Adherence to the SMART on FHIR specification is required to connect to Opala’s FHIR APIs that use authorization: Opala’s Patient Access API (member-initiated, interactive launches) uses the Authorization Code flow (PKCE recommended), while Opala’s Member Attribution API (system-to-system integrations) uses SMART Backend Services (client credentials with a signed JWT). The specification provides a consistent approach to security and data requirements for health applications. SMART on FHIR defines a workflow that an application can use to securely request access to data, then receive and use that data.
You can think of SMART on FHIR as having three different attributes:
The SMART technology platform enables healthcare organizations to plug third-party medical applications into their clinical data systems. These applications can take several forms:
The following describes the sequence of events that occurs when a SMART on FHIR web-based application is started.
https://mysmartapp.example/launch?iss=https://{baseurl}&launch=wd9833
The {baseurl} is the FHIR server base endpoint. For example, an application launch against Opala’s Patient Access API might look like:
https://mysmartapp.example/launch?iss=https://opala.tech/patient-access/premera/v1/fhir-r4&launch=wd9833
The launch context includes the following parameters:To fetch the discovery document, the application appends /.well-known/smart-configuration to the base URL of the FHIR endpoint.
For example:
https://{baseurl}/.well-known/smart-configuration
Along with exposing the issuer and supported interactions, the discovery document contains two important URLs:When the SMART on FHIR Application directs the user to the authorization server, it also requests a set of OAuth2 Scopes. These scopes are defined in the SMART on FHIR specification. See SMART on FHIR Scopes and Launch Context for a complete list of scopes defined in the specification.
{
"jti": "155bf20e-5caf-415f-8078-5c896350c828",
"iat": 1615563526,
"exp": 1615563586,
"aud": "client-id",
"sub": "user123",
"iss": "https://{baseurl}",
"given_name": "GIVEN_NAME",
"family_name": "FAMILY_NAME",
"profile": "https://{baseurl}RelatedPerson/123",
"nonce": "idihrgy",
"auth_time": 1615563526,
"at_hash": "GMPkjip0n0mGmMaOs8HA3w"
}GET /Observation?subject=Patient/123
Headers:
Accept: application/fhir+json
Authorization: Bearer eyJraWQiOiJ1b.o_GAe_P5E-y4GrCl.gTYd4is8zAQ
Notice that the call contains an authorization header whose value is the string Bearer followed by the access token. For readability, the token has been shortened (real tokens are much longer).
{
"azp": "my-client-id",
"profile": "https://{baseurl}/RelatedPerson/999",
"iss": "https://{baseurl}",
"exp": 1516069149,
"iat": 1516069089,
"jti": "95d12878-dd09-4d61-9930-d4b3cf077ec2"
}
POST /oauth/token/introspect
Headers:
Accept: application/json
Content-Type: application/x-www-form-urlencoded
Authorization: Basic [client_id and client_secret]
Body:
token=eyJraWQiOiJ1b.o_GAe_P5E-y4GrCl.gTYd4is8zAQ
The server sends back the following response, including (in the scope claim) that the user has been approved for a SMART Patient read scope:{
"active": true,
"scope": "patient/*.read online_access openid profile",
"client_id": "growth_chart_smart_app",
"token_type": "Bearer",
"exp": 1516069149,
"iss": "https://{baseurl}"
}
An app can launch from within an existing EHR or Patient Portal session, known as an EHR launch, or it can launch as a standalone app.
When an app receives a launch request, it requests authorization to access a FHIR resource. It does this by causing the browser to navigate to the EHR’s authorization endpoint. Based on pre-defined rules and possibly end-user authorization, the EHR authorization server either grants the request by returning an authorization code to the app’s redirect URL or denies the request. The app then exchanges the authorization code for an access token, which the app presents to the EHR’s resource server to access requested FHIR resources.
Note: If a refresh token is returned with the access token, the app may use this to request a new access token with the same scope once the current access token expires.
Both the iss and launch parameters are required when requesting an access token. For access tokens, the iss parameter identifies the EHR’s FHIR endpoint, which the app can use to obtain additional details about the EHR, including its authorization URL; the launch parameter (an opaque identifier for this specific launch and any EHR context associated with it) passes a launch parameter back to the EHR at authorization time.