Integration

SMART Application Platform

Register and launch SMART applications, configure identity and scopes, and manage patient, clinician, and proxy access.

Status: available as a configurable runtime module. The upstream SMART on openEHR specification is published at DEVELOPMENT maturity; AMCDR pins the supported revision and requires deployment-specific interoperability verification before production activation.

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 typeExample use casesRecommended launch and scope
Clinician applicationsSpecialty 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 applicationsWard 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 applicationsPatient 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 applicationsClinical 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 applicationsLaboratory, 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 applicationsApproved 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 coordinationVirtual 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 servicesApproved 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.

ObjectRegistration modelTypical scale
SMART applicationRegistered 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 installationUses the registered public client_id; it is not registered as another OAuth client.Potentially millions of mobile installations.
Patient digital identityAuthenticated 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 linkCreated 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 grantRecords 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 recordOptional risk, session, notification, and revocation record; not an OAuth client registration.Zero, one, or several devices per user and application.
Session and audit eventCreated 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

PartyProduction responsibility
AMCDR operatorOperates or governs Keycloak, approves federated identity providers, defines authentication strength and patient roles, controls the SMART registry, and owns the clinical authorization policy.
Application ownerRegisters 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 providerAuthenticates the person and supplies a stable issuer/subject identity with the required assurance attributes.
MPI and identity stewardResolves identity conflicts and establishes which authoritative MPI patient is represented. Keycloak does not perform clinical identity matching.
AMCDR authorization servicesResolve 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 delegateAuthenticates using their own identity, reviews consent where required, and never shares the patient's credentials for proxy access.
Before data is shared: Keycloak proves who authenticated. MPI determines which patient they represent. The SMART application registration identifies the requesting software. All three must resolve successfully before AMCDR exposes clinical data.

Supported Patient Authentication Models

ModelUseControl boundary
AMCDR Keycloak accountInstitutional 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 identityNational eID, insurer, hospital, or other approved OIDC/SAML identity.The external provider is brokered through the AMCDR-controlled Keycloak trust boundary.
Application-owner identity providerAn 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 credentialsDeployments 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 proxyA 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 serviceApproved 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

  1. The application is already registered and active in Keycloak and AMCDR with exact redirect URIs, audience, lifecycle state, and approved scopes.
  2. 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.
  3. AMCDR provisions or resolves the local identity from the trusted OIDC issuer and stable sub.
  4. 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.
  5. AMCDR creates an active patient portal identity link, patient-portal membership, enrollment/proofing state, and the patient_portal_user role constrained to that patient.
  6. 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.
  7. 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.

ConditionResult
Identity link, enrollment, application and grant remain activeResolve the patient automatically and issue a new scoped session.
Access token expiresUse an eligible rotating refresh token or perform authorization again according to policy.
Patient uses App A and App BThe same patient identity and MPI link are reused, but each application has a separate approval and grant.
Patient revokes App BApp B loses access while App A can continue under its own active grant.
Patient changes phoneAuthenticate again; register/bind the new device if device governance is enabled. No new SMART application client is created.
Delegate switches represented patientIssue 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:

Patient Identity and Session APIs

RoutePurpose
GET /patient-portal/patients/{patient_id}/accountsList identity links already associated with the MPI patient.
POST /patient-portal/patients/{patient_id}/accountsCreate a governed local portal account where local password authentication is the approved model.
POST /patient-portal/patients/{patient_id}/activation-tokensIssue a time-bounded first-time activation token.
POST /patient-portal/patients/{patient_id}/pairing-tokensIssue a controlled token for pairing an already authenticated user to an MPI patient.
POST /patient-portal/pairRedeem the pairing token and create the verified patient identity link.
GET /patient-portal/sessionReturn the active direct/proxy patient context and linked portal identity.
POST /patient-portal/smart-sessionIssue a short-lived own-record or delegated SMART session for the registered first-party portal.
POST /mobile/smart-sessionIssue 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.

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.

Checks that still apply

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.

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
Patient boundary: patient-compartment searches must contain a matching _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.

ComponentResponsibility
Application registryClient ID, exact launch/redirect URIs, client type, JWKS, requested and approved scopes, allowed facilities and lifecycle state.
Launch brokerOpaque, hashed, short-lived, single-use patient, EHR, encounter and episode context.
Grant registryUser, patient and system grants with scopes, purpose, context, expiry and revocation.
Scope enforcementIndependent checks across token, application approval and active grant; EHR context is pinned.
Audit and readinessApplication, 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

  1. A clinician selects an app from Applications → SMART app platform, or chooses SMART apps from a patient timeline.
  2. AMCDR creates a launch using POST /smart/apps/{application_id}/launches.
  3. The app receives its launch URI with iss and a one-time launch handle.
  4. The app completes OAuth authorization code with PKCE S256 against Keycloak.
  5. The authenticated app consumes the handle at POST /smart/launches/{launch}/consume with its client_id.
  6. AMCDR returns a short-lived resource token plus patient, ehrId, optional encounter/episode context and the active grant.
  7. 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
Required permissions: the token, registered application's approved scopes and active grant must all authorize the requested resource pattern and action. Wildcard scope never bypasses the launched EHR boundary.

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.

RoutePurpose
GET/POST /smart/appsList apps; super-admin registration and approval.
GET/PATCH/DELETE /smart/apps/{id}Inspect, update, suspend or retire.
POST /smart/apps/{id}/launchesCreate standalone or embedded clinical launch.
POST /smart/launches/{launch}/consumeConsume once and issue context token.
GET /smart/launchesSuper-admin launch lifecycle inspection.
POST /smart/apps/{id}/grantsCreate governed user, patient or system pre-grant.
GET /smart/grantsList own grants, or all grants for super admin.
DELETE /smart/grants/{id}Owner/admin revocation.
GET /smart/audit-eventsLifecycle evidence.
GET /smart/readinessRuntime and OIDC configuration checks.
GET /fhir/.well-known/smart-configurationFHIR-relative STU 2.1 discovery.
GET /smart/authorizeAuthorization code and PKCE validation.
POST /smart/tokenAuthorization-code or rotating refresh-token exchange.
POST /smart/first-party/bootstrapRegister the portal and mobile clients.
POST /patient-portal/smart-sessionOwn-record or delegated proxy session.
POST /mobile/smart-sessionDevice/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

  1. Apply migrations through 0097_smart_fhir_first_party and enable the runtime module.
  2. Configure exact Keycloak protocol endpoints, audience, TLS and signing keys.
  3. Register the OAuth client in Keycloak with exact redirect URIs and PKCE S256.
  4. Register the same client ID in AMCDR and approve only the minimum template/query scopes.
  5. Test standalone and patient launches, wrong-EHR denial, expiry, reuse prevention and revocation.
  6. Run GET /smart/readiness?probe_oidc=true and review lifecycle audit before activation.

Related Documentation