You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
4
4
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).
6
6
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.
10
8
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
14
10
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.
16
15
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.
21
17
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.**
23
19
24
20
## Using OAuth security features
25
21
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.
27
23
28
24
First, change the `use_oauth` flag to `true` to turn on security. Then set the `client_id`, `client_secret`, and `oauth_token` fields.
29
25
@@ -32,32 +28,31 @@ If using Keycloak and following the [REMS Admin](https://github.com/mcode/rems-a
32
28
1. Open the Keycloak admin console (http://localhost:8180/auth) and log in
33
29
2. Open the ClientFhirServer, then the `clients` tab, and click `app-token`.
34
30
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`
36
32
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
38
34
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.
|`/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:
46
38
47
-
## Version
39
+
`curl -d '{"resourceType":"Patient", "id":"example"}' -H "Content-Type: application/json" -X POST http://localhost:8080/test-ehr/r4/Patient`
48
40
49
-
Java v11 or higher is required to run this application.
41
+
## SMART on FHIR
50
42
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.
52
44
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.
54
46
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`.
56
48
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.
58
50
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.
0 commit comments