Implementation plan / Session plan / Handover RC-3-S06
Handover RC-3-S06 Build: Patient administration (part 1 of 3)¶
Card: RC-3-S06. Issue: cema-care/his#62. Branch: session/RC-3-S06. Slice: RC-3. Decision record: ADR-HIS-091.
Comes after:
- RC-2-S04, whose unit and encounter lifecycle this extends;
- RC-3-S03, the last contract session of the slice. The ADM contracts this card serves are RC-3-S02's (handover): adt.v1 1.0, encounters.v1 1.2 (the admit and discharge reversals and the inpatient context) and contract points 1 to 9 of RC-3-S06 in contracts/adm/README.md.
What was built and where¶
All of it is in services/adm-patient-administration, plus ADR-HIS-091, its index row and this handover. The unit's README.md lists every module, setting and stand-in. No contract was changed.
| Module | What was added |
|---|---|
mod-adm-005 (FR-ADM-ADT-001, 002, 003), new |
Adt: confirmAdmission, admitFromEmergency, recordLeave, recordReturn, recordDischargeDecision and recordDischarge.AdmissionRequests: DE-ADM-010 and decideAdmissionRequest.Responsibilities: DE-ADM-012 periods.Closure: the DEC-ADM-009 criteria per class, closeEncounter with waivers, closure by itself, and the port api.ClosureInputs.Reversals: the admit and discharge reversals of correctEncounter.Worklists: listInpatientCensus and listAdtWorklistItems.DeliveryTracker and DeliveryScanner: the delivery tracking and reconciliation of every Domain 1 event.clients/HttpScheduling: scheduling.v1 listAppointments.Migration V1__adt.sql. Test fixture FakeScheduling |
mod-adm-006 (bed occupancy), new |
BedLedger as api.BedOccupancy: occupy, vacate, compensating restore, reserve, release. DE-ADM-013 with append-only history, DE-ADM-014 with one active reservation per bed and per encounter, BedStateChanged and BedReserved on his.adm.bed.v1. api.ReservationListener. HttpBedRegistry (master-data.v1 readLocation).Migration V1__bed_occupancy.sql. Test fixture FakeBedRegistry. beds.v1 itself is RC-3-S07's |
mod-adm-004 |
api.EncounterRecords (implemented by AdtEncounterRecords), api.AdtReversals, api.Registries (RegistryPort).Migration V3__inpatient_context.sql: the inpatient context of encounters.v1 1.2 as one inpatient document, shown by every encounter read.correctEncounter reverses admit and discharge through AdtReversals, publishing EncounterCorrected 1.1 with location and responsibility, and refuses a Closed encounter.Registry reads organizations (ORGANIZATION, readOrganization) |
mod-adm-002 (test fixtures only) |
AdmTestSupport also clears the schemas mod_adm_005 and mod_adm_006 between tests |
app |
AdmissionJourneyTest (TEST-ADM-035). The provider contract test covers the 19 adt.v1 operations beside the 18 of RC-2. The consumer contract test adds readLocation, readOrganization and scheduling.v1 listAppointments |
The unit publishes PatientAdmitted, PatientLeaveStarted, PatientReturnedFromLeave, EncounterClosed, ResponsibilityChanged and PatientDischarged 1.1 on his.adm.encounter.v1, ordered per encounter. It publishes BedStateChanged and BedReserved on his.adm.bed.v1, ordered per bed. It consumes the eight Domain 1 topics (delivery tracking), his.ise.deliveryexception.v1 (InterfaceMessageDeadLettered) and the QueueStateChanged of his.adm.encounterflow.v1 (triage for closure).
Dependencies: none added. The lockfiles of mod-adm-005 and mod-adm-006 were written with ./gradlew :mod-adm-005:dependencies :mod-adm-006:dependencies --write-locks and hold the same versions as mod-adm-004's.
Policy: the actions and resource types of ADR-HIS-091 point 6, for D10 to register (follow-ups).
Checks and their result¶
The integration environment ran as HIS_SESSION=RC-3-S06 (his-rc-3-s06), light profile.
| Check | Command | Result |
|---|---|---|
| Build and all tests | ./gradlew build in services/adm-patient-administration |
passed, 163 tests:
|
| Provider contract test | ProviderContractTest (tag contract): his-contract verify contracts/adm --operation <each of the 37> against the unit, with a token permitted for RSU-01 and RSU-02 and denied otherwise. submitEventDeliveryStatuses runs with the integration engine's service identity. Then his-contract validate-event contracts/adm on everything published |
passed, 152 of 152 cases, the facility cases included. validate-event passed, with PatientAdmitted, PatientLeaveStarted, PatientReturnedFromLeave, ResponsibilityChanged, EncounterClosed and BedStateChanged among the events |
| Consumer contract test | ConsumerContractTest: each client against his-contract serve of contracts/adm, ess and fin |
no violation recorded, readLocation, readOrganization and listAppointments included |
| 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 (8 medium); no dependency added by this card |
| Documentation | python3 docs/implementation_plan/tools/check_links.py; mkdocs build |
0 broken links; the site builds |
Requirements and test scenarios¶
Tests carry the requirement and scenario tags (session rule 5). The classes are mod-adm-005/src/test/java/care/cema/his/adm/mod005/ (AdmissionTest, DischargeClosureTest, AdtEventPublicationTest) and app/src/test/java/care/cema/his/adm/app/ (AdmissionJourneyTest, contract/).
| Requirement, criterion | Test | Scenario |
|---|---|---|
| FR-ADM-ADT-001 AC-01, PR-ADT-001-1, part 6.2 (reserved bed: Admitted, bed Occupied, responsibility from the same effective time, request Admitted; PatientAdmitted, then ResponsibilityChanged; BedStateChanged; audited) | AdmissionTest.admissionWithReservedBed |
TEST-ADM-015 |
| FR-ADM-ADT-001 PR-ADT-001-1, part 10, BR-ADM-013 (bed not available: "Selected bed is not available: Occupied.", nothing changed; another facility's, retired or unknown bed refused; registry down 503) | AdmissionTest.bedNotAvailableChangesNothing |
TEST-ADM-015 |
| FR-ADM-ADT-001 PR-ADT-001-3, SAFE-004 (same key, one admission; stale version 412; second admission refused; two admissions into one bed, one wins, three rounds) | AdmissionTest.duplicateAndConcurrentConfirmation |
TEST-ADM-015 |
| FR-ADM-ADT-001 part 10, BR-ADM-010 (inactive practitioner, future or earlier-than-start time, registry outage, Cancelled encounter, the open request must be named) | AdmissionTest.admissionChecks |
TEST-ADM-015 |
| FR-ADM-ADT-001 AC-02, PR-ADT-001-2 (leave with bed-hold: On leave, the bed stays the patient's, neither admitted into nor reserved) | AdmissionTest.leaveWithBedHold |
TEST-ADM-015 |
| FR-ADM-ADT-001 part 6.4, CFG-ADM-026, AC-03 (expected return after leave; a hold beyond 24 hours needs the bed manager; no hold sends the bed to Cleaning; return then needs a bed) | AdmissionTest.leaveRules |
TEST-ADM-015 |
| FR-ADM-ADT-001 AC-03, part 6.6 (return to the held bed, location current; overdue-return worklist until the return) | AdmissionTest.returnAndOverdue |
TEST-ADM-015 |
| FR-ADM-ADT-001 AC-04 (emergency admission during a backbone outage; events delivered in order on recovery) | AdmissionTest.admissionDuringOutage |
TEST-ADM-015 |
| FR-ADM-ADT-001 AC-05, part 6.3, DEC-ADM-008 (admit from emergency: emergency encounter Discharged as Admitted, linked inpatient encounter of the same episode Admitted, no CFG-ADM-010 warning, one result per key) | AdmissionTest.admitFromEmergency, AdmissionJourneyTest.emergencyToInpatient |
TEST-ADM-015, TEST-ADM-035 |
| FR-ADM-ADT-001 part 6.1 (admission requests: mandatory fields, one open per encounter, accept, cancel with reason releases the reserved bed, history) | AdmissionTest.admissionRequests |
TEST-ADM-015 |
| FR-ADM-ADT-001 parts 3 and 12, architecture 7.5 (another facility not found, deny 403 audited, outage 503) | AdmissionTest.facilityAndPolicy |
TEST-ADM-015 |
| FR-ADM-ADT-003 AC-01, PR-ADT-003-1, parts 6.2 to 6.4 (Discharged, bed to Cleaning, responsibility ended, PatientDischarged 1.1 and BedStateChanged, ResponsibilityChanged cause discharge) | DischargeClosureTest.discharge |
TEST-ADM-017 |
| FR-ADM-ADT-003 part 10 (disposition required, not before admission, destination for a transfer out; from On leave; not from Discharged) | DischargeClosureTest.dischargeChecks |
TEST-ADM-017 |
| FR-ADM-ADT-003 part 6.1 (discharge decision: pending discharge, no state change, the responsible clinician only, withdrawn) | DischargeClosureTest.dischargeDecision |
TEST-ADM-017 |
| FR-ADM-ADT-003 AC-02, PR-ADT-003-2, BR-ADM-021, part 6.7 (unreported criteria unmet; closure refused listing them; aged-open worklist; the discharge summary never waivable) | DischargeClosureTest.unmetCriteria |
TEST-ADM-017 |
| FR-ADM-ADT-003 AC-03, DEC-ADM-009 (waivers per category by the role holding authority, reason and expiry; Closed; EncounterClosed with waivers; audited) | DischargeClosureTest.waivers |
TEST-ADM-017 |
| FR-ADM-ADT-003 part 6.5 and 6.6 (closure inputs, open orders, triage; closed by itself when all are met) | DischargeClosureTest.closesWhenAllMet |
TEST-ADM-017 |
| FR-ADM-ADT-003 AC-04, part 8 (discharge reversed: Admitted in its bed by a compensating entry, a new responsibility period, EncounterCorrected 1.1, history kept; another bed when the first is taken) | DischargeClosureTest.dischargeReversal |
TEST-ADM-017 |
| FR-ADM-ADT-002 AC-05, part 6.4 (a compensating event references the entry it corrects; the original event is unchanged). The test corrects a discharge; the corrected transfer of AC-05 is RC-3-S08's (transfers.v1 correctTransfer) | DischargeClosureTest.dischargeReversal |
TEST-ADM-016 |
FR-ADM-ADT-002 AC-02 (HL7 v2 A01, A02, A03, A08, A40 validated and acknowledged end to end). Not testable in this unit: the messages are made by the D02 adapters from these events (part 5). This unit supplies the content, validated against the contract (provider contract test, validate-event), and takes the ACK and NACK through submitEventDeliveryStatuses (AdtEventPublicationTest.rejectionGapReplay). The end-to-end case is RC-3-E2E-003, run by the integrate session RC-3-S24 with the adapters of RC-3-S15 and RC-3-S16 |
ProviderContractTest (content), AdtEventPublicationTest.rejectionGapReplay (acknowledgements); end to end RC-3-E2E-003 |
TEST-ADM-016 |
| PR-ADT-001-3 (a repeated key answers the original result, also after the encounter moved on; a key reused for another encounter refused on /Idempotency-Key, nothing changed) | AdmissionTest.duplicateAndConcurrentConfirmation |
TEST-ADM-015 |
| FR-ADM-ADT-002 PR-ADT-002-2, D01-ADM 11.1 (the overdue-acknowledgement detection reported in the unit's health: inactive without required consumers, active with them) | AdmissionTest.detectionInactiveIsVisible, AdtEventPublicationTest.detectionActive |
TEST-ADM-034 |
| Section 4.3, encounters.v1 1.2 (admission reversed to Registered, bed to Cleaning, responsibility ended; supervisor only; a Closed encounter not reversed) | DischargeClosureTest.admissionReversalAndClosed |
TEST-ADM-017 |
| FR-ADM-ADT-003 PR-ADT-003-3 (death: death documentation criterion, future appointments listed; scheduling down 503) | DischargeClosureTest.deathDisposition |
TEST-ADM-017 |
| FR-ADM-ADT-002 AC-01, parts 6.1 to 6.3 (unique identifiers, strictly increasing sequence, envelope; no demographic values) | AdtEventPublicationTest.uniqueOrderedEvents |
TEST-ADM-016 |
| FR-ADM-ADT-002 AC-03, part 10 (backbone outage blocks nothing; delivered in order on recovery; redelivery has no second effect) | AdtEventPublicationTest.outageDuplicateDelayed |
TEST-ADM-034 |
| FR-ADM-ADT-002 AC-04, PR-ADT-002-2 (overdue acknowledgement listed with its business transaction, clinical and other timeouts; the acknowledgement closes it) | AdtEventPublicationTest.overdueAcknowledgement |
TEST-ADM-016, TEST-ADM-034 |
| FR-ADM-ADT-002 PR-ADT-002-1, PR-ADT-002-3, parts 7 and 12 (rejection and gap items at once; repeated status counted once; replay requested, acknowledgement closes; reconciled; adm.event.replay) | AdtEventPublicationTest.rejectionGapReplay |
TEST-ADM-034 |
| FR-ADM-ADT-002 part 3 (only D02 identities report, adm.service.denied; a status for an unknown event kept and applied; dead letter item) | AdtEventPublicationTest.reportersUnknownDeadLetter |
TEST-ADM-034 |
| FR-ADM-ADT-002 part 8, AC-03 (census with lastEventSequence) | AdtEventPublicationTest.census |
TEST-ADM-034 |
| FR-ADM-ADT-002 with CFG-ADM-011 (ADT back-entered after downtime: beyond 24 hours only by a supervisor, a repeated entry no second effect, order kept, the census reconciles) | AdtEventPublicationTest.downtimeBackEntry |
TEST-ADM-036, the ADT part |
| FR-ADM-ADT-002 AC-06 (propagation measured, p95 under 5 seconds in the unit) | AdtEventPublicationTest.propagation |
TEST-ADM-016 |
| FR-ADM-REG-001, ENC-001, ADT-001, ADT-002, ADT-003 end to end (registration, request, admission, leave, return, decision, discharge; encounter, bed, census, events and tracking agree) | AdmissionJourneyTest.inpatientStay |
TEST-ADM-035, without the transfer |
| Every operation of adt.v1; every new client against its provider's stub | contract/ProviderContractTest, contract/ConsumerContractTest |
TEST-ADM-015, 016, 017 |
Safety-critical function "ADT event publication" (D01-ADM 11.1). The control is built as specified:
- the transactional outbox, written in each ADT transaction (the kit's DomainEventPublisher);
- unique events ordered per encounter;
- acknowledgement tracking per event and required consumer;
- the reconciliation worklist.
Its verification, TEST-ADM-016 and TEST-ADM-034, passes (the AdtEventPublicationTest rows above). The control is implemented as the specification states and not altered, so there is no hazard log entry to update. The clinical safety officer's review of the merged change is not named on this card.
Non-functional targets designed for: - NFR-ADM-005 (security). Every operation asks the decision point, each ADT step as an action of its own. A facility not permitted is refused before "not found". Every transaction, refusal, waiver and resolution is audited (adm.adt.change, adm.encounter.change, adm.bed.change, adm.event.replay, adm.service.denied). An outage is 503. - NFR-ADM-009 (interoperability). 152 provider cases pass, the events validate, and the consumer stubs record no violation. The events carry what the D02 HL7 v2 and FHIR adapters need (README mapping table of contracts/adm). - NFR-ADM-012 (observability). The kit's traces and correlation identifiers. Every event is traceable by event and correlation identifier (readEventDelivery), and the tracker logs each item it opens. - NFR-ADM-013 (localization). Timeouts, hold durations, criteria and dispositions are settings or configuration stand-ins; user messages are those of the requirements. - NFR-ADM-014 (time integrity). Effective and recorded times are kept in UTC to the millisecond. Effective times are checked against the history and the CFG-ADM-011 tolerance, and the events carry both times.
Differences from the specification or the contract¶
- Bed occupancy is built here, ahead of beds.v1 (ADR-HIS-091 point 3). The ADT transactions must change the bed in their own transaction, and the bed card RC-3-S07 comes after this one.
mod-adm-006holds only the ledger the transactions need. Its beds are D10 locations confirmed by the registry. No beds.v1 operation is served, so a reservation is made only through the port (as the tests do). Bed turnover, so that a cleaned bed becomes Available again, is beds.v1's. - "With the alternatives of searchEligibleBeds" (part 10 of FR-ADM-ADT-001). The refusal names the bed's state; the alternatives come with searchEligibleBeds (RC-3-S07).
- The closure criteria of Domains 3, 5 and 6 stay unmet until their subscriptions exist (PR-ADT-003-2). No D03, D05 or D06 event of D01-ADM 8.5 has a contract yet; the port
ClosureInputsis where they report. Until then an inpatient encounter cannot close: its discharge summary is never waivable. An outpatient or emergency one closes with waivers (AC-03). - Admitting privileges (FR-ADM-ADT-001 part 3). master-data.v1 checkPractitionerPrivilege is per procedure code, and D10 has no code for admitting. The requesting clinician must be active in the registry, and the privilege is the decision point's (
createon adm.AdmissionRequest). This is a follow-up for D10. - The responsible clinician of the discharge decision is decided by the decision point, which is given the encounter's attending practitioner (action
decide-discharge). The unit cannot match a user to a D10 practitioner itself. - The medication reconciliation check (CFG-CLI-013) is read by the screen from Domain 3, as the contract says. The unit records the override when it is given, but cannot check whether the check warned: Domain 3 has no contract for it yet.
- An admission reversed as entered in error sends its bed to Cleaning even when the patient was never placed. Domain 1 cannot tell, and a cleaned bed is the safe side (ADR-HIS-091). The admission request stays Admitted, since the contract gives no state for "admission reversed".
- The reversal of an emergency discharge that continued into admission is refused, with "reverse that admission instead". The two encounters are one care episode, and the inpatient one would be left without its predecessor.
- The required consumers of each Domain 1 event are configuration (ADR-HIS-091 point 5), empty by default. D01-ADM 8.5 names consumer domains, not subscriptions; Domain 2 registers those. A consumer D02 reports is tracked from its first status. Review round 1 asked for the hazard of that default to be visible:
- while the list is empty, a delivery Domain 2 never reported cannot fall overdue, so a lost event to a silent consumer is not listed;
- rejections, reported gaps and dead letters are still detected, and the outbox, ordering and replay are unaffected;
- the unit says so at startup and on every scan (WARN), and in its health (
/actuator/health, componentadtDelivery:overdueAcknowledgementDetection: inactivewith the warning); - it stays UP, because event delivery must never block an ADT transaction (part 9);
- an empty default is safe only until the slice is integrated: RC-3-S16 supplies the consumers, and RC-3-S24 must set them in the stack.
- The worklists
cancelled-with-activityandunattributed-after-unmergeanswer an empty list. They belong to FR-ADM-ENC-003 (RC-3-S07) and to the attribution of FR-ADM-MPI-005. - TEST-ADM-036 is covered for ADT only. Its downtime registration (FR-ADM-FLW-003, FR-ADM-XRF-001) is not this unit's, and no RC-3 ADM card builds the D02 downtime entry check (RC-3-S03 follow-up). The ADT back-entry is tested: the supervisor's backdating, one result per key, order kept, and the census.
- Two settings of the provider contract test only:
his.adm.adt.single-open-request=false, because verify repeats readAdmissionRequest's setup for one encounter;- a clock tolerance of 7 days, because the recordDischarge example (2026-11-29T04:30Z) may lie ahead of the clock.
The module tests cover both rules. The precedent is RC-2-S04's identical-window setting.
Review round 1¶
The review asked for four changes, all made on this branch:
- AC-02 and AC-05 of FR-ADM-ADT-002 are now named. AC-05 is in dischargeReversal's tag and title, and the test checks that the original event is unchanged and that the correction references its entry. AC-02 is recorded above as RC-3-E2E-003's, and the corrected transfer of AC-05 as RC-3-S08's.
- PR-ADT-001-3, the original result. A repeated Idempotency-Key now answers the answer recorded with the key in the command's transaction (idempotency_record.result), not the current state. A key used for another encounter or record is refused, 400 on /Idempotency-Key, and nothing changes. This holds for every adt.v1 command: the six ADT transactions, createAdmissionRequest, decideAdmissionRequest, closeEncounter and resolveEventReconciliationItem. A discharge answers its own result even when the encounter closed itself at once.
- The empty required consumers are visible (above).
- The responsible unit's message is now "Select an active responsible unit." FR-ADM-ADT-001 part 10 gives a message for the practitioner only, and the contract's "Select an active practitioner or team." stays for the practitioner and care team.
Questions for a person¶
None is open. No question under rule 3 was needed: where the card or the specification left a point open, the choices above follow its text and are recorded in ADR-HIS-091.
Follow-ups outside the card¶
- RC-3-S07 (beds.v1):
- serve beds.v1 on
mod006.api.BedOccupancyandBedLedger; - cleaning tasks and turnover (Cleaning to Available), with the terminal clean;
- isolation and room-mates, eligible-bed search (and its alternatives in the admission refusal), and reservation expiry and invalidation;
- make
reserveBedwith an admission request tellReservationListener; - fill the
cancelled-with-activityworklist. - RC-3-S08 (transfers.v1): build on
EncounterRecords,BedOccupancyandResponsibilities(package-private tomod005today: the transfer module will need anapiport for responsibility periods, or the period store moves into theapi). - D10 registrations before ADM goes live (RC-1-S16, as RC-2-S10 did):
- the actions of ADR-HIS-091 point 6 on
adm.Encounter; - the resource types
adm.AdmissionRequest,adm.EncounterClosure,adm.EventDelivery,adm.ReconciliationItemandadm.Bed; - the waiver roles (Head of HIM, medical director or delegate, revenue cycle manager);
decide-dischargelimited to the attending practitioner;reportfor the D02 service identities;- terminology:
urn:his:adm:admission-acuity,admission-request-cancellation-reason,leave-reason,closure-waiver-reason,reconciliation-reason, and the discharge dispositionsadmitted,transferred,died; - an admitting privilege in the practitioner registry, if governance wants one checked by the unit.
- RC-3-S24 (integrate): set
his.adm.delivery.required-consumersin the RC-3 stack, so that the health shows the overdue detection active. - RC-3-S16 (D02 delivery status feed): call
submitEventDeliveryStatuseswith the service identitiesintegration-engineorevent-backbone, and supply the required consumers per topic (his.adm.delivery.required-consumers). - Closure inputs: when D03 (ClinicalEntryCreated, ClinicalEntrySigned, ClinicalEntryAmended, MedicationReconciliationCompleted, the order events), D05 (InvoiceIssued) and D06 (CodingFinalized, ChartCompleted) publish contracts, subscribe and report through
mod005.api.ClosureInputs, and the downstream activity throughmod004.api.DownstreamActivity. - RC-3-S24 (integrate): set
his.adm.master-data.url(readLocation, readOrganization) andhis.adm.scheduling.url. The unit also consumeshis.ise.deliveryexception.v1andhis.adm.encounterflow.v1. - Death disposition: adm-identity sets the deceased indicator from PatientDischarged (contract point 4 of RC-3-S06); this unit lists the appointments only.
- Design system: none from this session.