Implementation plan / Session plan / Handover RC-5-S03
Handover RC-5-S03 Build: Runtime decision services (consent-aware decisions and privacy labels)¶
Card: RC-5-S03. Issue: cema-care/his#178. Branch: session/RC-5-S03. Slice: RC-5. Decision record: ADR-HIS-127.
Comes after RC-4-S02 and RC-5-S02. It serves policy-decision.v1 1.2, which RC-5-S01 contracted: the request fields labels, fieldLabels, labelTaxonomyVersion, recipient and emergencySessionId; the answer fields consentBasis and labelTaxonomyVersion; the stored consentDirective and labelsInfluencing; and the operations readLabelTaxonomy, listUnknownLabels and resolveUnknownLabel. It extends what RC-1-S17 and RC-2-S02 built in MOD-ESS-002 and MOD-ESS-003 (ADR-HIS-065, ADR-HIS-073). No contract was changed.
What was built and where¶
All the code is in services/ess-runtime-decision. The unit's README lists its packages, content and settings.
MOD-ESS-003, the consent-aware decision (FR-ESS-CNS-002).
- api/ConsentEvaluation is the in-process interface MOD-ESS-002 calls (ADR-HIS-127 point 1).
- decision/ConsentDecider takes the directives in force for the patient at the time of the request, the consent policy and the exception catalogue. Its answer is Permit, Deny, Restrict (a category withheld) or Not governed, each with its basis:
- a directive version;
- a legal basis;
- or an exception with its legal basis.
It names the restricted and released categories and whether an emergency override is available. Unavailable directive data gives Deny, "Consent could not be confirmed." (PR-CNS-002-4).
- decision/ConsentPolicies and ConsentPolicyIntake keep the versions of item types ess.consent-policy and ess.consent-exception-catalogue. They come from ConfigurationChanged, or from the starter content where his.consent.seed-enabled is set outside production. Migration: V2__consent_decision.sql.
- ConsentPolicy and ExceptionCatalogue check content at intake. An exception without the privacy and legal approvals is refused.
- Starter content in mod-ess-003/src/main/resources/consent/:
- consent-policy.v1.json: six rules over treatment, claims, statutory reporting, national exchange, third-party release and secondary use;
- consent-exception-catalogue.v1.json: emergency-treatment under an emergency session, with legal basis uu-27-2022-vital-interest; legal-obligation, with legalObligationRef;
- consent-policy.v1.test-pack.json: 21 cases.
MOD-ESS-002, privacy labels and the privacy stage (FR-ESS-AUZ-003).
- decision/PrivacyStage runs after the OPA rules and only narrows them (ADR-HIS-127 point 2). In order:
1. the recipient check, through ports/RecipientDirectory: ess-reference readOrganization over HTTP, or MOD-ESS-001 for a role or an application;
2. the consent evaluation;
3. the label rules;
4. elevated-audit where an exception applied.
It writes the audits ess.auz.label-enforcement (disclosure-and-exchange) and ess.cns.decision (consent-and-privacy), and the trace steps recipient, consent, emergency-session and labels.
- labels/ holds LabelTaxonomy (content and intake check), LabelTaxonomies (the version in force), LabelEvaluator and UnknownLabels.
- LabelEvaluator reads the resource labels, field labels and category rules, maps superseded codes, applies the ordered rules, and treats an unknown code at its most restrictive.
- UnknownLabels holds one stewardship item per code, counted by calling system.
- web/LabelTaxonomyController serves the three new operations, on policy resource type ess.LabelTaxonomy.
- DecisionService, DecisionRequests and DecisionStore read the 1.2 request fields, and store and answer the consent basis, taxonomy version, directive and labels influencing. Migration: V3__privacy_labels.sql.
- Starter content in mod-ess-002/src/main/resources/policy/:
- privacy-label-taxonomy.v1.json: 12 labels, 5 category rules and 7 label rules;
- privacy-label-taxonomy.v1.test-pack.json: 16 cases for read, export and exchange.
- enterprise-access.v1.json gains:
- the actions export, exchange and disclose on cli.ClinicalRecord;
- the resource type ess.LabelTaxonomy;
- the rules clinical-record-exchange-service (scope cli.clinical-record:share; the purposes DEC-ESS-009 point 3 names), label-taxonomy-read and label-taxonomy-resolve-unknown.
Its test pack gains TP-65 to TP-67 and TP-69 to TP-73 (TP-68 was removed in review round 1 with a rule granting HIM staff export and disclosure, which no requirement states). The rego evaluator offers the emergency override only for a read (ADR-HIS-127 point 8).
MOD-ESS-001. SubjectAttributes.recipientRegistered answers whether a role or an application named as a recipient exists and is active.
Service kit.
- When his.policy.outage-cache is on, a ConsentChanged (his.ess.consentdirective.v1) drops the cached outage Permits for its patient, and for the previous patient on a merge.
- The test fixture AuditCategoryRules gains the disclosure and consent categories.
Checks and their result¶
In services/ess-runtime-decision, on the light profile under HIS_SESSION=RC-5-S03:
./gradlew build # 398 tests: service-kit 32, mod-ess-001 104, mod-ess-002 184, mod-ess-003 68, app 10; none failed, 4 skipped
./gradlew :mod-ess-002:test --tests '*PrivacyLabelTest' # 33 tests, with the 16 label pack cases
./gradlew :mod-ess-003:test --tests '*ConsentDecisionTest' # with the 21 consent pack cases
./gradlew :app:test --tests '*ConsentAwareDecisionTest' # 3 tests across the modules, with OPA in its container
./gradlew :mod-ess-002:test --tests '*PolicyDecisionContractTest' # 8 operations, his-contract verify: 0 failed; validate-event passed
The full build was run again after the changes of review round 1, label pack included.
The provider contract test now also verifies: - readLabelTaxonomy, as a domain service; - listUnknownLabels and resolveUnknownLabel, as the privacy officer, on the examples' item at its version.
ModuleBoundaryTest passes: MOD-ESS-002 uses MOD-ESS-003 only through mod003.api. Documentation: check_links.py and mkdocs build pass. Secret scan: platform/delivery-pipeline/bin/secret-scan code origin/main found nothing.
Requirements and test scenarios¶
FR-ESS-AUZ-003, TEST-ESS-010. Tests are in mod-ess-002/.../PrivacyLabelTest.java, tagged FR-ESS-AUZ-003 and TEST-ESS-010, unless named otherwise.
| Criterion | Test |
|---|---|
| AC-01: restricted label, no relationship or consent → redaction or Deny | restrictedResourceIsRedacted, restrictedFieldIsRedacted, consentRestrictionRedactsTheCategory |
| AC-02, PR-AUZ-003-3: exchange of labelled and unlabelled data, redaction by consent and legal basis | exchangeWithoutConsentRedactsLabelled, consentReleasesTheCategory, exportForClaims |
| AC-03: label policy test pack for read, export and exchange | labelPackCoversTheActions, everyLabelCase (LTP-01 to LTP-16) |
| AC-04, PR-AUZ-003-1: unknown code most restrictive, stewardship item | unknownCodeIsMostRestrictive, privacyOfficerResolvesUnknown |
| PR-AUZ-003-2: field redaction | restrictedFieldIsRedacted |
| PR-AUZ-003-4: category-to-label rule | categoryRuleLabelsUnlabelled |
| DEC-ESS-009: sensitive opened and audited | sensitiveIsAuditedOpen |
| Parts 6.1, 6.7, 10, 11: taxonomy served, superseded versions, unusable content | readTaxonomy, supersededVersionIsMapped, unusableTaxonomyIsRefused |
| Contract point 1: 1.0 callers unchanged | attributeLabelsAreRead, unlabelledIsAsBefore |
| Access to the taxonomy operations | PolicyTestPackTest TP-70 to TP-73 |
| Across the unit | app/.../ConsentAwareDecisionTest.denyDirectiveAndEmergencySession (a PSY record redacted for the treating nurse under a deny directive), taxonomyServed |
FR-ESS-CNS-002, TEST-ESS-013. Tests are in mod-ess-003/.../ConsentDecisionTest.java, tagged FR-ESS-CNS-002 and TEST-ESS-013, unless named otherwise.
| Criterion | Test |
|---|---|
| AC-01: directive permits sharing with a named recipient → Permit, directive version recorded | ac01ExchangePermitted; app/.../ConsentAwareDecisionTest.exchangeBeforeAndAfterWithdrawal |
| AC-02: after withdrawal → Deny | ac02WithdrawalDenies; ConsentAwareDecisionTest.exchangeBeforeAndAfterWithdrawal |
| AC-03, PR-CNS-002-3: deny directive plus emergency session → exception and legal basis, elevated audit | ac03EmergencyException; ConsentAwareDecisionTest.denyDirectiveAndEmergencySession |
| AC-04: consent test pack for read, export and exchange | packCoversActions, everyCase (CNS-TP-01 to CNS-TP-21, disclose included) |
| PR-CNS-002-1: absent consent → Deny, override for treatment | consentAbsentOverride (offered to a permitted role reading for treatment; not to another role, not for research, not for an exchange); PolicyTestPackTest TP-69 (no override for an export) |
| PR-CNS-002-2: deny directive → Deny or redact | everyCase; PrivacyLabelTest.consentRestrictionRedactsTheCategory |
| PR-CNS-002-4: consent data unavailable → Deny | unavailableIsDeny |
| Part 4: no consent policy in force | noPolicyNotGoverned |
| Part 10: recipient not recognized | PrivacyLabelTest.unregisteredRecipient; PolicyTestPackTest TP-67 |
| Part 13: exception catalogue without approvals refused | unapprovedExceptionRefused |
| Cached outage Permits dropped on ConsentChanged | service-kit/.../OutageDecisionCacheTest.consentChangeDropsThePatientsPermits |
| IF-ESS-003 policy-decision.v1 1.2 | mod-ess-002/.../contract/PolicyDecisionContractTest (tagged FR-ESS-AUZ-003) |
Non-functional targets:
- NFR-ESS-007 (security):
- the privacy stage only narrows the rules' outcome, and every failure is closed (consent unavailable, unknown recipient, unknown label);
- the directive's content never goes back to the requester (
exchangeBeforeAndAfterWithdrawal); - access to the taxonomy operations goes through the policy, with a second factor for the privacy officer.
- NFR-ESS-011 (interoperability): policy-decision.v1 1.2 passes the provider contract test, and 1.0 callers get the decisions they got before.
- NFR-ESS-015 (time integrity): consent is evaluated at the later of the request's time and the present, and instants are stored in UTC.
- NFR-ESS-016 (localization): the messages are the specification's.
- NFR-ESS-017 (observability): the trace steps, and the metrics
his.authz.labels.unknown,his.authz.labels.superseded,his.consent.decisionsandhis.consent.policy.missing. Both audits pass the intake's category rules in the tests.
Safety-critical functions¶
Privacy label redaction (D10-ESS 11). The control as specified: - the policy defines whether the existence of redacted data is shown to treating clinicians; - there is an emergency access path.
What is built:
- the starter taxonomy sets discloseRedaction: true, and every redact obligation carries it;
- a restricted record withheld for a read is a redaction, not a Deny, so the screen can show "Restricted information not shown";
- under an Active emergency access session, the restricted-read-emergency rule releases it, and the emergency-treatment exception overrides a deny directive for treatment.
It is verified by restrictedResourceIsRedacted, ac03EmergencyException and denyDirectiveAndEmergencySession. The clinical review of the label policy that the hazard log names is listed under "Needs a person".
Done differently from the specification or contract¶
- A category-to-label rule by value set is refused at intake (ADR-HIS-127 point 3), because this unit cannot expand a value set yet. Rules by code, service or record category are applied.
- The conflict of directives that FR-ESS-CNS-001 raises as a privacy review item is not raised again by the decision. The decision applies the most restrictive of the directives in force.
- In the starter consent model, label scope is allowed only on
sensitive-restriction. A permit scoped to a category for external sharing therefore cannot be recorded yet: consent test pack case CNS-TP-14 uses a sensitive-restriction permit instead.
Questions left for a person¶
None that blocked the session. Needs a person (given on the merged work):
- The Enterprise Architecture Board approves ADR-HIS-127.
- The privacy officer and legal approve the starter content before any production use, including the clinical review of the label policy (D10-ESS 11):
- the label taxonomy and its label rules;
- the consent policy;
- the exception catalogue, including the legal bases uu-27-2022-vital-interest and uu-17-2023-*;
- the access rules added to enterprise-access.v1.json.
Follow-ups outside this card¶
- ess-governance (MOD-ESS-011): register the item types
ess.privacy-label-taxonomy,ess.consent-policyandess.consent-exception-catalogue, with validation hooks that call the intake checks of this unit. - ess-reference / terminology: value set expansion, so that category rules by value set can be applied.
- CLI build sessions (RC-5):
- send
recipienton export, exchange and disclosure, andemergencySessionIdunder emergency access; - enforce
redact,maskandaccompany-labels. - Consent model (MOD-ESS-003 content): a category-scoped permit for external sharing (see CNS-TP-14).
- MOD-ESS-003: a privacy review item when a decision meets conflicting directives.
- D06-HIM release of information (MOD-HIM-008): the roles that export or disclose a clinical record (the release of information officer, UR-47) are D06's to state. This card grants no person export or disclosure; the HIM sessions add the rule with their requirement.
- BC-7-S02 extends this work on MOD-ESS-003; it should read ADR-HIS-127.