Architecture / Decision records / ADR-HIS-104
ADR-HIS-104 Transfers in adm-patient-administration: MOD-ADM-009 as its own module on ports of the encounter, responsibility and bed modules, one transaction under one lock order, append-only correction of the responsibility timeline, and the clinical handover acknowledgement through a port until Domain 3 has its contract¶
| Status | Accepted |
| Decided | 2026-11-29 by session RC-3-S08 |
| Record | Drafted 2026-11-29; approved 2026-11-30 by the Enterprise Architecture Board |
| Where the rule lives | services/adm-patient-administration: mod-adm-009 (transfers.v1: Transfers, Arrivals, Responsibility, Handovers, TransferBeds, TransferStore; port api.ClinicalHandovers); the ports it uses in mod-adm-004 (api.EncounterRecords), mod-adm-005 (api.ResponsibilityTimeline, api.TransferAdmissions) and mod-adm-006 (api.BedOccupancy.transfer, api.TransferReservations, api.D10Notifications) |
Context¶
RC-3-S08 builds FR-ADM-TRF-001 (transfer as one governed business transition) and FR-ADM-TRF-002 (transfer handover, responsible care team and effective timestamps). It serves transfers.v1 (RC-3-S02, ADR-HIS-083) and implements the control of the safety-critical function "Transfer and responsibility" of D01-ADM 11.1: the hazard is a patient shown on two wards or none, with no accountable team.
The earlier sessions on the unit left these in place:
- the encounter, its state model and its append-only history in mod-adm-004 (RC-1-S09, RC-2-S04);
- the responsibility periods, written by the admission and the discharge, in mod-adm-005 (RC-3-S06, ADR-HIS-091);
- the bed ledger with its reservations in mod-adm-006 (RC-3-S06, RC-3-S07, ADR-HIS-102).
A transfer changes all three in one transaction (PR-TRF-001-1, BR-ADM-015). The specification and the contract leave the following to the build: - where the transfer lives, and how it reaches the other modules; - how the steps commit together without deadlock; - how a correction keeps the timeline append-only (part 11) and still answers one period at any time (AC-01); - how the acknowledgement arrives while EVT-CLI-011 has no Domain 3 contract; - the escalation interval's start, the recipients of the notifications, and the states from which each decision is taken.
Decision¶
- MOD-ADM-009 is the subproject
mod-adm-009, with its own schemamod_adm_009. It uses the other modules only through theirapipackages (ModuleBoundaryTest): mod004.api.EncounterRecords. The transitiontransferis written as the history entry type "Transferred" (D01-ADM 4.3: Admitted to Admitted).correctTransitionwrites the "Corrected" entry that names it, and publishes EncounterCorrected 1.1 withreversedTransition: transfer.openContinuationtakes the receiving facility, so a transfer between facilities opens the linked encounter there with a CIN of that facility.mod005.api.ResponsibilityTimeline. The responsibility periods (DE-ADM-012) stay inmod_adm_005, where the admission and the discharge write them. The port starts a period (the one in force ends at the same instant), lists the periods, and publishes ResponsibilityChanged for every cause. MigrationV2__responsibility_timeline.sqladds the period's location, transfer and the sequence it corrects.mod005.api.TransferAdmissions. The discharge and admission steps ofAdt, reused for a transfer between facilities, so that closure criteria, history, audit and events are those of adt.v1.mod006.api.BedOccupancy.transfer. The bed step of a transfer (see point 3).mod006.api.TransferReservations. Implemented by MOD-ADM-009. beds.v1 reserveBed withtransferIdasks it for the transfer's purpose, and tells it when the reservation begins and ends. The defaulttransferofReservationPurposesis removed.mod006.api.D10Notifications. The queued notification.v1 requests ofD10Requests.- The transfer is one row. Its columns are what the unit selects and locks by: encounter, both facilities, state, handover state, clinical handover, reservation, escalation due, and completion. A
recordjsonb holds the transfers.v1 Transfer as last written, with its history and handover, and is rewritten whole at the next version. The version is the ETag, and the request's note is a column of its own. One open transfer per encounter is checked under the encounter's row lock, which every request for the encounter takes first, so two requests at the same moment meet the rule one after the other. As for admission requests (ADR-HIS-091), the settinghis.adm.transfers.single-open-transferturns the rule off in the provider contract test only, whose setups request a transfer for the same encounter once per case. - One transaction, one lock order. The confirmation and the correction lock, in this order:
- the encounter;
- the transfer;
- every bed of the origin's and the destination's rooms, in the order of their identifiers (
BedLedger.transfer, as ADR-HIS-102 point 4 locks one room).
Under those locks: - The destination must be Reserved for the encounter, or Available. Otherwise nothing changes and the answer names the bed (PR-TRF-001-2, AC-02). - An Available destination is checked against the hard rules of BR-ADM-013, with isolation in force on the origin bed as the patient's need. - The origin goes to Cleaning with its turnover (BR-ADM-023), and the destination to Occupied. - The responsibility period, the encounter, the history entry, the audit and the events follow.
Any failure rolls all of it back (part 6.4). A reservation that expires or is invalidated calls back into MOD-ADM-009 after the bed's lock, which is the other order. A deadlock between that and a confirmation is detected by PostgreSQL, and one of the two is retried by the user or the next expiry scan.
4. Policy. Each step of part 3 is its own action on adm.Transfer:
- request, view and query;
- accept, reject and cancel;
- give-handover and change-receiver;
- confirm-arrival, confirm-urgent-arrival and correct.
On adm.Encounter the actions are change-responsibility and view-responsibility. The decision point receives the transfer's facilities, units and actors as attributes, with crossFacility when the caller's facility is neither origin nor destination. It decides the cross-facility cases (x-his-cross-facility policy) and the care relationship or audit role of the timeline (part 13). A transfer that does not exist is 404, after the decision point has refused a facility the caller is not permitted.
5. The pending transfer. The encounter's pendingTransferId (encounters.v1 1.2 inpatient context) is set at the request and cleared at completion, rejection or cancellation. That moves the encounter's version, as the discharge decision does. Nothing of location or responsibility moves before the confirmation (part 6.5, AC-03). The bed's pendingTransferId is derived when it is read: from its occupant's encounter, or from the transfer its reservation serves.
6. What the build does not decide.
- Bed swaps (PR-TRF-001-4). A swap is refused (400 on /swapWithTransferId). BR-ADM-023 puts a vacated bed in turnover and 4.3 has no Cleaning to Occupied, so a swap without double occupancy would need a bed to skip its cleaning. That is a question for the specification's owners (issue #64).
- Isolation does not move with the patient. The hard rules check the destination against the isolation in force on the origin bed. The isolation itself ends when the patient leaves that bed (ADR-HIS-102), and designating it on the destination stays the bed manager's step.
7. Correction is append-only, takes effect when it is recorded, and one period is in force at any time. FR-ADM-TRF-001 part 7 does not say whether the restored responsibility runs from the transfer's effective time or from the correction. This build takes the reading that rewrites nothing, as the admission reversal of RC-3-S06 does (ADR-HIS-091), and asks the owners for the other on issue #64 (Q4).
- The transfer's period ends at the correction. It stays the record of who was responsible, notified and given access until then. The timeline feeds the care-team attribute of D10 authorization and incident review.
- The correcting period starts at the same instant. It carries the origin responsibility, names the corrected period in corrects, and has the location the patient is restored to: the origin bed, or the bed named in restoreToBed.
- Every view carries that instant. The history entry "Corrected", the bed entries (the destination to Cleaning, the restored bed to Occupied), EncounterCorrected and ResponsibilityChanged all have the correction's time, so the timeline, the location and the events agree (AC-01).
- readResponsibilityTimeline?asAt answers the one period in force at that time, and two at once would be a defect, not an answer.
Only the latest completed transfer is corrected here, and only while it is in force: - the encounter is at the destination; - the transfer's period is the current one.
A transfer between facilities is corrected by reversing each encounter (encounters.v1 correctEncounter: the receiving admission, then the sending discharge).
8. The acknowledgement. EVT-CLI-011 (ClinicalHandoverAcknowledged) has no Domain 3 contract, so its topic and payload are not fixed. The port mod009.api.ClinicalHandovers is what its subscription will report through, as mod005.api.ClosureInputs is for the closure inputs (ADR-HIS-091). It is the only way a handover becomes Acknowledged, and it works as follows:
- every event is recorded once by its identifier (handover_receipt);
- it is matched to the transfer by clinicalHandoverId;
- it is taken only from the named receiver, or on the receiver's behalf with a reason (PR-TRF-002-2);
- TransferHandoverAcknowledged is published once per transfer.
transfers.v1 refuses acknowledge and decline. Until Q2 of RC-3-S02 (issue #58) is answered, nothing sets Declined.
9. Escalation (CFG-CLI-021, PR-TRF-002-3). The interval is his.adm.transfers.handover-escalation-after (30 minutes, OV-117). It runs from the handover given, or, on the urgent path when no handover was given, from the arrival. A change of receiver starts it again. The scan Handovers runs as the unit's service identity and escalates once per due time: it notifies adm.handover-escalation to the receiving unit's charge nurse, at high priority. "Handover not acknowledged" stays until the acknowledgement.
10. Notifications (part 9, INT-ADM-014).
- adm.transfer-requested goes to the receiving unit's charge nurse.
- adm.transfer-accepted goes to the sending unit's charge nurse.
- adm.transfer-rejected goes to the requester as a user. The type is new; part 10: "Requester notified".
- adm.transfer-completed goes to both units.
- adm.transfer-bed-lost goes to the bed manager.
The charge nurse is the role `adm.charge-nurse`, resolved in the unit, beside RC-3-S07's `adm.bed-manager`.
- The state model as written.
- Accept, reject and cancel are taken from Requested only (section 4.3).
- Off the urgent path, the arrival needs the acceptance, the acknowledged handover and the reservation of the destination bed (part 6.2), or no bed at all: a transfer that changes responsibility only (WF-ADM-005 alternative).
- The urgent path records the acceptance and an Available bed with the confirmation.
- A transfer between facilities. The sending encounter is discharged with the disposition
his.adm.transfers.enterprise-disposition(transferred). Its destination organization is the transfer's destination unit, and PatientDischarged carriescontinuedByEncounterId. The linked encounter is opened (EncounterOpened) and admitted (PatientAdmitted withcontinuesFromand withoutfromEmergency, then ResponsibilityChanged). Both are ordered per encounter. EncounterOpened of the new encounter is written before PatientDischarged of the sending one, because the discharge names the linked encounter. PatientTransferred is not published (EVT-ADM-010).
Consequences¶
- The ADT, bed and transfer modules keep their boundaries, and the transfer's transaction is still one database transaction.
- The safety control is testable end to end:
TransferTransitionTest(TEST-ADM-027) andResponsibilityHandoverTest(TEST-ADM-028) inmod-adm-009, andAdmissionJourneyTest(TEST-ADM-035) inapp. - Domain 10 registers the actions of point 4, the role
adm.charge-nurseand the notification typeadm.transfer-rejected. - Domain 3 fixes the contract of EVT-CLI-011. Its subscription is then a few lines that call
ClinicalHandovers. - Bed swaps and the decline wait for the answers of their owners. Each answer is a change of this unit alone, compatible with transfers.v1.