Architecture / Decision records / ADR-HIS-123
ADR-HIS-123 The emergency workflow in adm-scheduling-flow: the arrival reserved before its steps, routing by triage category, closure only by disposition, and Admitted from the encounter event¶
| Status | Accepted |
| Decided | 2026-12-02 by session RC-4-S04 |
| Record | Drafted 2026-12-02; awaiting approval by the Enterprise Architecture Board |
| Where the rule lives | services/adm-scheduling-flow/mod-adm-008 (queue/Emergency, queue/ArrivalStore, queue/Queues routing, config/Definitions, board/FlowProjection (Awaiting bed, Diagnostics, closed by disposition), ports/RegistrationService, ports/AdtService, ports/DowntimeWindows, migration V2__emergency_arrivals.sql); the unit's README |
Context¶
FR-ADM-FLW-003 covers emergency arrival, rapid registration, triage routing and the disposition hand-off. Its contract is flow.v1 1.1 (ADR-HIS-118; contract points of RC-4-S04 in contracts/adm/README.md). It carries two safety-critical functions of D01-ADM 11.1, "Triage routing and queue order" and "Emergency intake". MOD-ADM-008 (ADR-HIS-081) owns queues and boards but not persons, encounters or admission requests. Building the workflow here leaves these questions open:
- How one request makes a person, an encounter and a queue item in three services and stays idempotent as a whole, with no partial arrival and a downtime form number that is never entered twice, even by two clerks at once.
- What a triage routing rule does to an item already in service, to an item routed at the door, and to a rule whose target queue is not served; and how a disposition meets an open admission request.
- How "an emergency item closes only with a disposition" holds against the queue's other paths: the actions complete and cancel, and the no-response rule.
- Where "Admitted" comes from, since an admission request is no disposition and the confirmation happens on the encounter and ADT console of adm-patient-administration.
- Which times a downtime entry may carry.
- Where a downtime back-entry lands in the live queue. The specification is silent; the question was answered by the repository owner for clinical governance on cema-care/his#171 (2026-12-02).
- How the policy decision point learns that an arrival or a person is unidentified.
Decision¶
- The arrival is reserved first and completed last. registerEmergencyArrival takes the policy decision, then reserves an
emergency_arrivalrow in its own short transaction. The row is keyed by the caller and the Idempotency-Key, and carries the form number, unique per facility. The person (registration.v1, or the selected person read from the index) and the encounter (encounters.v1 createEncounter, classEMER, sourceemergency, started at the arrival time) are then made. Each call uses a key derived from the caller, the request's key and the step (a name-based UUID), so a repeat returns what the first call made. The queue item, the completion of the row, the audit and the idempotency record then commit in one transaction. While a step is unavailable the answer is 503 and the row stays pending: it is not listed, not readable and not on the board, and the retry with the same key completes it. A step refused by its service (400, 403) is answered as it is and releases the pending row, so the corrected entry may take the form number. A form number held by another arrival is refused on/downtimeEntry/downtimeFormNumber, "This downtime form has already been entered.", naming the arrival, or saying that it is still pending and should be completed by repeating its request. Locking across the downstream calls was rejected: it would hold a row lock for the length of two remote calls during a mass-casualty surge. The location is not sent to createEncounter, because the item's service point is not a registry location of the encounter and the encounter unit checks it against the D10 registry. - Routing follows the category wherever the item is. A definition's
triageRoutingnames, per category of the facility's triage scale, a target queue andskipWaiting. A category with a rule moves the item to the target queue with its number, history and encounter. The move is a priority change of the attributequeuewith before and after, an event withreroute, and an auditadm.queue.change"reroute". The item is then In service withskipWaiting, Waiting if it moved out of another state, and otherwise keeps its state. This applies to items in service too, since a deteriorating patient in a consultation room is moved to resuscitation. A category given at the door is placed by the routing alone, so an item routed into service never passes through Waiting (part 6.3). A routing rule may name only a scale code, once per category, and only on a triage queue. Its target must be an active queue of the facility. A moved item keeps its number, and the number stays unique within the queue for the service day (FR-ADM-FLW-001 part 6.1, D01-ADM 7.3). The database constraint of V1 is kept, and three things ensure a move never breaks it. First, the target and every queue that can route into it, directly or through other queues, must have distinct ticket prefixes; where two meet, the rules into that target are left out. Second, the move is checked under the target's counter lock. Third, a move whose number the target already holds that day (possible only while a configuration change is applied) is not made: the category is recorded and "reroute-not-applied" is audited with the reasonqueue-number-held. A rule that fails any of these checks is left out on its own, and the error is logged; the triage queue stays in service. Emergency intake and the actions on open triage items never depend on the routing (D01-ADM 11.1, "Emergency intake"). Without the rule, the category is still recorded and orders the item at the head of the triage queue by the scale. Taking the whole triage queue out of service was rejected: it would refuse every emergency arrival and every action on its open items because of one wrong routing target. In the same way, a target that cannot be read when a category is set leaves the item where it is, records the category and audits "reroute-not-applied", instead of refusing the triage change. - An emergency item closes only through recordEmergencyDisposition or Admitted. On a definition with
emergency: true, the actions complete and cancel are refused with "Record the disposition." (part 10). The no-response rule stops at Not present and never cancels. A linked arrival elsewhere (the patient sent to the laboratory or imaging) does not move the emergency item on. The emergency item stays In service, and the projection shows the patient in Diagnostics at the emergency item's location, so the patient stays on the emergency board until the disposition. The event of the linked item carries no link, so the projection derives this from an emergency item in service and a later open item of the same encounter. Discharge and transfer need the item In service, while left before completion and death are accepted from any open state. Discharge, left before completion and death end the encounter with end-visit and the disposition code, before the item is closed, with a derived key. An encounter already ended is not ended again, so a retry after a partial failure completes. A transfer names a transfers.v1 transfer of the same encounter that is not rejected, cancelled or corrected, and leaves the encounter to the transfer.completedAtis the disposition's effective time. A disposition code that names another outcome is refused:admittedis never recorded here (D01-ADM 7.3: admitted only from "Admit from emergency"), anddeathandleft-before-completiononly with that outcome. The rest of the value set per outcome is for D10 terminology governance. An item in Awaiting bed may be given a disposition, since D01-ADM 4.3 lets Awaiting bed leave the board "with a disposition". Its open admission request is cancelled first, with adt.v1 decideAdmissionRequest and a derived key, which also releases any bed held for it. The reason follows the outcome, from adt.v1's governed list: admission no longer needed (discharge), patient transferred elsewhere (transfer), patient left (left before completion), death. The codes areadmission-no-longer-needed,patient-transferred-elsewhere,patient-leftanddeathinurn:his:adm:admission-request-cancellation-reason, with the text. A request already cancelled is not cancelled again. A request already admitted refuses the disposition, because that item closes with Admitted from the encounter event (point 4). The cancellation is audited asadm.adt.change. - The admission request is a flow state; Admitted comes from PatientDischarged. requestAdmissionFromEmergency forwards the request to adt.v1 with
fromEmergency, the item's encounter and a derived key, and recordsadmissionRequestIdon the item, which stays In service. The board and readFlowState then show Awaiting bed: the projection derives it fromadmissionRequestIdon the event. A second request for the item is refused naming the open one. When "Admit from emergency" is confirmed, adm-patient-administration publishes PatientDischarged with the dispositionadmittedandcontinuedByEncounterId. The subscriptionemergency-admissioncloses the open emergency item of that encounter as Completed with the outcomeadmittedandadmittedEncounterId, and the event's actor stays the recorder. The subscription is unordered: it acts on that one event type, on open items only, and the inbox discards a redelivery. - A downtime entry carries the form's time, never a later or impossible one. The arrival time must equal the form's original time, which becomes the item's
arrivedAtand the encounter's start. Neither the arrival nor the original time may lie more thanclock-tolerance(5 minutes) after the unit's clock. With adowntimeId, the original time must lie within the declared window of that facility, read from the D02 recovery API. If that API is unavailable the entry answers 503 rather than skipping the check. The recorded time is the time of entry. The audit carries the provenance, both times, the form number and the window. - A downtime back-entry is never placed live by itself (decision on cema-care/his#171: options 4, then 3, then 2). Its queue item stays Arrived, internally marked unconfirmed. It has no position, it cannot be called, and the triage routing is not applied, whatever category the form gives. A triage change records the category without placing the item.
- Closed on paper. When the form records the episode's end, the disposition is recorded on the unconfirmed item with recordEmergencyDisposition, which accepts any outcome for it, and the item closes without ever being Waiting. An admission on paper closes it with Admitted from PatientDischarged, as in point 4.
- To confirm. The list to confirm is the emergency queue's Arrived items (listQueueItems
state=arrived), alongside listEmergencyArrivalsprovenance=downtime-entry. On the emergency board each unconfirmed entry is a row, counted underawaiting-triage, with thesubStatus"Downtime entry: confirm the patient is still in the department". An ATS 1 or 2 form reads "Downtime entry, ATS n: confirm now that the patient is in the department". None is dropped. - Confirmed. Staff confirm with the action
place, which needs the form's triage category. The item is then ordered by category and then the time of confirmation, not the original arrival, andpriorityBasisshows that time as itsarrival-time. The originalarrivedAtis kept. The queue's routing then applies. A category the queue routes goes from Arrived straight to the routing's placement, so ATS 1 is In service in resuscitation without passing through Waiting (part 6.3), as at the door. The confirmation and the move are recorded with the person who confirmed as actor. Confirmation is audited asdowntime-confirm. - Left. A patient who has left is closed with recordEmergencyDisposition, outcome left before completion. It is audited and ends the encounter.
This stays within flow.v1 1.1. A board indicator of its own for unconfirmed back-entries, Indicator being an extensible enum, is a contract addition for the ADM contract session.
7. The decision point is told about unidentified patients. registerEmergencyArrival with unidentified, and readEmergencyArrival of an unidentified person, carry the label unidentified-patient (D01-ADM 9.3), as ADR-HIS-122 point 8 does. The resource type is adm.EmergencyArrival (create, view, query). The disposition and the admission request are checked as record-disposition and request-admission on adm.QueueItem.
Consequences¶
- D10 terminology must publish the cancellation reason codes of point 3, and may bind the disposition codes to the outcomes beyond the check of point 3.
- D10 must register the resource type
adm.EmergencyArrivaland the actionsrecord-dispositionandrequest-admissiononadm.QueueItem. Until it does, a real decision point denies them. - The facility's queue configuration (CFG-ADM-019) must mark the emergency queues
emergencyand give the triage queue itstriageRouting. The resuscitation queue's service point must be a unit of the emergency board. Until then emergency items behave as ordinary queue items. - The unit calls four more services: registration.v1, adt.v1, transfers.v1 and recovery.v1 (settings
registration-url,adt-url,transfers-url,recovery-url). Only Domain 1 Tier 1 services and D02 are on the emergency path (part 6.6). A missing URL answers 503 for the step that needs it, never a partial arrival. - A request that fails for good after its person or encounter was made leaves a pending arrival row and an unattached person or encounter. The registration remains on the incomplete-registrations worklist, and the person on the unidentified worklist where unidentified. Repeating the original request completes the arrival.
- The safety review of "Emergency intake" and "Triage routing and queue order" covers the safety condition of point 6, which is that unconfirmed back-entries are counted on the board, never dropped, and ATS 1 or 2 flagged for immediate confirmation, together with the logged-only routing rules of point 2.
- Clinical governance reviews the routing semantics of point 2 (moving items in service) and the closure rules of point 3 on the merged work, as part of the safety review of the two safety-critical functions.