Skip to content
Merged

Dev #149

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
bc23369
Add auth number to the list of parameters used to search for ETASU in…
plarocque4 May 24, 2024
6bd9f38
run prettier
plarocque4 May 24, 2024
6530bc1
Merge pull request #145 from mcode/691-etasu-auth-number
avirgulto May 31, 2024
b613150
Fix typo
jtquach1 Jun 4, 2024
6cb68d0
Merge pull request #146 from mcode/fix-typo
jtquach1 Jun 5, 2024
6155ce2
Prefix possibly unused variable
jtquach1 Jun 6, 2024
34a1746
Light refactoring
jtquach1 Jun 6, 2024
03f43da
Rewrite patient-view and encounter-start callback to functional progr…
jtquach1 Jun 6, 2024
5fba23c
Add in refactored code from code review of encounter-start support PR
jtquach1 Jun 6, 2024
fcc1ce2
Convert giant for loop into more functional programming style code
jtquach1 Jun 6, 2024
5e1820e
Remove obsolete test
jtquach1 Jun 6, 2024
9e53c76
update the readme file
plarocque4 Jun 10, 2024
36f0312
Update README.md
plarocque4 Jun 11, 2024
30583b2
update mongodb section
plarocque4 Jun 11, 2024
40b6b1c
Merge branch 'update_readme' of github.com:mcode/rems-admin into upda…
plarocque4 Jun 11, 2024
eb604ef
Refactor types used
jtquach1 Jun 12, 2024
9057ae2
Fix linting issue
jtquach1 Jun 12, 2024
b807ff0
Update duplicated comment
jtquach1 Jun 12, 2024
fc5a88e
Get absolute links relevant to the patient
jtquach1 Jun 12, 2024
ef7cab1
Update README.md
plarocque4 Jun 13, 2024
3129a3f
Refactor function
jtquach1 Jun 13, 2024
64a4c3f
More refactoring
jtquach1 Jun 13, 2024
ff7613f
Replace variable
jtquach1 Jun 13, 2024
fd01fdd
Simplify if statement
jtquach1 Jun 13, 2024
fb5f94e
Simplify nested if statement into one one-indented if statement
jtquach1 Jun 13, 2024
6994709
More refactoring
jtquach1 Jun 13, 2024
6199b8b
Refactor card-producing logic so encounter-start/patient-view and ord…
jtquach1 Jun 14, 2024
ebea21d
Replace comments with variables
jtquach1 Jun 14, 2024
bd75f2d
Add dependency for rems-cds-hooks from origin/main and update pointed…
jtquach1 Jun 14, 2024
8202e47
Fix local linting issues
jtquach1 Jun 14, 2024
a00caa3
Merge pull request #147 from mcode/update_readme
smalho01 Jun 21, 2024
e0ba4a5
Merge branch 'dev' into update-encounter-start-and-patient-view-cards
smalho01 Jun 27, 2024
dcf8976
Merge pull request #148 from mcode/update-encounter-start-and-patient…
jtquach1 Jun 28, 2024
ecb959c
Merge branch 'main' into dev
smalho01 Jul 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 71 additions & 67 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,95 +1,99 @@
# rems-admin
# Description

## Running only the REMS server project locally
The [REMS](https://www.fda.gov/drugs/drug-safety-and-availability/risk-evaluation-and-mitigation-strategies-rems) Admin application is an app that acts as a REMS Administrator in the REMS workflow. It receives [CDS Hooks](https://cds-hooks.org/) calls of the type order-sign, order-select, patient-view and encounter-start and returns CARDS containing links to relevant information and SMART Links to launch SMART on FHIR Apps. These links launch applications for completing forms needed to register the Patient, Provider, and Pharmacy in the REMS program as well as other necessary forms. The application also contains a built-in FHIR Server. This FHIR Server contains the Questionnaires, Libraries, CQL, and all other FHIR Resources needed to launch the [REMS SMART on FHIR App](https://github.com/mcode/rems-smart-on-fhir) Questionnaires. There is also a FHIR operation used for querying the REMS ETASU status.

1. Clone the REMS repositories from GitHub:
```bash
git clone https://github.com/mcode/rems-admin.git rems-admin
```
2. Run dockerRunner.sh script
```bash
npm run start
```
# Getting Started with REMS Administrator

### How To Override Defaults
To get started, first clone the repository using a method that is most convenient for you. If using git, run the following command:

The .env file contains the default URI paths, which can be overwritten from the start command as follows:
a) `REACT_APP_LAUNCH_URL=http://example.com PORT=6000 npm start` or b) by specifying the environment variables and desired values in a `.env.local`.
`git clone https://github.com/mcode/rems-admin.git`

> **Bug**: Do note that the `SMART_ENDPOINT` environment variable cannot be overwritten in a `.env.local`, it must be done in the `.env`.
The following technologies must be installed on your computer to continue:
* [NPM](https://www.npmjs.com/)
* [Node](https://nodejs.org/en)

Following are a list of modifiable paths:
## Initialization

| URI Name | Default | Description |
| --------------- | ------------------------------------------ | ------------------------------------------------------------------------------------------------------|
| AUTH_SERVER_URI | `http://localhost:8090` | The base url of the auth server, currently set to the base url of this app. |
| HTTPS_CERT_PATH | `server.cert` | Path to a certificate for encryption, allowing HTTPS. Unnecessary if using HTTP. |
| HTTPS_KEY_PATH | `server.key` | Path to a key for encryption, allowing HTTPS. Unnecessary if using HTTP. |
| LOGGING_LEVEL | `debug` | Amount to output in the log, can be changed to verbose, info, warn, or error. |
| MONGO_DB_NAME | `remsadmin` | Name of the database table being used. Should be changed if not using the Mongo instructions below. |
| MONGO_URL | `mongodb://rems-user:pass@127.0.0.1:27017` | URL for the connection to the database, should be changed if not using the Mongo instructions below. |
| PORT | `8090` | Port that this server should run on, change if there are conflicts with port usage. |
| RESOURCE_SERVER | `http://localhost:8090` | Base URL of this server, should match with port. |
| SMART_ENDPOINT | `http://localhost:4040/launch` | Launch URL of associated SMART app, should be changed if not using the REMS Smart App. |
| USE_HTTPS | `false` | Change to true to enable HTTPS. Ensure that HTTPS_CERT_PATH and HTTPS_KEY_PATH are valid. |
| VSAC_API_KEY | `changeMe` | Replace with VSAC API key for pulling down ValueSets. Request an API Key from the [VSAC website](https://vsac.nlm.nih.gov/) |
| WHITELIST | `http://localhost, http://localhost:3005` | List of valid URLs for CORS. Should include any URLs the server accesses for resources. |
After cloning the repository, the submodules must be initialized. Run the following command:

### `git submodule update --init`

Next, install the required dependencies by running the following:

### `npm install`

## Running the Mongo DB instance

1. On the first run use the following command to create a Docker MongoDB instance:
The REMS Administrator relies on MongoDB for it's backing database.
Follow the mongodb setup instructions in the [REMS End to End Setup Guide](https://github.com/mcode/rems-setup/blob/main/EndToEndSetupGuide.md#mongodb).

```bash
docker run --name rems_local_pims_remsadmin_mongo --expose 27017 -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME='rems-admin-pims-root' -e MONGO_INITDB_ROOT_PASSWORD='rems-admin-pims-password' -v rems_local_pims_remsadmin_mongo:/data/db -v "$(pwd)"/mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js mongo
```
If you would rather run with docker, follow the setup found in the [REMS Simple Setup Guide](https://github.com/mcode/rems-setup/blob/main/SimpleSetupGuide.md) (this will also setup the other REMS applications in docker as well).

To stop the running container, simply use Ctrl + C.
## Available Scripts

2. On subsequent runs use the following command to start the existing mongo container:
```bash
docker start rems_local_pims_remsadmin_mongo
```
To stop the running container, simply run the below command
```bash
docker stop rems_local_pims_remsadmin_mongo
```
In the project directory, you can run:

# REMS Administrator
### `npm start`

NOTE: The REMS Administrator is a work in progress.
Runs the app in the development mode.\
Open [http://localhost:8090/cds-services](http://localhost:8090/cds-services) to view the CDS Services discovery information in the browser.

## Running the REMS Administrator
You will also see any lint errors in the console.

#### Initialization
### `npm test`

After cloning the repository, the submodules must be initialized. To do this you can run:
Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://create-react-app.dev/docs/running-tests/) for more information.

```
git submodule update --init
```
## Usage

#### Setup
The REMS Admin interacts with the [Request Generator](https://github.com/mcode/request-generator), [REMS SMART on FHIR app](https://github.com/mcode/rems-smart-on-fhir), and an [EHR](https://github.com/mcode/test-ehr). These apps are provided as part of the REMS ecosystem, but any individual part may be swapped out for something custom. The REMS Admin responds to CDS Hooks requests as well as FHIR operations for the questionnaire package ($questionnaire-package) and REMS ETASU check ($rems-etasu).

```
npm install
```
Typically, a CDS Hook will be sent from the EHR to the REMS Admin, which will respond with cards that contain information about next steps. These cards may contain a link to a SMART app. Clicking on these links in the Request Generator or REMS SMART on FHIR App acting as the EHR will launch the SMART app automatically. These links will contain information on the requirements that must be met for the REMS program. This includes forms for registration and acknowledgement of the risks involved.

#### Run Tests
The FHIR server built into the REMS Admin can be queried for the questionnaire package at the Questionnaire/$questionnaire-package endpoint. This will return a FHIR Bundle with the FHIR Questionnaire and all other FHIR Resources including CQL Libraries embedded within FHIR Libraries. The FHIR Server also contains a REMS ETASU check at the GuidanceResponse/$rems-etasu endpoint. This will return a FHIR Parameter containing a GuidanceResponse with the status of the ETATSU and nested GuidanceResponse for each requirement.

```
npm test
```
## Routes

#### Run Application
* `/cds-services` - The base CDS Hooks Discovery endpoint that serves a list of supported hooks/services in JSON.
* `/cds-services/rems-order-sign` - The CDS Hooks endpoint for order-sign
* `/cds-services/rems-order-select` - The CDS Hooks endpoint for order-select
* `/cds-services/rems-patient-view` - The CDS Hooks endpoint for patient-view
* `/cds-services/rems-encounter-start` - The CDS Hooks endpoint for encounter-start
* `/4_0_0 - The base of the FHIR Server
* `/4_0_0/GuidanceResponse/$rems-etasu` - The endpoint for FHIR Operation used for checking the ETASU status
* Input requires a parameter containing the following:
* `patient` - Patient FHIR Resource, must include `medication` with `patient`
* `medication` - Medication or MedicationRequest FHIR Resource, must include `patient` with `medication`
* `authNumber` - String containing the REMS Authorization Number, may be sent without `patient` or `medication`
* Returns a GuidanceResponse within a Parameter with the status
* Contains Nested GuidanceResponse resources for each ETASU requirement with their status
* `/4_0_0/Questionnaire/\<form-name\>/$questionnaire-package` - The endpoint for the FHIR Operation used for retrieving the Questionnaire package for a given form
* Example: /4_0_0/Questionnaire/TIRFRemsPatientEnrollment/$questionnaire-package
* This includes the Questionnaire and any other necessary FHIR resources needed for loading the quesetionnaire form with the REMS SMART on FHIR app

```
npm start
```
## Environment Variables

Application will be running on port 8090.
### How To Override Defaults

The .env file contains the default URI paths, which can be overwritten from the start command as follows:
a) `REACT_APP_LAUNCH_URL=http://example.com PORT=6000 npm start` or b) by specifying the environment variables and desired values in a `.env.local`.

> **Bug**: Do note that the `SMART_ENDPOINT` environment variable cannot be overwritten in a `.env.local`, it must be done in the `.env`.

To reach the CDS Services discovery information:
Following are a list of modifiable paths:

```
http://localhost:8090/cds-services
```
| URI Name | Default | Description |
| --------------- | ------------------------------------------ | ------------------------------------------------------------------------------------------------------|
| AUTH_SERVER_URI | `http://localhost:8090` | The base url of the auth server, currently set to the base url of this app. |
| HTTPS_CERT_PATH | `server.cert` | Path to a certificate for encryption, allowing HTTPS. Unnecessary if using HTTP. |
| HTTPS_KEY_PATH | `server.key` | Path to a key for encryption, allowing HTTPS. Unnecessary if using HTTP. |
| LOGGING_LEVEL | `debug` | Amount to output in the log, can be changed to verbose, info, warn, or error. |
| MONGO_DB_NAME | `remsadmin` | Name of the database table being used. Should be changed if not using the Mongo instructions above. |
| MONGO_URL | `mongodb://rems-user:pass@127.0.0.1:27017` | URL for the connection to the database, should be changed if not using the Mongo instructions above. |
| PORT | `8090` | Port that this server should run on, change if there are conflicts with port usage. |
| RESOURCE_SERVER | `http://localhost:8090` | Base URL of this server, should match with port. |
| SMART_ENDPOINT | `http://localhost:4040/launch` | Launch URL of associated SMART app, should be changed if not using the REMS Smart App. |
| USE_HTTPS | `false` | Change to true to enable HTTPS. Ensure that HTTPS_CERT_PATH and HTTPS_KEY_PATH are valid. |
| VSAC_API_KEY | `changeMe` | Replace with VSAC API key for pulling down ValueSets. Request an API Key from the [VSAC website](https://vsac.nlm.nih.gov/) |
| WHITELIST | `http://localhost, http://localhost:3005` | List of valid URLs for CORS. Should include any URLs the server accesses for resources. |
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"@types/chai": "^4.3.4",
"@types/cors": "^2.8.12",
"@types/express": "^4.17.14",
"@types/flat": "^5.0.5",
"@types/lodash": "^4.14.188",
"@types/mocha": "^10.0.1",
"@types/mongodb-memory-server": "2.3.0",
Expand Down
Loading