SMART

Introduction

Components for authenticating against the Commure Platform using the OpenID Connect and SMART App Launch protocols.

The SMARTClient class implements the client side of the SMART protocol. It handles the work of interfacing with the Commure Authentication API for you. To initialize SMARTClient, pass it an object with the following keys.

keytypedescription
clientIdstringThe client ID provided by Commure. For testing with the developer sandbox, you can use smart_hello_world.
scopesstring[]The set of scopes to request. Typically apps will require the openid, profile, email, and fhirUser scopes.
redirectUristringThe redirect URL configured with Commure. For smart_hello_world this is http://localhost:1234/callback.
standaloneLaunchstringWhether the app should be launched as standalone; valid values are always, ifNecessary, and never. An app launched as standalone doesn't receive launch context during the SMART flow.
fhirBaseUrlstring(optional) The FHIR server used if we aren't given this information by EHR's launch context doesn't provide it to us. Required in order to use standalone launch. For the sandbox this is https://api-<tenant>.developer.commure.com/api/v1/r4.

The CommureSmartApp React component integrates with SMARTClient to seamlessly authenticate users before the app starts running. Developers often don't need to use SMARTClient directly beyond initializing and passing it to CommureSmartApp. Simply wrap your app with CommureSmartApp and the component will ensure the user is authenticated. You can then use the

Read
and
Write
components to interface with the FHIR API.

Usage

CommureSmartApp

import React from "react";
import { CommureSmartApp } from "@commure/components-data";
import SMARTClient, { StandalonePreference } from "@commure/smart-core";
const smartClient = new SMARTClient({
clientId: "smart_hello_world", // this client_id will work with your Commure tenant
scopes: ["openid", "profile", "fhirUser"],
redirectUri: "http://localhost:1234/callback", // the app's callback url
standaloneLaunch: StandalonePreference.IfNecessary,
fhirBaseUrl: "https://api-TENANT_ID.developer.commure.com/api/v1/r4"
});
export default () => (
<CommureSmartApp client={smartClient}>
<div>Hello World!</div>
</CommureSmartApp>
);

API Reference

CommureSmartApp

Prop NameRequired?TypeDescription
childrentrueReact.ReactNodeChild components to be rendered.
clienttrueSMARTClientSMARTClient instance for the application.

Related Reading

Quick Start Guide
Build a New Application