Real Time FHIR is a simulation architecture that transmits Electronic Health Record data from a data source to a FHIR endpoint in real-time.
This project uses a React-based dashboard for simulation control and a Python Flask-based backend for simulation processing. Currently, only NDJSON FHIR resource files are supported.
- Ensure that you have NodeJS installed (Preferably NodeJS 17.x).
If not, check out this guide to install NodeJS on your machine: How to install Node.js.
If you're on Ubuntu, here are some command to install NodeJS 17.x:
curl -fsSL https://deb.nodesource.com/setup_17.x | sudo -E bash -
sudo apt-get install -y nodejs
- Ensure that you have either Yarn or NPM installed.
If you don't have either, here are some commands to install the latest version of Yarn on Ubuntu:
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/sh
echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | s
sudo apt-get update && sudo apt-get install yarn
-
Clone this repo and
cd
into its root folder. -
Run the command
yarn install
ornpm install
to download node dependencies, depending on which package manager you have installed. -
cd
into the /api folder to set up a Python virtual environment and install Python dependencies. Before following the commands below, ensure you have Python3 and pip installed!cd
back to the root folder after installation.
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
cd ..
-
Refer to the section below to configure environment variables before starting the app. The easiest way to do this is to create a
.env
file in the root folder. -
To start the app, run
./run-api.sh
and./run.sh
in two different terminals.
Before usage, there are a few environment variables that requires configuration. Some are required to be configured while some are optional:
Required
ENDPOINT_URL
- URL of simulation destination endpoint.
REACT_APP_BACKEND_PORT
- Port in which the Flask-based backend runs on. This value must be the same as FLASK_RUN_PORT in Flask environment variables.
Optional
PORT
- Port of which React runs on. If not specified, React will run on port 3000 by default.
TOKEN_URL
- URL of token endpoint to request client credentials access token. Do not specify if endpoint does not require authentication.
CLIENT_ID
- Client ID of endpoint.
CLIENT_SECRET
- Client Secret of endpoint.
SCOPE
- Scope of access token.
Required
FLASK_APP
- Main script for Flask app to be run on. By default, set value to api.py.
FLASK_RUN_PORT
- Port of which Flask runs on. This value must be the same as REACT_APP_BACKEND_PORT in General environment variables.
There are three components in the simulation interface:
- Input fields allows specification of resource type and duration as parameters of the simulation. By default, resource type and duration will be set to DiagnosticReport and 60 seconds respectively.
- Simulation attributes displays both static and actively-changing simulation details such as timeline duration, time elapsed, events sent, upcoming events etc.
- Event table displays events that has been successfully received by the endpoint.
Simulation steps:
- Ensure that connection to the set endpoint is successful by viewing the pop-up notification on the bottom left whenever you refresh the page.
- Before starting the simulation, set the resource type and duration input fields to your desired values.
- Click on the "Start Simulation" button to start the simulation.
- To stop the simulation midway, click on the "Stop Simulation" button. Otherwise, the simulation will stop once all events are sent to the endpoint.
- To start a new simulation, click on the "Reset Simulation" button to reset all values.
To fetch a resource, specify the resource type and additional parameters (optional) in the input fields, then click on the "Fetch Resource" button. Resource entries will be displayed in the resource table below.
- Remove all the files in
api/input
before adding your own files. - Add your NDJSON FHIR resource files (and JSON files for FHIR references, if there are any) to
api/input
. - If necessary, add additional resources types to
src/components/assets/resources-synthea.json
if they are not present already.
Note: In a simulation, Real Time FHIR will bundle a resource together with all its references. In the case where a reference cannot be found, an error will occur and the simulation will fail.
Real-Time FHIR is copyright © 2022, Commonwealth Scientific and Industrial Research Organisation (CSIRO) ABN 41 687 119 230. Licensed under the CSIRO Open Source Software Licence Agreement.