Implementation plan / Session plan / Handover RC-2-S01
Handover RC-2-S01 Contract: Contracts, stubs and the failing scenario test (slice RC-2)¶
Card: RC-2-S01. Issue: cema-care/his#46. Branch: session/RC-2-S01. Slice: RC-2. Decision record: ADR-HIS-067.
What was built and where¶
Done first, as issue #46 asked: patient-identity.v1 1.1 (answer A to Q-S09-4 of RC-1-S09, which is blocked on it). Compatible minor version, his-contract check passed, stubs regenerated.
| Point of #46 | In the contract |
|---|---|
| 1. A pair review from adm-patient-administration | recordIdentityReview, POST /v1/identity-reviews. Enterprise-scoped, Idempotency-Key. Body IdentityReviewRequest: personId, trigger (registration or demographic-change), registrationId, duplicateCheck (DuplicateCheckAnswer), heldDemographics, heldIdentifiers, source. Answer IdentityReview: reviewItems[] of matchId, candidatePersonId, response, highRisk, plus the person's identityUnderReview and ambiguityFlag |
| 2. An open review item that is not high-risk | Person.identityUnderReview (DE-ADM-001 identity_under_review, added to 7.3) |
| 3. The INT-ADM-001 handoff | recordDemographicChange, POST /v1/persons/{personId}/demographic-changes. Ordered by demographicsVersion: a version already applied answers the person unchanged, a gap is 412. adm-identity re-indexes and publishes IdentityUpdated |
RC-1-S09 can go on against the stub of 1.1 (session rule 12). adm-identity serving it is the RC-1-S08 fix recorded on #40, not this card. The contract points of both are in contracts/adm/README.md, "Contract points of slice RC-2".
The D01-ADM contracts of RC-2, in contracts/adm/
| API | Version | Unit | Operations |
|---|---|---|---|
registration.v1 |
1.1 | adm-patient-administration | +3: runConsentCheck, recordConsentReference, listConsentReferences (FR-ADM-REF-002); Registration.consentReferences |
encounters.v1 |
1.1 | adm-patient-administration | +5: transitionEncounter, correctEncounter, listEncounterHistory (FR-ADM-ENC-002); capturePayerReference, listPayerReferences (FR-ADM-REF-001); Encounter.disposition, cancellation, payerContext, appointmentId |
scheduling.v1 |
1.0, new | adm-scheduling-flow | 33: templates and calendars (create, list, read, revise, approve or retire), availability exceptions, affected appointments, slot search, appointments (book, list, read, reschedule, cancel, check in, no-show, progress, reminders), Domain 7 requests, waitlist (create, list, read, priority change, offer, offer response, closure, proposals) (FR-ADM-SCH-001 to 004) |
flow.v1 |
1.0, new | adm-scheduling-flow | 11: queues, arrivals, queue items and their actions and priority changes, call display, flow boards, flow state (FR-ADM-FLW-001, 002) |
Nine new events, each in the event catalogue with ADM as producer:
- on his.adm.encounter.v1: PatientDischarged (EVT-ADM-011, the end of visit), EncounterCancelled (015), EncounterCorrected (026);
- on his.adm.appointment.v1: AppointmentBooked (019), AppointmentChanged (020), AppointmentArrived (021), ResourceReleased (018);
- on his.adm.waitlistentry.v1: WaitlistEntryChanged (022);
- on his.adm.encounterflow.v1: QueueStateChanged (023), aggregate EncounterFlow, ordered per encounter (ADR-HIS-067 point 3).
Other files: TRACE.md (a section per API of RC-2), README.md (what RC-2 added, names registered in D10, contract points of every RC-2 session), scripts/cross-references.ts (now also checks contracts/fin and the RC-2 names), scripts/ends-when-rc-2.sh (this card's "Ends when", repeatable).
The D10-ESS contracts of RC-2, in contracts/ess/. consent.v1 (IF-ESS-005, 7 operations: record, list with as-at, read, versions, new version, withdraw, entered in error) and notification.v1 (IF-ESS-009, 9 operations: request with recipient resolution and deduplication, list, read with deliveries, cancel, close, retry, channel settings, notification-type validation). Events ConsentChanged (EVT-ESS-002, his.ess.consentdirective.v1) and NotificationStatusChanged (EVT-ESS-009, his.ess.notification.v1). README.md, TRACE.md and CONTRACT-POINTS.md (RC-2-S02, RC-2-S03, RC-2-S09 and the consuming domains) are extended.
The upstream contract of D05-FIN, in contracts/fin/ (new folder). coverage.v1 (IF-FIN-003 eligibility part: requestEligibility, readEligibilityRequest) and CoverageVerified (EVT-FIN-011, his.fin.coverage.v1), with package.json, pnpm-lock.yaml (links @his/contract-tools only, like the other domains), README.md, TRACE.md, stubs and scripts/verify-stub.sh. Payer capture (FR-ADM-REF-001, TEST-ADM-029) calls Domain 5, which no RC-2 session builds; this is the card's "stub for every upstream module the slice needs but does not build". The D05-FIN contract session of slice BC-1 owns the folder from then on.
Section 7.3, for approval by the domain leads, each attribute with its source and a classification line; no existing attribute changed: - D01-ADM 7.3: new entity sections DE-ADM-009 EncounterStateHistory, DE-ADM-015 AppointmentTemplate, DE-ADM-016 ResourceCalendar, DE-ADM-018 WaitlistEntry, DE-ADM-020 FlowStateProjection, DE-ADM-021 PayerReference, DE-ADM-022 ConsentReference (their 7.2 rows now link to them), and the appointment request beside DE-ADM-017; additions to DE-ADM-001 (identity_under_review), DE-ADM-004 (registration, held data), DE-ADM-008 (cancellation), DE-ADM-017 and DE-ADM-019; - D10-ESS 7.3: additions to the consent directive (DE-ESS-007) and the notification (DE-ESS-014), and two tables (recipient channel settings, notification type).
The scenario test of RC-2, in e2e/scenarios/RC-2/: stack.json (stubs adm, ess, fin; no unit yet), builders.ts, rc-2.scenario.ts, README.md. RC-2-E2E-001 walks scenario steps 1 to 5 through the units; 002 the cancellation, waiting list and reschedule; 003 the encounter state machine; 004 the priority queue; 005 the contract walk through the stubs.
ADR-HIS-067 and its row in the decision record index (66 records).
Checks and their result¶
Node.js is not installed on this server. The Node.js checks ran in the node:22.18-bookworm image with pnpm 10.34.9 through corepack, after pnpm install --frozen-lockfile in contracts/common and in each contract folder. The integration environment ran as HIS_SESSION=RC-2-S01 (his-rc-2-s01) and was reset afterwards.
| Check | Command | Result |
|---|---|---|
| Conventions | pnpm build (his-contract lint .) in contracts/adm, ess, fin |
passed |
Compatibility with origin/main, stubs up to date |
his-contract check . --base origin/main in contracts/adm, ess, fin |
passed. adm: three APIs 1.0 to 1.1 with new operations, two new APIs, nine new events; ess: two new APIs and events; fin: new |
| Stub against the provider contract test | scripts/verify-stub.sh in each |
adm 322 cases, ess 494, fin 10; no violation |
| Cross-domain references | node scripts/cross-references.ts in contracts/adm |
passed, 349 references (adm, ess, ise, fin) |
| Scenario folder type check | pnpm build in e2e/harness |
passed |
| Ends when | HIS_SESSION=RC-2-S01 contracts/adm/scripts/ends-when-rc-2.sh |
passed, see below |
| Documentation links | python3 docs/implementation_plan/tools/check_links.py |
0 broken, 0 duplicate anchors |
| Documentation site | mkdocs build |
builds; its warnings are older ones of other files |
| Secret scan, static analysis, dependency scan | secret-scan code and secret-scan docs from origin/main; static-analysis on contracts/adm, ess, fin and e2e/scenarios/RC-2; dependency-scan contracts/fin |
no secret; no blocking finding; 0 components and 0 blocking |
The steps of ends-when-rc-2.sh:
- The adm, ess and fin contracts pass the check, and each stub answers all its provider cases with no violation.
- The cross-references pass.
- On the full profile, for each of adm, ess and fin: the schemas register in Apicurio,
unchangedon the second run; the topics are created; the sample events are published, read back from Kafka and validated; the stub on the session network passes all its cases with a token of the realmhis(userdev.registrar). Result: adm 14 sample events and 322 cases, ess 11 and 494, fin 1 and 10; schemasunchangedon the second run; no violation. - The scenarios of RC-2 and RC-1 run. RC-2-E2E-005 and RC-1-E2E-005 pass; every other test (RC-2-E2E-001 to 004, RC-1-E2E-001 to 004) fails with
unit "adm-identity" is not in this stack, the only failure the step accepts.
The first two runs stopped at step 3 on the ESS stub, with no message: the realm's token had expired during the earlier domains (it lives five minutes), and verify's output was lost on the pipe. The script now takes a fresh token for each domain and writes verify's output to a file first.
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, contracts/ess/TRACE.md, contracts/fin/TRACE.md, 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. Each requirement of the card's modules, with what serves it and what proves it:
| Requirement | Contract | Checked by | Scenario (test scenario of 15.2) |
|---|---|---|---|
| FR-ADM-ENC-002 | transitionEncounter, correctEncounter, listEncounterHistory; PatientDischarged, EncounterCancelled, EncounterCorrected |
verify cases; sample events | RC-2-E2E-001 step 5, RC-2-E2E-003 (TEST-ADM-013), for RC-2-S04 |
| FR-ADM-SCH-001 | templates, calendars, exceptions, affected appointments, searchSlots |
verify cases | RC-2-E2E-001 setup and step 1 (TEST-ADM-020), for RC-2-S05 |
| FR-ADM-SCH-002 | appointments, reminders, Domain 7 requests; AppointmentBooked, Changed, Arrived; notification.v1 | verify cases; sample events | RC-2-E2E-001 steps 1 to 3, RC-2-E2E-002 (TEST-ADM-021), for RC-2-S05 |
| FR-ADM-SCH-003 | searchSlots (all resources, unmet dependencies, patient conflict), atomic bookAppointment; ResourceReleased |
verify cases | RC-2-E2E-001 step 1 (TEST-ADM-022), for RC-2-S05 |
| FR-ADM-SCH-004 | waitlist operations and proposals; WaitlistEntryChanged | verify cases | RC-2-E2E-002 (TEST-ADM-023), for RC-2-S05 |
| FR-ADM-FLW-001 | arrivals, queue items, actions, priority changes, call display; QueueStateChanged | verify cases | RC-2-E2E-001 step 4, RC-2-E2E-004 (TEST-ADM-024), for RC-2-S06 |
| FR-ADM-FLW-002 | flow boards, flow state | verify cases | RC-2-E2E-001 step 4 (TEST-ADM-025), for RC-2-S06 |
| FR-ADM-REF-001 | capturePayerReference, listPayerReferences, payerContext; contracts/fin requestEligibility, CoverageVerified |
verify cases (adm, fin) | RC-2-E2E-001 step 3, RC-2-E2E-005 (TEST-ADM-029), for RC-2-S04 |
| FR-ADM-REF-002 | runConsentCheck, recordConsentReference, listConsentReferences; consent.v1 |
verify cases (adm, ess) | RC-2-E2E-001 step 3 (TEST-ADM-030), for RC-2-S04 |
| FR-ESS-CNS-001 | consent.v1, ConsentChanged | verify cases (ess) | RC-2-E2E-001 step 3, RC-2-E2E-005 (TEST-ESS-012), for RC-2-S02 |
| FR-ESS-NTF-001 | notification.v1, NotificationStatusChanged | verify cases (ess) | RC-2-E2E-001 step 2, RC-2-E2E-005 (TEST-ESS-025, TEST-ESS-026), for RC-2-S03 |
The slice's workflows WF-ADM-007 and WF-ADM-008 are RC-2-E2E-001 and 002.
Contract changes¶
All within major version 1 and checked compatible:
- contracts/adm: patient-identity.v1 1.0 to 1.1 (#46), registration.v1 1.0 to 1.1, encounters.v1 1.0 to 1.1, each by new operations and optional fields only; new APIs scheduling.v1, flow.v1; nine new events.
- contracts/ess: new APIs consent.v1, notification.v1; two new events. No existing operation or schema changed.
- contracts/fin: new.
Differences from the card or specification¶
- Encounter transitions in RC-2 are those of the outpatient visit (
end-visit,cancel, and the reversal ofend-visit). Admission, leave, return, inpatient discharge and closure are ADT transactions of MOD-ADM-005 (RC-3), which add their values totransitionEncounter. The arrival of a pre-admitted encounter has no event in the catalogue and is left to RC-3 with pre-admission. TEST-ADM-013 is covered for the transitions of this version. - The end of an outpatient visit publishes PatientDischarged (EVT-ADM-011, catalogued for MOD-ADM-005), because section 4.3 makes Discharged the end of visit and the producer is the unit, not the module.
- QueueStateChanged has its own aggregate,
EncounterFlow, onhis.adm.encounterflow.v1, so that queue events are ordered per encounter (8.5) without a second producer on the encounter topic (ADR-HIS-067 point 3). - A refused transition's reason code is the problem's
detail, not a new field, because the sharedProblembelongs tocontracts/common. - Appointments are referenced by
appointmentId: the sharedReferenceTypehas noAppointment. - The ADM consent type is the ESS string type (
general-consent,external-sharing, …), by architecture 6.6. contracts/finwas written by this session, though it is the FIN domain's folder: the card asks for a stub of every upstream module the slice needs, and a stub needs a contract. Only the eligibility part of IF-FIN-003 is in it.- The contract walk RC-2-E2E-005 covers creations, reads and lists, not the sub-resource commands: the harness's stubs permit
SYN-FAC-01/02, and a stub seeds sub-resource records from the contract example's facility only.verify-stub.shcovers every operation.
Questions for a person¶
Reviews and approvals: given (reported by the person on 25 Nov 2026 in the session's conversation, recorded on #46):
- the D01-ADM and D10-ESS domain leads approved the contracts and the section 7.3 additions;
- the D05-FIN leads approved contracts/fin as the upstream contract;
- the Enterprise Architecture Board approved ADR-HIS-067. Its Record line and index row say so.
All seven settled. Q-RC2-2, 4, 5 and 7 were decided after the person's request to decide on common practice; Q-RC2-1, 3 and 6 were answered by the person one by one after review round 2 (25 Nov 2026: "questions -> use your best judgement, use best common practices"), as RC-1-S09 did for Q-S09-1 to 3. The answer and every decision with its source are recorded on #46. The person's words, as given in the session's conversation on 25 Nov 2026: "review and approval -> approved"; "questions -> use your best judgement, use best common practices, search the internet if needed". The review agent (round 2) held that a general delegation does not make the session the owner of access, safety and privacy behaviour (session rule 3, section 4). So Q-RC2-1, 3 and 6 were put to the person again, one by one. The person answered on 25 Nov 2026 in the session's conversation: "Q-RC2-1 -> yes", "Q-RC2-3 -> yes", "Q-RC2-6 -> make your best judgement, use best common practice". These answers are also recorded on #46. The specification is not changed here; the owners confirm the answers into it. The reasons are in ADR-HIS-067, "The open questions, decided on common practice".
| # | Question | Decision | Changed in the contract |
|---|---|---|---|
| Q-RC2-1 | Flow state and board patient detail across facilities | Answered by the person: yes. readFlowState across facilities follows the policy decision point, like readEncounter; boards and queues stay hidden |
flow.v1 readFlowState: hidden to policy |
| Q-RC2-2 | Who sets the CFG-ADM-019 priority flags | older-adult derived at arrival from the date of birth (60 or more), not removable by hand; the others set by the clerk as observed or declared, each change audited |
PriorityFlag description |
| Q-RC2-3 | An out-of-order call | Answered by the person: yes. Staff may call out of order with a reason, which is shown and audited; supervisor authority only to pass over a waiting item of a higher triage category; the call moves no position | actOnQueueItem description |
| Q-RC2-4 | Wall-display logging | Per device and board, as FR-ADM-FLW-002 part 12 proposes | None |
| Q-RC2-5 | A complete consent directive with a future start | proposed until its effective time (D10-ESS 4.3); shown as "Recorded · applies from [date]" |
consent.v1 description |
| Q-RC2-6 | Patient reminders before Domain 7 | Decided by the session at the person's explicit request for this question. Domain 2 SMS, or WhatsApp where the preference names it, to the mobile number read from D01-ADM at send time and not kept; a preference excluding a channel or reminders is honoured, otherwise sent under the general consent; content facility, date and time only; no permitted channel is delivery-failed; delivered only from a provider receipt; every attempt audited as ess.ntf.delivery |
notification.v1 description and RecipientSpec; ESS contract point 4 of RC-2-S03; a D10 rule for ess-coordination to read the mobile number |
| Q-RC2-7 | Audit of a change to channel settings | ess.iam.account (account attribute change, D10-ESS 9.5) |
updateNotificationSettings description |
After these changes lint, check against origin/main, the stub verify (adm 322 cases, ess 494) and the cross-references (350) pass again. Every change is to prose, or to x-his-cross-facility of an operation that is new in this pull request.
For the owners (follow-up, not blocking): confirm the seven answers into D01-ADM and D10-ESS; Q-RC2-6 also wants D10-ESS part 6.10 to name the interim path (for example as GAP entries, as GAP-ADM-014 to 016 were);
Follow-ups outside the card¶
- RC-1-S09 (#23): unblocked by this pull request's merge: replace the D10 task of
Reconciliations.enqueueSamePersonwithrecordIdentityReview, add the review items of a change of an existing person, fill the registration'sreviewItems, deliveridentity_handoffwithrecordDemographicChange. - The RC-1-S08 fix (adm-identity, recorded on #40): serve
recordIdentityReview,recordDemographicChangeandidentityUnderReview(contract points incontracts/adm/README.md). - RC-3 contract session (MOD-ADM-005): add the ADT transitions to
transitionEncounter, the inpatient fields to PatientDischarged, and an event or decision for the pre-admitted arrival. contracts/common(a foundation change):AppointmentandQueueIteminReferenceType; a reason-code field (or a code for a refused precondition) inProblem; stub seeding of sub-resources from the record their collection created, and records of facility-owned seeds for the stub's own facilities.- D05-FIN contract session (BC-1-S01): start from
contracts/finversion 1; add layers, authorizations and manual verification compatibly. - Development realm (FN-S02 or RC-1-S16): a user
dev.supervisorwith the registration supervisor role (RC-2-E2E-003); a scheduler and a triage nurse role on the existing users. - D10 registrations before the RC-2 units go live: the policy resource types, audit event types, notification types and code lists listed at the end of
contracts/adm/README.md; the ESS task types, queues and the configuration item typeess.notification-typeincontracts/ess/README.md. - RC-2-S10 (integrate): the units, configuration and registry entries of
e2e/scenarios/RC-2/README.md. - Delivery receipts (EXT-ESS-005, EXT-ISE-013): no Domain 2 contract yet.
- Design system: none from this session.