Implementation plan / Session plan / Handover RC-2-S06
Handover RC-2-S06 Build: Scheduling and flow (part 2 of 2)¶
Card: RC-2-S06. Issue: cema-care/his#51. Branch: session/RC-2-S06. Slice: RC-2. Decision record: ADR-HIS-081.
What was built and where¶
MOD-ADM-008 in services/adm-scheduling-flow/mod-adm-008 serves all 11 operations of flow.v1 (IF-ADM-007). It publishes QueueStateChanged (EVT-ADM-023) on his.adm.encounterflow.v1, aggregate EncounterFlow, with the encounter as aggregate id, sequenced per encounter through the outbox. Its packages are listed in the unit's README.md.
- Definitions (
config): - the queues (CFG-ADM-019, CFG-ADM-020) and boards (CFG-ADM-021) of a facility are read from D10
configuration.v1resolveConfiguration, item typesadm.queue-definitionsandadm.flow-boards, keydefault, or from a file where no URL is set; - checked before use, cached for 30 s, and the last definitions read are kept through an outage (ADR-HIS-081 point 2);
- a rule naming
urgencyis not served (point 3, Q-S06-1 below). - Arrivals and queues (
queue, FR-ADM-FLW-001): - Arrival of each of the five types into an active queue that accepts it, checked against encounters.v1 (an open encounter of the facility):
- the queue number
<prefix>-<nnn>per queue and service day; - Arrived, then placed by the system: Triage with
awaitingTriageon a triage queue without a category, otherwise Waiting; - PR-FLW-001-2 refused naming the existing item;
- one active item unless a queue allows parallel queues;
linkedFromcompletes the item the patient moves on from;- one item per Idempotency-Key.
- the queue number
- Order by the queue's rule as a sort key (triage level, priority flag, appointment time within the window, arrival time; then first come, first served). The position is derived on every read, with
priorityBasis(point 4). - Past order:
listQueueItems?asAtrebuilds the order at any past time from the history rows (AC-04). older-adultis derived from the person's date of birth (60 or more, counted conservatively for a partial date), is never set or removed by hand, and is derived later if the person index was down (point 6).- Actions
actOnQueueItem: only the transitions of section 4.3, each refused from another state with its own message; If-Match; Idempotency-Key.startnames the called patient: missing or another patient is refused with "Ask the patient's name and date of birth, then start service for …" (AC-06).- An out-of-order call needs a reason. Passing over a higher triage category also needs
overrideauthority and a person ("Supervisor authority required."). No position moves (Q-RC2-3).
- Priority changes
changeQueuePriority:- a triage category (by
triage, on triage queues only; an item in Triage is then placed); - priority flags;
- the supervised override: a reason, "Supervisor authority required." without authority, shown on the item, and sorted just ahead of the item named.
- a triage category (by
- The no-response rule of CFG-ADM-020, run by the unit:
- the first missed call returns the item to Waiting, the second sets Not present;
- Cancelled "not present" at the configured number of calls.
- The public call display: queue numbers and service point only.
- Check-in:
mod007.api.QueueArrivalsis implemented (CheckInArrivals), so check-in creates the item with the appointment, ordered by the slot time within the window. A start or completion moves the appointment throughmod007.api.AppointmentProgress. - Flow boards (
board, FR-ADM-FLW-002): - Projection. The flow-state projection subscribes, ordered, to its own QueueStateChanged, the encounter events of adm-patient-administration and the appointment events of MOD-ADM-007.
- It keeps every input (
flow_input) and folds each encounter's state from them in business-time order (PR-FLW-002-1). FlowProjection.rebuildfolds every encounter again (part 6.7).- It measures
his.flow.projection.lag(point 12).
- It keeps every input (
- Flow states (point 10): awaiting triage, triage, waiting, consultation (In service), pending discharge, discharge (PatientDischarged); a cancelled encounter leaves.
- Boards show rows by unit, with:
- name and No. RM, or initials on a wall display;
- state and time in state, location, triage category and queue number;
- counts per state that reconcile with the queue (AC-04);
- the last-updated time and
stale/staleMinutes. The last-updated time is how far the projection is behind, by a watermark on each feed (point 11, review round 1): own queue and appointment events not yet applied (a stalled relay or consumer), and queue items whose EncounterOpened has not arrived (a stalled or silent encounter feed). A board is stale once that age passes the threshold, and at once on a sequence gap;staleMinutesis at least 1. No backlog ages out: a feed silent for days keeps the board stale (review round 2). - The
diagnosticscolumn is answerednot-current: no D03/D04 event contract exists yet (PR-FLW-002-3; point 9).
readFlowStateacross facilities follows the policy decision point, withresourceFacility(Q-RC2-1).- Wall displays are service identities named in a board's
displays(point 13):- they get their boards only, with their privacy setting;
- any other board, patient detail, queue list or write is 403 and audited;
- views are logged per device, board and hour, not per patient.
- Audit:
adm.queue.changefor the arrival, every state change, priority change, override, assignment and no-response step, with before, after, reason and actor;adm.person.viewper patient for queue reads and the flow state;- board and call-display views once per caller, board and hour.
- Migration
V1__queues_and_flow.sql, schemamod_adm_008.
Elsewhere in the unit:
- mod-adm-008/build.gradle.kts depends on :mod-adm-007 (its api only).
- app/src/test/.../ModuleWiringTest.java checks that check-in uses MOD-ADM-008's queue.
- README.md lists the MOD-ADM-008 packages, subscriptions and his.flow.* settings.
- No dependency was added, and the lockfiles are unchanged.
Outside the unit: docs/architecture/decisions/ADR-HIS-081.md and its row in the index (81 records).
Checks and their result¶
The integration environment ran as HIS_SESSION=RC-2-S06 (his-rc-2-s06), light profile.
| Check | Command | Result |
|---|---|---|
| Build and every test of the unit | ./gradlew build in services/adm-scheduling-flow |
passed: 133 tests (MOD-ADM-008 37, of which 12 are the contract test's; MOD-ADM-007 65; kit 27; app 4 with the module boundary and wiring tests) |
| Provider contract test | ./gradlew :mod-adm-008:test --tests '*FlowContractTest' |
passed: all 11 operations of flow.v1 pass his-contract verify contracts/adm, 50 cases (the documented request, no credential, broken body, no X-Facility, a facility not permitted, a record of another facility hidden); the 28 QueueStateChanged events published pass his-contract validate-event |
| Dependency scan and SBOM | platform/delivery-pipeline/bin/dependency-scan services/adm-scheduling-flow |
0 blocking (5 medium) |
| Image scan | platform/delivery-pipeline/bin/image-scan services/adm-scheduling-flow |
0 blocking (15 low, 117 medium) |
| Static analysis | platform/delivery-pipeline/bin/static-analysis services/adm-scheduling-flow |
no blocking finding |
| Secret scan | platform/delivery-pipeline/bin/secret-scan code origin/main HEAD and docs |
no secret; no exception file added |
| Documentation | check_links.py; mkdocs build |
0 broken links, 0 duplicate anchors; site builds |
No contract changed: contracts/adm is untouched.
Requirements and test scenarios¶
Every test carries @Tag with its requirement and scenario, and its display name starts with them. They are in services/adm-scheduling-flow/mod-adm-008/src/test/java/care/cema/his/adm/mod008/.
| Requirement, criterion | Test |
|---|---|
| FR-ADM-FLW-001 AC-01 the five arrival types into queues that accept them; queue numbers per day; events per encounter | QueuesTest.fiveArrivalTypes |
| FR-ADM-FLW-001 AC-02 a later higher-priority arrival ordered ahead; PR-FLW-001-1 and PR-FLW-003-3 re-triage re-orders and keeps the prior category (tagged TEST-ADM-026) | QueuesTest.triageOrdering |
FR-ADM-FLW-001 AC-02 the clinic rule (flags, appointment window, arrival); older-adult derived and not removable (Q-RC2-2) |
QueuesTest.clinicRule, CheckInArrivalsTest.checkInOrdersByAppointmentTime |
| FR-ADM-FLW-001 AC-03 override stored and visible; without authority 403 audited; without reason 400 | QueuesTest.override |
| FR-ADM-FLW-001 AC-04 order at a past time rebuilt | QueuesTest.orderAsAt |
| FR-ADM-FLW-001 AC-05 PR-FLW-001-3, -4 no response, Not present, recall, Cancelled after three calls | QueuesTest.noResponse |
| FR-ADM-FLW-001 AC-06 start from the panel naming the called patient; call display shows the queue number only | QueuesTest.startFromThePanel |
| FR-ADM-FLW-001 part 10 awaiting triage, invalid state actions, cancel reason | QueuesTest.awaitingTriage |
| FR-ADM-FLW-001 BR-ADM-018 Q-RC2-3 out-of-order call | QueuesTest.outOfOrderCall |
| FR-ADM-FLW-001 PR-FLW-001-2 part 6.6 duplicates, one active item, linked items | QueuesTest.duplicatesAndLinkedItems |
| FR-ADM-FLW-001 parts 7, 12 validation, Idempotency-Key, If-Match, audit, events without demographics | QueuesTest.validationAndAudit, QueuesTest.undefinedAttribute |
| FR-ADM-FLW-001 BR-ADM-025 check-in through the port; appointment progress | CheckInArrivalsTest, app/.../ModuleWiringTest |
| FR-ADM-FLW-002 AC-01 the change on the board once delivered (p95 under 5 s in process; NFR-003 at integration) | FlowBoardsTest.latency |
| FR-ADM-FLW-002 AC-02 states in turn; PR-FLW-002-3 not-current column; part 9 read model | FlowBoardsTest.statesInTurn, FlowBoardsTest.emergencyStates |
| FR-ADM-FLW-002 AC-03 PR-FLW-002-2 BR-ADM-024 own feed interrupted (relay, consumer): behind under the threshold, stale past it, with the last-updated time; a quiet board current | FlowBoardsTest.feedInterrupted |
| FR-ADM-FLW-002 AC-03 BR-ADM-024 the inbound encounter feed stops: stale after the threshold, current when it resumes | FlowBoardsTest.upstreamFeedStops |
| FR-ADM-FLW-002 AC-03 BR-ADM-024 an unapplied event and an unmatched queue item older than a day keep the board stale | FlowBoardsTest.stalledForDays |
| FR-ADM-FLW-002 PR-FLW-002-1 out of order held and applied in sequence; redelivery without effect | FlowBoardsTest.outOfOrder |
| FR-ADM-FLW-002 AC-04 counts reconcile; part 6.7 rebuild gives the same | FlowBoardsTest.countsReconcileAndRebuild |
| FR-ADM-FLW-002 AC-05 wall display: initials, other board and patient detail denied and audited, logged per device and board | FlowBoardsTest.wallDisplay |
| FR-ADM-FLW-002 part 13 Q-RC2-1 flow state across facilities by policy; boards hidden | FlowBoardsTest.acrossFacilities |
| IF-ADM-007, EVT-ADM-023 | contract/FlowContractTest |
Test scenarios:
- TEST-ADM-024 is QueuesTest with CheckInArrivalsTest.
- TEST-ADM-025 is FlowBoardsTest.
All pass.
Safety (card "Safety" row): - Triage routing and queue order is verified by TEST-ADM-024 above: - rule-based ordering; - re-routing on reassessment, with the prior category kept; - the authorized, audited override; - an out-of-order call past a higher triage category only with supervisor authority.
TEST-ADM-026 belongs to FR-ADM-FLW-003 (emergency rapid registration and disposition), which is not on this card. Its re-triage part (PR-FLW-003-3) is covered by QueuesTest.triageOrdering, tagged TEST-ADM-026 and FR-ADM-FLW-003.
Open for the gate: the rest of TEST-ADM-026, the parts of FR-ADM-FLW-003 that no RC-2 card builds: - rapid registration with a provisional identity (part 6.1); - routing of resuscitation-level categories straight to the resuscitation queue (part 6.3); - disposition closing the emergency item, and "Awaiting bed" (part 6.5); - independence from non-critical modules, verified with those stopped (part 6.6, PR-FLW-003-1); - downtime entry without duplicates (part 6.7, PR-FLW-003-2). - Flow boards are verified by TEST-ADM-025: - the last-updated time and stale indicator; - a rebuildable projection.
Both controls are built as D01-ADM 11.1 states them. No existing control was changed, so no hazard log entry changes. The safety review is under "Needs a person" in the pull request.
Non-functional targets designed for:
- NFR-ADM-005:
- the decision point on every operation;
- facility scope;
- wall displays limited by the service;
- audit;
- no names in events or audit.
- NFR-ADM-009: the contract and its event, checked by the contract test.
- NFR-ADM-012:
- the kit's correlation identifier and telemetry;
- the timer his.flow.projection.lag with p95.
- NFR-ADM-013: the service day in the facility time zone; texts as the contract gives them.
- NFR-ADM-014: instants in UTC to the millisecond, with the business time in each event.
Done differently from the specification or contract, and why¶
urgencyis not applied (ADR-HIS-081 point 3). A queue whose rule names it is not served. The specification does not define it (Q-S06-1).- No Domain 3 or Domain 4 inputs (point 9). No D03/D04 event contract exists, so the diagnostics state and sub-status are not derived, and the
diagnosticscolumn isnot-current(PR-FLW-002-3, which is the specified behaviour when that feed is unavailable). - Freshness without a heartbeat (point 11). No contract has a heartbeat event, so the encounter feed is watched through queue items, which witness that an encounter exists. A change of an encounter that has no queue item is not watched.
- Fields without an RC-2 source are left empty:
- restricted-location labels (part 13);
- beds (
initials-and-bedshows initials only); - row indicators (isolation, pending transfer, unacknowledged handover);
- the responsible team.
ADT, transfers and location labels come with RC-3 and D10.
- "Closed at the end of the clinic session" (CFG-ADM-020) is not applied: no clinic session data reaches this module. The count of calls is applied.
- Completed with nothing open is pending-discharge until the encounter ends (point 10). For an outpatient this is the time between the last service and the end of the visit.
- Board views by staff and displays are logged once per caller, board and hour, not on every refresh (point 13). The specification's "per display device and board" is kept, and the audit is not flooded by refreshes.
- The contract test gives each setup arrival a new encounter (FlowContractTest.FreshEncounters). verify repeats the setup recordArrival with the example's encounter, which PR-FLW-001-2 would refuse after the first. The rule is tested in QueuesTest.
Questions for a person¶
| # | Question | In the code until answered |
|---|---|---|
| Q-S06-1 (clinical, queue order; on #51) | What does the priority attribute urgency of CFG-ADM-019 order by, and in which order of values? |
A queue whose rule names it is not served (logged). No default rule uses it, so it blocks nothing on this card. |
Follow-ups outside the card¶
- D10 registrations before the unit goes live:
- the configuration item types
adm.queue-definitionsandadm.flow-boardswith the content of ADR-HIS-081 point 2, includingdisplaysandticketPrefix; - the policy actions of point 8 on
adm.QueueItemandadm.FlowBoard; - the wall-display service identities with their boards (FR-ESS-IAM-003);
- the audit type
adm.queue.change; - the code systems
urn:his:adm:triage-scale(CFG-ADM-028),urn:his:adm:queue-override-reason,urn:his:adm:queue-cancellation-reasonandurn:his:adm:queue-change-reason. - RC-2-S10 (integrate):
- add
adm-scheduling-flowtoe2e/scenarios/RC-2/stack.json; - set
his.flow.encounters-url,patient-identity-url, andconfiguration-url(orconfiguration-file); - measure
his.flow.projection.lagp95 against NFR-003 (AC-01). - D03 and D04 contract sessions: OrderPlaced, OrderCancelled, OrderDiscontinued, OrderCompleted (EVT-CLI-012, 014 to 016), FulfilmentOrderStatusChanged and ImagingAcquisitionStatusChanged (EVT-ANC-002, 009). The projection then subscribes and derives diagnostics.
- RC-3 (ADT, transfers, beds): the admission and awaiting-bed states, beds for
initials-and-bed, pending-transfer and isolation indicators, and the emergency queue item's disposition (FR-ADM-FLW-003, TEST-ADM-026). - ADM contract session (next minor version of
flow.v1): - perhaps a
displaysfield onFlowBoardfor administration screens; - a definition of
urgencyonce Q-S06-1 is answered. - Service template: none beyond RC-2-S05's.
- Design system: none from this session.