CONTROLLED DATA
Leidos Proprietary - US Citizens ONLY
The information contained herein is proprietary to Leidos, Inc. It may not be used, reproduced, disclosed, or exported without the written approval of Leidos.
This guide shows the steps required to make a basic SMART on FHIR application that uses Terra UI with internationalization that can connect to the Cerner sandbox. The steps start from nothing and do not use anything existing code from source control. Links provide additional information on the step but are not required reading.
Step-by-step guide
Prerequisites
Node.js
Node is required for Node Package Manager (npm) and Node package runner (npx). Node.js is available through CIO Central.
Visual Studio Code
Any IDE can be used but Visual Studio Code is recommended. Code is not available on CIO Central. It technically requires approval but it will install on a Leidos laptop without admin rights.
Step-by-step guide
Register account with Cerner Code
- https://code.cerner.com/developer/smart-on-fhir/apps
- Select "Create an account"
- Fill in information
- The process is automated but it may take a few minutes before the account is fully ready.
Create base React application
- Open a terminal window
Navigate to the desired folder for the project
> npx create-react-app myapp
> cd myapp
Install React Router
The FHIR launch sequence requires a launch page and a main entry point for the application. React Router provides an easy way to have two entry points.
https://www.npmjs.com/package/react-router-dom
https://codesandbox.io/s/fhir-client-react-react-router-context-0q3n8
- > npm i react-router-dom
Install FHIR client
https://www.npmjs.com/package/fhirclient
http://docs.smarthealthit.org/client-js/
https://engineering.cerner.com/smart-on-fhir-tutorial/
- > npm i fhirclient
Install Terra UI base components
Two base level components are required in any Terra UI project.
https://engineering.cerner.com/terra-ui/getting-started/terra-ui/what-is-terra
- > npm i terra-base terra-aggregate-translations
Install terra-base peer dependencies
React Intl is required by Terra UI components to do internationalization.
https://www.npmjs.com/package/react-intl
- > npm i react-intl@^2.8.0
- > npm i node-sass
Install Terra UI components
Install the components which will actually make up the UI. A full list of components with examples can be found in the link below. For this example we will only add terra-demographics-banner.
https://engineering.cerner.com/terra-ui/components
- > npm i terra-demographics-banner
Enable local environment variables
Every developer will likely have a different clientId. This sets up a framework for holding local development variables.
- Add file ./.env. This is defaults for all variables and will be in source control.
- Add file ./.env.local. This is local overrides and it is listed in .gitignore by default.
Enter the following text in both files.
Add aggregate-translations script to start scripts
This adds a step to the start where translations are built. In this example I only have English, German, and Spanish.
WARNING: The -o parameter is a hack. See "Resolving Translations and Loaders" in the link below. We need to have access to the webpack config but it is hidden by CRA. Could eject or find a different solution.
https://github.com/cerner/terra-aggregate-translations/blob/master/README.md
- Open package.json
- Add the prestart and aggregate-translations line from the example below
Edit index.html
Terra internationalization requirement.
- Edit ./public/index.html
- Change html tag from <html lang="en"> to <html dir="ltr" lang="en">
Create index.js
index.js is the entry point into the application. It is only doing routing.
- Delete all files under ./src but leave the directory
- Add file ./src/index.js
- Copy the contents below
Create Launcher.js
- Create folder ./src/Components
- Create file ./src/Components/Launcher.js
- Paste in contents below
Create App.js
- Create file ./src/Components/App.js
- Paste in the contents below
Create Translations
- Create folder ./translations
- Create files en.json, de.json, and es.json
- Paste in the contents below
en.json
{
"MyApp.hello": "Hello World"
}
Register the app with Cerner
- Go to https://code.cerner.com/developer/smart-on-fhir/apps
- Select New App
- Enter
- App Name: (any name)
- SMART Launch URI: http://localhost:3000/
- Redirect URI: http://localhost:3000/app
- App Type: Provider
- FHIR Spec: r4
- Authorized: Yes
- Standard Scopes: all
- User Scopes: none
- Patient Scopes: Patient.read
- Select Register
- Note the client ID
Update clientID env variable
- ./.env.local
- Replace "clientId not entered" with the value you got from Cerner registration
Test the app
- Bring up the terminal
- > npm start
- Wait for the app to build
- Go back to Cerner Code and select your app
- Hit Begin Testing and follow prompts