Skip to content

Implementation plan / Session plan / Handover RC-1-S28-F23

Handover RC-1-S28-F23 Fix: adm-patient-administration audits refusals during a decision outage as denied with decisionUnavailable

Card: RC-1-S28-F23. Issue: cema-care/his#275. Branch: session/RC-1-S28-F23. Slice: RC-1. This is a round 2 fix of the gate session RC-1-S28-G2. The unit belongs to RC-1-S09. It finishes the outage path that RC-1-S28-F18 left as a follow-up.

The failure

The gate's evidence, in the first comment on #275: run 20261201T000308Z-fa9c at commit 1586d431 quarantined 20 events from adm-patient-administration. All of them were refusals made while the decision point timed out:

Events Quarantined for
8 adm.person.view /decisionId, /policyVersion (record access)
8 adm.person.change, 4 adm.encounter.change /resourceRef, /beforeAfter/changedFields (record change, outcome failure)

Each refusal site of the unit audited an outage as outcome failure, with no decision and no marker. audit.v1 1.2 (RC-1-S28-F14, ADR-HIS-101) and the ruling on #220 say how such a refusal is audited: outcome denied with decisionUnavailable: true, and without decisionId or policyVersion. The audit service then waives the decision. A refused creation also carries recordNotCreated (ruling on #224), which waives the record reference, the changed fields and the patient. On main, services/ess-audit's SubmissionValidator already applies both waivers. What was left was the emitter half.

What was changed and where

Only services/adm-patient-administration:

  • Kit (service-kit):
  • AuditRecord has a new component decisionUnavailable, with the builder method decisionUnavailable().
  • The new factory AuditRecord.refusal(eventType, action, unavailable) gives outcome denied either way, and marks the event decisionUnavailable when the refusal came from an outage.
  • build() refuses decisionUnavailable or recordNotCreated on any outcome other than denied, as the contract does.
  • AuditEmitter writes "decisionUnavailable": true and leaves decisionId and policyVersion out for such an event.
  • PolicyEnforcer's default refusal audit uses the factory too. No caller in this unit uses that default: every require passes its own refusal audit. Its event type settings are unchanged.
  • Every refusal site now builds its event with AuditRecord.refusal(…, unavailable) in place of unavailable ? FAILURE : DENIED:
  • mod-adm-002: AuditTrail.refusal, which serves registrations and demographics;
  • mod-adm-004: Encounters, EncounterLifecycle (two sites) and EncounterValidation;
  • mod-adm-005: Guard;
  • mod-adm-006: BedGuard;
  • mod-adm-009: TransferGuard;
  • mod-adm-010: ConsentReferences and PayerReferences.
  • A refused creation during an outage now carries recordNotCreated as well. The && !unavailable condition is gone from AuditTrail.refusal (registration) and Encounters.refusal (encounter). It was there only because F18 had to keep the marker off outcome failure.
  • A refused change of an existing record keeps its resource reference, version and changed fields during an outage, as it already did. Only the outcome and the marker change.
  • Outcome.FAILURE stays where it means a failure, not a refusal: a transition rejected by the encounter's state model (EncounterLifecycle), a failed closure (Closure), a refused handover acknowledgement (Handovers).
  • Test fixture AuditIntakeRules (mod-adm-002 test fixtures) mirrors the waiver of SubmissionValidator. A record access event marked decisionUnavailable with outcome denied and no decision needs no decision identifier or policy version. The marker on another outcome, or next to a decision, is an error.

No contract file, dependency, lockfile or migration changed. No decision record was written: the rule comes from the rulings and audit.v1 1.2, and the factory is a local choice.

Checks and their results

Light profile as HIS_SESSION=RC-1-S28-F23, in services/adm-patient-administration:

Check Result
The new and changed tests with main's sources (src/main of this change reverted, tests and fixture kept) Fail, 3 of 7. RefusalAuditTest.refusedRegistrationOfNewPerson: expected ["denied", "denied"], got ["denied", "failure"]. RefusalAuditTest.outageRefusals and EncounterRefusalAuditTest.outageRefusals: an adm.person.view with outcome failure and no marker, which the intake rule rejects for /decisionId and /policyVersion
The same tests with this change 9 of 9 pass (RefusalRecordTest 2, RefusalAuditTest 4, EncounterRefusalAuditTest 3)
./gradlew build --continue 221 tests: 219 passed, 1 skipped (the Kafka test of the full profile), 1 failed. The failure was AdtEventPublicationTest.propagation (mod-adm-005), a timing test: its p95 was 5,287 ms against a 5,000 ms limit, with the host's load average at about 43. It passed alone on the rerun (9 of 9). This change does not touch event publication
python3 docs/implementation_plan/tools/check_links.py 0 broken
Review round 1, the pipeline The unit's job failed in service-kit, at HttpPolicyDecisionClientTest.permit: the Permit came back as not permitted. That test reads a Permit through a client with a 300 ms timeout. The limit is there for the outage cases (a reply after 1,000 ms), and on the loaded runner the cold first call went past it and failed closed. This change does not touch that client or that test. The Permit and Deny reading tests now use a second client with a 5 s timeout; the outage cases keep 300 ms. ./gradlew :service-kit:test: 38 tests, 0 failed, 1 skipped

The slice scenario was not run end to end on this host. The next gate round, RC-1-S28-G3, runs it. This change alters only the content of audit events this unit sends for refused requests. No answer to any request changes: an outage is still a 503 and a policy refusal still a 403. So no step of the slice scenario can pass or fail differently, because none asserts on the outcome of these audit events.

What the gate line now shows

The line is criterion 6 (ACC-005), IF-ESS-008, and criterion 4, FR-ESS-AUD-001 (nothing quarantined), of slice gate RC-1. Its check is the audit quarantine after the slice run. For the gate's 20 events, with main's audit service:

Gate events Now sent as Intake on main
8 adm.person.view outcome denied, decisionUnavailable, resource reference, purpose, patient where the record exists, no decision stored: the decision is waived (RefusalAuditTest.outageRefusals, EncounterRefusalAuditTest.outageRefusals)
adm.person.change / adm.encounter.change refused creations (registration, encounter) outcome denied, decisionUnavailable, recordNotCreated, action create stored: record, changed fields and patient are waived (RefusalAuditTest.refusedRegistrationOfNewPerson, outageRefusals; EncounterRefusalAuditTest.outageRefusals)
adm.person.change refused change of an existing registration outcome denied, decisionUnavailable, resource reference with version, changed fields, patient stored (RefusalAuditTest.outageRefusals)

Each test checks every event against AuditIntakeRules, which mirrors the audit service's rule for these types. The quarantine of RC-1-S28-G3 should therefore hold no outage refusal from adm-patient-administration of these types.

Requirements and test scenarios of the card

Requirement Test
FR-ESS-AUD-001 AC-06 with D10-ESS 9.5 and the ruling on #220: a refusal during a decision outage is audited as denied with decisionUnavailable and no decision, and is accepted at intake RefusalAuditTest.outageRefusals (mod-adm-002: registration read, demographics read, registration creation, registration completion); EncounterRefusalAuditTest.outageRefusals (mod-adm-004: encounter read and creation); RefusalRecordTest (kit)
The same, with the ruling on #224: a refused creation during an outage also carries recordNotCreated RefusalAuditTest.refusedRegistrationOfNewPerson, outageRefusals; EncounterRefusalAuditTest.outageRefusals
IF-ESS-008 audit intake (gate criterion 6, ACC-005) Every event in these tests is checked with AuditIntakeRules. Tags FR-ESS-AUD-001 and IF-ESS-008, with FR-ADM-REG-001, FR-ADM-REG-002 or FR-ADM-ENC-001

The tests of the owning session RC-1-S09, and those of every later session on the unit, are part of ./gradlew build above.

Done differently from the specification or contract

Nothing. The outcome and markers are those of audit.v1 1.2 and the rulings on #220 and #224.

Questions and follow-ups

  • Other refused creations of the unit still send no recordNotCreated, whether they are decided or made for want of a decision. These are bed reservations (adm.bed.change), transfers (adm.adt.change), consent and payer references, and the delivery tracker. They were outside both gate runs. F18 listed them already, and the rule and fixture are here to reuse.
  • adm-identity has the same outage path. That is RC-1-S28-F22.
  • Template (services/_template, FN-S03): its kit should get AuditRecord.refusal and decisionUnavailable too, and its default unavailableEventType (access-check-unavailable, unregistered) should go. The gate handover RC-1-S28-G2 names this for the template's owner.
  • D10-ESS 7.3: DE-ESS-013 has no attribute for decisionUnavailable or recordNotCreated yet. That is for the ESS contract session and the Domain 10 lead.

None of these needs a person to decide anything for this card.