Skip to content

Commit

Permalink
add ips+subs app example
Browse files Browse the repository at this point in the history
  • Loading branch information
spicyfalafel committed Aug 12, 2024
1 parent 11b9ab1 commit da4bec7
Show file tree
Hide file tree
Showing 21 changed files with 4,030 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ips-subscriptions/.dockerfileignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.env
32 changes: 32 additions & 0 deletions ips-subscriptions/.env.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
AIDBOX_LICENSE=

AIDBOX_DEV_MODE=true
AIDBOX_FHIR_VERSION=4.0.1
AIDBOX_FHIR_SCHEMA_VALIDATION=true
AIDBOX_FHIR_PACKAGES=hl7.fhir.r4.core#4.0.1:hl7.fhir.uv.ips#1.1.0
AIDBOX_TERMINOLOGY_SERVICE_BASE_URL="https://r4.ontoserver.csiro.au/fhir"
AIDBOX_COMPLIANCE=enabled

PGPORT=5432
PGHOST=aidbox-db
PGHOSTPORT=5437
PGUSER=postgres
PGPASSWORD=postgres
PGDATABASE=aidbox

AIDBOX_BASE_URL=http://aidbox:8888
AIDBOX_PORT=8888

AIDBOX_CLIENT_SECRET=secret
AIDBOX_CLIENT_ID=root
AIDBOX_ADMIN_PASSWORD=password

APP_PORT=4000
APP_URL=http://node-app:4000
APP_SECRET=secret
APP_CALLBACK_URL=/aidbox
APP_ID=my-app

BOX_AUTH_KEYS_SECRET=auth-key-secret
BOX_AUTH_KEYS_PRIVATE="-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEApbUYGNmCz1P8G0j/FFOjx1d5GNssJ/jj6xasSwTIbjjt6FtY\nCDw8o7hayOc/u8aUqXCGhK3JD2T9gtKv9/rV30w4YzmHhA8OOuLJE7tfh/PJA4Hn\n4i2JJ30BuoZ7rPTlTRGdc1FS3XFdmBQtnplEkJ7y8qbdrVme3Kbtn+BR1BdtgwSy\nbpNH2yqh3bb6PwpgNSMH7BIkBWL4A6QDpaFf1/9jSN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I9C\nm5DgtQZkmCg/d4rdI+JW9Dlc6DGlFmHog2GskiqSfxcLFhB7gZeoAziS2fexynqT\nYlG06QZQ5fij24z/RP5hW3XSdgY7AqF5c/8p2Y7+h+PDmDXGD4esM6NoprlIcxbe\nkfOOvwKBgQCoOpkW+OWnxPLawmG/gv8+s5CsfOPUpURwAjltSXz9LXvsJmWQPQVG\np4sKEOJidYyt24YrIHi9/UEqRi+uuRQ4zCuXS6UjXftjAarPIPGkL/1S6B1Z91zg\nE5C0rXOvAlrvK09p4HGXLrwQxjrWt8R7rPvaD2yqVKLP4liFj8RMdg==\n-----END RSA PRIVATE KEY-----\n"
BOX_AUTH_KEYS_PUBLIC="-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApbUYGNmCz1P8G0j/FFOj\nx1d5GNssJ/jj6xasSwTIbjjt6FtYCDw8o7hayOc/u8aUqXCGhK3JD2T9gtKv9/rV\n30w4YzmHhA8OOuLJE7tfh/PJA4Hn4i2JJ30BuoZ7rPTlTRGdc1FS3XFdmBQtnplE\nkJ7y8qbdrVme3Kbtn+BR1BdtgwSybpNH2yqh3bb6PwpgNSMH7BIkBWL4A6QDpaFf\n1/9jSNE1vO25ssLC+bhFQNWLYriu+HogzEf9NWIrR2W29mI1QiA7wqvEuhg1yx38\nylWD8GhCGL6+2QLKBYgp7DIGv6UoTnqcVISatdQ51lVcCPmU6L1BhmcXVti6dWBI\n+wIDAQAB\n-----END PUBLIC KEY-----\n"
11 changes: 11 additions & 0 deletions ips-subscriptions/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:20

WORKDIR /app
RUN corepack enable
COPY . .
RUN pnpm install --frozen-lockfile
RUN pnpm run build

EXPOSE 4000

CMD [ "node", "build/index.js" ]
16 changes: 16 additions & 0 deletions ips-subscriptions/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM node:20-slim

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update -y
RUN apt-get install -y rsync
RUN corepack enable

WORKDIR /usr/src/app-cache

COPY package.json .
RUN pnpm install

WORKDIR /usr/src/app

EXPOSE 4000
78 changes: 78 additions & 0 deletions ips-subscriptions/README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Implementation of IPS FHIR IG on Aidbox FHIR platform

This repository contains pre-configured Aidbox instance and implementation of `$summary` operation defined by IPS:

- [FHIRSchema](https://docs.aidbox.app/modules-1/profiling-and-validation/fhir-schema-validator)
- FHIR 4.3.0, ca.infoway.io.psca
- [Topic-based subscriptions](https://docs.aidbox.app/modules-1/topic-based-subscriptions)
- [$summary](https://build.fhir.org/ig/HL7/fhir-ips/OperationDefinition-summary.html) operation


## Prerequisites

- [Docker](https://www.docker.com/)

## STEP 1: Environment and Aidbox license

Copy `.env.tpl` file into `.env` file:

```shell
cp .env.tpl .env
```

If you are hosting Aidbox on your local computer, obtain the self-hosted license as described in the [documentation](https://docs.aidbox.app/getting-started/run-aidbox-locally-with-docker).

Add the license (`AIDBOX_LICENSE`) int the .env file.

## STEP 2: Run aidbox and node-app in Docker

```shell
docker compose up --build
```

On start, the node-app will create [App resource](https://docs.aidbox.app/app-development/aidbox-sdk/aidbox-apps), [upload](./src/index.ts#L142) a sample FHIR [Bundle](./src/patientData.ts) with patient data.

## Step 3: Open and log in into Aidbox instance

Open in browser http://localhost:8888

And log in witn username: `admin` and password: `password`

## Step 4: Request $summary using REST Console

In the Aidbox admin window, navigate to the APIs section and choose REST Console.

The [$summary](https://build.fhir.org/ig/HL7/fhir-ips/OperationDefinition-summary.html) operation requires either the logical ID (`Patient.id`) or a business identifier (`Patient.identifier`) of the patient.
To request the IPS "document" _Bundle_ for a specific patient using the REST Console, you can use the following request:

```
GET /fhir/Patient/[id]/$summary
```

Or you can use request with `identifier` search parameter:

```
GET /fhir/Patient/$summary?identifier=<patient-identifier>
```

## Step 5: Check if topic-based-subscriptions works

[Here](./zrc/main.edn) is configured one SubscriptionTopic (triggers if new resource Observation has valueQuantity > 10).
Table "observation_topic" will be used.

Let's check if it works. Create observation:
```
POST /fhir/Observation
status: final
code:
text: text
valueQuantity:
value: 11
```
Check Subscription Topics tab or check `observation_topic` table in Db Console:
```sql
select * from observation_topic
```
Read more about Topic-Based Subscriptions: https://docs.aidbox.app/modules-1/topic-based-subscriptions

42 changes: 42 additions & 0 deletions ips-subscriptions/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: "3.7"
volumes:
ips_pgdata:
name: ips_pgdata
services:
aidbox-db:
image: healthsamurai/aidboxdb:16.1
pull_policy: always
ports:
- "${PGHOSTPORT}:5432"
volumes:
- "ips_pgdata:/data:delegated"
environment:
POSTGRES_USER: "${PGUSER}"
POSTGRES_PASSWORD: "${PGPASSWORD}"
POSTGRES_DB: "${PGDATABASE}"

aidbox:
image: healthsamurai/aidboxone:edge
pull_policy: always
depends_on: ["aidbox-db"]
volumes:
- "./zrc:/aidbox-project/zrc"
- "./tmp:/tmp"
ports:
- "${AIDBOX_PORT}:${AIDBOX_PORT}"
env_file:
- .env

node-app:
hostname: node-app
build:
context: ./
dockerfile: Dockerfile.dev
ports:
- 4000:4000
user: node
command: sh -c "rsync -ar /usr/src/app-cache/node_modules/. /usr/src/app/node_modules && pnpm run dev"
env_file:
- .env
volumes:
- ./:/usr/src/app
6 changes: 6 additions & 0 deletions ips-subscriptions/nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"watch": ["src/**/*.ts"],
"ext": "ts",
"legacyWatch": true,
"exec": "node --loader ts-node/esm ./src/index.ts"
}
35 changes: 35 additions & 0 deletions ips-subscriptions/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "app",
"version": "1.0.0",
"description": "",
"main": "src/index.ts",
"type": "module",
"engines": {
"node": ">=18.0"
},
"scripts": {
"clean": "rm -rf build/ *.tsbuildinfo",
"dev": "NODE_ENV=development nodemon",
"start": "nodemon",
"ci:test": "echo \"Error: no test specified\" ",
"build": "pnpm run clean && tsc -b --force"
},
"author": "",
"license": "ISC",
"dependencies": {
"@aidbox/sdk-r4": "^1.0.12",
"dotenv": "^16.3.1",
"fastify": "^4.21.0",
"fastify-healthcheck": "^4.4.0",
"formdata-node": "^2.4.0",
"valibot": "^0.30.0"
},
"devDependencies": {
"@types/node": "^18.17.5",
"nodemon": "^3.0.1",
"prettier": "^3.0.2",
"ts-node": "^10.9.1",
"typescript": "^5.1.6"
},
"packageManager": "pnpm@9.1.0+sha512.67f5879916a9293e5cf059c23853d571beaf4f753c707f40cb22bed5fb1578c6aad3b6c4107ccb3ba0b35be003eb621a16471ac836c87beb53f9d54bb4612724"
}
Loading

0 comments on commit da4bec7

Please sign in to comment.