Set up SMART on FHIR in Aidbox
This guide shows how to get set up SMART on FHIR in Aidbox
Last updated
Was this helpful?
This guide shows how to get set up SMART on FHIR in Aidbox
Last updated
Was this helpful?
SMART on FHIR specifies authentication/authorization scheme for FHIR Applications. This scheme extends OAuth 2.0 and OpenID. To enable you need to create an and configure SMART API routes using the .
Clone the repo:
In the aidbox-project-samples/smart-on-fhir/core.edn
file you can see example of the API constructor configuration.
Currently only two middlewares for SMART on FHIR authorization are implemented:
:smart.fhir/single-patient-auth-middleware
— Patient launch
:smart.fhir/authorization-middleware
— Provider launch
To use SMART on FHIR you need to create a few resources like Client and AccessPolicies
Let's create an :
The launch_uri
parameter here specifies the launch URI for the EHR-based SMART App launch.
user
: id of the User
resource
iss
: Aidbox base URL
client
: id of the Client
resource
ctx
: additional launch contextо
patient
: id of Patient
resource
encounter
: id of Encounter
resource
Authorization code flow with SMART on FHIR Standalone Launch:
App requests SMART configuration from base-url/.well-known/smart-configuration
App requests FHIR conformance statement from base-url/metadata
App redirects to the EHR Authorization endpoint providing extra parameters:
scope
: OAuth scopes including scopes defined by SMART on FHIR
aud
: FHIR Server base url
Authorization server checks asks user to grant access to resources requested by the App and redirects to the App with code
App exchanges code for token using the token endpoint
App uses the token for resource access
Authorization code flow with SMART on FHIR EHR Launch:
App requests SMART configuration from base-url/.well-known/smart-configuration
App requests FHIR conformance statement from base-url/metadata
App redirects to the EHR Authorization endpoint providing extra parameters:
scope
: OAuth scopes including scopes defined by SMART on FHIR
aud
: FHIR Server base url
Authorization server checks asks user to grant access to resources requested by the App and redirects to the App with code
App exchanges code
for token
using the token
endpoint
App uses the token
for resource access
You likely want to add some to allow users see their data. Here we provide some examples for reference:
To generate SMART App launch URI use method aidbox.smart/get-launch-uri
. The method accepts the following arguments:
fhirContext
: array of objects referring to any resource type other than Patient
or Encounter
(see )
EHR redirects to the App Launch URI (which is )
More details can be found
The SMART on FHIR sample in the is ready to pass the Inferno ONC Program and most of the Inferno Community SMART on FHIR tests. Follow the README in the Aidbox Project Samples repository to set up Aidbox for running these tests.