Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added docker image, updated readme and dependencies #16

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
99b900f
Add renovate.json
renovate-bot Mar 1, 2021
ad1291b
Merge pull request #1 from joundso/renovate/configure
joundso Mar 1, 2021
49c9df6
Pin dependencies (#2)
renovate[bot] Mar 1, 2021
e001104
Update dependency http-server to ^0.12.0 (#3)
renovate[bot] Mar 1, 2021
31f8ce7
Update dependency @types/node to v14.14.31 (#4)
renovate[bot] Mar 1, 2021
15096f3
Update dependency selenium-download to v2.0.15 (#5)
renovate[bot] Mar 1, 2021
efd21c9
Update dependency style-loader to ^0.23.0 (#6)
renovate[bot] Mar 1, 2021
3b96698
Update babel monorepo (#7)
renovate[bot] Mar 1, 2021
25bc502
Update dependency autoprefixer to v10 (#8)
renovate[bot] Mar 1, 2021
070d143
Update dependency commander to v7 (#9)
renovate[bot] Mar 1, 2021
c291e13
Update renovate.json
joundso Mar 2, 2021
afd3629
Update all dependencies (#22)
renovate[bot] Mar 16, 2021
eade76c
Update all dependencies (#23)
renovate[bot] Jun 14, 2021
c01dbd0
feat: added docker image and readme information
joundso Jul 5, 2021
9b849a1
chore: added image version to nginx
joundso Jul 5, 2021
0547369
chore: changed name of service to patient-browser
joundso Jul 5, 2021
c46e3e1
feat: added fhir server and demo files
joundso Jul 5, 2021
8dafff4
chore: changed docker image
joundso Jul 5, 2021
bc07b32
chore: added info about fhir server to readme
joundso Jul 5, 2021
412f1ad
chore: increased curl timeout to 10 minutes
joundso Jul 5, 2021
bd77b57
feat: :fire: added fhir server and demo files to docker compose and r…
joundso Jul 6, 2021
a54e547
chore: switched ports
joundso Jul 6, 2021
df39ddd
chore: changed ports, formatted sh files
joundso Jul 6, 2021
083822e
chore: dc update
joundso Jul 20, 2021
d7344f8
docs: added links to other forks
joundso Jul 20, 2021
aeda650
chore: added script to post local ressources
joundso Jul 30, 2021
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 2.1
orbs:
node: circleci/node@1.1.6
node: circleci/node@4.2.1
jobs:
build:
executor:
Expand Down
10 changes: 10 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
VERSION_TAG=0.0.1.9005
IMAGE_NAME=patient-browser
REGISTRY_PREFIX=ukerdiz

## Port(s) for the HAPI FHIR server:
PORT_HAPI_HTTP=8080

## Ports for the patient browser:
PORT_PB_HTTP=8090
PORT_PB_HTTPS=8091
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM nginx:alpine
FROM nginx:1.21.0-alpine
COPY ./build /usr/share/nginx/html
CMD ["sh", "-c", "nginx -g 'daemon off;'"]
80 changes: 59 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,36 @@
# patient-browser

App to browse sample patients
[DEMO](https://patient-browser.smarthealthit.org/index.html)

## Quick installation

1. Clone this repository:

```sh
git clone https://github.com/joundso/patient-browser.git patient-browser
```

2. Run [`start.sh`](./start.sh):

```sh
sudo bash ./start.sh
```

3. Go to
- [`localhost:8090`](http://localhost:8090) (or whatever port you specified for `PORT_HTTP` in the [`.env`](./.env) file) to access the **patient browser** with demo datafrom external, or
- [`localhost:8090/?config=demo#/`](http://localhost:8090/?config=demo#/) to see the demo data which is available in the running hapi fhir server in the patient browser. :bulb: The loading of the demo fhir ressources into the fhir server takes a while. Try refreshing the page continously. To see the progress run `docker-compose logs -f` (which will automatically be called if you ran the `start.sh`).
- [`localhost:8080`](http://localhost:8080) to access the fhir server (HAPI) itself.
4. Finished :tada:

## Usage
The patient browser is standalone static html5 app living at
https://patient-browser.smarthealthit.org that is supposed to be invoked in
dialog windows or iFrames giving you the ability to select patients. It
would typically be rendered in a popup window but an iFrame inside a
layered dialog is often a preferred option. In any case, the patient
browser will be in it's own window which will be in another domain,

The patient browser is standalone static html5 app living at <https://patient-browser.smarthealthit.org> that is supposed to be invoked in
dialog windows or iFrames giving you the ability to select patients. It would typically be rendered in a popup window but an iFrame inside a
layered dialog is often a preferred option. In any case, the patient browser will be in it's own window which will be in another domain,
thus the post messages are used for the cross-window communication.

The host app (the one that invokes the patient browser) can also
"inject" some configuration to the patient browser to customize it.
The host app (the one that invokes the patient browser) can also "inject" some configuration to the patient browser to customize it.
Here is one commented example of how that works:

```js
Expand Down Expand Up @@ -122,26 +140,26 @@ jQuery(function($) {
The patient browser is designed to load external config file while starting. This way you can change the settings without having to re-build the app. Additionally, the app can be told which config file to load using an `config` get parameter like so:

**Official FHIR STU3 Picker:**
https://patient-browser.smarthealthit.org/index.html?config=stu3-open-sandbox
<https://patient-browser.smarthealthit.org/index.html?config=stu3-open-sandbox>

**Official FHIR DSTU2 Picker:**
https://patient-browser.smarthealthit.org/index.html?config=dstu2-open-sandbox
<https://patient-browser.smarthealthit.org/index.html?config=dstu2-open-sandbox>

**HAPI FHIR STU3 Picker:**
https://patient-browser.smarthealthit.org/index.html?config=stu3-open-hapi
<https://patient-browser.smarthealthit.org/index.html?config=stu3-open-hapi>

**HAPI FHIR DSTU2 Picker:**
https://patient-browser.smarthealthit.org/index.html?config=dstu2-open-hapi
<https://patient-browser.smarthealthit.org/index.html?config=dstu2-open-hapi>

If you need to support other servers you can just submit a pull request adding dedicated config file to this folder `/build/config`.
Note that these config files are in `json5` format which is like a loose version of JSON and you can even have comments inside it.

Any config file might contain the following options:

- `server` - an object describing the FHIR API server
- `server.url` - The base URL of the FHIR API server to use. Note that the picker will only work with open servers that do not require authorization.
- `server.type` - The FHIR version. Currently this can be `DSTU-2` or `STU-3` or `R4`.
- `server.tags` - An array of tag objects to be rendered in the tags auto-complete menu. This defaults to an empty array and in that case the tag selection widget will not have a drop-down menu options but it will still allow you to search by typing some tag manually. In other words, using an empty array is like saying that we just don't know what tags (if any) are available on that server. The list of tags might look like this:
- `server.url` - The base URL of the FHIR API server to use. Note that the picker will only work with open servers that do not require authorization.
- `server.type` - The FHIR version. Currently this can be `DSTU-2` or `STU-3` or `R4`.
- `server.tags` - An array of tag objects to be rendered in the tags auto-complete menu. This defaults to an empty array and in that case the tag selection widget will not have a drop-down menu options but it will still allow you to search by typing some tag manually. In other words, using an empty array is like saying that we just don't know what tags (if any) are available on that server. The list of tags might look like this:
```js
[
{
Expand All @@ -164,6 +182,7 @@ Any config file might contain the following options:
```
If your server does not have any tags then the tag selector widget will be useless and it is better if you hide it - see the `hideTagSelector` option below.
- `server.conditions` - An object containing all the predefined medical conditions. Each condition is stored by it's unique key and has a shape similar to this one:

```js
prediabetes: {
description: 'Prediabetes',
Expand All @@ -172,37 +191,44 @@ Any config file might contain the following options:
}
}
```

This is an empty object by default since we can't know what conditions are available on each server. We have that list pre-built for the smart sandbox servers but for the others you are expected to that yourself (see the Config Generator section below).

- `patientsPerPage` - Patients per page. Defaults to `10`.
- `timeout` - AJAX requests timeout in milliseconds. Defaults to `20000`.
- `renderSelectedOnly` - Only the selected patients are rendered. Should be false or the preselected patient IDs should be passed to the window. Otherwise It will result in rendering no patients at all. Defaults to `false`.
- `fhirViewer` - If `fhirViewer.enabled` is true (then `fhirViewer.url and `fhirViewer.param` MUST be set) then clicking on the patient-related resources in detail view will open their source in that external viewer. Otherwise they will just be opened in new browser tab. Defaults to
- `fhirViewer` - If `fhirViewer.enabled` is true (then `fhirViewer.url` and `fhirViewer.param` MUST be set) then clicking on the patient-related resources in detail view will open their source in that external viewer. Otherwise they will just be opened in new browser tab. Defaults to

```js
{
enabled: false,
url : "http://docs.smarthealthit.org/fhir-viewer/index.html",
param : "url"
}
```

- `outputMode` - How to return the selection. Defaults to `id-list`. Options are:
- `id-list` - return the selection as comma-separated list of patient IDs.
- `id-array` - return the selection as an array of patient IDs.
- `patients` - return the selection as an array of patient JSON objects.
- `id-list` - return the selection as comma-separated list of patient IDs.
- `id-array` - return the selection as an array of patient IDs.
- `patients` - return the selection as an array of patient JSON objects.
- `submitStrategy` - Defaults to `automatic`. Options are:
- `automatic` - Submit on change and defer that in some cases
- `manual` - Render a submit button
- `automatic` - Submit on change and defer that in some cases
- `manual` - Render a submit button
- hideTagSelector - If there are no tags in the server the tag selector will not be useful. You can hide the Tags tab by passing `true` here.

### Config Generator

Creating a config file might be a difficult task if you also want to have reliable condition list. We have created a special command-line tool to help you with that.
It will expect you to provide a FHIR server base URL and a config name and will handle everything else.
Example, ran within the project directory:

```sh
cd config-genrator
node generate_config.js -s http://127.0.0.1:18300 -f my-test-config
```

This will do the following:

1. Connect to the specified open server provided with the `-s` or `--server` option.
2. Load the conformance statement and detect the FHIR version (`"DSTU-2"` or `"STU-3"` or `"R4"`).
3. Load all the conditions that are found ot that server.
Expand All @@ -216,15 +242,27 @@ Keep in mind that when using this tool tu update existing config file, the data
NOTE: If you don't provide the `-f` the result configuration will be printed to stdout.

## URL Options

Some of the options above plus some additional ones can be passed via the URL. The app recognizes two types of parameters - search parameters and hash parameters. The search parameters are those listed after the first `?` and hash parameters are listed after a `?` character that is preceded by a `#` character. In other words, the hash portion of the URL can have it's own query string portion.

### Search parameters

This can contain `config` parameter plus some of the config variable described above - `patientsPerPage`, `submitStrategy`, `hideTagSelector`.

The **config** option is the base name of the config file that should be loaded from `/build/config/`. Defaults to `stu3-open-sandbox`.

### Hash parameters

- `_tab` - Which tab to open by default. Can be `tags`, `conditions` or `demographics`. If missing the Demographics tab will be activated.
- `_selection` - Comma-separated list of patient IDs to be rendered as selected. Note that this is only evaluated once, while the picker is loading.

## Further Information

Some files of these repos were merged into this fork of the patient browser:

- The Helm Chart stuff from here: <https://github.com/Alvearie/patient-browser>
- Updates in the Encounter Ressource from here: <https://github.com/BillyYarosh-WellSky/patient-browser>
- `animations.css` and R4 adaptions from <https://github.com/RufManuel/patient-browser>
- Updates in `package.json` and demo-config comments from <https://github.com/zeronote/patient-browser>
- LineCharts and CandlestickChart from <https://github.com/s4s-discovery/patient-browser>
- Dockerfile from <https://github.com/rodriperez/patient-browser>
19 changes: 19 additions & 0 deletions build/config/demo.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
server: {
type: "R4",
// url: "http://fhir:8080/fhir",
url: "http://localhost:8080/fhir",
tags: [],
conditions: {}
},
patientsPerPage: 25,
timeout: 20000,
renderSelectedOnly: false,
fhirViewer: {
enabled: true,
url: "http://docs.smarthealthit.org/fhir-viewer/index.html",
param: "url"
},
outputMode: "id-list",
submitStrategy: "manual"
}
4 changes: 2 additions & 2 deletions build/examples/picker.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="shortcut icon" href="../img/icon.png" type="image/png?_=f7b5a01551361f39f0e0" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.6.0/css/bootstrap.min.css">
</head>
<body>
<div id="main"></div>
<script src="../js/vendor/babel-polyfill.min.js"></script>
<script src="../js/commons.js?_=f7b5a01551361f39f0e0"></script>
<script src="../js/index.js?_=f7b5a01551361f39f0e0"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.6.0/js/bootstrap.min.js"></script>
<script src="../js/vendor/jdenticon-1.4.0.min.js"></script>
</body>
</html>
30 changes: 30 additions & 0 deletions build_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

source ./.env

printf "\n\n##################################\n"
printf "Building image $IMAGE_NAME with version tag $VERSION_TAG"
printf "\n##################################\n"


printf "\n\nPlease insert your login credentials to registry: $REGISTRY_PREFIX ...\n"
docker login

## Build the image:
printf "\n\n##################################\n"
printf "$IMAGE_NAME:$VERSION_TAG"
printf "\n##################################\n"
printf "\nPulling cached $IMAGE_NAME image\n"
# pull latest image for caching:
docker pull $REGISTRY_PREFIX/$IMAGE_NAME
# build new image (latest):
printf "\n\nBuilding $IMAGE_NAME image\n"
docker build -f ./Dockerfile -t $REGISTRY_PREFIX/$IMAGE_NAME .
printf "\n\nPushing $IMAGE_NAME image (latest)\n"
# push new image as new 'latest':
docker push "$REGISTRY_PREFIX/$IMAGE_NAME"
# also tag it with the new tag:
docker tag $REGISTRY_PREFIX/$IMAGE_NAME $REGISTRY_PREFIX/$IMAGE_NAME:$VERSION_TAG
# and also push this (tagged) image:
printf "\n\nPushing $IMAGE_NAME image ($VERSION_TAG)\n"
docker push "$REGISTRY_PREFIX/$IMAGE_NAME:$VERSION_TAG"
27 changes: 20 additions & 7 deletions config-genrator/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions config-genrator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
},
"dependencies": {
"colors": "^1.2.1",
"commander": "^2.15.1",
"json5": "^0.5.1",
"mixin-deep": "^1.2.0",
"commander": "^7.0.0",
"json5": "^2.0.0",
"mixin-deep": "^2.0.0",
"request": "^2.85.0"
}
}
36 changes: 36 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: "3.9" # optional since v1.27.0
services:
## The FHIR-Server:
fhir:
image: hapiproject/hapi:v5.4.1
restart: unless-stopped
environment:
# HAPI_FHIR_VALIDATION_REQUESTS_ENABLED: "true"
# HAPI_FHIR_SUBSCRIPTION_RESTHOOK_ENABLED: "true"
HAPI_FHIR_FHIR_VERSION: "R4"
HAPI_FHIR_CORS_ALLOWCREDENTIALS: "false"
HAPI_FHIR_CORS_ALLOWED_ORIGIN: "*"
ports:
- "${PORT_HAPI_HTTP}:8080"
hostname: docker-hapi

## Some demo-files:
# loader:
# image: joundso/alpine-bash-curl-ssl:latest
# command: >
# bash /data/run.sh
# volumes:
# - ./post_demo_data.sh:/data/run.sh:ro
# depends_on:
# - fhir

## And then the actual patient browser:
patient-browser:
image: ${REGISTRY_PREFIX}/${IMAGE_NAME}:${VERSION_TAG}
restart: unless-stopped
ports:
- "${PORT_PB_HTTP}:80" # nginx non-ssl
- "${PORT_PB_HTTPS}:443" # nginx SSL
hostname: docker-patientbrowser
# depends_on:
# - loader
Loading