Architecture / Decision records / ADR-HIS-102
ADR-HIS-102 Beds and encounter validation in adm-patient-administration: beds.v1 on the occupancy ledger, the state model kept by composing its transitions, a configurable constraint catalogue, room holds for isolation, and validation against both the history and the current state¶
| Status | Accepted |
| Decided | 2026-11-29 by session RC-3-S07 |
| Record | Drafted 2026-11-29; approved 2026-11-30 by the Enterprise Architecture Board |
| Where the rule lives | services/adm-patient-administration: mod-adm-006 (beds.v1: BedLedger, Beds, Eligibility, BedBoard, ReservationExpiry, D10Requests; port api.ReservationPurposes), mod-adm-004 (EncounterValidation, ValidationPolicy, MergeLinks) |
Context¶
RC-3-S07 builds FR-ADM-BED-001 (bed, room and location state), FR-ADM-BED-002 (conflict-free reservation and allocation) and FR-ADM-ENC-003 (encounter validation for downstream activity). It serves beds.v1 and validateEncounterContext of encounters.v1 1.2 (RC-3-S02, ADR-HIS-083). RC-3-S06 had built the occupancy ledger that the ADT transactions change in their own transaction (ADR-HIS-091 point 3).
The specification and the contracts leave six things to the build:
- Bed attributes. The D10 registry (master-data.v1 Location) carries the room's isolation capability and bed count, but no bed type, bed class, equipment or age band.
- Steps outside the state model. Some steps the requirements name are not transitions of section 4.3: a reserved bed that is blocked (PR-BED-002-3), or a bed that becomes Available in a room held for isolation.
- Isolation compatibility. What "compatible with the isolation need" means for a room.
- The encounter validation policy (CFG-ADM-023, DEC-ADM-007). It is stated per state, and it must be applied both "at the activity time" (part 11) and "after discharge, within windows" (part 6.4).
- The emergency exceptions, which are governed configuration with no list yet.
- Merge links, which this unit must follow without a call to the person index on every validation.
Decision¶
- beds.v1 is served on the ledger of ADR-HIS-091. The definition of a bed is D10's (DEC-ADM-015); its operational state is this unit's. The ledger takes a bed from the registry in three ways:
- when a transaction names it, as before;
- by listLocations of the facility's bed positions and rooms, when the board, the census or a search needs it and the last read is older than
his.adm.beds.registry-refresh(5 minutes); - by MasterDataChanged of a location.
A bed the registry no longer lists, retires or makes inactive leaves the board. One that is Occupied or Reserved keeps its state and is flagged (registryFlag, PR-BED-001-3). When the registry cannot be reached, the board is answered from the ledger. It is stale once the last good read is older than registry-stale-after (15 minutes, BR-ADM-024).
- The state model of section 4.3 is kept exactly; a step it lacks is two of its transitions.
- A reserved bed that is blocked or taken out of service: Reserved to Available ("reservation-invalidated"), then Available to Blocked or Out of service.
- A bed that becomes Available in a room held for isolation: Available, then Blocked with reason
isolation. - The terminal clean of an empty bed whose isolation ended: Available to Blocked (
terminal-clean), and back to Available when the cleaning is completed.
A bed blocked or taken out of service while Cleaning keeps its cleaning task. It is not unblocked or returned to service until the task is completed (BR-ADM-023: not offered until cleaned). Each of these steps is its own history entry and BedStateChanged event.
- The constraint catalogue of CFG-ADM-014 is configuration (
his.adm.beds.hard-constraints, defaultisolation,sex, as CFG-ADM-014 sets them). The state rules are always hard; every other constraint is soft and overridable with a reason. - An isolation need is met by a room D10 defines as isolation capable and that is not shared with another patient, or by cohort placement with the same precaution type. A single room that is not isolation capable does not meet it.
- A room-mate's isolation need counts too: the isolation in force on its bed, or else the need its admission request names (
ReservationPurposes.isolationNeed). No bed is given beside a patient who needs isolation, except cohort placement with the same precaution type. - Sex in a shared room compares the encounter's sex (from the requirements, or the person index) with that of every occupant and reservation holder of the room. Unknown is not the same. An index that cannot be reached means the bed is not offered in a search, and the reservation answers 503.
- A requested attribute the registry does not record (bed type, class, equipment, age band, the service line without a unit) is unmet with "not recorded in the location registry", never met by default.
-
The requested unit is the service-line constraint, as the beds.v1 example shows.
-
Isolation places a room hold (DEC-ADM-005, PR-BED-001-4 and 5).
- The isolated bed carries the hold: block-room, or cohort with its precaution type. Its room-mates name it as
room_hold_source. - A room-mate that is free is blocked ("Blocked · isolation") or marked for cohort placement.
- An occupied room-mate is marked "Isolation exposure · review", and an
adm.isolation-exposure-reviewtask is created. - A reserved room-mate's reservation is invalidated, since it was made without the constraint.
-
The isolation ends with the patient's leaving (vacate) or by
end. The hold lasts until the bed's terminal clean is completed; then the room-mates are released, or held by another bed of the room that still holds it. -
Reservations.
- For which requests. A bed is reserved for an admission request that is Requested, Accepted or Bed allocated. The RC-3 scenario (RC-3-E2E-001) reserves without an acceptance, and RC-3-S06's listener already moves a Requested request to Bed allocated. The request is confirmed through the port
mod006.api.ReservationPurposes, which MOD-ADM-005 implements. A transfer is refused until MOD-ADM-009 implements the port'stransfer(RC-3-S08). - Hard rules again. The reservation checks the hard rules once more against the request's BedRequirements.
- Direct admission. An admission straight into an Available bed (part 6.5) takes the same room lock and the same hard rules, with the encounter's isolation need from its admission request; soft constraints are the reservation's to override.
- The room is locked. A reservation, like every bed command, locks every bed of its room in the order of their identifiers before it applies the rules, so two reservations in one shared room are serialized (D01-ADM 11.1).
- Refusals. A bed Reserved or Occupied for another encounter is the conflict of BR-ADM-014: 409 version-conflict. Blocked, Cleaning and Out of service are refused with 400 and "Bed cannot be allocated: (state)."
- Overrides need the distinct action
override-constraint. Each override is recorded with its reason and the person who gave it. -
One per encounter. An encounter holds one active reservation;
replacesReservationIdchanges it in one transaction. -
What D10 must do after a bed change is queued in that change's transaction. These are:
- the notifications
adm.bed-reservation-expiredandadm.bed-reservation-invalidatedto the roleadm.bed-managerof the unit; - the task
adm.isolation-exposure-reviewin queueadm.bed-management.
A relay delivers them with the queued request's identifier as the Idempotency-Key, retrying while D10 is down. A D10 outage never blocks a bed change, and a retry never makes a second notification or task. The reservation expiry is a scan (his.adm.beds.expiry-scan-interval, 30 seconds) that expires each due reservation in a transaction of its own, as the unit's service identity.
-
Policy actions on
adm.Bed, one per manual change, so that the decision point can give them by role (FR-ADM-BED-001 part 3):block,unblock,take-out-of-service,return-to-service,start-cleaning,complete-cleaning,designate-isolation,end-isolation, plusview,queryandsearch. Onadm.BedReservationthe actions arecreate,release,view,queryand the distinctoverride-constraint. The attributes are the facility, the responsible unit, the ward and the state, so a ward nurse can be limited to the nurse's own unit. Theredactobligation removes occupant and isolation detail (part 13). -
Encounter validation evaluates both the history and the current state.
- The state at the activity time must accept the category. It is read from the history, without transitions that a later correction reversed.
- The current state must also accept the category being recorded now, with the post-discharge windows measured from the discharge.
- So an order with a time during the stay is still refused once the encounter is Discharged ("no new orders"), and a late charge is accepted only within its window.
- Merge links come first from PatientMerged and PatientUnmerged on
his.adm.person.v1(MergeLinks). Only a remaining difference between the persons is put to the person index; an index that cannot answer is 503. - An unmerge marks every encounter of either identity created after the merge as
attributionPendinguntil it is attributed. -
Facility mismatch, unknown CIN and patient mismatch disclose no context.
-
CFG-ADM-023 is a stand-in (
mod004/ValidationPolicy) until the D10 configuration client exists, as the other stand-ins of ADR-HIS-057 are. It holds: - the DEC-ADM-007 matrix, read state by state as it is written;
- the windows (documentation 24 hours, late charges 48 hours);
- results of orders placed during the encounter in every state but Cancelled. DEC-ADM-007's specific rule for them ("results for orders placed during the encounter are always accepted") is applied over the lists of the matrix, so a result is accepted on a Closed, Pre-admitted or On leave encounter and none is lost. Cancelled stays "none";
- late charges checked against their 48-hour window only. DEC-ADM-007's "and before the bill is final" needs the bill's state from Domain 5, which has no contract yet (a follow-up);
- one approved emergency exception,
downtime-back-entry: DEC-ADM-007's downtime entries "back-entered with their real time". It waives only an activity time before the encounter's record began, and only within the backdating limit of CFG-ADM-011 (his.adm.validation.back-entry-limit, 24 hours).
The current state is checked first, and no exception waives what it refuses: a Cancelled or Closed encounter, no new orders after discharge, a closed window. Nor does an exception waive a patient, facility or encounter mismatch, or an unconfirmed encounter. DEC-ADM-007's quick registration is not an exception: it creates the encounter, Registered, before care is recorded. The policy version is CFG-ADM-023@1.
- The module tests of beds.v1 and of encounter validation run with the ADT module tests (
mod-adm-005/src/test). Those already start MOD-ADM-002, 004, 005 and 006, and beds and validation are exercised through admissions, discharges and leave.
Consequences¶
- No contract was changed. Every beds.v1 operation and validateEncounterContext pass
his-contract verify. - A request naming bed type, class, equipment or age band puts every bed under "soft constraint failures" until master-data.v1 carries those attributes (a follow-up for D10). Such a bed needs an authorized override, so the request is never met silently.
- The emergency exceptions, the windows and the hard and soft catalogue are governance's to approve (CFG-ADM-014, CFG-ADM-023). Each is one setting or one class to replace.
- Until the unit serves
correctEncounterwithunmergeId(the reattribution after an unmerge, FR-ADM-MPI-005 part 6.9.1), an encounter that awaits attribution staysattributionPending, which is the safe side. - The
cancelled-with-activityworklist is filled, but stays empty until the Domain 3 to 6 subscriptions report activity throughmod004.api.DownstreamActivity.