Skip to content

Architecture / Decision records / ADR-HIS-126

ADR-HIS-126 The D03-CLI contracts of slice RC-5: the patient context checked by the service, one entry topic, governed content in one API, coded values that carry their stewardship state, and documents held in D10 only

Status Accepted
Decided 2026-12-02 by session RC-5-S02
Record Drafted 2026-12-02; awaiting approval by the Enterprise Architecture Board
Where the rule lives contracts/cli/ (the nine APIs of api/, the events of contract.yaml, schemas/cli-types.v1.json, CONTRACT-POINTS.md, scripts/cross-references.ts); D03-CLI section 7.3

Context

The contract session RC-5-S02 writes the first D03-CLI contracts, for slice RC-5 and modules MOD-CLI-001 to 005 and MOD-CLI-012. Section 8 of D03-CLI names few interfaces for them (IF-CLI-001, 008 and 010); most of what the modules offer is the API their own screens and the shell call. Five questions were left to the contract:

  1. How the service enforces the persistent patient context of FR-CLI-RSP-003 (PR-RSP-003-01: an action started for one patient is never submitted in another's context).
  2. How the eleven catalogued events EVT-CLI-001 to 011 map to topics and aggregates.
  3. Where governed clinical content lives: document templates and flowsheet layouts (FR-CLI-DOC-001) and assessment instruments (FR-CLI-OBS-002) share one lifecycle (draft, review, approval by someone other than the author, activation, rollback).
  4. How a coded value shows what governed terminology made of it (BR-CLI-004, FR-ESS-TRM-003).
  5. Where attachment and imported document content is held.

The card also asks that every reference between the domains' contracts resolve. Two references of the ESS contracts named CLI resources that did not exist.

Options considered

  1. Patient context:
  2. (a) the client keeps the context and the service trusts the body's patient;
  3. (b) a context resource in cli-orders (MOD-CLI-012), named on every clinical write by a header, and checked by the writing unit before it acts.
  4. Event topics:
  5. (a) a topic per event;
  6. (b) a topic per aggregate, with entry events on one topic for clinical entries of every kind.
  7. Governed content:
  8. (a) templates in the documentation API and instruments in the observations API, each with its own lifecycle;
  9. (b) one content API for every kind, with the kind as a field.
  10. Coded values:
  11. (a) FHIR CodeableConcept as it is, with stewardship in a separate list;
  12. (b) a CLI coded value that carries codeStatus, uncoded, stewardshipItemId and the concept map mapping.
  13. Document content:
  14. (a) content in CLI records;
  15. (b) registered in the D10 document service (ADR-HIS-125), with CLI holding documentId and versionId only.

Decision

  1. The service checks the patient context (1b).
  2. clinical-context.v1 (served by cli-orders, the unit of MOD-CLI-012) holds a context per user and window. Selecting another patient is an explicit command that replaces the current context and lists the unsigned work it leaves.
  3. Every clinical write of the CLI APIs carries the header X-Clinical-Context. The writing unit calls checkClinicalContext and refuses a missing, closed, foreign or mismatching context with 400 at /X-Clinical-Context. The mismatch is audited (cli.context.mismatch). A service identity delivering imports sends none.
  4. A header rather than a body field, so that every write of every API carries it the same way, and the shell can add it without each screen doing so.
  5. Option 1a leaves PR-RSP-003-01 to every screen, which is the failure the requirement exists to prevent.
  6. One topic per aggregate (2b).
  7. ClinicalEntryCreated, Signed and Amended are on his.cli.clinicalentry.v1, keyed by the entry: a consumer reads an entry's creation, signature and amendment in order. entryType names the kind.
  8. AllergyChanged is on his.cli.allergyrecord.v1, keyed by the patient and enterprise-scoped, because the allergy status is per patient across facilities. Every other event is facility-owned.
  9. Tasks (TaskAssigned, Completed, Overdue) share his.cli.caretask.v1. Observation sets, escalations, referrals and handovers have their own topics.
  10. Event fields follow D01-ADM: patient, encounterId, cin, facility. The APIs name the encounter encounter, as the ESS APIs do.
  11. One content API (3b). clinical-content.v1 holds document templates, flowsheet layouts and assessment instruments as versions with a kind. The validation, submission, approval, return, promotion, rollback and retirement are the same for each. A document and an assessment keep the content version they were made with (BR-CLI-007). The content API is served by cli-clinical-record, beside both modules that use it.
  12. Coded values carry their state (4b). ClinicalCode of schemas/cli-types.v1.json:
  13. codeStatus is active, inactive-flagged, unmapped or ambiguous; a Safety-relevant binding refuses what a Standard binding flags (BR-CLI-004).
  14. uncoded marks free text in a coded field, and stewardshipItemId names the D10 item it was reported as.
  15. mapping names the concept map version a translated code came from.
  16. Option 4a would leave the screen and decision support to join two sources to learn whether an allergy is unverified.
  17. Services and teams are referenced with the common reference type Service. The common types are FN-S04's, and adding HealthcareService and CareTeam there is a follow-up.
  18. Documents are held in D10 (5b). Attachments and imported documents are uploaded to the address createDocumentUpload answers, and registered with registerDocument under a cli. document type. CLI's records and events hold DocumentRef only, and a reader resolves it through D10, which decides and audits the read.
  19. Names other domains use are registered and checked. The policy resource types, document types, audit event types and notification types CLI uses are listed in contracts/cli/README.md. scripts/cross-references.ts fails when a contract of any domain uses a cli. name that is neither listed nor a CLI API. It reports, without failing, the references to events of slices not yet contracted (today MedicationReconciliationCompleted, OR-6).
  20. Two ESS references are repaired, without a version change. In document-reference.v1 the example signatureStatusRef named a cli.NoteSignature resource that does not exist; it now names cli.ClinicalDocument. In configuration.v1 the examples named the contract cli.forms; they now name cli.clinical-content. Both are example values, so the compatibility check passes and no consumer changes.

Consequences

  • RC-5-S06 builds the context service in cli-orders; RC-5-S07 to S10 build the other eight APIs in cli-clinical-record, each as contracts/cli/CONTRACT-POINTS.md lists.
  • The shell sends X-Clinical-Context from its patient context, so every CLI screen gets the check without code of its own.
  • The event backbone's topic register (platform/event-backbone) must gain the seven his.cli. topics of contract.yaml (producer cli-clinical-record). Its RegisterTest fails until it does, as it did for earlier contract topics.
  • Orders (OR-1) and medication (OR-6) add their APIs and events beside these, and extend the downtime item kinds and the handover's pending work by minor versions.
  • A change of the common reference types (HealthcareService, CareTeam) is FN-S04's to make. Until it is made, CLI uses Service.