Applications That Can Be Built
SMART lets AMCDR and approved third-party applications launch with short-lived access tied to a user, patient, EHR, encounter and purpose. Each application can access only the records and operations approved for it.
| Application type | Example use cases | Recommended launch and scope |
|---|---|---|
| Clinician applications | Specialty viewers, care-plan tools, risk calculators, medication reconciliation, clinical pathways, referral tools, and focused documentation applications. | Embedded EHR launch with user, patient, EHR, and optional encounter context; minimum read/write scopes for approved resources. |
| Clinical mobile applications | Ward rounds, bedside capture, community visits, task execution, specimen collection, and secure review on managed devices. | Device-bound mobile session with clinician, patient, EHR, encounter, facility, and expiry context. |
| Patient applications | Patient portal, personal health view, released results, appointments, consent preferences, care-team visibility, questionnaires, and approved record download. | Patient launch with own-record scopes; proxy or guardian access requires an active, time-bounded delegation. |
| AI-assisted applications | Clinical summarisation, coding assistance, document classification, chart review, risk stratification, guideline retrieval, and draft recommendations. | Patient/user launch for interactive tools or a governed system grant for approved services; exact data, template, query, purpose, processor, and write-back scopes are required. |
| Diagnostic applications | Laboratory, imaging, pathology, cardiology, and device-data viewers that need the active patient and order/encounter context. | Embedded patient/encounter launch with read scopes for relevant FHIR resources or openEHR templates. |
| Reporting and quality applications | Approved dashboards, quality review, registry submission, cohort review, and programme reporting. | User or system grant to named saved AQL queries, exports, or aggregate APIs; patient launch is not a population-reporting authority. |
| Telehealth and care coordination | Virtual consultation, referral review, discharge follow-up, multidisciplinary review, and cross-facility coordination. | User launch with patient/EHR/encounter context and care-team, consent, service, and organisation constraints. |
| National and partner services | Approved public-health, registry, terminology, identity, decision-support, and exchange services. | Confidential client or workload identity with a narrowly governed system grant, audience, tenant, organisation, environment, and destination policy. |
Application Registration and Patient Identity
Application registration and patient registration are different controls. Registering an application proves which software client is requesting access. Authenticating and linking a patient proves which person is using that software and which MPI patient/EHR they are permitted to represent.
| Object | Registration model | Typical scale |
|---|---|---|
| SMART application | Registered once in Keycloak and the AMCDR application registry for each deployment environment. | One client for App A and one client for App B in production, plus separate clients for development, test, or sandbox where required. |
| Application installation | Uses the registered public client_id; it is not registered as another OAuth client. | Potentially millions of mobile installations. |
| Patient digital identity | Authenticated by AMCDR-controlled Keycloak or an approved federated identity provider. | One identity per patient or delegate, subject to the identity provider's account model. |
| MPI identity link | Created only after identity proofing or controlled pairing to the authoritative MPI patient. | Normally one active direct patient link; delegates have separate, time-bounded relationships. |
| Application grant | Records what App A or App B may do for that user/patient and can be revoked independently. | Potentially one or more grants per patient and application. |
| Device record | Optional risk, session, notification, and revocation record; not an OAuth client registration. | Zero, one, or several devices per user and application. |
| Session and audit event | Created as the application is used; tokens remain short-lived and every clinical operation is attributable. | Continuous operational volume. |
Population-scale example
Company 1 → App A → one production application registration
Company 2 → App B → one production application registration
1,000,000 patients install both applications
→ 2 registered production applications
→ approximately 1,000,000 patient identities
→ up to 2,000,000 patient-to-application grants
→ potentially 2,000,000 or more device records
→ continuous short-lived sessions and audit events
AMCDR does not create one SMART application registration for every phone. It must nevertheless identify, authorize, scope, and audit every person, application, session, and clinical request.
Identity Authority and Responsibilities
| Party | Production responsibility |
|---|---|
| AMCDR operator | Operates or governs Keycloak, approves federated identity providers, defines authentication strength and patient roles, controls the SMART registry, and owns the clinical authorization policy. |
| Application owner | Registers the application, protects its software supply chain, configures exact redirect URIs and PKCE, requests minimum scopes, manages its application session, and complies with monitoring, incident, privacy, and retirement requirements. |
| Identity provider | Authenticates the person and supplies a stable issuer/subject identity with the required assurance attributes. |
| MPI and identity steward | Resolves identity conflicts and establishes which authoritative MPI patient is represented. Keycloak does not perform clinical identity matching. |
| AMCDR authorization services | Resolve the authenticated user to the proofed patient link, evaluate application approval, grant, scopes, consent, proxy delegation, record protection, release policy, tenant context, and token audience. |
| Patient or delegate | Authenticates using their own identity, reviews consent where required, and never shares the patient's credentials for proxy access. |
Supported Patient Authentication Models
| Model | Use | Control boundary |
|---|---|---|
| AMCDR Keycloak account | Institutional or national patient account managed in the AMCDR identity domain. | Keycloak authenticates; AMCDR pairs the OIDC subject to the MPI patient after proofing. |
| Federated national or institutional identity | National eID, insurer, hospital, or other approved OIDC/SAML identity. | The external provider is brokered through the AMCDR-controlled Keycloak trust boundary. |
| Application-owner identity provider | An application company already operates a patient identity service. | Allowed only after formal federation/brokering and assurance approval. AMCDR does not accept an app's unverified patient identifier as authentication. |
| Local AMCDR portal credentials | Deployments operating without OIDC as the primary authentication method. | Uses AMCDR activation, password, proofing, and pairing controls. When OIDC is primary, patients should use Keycloak/federated login instead. |
| Guardian, caregiver, or proxy | A person acts for a child, dependent, or another patient. | The delegate authenticates with their own identity and receives a patient-bound session only while an active, scoped delegation exists. |
| System service | Approved non-interactive registry, analytics, integration, or decision-support processing. | Uses a confidential workload identity and system grant; it is not treated as a patient login. |
First-Time Patient Onboarding
- The application is already registered and active in Keycloak and AMCDR with exact redirect URIs, audience, lifecycle state, and approved scopes.
- The patient signs in through AMCDR Keycloak or an approved federated identity provider. A native mobile app uses Authorization Code with PKCE S256 and does not collect the patient's Keycloak password.
- AMCDR provisions or resolves the local identity from the trusted OIDC issuer and stable
sub. - The patient's identity is proofed against authoritative evidence and reconciled to an existing MPI patient. A new clinical patient is not created merely because an identity-provider account exists.
- AMCDR creates an active patient portal identity link, patient-portal membership, enrollment/proofing state, and the
patient_portal_userrole constrained to that patient. - AMCDR creates or resolves the application grant and issues a short-lived SMART session containing the authorized patient, EHR, audience, scopes, actor type, optional delegation, and optional device context.
- Every access is evaluated against consent, release controls, protected-record policy, application scope, token scope, active grant, and patient/EHR boundary.
Registered App A
+ trusted patient authentication
+ proofed Keycloak subject → MPI patient link
+ active portal enrollment
+ approved App A scopes and grant
+ consent/release/protection decision
= patient-bound SMART session
Subsequent Login and SSO
Identity proofing and MPI pairing are not repeated for every login. After the first approved pairing, AMCDR resolves the stable OIDC issuer and subject to the existing identity link and then re-evaluates the current authorization state.
Keycloak issuer + subject (`iss`, `sub`)
→ AMCDR local identity
→ active PatientPortalIdentityLink
→ authoritative MPI patient
→ EHR
→ application grant and permitted data
If an active Keycloak SSO session exists, the authorization redirect may complete without showing another password screen. This is still a new authorization decision and SMART session; it is not permanent access.
| Condition | Result |
|---|---|
| Identity link, enrollment, application and grant remain active | Resolve the patient automatically and issue a new scoped session. |
| Access token expires | Use an eligible rotating refresh token or perform authorization again according to policy. |
| Patient uses App A and App B | The same patient identity and MPI link are reused, but each application has a separate approval and grant. |
| Patient revokes App B | App B loses access while App A can continue under its own active grant. |
| Patient changes phone | Authenticate again; register/bind the new device if device governance is enabled. No new SMART application client is created. |
| Delegate switches represented patient | Issue a new patient-bound token only after validating the selected active delegation. |
Denial and Revocation Conditions
AMCDR denies login completion or clinical access when any required trust link is unavailable. Typical causes include:
- the SMART application is unregistered, unapproved, suspended, retired, or uses an unregistered redirect URI;
- the identity provider, token issuer, audience, authorized party, signature, PKCE verifier, or authentication assurance is invalid;
- no active patient identity link exists, proofing is incomplete, or the identity is linked to a different MPI patient;
- the patient portal enrollment, patient account, device, application grant, consent, or proxy delegation is inactive, expired, or revoked;
- the requested scope, template, query, resource, EHR, encounter, facility, tenant, organisation, environment, or purpose is outside the approved boundary;
- the record is protected, the requested result is not released, or the applicable privacy policy denies disclosure; or
- the access/refresh token has expired, been reused, rotated, or revoked.
Patient Identity and Session APIs
| Route | Purpose |
|---|---|
GET /patient-portal/patients/{patient_id}/accounts | List identity links already associated with the MPI patient. |
POST /patient-portal/patients/{patient_id}/accounts | Create a governed local portal account where local password authentication is the approved model. |
POST /patient-portal/patients/{patient_id}/activation-tokens | Issue a time-bounded first-time activation token. |
POST /patient-portal/patients/{patient_id}/pairing-tokens | Issue a controlled token for pairing an already authenticated user to an MPI patient. |
POST /patient-portal/pair | Redeem the pairing token and create the verified patient identity link. |
GET /patient-portal/session | Return the active direct/proxy patient context and linked portal identity. |
POST /patient-portal/smart-session | Issue a short-lived own-record or delegated SMART session for the registered first-party portal. |
POST /mobile/smart-session | Issue a device/context-bound clinician mobile session. |
These endpoints do not allow an application vendor to assert an arbitrary patient ID. Administrative token issuance, proofing, pairing, delegation, and account lifecycle operations remain role-controlled and audited.
AI Application Controls
An AI application can register as a SMART client. SMART controls its launch and access permissions. Clinical approval and limits on model access still apply.
- Approve the exact openEHR templates, FHIR resources, saved queries, patient/encounter context, and purpose of use the AI application requires.
- Use read-only scopes unless a separately approved workflow permits draft or final write-back. AI-generated content must identify its model/service provenance and remain distinguishable from clinician-authored content.
- Apply patient consent, protected-record, care-team, release, residency, processor, retention, and cross-border rules before any payload leaves AMCDR.
- Keep deterministic CQL, medication-safety, validation, and workflow guardrails authoritative where configured. A model suggestion cannot bypass a blocking rule.
- Require human review for clinical decisions according to the approved risk classification and record acceptance, rejection, override, and resulting action in audit.
- Do not place reusable access tokens, raw clinical payloads, or patient identifiers in prompts, logs, telemetry, or model-training stores outside the approved processing contract.
Mobile Application Controls
SMART supports browser, native, and hybrid mobile clients through authorization code with PKCE. AMCDR's first-party Clinical Mobile client uses the same registry and grant model as external mobile applications.
- Use public-client PKCE S256; never embed a confidential client secret in a mobile binary.
- Bind the session to the authenticated clinician, registered device, patient/EHR, facility, optional encounter, token audience, and expiry.
- Store refresh tokens only in the platform secure keystore and revoke them when the device, user, grant, or application is suspended.
- SMART does not automatically provide offline synchronization. Any offline cache, conflict resolution, remote wipe, local encryption, and delayed submission workflow requires separate approval and testing.
Checks that still apply
- SMART does not replace openEHR templates, FHIR profile validation, MPI reconciliation, terminology governance, or clinical workflow bindings.
- SMART does not bypass RBAC/ABAC, patient consent, care-team scope, protected-record controls, delayed release, or break-glass policy.
- SMART does not grant population access from a patient launch. Population reporting requires approved query/report authority.
- SMART does not automatically make an application trusted. Registration, security review, redirect URI control, scope approval, testing, monitoring, suspension, and retirement remain mandatory.
- SMART is an application launch and authorization standard, not a user-interface framework. Applications may use any approved web or mobile technology.
First-party Patient Portal and Mobile
amcdr-patient-portal and amcdr-clinical-mobile are registered SMART clients. They use the same application approval, grants, resource scopes, audit and revocation controls as external applications.
- The portal exchanges an MPI-verified login at
POST /patient-portal/smart-sessionfor a short-lived own-record token. - Guardian, caregiver and proxy access requires a consent reference, patient-only scopes, validity period and an active delegation. Switching records issues a new patient-bound token.
- The mobile endpoint
POST /mobile/smart-sessionbinds clinician, device, patient, EHR and optional encounter context. - SMART never bypasses RBAC, ABAC, consent, sensitive-record release or delayed-result policies.
SMART App Launch STU 2.1
Profile contract: HL7 SMART App Launch STU 2.1.
GET /fhir/.well-known/smart-configuration
GET /smart/authorize
POST /smart/token
The FHIR profile declares EHR and standalone launch, public clients, PKCE S256, permission-v2 patient/user scopes, patient and encounter context, and rotating offline refresh tokens. Authorization codes are hashed, single-use and expire after five minutes.
patient/Observation.rs
patient/*.rs
user/Encounter.cruds
system/Patient.rs
_id, patient, patient_id or subject constraint. Cross-patient and unconstrained searches are rejected before FHIR processing.Architecture
Keycloak is the OAuth 2.0/OpenID Connect authority. AMCDR is the clinical context and resource authorization broker. This separation keeps login, SSO, PKCE, client authentication and provider keys in the identity platform while AMCDR governs which app may see which EHR, template or saved query.
| Component | Responsibility |
|---|---|
| Application registry | Client ID, exact launch/redirect URIs, client type, JWKS, requested and approved scopes, allowed facilities and lifecycle state. |
| Launch broker | Opaque, hashed, short-lived, single-use patient, EHR, encounter and episode context. |
| Grant registry | User, patient and system grants with scopes, purpose, context, expiry and revocation. |
| Scope enforcement | Independent checks across token, application approval and active grant; EHR context is pinned. |
| Audit and readiness | Application, launch and grant lifecycle events plus module, database, OIDC and signing-key checks. |
Discovery
GET /.well-known/smart-configuration
The document publishes OAuth/OIDC endpoints, PKCE S256, launch capabilities, supported openEHR scopes, org.openehr.rest, and optional org.fhir.rest. Swagger exposes the same authorization-code flow as SmartOAuth2.
Patient and Standalone Launch
- A clinician selects an app from Applications → SMART app platform, or chooses SMART apps from a patient timeline.
- AMCDR creates a launch using
POST /smart/apps/{application_id}/launches. - The app receives its launch URI with
issand a one-timelaunchhandle. - The app completes OAuth authorization code with PKCE S256 against Keycloak.
- The authenticated app consumes the handle at
POST /smart/launches/{launch}/consumewith itsclient_id. - AMCDR returns a short-lived resource token plus
patient,ehrId, optional encounter/episode context and the active grant. - The app calls
/openehr/v1; AMCDR applies RBAC/ABAC and SMART scope checks.
AMCDR advertises only the capabilities enforced by the runtime. Production release approval requires successful execution of the applicable SMART/Inferno interoperability suite, retention of results in the deployment evidence pack, and resolution of all material findings. Certification claims may be made only against the resulting independent evidence.
A launch is rejected when expired, already consumed, issued for another client, issued to another authenticated user, or outside the app's approved facility/context.
openEHR Permission Scopes
patient|user|system / composition-<templateId>|template-<templateId>|aql-<queryName> . <permissions>
Permissions are c create, r read, u update, d delete and s search/execute. Wildcards are supported.
patient/composition-openEHR-EHR-OBSERVATION.vital_signs.v2.rs
patient/composition-*.rs
user/template-*.rs
user/aql-org.example::patient-summary.s
system/composition-*.cruds
Patient-context AQL must send the launched EHR in openehr-ehr-id or the standard ehr_id query parameter. Unbounded patient AQL is rejected.
API reference
The authenticated Swagger UI exposes 19 operations under SMART on openEHR. They are included in the default FHIR + openEHR API-area view. The operation count treats different HTTP methods on the same path as separate calls.
| Route | Purpose |
|---|---|
GET/POST /smart/apps | List apps; super-admin registration and approval. |
GET/PATCH/DELETE /smart/apps/{id} | Inspect, update, suspend or retire. |
POST /smart/apps/{id}/launches | Create standalone or embedded clinical launch. |
POST /smart/launches/{launch}/consume | Consume once and issue context token. |
GET /smart/launches | Super-admin launch lifecycle inspection. |
POST /smart/apps/{id}/grants | Create governed user, patient or system pre-grant. |
GET /smart/grants | List own grants, or all grants for super admin. |
DELETE /smart/grants/{id} | Owner/admin revocation. |
GET /smart/audit-events | Lifecycle evidence. |
GET /smart/readiness | Runtime and OIDC configuration checks. |
GET /fhir/.well-known/smart-configuration | FHIR-relative STU 2.1 discovery. |
GET /smart/authorize | Authorization code and PKCE validation. |
POST /smart/token | Authorization-code or rotating refresh-token exchange. |
POST /smart/first-party/bootstrap | Register the portal and mobile clients. |
POST /patient-portal/smart-session | Own-record or delegated proxy session. |
POST /mobile/smart-session | Device/context-bound clinical mobile session. |
Configuration
AMCDR_MODULE_SMART_APP_PLATFORM_ENABLED=true
AMCDR_OIDC_ISSUER_URL=https://auth.example.org/realms/amcdr
AMCDR_SMART_AUTHORIZATION_ENDPOINT=https://auth.example.org/realms/amcdr/protocol/openid-connect/auth
AMCDR_SMART_TOKEN_ENDPOINT=https://auth.example.org/realms/amcdr/protocol/openid-connect/token
AMCDR_SMART_JWKS_URI=https://auth.example.org/realms/amcdr/protocol/openid-connect/certs
AMCDR_SMART_INTROSPECTION_ENDPOINT=https://auth.example.org/realms/amcdr/protocol/openid-connect/token/introspect
AMCDR_SMART_REVOCATION_ENDPOINT=https://auth.example.org/realms/amcdr/protocol/openid-connect/revoke
AMCDR_SMART_RESOURCE_AUDIENCE=amcdr-openehr-api
AMCDR_SMART_FHIR_RESOURCE_AUDIENCE=amcdr-fhir-api
AMCDR_SMART_LAUNCH_TTL_SECONDS=300
Every SMART access token must contain the configured resource audience in aud and the application's registered client ID in azp. AMCDR verifies both claims against the active application registry before checking the grant and openEHR scopes.
Production Checklist
- Apply migrations through
0097_smart_fhir_first_partyand enable the runtime module. - Configure exact Keycloak protocol endpoints, audience, TLS and signing keys.
- Register the OAuth client in Keycloak with exact redirect URIs and PKCE S256.
- Register the same client ID in AMCDR and approve only the minimum template/query scopes.
- Test standalone and patient launches, wrong-EHR denial, expiry, reuse prevention and revocation.
- Run
GET /smart/readiness?probe_oidc=trueand review lifecycle audit before activation.