Skip to content

Architecture / Decision records / ADR-HIS-069

ADR-HIS-069 How a screen calls domain APIs, shows the patient it opened and keeps its draft, until the shell SDK offers them

Status Accepted
Decided 2026-11-25 by session RC-1-S21
Record Drafted 2026-11-25; approved 2026-11-30 by the Enterprise Architecture Board
Where the rule lives web/domains/adm/UI-ADM-001/ and web/domains/adm/UI-ADM-002/ (api/http.ts, IdentityZone.tsx, draft.ts, check-against-stubs.sh)

Context

RC-1-S21 builds the first screens that call a service: UI-ADM-001 and UI-ADM-002. ADR-HIS-042 lets a screen import only React, React Aria, clsx, the design system and the shell SDK, and FN-S06 left three things to "the first screen that calls a service": a fetch helper in the SDK that adds correlation identifiers, the patient context taken from Domain 1, and drafts. A screen session cannot change the SDK (session rule 10). The card leaves open how the screens:

  • reach the APIs, and with which headers, given the conventions of IF-ISE-001 (architecture 6.2) and the gateway paths of ADR-HIS-062;
  • turn an answer into the standard screen states of Shell 13, including "Access cannot be checked" (CUX-67) and a lost response (CUX-36);
  • show the patient context zone when the screen itself opens the patient, which the SDK cannot be told yet;
  • keep a draft (CUX-30 to CUX-32) without leaving patient data on a shared workstation (CUX-39);
  • prove that they "work against the stubs of the contracts" when the workspace's tests run in jsdom without the contract tools.

Options considered

  1. Wait for the SDK. Build the screens with fixtures only. The card's "works against the stubs" would not hold, and every later screen session would meet the same gap.
  2. One shared helper outside the screen folders. Not allowed to a screen session: the workspace holds only screen folders, and the SDK belongs to the shell.
  3. A small service layer inside each screen folder, in the shape the SDK should take over. Two copies of one file now, one move later.

Decision

Option 3.

  1. Paths. A screen calls <base>/<contract path>, where the base of each domain is /<domain> on the same origin: the gateway's /<domain>/v<major>/... (ADR-HIS-062 point 3). The bases are a setting, so a test or a stub run can point a domain elsewhere.
  2. Headers on every call.
  3. Authorization: Bearer with the signed-in user's own token, never a service token: the decision point and the unit decide on the user (FR-ADM-MPI-002 part 13). The token comes from a provider set by the host; until sign-on exists (UI-ESS-001) there is none, and the screen shows "session ended".
  4. X-Correlation-Id: a new UUID per request. The screen shows it as the service-desk reference of an error (Shell 13).
  5. X-Purpose-Of-Use: HOPERAT for the registration desk and identity stewardship. A clinical screen sets its own.
  6. X-Facility: the shell's working facility, on every call, for facility-owned and enterprise operations alike (architecture 7.5).
  7. Idempotency-Key: one per user intent (CUX-35). It is kept across retries of the intent and renewed after its success, or when the intent changes (for example "Create separate visit").
  8. If-Match: the version read, as "<version>".
  9. Answers to screen states.
Answer State
401 session ended
403 no permission
400 refused, naming the field from errors[].pointer
404 not found
409, 412 changed
503 whose detail starts "Authorization service unavailable" (the gateway's degraded path) "Access cannot be checked" (CUX-67)
any other 5xx unavailable
no answer at all not known (CUX-36)
4. A lost response. A command that gets no answer says "Checking whether this was saved" and sends the same request with the same key once more. The provider answers the original if the first attempt took effect. If the second gets no answer either, the screen offers only "Check again", with the same key, never a new attempt. This relies on the contract rule that a repeated Idempotency-Key gets the original answer, which the ADM contract states.
5. Where the code lives. api/http.ts is identical in both screen folders, because a screen folder imports nothing from another one. setServiceSettings() is the hook a host calls; tests call it now, and the SDK's service client will replace it.
6. The patient a screen opens. UI-ADM-001 finds or creates the patient, and the SDK cannot be told which patient that is. So the screen draws the design system's PatientContextZone at the top of its content as soon as a person is opened. It uses the counter variant (CUX-48), never builds its own patient header, and registers with context: "none", because it opens with no patient. UI-ADM-002 draws the "Comparing 2 records" state of CUX-03, which the design system lacks, in the same position and style.
7. Drafts. A screen keeps the user's draft in the memory of the window, per user and facility, and autosaves it every 10 seconds of activity and when the view is left. It never uses browser storage, so no patient data stays on the device and another user never sees it (CUX-39). It survives leaving and reopening the view, not closing the window. A draft is never submitted on restore (CUX-32).
8. Proof against the stubs. The component tests (pnpm test, in the pipeline) use a fake gateway shaped by the contract's examples. Each screen folder also has stubs.test.tsx, skipped unless HIS_ADM_STUB_URL and HIS_ESS_STUB_URL are set. check-against-stubs.sh serves the stubs with his-contract serve, runs that test through the same screen against them, and fails on any violation a stub records (consumer side of ADR-HIS-045).

Rationale

  • The card asks the screens to work against the stubs, so they must make real calls now.
  • Writing the service layer in the shape the SDK will take keeps the later move mechanical. Screens keep calling one function per contract operation; only the import changes.
  • Same-origin gateway paths need no CORS and no address in the bundle. The prefix is the one the gateway already publishes.
  • Detecting the policy outage from the gateway's detail is weak, but it is the only signal ADR-HIS-062 gives. CUX-67 forbids showing an outage as "No permission", and a weak signal is better than that.
  • An in-memory draft meets CUX-30 to CUX-32 for interruptions within the window, and cannot breach CUX-39. A server-side draft store (CUX-31 "pending work") is a service of its own and is not in any RC-1 contract.

Consequences

  • Shell SDK (a session owning web/shell), as follow-ups:
  • a service client with the behaviour of points 1 to 4, and the token from sign-on;
  • an openPatient call, so that the shell shows the zone and the window title of CUX-03 for a patient a screen opened;
  • a draft service backed by the user's pending work.

The two api/http.ts copies, IdentityZone.tsx and draft.ts are then deleted, and the screens import from the SDK. - Design system: a select, a radio group, a notice, a disabled action with its reason, the comparison state of the patient context zone, and partial dates of birth in PatientContextZone. Today they are built in the screen folders. - Gateway (RC-1-S12's unit): a distinct problem code for "authorization service unavailable" would let point 3 drop the detail prefix. - Later screen sessions follow points 1 to 8 until the SDK offers them, and add their own check-against-stubs.sh with the same layout. - The pipeline does not run check-against-stubs.sh. RC-1-S26 (integrate) or the harness may run it beside the slice scenario.