hemepositive / SMART-ExpressJS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SMART-ExpressJS

Boilerplate code which can be modified to create an ExpressJS SMART on FHIR app.

Adapted from this tutorial by Cerner.
Architecture uses Express.
Templating done via EJS.
Front-end display uses Bootstrap's Dashboard example (v4.0).

1. Install Docker

This example uses Docker, the links below can help you get Docker installed.

2. Create a SMART on FHIR sandbox

This app was developed using an HSPC Logica Sandbox as the launch environment.
Create an account and then create a new sandbox making sure that you use FHIR version R4, allow an open FHIR endpoint, and import sample patients, practitioners, and applications.

newsandbox

Register this app with your sandbox

Select the "Apps" option on the sidebar and press the button to add an app.

apps

Select the option to "Manually" create the app

manually

On the details page, give the app a name and ensure that the "Public Client" option is selected. Enter the following parameters as shown below:

App Launch URI: http://localhost:8080/smart-launch
App Redirect URI: http://localhost:8080/
Scopes: launch patient/*.*

IMPORTANT - if you are a Windows user and installed Docker Toolbox, your app won't be deployed on localhost but on a default IP address. The standard IP used by Docker Toolbox is 192.168.99.100 but yours could be different. Check the top of the terminal window (by the whale) for your Docker machine IP. Use the same URIs as above but replace "localhost" with your IP.

params

After saving, you will be given a client ID.

clientid

Copy this ID and open the file index.js.

At the top of this file you will see:
let client = "REPLACE-WITH-CLIENT-ID-FROM-SANDBOX"
Paste the ID there so that it looks something like this (but with your ID):
let client = "420c747a-e456-4487-808e-5de56c1be831"
Save the file

3. Start the app server

Open the terminal app (Mac) or the Docker terminal (Windows), go to the home directory of this project.

Launch the server with the command docker-compose -p projectName up --build &

  • View server output: docker logs projectName_app_1
  • Stop server: docker stop projectName_app_1
  • Start server again: docker start projectName_app_1
  • To wipe a previous build if you want to start over:
    • docker stop projectName_app_1
    • docker rm projectName_app_1
    • docker rmi projectName_app
    • docker volume prune

4. Perform a SMART launch

From the sandbox, launch your app and select a patient. The type of SMART launch we defined when registering our app depends on a patient (learn more about scopes here). You'll see that the app redirects to the HSPC authorization server where you are prompted to authorize the app. Once authorized, you are taken to the app where this example demonstrates how to use the auth token to query the Patient resource and how to parse out the patient name, gender, and age.

dashboard

About


Languages

Language:HTML 56.0%Language:CSS 22.6%Language:JavaScript 20.6%Language:Dockerfile 0.8%