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

WIP V2 #54

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
- name: Upgrade pip
run: |
python -m pip install --upgrade pip
- name: Create deps dir
run: mkdir -p zenproject/zen-packages && chmod 0777 zenproject/zen-packages
- name: Run tests
run: ./run_test.sh
shell: bash
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ venv
aidbox_python_sdk.egg-info/
.python-version
.vscode
dist
dist
zenproject/zen-packages
30 changes: 15 additions & 15 deletions docker-compose.yaml → compose.yaml
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
version: '3.1'
services:
devbox-db:
image: "healthsamurai/aidboxdb:14.5"
aidbox-db:
image: "healthsamurai/aidboxdb:14.9"
ports:
- "5434:5432"
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: devbox
devbox:
image: "healthsamurai/aidboxone:latest"
POSTGRES_DB: aidbox
aidbox:
image: "healthsamurai/aidboxone:edge"
depends_on:
- devbox-db
- aidbox-db
links:
- "devbox-db:database"
- "aidbox-db:database"
ports:
- "8080:8080"
env_file:
- env_tests
environment:
PGHOST: database
PGDATABASE: devbox
PGDATABASE: aidbox
PGPORT: 5432
PGUSER: postgres
PGPASSWORD: postgres
AIDBOX_CONFIG: /var/config/config.edn
AIDBOX_LICENSE: ${AIDBOX_LICENSE}
volumes:
- ./config:/var/config
devbox-healthcheck:
- ./zenproject:/zenproject
aidbox-healthcheck:
image: curlimages/curl
entrypoint: /bin/sleep 10000
links:
- devbox
- aidbox
depends_on:
- devbox
- aidbox
healthcheck:
test: curl --fail http://devbox:8080/__healthcheck || exit 1
test: curl --fail http://aidbox:8080/__healthcheck || exit 1
interval: 1s
timeout: 20s
retries: 100
Expand All @@ -47,11 +47,11 @@ services:
PYTHON_VERSION: ${PYTHON:-3.11}
command: ["pipenv", "run", "pytest"]
depends_on:
devbox-healthcheck:
aidbox-healthcheck:
condition:
service_healthy
links:
- devbox
- aidbox
env_file:
- env_tests
ports:
Expand Down
10 changes: 0 additions & 10 deletions config/config.edn

This file was deleted.

5 changes: 0 additions & 5 deletions config/genkey.sh

This file was deleted.

49 changes: 0 additions & 49 deletions config/jwtRS256.key

This file was deleted.

1 change: 0 additions & 1 deletion config/jwtRS256.key.pub

This file was deleted.

16 changes: 9 additions & 7 deletions env_tests
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
AIDBOX_CLIENT_ID=root
AIDBOX_CLIENT_SECRET=secret
AIDBOX_BASE_URL=http://devbox:8080
AIDBOX_BASE_URL=http://aidbox:8080

AIDBOX_ZEN_DEV_MODE=enable
AIDBOX_ZEN_ENTRYPOINT=system/box
BOX_PROJECT_GIT_TARGET__PATH=/zenproject
AIDBOX_ZEN_PROJECT=/zenproject

AIDBOX_PORT=8080
AIDBOX_FHIR_VERSION=3.0.1
AIDBOX_FHIR_VERSION=4.3.0

APP_INIT_CLIENT_ID=root
APP_INIT_CLIENT_SECRET=secret
APP_INIT_URL=http://devbox:8080
APP_INIT_URL=http://aidbox:8080

APP_ID=app-py-example
APP_SECRET=secret
Expand All @@ -17,7 +22,4 @@ AIO_PORT=8081
AIO_HOST=0.0.0.0
AIO_APP_PATH=.

OPENID_RSA=/var/config/jwtRS256.key
OPENID_RSA_PUB=/var/config/jwtRS256.key.pub

AIDBOX_STDOUT_PRETTY=debug
AIDBOX_STDOUT_PRETTY=debug
2 changes: 1 addition & 1 deletion run_test.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

docker compose -f docker-compose.yaml up --exit-code-from app app
docker compose up --exit-code-from app app
3 changes: 3 additions & 0 deletions zenproject/zen-package.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{:deps
{fhir.topic-based-subscription
"https://github.com/zen-fhir/hl7-fhir-uv-subscriptions-backport-r4b.git"}}
71 changes: 71 additions & 0 deletions zenproject/zrc/system.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{ns system
import #{aidbox
fhir.topic-based-subscription
hl7-fhir-uv-subscriptions-backport-r4b}

observation-topic
{:zen/tags #{fhir.topic-based-subscription/topic-definition}
;; SubscriptionTopic url should be an absolute URI (globally unique)
:url "urn:aidbox-python-sdk:SubscriptionTopic:observations"
:resourceTrigger [
;; an SubscriptionTopic may consist
;; of any number of resources
{:resource "Observation"
:fhirPathCriteria "%current.value.ofType(Quantity).value > 10"}]
:canFilterBy [{:resource "Observation"
:filterParameter "value"
;; _fhirPath specifies how to calculate value for the filter
:_fhirPath "%current.value.ofType(Quantity).value"
:modifier ["eq" "gt" "lt" "ge" "le"]}

{:resource "Observation"
:filterParameter "value-increase"
;; both %current and %previous state of the
;; resource are available
:_fhirPath "%current.value.ofType(Quantity).value > %previous.value.ofType(Quantity).value"
:modifier ["eq"]}]}


postgres-observation-topic-storage
{:zen/tags #{fhir.topic-based-subscription/topic-storage}
;; At the moment only PostgreSQL is available as a storage
:storage-type fhir.topic-based-subscription/postgres
;; The name of the table which will be created to store topic events:
:table-name "observation_topic"
;; Possible value for maxContent are: "empty" | "id-only" | "full-resource"
;; The actual Resource is only stored in queue when "full-resource" value
;; are specified. When deciding which payload type to request,
;; systems SHOULD consider both ease of processing and security of PHI.
;; To mitigate the risk of information leakage, systems SHOULD use the
;; minimum level of detail consistent with the use case.
;; In practice, id-only provides a good balance between security
;; and performance for many real-world scenarios.
:maxContent "full-resource"
;; The period, in seconds, during which events from the replication slot
;; will be buffered before being written to storage:
:timeout 10
;; The maximum number of events the replication slot will buffer before
;; writing to storage:
:maxCount 100
;; Interval in seconds periodic heartbeat record generation
;; in cdc_topic_heartbeat_table, to reclaim the WAL space:
:heartbeat-rate 120
;; The number of workers responsible for notification delivery.
;; min number 4 is advised. One worker can handle up to 1024 subsrciptions:
:senders-number 4}


;; Service which binds storage with topic definition
observation-topic-srv
{:zen/tags #{aidbox/service}
:engine fhir.topic-based-subscription/change-data-capture-service-engine
:topic-definition observation-topic
:topic-storage postgres-observation-topic-storage}


;; Entrypoint for the instance with corresponding service

box
{:zen/tags #{aidbox/system}
:services {:observation-topic-srv observation-topic-srv}
:zen/desc "Test python sdk"}}