Skip to content

Commit

Permalink
Merge pull request #131 from mcode/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
smalho01 authored Jul 1, 2024
2 parents b086b5b + 1b268ba commit f341795
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 48 deletions.
2 changes: 0 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ VITE_CLIENT = app-login
VITE_CLIENT_SCOPES = launch offline_access openid profile user/Patient.read patient/Patient.read user/Practitioner.read
VITE_DEFAULT_USER = pra1234
VITE_EHR_BASE = http://localhost:8080/test-ehr/r4
VITE_EHR_LINK = http://localhost:8080/ehr-server/
VITE_EHR_SERVER = http://localhost:8080/test-ehr/r4
VITE_EHR_SERVER_TO_BE_SENT_TO_REMS_ADMIN_FOR_PREFETCH = http://localhost:8080/test-ehr/r4
VITE_GENERATE_JWT = true
VITE_GH_PAGES=false
VITE_HOMEPAGE = http://localhost:8080
VITE_LAUNCH_URL = http://localhost:4040/launch
VITE_PASSWORD = alice
VITE_PATIENT_FHIR_QUERY = Patient?_sort=identifier&_count=12
Expand Down
111 changes: 67 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Request Generator

This project provides a small web application that is capable of generating requests and displaying the CDS Hooks cards that are provided as a response. This project is written in JavaScript and runs in [node.js](https://nodejs.org/en/).
This project provides a testing tool for the REMS workflow that is capable of generating CDS Hooks requests and displaying the CDS Hooks cards that are provided as a response. The Request Generator also handles various other tasks like patient selection, sending medication requests to the pharmacy system, managing in-progress Questionnaire forms, and launching SMART apps. Typically, capabilities provided by the Request Generator would be handled by an EHR in a production environment.

## Running the request generator standalone
This project is written in JavaScript with React and runs in [node.js](https://nodejs.org/en/).

## Initialization

1. Install node.js v14 (using [`nvm`](https://github.com/nvm-sh/nvm) is optional, but easier)

Expand Down Expand Up @@ -35,52 +37,13 @@ Run the following commands

Embedded in the application are the public and private keys used to generate and verify JSON Web Tokens (JWT) that are used to authenticate/authorize calls to a CDS-Hooks service. The public key is contained in the public/.well-known/jwks.json document. The private key is contained in src/keys/crdPrivateKey.js file. The keys were generated from https://mkjwk.org/. To update these keys you can generate a new key pair from this site, ensure that you request the Show X.509 option is set to yes. Once generated you can replace the public and private keys. You will also need to update the src/utils/auth.js file with the corresponding key information.

### How To Override Defaults

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

Following are a list of modifiable paths:
## Usage

| URI Name | Default |
| ---------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| HTTPS | `false` |
| HTTPS_CERT_PATH | `server.cert` |
| HTTPS_KEY_PATH | `server.key` |
| VITE_ALT_DRUG | `true` |
| VITE_AUTH | `http://localhost:8180` |
| VITE_CDS_SERVICE | `http://localhost:8090/cds-services` |
| VITE_CLIENT | `app-login` |
| VITE_CLIENT_SCOPES | `launch offline_access openid profile user/Patient.read patient/Patient.read user/Practitioner.read` |
| VITE_DEFAULT_USER | `pra1234` |
| VITE_EHR_BASE | `http://localhost:8080/test-ehr/r4` |
| VITE_EHR_LINK | `http://localhost:8080/ehr-server/` |
| VITE_EHR_SERVER | `http://localhost:8080/test-ehr/r4` |
| VITE_EHR_SERVER_TO_BE_SENT_TO_REMS_ADMIN_FOR_PREFETCH | `http://localhost:8080/test-ehr/r4` |
| VITE_GENERATE_JWT | `true` |
| VITE_GH_PAGES | `false` |
| VITE_HOMEPAGE | `http://localhost:8080` |
| VITE_LAUNCH_URL | `http://localhost:4040/launch` |
| VITE_ORDER_SELECT | `rems-order-select` |
| VITE_ORDER_SIGN | `rems-order-sign` |
| VITE_PASSWORD | `alice` |
| VITE_PATIENT_FHIR_QUERY | `Patient?_sort=identifier&_count=12` |
| VITE_PATIENT_VIEW | `rems-patient-view` |
| VITE_PIMS_SERVER | `http://localhost:5051/doctorOrders/api/addRx` |
| VITE_PUBLIC_KEYS | `http://localhost:3000/request-generator/.well-known/jwks.json` |
| VITE_REALM | `ClientFhirServer` |
| VITE_RESPONSE_EXPIRATION_DAYS | `30` |
| VITE_SERVER | `http://localhost:8090` |
| VITE_SMART_LAUNCH_URL | `http://localhost:4040/` |
| VITE_URL | `http://localhost:3000` |
| VITE_URL_FILTER | `http://localhost:3000/*` |
| VITE_USER | `alice` |

## How to launch as a SMART on FHIR app
To use the app, first you must launch it. The Request Generator is a SMART on FHIR App, so it can either be launched standalone, by visiting the base url (http://localhost:3000), or EHR launched, which requires the app to be launched from an actual EHR system or a SMART App Launcher that mimics an EHR system.

### Using a SMART App Launcher

1. Go to a SMART app launcher, such as `http://moonshot-dev.mitre.org:4001/index.html` (MITRE) or `https://launch.smarthealthit.org/` (open to public).
1. Go to a SMART app launcher, such as `https://launch.smarthealthit.org/`.
2. For the App Launch URL, provide `http://localhost:3000/launch`.

### Using Meld or a real EHR
Expand All @@ -96,6 +59,32 @@ Following are a list of modifiable paths:

4. After registering request-generator, hover over it and click Launch.

### Workflow

The Request Generator's main purpose is to provide the capability to send CDS hooks to and receive/display cards from a CDS service like the [REMS Admin](https://github.com/mcode/rems-admin). After launching the app, the main workflow consists of selecting a patient and then selecting a medication for that patient. The selected medication can be sent to the [pharmacy system](https://github.com/mcode/pims) to kick off the REMS workflow, though it is not necessary if you just want to explore.

The next step is to submit the patient and medication information to the REMS Admin. The REMS admin will respond with a set of cards indicating whether the selected medication has a REMS program, with links to fill out necessary forms if it does have one. The workflow then continues from the request generator to the [REMS SMART on FHIR app](https://github.com/mcode/rems-smart-on-fhir), which handles filling out forms and fulfilling requirements.

The Request Generator also manages tasks, which can be used to defer forms to be completed later, or to assign forms to specific parties. Tasks can be handled in the `tasks` tab and can be created from cards that are returned from the REMS Admin. Some cards will have a suggestion to create a task for completing a form, and clicking on the suggestion button will automatically create a task resource.

For patients, the Reqest Generator has a patient portal which allows users to view their in progress medications, tasks that are assigned to them, and information about their prescriptions. The patient portal is mainly used to allow patients to fill out required forms by launching them from a task or in-progress form into the REMS SMART on FHIR app.

Information about the status of the prescription and the status of the REMS approval can be viewed directly in the Request Generator. Panels with the status information can be viewed in both the main app and the patient portal.


## Routes

The request generator has three distinct routes.

* `/` - The base route opens the main app page. This is where a user can select a patient and send a CDS Hook, or launch a SMART app.

* `/patient-portal` - The patient portal allows patients to log into the EHR and see information about their pending medications or launch a SMART app from a task to complete a pending form.

* `/register` - The registration page allows users to add client ids and their associated FHIR server url to allow for connecting to different EHRs automatically. This is useful for launching the request generator directly from an EHR or from a SMART sandbox, as opposed to visiting the base route directly.

## How to launch as a SMART on FHIR app


<!-- TODO: update step 4 once Zach does client registration ticket. This is the error when launching:
```
Expand All @@ -110,3 +99,37 @@ Client with id app-login was not found
## How to launch a SMART on FHIR app from request-generator

See the [following guide](./How-To-Launch-SMART-on-FHIR-Apps.md) for more information.


### Environment Variables

The .env file contains the default URI paths, which can be overwritten from the start command in one of the following ways:
* By starting the app with the following comamand: `VITE_LAUNCH_URL=http://example.com PORT=6000 npm start`
* By specifying the environment variables and desired values in a `.env.local` file.

Following are a list of modifiable paths:

| URI Name | Default | Description |
| ---------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |-----------------------
| VITE_ALT_DRUG | `true` | When set to true, allows the app to recieve alternate drug therapy cards from the REMS Admin. |
| VITE_AUTH | `http://localhost:8180` | The base URL of the EHR auth server. |
| VITE_CDS_SERVICE | `http://localhost:8090/cds-services` | The base URL of the CDS Service. This will typically be the REMS Admin. |
| VITE_CLIENT | `app-login` | The default client to use for the SMART launch. Can be modified directly when launching the app. |
| VITE_CLIENT_SCOPES | `launch offline_access openid profile user/Patient.read patient/Patient.read user/Practitioner.read` | The default scopes to use for the SMART launch. Can be modified directly when launching the app. |
| VITE_DEFAULT_USER | `pra1234` | The default user to log in as when SMART launching. It should be the FHIR id of a practitioner resource. |
| VITE_EHR_BASE | `http://localhost:8080/test-ehr/r4` | The default base url for the EHR. Can be modified directly when launching the app. |
| VITE_EHR_SERVER | `http://localhost:8080/test-ehr/r4` | The default base url for the EHR FHIR Server. Generally, this should be the same as the EHR_BASE. |
| VITE_EHR_SERVER_TO_BE_SENT_TO_REMS_ADMIN_FOR_PREFETCH | `http://localhost:8080/test-ehr/r4` | The default base URL for the EHR FHIR server to be sent in the CDS Hook. This environment generally should match EHR_SERVER, except in edge cases when dealing with deployment. |
| VITE_GENERATE_JWT | `true` | When true, the app will generate a JWT for authentication when sending the CDS Hook. Can be set to false if using a REMS Admin CDS Service that is not secured. |
| VITE_GH_PAGES | `false` | Should be set to `true` if the app is being hosted on github pages, and `false` otherwise. |
| VITE_LAUNCH_URL | `http://localhost:4040/launch` | The launch URL of the SMART app the request generator should use for standalone launches. Note that this URL is only used outside of the context of the CDS Hooks workflow. Normally, the SMART app launch URL will come from a link inside a card that is returned by the REMS Admin. |
| VITE_PASSWORD | `alice` | The default password for logging in as the default user, defined by VITE_USER. This should be changed if using a different default user. |
| VITE_PATIENT_FHIR_QUERY | `Patient?_sort=identifier&_count=12` | The FHIR query the app makes when searching for patients in the EHR. This should be modified if a different behavior is desired by the apps patient selection popup. This can also be modified directly in the app's settings. |
| VITE_PIMS_SERVER | `http://localhost:5051/doctorOrders/api/addRx` | The Pharmacy System endpoint for submitting medications. This should be changed depending on which pharmacy system you want to connect with. |
| VITE_PUBLIC_KEYS | `http://localhost:3000/request-generator/.well-known/jwks.json` | The endpoint which contains the public keys for authentication with the REMS admin. Should be changed if the keys are moved elsewhere. |
| VITE_REALM | `ClientFhirServer` | The Keycloak realm to use. Only relevant is using Keycloak as an authentication server. This only affects direct logins like through the Patient Portal, not SMART launches like opening the app normally. |
| VITE_RESPONSE_EXPIRATION_DAYS | `30` | The number of days old a Questionnaire Response can be before it is ignored and filtered out. This ensures the patient search excludes outdated or obsolete prior sessions from creating clutter. |
| VITE_SERVER | `http://localhost:8090` | The default base URL of the CDS service. Typically this will be the base url of the REMS Admin. |
| VITE_SMART_LAUNCH_URL | `http://localhost:4040/` | The base url of the SMART app. This is used for opening the app directly, rather than doing an EHR SMART launch. |
| VITE_URL | `http://localhost:3000` | The base url of this app. Should be modified if the port or domain change. |
| VITE_USER | `alice` | The default user to login as when opening the app. |
3 changes: 1 addition & 2 deletions src/components/DisplayBox/DisplayBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ const DisplayBox = props => {
const element = document.getElementById(buttonId);
element.setAttribute('disabled', 'true');
element.setAttribute('style', 'background-color:#4BB543;');
element.setAttribute('style');
}

if (suggestion.label) {
Expand Down Expand Up @@ -300,7 +299,7 @@ const DisplayBox = props => {
width: '100%',
marginBottom: '5px'
}}
ÍclassName="myButton"
className="myButton"
onClick={e => launchLink(e, link)}
endIcon={<ArrowForwardRoundedIcon />}
>
Expand Down

0 comments on commit f341795

Please sign in to comment.