Skip to content

Implementation plan / Session plan / Handover RC-3-S08

Handover RC-3-S08 Build: Patient administration (part 3 of 3)

Card: RC-3-S08. Issue: cema-care/his#64. Branch: session/RC-3-S08. Slice: RC-3. Decision record: ADR-HIS-104.

Comes after RC-3-S07, whose beds.v1 and bed ledger the transfer moves patients between. It also builds on RC-3-S06 (the ADT transactions and the responsibility periods) and RC-2-S04 (the encounter and its history).

The contract served is transfers.v1 1.0 of RC-3-S02 (handover), with contract points 1 to 7 of RC-3-S08 in contracts/adm/README.md. RC-3-S03's handover holds the scenario RC-3-E2E-002, which uses it. No contract was changed.

What was built and where

All of it is in services/adm-patient-administration, plus ADR-HIS-104, its index row and this handover. The unit's README.md lists every module, setting and stand-in. With MOD-ADM-009, every module of the unit is built.

Module What was added
mod-adm-009 (new; FR-ADM-TRF-001, FR-ADM-TRF-002) transfers.v1, all 9 operations (web/TransferController).
  • Transfers: request, list, read, accept, reject and cancel, and the handover actions give and change-receiver.
  • Arrivals: the confirmation as one governed transition, within a facility and between facilities, the urgent path, and the correction.
  • Responsibility: changeResponsibility and readResponsibilityTimeline with asAt.
  • Handovers: the acknowledgement from EVT-CLI-011 through the port api.ClinicalHandovers, and the CFG-CLI-021 escalation scan.
  • TransferBeds: the transfers' side of bed reservations, including a destination bed lost.
  • TransferStore, TransferRecords, TransferGuard and Idempotency.
Migration V1__transfers.sql (schema mod_adm_009). Lockfile gradle.lockfile: no dependency version new to the unit
mod-adm-005 Port api.ResponsibilityTimeline, implemented by Responsibilities. It now also publishes ResponsibilityChanged for every cause, with transferId.
Port api.TransferAdmissions (TransferAdmissionSteps): the discharge and admission steps of Adt for a transfer between facilities. Adt.discharged is extracted from recordDischarge, unchanged in behaviour.
Migration V2__responsibility_timeline.sql: a period's location, transfer and the sequence it corrects
mod-adm-004 api.EncounterRecords:
  • the transition transfer is written as the history entry type "Transferred";
  • correctTransition writes the "Corrected" entry and publishes EncounterCorrected 1.1 with reversedTransition: transfer;
  • openContinuation can open the linked encounter at another facility.
mod-adm-006 BedOccupancy.transfer: both rooms locked in one order, the hard rules for an Available destination with the patient's isolation need, origin to Cleaning, destination to Occupied.
Ports api.TransferReservations (implemented by MOD-ADM-009) and api.D10Notifications (implemented by D10Requests).
beds.v1 reserveBed for a transfer:
  • a transfer between facilities reserves at the receiving facility;
  • the isolation need comes from the origin bed or the admission request.
Bed.pendingTransferId on reads. Reservation carries transferId. The unused default ReservationPurposes.transfer is removed
app The provider contract test covers the 9 transfers.v1 operations beside the 50 of before. AdmissionJourneyTest (TEST-ADM-035) now takes the patient through a transfer between the return from leave and the discharge
mod-adm-002 test fixtures AdmTestSupport clears mod_adm_009 too

Events published on his.adm.encounter.v1, ordered per encounter: - PatientTransferred; - TransferHandoverAcknowledged; - ResponsibilityChanged, with the causes transfer, responsibility-change and correction; - EncounterCorrected 1.1, with reversedTransition: transfer; - for a transfer between facilities: PatientDischarged with continuedByEncounterId, then EncounterOpened and PatientAdmitted.

BedStateChanged (transfer-out, transfer-in, correction) goes on his.adm.bed.v1.

Notifications go through D10 (notification.v1, queued in the transaction): adm.transfer-requested, adm.transfer-accepted, adm.transfer-rejected (new), adm.transfer-completed, adm.transfer-bed-lost and adm.handover-escalation.

Policy: the actions of ADR-HIS-104 point 4 on adm.Transfer and adm.Encounter, for D10 to register (follow-ups).

Checks and their result

The integration environment ran as HIS_SESSION=RC-3-S08 (his-rc-3-s08), light profile.

Check Command Result
Build and all tests ./gradlew build --rerun-tasks in services/adm-patient-administration passed, 212 tests:
  • mod-adm-002: 45;
  • mod-adm-004: 22;
  • mod-adm-005: 61;
  • mod-adm-009: 17, all new (TransferTransitionTest 13, ResponsibilityHandoverTest 4);
  • mod-adm-010: 17;
  • app: 14, the journey of TEST-ADM-035 now with the transfer;
  • kit: 36, one skipped (the Kafka adapter, full profile only).
Provider contract test ProviderContractTest (tag contract): his-contract verify contracts/adm --operation <each of the 59> against the unit, with a token permitted for RSU-01 and RSU-02 and denied otherwise; then his-contract validate-event on everything published, PatientTransferred included passed, 252 of 252 cases, the facility cases included; validate-event passed
Consumer contract test ConsumerContractTest passed, no violation; no client was added (notifications go through the existing notification.v1 client)
Static analysis platform/delivery-pipeline/bin/static-analysis services/adm-patient-administration no blocking finding; no clinical artifact
Secret scan platform/delivery-pipeline/bin/secret-scan code origin/main HEAD; secret-scan docs origin/main HEAD no secret, in the files or in the commits
Dependency scan platform/delivery-pipeline/bin/dependency-scan services/adm-patient-administration 0 blocking (9 medium; RC-3-S07 recorded 8, and this card added no dependency, so the ninth is a new advisory on an existing one)
Documentation python3 docs/implementation_plan/tools/check_links.py; mkdocs build 0 broken links, 0 duplicate anchors; the site builds

Requirements and test scenarios

Tests carry the requirement and scenario tags (session rule 5). The classes are in mod-adm-009/src/test/java/care/cema/his/adm/mod009/ (TransferTransitionTest, ResponsibilityHandoverTest) and app/src/test/java/care/cema/his/adm/app/ (AdmissionJourneyTest, contract/ProviderContractTest).

Requirement, criterion Test Scenario
FR-ADM-TRF-001 AC-01, PR-TRF-001-1, BR-ADM-015, part 6.3. The ward board, the encounter validation, the worklist assignment (ResponsibilityChanged) and the ADT message (PatientTransferred) agree on location and effective time. The history entry is "Transferred"; the origin is in turnover; the destination is Occupied; both BedStateChanged are published; the units are notified TransferTransitionTest.completedTransferAllViewsAgree TEST-ADM-027
FR-ADM-TRF-001 AC-02, PR-TRF-001-2, part 6.4. Nothing changes and the condition is named for each of these: a stale encounter version (412, "Encounter changed. Review and retry."); an occupied destination; a hard rule failing inside the transaction (the sex of a shared room); not the reserved bed; an unaccepted transfer; an unacknowledged handover; an effective time before the last change TransferTransitionTest.failedConditionChangesNothing TEST-ADM-027
FR-ADM-TRF-001 AC-03, part 6.5. Pending: the encounter, the boards, the timeline and the validation show the origin and the origin team; pendingTransferId is on the encounter and on both beds TransferTransitionTest.pendingTransferShowsOrigin TEST-ADM-027
FR-ADM-TRF-001 AC-04, part 7, BR-ADM-012. A correction by the supervisor only:
  • location and responsibility restored from the correction;
  • "Transferred" and "Corrected" both in the history;
  • EncounterCorrected 1.1, with PatientTransferred kept;
  • the correcting period;
  • one team and location at every time, before and after the correction;
  • the timeline, history entry, bed entries and ResponsibilityChanged all at the correction's time (AC-01);
  • restoreToBed when the origin was taken, that bed the location only from the correction;
  • no second correction.
TransferTransitionTest.correctionRestoresPriorState TEST-ADM-027
FR-ADM-TRF-001 PR-TRF-001-3 (a repeated key: one transfer) TransferTransitionTest.duplicateConfirmationIsNoSecondTransfer TEST-ADM-027
FR-ADM-TRF-001 part 10, section 4.3. The destination bed lost (blocked, or the reservation expired): back to Requested with "Destination bed lost", and the bed manager notified TransferTransitionTest.destinationBedLost TEST-ADM-027
FR-ADM-TRF-001 part 10, section 4.3. Rejected with a reason: the requester notified, the reservation released, the patient stays. Cancelled. Decisions only from Requested TransferTransitionTest.rejectAndCancel TEST-ADM-027
FR-ADM-TRF-001 parts 6.1, 7 and 10. The request's fields; an Admitted encounter only; an active team ("Select an active practitioner or team."); one open transfer; a registry outage is 503; another facility's encounter; audited TransferTransitionTest.requestRules TEST-ADM-027
FR-ADM-TRF-001 part 6.6, DEC-ADM-008. Between facilities: the sending encounter is discharged and a linked encounter of the same care episode is admitted at the receiving facility, in one transaction; no PatientTransferred; not corrected here TransferTransitionTest.transferBetweenFacilities TEST-ADM-027
FR-ADM-TRF-001 PR-TRF-001-4. A bed swap is refused and nothing changes (question below) TransferTransitionTest.bedSwapRefused TEST-ADM-027
FR-ADM-TRF-001, WF-ADM-005 alternative (a change of responsibility only: no bed changes) TransferTransitionTest.responsibilityOnlyTransfer TEST-ADM-027
FR-ADM-TRF-001 parts 3, 12 and 13, architecture 7.5. A deny is 403 and audited; the urgent path is the charge nurse's; a decision point outage is 503; an unknown transfer is 404; reads across facilities are the decision point's, with crossFacility TransferTransitionTest.policyAndFacility TEST-ADM-027
FR-ADM-TRF-001, D01-ADM 11.1. Two patients confirmed into one free bed at once, and one transfer confirmed twice at once: one wins and nobody is on two wards or none. Three rounds TransferTransitionTest.concurrentConfirmations TEST-ADM-027
FR-ADM-TRF-002 AC-01, PR-TRF-002-1, BR-ADM-016, part 6.5. Two transfers, then discharge: exactly one ward and team every 17 minutes of the stay and at each boundary instant; contiguous periods; none outside the admission ResponsibilityHandoverTest.exactlyOneResponsibleAtAnyTime TEST-ADM-028
FR-ADM-TRF-002 AC-02, PR-TRF-002-2, part 6.2. Given: receiver, user and time. Acknowledged by the named receiver: user and time, and TransferHandoverAcknowledged published once (a repeated event and a second event publish nothing). Refused and audited from anyone else, or on behalf without a reason. On behalf with a reason is recorded. The API refuses acknowledge and decline. A shift handover is not recorded ResponsibilityHandoverTest.acknowledgementRecordedOnce TEST-ADM-028
FR-ADM-TRF-002 AC-03, PR-TRF-002-3, part 6.4. Urgent arrival without acknowledgement: the acceptance and the bed are recorded with it; "Handover not acknowledged" is shown; one escalation to the receiving charge nurse after 30 minutes, and not before; the indicator stays until acknowledged; the receiver is changed with a reason ResponsibilityHandoverTest.urgentArrivalEscalates TEST-ADM-028
FR-ADM-TRF-002 AC-04, part 6.6, part 10. A change of team without a move: the timeline and ResponsibilityChanged. Refused: an overlap ("Responsibility must be continuous."), an inactive team, a stale If-Match, another facility (404), and a deny for the change and for the read ResponsibilityHandoverTest.changeOfTeamWithoutMove TEST-ADM-028
FR-ADM-REG-001, FR-ADM-ENC-001, FR-ADM-ADT-001, FR-ADM-TRF-001, FR-ADM-ADT-003. Registration, admission, leave, return, transfer and discharge through the whole unit: encounter, beds, census, responsibility, history, events in sequence and delivery tracking agree AdmissionJourneyTest.inpatientStay TEST-ADM-035
Every operation of transfers.v1 contract/ProviderContractTest TEST-ADM-027, 028

Safety-critical function "Transfer and responsibility" (D01-ADM 11.1). The control is built as specified: - One governed transition. It runs in one database transaction under the locks of the encounter, the transfer and every bed of both rooms, taken in one order. A failure rolls everything back. - A contiguous responsibility timeline. A new period starts at the instant the previous one ends, and a correction appends a correcting period. asAt answers exactly one period and refuses a time outside the admission rather than guess. - Handover acknowledgement and escalation. The acknowledgement comes only from Domain 3, from the named receiver or on their behalf with a reason. The escalation goes to the receiving charge nurse after CFG-CLI-021.

Its verification passes: TEST-ADM-027 (TransferTransitionTest) and TEST-ADM-028 (ResponsibilityHandoverTest). The control is implemented as the specification states and not altered, so no hazard log entry changes. The card names no safety review.

Non-functional targets designed for: - NFR-ADM-005 (security). - Every step is an action of its own at the decision point. An outage is 503, never a grant. - Facility scope follows architecture 7.5. The timeline is read only under the decision point and changed only through the governed transitions. - Changes are audited as adm.adt.change and reads as adm.person.view. - NFR-ADM-009 (interoperability). Every transfers.v1 operation passes verify, and the published events validate against their schemas. - NFR-ADM-012 (observability). The kit's traces and correlation identifiers. Refused acknowledgements and escalations are logged and audited. - NFR-ADM-013 (localization). The user messages are the requirements'. The interval and the disposition are settings. - NFR-ADM-014 (time integrity). - Effective and recorded times are kept apart, in UTC to the millisecond. - The arrival is checked against the encounter's last change and the period in force. - A change of team is refused in the future beyond the CFG-ADM-011 tolerance.

Differences from the specification or the contract

None of these guesses clinical, financial or access behaviour. Each takes the text as written or its stricter reading, and ADR-HIS-104 records them. - Bed swaps are refused (PR-TRF-001-4, question Q1 below). Each swap is answered 400 on /swapWithTransferId. Patients are transferred one after the other through a free bed. - EVT-CLI-011 has no subscription yet. Domain 3 has no contract for ClinicalHandoverAcknowledged (contracts/cli is empty). The port mod009.api.ClinicalHandovers is what the subscription will call. It is the only way a handover becomes Acknowledged, and the tests drive it. - Declined is never set. Q2 of RC-3-S02 (issue #58) is not answered, as transfers.v1 says. - A transfer between facilities is not corrected through correctTransfer. It is reversed through correctEncounter of each encounter: the receiving admission, then the sending discharge. correctTransfer refuses it, naming that path. - A correction takes effect when it is recorded. Part 7 does not say whether the restored responsibility runs from the transfer's effective time or from the correction. The build rewrites nothing, as RC-3-S06's admission reversal does, and asks the owners for the other reading (Q4). The transfer's period stays the record until the correction, and the correcting period, the history entry, the beds and the events all start at it (review round 1). - Only the latest transfer, while it is in force, is corrected. The encounter must be at the destination under the transfer's period; otherwise the later change is corrected first. - Isolation does not move with the patient. An Available destination is checked against the isolation in force on the origin bed. The isolation ends when the patient leaves the bed (ADR-HIS-102), and designating it on the destination is the bed manager's step (follow-up Q2). - Accept, reject and cancel are taken from Requested only (section 4.3), so an accepted transfer is not cancelled (Q3). - Off the urgent path, the arrival needs the reservation of the destination bed (part 6.2), or no bed at all for a change of responsibility only. An Available bed is taken only on the urgent path. - The escalation runs from the handover given, or on the urgent path from the arrival when none was given. A change of receiver starts it again. - The new notification type adm.transfer-rejected. Part 10 has the requester notified of a rejection, and the registered types have none for it. - In a transfer between facilities, EncounterOpened of the linked encounter is written before PatientDischarged of the sending one, because the discharge names it. Contract point 4 lists them the other way round. Events are ordered per encounter, and these are two encounters. - his.adm.transfers.single-open-transfer turns the one-open-transfer rule off in the provider contract test only, as his.adm.adt.single-open-request does for admission requests.

Questions for a person

None blocks the work; each is posted on issue #64 (Q4 since review round 1). - Q1, owners of D01-ADM (clinical, infection control): PR-TRF-001-4 and WF-ADM-005 ask for a bed swap "as one transition for each patient with no intermediate double occupancy". BR-ADM-023 and section 4.3 put a vacated bed in Cleaning, and it is not offered until cleaned; 4.3 has no Cleaning to Occupied. Is a swap within a ward done without turnover of the two beds (Occupied to Occupied, a step 4.3 would need), or does each bed's turnover come first? Until the answer, swaps are refused. - Q2, owners of D01-ADM (clinical, infection control): when a patient under isolation is transferred, is the isolation designated on the destination bed automatically, with the same precaution and source order, or is that the bed manager's step, as now? The destination is already required to meet the patient's need. - Q3, owner of D01-ADM: section 4.3 lets a transfer be cancelled only from Requested. Should the requester or the receiving unit be able to cancel an Accepted transfer, for example when the patient's condition changes? Until then an accepted transfer completes, or returns to Requested if its bed is lost.

  • Q4, owners of D01-ADM (clinical and access behaviour): a transfer entered in error is corrected with "restores the prior location and responsibility" (FR-ADM-TRF-001 part 7). Should the restored responsibility be effective from the transfer's effective time, so that the timeline says the receiving team was never responsible? Or from the correction, as now, so that the receiving team stays recorded as responsible, notified and given access until it? The timeline feeds the care-team attribute of D10 authorization and incident review. The other reading would also need the history and beds dated back, and ResponsibilityChanged sent with a past effective time.

Review round 1

The review found that the correction dated the restored responsibility back to the transfer's effective time, while the encounter, the history entry and the beds were restored at the time of the correction. Between the two, readResponsibilityTimeline?asAt disagreed with the encounter history and the bed board. With restoreToBed, the timeline also gave a bed the patient never occupied. It was an unasked choice on a point the specification leaves open.

What changed on this branch: - The correction now takes effect when it is recorded, throughout (ADR-HIS-104 point 7): - the transfer's period ends at the correction; - the correcting period, the "Corrected" history entry, the bed entries and ResponsibilityChanged all start at the same instant. - asAt no longer skips a corrected period, which stays the record of who was responsible until the correction. - The question is posted as Q4 on issue #64. - The full build was run again: 210 of 212 tests passed, the 252 contract cases among them. The 2 that failed are the kit's HttpPolicyDecisionClientTest (permit, deny), which this branch does not change. On a host at load 10 to 20 on 4 cores, its local stub missed the client's 300 ms limit and the client failed closed, as its log shows. They passed in the first full build. Follow-up below. - TransferTransitionTest.correctionRestoresPriorState checks it: the times agree; the transfer's team and bed are answered before the correction and the origin's after; with restoreToBed, that bed is the location only from the correction.

Follow-ups outside the card

  • D03-CLI contract (contracts/cli):
  • ClinicalHandoverAcknowledged (EVT-CLI-011), with its topic and payload: the handover, the acknowledging user, on-behalf and its reason, and the transfer where there is one.
  • Then subscribe in mod-adm-009 and call ClinicalHandovers.
  • With Q2 of RC-3-S02, the channel of the decline.
  • D10 registrations before ADM goes live (RC-1-S16, RC-1-S15, configuration):
  • the actions of ADR-HIS-104 point 4 on adm.Transfer and adm.Encounter, with the attributes it lists. The wind-down of the sending team's access follows from ResponsibilityChanged (part 13);
  • the role adm.charge-nurse, resolved within a unit;
  • the notification type adm.transfer-rejected, which contracts/adm/README.md should list with the others;
  • the code lists urn:his:adm:transfer-reason, transfer-urgency and responsibility-change-reason, and the disposition transferred.
  • RC-3-S24 (integrate):
  • give D10 the synthetic ICU and step-down units, teams and beds of RC-3-E2E-002;
  • measure PatientTransferred propagation against NFR-003.
  • Screens (RC-3-S19, UI-ADM-009):
  • send encounterVersion from the encounter read;
  • show stateNote "Destination bed lost" in amber;
  • show "Handover not acknowledged ยท [time]" from handover.urgentArrivalWithoutAcknowledgement;
  • offer restoreToBed when a correction asks for it.
  • A discharge with a pending transfer: adt.v1 recordDischarge leaves an open transfer open. The specification says nothing on it; a later card on MOD-ADM-005 or 009 should close it, with its owners.
  • Kit test timing (owner of services/_template, FN-S03): HttpPolicyDecisionClientTest checks answers against a local stub with the client's 300 ms timeout, so it fails on a heavily loaded host. The self-hosted runners share this host. A longer timeout in that test alone would keep its check of the outage case without depending on the host's load.
  • Design system: none from this session.