Skip to content

feat(viewer): open a record on a justification with a reason (#6649) - #6714

Open
rubentalstra wants to merge 31 commits into
mainfrom
feat/viewer-justified-access
Open

rubentalstra wants to merge 31 commits into
mainfrom
feat/viewer-justified-access

Conversation

@rubentalstra

@rubentalstra rubentalstra commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

A clinician can now open a record on a justification when FerroEHR refuses it for lack of a care relationship. The reason they give stays on the server.

  • The offer. When the CDR answers refused-no-care-relationship or refused-reason-missing on an EHR's page, the refusal is followed by a form. It asks for a purpose of use, from the list {ext}/access/purposes returns, and a required reason of 1 to 1000 characters with no control characters (book security.md §Justified access outside the care relationships). The access policy decides, by purpose, whether this is a justification or an emergency; the viewer only states it.
  • Where it lives. The justification (EHR id, purpose, reason, end time) is kept in the viewer's server-side session record through ferrohealth-session 0.30.1 Sessions::justify (ferrohealth-session keeps a stated justification with a memory-store session FerroSMART#902). It is never kept in a cookie, since the reason may hold health data (GDPR Art. 5(1)(c) and (f)). It lasts for that one EHR for 15 minutes, until End now, or until sign-out.
  • On the wire. While it holds, each CDR call to the REST root that draws that EHR's pages declares the purpose in the purpose header. It states the reason, percent-encoded (RFC 3986 §2.1), in the header the CDR names. Calls about any other EHR, and calls to the management API, carry neither header.
  • The notice. A warning above the page shows the purpose, the end time and the reason, with End now.
  • Sealed store. A viewer with [session] store = "sealed" keeps no reason. It says that justified access needs the server-side session store, names the key, and shows no form. The hosted sandbox moves to the memory store, so every shipped posture supports justified access. Several replicas sharing a store is ferrohealth-session: a server-side session store shared between console instances FerroSMART#904.
  • Server. GET {ext}/access/purposes now also returns reason_header ([audit] reason_header), so the viewer uses the header the deployment reads. The served OpenAPI snapshot and the REST test follow.

No openEHR specification governs the justification header, its bound or the viewer: FerroEHR's own design.

Tests:

  • justified unit tests: reason bounds, encoding, which refusals offer a justification.
  • ssr_app::a_refused_record_offers_a_justification_that_holds_until_ended: the memory store draws the form and the notice and never puts the reason in a cookie; a sealed store explains why it offers none; End now ends it.
  • an_empty_reason_keeps_no_justification, the sandbox posture test, and access_purposes_http.
  • Live against a local server with a policy that requires care relationships and has TREAT and ETREAT justifications: refused, then justified, then the access-log entry shows the justification authorisation with the reason, then End now, then refused again.

Closes #6649

  • Captures. The docs-shots pass captures the form and the notice as the seeded clinician. It writes the seed's first policy version over its final one, captures, and writes the final version back whatever the captures did. This runs after every other capture, so the access-policy and access-log captures keep the seed's own history.

This PR is stacked on #6679 (the access catalog part) and carries it until that merges. #6698 is on main.

#6641)

Parties lists the parties the CDR holds by kind, newest commit first,
read through the CDR's AQL rooted at a demographic class, so the
policy-party rule is the server's. A find narrows the list to the parties
whose identities hold a text; it posts, so the text stays out of the
address. A CDR that serves no demographic root keeps the open by uid and
the tag index. The parties pages get their own catalog part.
…le (#6647)

The Access log tab lists the EHR's access-log entries newest first, read
from the CDR's access-log extension, filtered by action, outcome, kind of
accessor, ground and day, and paged in the session. An entry shows the
access, what it rested on with the reason stated for a justified or an
emergency access, what it reached and the entry as served. The CDR decides
which view the reader gets; a refused read says who may read the log.
….30 (#6689)

ferrohealth-smart 0.35 signs and verifies every JWS in its own jws module
over aws-lc-rs. The viewer names its launch key's algorithm in that type,
so jsonwebtoken is a test fixture alone. ihe-iti 0.24 and ferrobridge-term
0.21 are the releases on ferrohealth-smart 0.35 that keep fhir-types 0.2,
so the lock holds one copy of each family crate. A configured HS256 or none
now fails to parse.
GET {ext}/access/purposes answers the [audit] reason_header beside the
purpose header, so a client states the reason of a justified access in
the header this deployment reads.
A refusal a justification answers (no care relationship, or a
justification with no reason) is followed by a form: a purpose of use the
CDR lists and the clinician's reason. The viewer keeps it in its
server-side session for that EHR for 15 minutes, never in a cookie, and
each CDR call drawing that EHR's pages declares the purpose and states the
reason, percent-encoded, in the header the purposes route names. A notice
shows it with End now. A sealed session store keeps no reason, so it says
justified access needs the memory store; the hosted sandbox moves to the
memory store.
…t/viewer-ehr-access-log

# Conflicts:
#	app/ferroehr-viewer/src/paging.rs
#	app/ferroehr-viewer/tests/fixtures/cdr/manifest.json
#	app/ferroehr-viewer/tests/fixtures/cdr/recording.json
#	app/ferroehr-viewer/tests/it/ssr_app.rs
#	scripts/checks/stray-literals.allow
…iti and ferrobridge-term (#6689)

ihe-atna and ehds-logging 0.29, ihe-iti 0.25 and ferrobridge-term 0.22.1
take fhir-types 0.3, so the lock links one copy of it beside
ferrohealth-smart 0.35. This folds in Dependabot's ferrohealth-family
group (#6703).
0.30.1 keeps the justification an operator states for one object with a
memory-store session, which the viewer's justified access builds on.
# Conflicts:
#	website/book/src/viewer/img/parties/parties-dark.png
#	website/book/src/viewer/img/parties/parties.png
# Conflicts:
#	website/book/src/viewer/img/ehrs/ehr-dark.png
#	website/book/src/viewer/img/ehrs/ehr.png
# Conflicts:
#	.claude/rules/console-ui.md
#	app/ferroehr-viewer/src/locale.rs
#	app/ferroehr-viewer/tests/fixtures/cdr/manifest.json
#	app/ferroehr-viewer/tests/fixtures/cdr/recording.json
# Conflicts:
#	app/ferroehr-viewer/src/bff/mod.rs
#	app/ferroehr-viewer/tests/fixtures/cdr/manifest.json
#	app/ferroehr-viewer/tests/fixtures/cdr/recording.json
#	app/ferroehr-viewer/tests/it/main.rs
@rubentalstra rubentalstra added the viewer The FerroEHR Viewer (the console, its own OCI image) label Nov 26, 2026
# Conflicts:
#	scripts/checks/stray-literals.allow
# Conflicts:
#	scripts/checks/stray-literals.allow
…-access

# Conflicts:
#	scripts/checks/stray-literals.allow
…eded clinician (#6649)

The docs-shots pass writes the seed's first policy version over its final
one, captures the clinician's refused EHR with the justification form and
the notice after stating one, and writes the final version back whatever
the captures did. It runs after every other capture.
@rubentalstra
rubentalstra marked this pull request as ready for review November 26, 2026 20:16
@rubentalstra
rubentalstra added this pull request to the merge queue Nov 26, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 26, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

viewer The FerroEHR Viewer (the console, its own OCI image)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The viewer offers justified and emergency access with a reason

1 participant