Skip to content

Implementation plan / Session plan / Handover RC-2-S04

Handover RC-2-S04 Build: Patient administration

Card: RC-2-S04. Issue: cema-care/his#49. Branch: session/RC-2-S04. Slice: RC-2. Decision record: ADR-HIS-075.

Comes after: - RC-1-S09, whose unit this extends. Its registration and encounter creation are unchanged except where named below; - RC-2-S01, whose contracts encounters.v1 and registration.v1 1.1, contracts/fin coverage.v1 and contracts/ess consent.v1 this card serves and calls.

What was built and where

All of it is in services/adm-patient-administration (its README.md lists every module, setting and stand-in), plus ADR-HIS-075 and this handover.

Module What was added
mod-adm-004 (FR-ADM-ENC-002) EncounterLifecycle:
  • transitionEncounter: end-visit and cancel of D01-ADM 4.3, per class;
  • correctEncounter: attributes, or the reversal of the latest end-visit;
  • listEncounterHistory.
Migration V2__state_history.sql:
  • the encounter's disposition, cancellation, appointment_id and payer_context;
  • DE-ADM-009 encounter_history, append-only by trigger, with a creation entry for every encounter;
  • downstream_activity.
createEncounter takes appointmentId (contract point 8) and writes history entry 1. readEncounter and listEncounters apply a redact obligation (payerContext). The api package: EncounterDirectory (for MOD-ADM-010) and DownstreamActivity (for the subscriptions to come)
mod-adm-010 (FR-ADM-REF-001, FR-ADM-REF-002), new PayerReferences and EligibilityRelay: capturePayerReference and listPayerReferences, the IF-FIN-003 request queued in the capture's row, the CoverageVerified subscription.
ConsentReferences: runConsentCheck, recordConsentReference, listConsentReferences (the pending worklist), the ConsentChanged subscription, and the completion gate (RegistrationConsents).
PayerFields and ConsentPolicy: stand-ins of the D10 configuration.
clients/: HttpCoverageClient (contracts/fin), HttpConsentClient (consent.v1), HttpPayerDirectory (master-data.v1 readOrganization).
Migration V1__payer_and_consent_references.sql (DE-ADM-021, DE-ADM-022).
Test fixtures: FakeCoverage, FakeConsentService, FakePayerDirectory
mod-adm-002 The api interfaces RegistrationConsents (the gate MOD-ADM-010 implements) and RegistrationDirectory (RegistrationPorts).
registerPatient and completeRegistration ask the gate: the required consents become outstanding fields, consentReferences.<type>; complete with one outstanding is refused on /consentReferences; a valid existing directive is linked in the registration's transaction.
Registration.consentReferences in every answer
app RegistrationJourneyTest follows the RC-2 journey. The provider contract test covers the 18 operations. The consumer contract test adds contracts/fin, consent.v1 and readOrganization

The unit publishes PatientDischarged, EncounterCancelled and EncounterCorrected on his.adm.encounter.v1, ordered per encounter after EncounterOpened, each validated against the contract. It consumes his.fin.coverage.v1 (CoverageVerified) and his.ess.consentdirective.v1 (ConsentChanged). No dependency was added: the mod-adm-010 lockfile was written with ./gradlew :mod-adm-010:dependencies --write-locks and holds the same versions as mod-adm-004's.

Policy: - resource types adm.PayerReference and adm.ConsentReference (contracts/adm README); - new actions on adm.Encounter: transition, correct, cancel-with-activity and backdate (ADR-HIS-075 decision 1).

Checks and their result

The integration environment ran as HIS_SESSION=RC-2-S04 (his-rc-2-s04), light profile.

Check Command Result
Build and all tests ./gradlew build in services/adm-patient-administration passed, 121 tests:
  • mod-adm-002: 45;
  • mod-adm-004: 22 (9 new);
  • mod-adm-010: 17, new;
  • app: 10, of which 5 are contract tests;
  • kit: 27, with the Kafka adapter test skipped (full profile only).
Provider contract test ProviderContractTest (tag contract): his-contract verify contracts/adm --operation <each of the 18> against the unit on a random port, with a token permitted for RSU-01 and RSU-02 and denied for any other facility; then his-contract validate-event contracts/adm on everything published passed, 76 of 76 cases, the facility cases included; validate-event passed, PatientDischarged and EncounterCorrected among the events
Consumer contract test ConsumerContractTest: each client against his-contract serve of contracts/adm, contracts/ess and contracts/fin no violation recorded by any stub, requestEligibility, listConsentDirectives, readConsentDirective and readOrganization included
Static analysis platform/delivery-pipeline/bin/static-analysis services/adm-patient-administration no blocking finding
Secret scan platform/delivery-pipeline/bin/secret-scan code origin/main HEAD no secret, in the files or in the commits; secret-scan docs likewise
Dependency and image scan platform/delivery-pipeline/bin/dependency-scan, image-scan dependency scan 0 blocking (6 medium); image scan 0 blocking (15 low, 116 medium, in the base image's packages; no dependency or image change by this card)
Documentation python3 docs/implementation_plan/tools/check_links.py; mkdocs build 0 broken links, 0 duplicate anchors; the site builds

Requirements and test scenarios

Tests carry the requirement and scenario tags (session rule 5). The classes are in: - mod-adm-004/src/test/java/care/cema/his/adm/mod004/EncounterTransitionTest; - mod-adm-010/src/test/java/care/cema/his/adm/mod010/ (PayerReferenceTest, ConsentReferenceTest); - app/src/test/java/care/cema/his/adm/app/.

Requirement, criterion Test Scenario
FR-ADM-ENC-002 AC-01, PR-ENC-002-1 (every transition not in the model rejected with a reason code and audited, in each state reached: Pre-admitted, Registered, Discharged, Cancelled; MOD-ADM-005's transitions and unknown codes too; end-visit refused for an inpatient class) EncounterTransitionTest.invalidTransitionsRejected TEST-ADM-013
FR-ADM-ENC-002 AC-02, PR-ENC-002-4, part 9 (history entry with actor, effective and recorded time; audited; PatientDischarged and EncounterCancelled in sequence; reason and disposition required, codes checked) EncounterTransitionTest.validTransitionsRecorded TEST-ADM-013
FR-ADM-ENC-002 AC-03, PR-ENC-002-3, BR-ADM-012 (supervisor reverses a transition entered in error: original entry kept, prior state restored, EncounterCorrected; history not editable) EncounterTransitionTest.reversalCompensates TEST-ADM-013
FR-ADM-ENC-002 part 6.5 (attribute correction with before and after values; not for a Cancelled encounter; start consistent with the history) EncounterTransitionTest.attributeCorrection TEST-ADM-013
FR-ADM-ENC-002 AC-04, PR-ENC-002-2, part 6.3 (two simultaneous transitions, exactly one succeeds, three rounds; If-Match required and stale refused; one result per key, the encounter it was first used on) EncounterTransitionTest.concurrentTransitions TEST-ADM-013
FR-ADM-ENC-002 part 6.4 (cancelling with downstream activity only by a supervisor; hadDownstreamActivity in EncounterCancelled) EncounterTransitionTest.cancellationWithActivity TEST-ADM-013
FR-ADM-ENC-002 part 6.6, CFG-ADM-011 (not before the history, not in the future, beyond 24 hours only by a supervisor) EncounterTransitionTest.effectiveTimes TEST-ADM-013
FR-ADM-ENC-002 parts 12 and 13, architecture 7.5 (policy deny and outage, another facility not found, history read under policy and audited) EncounterTransitionTest.facilityAndPolicy TEST-ADM-013
Contract point 8 (check-in's appointmentId stored and carried by PatientDischarged) EncounterTransitionTest.appointmentCarried
FR-ADM-REF-001 AC-01 (coverage reference, payer, plan, status and timestamp shown; the request's content; payer context; audited) PayerReferenceTest.domainFiveAvailable TEST-ADM-029
FR-ADM-REF-001 AC-02, PR-REF-001-1, part 10 (Domain 5 down: not verified, registration and the visit go on, delivered after recovery with one key; a negative answer blocks nothing) PayerReferenceTest.domainFiveUnavailable TEST-ADM-029
FR-ADM-REF-001 PR-REF-001-2, part 11 (layers in Domain 5's order, inactive not listed) PayerReferenceTest.layersInDomainFiveOrder TEST-ADM-029
FR-ADM-REF-001 parts 6.3 and 11 (CoverageVerified updates the capture and the payer context; the encounter's version stays) PayerReferenceTest.coverageVerifiedUpdates TEST-ADM-029
FR-ADM-REF-001 part 6.5 (a change is a new capture; the earlier kept; one result per key) PayerReferenceTest.changeIsNewCapture TEST-ADM-029
FR-ADM-REF-001 PR-REF-001-3, part 6.6, AC-03 (inactive payer rejected, master data outage 503; mandatory fields by class and field set; none for the emergency type) PayerReferenceTest.payerChecksAndFieldSets TEST-ADM-029
FR-ADM-REF-001 PR-REF-001-1 (a refusal that may pass, such as 403, keeps the request queued until Domain 5 takes it; only an invalid request, 400, is given up) PayerReferenceTest.refusalThatMayPassIsRetried TEST-ADM-029
FR-ADM-REF-001 parts 3 and 13 (payer access under the decision point; payerContext redacted; required fields kept; facility hidden; no capture on a cancelled encounter) PayerReferenceTest.payerAccess TEST-ADM-029
FR-ADM-REF-002 AC-01, part 10 (prompted; completion refused until the general consent is recorded; reference stored on completion; snapshot only) ConsentReferenceTest.promptedAndStored TEST-ADM-030
FR-ADM-REF-002 AC-02, PR-REF-002-1 (existing directive linked at registration and at the check, no capture, no second link; an existing decline linked as declined) ConsentReferenceTest.existingDirectiveLinked TEST-ADM-030
FR-ADM-REF-002 AC-03, PR-REF-002-2 (consent service down: capture pending, listed per facility, completion permitted by policy, superseded when captured) ConsentReferenceTest.serviceUnavailablePending TEST-ADM-030
FR-ADM-REF-002 AC-04 (emergency rapid registration and its completion need no consent; every consent deferred; the consent service not asked) ConsentReferenceTest.emergencyUnblocked TEST-ADM-030
FR-ADM-REF-002 parts 6.2, 7 and 10 (representative's authority; directive of the patient and the type; outage 503; pending without directive; a declined general consent keeps the registration incomplete, a declined optional one never blocks) ConsentReferenceTest.representativeAndDirectiveChecks TEST-ADM-030
FR-ADM-REF-002 part 10, DEC-ADM-013 (a returning patient whose general consent is declined in Domain 10: linked as declined, a planned registration refused as complete and saved incomplete; an emergency registration not blocked) ConsentReferenceTest.declinedGeneralConsentBlocks TEST-ADM-030
FR-ADM-REF-002 PR-REF-002-2, part 6.4 (pending only while the consent service cannot be reached; captured or declined only as Domain 10's active directive holds it, permit or deny) ConsentReferenceTest.outcomeAsDomainTenHoldsIt TEST-ADM-030
FR-ADM-REF-002 part 10, PR-REF-002-3 (completion never rests on a withdrawn general consent, also while the service is down; a renewed directive linked; a pending capture does not complete once the service answers) ConsentReferenceTest.completionNeedsAnActiveConsent TEST-ADM-030
FR-ADM-REF-002 PR-REF-002-3, part 12 (Domain 10's current status on read, stale when unreachable, ConsentChanged applied; capture needed again after a withdrawal; views audited) ConsentReferenceTest.currentStatusFromDomainTen TEST-ADM-030
FR-ADM-REG-001, FR-ADM-ENC-001, FR-ADM-ENC-002, FR-ADM-REF-001, FR-ADM-REF-002 end to end through the unit (register incomplete, encounter, payer, consent, complete, end of visit; events and audits agree) RegistrationJourneyTest.registerAndOpen TEST-ADM-035, the registration, encounter and end-of-visit part
Every operation of 1.1; every client against its provider's stub contract/ProviderContractTest, contract/ConsumerContractTest TEST-ADM-013, 029, 030

Safety-critical function "Encounter creation and validation" (D01-ADM 11.1; FR-ADM-ENC-002 contributes to SAFE-004). This card has no "Safety" row, but its controls follow 4.3 and part 6 as specified: - only the model's transitions; - one winner of two; - corrections that never erase; - cancellation with activity limited to the supervisor.

No specified control was altered, so there is no hazard log entry to update.

Non-functional targets designed for: - NFR-ADM-005 (security). Every operation goes to the decision point, the supervisor privileges as actions of their own. A facility not permitted is refused before "not found". Every applied and refused transition is audited (adm.encounter.change), and so is every consent reference (adm.consent.reference) and view (adm.person.view). An outage is 503, never a grant. Payer detail is redacted by obligation. - NFR-ADM-009 (interoperability). Provider (76 cases) and consumer contract tests pass, and the events validate. - NFR-ADM-012 (observability). The kit's traces, logs and correlation identifier; every client passes them on. The eligibility relay logs each wait and refusal. - NFR-ADM-013 (localization). The service date of the eligibility request is the encounter's start in the configured zone. The payer fields and consent policy are configuration. - NFR-ADM-014 (time integrity). Effective and recorded times are both kept, in UTC to the millisecond (BR-ADM-026), and effective times are checked against the history and the clock tolerance.

Differences from the specification or the contract

  • A new planned patient is registered incomplete, then completed once the general consent is recorded (ADR-HIS-075 decision 6). registration.v1 refuses completion while the general consent is missing (DEC-ADM-013), but its consent operations need a registration that already exists. So registerPatient with completion: complete for a new person in a planned type is refused on /consentReferences. With completion: incomplete, the registration is saved with consentReferences.general-consent outstanding, and the desk then captures the consent and completes it. Some flows still send the documented registerPatient example, a new person with complete: the provider contract test, and the RC-1 and RC-2 scenarios. The provider test therefore runs with his.adm.consent.required-for-completion empty, as RC-1-S09 relaxed CFG-ADM-010 there; ConsentReferenceTest covers the rule. The scenarios are follow-ups below.
  • Downstream activity is never reported yet (part 6.4). The rule and its store are built (DownstreamActivity), but no Domain 3 to 6 event of D01-ADM 8.5 has a contract this unit can subscribe to. Until one does, no encounter shows activity, and any clerk with transition may cancel a Registered or Pre-admitted encounter.
  • Backdating beyond 24 hours is a supervisor's (CFG-ADM-011 "without supervisor authority"): a clerk gets backdating-beyond-tolerance, a supervisor (action backdate) proceeds. The downtime-window exception of CFG-ADM-011 is not applied: the contract has no downtime flag on a transition.
  • end-visit is for the classes AMB and EMER (setting his.adm.encounters.end-visit-classes). Section 4.3 makes Discharged the end of visit "for outpatient and emergency encounters that do not lead to admission". An inpatient encounter is discharged through ADT (MOD-ADM-005).
  • AC-03 of FR-ADM-ENC-002 names an admission entered in error. This version has no admission (MOD-ADM-005, RC-3), so the test reverses the end of visit, the outpatient form of "discharge cancelled as entered in error" that correctEncounter 1.1 offers.
  • The audit of a correction holds the changed fields, the history sequence and the reason's entry, not the values. The kit's record-change events keep no values, so the before and after values are in DE-ADM-009, which the audit names (part 12).
  • The payer fields mandatory by class are configuration defaults (CFG-ADM-004, the payer part; part 7 says "conditional"): payer and member identifier for an insurer or government scheme, payer for corporate, nothing more for self-pay, nothing conditional for the emergency field set (AC-03).
  • Payer master data unavailable is 503 on the capture. An inactive payer must be refused at entry (PR-REF-001-3), which cannot be known while master data is down. Registration and the encounter are not affected.
  • A capture on a Cancelled or Closed encounter is refused. Part 6.5 speaks of changes "during an open encounter"; a Discharged encounter still takes one, for billing.
  • "Who may receive information about the patient" (DEC-ADM-013 item 3) has no D10 consent type among those of the Indonesia profile. The offered consents are external-sharing and communication-preference, by setting; a type can be added when D10 registers one.
  • The completion gate (review round 3). A required consent counts only while Domain 10 holds its directive active. Its status is read at completion, or taken as last known while the service cannot be reached, so a withdrawn or expired general consent never completes a registration. A capture pending counts only while the service cannot be reached, and never over a consent known to have lapsed. recordConsentReference takes pending only while the service cannot be reached, and captured or declined only as an active directive's decision (permit or deny).
  • A declined general consent blocks completion (review round 4; ADR-HIS-075 decision 6, amended). registration.v1 states the rule two ways:
  • the API description says completion is refused while a required consent "has neither a captured nor a declined reference";
  • recordConsentReference says a decline "does not block registration unless the type is required for completion".

DEC-ADM-013 sets the general consent apart from "a refused optional consent never blocks registration". So a declined general consent is recorded and linked, and the planned registration stays incomplete, refused with "The patient declined a consent this registration requires. The registration stays incomplete." A declined optional consent never blocks, and an emergency type defers every consent. The settling follows the text of DEC-ADM-013 and the contract's operation; it is not a new rule. - runConsentCheck records a pending reference for each type while the consent service is down, the offered types included, so the worklist shows everything not yet captured. Only the required ones block completion, and only where the policy forbids pending.

Questions for a person

None is open. The card has no "Needs a person" line, and no question under rule 3 was needed: where the specification or contract left a point open, the choices above follow its text and are recorded in ADR-HIS-075.

For the Enterprise Architecture Board, on the merged work: approve the 2026-11-26 amendment of ADR-HIS-075 decision 6 (a declined required consent blocks completion).

Approvals: given (reported by the person on 26 Nov 2026 in the session's conversation): - the Enterprise Architecture Board approved ADR-HIS-075. Its Record line and index row say so; - the registration in D10 of the new policy actions on adm.Encounter (transition, correct, cancel-with-activity, backdate) was approved. Registering them is still RC-1-S16's work (follow-ups).

Readings confirmed by the D01-ADM owners on 2026-11-26 (reported by the repository owner, relayed in the session's conversation). Nothing is left open on these readings: - a planned registration happens in two steps: register as incomplete, record the general consent, then complete (DEC-ADM-013 with the 1.1 contract; ADR-HIS-075 decision 6); - a registration supervisor may backdate an encounter transition beyond the 24 hours of CFG-ADM-011 (ADR-HIS-075 decision 1).

The specification is not changed here; the amendment is a follow-up.

Follow-ups outside the card

  • Next ADM contract session (contracts/adm): align the registration.v1 API description with recordConsentReference: completion needs the required consent captured; a decline of a required type keeps the registration incomplete.
  • D01-ADM owners (specification text): write the two confirmed readings into D01-ADM, for example as GAP entries as GAP-ADM-014 to 016 were:
  • FR-ADM-REF-002 part 10 and DEC-ADM-013: a new planned patient is registered incomplete, the general consent is recorded on that registration, then the registration is completed;
  • CFG-ADM-011 and FR-ADM-ENC-002 part 6.6: beyond the tolerance, a registration supervisor may record the backdated effective time.
  • Next ADM contract session (contracts/adm):
  • make the registerPatient example a planned registration with completion: incomplete (or a returning person with a directive), so the documented request meets the consent policy;
  • consider a downtime flag on transitionEncounter (CFG-ADM-011 back-entry);
  • a consent type for "who may receive information" with D10.
  • RC-2-S10 (integrate):
  • in e2e/scenarios/RC-2, register a new patient with completion: incomplete, record the general consent, and complete the registration with completeRegistration before the steps that need a complete one. RC-2-E2E-001 step 3 already captures the consent;
  • set his.adm.coverage.url (the fin stub until BC-1), his.adm.consent.url (ess-runtime-decision) and his.adm.master-data.url;
  • the unit subscribes to his.fin.coverage.v1 and his.ess.consentdirective.v1.
  • RC-1 scenarios (e2e/scenarios/RC-1, the RC-1 gate fixes): newRegistration sends completion: complete for a new planned patient. Under the RC-1 stack the consent service is absent, which still refuses: a new person is never checked against D10. They need the incomplete-then-complete flow, or the stack sets his.adm.consent.required-for-completion empty.
  • Screens (UI-ADM-001 registration): the same flow, and the "Required consent has not been recorded." message on /consentReferences.
  • D10 registrations before ADM goes live:
  • RC-1-S16: the actions transition, correct, cancel-with-activity and backdate on adm.Encounter, the last three for the registration supervisor only; the resource types adm.PayerReference (registration and revenue roles) and adm.ConsentReference; a redact obligation naming payerContext on adm.Encounter views for clinical roles (FR-ADM-REF-001 part 3);
  • RC-1-S04: adm.consent.reference (already listed by RC-2-S01);
  • D10 terminology: urn:his:adm:payment-class (self-pay, insurer, government-scheme, corporate), discharge-disposition, encounter-cancellation-reason, encounter-correction-reason (listed by RC-2-S01).
  • Downstream activity subscriptions: once D03 (OrderPlaced, ClinicalEntryCreated), D04 and D05 (InvoiceIssued) publish contracts, subscribe and report through mod004.api.DownstreamActivity. MOD-ADM-005 and the closure criteria (FR-ADM-ADT-003) use the same events.
  • RC-3 (MOD-ADM-005): add admission, leave, return, discharge and closure to EncounterLifecycle.MODEL, with their reversals, on the same history.
  • D10 configuration client (IF-ESS-012): replace PayerFields and ConsentPolicy, besides RC-1-S09's FieldSets, SourceTrust and the CIN settings.
  • Design system: none from this session.