Skip to content

Commit b9ab943

Browse files
Merge pull request #220698 from EXPEkesheth/patch-26
Create smart-on-fhir.md
2 parents 0741c9e + cdea60c commit b9ab943

File tree

3 files changed

+160
-3
lines changed

3 files changed

+160
-3
lines changed
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
---
2+
title: SMART on FHIR - Azure API for FHIR
3+
description: This tutorial describes how to enable SMART on FHIR applications with the Azure API for FHIR.
4+
services: healthcare-apis
5+
ms.service: healthcare-apis
6+
ms.subservice: fhir
7+
ms.topic: tutorial
8+
ms.author: kesheth
9+
author: expekesheth
10+
ms.date: 12/06/2022
11+
---
12+
13+
# SMART on FHIR overview
14+
15+
Substitutable Medical Applications and Reusable Technologies ([SMART on FHIR](https://docs.smarthealthit.org/)) is a healthcare standard through which applications can access clinical information through a data store. It adds a security layer based on open standards including OAuth2 and OpenID Connect, to FHIR interfaces to enable integration with EHR systems. Using SMART on FHIR provides at least three important benefits:
16+
- Applications have a known method for obtaining authentication/authorization to a FHIR repository.
17+
- Users accessing a FHIR repository with SMART on FHIR are restricted to resources associated with the user, rather than having access to all data in the repository.
18+
- Users have the ability to grant applications access to a further limited set of their data by using SMART clinical scopes.
19+
20+
Below tutorials describe steps to enable SMART on FHIR applications with FHIR Service.
21+
22+
## Prerequisites
23+
24+
- An instance of the FHIR service
25+
- .NET SDK 6.0
26+
- [Enable cross-origin resource sharing (CORS)](configure-cross-origin-resource-sharing.md)
27+
- [Register public client application in Azure AD](https://learn.microsoft.com/azure/healthcare-apis/azure-api-for-fhir/register-public-azure-ad-client-app)
28+
- After registering the application, make note of the applicationId for client application.
29+
30+
## SMART on FHIR using samples (preferred approach)
31+
As a prerequisite, ensure you have access to Azure Subscription of FHIR service, to create resources and add role assignments.
32+
33+
### Step 1: Set up FHIR SMART user role
34+
Follow the steps listed under section [Manage Users: Assign Users to Role](https://learn.microsoft.com/azure/active-directory/fundamentals/active-directory-users-assign-role-azure-portal). Any user added to role - "FHIR SMART User" will be able to access the FHIR Service if their requests comply with the SMART on FHIR implementation Guide, such as request having access token, which includes a fhirUser claim and a clinical scopes claim. The access granted to the users in this role will then be limited by the resources associated to their fhirUser compartment and the restrictions in the clinical scopes.
35+
36+
### Step 2: FHIR server integration with samples
37+
[Follow the steps](https://github.com/Azure-Samples/azure-health-data-services-samples/blob/main/samples/Patient%20and%20Population%20Services%20G10/docs/deployment.md) under Azure Health Data Service Samples OSS. This will enable integration of FHIR server with other Azure Services (such as APIM, Azure functions and more).
38+
39+
This is our preferred approach, as it demonstrates to Health IT developers steps needed to comply with 21st Century Act Criterion §170.315(g)(10) Standardized API for patient and population services criterion.
40+
41+
> [!NOTE]
42+
> These samples are open-source code, and you should review the information and licensing terms on GitHub before using it. They are not part of the Azure Health Data Service and are not supported by Microsoft Support. These samples can be used to demonstrate how Azure Health Data Services and other open-source tools can be used together to demonstrate ONC (g)(10) compliance, using Azure Active Directory as the identity provider workflow.
43+
44+
45+
## SMART on FHIR proxy
46+
### Step 1: Set admin consent for your client application
47+
48+
To use SMART on FHIR, you must first authenticate and authorize the app. The first time you use SMART on FHIR, you also must get administrative consent to let the app access your FHIR resources.
49+
50+
If you don't have an ownership role in the app, contact the app owner and ask them to grant admin consent for you in the app.
51+
52+
If you do have administrative privileges, complete the following steps to grant admin consent to yourself directly. (You also can grant admin consent to yourself later when you're prompted in the app.) You can complete the same steps to add other users as owners, so they can view and edit this app registration.
53+
54+
To add yourself or another user as owner of an app:
55+
56+
1. In the Azure portal, go to Azure Active Directory.
57+
2. In the left menu, select **App Registration**.
58+
3. Search for the app registration you created, and then select it.
59+
4. In the left menu, under **Manage**, select **Owners**.
60+
5. Select **Add owners**, and then add yourself or the user you want to have admin consent.
61+
6. Select **Save**
62+
63+
### Step 2: Enable the SMART on FHIR proxy
64+
65+
SMART on FHIR requires that `Audience` has an identifier URI equal to the URI of the FHIR service. The standard configuration of the Azure API for FHIR uses an `Audience` value of `https://azurehealthcareapis.com`. However, you can also set a value matching the specific URL of your FHIR service (for example `https://MYFHIRAPI.azurehealthcareapis.com`). This is required when working with the SMART on FHIR proxy.
66+
67+
To enable the SMART on FHIR proxy in the **Authentication** settings for your Azure API for FHIR instance, select the **SMART on FHIR proxy** check box:
68+
69+
![Screenshot shows enabling the SMART on FHIR proxy.](media/tutorial-smart-on-fhir/enable-smart-on-fhir-proxy.png)
70+
71+
The SMART on FHIR proxy acts as an intermediary between the SMART on FHIR app and Azure AD. The authentication reply (the authentication code) must go to the SMART on FHIR proxy instead of the app itself. The proxy then forwards the reply to the app.
72+
73+
Because of this two-step relay of the authentication code, you need to set the reply URL (callback) for your Azure AD client application to a URL that is a combination of the reply URL for the SMART on FHIR proxy and the reply URL for the SMART on FHIR app. The combined reply URL takes this form:
74+
75+
```http
76+
https://MYFHIRAPI.azurehealthcareapis.com/AadSmartOnFhirProxy/callback/aHR0cHM6Ly9sb2NhbGhvc3Q6NTAwMS9zYW1wbGVhcHAvaW5kZXguaHRtbA
77+
```
78+
79+
In that reply, `aHR0cHM6Ly9sb2NhbGhvc3Q6NTAwMS9zYW1wbGVhcHAvaW5kZXguaHRtbA` is a URL-safe, base64-encoded version of the reply URL for the SMART on FHIR app. For the SMART on FHIR app launcher, when the app is running locally, the reply URL is `https://localhost:5001/sampleapp/index.html`.
80+
81+
You can generate the combined reply URL by using a script like this:
82+
83+
```PowerShell
84+
$replyUrl = "https://localhost:5001/sampleapp/index.html"
85+
$fhirServerUrl = "https://MYFHIRAPI.azurewebsites.net"
86+
$bytes = [System.Text.Encoding]::UTF8.GetBytes($ReplyUrl)
87+
$encodedText = [Convert]::ToBase64String($bytes)
88+
$encodedText = $encodedText.TrimEnd('=');
89+
$encodedText = $encodedText.Replace('/','_');
90+
$encodedText = $encodedText.Replace('+','-');
91+
92+
$newReplyUrl = $FhirServerUrl.TrimEnd('/') + "/AadSmartOnFhirProxy/callback/" + $encodedText
93+
```
94+
95+
Add the reply URL to the public client application that you created earlier for Azure AD:
96+
97+
![Screenshot show how reply url can be configured for the public client.](media/tutorial-smart-on-fhir/configure-reply-url.png)
98+
99+
### Step 3: Get a test patient
100+
101+
To test the Azure API for FHIR and the SMART on FHIR proxy, you'll need to have at least one patient in the database. If you've not interacted with the API yet, and you don't have data in the database, see [Access the FHIR service using Postman](./../fhir/use-postman.md) to load a patient. Make a note of the ID of a specific patient.
102+
103+
### Step 4: Download the SMART on FHIR app launcher
104+
105+
The open-source [FHIR Server for Azure repository](https://github.com/Microsoft/fhir-server) includes a simple SMART on FHIR app launcher and a sample SMART on FHIR app. In this tutorial, use this SMART on FHIR launcher locally to test the setup.
106+
107+
You can clone the GitHub repository and go to the application by using these commands:
108+
109+
```PowerShell
110+
git clone https://github.com/Microsoft/fhir-server
111+
cd fhir-server/samples/apps/SmartLauncher
112+
```
113+
114+
The application needs a few configuration settings, which you can set in `appsettings.json`:
115+
116+
```json
117+
{
118+
"FhirServerUrl": "https://MYFHIRAPI.azurehealthcareapis.com",
119+
"ClientId": "APP-ID",
120+
"DefaultSmartAppUrl": "/sampleapp/launch.html"
121+
}
122+
```
123+
124+
We recommend that you use the `dotnet user-secrets` feature:
125+
126+
```PowerShell
127+
dotnet user-secrets set FhirServerUrl https://MYFHIRAPI.azurehealthcareapis.com
128+
dotnet user-secrets set ClientId <APP-ID>
129+
```
130+
131+
Use this command to run the application:
132+
133+
```PowerShell
134+
dotnet run
135+
```
136+
137+
### Step 5: Test the SMART on FHIR proxy
138+
139+
After you start the SMART on FHIR app launcher, you can point your browser to `https://localhost:5001`, where you should see the following screen:
140+
141+
![Screenshot of SMART on FHIR app launcher.](media/tutorial-smart-on-fhir/smart-on-fhir-app-launcher.png)
142+
143+
When you enter **Patient**, **Encounter**, or **Practitioner** information, you'll notice that the **Launch context** is updated. When you're using the Azure API for FHIR, the launch context is simply a JSON document that contains information about patient, practitioner, and more. This launch context is base64 encoded and passed to the SMART on FHIR app as the `launch` query parameter. According to the SMART on FHIR specification, this variable is opaque to the SMART on FHIR app and passed on to the identity provider.
144+
145+
The SMART on FHIR proxy uses this information to populate fields in the token response. The SMART on FHIR app *can* use these fields to control which patient it requests data for and how it renders the application on the screen. The SMART on FHIR proxy supports the following fields:
146+
147+
* `patient`
148+
* `encounter`
149+
* `practitioner`
150+
* `need_patient_banner`
151+
* `smart_style_url`
152+
153+
These fields are meant to provide guidance to the app, but they don't convey any security information. A SMART on FHIR application can ignore them.
154+
155+
Notice that the SMART on FHIR app launcher updates the **Launch URL** information at the bottom of the page. Select **Launch** to start the sample app.
156+
157+
FHIR&#174; is a registered trademark of [HL7](https://hl7.org/fhir/) and is used with the permission of HL7.

articles/healthcare-apis/azure-api-for-fhir/toc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ items:
4040
- name: 4. Write web application
4141
href: tutorial-web-app-write-web-app.md
4242
- name: SMART on FHIR
43-
href: use-smart-on-fhir-proxy.md
43+
href: smart-on-fhir.md
4444
- name: Interoperability and Patient Access
4545
expanded: false
4646
items:

articles/healthcare-apis/azure-api-for-fhir/use-smart-on-fhir-proxy.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: SMART on FHIR - Azure API for FHIR
2+
title: SMART on FHIR Proxy- Azure API for FHIR
33
description: This tutorial describes how to use a proxy to enable SMART on FHIR applications with the Azure API for FHIR.
44
services: healthcare-apis
55
ms.service: healthcare-apis
@@ -10,7 +10,7 @@ author: expekesheth
1010
ms.date: 06/03/2022
1111
---
1212

13-
# SMART on FHIR overview
13+
# SMART on FHIR :Overview
1414

1515
Substitutable Medical Applications and Reusable Technologies ([SMART on FHIR](https://docs.smarthealthit.org/)) is a healthcare standard through which applications can access clinical information through a data store. It adds a security layer based on open standards including OAuth2 and OpenID Connect, to FHIR interfaces to enable integration with EHR systems. Using SMART on FHIR provides at least three important benefits:
1616
- Applications have a known method for obtaining authentication/authorization to a FHIR repository.

0 commit comments

Comments
 (0)