Skip to content

Commit cc66ebf

Browse files
authored
Merge pull request #74 from mcode/dev
Dev
2 parents 72560f9 + ca9a57f commit cc66ebf

File tree

1 file changed

+29
-34
lines changed

1 file changed

+29
-34
lines changed

README.md

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
1-
# EHR FHIR Server
1+
# REMS EHR FHIR Server
22

33
This sub-project hosts a HAPI FHIR server that is based on the now-deprecated [hapi-fhir-jpaserver-example](https://github.com/jamesagnew/hapi-fhir/tree/master/hapi-fhir-jpaserver-example). The new repo is found [here](https://github.com/hapifhir/hapi-fhir-jpaserver-starter).
44

5-
## Running the server
5+
The server this repository runs is a standard FHIR server that saves and provides FHIR resources for clients. Almost every step of the REMS workflow involves the EHR, it communicates with the [Request Generator](https://github.com/mcode/request-generator), [REMS Admin](https://github.com/mcode/rems-admin), [REMS SMART on FHIR app](https://github.com/mcode/rems-smart-on-fhir), and [Pharmacy System](https://github.com/mcode/pims).
66

7-
1. Make sure `gradle` is installed on your machine. Gradle v6.9 or higher.
8-
2. Run `gradle bootRun`
9-
3. In a separate terminal tab, run `gradle loadData` to load resources
7+
Any compliant FHIR server can replace this server in the workflow. This EHR server is provided as a convenience. All apps in the REMS workflow are programmed to function with any FHIR server, but are programmed to work with this one by default.
108

11-
This will start the server running on http://localhost:8080/test-ehr.
12-
13-
**If you've loaded resources before, and want a clean slate, delete the `target` and `build` folders from test-ehr if they exist.**
9+
## Initialization
1410

15-
## Adding resources to the database
11+
1. Install [Java](https://www.oracle.com/java/technologies/downloads/) version 11 or higher.
12+
2. Install [gradle](https://gradle.org/) version 6.9 or higher.
13+
3. Run `gradle bootRun`
14+
4. In a separate terminal tab, run `gradle loadData` to load resources.
1615

17-
The FHIR server will persist FHIR resources between restarts. You can delete the folder `target` to clear all resources.
18-
19-
To load the data from the json files in fhirResourcesToLoad, run the following script:
20-
`gradle loadData`
16+
This will start the server running on http://localhost:8080/test-ehr.
2117

22-
> Note: 'gradle loadData' can only be run while the FHIR server is running and `use_oauth` is false in `src/main/resources/fhirServer.properties`
18+
**If you've loaded resources before, and want a clean slate, delete the `target` and `build` folders from test-ehr if they exist.**
2319

2420
## Using OAuth security features
2521

26-
The FHIR server is open by default, but this can be changed in the `fhirServer.properties` file.
22+
The FHIR server is open by default, but this can be changed in the `application.yml` file.
2723

2824
First, change the `use_oauth` flag to `true` to turn on security. Then set the `client_id`, `client_secret`, and `oauth_token` fields.
2925

@@ -32,32 +28,31 @@ If using Keycloak and following the [REMS Admin](https://github.com/mcode/rems-a
3228
1. Open the Keycloak admin console (http://localhost:8180/auth) and log in
3329
2. Open the ClientFhirServer, then the `clients` tab, and click `app-token`.
3430
3. Click on the `Credentials` tab, use the `regenerate secret` option if needed.
35-
4. Copy the client secret into the properties file under `client_secret`
31+
4. Copy the client secret into the `application.yml` file under `client_secret`
3632

37-
Finally, ensure that the [request generator](https://github.com/mcode/request-generator) has the correct username and password in the `properties.json` file. If following the REMS Admin guide, this will be one of the users created when setting up Keycloak.
33+
## Usage
3834

39-
## Server endpoints
35+
The EHR mainly serves resources to clients and handles authorization requests. Generally, the other apps in the REMS workflow interact with the EHR automatically. To add resources to the EHR, place the resource files in the `fhirResourceToLoad` directory and then run `gradle loadData` while the server is currently running.
4036

41-
| Relative URL | Endpoint Description |
42-
| -------------- | ------------------------------------------------------ |
43-
| `/test-ehr/` | Base server endpoint |
44-
| `/test-ehr/r4` | EHR FHIR Server endpoint (will not resolve in browser) |
45-
| `/test-ehr/script/rxfill` | NCPDP SCRIPT endpoint that RxFill messages from the pharmacy can be sent to (will not resolve in browser) |
37+
A new resource can also be created manually by making a POST to a resource endpoint, for example:
4638

47-
## Version
39+
`curl -d '{"resourceType":"Patient", "id":"example"}' -H "Content-Type: application/json" -X POST http://localhost:8080/test-ehr/r4/Patient`
4840

49-
Java v11 or higher is required to run this application.
41+
## SMART on FHIR
5042

51-
## Run configurations
43+
The EHR server SMART on FHIR compliant. This means that SMART apps like the [Request Generator](https://github.com/mcode/request-generator) and [REMS SMART on FHIR app](https://github.com/mcode/rems-smart-on-fhir) can authenticate automatically against the FHIR server.
5244

53-
Run configurations to run, clean, and load data for the FHIR server can be used for the IntelliJ IDEA CE IDE. You can set breakpoints on the `Boot Run` configuration.
45+
All authorization requests are proxied to an authorization server. Any OAuth2.0 compliant authorization server can be connected to the EHR by changing the `auth_base` property in the `application.yml` file.
5446

55-
These were last used with IntelliJ IDEA 2021.2.2 (Community Edition) and Microsoft Edge DevTools.
47+
This server provides a `/_services/smart/Launch` endpoint for session creation. A client POSTs a payload consisting of a `launchUrl`, `redirectUri`, and `parameters`, and receives a `launchId`.
5648

57-
### Steps:
49+
The `launchId` is a unique ID which lets the SMART app maintain its state through the authorization process. This is not a standard process. Apps like the [Request Generator](https://github.com/mcode/request-generator), which are within the EHR ecosystem but not directly connected, might make use of this endpoint to create SMART sessions and launch SMART apps.
5850

59-
1. Select "Boot Run" as a Run Configuration from the dropdown menu.
60-
2. Put a breakpoint (red dot) on the desired line, e.g. line 43 of `test-ehr/src/main/java/org/hl7/davinci/ehrserver/interceptor/QuestionnaireResponseSearchParameterInterceptor.java`.
61-
3. Click the debug icon (green bug) up top.
62-
4. Go to http://localhost:3000 (where a locally run request-generator is served at) and try to select a patient. You may have to wait for bootRun to finish starting up if you see a "Network Request Failed Error". request-generator will ask test-ehr for QuestionnaireResponse resources (to get the list of in-progress forms).
63-
5. request-generator will pause as the breakpoint at line 43 gets hit. Hit F12 to open up DevTools on http://localhost:3000. You will see the QuestionnaireResponse (and other FHIR resources) have yet to be received.
51+
## Server endpoints
52+
53+
| Relative URL | Endpoint Description |
54+
| -------------- | ------------------------------------------------------ |
55+
| `/test-ehr/` | Base server endpoint |
56+
| `/test-ehr/r4` | EHR FHIR Server endpoint (will not resolve in browser) |
57+
| `/test-ehr/script/rxfill` | NCPDP SCRIPT endpoint that RxFill messages from the pharmacy can be sent to (will not resolve in browser) |
58+
| `/_services/smart/Launch` | SMART on FHIR endpoint which produces a launch ID for SMART apps to use when launching |

0 commit comments

Comments
 (0)