Created
December 22, 2021 13:01
-
-
Save niquola/460e762aea0bd74e0f88fd8f84e15e44 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ns innovaccer | |
import #{aidbox aidbox.ops | |
fhir.Patient.search-params | |
fhir.Encounter.search-params} | |
server | |
{:apis #{apis aidbox/api}} | |
apis | |
{:zen/tas #{aidbox/api} | |
:routes {"pract" pract-api}} | |
Practitoner | |
{:zen/tas #{zen/schema} | |
:confirms #{fhir/Practitioner} | |
:keys {:name {:minItems 1}}} | |
pract-api | |
{:zen/tas #{aidbox/api} | |
:generate {:metadata {} | |
:openapi {}} | |
:routes | |
{"Patient" {:resource/type "Encounter" | |
:GET {:operation aidbox.ops/search | |
:params {:name fhir.Patient.search-params/name | |
:_sort {:date fhir.Patient.search-params/sort-name}} | |
:patch-query | |
{:join {:upt {:table :user_patients | |
:on {:match-pt [:= :id :upt.patient_id] | |
:match-user [:= :upt.user_id (ctx :user :id)]}}}}}} | |
"Encounter" | |
{:resource/type "Encounter" | |
:GET {:operation aidbox.ops/search | |
:params {:class fhir.Encounter.search-params/class | |
:subject fhir.Encounter.search-params/subject | |
:practitioner fhir.Encounter.search-params/subject | |
:_include {:subject {:Patient {}}} | |
:_sort {:date fhir.Encounter.search-params/sort-date}} | |
:patch-params | |
{:practitioner (ctx :user :data :practitioner_id)} | |
:patch-query | |
{:join {:upt {:table :user_patients | |
:on {:match-pt [:= [:resource#>> :subject :id] :upt.patient_id] | |
:match-user [:= :upt.user_id (ctx :user :id)]}}}} | |
:elements {:mask #{[:identifier :value]} | |
:hide #{[:name]}}} | |
:POST {:operation aidbox.ops/create | |
:profiles #{Pratitioner} | |
:policies {:pt {:engine :sql | |
:query {:from :user_patient | |
:where {:match-user [:= :user_id (ctx :user :id)] | |
:match-pt [:= :patient_id (ctx :resource :subject :id)]}}}} | |
:inject-elements | |
{[:participant {:type {:coding [{:code "ADM" :system "http://terminology.hl7.org/CodeSystem/participant-type"}]}}] | |
{:resourceType "Practitioner" :id (ctx [:user :data :practitioner_id])}}}}}}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment