Skip to content

Architecture / Decision records / ADR-HIS-130

ADR-HIS-130 Clinical context: one current context per user, facility and window, a selection in an occupied window is a switch, and the patient context zone never shows an earlier allergy status

Status Accepted
Decided 2026-12-02 by session RC-5-S06
Record Drafted 2026-12-02; awaiting approval by the Enterprise Architecture Board
Where the rule lives services/cli-orders/mod-cli-012/ (context/ClinicalContexts, context/ContextStore, zone/ZoneAssembler, zone/ZoneCache, zone/ZoneEvents, sources/, migration V1__clinical_context.sql); services/cli-orders/service-kit/

Context

FR-CLI-RSP-003 asks for a persistent patient identity zone in every clinical workspace, an explicit action to switch patient, and a service that refuses a write started in another patient's context (PR-RSP-003-01, AC-04). Contract session RC-5-S02 wrote clinical-context.v1 (ADR-HIS-126), served by unit cli-orders, and its contract points for RC-5-S06 (contracts/cli/CONTRACT-POINTS.md).

Session RC-5-S06 is the first build session on cli-orders, so the questions it had to settle shape the unit and every CLI unit that checks a context: - which kit the unit starts from; - what makes a context current, and what a selection in a window that already shows a chart does; - how far the open-chart limit reaches; - what the zone shows when a source does not answer (contract point 4), since the contract has no "unavailable" field; - how the zone stays current with Domain 1; - what a context check compares, and how it is decided.

Options considered

  1. Refuse a selection in a window that already has a current context unless replaces names it. Strict, but a user who reloads a screen or opens a patient from a worklist in the same window would be refused, and the slice scenario opens one chart after another in window main without replaces. A refusal there teaches users to close charts blindly.
  2. A selection in an occupied window is a switch (chosen). Selecting a patient is itself the explicit action of part 6.6. The earlier context ends in the same transaction, and the answer lists the unsigned work it leaves.
  3. For an unanswered source, leave the part out, or show the default "not-assessed". Leaving it out breaks the contract's required fields and leaves the zone blank. "Not assessed" for the allergy status would show a state the source did not give.
  4. Serve every part's last data, of any age, marked only by the zone's freshness.dataAsOf (this record's first version). The screen cannot tell which part is old, and an allergy status could be shown without its own date, which CUX-49 and the shell's freshness rule 3 forbid for a value used for decisions. The review of the pull request refused it.
  5. Add an optional "unavailable" marker per part to PatientContextZone (clinical-context.v1 1.1). This is what contract point 4 asks for ("shown as unavailable with the time of the last data"). It is a contract change, which a build session does not make, so it is a follow-up for a CLI contract session. Until then point 3 below is the safe subset.

Decision

  1. The unit's kit is the one of services/adm-patient-administration, copied after new-unit.sh. The template's kit lacks:
  2. the downstream client that passes the user's token on with the unit's own (kit/client/Downstream, ServiceTokens);
  3. the patientRef and encounterRef names of policy-decision.v1;
  4. the audit fields of RC-1-S28-F19.

The template should take these over (follow-up for the template's owner). 2. One current context per user, facility and window (a partial unique index). Selecting in a window that already has a current context, or naming another current context in replaces, is a switch (option 2): - the earlier context stops being current in the same transaction; - the answer lists the unsigned work it leaves (drafts and saved, not signed, documents of the user for the earlier patient, from searchClinicalDocuments); - the switch is audited as cli.context.select with action switch.

replaces must name a current context of the user, or the selection is refused at /replaces. A context is never deleted, so a write started in it is refused afterwards. The open-chart limit (CFG-CLI-032, his.cli.context.open-chart-limit, default 2) counts the user's current contexts in the facility of the request, after the switch. Contexts, like every read and list of this unit, are scoped to the facility of the request. 3. An earlier allergy status or risk is never shown; earlier D01 data is shown for at most an hour, with its time. - The parts are the person and the encounter (D01), and the allergy status and the active risks (cli-clinical-record). - The allergy status and the active risks are values used for clinical decisions, which must carry their own date (CUX-49; application shell 6, freshness rule 3). The zone has no date per part, so they are always read live. When cli-clinical-record does not answer, the zone, and with it the selection, answers 503 "unavailable". That unit holds the chart itself, so no chart could be worked without it anyway. - The person and the encounter last read from D01 are kept per user (zone_part), because each source answers what that user may see. When D01 does not answer, they are served for at most his.cli.context.last-data-max-age (default 60 minutes, the limit an earlier Permit has on a Tier 1 read path, CFG-ESS-025). freshness.dataAsOf is then the time of that data, the oldest watermark of the view (CUX-53), and the screen shows "Not updated for [n] minutes". Older data, or none, gives 503. - A part is never left blank or filled with a default, and the allergy status is never anything the source did not say now (options 3 and 4 rejected). - This meets contract point 4 only in part: a part served from earlier data is not marked as unavailable on its own (option 5, a follow-up). - The unsigned work, which is not a part of the zone, is left out of the answer when it cannot be read, rather than given as an empty list. 4. Domain 1 events drop or update the held data; they never extend it. - PatientMerged, PatientUnmerged and IdentityUpdated drop the person part of both identities, so the next read asks adm-identity and shows the merge notice (identity status merged) or the corrected name. Unmerge also drops the encounter parts. - PatientTransferred sets the destination location. - PatientDischarged drops the encounter part. - With its source down, a dropped part is not served, so an identity the patient no longer has is never shown. 5. The check compares the context with the write, locally, and is decided as a cli.ClinicalContext view. - Reasons, in order: - unknown: not a context of the request's facility; - other-user: another user's context, or a person checking with a user other than themselves; - closed; - patient-differs; - encounter-differs, also when the write names no encounter: every write carries its context's encounter (PR-RSP-003-01), and every context has one. - No other unit is called on the check, so it is as available as this unit. - Each mismatch is counted and audited (cli.context.mismatch, outcome denied, with the reason and "Patient context changed; action not submitted"). - BR-CLI-001's encounter status rules stay with the writing unit, which knows the activity. 6. Every answer that carries a zone is decided as a cli.ClinicalRecord view with the encounter's facility as owningFacility: select, list, read and the zone read. - Close is an update of cli.ClinicalContext. - The obligations applied are elevated-audit and session-marker (the emergency session goes in the audit). Any other obligation is refused by the kit, because the zone has nothing it could redact. - A service identity has no chart, so it cannot select, list, read or close one. 7. readPatientContextZone without an encounter takes the encounter of the user's current context for the patient, and is otherwise refused at /encounter. The allergy status is recorded per encounter (point 3).

Consequences

  • A CLI unit refuses a write on a mismatch answer and passes on a match. It treats this unit's 503 as "cannot be checked", and never as a match.
  • The zone needs adm-identity, adm-patient-administration and cli-clinical-record configured (his.cli.sources.*). While cli-clinical-record is down, no chart opens and no zone is answered; while D01 is down, only charts whose patient the user read in the last hour. The screen keeps what it last showed, with its time (CUX-53). Integrate session RC-5-S16 sets the URLs.
  • A CLI unit's write must send the encounter in its check, or it is refused.
  • The held parts grow with users and patients, and closed contexts are kept. A retention job for both is a follow-up.
  • Unconfirmed allergies are marked in the zone's allergy strings ("(unverified)"), because allergies is a list of strings. A structured field would be a minor version of clinical-context.v1.