Skip to content

Implementation plan / Session plan / Handover RC-4-S04

Handover RC-4-S04 Build: Scheduling and flow

Card: RC-4-S04. Issue: cema-care/his#171. Branch: session/RC-4-S04. Slice: RC-4. Decision record: ADR-HIS-123.

Comes after RC-4-S01, whose contracts it serves: flow.v1 1.1, with contract points 1 to 10 of RC-4-S04 in contracts/adm/README.md. It extends what RC-2-S06 built in MOD-ADM-008 (ADR-HIS-081). As a client, it uses registration.v1 1.2, encounters.v1, adt.v1, transfers.v1 and the D02 recovery API. No contract was changed.

What was built and where

MOD-ADM-008 in services/adm-scheduling-flow/mod-adm-008 now serves all 16 operations of flow.v1 1.1. The five new ones are registerEmergencyArrival, listEmergencyArrivals, readEmergencyArrival, recordEmergencyDisposition and requestAdmissionFromEmergency. QueueStateChanged is published at schema version 1.1, with reroute, disposition, admissionRequestId and emergencyArrival where they apply.

  • Rapid registration in one step (queue/Emergency.register, queue/ArrivalStore, migration V2__emergency_arrivals.sql; ADR-HIS-123 point 1):
  • the decision on adm.EmergencyArrival create, labelled unidentified-patient for an unidentified patient;
  • an arrival row is reserved by caller and Idempotency-Key, and holds the downtime form number, unique per facility;
  • then the person: the selected personId; or newPerson through registration.v1 registerPatient, completion: incomplete; or unidentified through registerUnidentifiedPatient;
  • then the encounter: encounters.v1 createEncounter, class EMER, source: emergency, started at the arrival time;
  • each call carries a key derived from the request's key and the step;
  • then the queue item, the completed arrival, the audit and the idempotency record, in one transaction.
  • An unavailable step answers 503 and the retry completes the arrival. A refused step is answered as it is and releases the reservation.
  • duplicateCheckPending is set for a new person without an answered duplicate check. registrationOutstanding comes from the registration's status.
  • Downtime back-entry (ADR-HIS-123 point 5):
  • the arrival time is the form's original time, which becomes the encounter's start and the item's arrivedAt;
  • a form already entered is refused on /downtimeEntry/downtimeFormNumber, "This downtime form has already been entered.", naming the arrival;
  • with a downtimeId, the original time must lie within that facility's declared window (recovery.v1);
  • the audit carries the provenance, both times, the form number and the window;
  • placement (decision on cema-care/his#171; ADR-HIS-123 point 6):
    • the item stays Arrived and unconfirmed, outside the live order and the routing;
    • the form's disposition closes it with no live placement;
    • it is a counted board row with a confirmation prompt, which is immediate for ATS 1 or 2;
    • place with the form's triage category confirms it, ordered by the time of confirmation; a routed category goes from Arrived straight to the routing's placement, never through Waiting (part 6.3; review round 3), with the confirming person as actor;
    • left before completion closes it;
    • Queues (unconfirmed, confirmation in act), Ordering.orderedFrom, FlowProjection.confirmPrompt, Emergency.dispose.
  • Triage routing (config/Definitions, config/QueueDefinition, queue/Queues.route; ADR-HIS-123 point 2):
  • a queue definition's triageRouting and emergency (flow.v1 1.1 Queue) are checked: scale codes only, one rule per category, only on triage queues;
  • a rule whose target is missing or inactive is left out on its own with a logged error; the triage queue stays in service and orders by category (review round 1);
  • the target and every queue that can route into it must have distinct ticket prefixes, or the rules into it are left out; a move whose number the target already holds that day is not made, so a number stays unique within the queue for the day (database constraint of V1 kept; review round 2);
  • a category with a rule, given at the door or on reassessment, moves the item to the target queue with a queue history entry (before and after), the event's reroute and an audit adm.queue.change "reroute";
  • with skipWaiting the item goes straight to In service, and at the door it never passes through Waiting;
  • ItemStore.update now writes the queue and service point columns, and a moved item keeps its number.
  • Closure only by disposition (Emergency.dispose, Queues.act, Queues.missedCall; ADR-HIS-123 point 3):
  • complete and cancel of an emergency item are refused with "Record the disposition.";
  • the no-response rule stops at Not present;
  • discharge and transfer need In service;
  • discharge, left before completion and death end the encounter with end-visit and the disposition, in the same step;
  • a transfer names a live transfers.v1 transfer of the encounter;
  • a disposition code that names another outcome is refused (admitted always);
  • from Awaiting bed, the open admission request is cancelled first through adt.v1 decideAdmissionRequest, with the outcome's reason; a request already admitted refuses the disposition (review round 1);
  • a patient sent on to diagnostics keeps the emergency item open, and the board shows Diagnostics at the emergency location.
  • Admission from emergency (Emergency.requestAdmission, Emergency.onEncounterEvent; ADR-HIS-123 point 4):
  • the request is forwarded to adt.v1 with fromEmergency, and admissionRequestId is recorded on the item, which stays In service;
  • the item, the board and readFlowState show Awaiting bed;
  • a second request is refused naming the open one;
  • PatientDischarged with the disposition admitted (subscription emergency-admission, unordered) closes the item as Completed, Admitted, with admittedEncounterId.
  • Emergency flow state on the item (Queues.emergencyFlowState): flowState on an emergency item is awaiting-triage, triage, waiting, consultation or awaiting-bed. It is absent once the item is closed.
  • Settings: his.flow.registration-url, adt-url, transfers-url, recovery-url and clock-tolerance (5m), in the unit's README.

Checks and their result

In services/adm-scheduling-flow, on the light profile under HIS_SESSION=RC-4-S04:

./gradlew build                                    # 173 tests: service-kit 36, mod-adm-007 65, mod-adm-008 68, app 4; none failed
./gradlew :mod-adm-008:test --tests '*EmergencyTest'      # 25 tests
./gradlew :mod-adm-008:test --tests '*FlowContractTest'   # 16 operations, his-contract verify: 0 failed; validate-event: passed (64)

The provider contract test now runs the five new operations: the documented request, the missing credential, the broken body, no X-Facility, a facility not permitted, and a record of another facility not shown. Their setup is registerEmergencyArrival, on the examples' day. For the disposition and the admission request, the test's filter adds ATS 1 to the setup arrival, so the item is In service at version 3, the contract's If-Match example. The published events include reroute, disposition, emergencyArrival and admissionRequestId, and all pass validate-event. Documentation: check_links.py and mkdocs build pass. Secret scan: platform/delivery-pipeline/bin/secret-scan code origin/main found nothing.

Requirements and test scenarios

All tests are in mod-adm-008/src/test/java/care/cema/his/adm/mod008/EmergencyTest.java, tagged FR-ADM-FLW-003 and TEST-ADM-026, unless named otherwise.

Criterion Test
AC-01, PR-FLW-003-1: Domain 1 steps complete with non-critical services stopped independentOfNonCriticalServices (person index down; no scheduling or notification call; registered, triaged, routed, admission requested, closed Admitted)
AC-02, PR-FLW-003-3: reassessment re-routes; both categories in the history reassessmentReroutes (also TEST-ADM-024), resuscitationAtTheDoor, brokenRoutingDegradesOnlyTheRouting
AC-03: unidentified patient registered, encounter and board unidentifiedArrival, simultaneousArrivals (also TEST-ADM-033)
AC-04, PR-FLW-003-2: two downtime forms, one entered twice downtimeBackEntry, downtimeTimes (TEST-ADM-036)
Back-entry placement, decision on #171 (TEST-ADM-036) backEntryClosedOnPaper, unconfirmedBackEntryIsVisibleNotLive, confirmedBackEntryPlacedByConfirmationTime, unconfirmedBackEntryLeft
Part 6.1 person selected, new or unidentified; part 10 "Duplicate check pending." knownAndNewPersons
One step, idempotent across a partial failure (ADR-HIS-118 point 1) partialFailureIsCompletedByTheRetry
Part 6.5, part 10, part 11: disposition, no closure without it noClosureWithoutDisposition, leftBeforeCompletion, otherDispositions, encounterEndFailures, diagnosticsKeepTheEmergencyItem, dispositionCodeMatchesOutcome, dispositionCancelsTheAdmissionRequest
Part 6.5, DEC-ADM-008: admission requested, Awaiting bed, Admitted admissionFromEmergency, admissionRefused
Part 12: audit with actor, original and recorded times, provenance unidentifiedArrival, downtimeBackEntry
IF-ADM-007 flow.v1 1.1 contract/FlowContractTest (tagged FR-ADM-FLW-003)

TEST-ADM-026 is verified at module level by the tests above. As the end-to-end resilience scenario, it is RC-4-E2E-001 and 004 of e2e/scenarios/RC-4, which RC-4-S06 runs once it adds the units to that stack.json. TEST-ADM-036 is verified for MOD-ADM-008's part: entries with their original times, no duplicate, and a list by form number for reconciliation. Reconciliation of downtime ADT and cross-references (FR-ADM-ADT-002, FR-ADM-XRF-001) belongs to other cards.

Non-functional targets:

  • NFR-ADM-005: a policy decision is taken before every step, with the Sensitive label for unidentified patients; facility scoping hides other facilities' arrivals and items; every change and read is audited.
  • NFR-ADM-009: flow.v1 1.1 passes the provider contract test, and the events pass validation.
  • NFR-ADM-012: the kit's correlation identifiers are passed on every downstream call, and failed steps are logged with their cause.
  • NFR-ADM-013: the service day follows his.flow.time-zone, and messages are the specification's.
  • NFR-ADM-014: instants are stored in UTC to the millisecond. Original and recorded times are kept apart, and a time ahead of the clock beyond clock-tolerance is refused.

Safety-critical functions

  • Triage routing and queue order (D01-ADM 11.1). The control as specified is rule-based ordering, re-routing on reassessment, and an authorized, audited override. Re-routing on reassessment is now built (ADR-HIS-123 point 2). It is verified by reassessmentReroutes and resuscitationAtTheDoor here, and by the TEST-ADM-024 tests of QueuesTest, which still pass.
  • Emergency intake (D01-ADM 11.1). The control as specified is independence from non-critical modules and provisional registration. It is verified by independentOfNonCriticalServices, unidentifiedArrival, knownAndNewPersons, partialFailureIsCompletedByTheRetry and brokenRoutingDegradesOnlyTheRouting. Queue numbers are never repeated by a move: routingIntoAQueueNeedsDistinctPrefixes, moveNeverRepeatsANumber. A broken routing rule never takes the triage queue out of service.

Safety condition of the #171 decision, for the safety review: unconfirmed downtime back-entries are counted on the emergency board and never silently dropped, and an ATS 1 or 2 form is flagged for immediate confirmation. Tested by unconfirmedBackEntryIsVisibleNotLive. With it, the review should look at the routing rules that are only logged (follow-ups).

No control was changed from its hazard log entry, so the hazard log is unchanged. The routing semantics (moving items already in service) and the closure rules are named for the safety review below.

Done differently from the specification or contract

  • Item flow state while sent to diagnostics. QueueStateChanged carries no link between items, so Diagnostics is derived from an emergency item in service plus a later open item of the same encounter elsewhere (ADR-HIS-123 point 3). The patient stays on the emergency board at the emergency location, not the laboratory's, so the patient does not drop off the emergency board.
  • Read-only downtime mode of the shell (part 10) is a screen concern. The unit accepts entries whenever it is reachable.

Questions left for a person

Answered on cema-care/his#171 (2026-12-02), and built: where a downtime back-entry lands in the live queue. The repository owner, for clinical governance, chose options 4, then 3, then 2 (ADR-HIS-123 point 6): - a form that closed the episode is recorded with its disposition and no live item; - otherwise the entry waits, visible, on the list to confirm; - once confirmed, it is placed by category and then the time of confirmation.

Open and non-blocking: Clinical governance should confirm, in the safety review, that a routing rule moves an item already in service (ADR-HIS-123 point 2). D10 terminology governance should confirm the cancellation reason codes and may bind disposition codes to outcomes (point 3).

Follow-ups outside this card

  • ADM contract session (flow.v1): a row Indicator of its own for unconfirmed downtime back-entries, for example downtime-unconfirmed and confirm-immediately. The enum is extensible, so the addition is compatible. Until then the board carries the prompt in subStatus and counts the rows under awaiting-triage (ADR-HIS-123 point 6). The emergency screen can also show the list to confirm from listQueueItems state=arrived.
  • Configuration (D10 configuration.v1, CFG-ADM-019): a routing rule that MOD-ADM-008 cannot apply is only logged. That covers a missing or inactive target and prefixes that meet. ATS 1 patients then stay, first in order, in the triage queue, and nothing is shown to staff. Such a definition should be refused, or flagged, where it is set, and the "Triage routing and queue order" safety review should note this (review round 2).
  • RC-4-S06 (integrate):
  • add adm-scheduling-flow, adm-patient-administration and adm-identity to e2e/scenarios/RC-4/stack.json;
  • in the RC-4 flow configuration, mark igd-triage and igd-resusitasi emergency, give igd-triage its triageRouting (ATS 1 to igd-resusitasi, skipWaiting: true), and make the resuscitation service point a unit of board igd;
  • set his.flow.registration-url, adt-url, transfers-url and recovery-url.
  • D10: register the resource type adm.EmergencyArrival (create, view, query) and the actions record-disposition and request-admission on adm.QueueItem.
  • Queue configuration (CFG-ADM-019): the emergency board should list the diagnostics service points only if the facility wants those queues shown there. An emergency patient in diagnostics is already shown at the emergency location.
  • A pending arrival whose request is never repeated leaves a person and an encounter without a queue item. A worklist of pending arrivals older than a threshold could be added to MOD-ADM-008's rules.