Implementation plan / Session plan / Handover RC-4-S01
Handover RC-4-S01 Contract: Contracts, stubs and the failing scenario test (slice RC-4)¶
Card: RC-4-S01. Issue: cema-care/his#168. Branch: session/RC-4-S01. Slice: RC-4. Decision record: ADR-HIS-118.
What was built and where¶
The contracts of slice RC-4 (emergency arrival: unidentified patient, triage and emergency access), their stubs, the section 7.3 additions, the contract points of every RC-4 session, and the RC-4 scenario as a test that fails only because the behaviour is not built.
D01-ADM, in contracts/adm/ (README.md, "What slice RC-4 added")
| API | Version | Unit | What it adds |
|---|---|---|---|
registration.v1 |
1.1 → 1.2 | adm-patient-administration | FR-ADM-REG-004: registerUnidentifiedPatient, registerNewborn (every baby of one birth, all or none, linked to the mother with birth order), reconcileIdentity (complete in place, or route to the steward); evidence reference and former name on a legal name change, aliases (updateDemographics); listRegistrations?identityStatus |
flow.v1 |
1.0 → 1.1 | adm-scheduling-flow | FR-ADM-FLW-003: registerEmergencyArrival (person, encounter and queue item in one idempotent step; downtime back-entry with the form number unique per facility), readEmergencyArrival, listEmergencyArrivals, recordEmergencyDisposition, requestAdmissionFromEmergency; Queue.triageRouting and Queue.emergency; re-routing on changeQueuePriority; "Record the disposition." on actOnQueueItem |
patient-identity.v1 |
1.2 → 1.3 | adm-identity | createPerson with identityStatus: unidentified (no duplicate check) or newborn; recordDemographicChange with identified |
Shared types: Demographics.birthTime, Demographics.multipleBirth, RelatedPerson role mother and relatedEncounterId, evidenceReference, UnidentifiedObservation, DowntimeEntry. QueueStateChanged goes to 1.1 (optional reroute, disposition, admissionRequestId, emergencyArrival). No new ADM event: none is catalogued for these steps, and the existing ones carry them (contracts/adm/TRACE.md, "Events of slice RC-4").
Also in contracts/adm/: TRACE.md (section "Slice RC-4"), README.md (contract points of RC-4-S03, RC-4-S04, RC-4-S06 and the D10 registrations), scripts/cross-references.ts (the RC-4 resource types), scripts/ends-when-rc-4.sh (this card's "Ends when", repeatable) and scripts/verify-stub-wait.sh (verify-stub.sh with a two-minute start wait, for any contract folder: the ADM and ESS stubs need more than verify-stub.sh's ten seconds on this host).
D10-ESS, in contracts/ess/
emergency-access.v11.0 → 1.1:readEmergencyAccessPatterns(FR-ESS-AUZ-002 part 6.10, REP-ESS-005);listEmergencyAccessSessions?reviewOverdue; on the sessionsubjectRole,careSetting,reviewTaskId,reviewOverdue,escalatedAt,followUpTaskId,securityIncidentId.- Two new events for EVT-ESS-005, on
his.ess.emergencyaccesssession.v1: EmergencyAccessReviewed and ReviewOverdue (the catalogue's two names; ADR-HIS-118 point 5). TRACE.md,README.md, andCONTRACT-POINTS.md(RC-4-S02, RC-4-S05, the names ESS registers).
Upstream stub. The slice needs no contract of a domain it does not build beyond those that exist: the security incident of an inappropriate review is contracts/ise security-monitoring.v1 (RC-3), and notification and workflow are ESS's own. stack.json names the ADM, ESS and ISE stubs.
Section 7.3, for approval by the domain leads. Each attribute names its source; no existing attribute changed. - D01-ADM 7.3: - "Added by the RC-4 contracts" blocks in DE-ADM-006 (evidence reference, birth time, multiple birth; the placeholder name as a name of use temp), the registration record (placeholder name, observation, newborn), DE-ADM-007 (role mother, related encounter) and DE-ADM-019 (emergency arrival, disposition, admission request); - three new records: the emergency arrival record, the identity reconciliation record and the queue definition additions. - D10-ESS 7.3: an "Added by the RC-4 contracts" block in DE-ESS-006 (subject role, care setting, review task, escalated at, follow-up task, security incident).
The scenario test of RC-4, in e2e/scenarios/RC-4/: stack.json (stubs adm, ess, ise; no unit yet), builders.ts, rc-4.scenario.ts, README.md.
| Case | Scenario step |
|---|---|
| RC-4-E2E-001 | Steps 1, 2 and 4: two simultaneous unidentified arrivals, triage and re-routing, the board, admission through Awaiting bed and "Admit from emergency", a disposition |
| RC-4-E2E-002 | Step 3: Break-the-Glass from deny-override-available to the review, with the refused role, suspension and resumption |
| RC-4-E2E-003 | Step 5: reconciliation to an existing person through the steward's merge, completion in place, twins, alias and legal name change |
| RC-4-E2E-004 | Downtime back-entry with a duplicate form, and intake on Tier 1 services only |
| RC-4-E2E-005 | The contract walk through the stubs of ADM, ESS and ISE |
ADR-HIS-118: emergency arrival as one orchestrated, idempotent step of adm-scheduling-flow; unidentified persons without a duplicate check, by an explicit status; the admission request from emergency through adm-scheduling-flow; the placeholder name patterns; EVT-ESS-005 as two events; the review workspace reading the session. The record was first numbered ADR-HIS-117. Session RC-3-S23 took that number on main first (#308), so bringing the branch up to date on 2026-12-02 moved it to ADR-HIS-118, with every reference. 118 was then free on main (up to 117) and in every open pull request (112 to 114).
Checks and their result¶
The host's Node.js 22.22 cannot run the TypeScript contract tool, so the Node.js checks ran in the image node:22.18-bookworm with pnpm 10.34.9 through corepack, after pnpm install --frozen-lockfile in contracts/common, adm, ess, ise, fin and e2e/harness. The integration environment ran as HIS_SESSION=RC-4-S01 (his-rc-4-s01) and was reset afterwards.
| Check | Command | Result |
|---|---|---|
| Conventions | pnpm build (his-contract lint .) in contracts/adm and contracts/ess |
passed |
Compatibility with origin/main, stubs up to date |
his-contract check . --base origin/main in contracts/adm, ess, ise, fin |
passed. adm: registration.v1 1.2, flow.v1 1.1, patient-identity.v1 1.3, QueueStateChanged 1.1, 8 new operations, one new optional query parameter; ess: emergency-access.v1 1.1, one new operation and query parameter, two new events; ise and fin unchanged |
| Stubs against the provider contract test | bash ../adm/scripts/verify-stub-wait.sh in each |
adm 566 cases, ess 559, ise 340, fin 10; no violation |
| Cross-domain references | node scripts/cross-references.ts in contracts/adm and contracts/ise |
passed: 462 references to ADM; 294 to and from ISE |
| Scenario folder type check | pnpm build in e2e/harness |
passed |
| Ends when | HIS_SESSION=RC-4-S01 contracts/adm/scripts/ends-when-rc-4.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 | platform/delivery-pipeline/bin/secret-scan code and docs from origin/main |
no secret |
The steps of ends-when-rc-4.sh (STEPS picks steps; KEEP=1 keeps the environment):
- The adm, ess, ise and fin contracts pass the check, and each stub answers all its provider cases with no violation.
- Both cross-reference checks pass.
- On the full profile, for adm and ess: the event schemas register in Apicurio, and the second run reports them unchanged; the topics are created; the sample events are published, read back from Kafka and validated (adm 26, ess 13); each stub on the session network passes all its cases (566 and 559) with a token of the realm
his, with no violation recorded. - The scenarios run. RC-4: RC-4-E2E-005 passes; RC-4-E2E-001 to 004 fail only with
unit "…" is not in this stack(adm-scheduling-flow, ess-runtime-decision, adm-patient-administration, adm-scheduling-flow). RC-3: RC-3-E2E-007 passes, and 001 to 006 fail only with that error, as before.
How the runs went, so that a later session is not surprised:
- Full profile under load. The host's load average was 20 to 41. Twice, Keycloak and Kafka took 15 to 17 minutes to report healthy, longer than his-env start waits, so the start failed. Starting the profile first and waiting for every service to be healthy, then running the script with KEEP=1, worked.
- The final evidence comes from two runs. Steps 1 to 3 passed in one run, and step 4 in a later one (STEPS=4). Between the two only the scenario file changed: no contract or stub.
- The step-4 fixes. The first step-4 run had no test, because the harness refuses PR-… processing-rule identifiers in covers; they were removed. The next one failed the walk on audit.v1's required queryPurpose, now sent.
- The copied script swallowed failures. It had no pipefail inside the container, so a failed check piped into tail did not stop it. This was found when an ESS stub left stale by a late description edit was not caught. It now sets pipefail, and the stub was regenerated. contracts/ise/scripts/ends-when-rc-3.sh has the same weakness (follow-up).
After main was merged into the branch on 2026-12-02 (the ADR renumbered, contract descriptions changed, stubs regenerated), steps 1 and 2 were run again and passed: adm 566 cases, ess 559, ise 340, fin 10, no violation, cross-references 462 and 294. Steps 3 and 4 were not repeated, because no schema, operation or scenario call changed. Lint, check, the scenario type check and the link check passed again.
The evidence records are in e2e/harness/out/evidence/RC-4/ends-when-RC-4-S01-20261201T235619Z and …/RC-3/ends-when-RC-4-S01-20261201T235953Z, which git ignores.
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 and contracts/ess/TRACE.md (slice RC-4), 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: 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; the RC-4 scenario cases that exercise them end to end are given.
| Requirement | Contract | Checked by | Test scenario: build session; scenario case |
|---|---|---|---|
| FR-ADM-REG-004 | registration.v1 1.2 registerUnidentifiedPatient, registerNewborn, reconcileIdentity, updateDemographics (evidence, aliases), listRegistrations?identityStatus; patient-identity.v1 1.3 createPerson (unidentified, newborn), recordDemographicChange (identified); RC-3 merge (resolveIdentityMatch) |
verify cases; cross-references | TEST-ADM-009, TEST-ADM-033: RC-4-S03; RC-4-E2E-001 (simultaneous placeholders), RC-4-E2E-003 |
| FR-ADM-FLW-003 | flow.v1 1.1 registerEmergencyArrival, listEmergencyArrivals, readEmergencyArrival, recordEmergencyDisposition, requestAdmissionFromEmergency, triageRouting on changeQueuePriority; QueueStateChanged 1.1; adt.v1 admitFromEmergency (RC-3) |
verify cases; sample event | TEST-ADM-026, TEST-ADM-036: RC-4-S04; RC-4-E2E-001, RC-4-E2E-004 |
| FR-ESS-AUZ-002 | emergency-access.v1 1.1 (all operations); policy-decision.v1 obligations and emergencySessionId (RC-1); audit.v1 emergencySessionId (RC-1); EmergencyAccessInvoked, EmergencyAccessReviewed, ReviewOverdue |
verify cases; sample events | TEST-ESS-006, TEST-ESS-007: RC-4-S02; RC-4-E2E-002. TEST-ESS-008, TEST-ESS-009: RC-4-S02 unit tests with a test clock and a stopped dependency, and RC-4-S06 as a failure branch (e2e/scenarios/RC-4/README.md) |
The slice's workflows WF-ADM-003 and WF-ESS-002 are RC-4-E2E-001 with 003, and RC-4-E2E-002. UI-ESS-005 (RC-4-S05) works against the ESS stub with the contract points of contracts/ess/CONTRACT-POINTS.md.
Contract changes¶
All within major version 1 and checked compatible against main:
- contracts/adm: registration.v1 1.1 → 1.2, flow.v1 1.0 → 1.1, patient-identity.v1 1.2 → 1.3, by new operations, optional fields and an optional query parameter; NewPerson.duplicateCheck is no longer required (a widened input); QueueStateChanged 1.0 → 1.1 (optional fields); the shared types gain optional fields, two types and the extensible-enum value mother.
- contracts/ess: emergency-access.v1 1.0 → 1.1 (a new operation, a new optional query parameter, optional fields); two new events.
Differences from the card or specification¶
- Rapid registration is offered by adm-scheduling-flow and orchestrates registration and encounter creation in adm-patient-administration, idempotently rather than in one database transaction (ADR-HIS-118 point 1). Part 6.1's "single step" is the user's single step.
- "Awaiting bed" is set through
requestAdmissionFromEmergencyof adm-scheduling-flow, which forwards the request to adt.v1. D01-ADM 4.3 says the system sets it "from the admission request", but no event carries an admission request (ADR-HIS-118 point 3). A request made directly in adt.v1 withfromEmergencydoes not move the board. - Left before completion and death are accepted from any open state of an emergency queue item; discharge and transfer from In service. D01-ADM 4.3 names In service → Completed for the disposition; a patient may leave or die while waiting, which this reading allows.
- The placeholder and newborn name patterns are the session's, on common Indonesian practice (ADR-HIS-118 point 4). The specification requires only uniqueness, distinguishability and no clinical information. Listed for registration governance below.
- EVT-ESS-005 is two events, the second named
ReviewOverdueas in the catalogue row. - adm-identity is changed by contract (patient-identity.v1 1.3) though no RC-4 card builds it. The slice needs it (FR-ADM-REG-004 parts 6.1, 6.2 and 6.4). This follows RC-2-S01, which changed patient-identity.v1 for a fix session of adm-identity. It needs a card (below).
- Earlier slices' scenarios are not run by
ends-when-rc-4.sh. RC-3 is (it is still on stubs). RC-2 and RC-1 now start the built units of their slices, and their regression belongs to the integrate sessions; every change here is additive, andhis-contract checkand the stub verifies prove the earlier operations unchanged.
Needs a person¶
None of these blocks the merge.
- Domain leads of D01-ADM and D10-ESS: 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-118.
- Registration governance (HIM): the placeholder name pattern
TANPA NAMA <facility>-<yymmdd>-<nnn>and the newborn nameBy. Ny. <mother's official name>with the birth order (ADR-HIS-118 point 4). Changing them changes no contract. - Q4 on #15, Security and Privacy Office and Clinical Governance (still open from RC-1): while a session is still Active, does "Extend emergency access" end it and start a new one with its own window and review, or does it run on to its own expiry? Version 1 keeps answering a repeat invocation with the Active session; an extend operation can be added compatibly when answered. RC-4-S02 builds version 1's behaviour.
- Planning (session plan owner): a card for adm-identity to serve patient-identity.v1 1.3 before RC-4-S06; no RC-4 card owns the unit.
Follow-ups outside the card¶
- adm-identity (a card or a fix session before RC-4-S06): serve
createPersonwithidentityStatus: unidentified(no duplicate check, exclusion flagunidentified) andnewborn(exclusion flags, candidates as review items), andrecordDemographicChangewithidentified(contract points incontracts/adm/README.md, slice RC-4; ADR-HIS-118 point 2). - Development realm (FN-S02 or RC-1-S16): users
dev.privacy(privacy officer) anddev.security(security officer, also named by RC-3-S03), anddev.steward(RC-3);dev.clinicianmust hold a Break-the-Glass permitted role and no care relationship to new patients. - RC-4-S06 (integrate): the units, the queue configuration (
triageRouting,emergency,igd-resusitasi) and the users ofe2e/scenarios/RC-4/README.md; TEST-ESS-009 as a failure branch; stop the non-critical services in RC-4-E2E-004. - D10 registrations before the RC-4 units go live: the resource types, actions, code lists, task types, escalation policy and notification type listed at the end of
contracts/adm/README.mdandcontracts/ess/CONTRACT-POINTS.md. - FR-ADM-FLW-002 owner: the emergency flow state Pending discharge "from the discharge decision" has the same gap as Awaiting bed: no event carries
recordDischargeDecisionto adm-scheduling-flow. - Downtime No. RM (TEST-ADM-041, CFG-ADM-008): registration.v1 has no field for a No. RM taken from a downtime block; the back-entry of a new patient with a downtime number needs one (a later slice with NFR-ADM-011).
- Contract tooling (FN-S04 owner):
verify-stub.shof each contract folder waits ten seconds for the stub; the ADM and ESS stubs now take longer on this host.contracts/adm/scripts/verify-stub-wait.shwaits two minutes; the common tool could print its ready line earlier. contracts/ise/scripts/ends-when-rc-3.sh(RC-3 contract sessions): like the RC-4 script before its fix, it runsbash -cwithoutpipefail, so a failedhis-contract checkpiped intotaildoes not stop it.- Development environment (FN-S02 owner): under load, Keycloak and Kafka can take 15 to 17 minutes to report healthy, longer than
his-env startwaits. - Design system: none from this session.