Skip to content

Commit

Permalink
Enable topic based subscription for Observation
Browse files Browse the repository at this point in the history
  • Loading branch information
ir4y committed Nov 9, 2023
1 parent 248015e commit 8172a30
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 2 deletions.
4 changes: 3 additions & 1 deletion zenproject/zen-package.edn
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{:deps {}}
{:deps
{fhir.topic-based-subscription
"https://github.com/zen-fhir/hl7-fhir-uv-subscriptions-backport-r4b.git"}}
67 changes: 66 additions & 1 deletion zenproject/zrc/system.edn
Original file line number Diff line number Diff line change
@@ -1,6 +1,71 @@
{ns system
import #{aidbox}
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"}}

0 comments on commit 8172a30

Please sign in to comment.