Skip to content

Commit 5c2751c

Browse files
committed
add ips+subs app example
1 parent 11b9ab1 commit 5c2751c

20 files changed

+4035
-0
lines changed

Diff for: ips-subscriptions/.dockerfileignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
.env

Diff for: ips-subscriptions/.env.tpl

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
AIDBOX_LICENSE=
2+
3+
BOX_PROJECT_GIT_TARGET__PATH=/aidbox-project/zrc
4+
AIDBOX_ZEN_ENTRYPOINT=main/box
5+
AIDBOX_ZEN_DEV_MODE="true"
6+
7+
AIDBOX_DEV_MODE=true
8+
AIDBOX_FHIR_VERSION=4.0.1
9+
AIDBOX_FHIR_SCHEMA_VALIDATION=true
10+
AIDBOX_FHIR_PACKAGES=hl7.fhir.r4b.core#4.3.0:ca.infoway.io.psca#1.1.0
11+
AIDBOX_TERMINOLOGY_SERVICE_BASE_URL="https://tx.health-samurai.io/fhir"
12+
AIDBOX_COMPLIANCE=enabled
13+
AIDBOX_CORRECT_AIDBOX_FORMAT=true
14+
15+
PGPORT=5432
16+
PGHOST=aidbox-db
17+
PGHOSTPORT=5438
18+
PGUSER=postgres
19+
PGPASSWORD=postgres
20+
PGDATABASE=aidbox
21+
22+
AIDBOX_BASE_URL=http://aidbox:8888
23+
AIDBOX_PORT=8888
24+
25+
AIDBOX_CLIENT_SECRET=secret
26+
AIDBOX_CLIENT_ID=root
27+
AIDBOX_ADMIN_PASSWORD=password
28+
29+
APP_PORT=4000
30+
APP_URL=http://node-app:4000
31+
APP_SECRET=secret
32+
APP_CALLBACK_URL=/aidbox
33+
APP_ID=my-app
34+
35+
BOX_AUTH_KEYS_SECRET=auth-key-secret
36+
BOX_AUTH_KEYS_PRIVATE="-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEApbUYGNmCz1P8G0j/FFOjx1d5GNssJ/jj6xasSwTIbjjt6FtY\nCDw8o7hayOc/u8aUqXCGhK3J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MtEnY/WgwV2Ic5a9RBZEWYAM4I\nMQ3HTUtuQSL8uRIwxaIlTeEQpnq2TKUINGRyZGdO/OPEvIwO7SmFpvOx30tiBgTv\nHkiCS1RtPHhkh1tZhirUneECgYAxNmARVQDKuYLXdM/jbEgJJD4FHXSNHqSi/I9C\nm5DgtQZkmCg/d4rdI+JW9Dlc6DGlFmHog2GskiqSfxcLFhB7gZeoAziS2fexynqT\nYlG06QZQ5fij24z/RP5hW3XSdgY7AqF5c/8p2Y7+h+PDmDXGD4esM6NoprlIcxbe\nkfOOvwKBgQCoOpkW+OWnxPLawmG/gv8+s5CsfOPUpURwAjltSXz9LXvsJmWQPQVG\np4sKEOJidYyt24YrIHi9/UEqRi+uuRQ4zCuXS6UjXftjAarPIPGkL/1S6B1Z91zg\nE5C0rXOvAlrvK09p4HGXLrwQxjrWt8R7rPvaD2yqVKLP4liFj8RMdg==\n-----END RSA PRIVATE KEY-----\n"
37+
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"

Diff for: ips-subscriptions/Dockerfile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM node:20
2+
3+
WORKDIR /app
4+
RUN corepack enable
5+
COPY . .
6+
RUN pnpm install --frozen-lockfile
7+
RUN pnpm run build
8+
9+
EXPOSE 4000
10+
11+
CMD [ "node", "build/index.js" ]

Diff for: ips-subscriptions/Dockerfile.dev

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM node:20-slim
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
5+
RUN apt-get update -y
6+
RUN apt-get install -y rsync
7+
RUN corepack enable
8+
9+
WORKDIR /usr/src/app-cache
10+
11+
COPY package.json .
12+
RUN pnpm install
13+
14+
WORKDIR /usr/src/app
15+
16+
EXPOSE 4000

Diff for: ips-subscriptions/README.MD

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Implementation of IPS FHIR IG on Aidbox FHIR platform
2+
3+
This repository contains pre-configured Aidbox instance and implementation of `$summary` operation defined by IPS:
4+
5+
- [FHIRSchema](https://docs.aidbox.app/modules-1/profiling-and-validation/fhir-schema-validator)
6+
- FHIR 4.3.0, ca.infoway.io.psca
7+
- [Topic-based subscriptions](https://docs.aidbox.app/modules-1/topic-based-subscriptions)
8+
- [$summary](https://build.fhir.org/ig/HL7/fhir-ips/OperationDefinition-summary.html) operation
9+
10+
11+
## Prerequisites
12+
13+
- [Docker](https://www.docker.com/)
14+
15+
## STEP 1: Environment and Aidbox license
16+
17+
Copy `.env.tpl` file into `.env` file:
18+
19+
```shell
20+
cp .env.tpl .env
21+
```
22+
23+
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).
24+
25+
Add the license (`AIDBOX_LICENSE`) int the .env file.
26+
27+
## STEP 2: Run aidbox and node-app in Docker
28+
29+
```shell
30+
docker compose up --build
31+
```
32+
33+
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.
34+
35+
## Step 3: Open and log in into Aidbox instance
36+
37+
Open in browser http://localhost:8888
38+
39+
And log in witn username: `admin` and password: `password`
40+
41+
## Step 4: Request $summary using REST Console
42+
43+
In the Aidbox admin window, navigate to the APIs section and choose REST Console.
44+
45+
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.
46+
To request the IPS "document" _Bundle_ for a specific patient using the REST Console, you can use the following request:
47+
48+
```
49+
GET /fhir/Patient/[id]/$summary
50+
```
51+
52+
Or you can use request with `identifier` search parameter:
53+
54+
```
55+
GET /fhir/Patient/$summary?identifier=<patient-identifier>
56+
```
57+
58+
## Step 5: Check if topic-based-subscriptions works
59+
60+
[Here](./zrc/main.edn) is configured one SubscriptionTopic (triggers if new resource Observation has valueQuantity > 10).
61+
Table "observation_topic" will be used.
62+
63+
Let's check if it works. Create observation:
64+
```
65+
POST /fhir/Observation
66+
67+
status: final
68+
code:
69+
text: text
70+
valueQuantity:
71+
value: 11
72+
```
73+
Check Subscription Topics tab or check `observation_topic` table in Db Console:
74+
```sql
75+
select * from observation_topic
76+
```
77+
Read more about Topic-Based Subscriptions: https://docs.aidbox.app/modules-1/topic-based-subscriptions
78+

Diff for: ips-subscriptions/docker-compose.yaml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
version: "3.7"
2+
volumes:
3+
ips_pgdata:
4+
name: ips_pgdata
5+
services:
6+
aidbox-db:
7+
image: healthsamurai/aidboxdb:16.1
8+
pull_policy: always
9+
ports:
10+
- "${PGHOSTPORT}:5432"
11+
volumes:
12+
- "ips_pgdata:/data:delegated"
13+
environment:
14+
POSTGRES_USER: "${PGUSER}"
15+
POSTGRES_PASSWORD: "${PGPASSWORD}"
16+
POSTGRES_DB: "${PGDATABASE}"
17+
18+
aidbox:
19+
image: healthsamurai/aidboxone:edge
20+
pull_policy: always
21+
depends_on: ["aidbox-db"]
22+
volumes:
23+
- "./zrc:/aidbox-project/zrc"
24+
- "./tmp:/tmp"
25+
ports:
26+
- "${AIDBOX_PORT}:${AIDBOX_PORT}"
27+
env_file:
28+
- .env
29+
30+
node-app:
31+
hostname: node-app
32+
build:
33+
context: ./
34+
dockerfile: Dockerfile.dev
35+
ports:
36+
- 4000:4000
37+
user: node
38+
command: sh -c "rsync -ar /usr/src/app-cache/node_modules/. /usr/src/app/node_modules && pnpm run dev"
39+
env_file:
40+
- .env
41+
volumes:
42+
- ./:/usr/src/app

Diff for: ips-subscriptions/nodemon.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"watch": ["src/**/*.ts"],
3+
"ext": "ts",
4+
"legacyWatch": true,
5+
"exec": "node --loader ts-node/esm ./src/index.ts"
6+
}

Diff for: ips-subscriptions/package.json

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "app",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "src/index.ts",
6+
"type": "module",
7+
"engines": {
8+
"node": ">=18.0"
9+
},
10+
"scripts": {
11+
"clean": "rm -rf build/ *.tsbuildinfo",
12+
"dev": "NODE_ENV=development nodemon",
13+
"start": "nodemon",
14+
"ci:test": "echo \"Error: no test specified\" ",
15+
"build": "pnpm run clean && tsc -b --force"
16+
},
17+
"author": "",
18+
"license": "ISC",
19+
"dependencies": {
20+
"@aidbox/sdk-r4": "^1.0.12",
21+
"dotenv": "^16.3.1",
22+
"fastify": "^4.21.0",
23+
"fastify-healthcheck": "^4.4.0",
24+
"formdata-node": "^2.4.0",
25+
"valibot": "^0.30.0"
26+
},
27+
"devDependencies": {
28+
"@types/node": "^18.17.5",
29+
"nodemon": "^3.0.1",
30+
"prettier": "^3.0.2",
31+
"ts-node": "^10.9.1",
32+
"typescript": "^5.1.6"
33+
},
34+
"packageManager": "[email protected]+sha512.67f5879916a9293e5cf059c23853d571beaf4f753c707f40cb22bed5fb1578c6aad3b6c4107ccb3ba0b35be003eb621a16471ac836c87beb53f9d54bb4612724"
35+
}

0 commit comments

Comments
 (0)