This matrix is cumulative. An allow at one layer never overrides a deny at a later layer. A super_admin role, SMART wildcard, broad Keycloak group or API key does not silently bypass tenant isolation, protected-record policy, patient consent or audit.
Authorization Decision Flow
If any step denies the request, processing stops. Patient aliases and persisted FHIR identifiers are resolved to the authoritative MPI patient before the relationship decision is made.
Patient Access Levels
Each level describes the caller’s relationship to one patient for one request. Administrative and system access have separate rules. Emergency access is temporary and requires its own approval and review.
| Level | Runtime scope | Who qualifies | Permitted boundary | Explicit exclusion |
|---|---|---|---|---|
| L0 | denied | Unauthenticated, invalid context, or no qualifying relationship | Explicitly public readiness and discovery routes only | Patient discovery, clinical data and protected-patient existence leakage |
| L1 | Authenticated, no patient relationship | Valid staff/app identity with a route role | Granted non-patient control-plane or catalogue functions | Patient records merely because a route or workspace can be opened |
| L2 | self | Patient Portal user or validated proxy representing the patient | Released patient-facing information for exactly the represented patient | Unreleased clinician-only content, another patient and staff administration |
| L3 | service | Clinician assigned to a governed service actively related to the patient | Care demographics, matching service records, and medication/allergy safety data | Full longitudinal record, unrelated services, cohorts and unfiltered AQL |
| L4 | longitudinal | Active explicit patient care-team member | Clinically necessary cross-service information | Opted-out membership, protected data without clearance, population reporting |
| L5 | administrative | Governed super_admin or system_admin operation | Explicit administrative workflows within tenant context | Automatic clinical need-to-know or bypass of consent, protection and audit |
| L6 | system | Registered service with explicit trusted-system scope | Exact tenant-bound machine operation and resource contract | Human use, cross-tenant access, undeclared resources and secondary use |
| E1 | Emergency overlay | Eligible clinician, break-glass clearance, emergency purpose and reason | Time-limited access necessary for the emergency | Permanent access, silent routine browsing, bulk export and omitted review |
The response header X-AMCDR-Clinical-Access-Scope reports the server-resolved scope on governed clinical responses. It is diagnostic evidence, not a client-side authorization mechanism.
Authentication Matrix
| Credential or flow | Actor | Required validation | Resolved context | Production restriction |
|---|---|---|---|---|
| Keycloak/OIDC code + PKCE | Interactive staff | Issuer, signature, audience, expiry, state/nonce and PKCE | AMCDR user, memberships, normalized roles and tenant context | Realm role alone does not create a patient relationship |
| Local password | Staff where OIDC is absent | Password policy, active account and token invalidation after password change | Local user, memberships and roles | Disabled when Keycloak/OIDC is authoritative; no shared accounts |
| SMART code + PKCE | First- or third-party application | Registered client, exact redirect URI, audience, PKCE, launch context and scopes | User/app plus patient, encounter and SMART grants | SMART grants constrain access and never override AMCDR policy |
| Patient Portal SMART session | Patient or authorized proxy | Patient link, active delegation, represented patient and release policy | L2 self for one patient | Patient and workforce assignment groups remain separate |
| API key | Integration or automation | Hashed lookup, active state, tenant binding, scopes, expiry and revocation | Registered service/user and explicit scopes | One credential per integration; never reuse a human administrator |
| Trusted system token | Approved internal/national service | Normal token checks plus explicit trusted-system scope | L6 system inside signed tenant context | Trust is never inferred from network location |
Interactive workspace and Patient Portal sessions expire after 900 seconds of inactivity. Keyboard, pointer, touch, focus and activity in another AMCDR tab on the same origin reset the timer. Background refresh does not. Timeout revokes the bearer session, clears patient context, ends the Keycloak session, and requires a new sign-in. The default bearer-token lifetime is also 900 seconds, and expired bearer tokens cannot be refreshed.
Fine-Grained Patient Data Matrix
Conditional means the named workflow, role, release or clearance must also permit the action. Every column remains tenant-bound and audited.
| Data or action | L2 self/proxy | L3 service | L4 care team | L5 admin | L6 system |
|---|---|---|---|---|---|
| Identity and care demographics | Own/represented patient | Minimum needed for active care | Assigned patient | Authorized admin workflow | Explicit MPI scope |
| Service-owned openEHR compositions | Released view | Read/write for matching service and template | Clinical role/workflow | Conditional; admin is not clinical authorship | Composition scope and template contract |
| Other-service compositions | Released view | Denied | Clinically necessary read | Conditional and audited | Explicit system scope |
| Medication and allergy safety | Released view | Cross-service read; governed medication writes | Read plus authorized workflow writes | Conditional | Explicit medication scope |
| Lab and diagnostic detail | Result-release policy | Service provenance and route policy; otherwise denied | Cross-service read; assigned workflow writes | Conditional | Explicit lab/diagnostic scope |
| Documents, images and binaries | Released view | Service-owned where provenance resolves | Clinically necessary read | Conditional | Explicit document scope |
| SHR/IPS and FHIR projections | Patient endpoint/release rules | Service-safe resources | Longitudinal patient projection | Conditional | Exchange scope, partner policy and purpose |
| AQL, saved query and browser | No staff workbench | Patient rows only when service filtering is enforceable | Assigned-patient rows | Approved reporting purpose | Approved query scope |
| Population cohort/report/export | Denied | Denied through clinical APIs | Denied through clinical APIs | Reporting role, approved query and disclosure controls | Dedicated reporting/output contract |
| Care-team/consent administration | Own choices where exposed | Separately authorized only | Separately authorized only | Privacy/release authority | Explicit workflow scope |
| VIP, sealed or protected content | Patient release policy | Clearance or break-glass | Clearance or break-glass | Clearance and purpose required | Explicit protected-data authority |
| Hard delete, EHR merge, template delete | Denied | Denied | Denied | Dedicated high-risk role, confirmation and audit | Approved administrative service only |
Control Ownership
| Control | Authority | Decision | Owner |
|---|---|---|---|
| Identity, SSO and MFA | Keycloak/OIDC realm and clients | Is the credential authentic? | Identity administrator |
| Tenant boundary | Signed AMCDR context, memberships and row-level controls | Where may the actor operate? | Platform/organisation administrator |
| Job capability | Keycloak roles synchronized to AMCDR roles | May the actor perform this class of work? | Workforce/access administrator |
| Clinical service | Clinical Service Offering and workforce assignment | Which service does the clinician represent? | Facility/workforce administrator |
| Patient relationship | Active service workflow or explicit care-team membership | Why may this actor access this patient now? | Service/care-team manager |
| Patient privacy | Portal consent and care-team privacy | Has the patient limited routine access? | Patient/delegate and privacy staff |
| Protected classification | Record/template policy and clearances | Is additional clearance required? | Protected-record officer |
| Emergency exception | Break-glass eligibility, reason, time and review | Is emergency access justified? | Emergency authority/privacy reviewer |
| API and resource policy | Route matrix, policies and SMART/API scopes | Is this method/resource permitted? | Platform/security administrator |
| Release and export | Release, sharing and query governance | May data be shown or leave AMCDR? | Release/data-governance authority |
Deny Precedence
- Invalid, expired, revoked or incorrectly addressed credential.
- Invalid signed tenant context or tenant, organisation or facility mismatch.
- Inactive user, membership, role, API credential, delegation or care-team membership.
- Route role or SMART/API scope excludes the method or resource.
- Matching executable deny policy.
- No qualifying patient relationship.
- Patient consent or care-team privacy excludes the actor.
- Protected-record or protected-template clearance is absent.
- Patient-facing result or document has not been released.
- Patient-safe query filtering, reporting authority or export control cannot be proven.
Worked Decisions
| Scenario | Decision | Reason |
|---|---|---|
| Mental Health psychiatrist opens an active service patient | L3 service | Mental Health compositions and medication/allergy safety are available; unrelated cardiology records are not |
| The psychiatrist joins the explicit patient care team | L4 longitudinal | Clinically necessary cross-service data becomes available, subject to privacy and protection |
| Care-team clinician requests a sealed composition without clearance | Denied | Care-team access does not replace protected-record clearance |
| Patient opts out of whole-team routine access | Denied for routine team access | The relationship remains auditable, but the patient's restriction is enforced |
| Eligible emergency clinician supplies break-glass reason | E1 overlay | Time-limited access is audited and reviewed |
| Analyst submits identifiable AQL without reporting authority | Denied | Query access cannot bypass row filtering or export governance |
| SMART token targets a different patient | Denied | Scope and represented-patient context do not match |
Audit And Production Acceptance
Material decisions retain actor and credential type, tenant context, memberships and roles, service keys, represented patient, access level, purpose, route/action, decision identifiers, protected classification, emergency reason, outcome, timestamp and correlation ID. Query and export evidence additionally records the saved-query or normalized query reference, parameters, row count, output format, cache scope and protected-row treatment.
Production acceptance tests must cover allow and deny outcomes across Patient Workspace, direct APIs, openEHR, FHIR, SHR/IPS, AQL, saved queries, documents, caches and exports. Cross-tenant, stale-membership, opt-out, protected-record and identifier-alias cases are mandatory negative tests.