Skip to content

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

Handover RC-3-S02 Contract: Contracts and stubs: D1 ADM (slice RC-3)

Card: RC-3-S02. Issue: cema-care/his#58. Branch: session/RC-3-S02. Slice: RC-3. Decision record: ADR-HIS-083.

What was built and where

The D01-ADM contracts of the inpatient stay, in contracts/adm/. They cover the eleven ADM requirements of the slice, for modules MOD-ADM-001, 003, 004, 005, 006 and 009. Every change to the RC-1 and RC-2 contracts is additive.

API Version Unit What it adds
patient-identity.v1 1.1 → 1.2 adm-identity 12 operations: stewardship work items and their resolution (FR-ADM-MPI-004); merge through the resolution, unmerge, attribution of post-merge records and sign-off (FR-ADM-MPI-005); crossReferenceIdentifier and queryDemographics (FR-ADM-XRF-002). Also IdentityMatch resolution fields and listIdentityMatches?itemType
encounters.v1 1.1 → 1.2 adm-patient-administration validateEncounterContext (FR-ADM-ENC-003); correctEncounter reversals admit and discharge, and the patient reattribution after an unmerge; the inpatient context of Encounter (responsibility, leave, pending discharge, pending transfer, closure, attribution pending)
adt.v1 1.0, new adm-patient-administration 19 operations: admission requests, confirmAdmission, admitFromEmergency, leave and return, discharge decision, discharge, closure with waivers (FR-ADM-ADT-001, 003); the current-state census, the delivery tracking of every Domain 1 event pushed by Domain 2, and the reconciliation worklist (FR-ADM-ADT-002); the UI-ADM-010 operational worklists
beds.v1 1.0, new adm-patient-administration 12 operations: bed board, history, state changes, isolation, census, cleaning tasks (FR-ADM-BED-001); eligible-bed search, reservation with 409 on conflict, release (FR-ADM-BED-002)
transfers.v1 1.0, new adm-patient-administration 9 operations: transfer request, decisions, handover, arrival as one transition with the urgent path and bed swap, correction (FR-ADM-TRF-001); change of responsibility and the timeline with asAt (FR-ADM-TRF-002)

Twelve new events, each in the event catalogue with ADM as producer: - IdentityReviewResolved on his.adm.identitymatch.v1; - PatientMerged and PatientUnmerged on his.adm.person.v1; - PatientAdmitted, PatientTransferred, PatientLeaveStarted, PatientReturnedFromLeave, EncounterClosed, TransferHandoverAcknowledged and ResponsibilityChanged on his.adm.encounter.v1; - BedStateChanged and BedReserved on the new topic his.adm.bed.v1.

PatientDischarged and EncounterCorrected go to 1.1, with optional fields only.

Other files: - schemas/adm-types.v1.json: ten new shared types. - Generated stubs in stubs/. - TRACE.md: a section "Slice RC-3". - README.md: what RC-3 added, the mapping to HL7 v2 and FHIR, the names ADM registers in D10, topic ownership, and the contract points of RC-3-S03, S05 to S08, S18, S19, S24 and the D10 registrations. - scripts/cross-references.ts: now also knows the RC-3 names and APIs. - scripts/ends-when-rc-3.sh: this card's "Ends when", repeatable.

Section 7.3 of D01-ADM data, for approval by the domain leads, each attribute with its source and a classification line. No existing attribute was changed. - New entity sections DE-ADM-010 AdmissionRequest and DE-ADM-014 BedReservation. Their 7.2 rows now link to them. - New tables: the unmerge attribution, the closure criterion status and waiver, and the event delivery and reconciliation item. - "Added by the RC-3 contracts" blocks in DE-ADM-004, 005, 008, 011/012 and 013.

ADR-HIS-083 and its row in the decision record index (81 records). It records eight decisions: 1. ADT, beds and transfers are APIs of their own, and transitionEncounter keeps only the outpatient transitions. 2. The topics. 3. Merge events belong to the person whose status changes. 4. A merge is made only by resolving a work item, and a post-merge encounter is reattributed through correctEncounter. 5. One delivery tracker for all Domain 1 events, fed by Domain 2. 6. A vacate entered in error is undone by a compensating bed entry. 7. A transfer between facilities is policy-scoped, and is a discharge plus a linked admission. 8. Encounter validation is a facility-owned POST that always answers a decision.

The scenario test. The card's "Leaves behind" and "Ends when" name a failing scenario test. The card's scope gives it to "the last contract session of the slice", RC-3-S03, which joins the domains; RC-3-S01 read it the same way. This session writes nothing under e2e/scenarios/RC-3/. Its "Ends when" runs the RC-1 and RC-2 scenarios instead, to show that the contract changes break neither (step 4 below). The calls the RC-3 scenario uses are listed in contract point 4 of RC-3-S03.

Checks and their result

The host's Node.js 22.22 cannot run the TypeScript contract tool, so the checks ran in the image node:22.18-bookworm with pnpm 10.34.9 through corepack, after pnpm install --frozen-lockfile in contracts/common and contracts/adm. The integration environment ran as HIS_SESSION=RC-3-S02 (his-rc-3-s02) and was reset afterwards.

Check Command Result
Conventions his-contract lint . in contracts/adm passed
Compatibility with origin/main, stubs up to date his-contract check . --base origin/main in contracts/adm, ess, ise, fin passed: adm three APIs new, two at 1.2 with new operations and optional fields, twelve new events, two events at 1.1; ess, ise, fin unchanged
Stub against the provider contract test scripts/verify-stub.sh in contracts/adm passed, 527 cases, no violation
Cross-domain references node scripts/cross-references.ts in contracts/adm passed, 355 references; one known reference reported for RC-3-S03 (below)
Ends when HIS_SESSION=RC-3-S02 contracts/adm/scripts/ends-when-rc-3.sh passed, see below
Documentation links python3 docs/implementation_plan/tools/check_links.py 0 broken, 0 duplicate anchors
Documentation site mkdocs build builds
Secret scan, static analysis platform/delivery-pipeline/bin/secret-scan code and docs from origin/main; static-analysis contracts/adm no secret; no blocking finding; no clinical artifact

The steps of ends-when-rc-3.sh:

  1. The adm, ess, ise and fin contracts pass the check, and the stubs of adm, ess and fin answer every provider case with no violation.
  2. The cross-references pass.
  3. On the full profile, for adm: the 26 event schemas register in Apicurio, and the second run reports them unchanged; the topics are created; the 26 sample events are published, read back from Kafka and validated; and the stub on the session network passes all 527 cases with a token of the realm his.
  4. The scenarios of RC-2 and RC-1 run. Each contract walk (RC-2-E2E-005, RC-1-E2E-005) passes; every other test fails only with unit "adm-identity" is not in this stack.

How the "Ends when" lines are met: - Contracts pass the compatibility check: step 1. - Every contract field traces to a requirement, a business rule or a section 7.3 attribute: contracts/adm/TRACE.md, section "Slice RC-3", with the 7.3 additions above. - Stubs run in the integration environment: step 3. - The scenario test runs and fails only because the behaviour is not built: the RC-3 scenario is RC-3-S03's (above). The earlier scenarios still run that way: step 4.

Requirements and test scenarios

A contract session covers requirements by contract. The test scenarios of section 15.2 belong to the build sessions named.

Requirement Contract Checked by Test scenario, build session
FR-ADM-MPI-004 reportIdentityWorkItem, resolveIdentityMatch, readStewardshipReport, listIdentityMatches?itemType; IdentityReviewResolved verify cases; sample event TEST-ADM-004, RC-3-S05
FR-ADM-MPI-005 resolveIdentityMatch (merge), listMerges, readMerge, unmergePersons, listUnmergeAttributions, attributeAfterUnmerge, signOffUnmerge; correctEncounter (patient); PatientMerged, PatientUnmerged, EncounterCorrected 1.1; delivery tracking verify cases; sample events TEST-ADM-005, TEST-ADM-032, RC-3-S05 (with RC-3-S06 for the tracking)
FR-ADM-XRF-002 crossReferenceIdentifier, queryDemographics verify cases TEST-ADM-011, RC-3-S05
FR-ADM-ENC-003 validateEncounterContext; listAdtWorklistItems cancelled-with-activity verify cases TEST-ADM-014, RC-3-S07
FR-ADM-ADT-001 admission requests, confirmAdmission, admitFromEmergency, recordLeave, recordReturn; PatientAdmitted, PatientLeaveStarted, PatientReturnedFromLeave verify cases; sample events TEST-ADM-015, TEST-ADM-035, RC-3-S06
FR-ADM-ADT-002 the events of slices RC-1 to RC-3; listInpatientCensus, submitEventDeliveryStatuses, readEventDelivery, listEventReconciliationItems, resolveEventReconciliationItem verify cases; registry, backbone and validate-event (step 3) TEST-ADM-016, TEST-ADM-034, TEST-ADM-036, RC-3-S06
FR-ADM-ADT-003 recordDischargeDecision, recordDischarge, readEncounterClosure, closeEncounter, correctEncounter (discharge); PatientDischarged 1.1, EncounterClosed verify cases; sample events TEST-ADM-017, TEST-ADM-035, RC-3-S06
FR-ADM-BED-001 listBeds, readBed, listBedHistory, changeBedState, changeBedIsolation, readBedCensus, listCleaningTasks; BedStateChanged verify cases; sample event TEST-ADM-018, RC-3-S07
FR-ADM-BED-002 searchEligibleBeds, reserveBed (409), listBedReservations, readBedReservation, releaseBedReservation; BedReserved verify cases; sample event TEST-ADM-019, RC-3-S07
FR-ADM-TRF-001 requestTransfer, listTransfers, readTransfer, decideTransfer, confirmTransferArrival, correctTransfer; PatientTransferred verify cases; sample event TEST-ADM-027, TEST-ADM-035, RC-3-S08
FR-ADM-TRF-002 recordTransferHandover, changeResponsibility, readResponsibilityTimeline; TransferHandoverAcknowledged, ResponsibilityChanged verify cases; sample events TEST-ADM-028, RC-3-S08

Contract changes

All of them are within major version 1, and the check found them compatible: - patient-identity.v1 1.1 → 1.2 and encounters.v1 1.1 → 1.2: new operations, optional output fields, input enum values, and an optional query parameter; - adt.v1, beds.v1 and transfers.v1: new; - twelve new events; - PatientDischarged 1.0 → 1.1 and EncounterCorrected 1.0 → 1.1: optional fields, and patient added to an extensible enum.

No contract of another domain was changed.

Review round 1

The review asked for four changes. Three are made on this branch; the fourth is RC-3-S03's. - The decline of a handover is no longer recorded in Domain 1. recordTransferHandover lost the action decline, and Q2 is asked on issue #58 under rule 3 (below). - Q2 is named as clinical and access behaviour. - The 7.3 block of DE-ADM-011 no longer replaces the existing handover_state values. It states the contradiction with FR-ADM-TRF-002 part 6.2, and Q3 asks the owner to reconcile it. - adm.person.merge in contracts/ess stays for RC-3-S03, as before.

Afterwards, lint, check against origin/main, the stub verify (527 cases, no violation), the cross-references and check_links.py pass again. The change touches no event schema, so the registry and backbone step was not repeated.

Differences from the card or specification

  • The ADT transactions are not values of transitionEncounter. The RC-2 handover planned that they would be. They are operations of adt.v1 instead, because each carries a bed, a responsibility, an admission request or a waiver (ADR-HIS-083 point 1). The state model and history of section 4.3 are unchanged.
  • The handover states follow FR-ADM-TRF-002 part 6.2 and section 4.3, which the requirement decides: not yet given, awaiting acknowledgement, acknowledged, declined. DE-ADM-011 lists pending, given and acknowledged. The specification contradicts itself here. The existing attribute is not changed: the 7.3 block states the difference and leaves the reconciliation to the owner (Q3, asked on issue #58).
  • No channel for the decline of a handover (review round 1). Section 4.3 has the named receiver decline in Domain 3, which holds the one handover record. No Domain 3 event yet carries the decline to Domain 1, and the specification does not say how it arrives. Who records a clinical handover decision, and where, is clinical and access behaviour (rule 3), so it is asked, not settled (Q2, issue #58). recordTransferHandover offers give and change-receiver only, and no operation sets Declined. The answer adds the channel in a compatible minor version. The acknowledgement is still taken only from EVT-CLI-011.
  • The release of a bed reservation is BedStateChanged, as ADR-HIS-067 decided, though section 8.5 names ResourceReleased for MOD-ADM-006 too. An event type has one topic, and ResourceReleased is the appointment's.
  • Undoing a vacate entered in error uses a compensating bed history entry, not a Cleaning to Occupied transition (ADR-HIS-083 point 6).
  • Appointments are not reattributed after an unmerge yet. scheduling.v1 has no patient correction, and no RC-3 session builds adm-scheduling-flow. Appointments are listed and stay pending (follow-up).
  • The pre-admitted arrival (Pre-admitted to Registered) is still not offered: section 8.5 has no event for it, and no RC-3 requirement asks for it (Q1).
  • contracts/ess names adm.person.merge, an audit event type that is not in D01-ADM 9.5 (adm.identity.merge). This card changes only ADM files, so it is left for RC-3-S03, which repairs cross-domain references. cross-references.ts reports it.

Needs a person

None of these blocks the merge. Each is listed in the pull request.

  • Domain leads of the slice (D1 ADM; D2 ISE and D10 ESS for the references to them): review of the contracts and of the section 7.3 additions (session plan section 4, end of each contract session).
  • Enterprise Architecture Board: approval of ADR-HIS-083.
  • Questions for the owners of the specification, all posted on issue #58. Q2 is clinical and access behaviour, so the contract leaves that point open instead of settling it (rule 3). Q1 and Q3 are about where a fact travels and a contradiction in the wording:
  • Q1, missing events: section 4.3 drives the emergency flow state "Awaiting bed" from the admission request, and "Pending discharge" from the discharge decision. The flow state lives in adm-scheduling-flow, but section 8.5 has no event for either. The pre-admitted arrival has none either. Should 8.5 gain events for them, for example AdmissionRequested and DischargeDecisionRecorded? Until then the contract publishes none for them. adm-scheduling-flow can read listAdmissionRequests and Encounter.pendingDischarge.
  • Q2, handover decline (owners of D01-ADM and D03-CLI; clinical and access behaviour): section 4.3 has the named receiver decline the handover of a transfer in Domain 3, but only the acknowledgement reaches Domain 1 (EVT-CLI-011). How does the decline, with its reason, reach Domain 1? For example, a Domain 3 event, or EVT-CLI-011 carrying a declined outcome. And who may record it? Until the answer, no operation sets Declined, and RC-3-S08 and RC-3-S19 build no decline action.
  • Q3, handover states (owner of D01-ADM): DE-ADM-011 handover_state lists pending, given and acknowledged, while FR-ADM-TRF-002 part 6.2 and section 4.3 list not yet given, awaiting acknowledgement, acknowledged and declined. The contract follows the requirement. Please reconcile DE-ADM-011, which this session has not changed.

Follow-ups outside the card

  • RC-3-S03:
  • repair adm.person.merge in contracts/ess/api/audit.v1.openapi.yaml;
  • make the D02 engine and backbone call submitEventDeliveryStatuses;
  • map the adapters as in the README table;
  • write the RC-3 scenario.
  • A later ADM contract and scheduling build: a patient correction of an appointment in scheduling.v1, for the attribution after an unmerge (FR-ADM-MPI-005 part 6.9.1).
  • Session plan: UI-ADM-002, the identity stewardship workqueue, is in no RC-3 screen session. Its merge and unmerge decisions are now in the contract.
  • Development realm (FN-S02 or RC-1-S16): the synthetic users of the examples. dev.nurse (ward nurse and charge nurse), dev.bedmanager, dev.housekeeping and dev.himhead (Head of HIM) are needed, beside dev.steward.
  • D10 registrations: the policy resource types, task types, queue, notification types and code lists at the end of contracts/adm/README.md.
  • Not in RC-3: the daily control totals (EVT-ADM-027) and SIRS RS Online (EXT-ADM-008) come with the slices that bring their requirements.
  • Host tooling: as RC-3-S01 noted, the server's Node.js cannot run the contract tool.
  • Design system: none from this session.