Skip to content

Consent points to careteam #9

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

Open
wants to merge 1 commit into
base: main
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
6 changes: 5 additions & 1 deletion Hackathon_2024.10/1 Setup/Create CareTeam.bru
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
meta {
name: Create CareTeam
type: http
seq: 12
seq: 11
}

post {
Expand Down Expand Up @@ -69,6 +69,10 @@ body:json {
}
}

vars:post-response {
CareTeamID: res.body.id
}

assert {
res.status: eq 201
}
Expand Down
28 changes: 5 additions & 23 deletions Hackathon_2024.10/1 Setup/Create Consent.bru
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
meta {
name: Create Consent
type: http
seq: 11
seq: 12
}

post {
Expand Down Expand Up @@ -44,32 +44,14 @@ body:json {
"role": {
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/v3-ParticipationType",
"code": "PRCP"
"system": "http://terminology.hl7.org/CodeSystem/v3-ParticipationFunction",
"code": "AUTM"
}
]
},
"reference": {
"identifier": {
"system": "$ura",
"value": "{{Org1Ura}}"
}
}
},
{
"role": {
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/v3-ParticipationType",
"code": "PRCP"
}
]
},
"reference": {
"identifier": {
"system": "$ura",
"value": "{{Org2Ura}}"
}
"type":"CareTeam",
"reference":"CareTeam/{{CareTeamID}}"
}
}
],
Expand Down
Binary file modified bundles/bundle.tar.gz
Binary file not shown.
39 changes: 4 additions & 35 deletions opa/policy.rego
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ allow if {

"hackathon_v2024" in scope

consent_given

requestor_part_of_care_team
}

consent_given if requestor_ura in consent_uras

requestor_part_of_care_team if requestor_ura in care_team_uras

scope contains input.introspectionResult.scope
Expand All @@ -27,50 +23,23 @@ token_active if {
}

care_team_uras contains org.member.identifier.value if {
some care_team in fetch_careteam(bsn)
care_team.resourceType == "CareTeam"
some resource in fetch_consent(bsn)
resource.resourceType == "CareTeam"

some org in care_team.participant
some org in resource.participant
org.member.identifier.system == "$ura"
}

consent_uras contains actor.reference.identifier.value if {
some consent in fetch_consent(bsn)
consent.resourceType == "Consent"

some actor in consent.provision.actor
actor.reference.identifier.system == "$ura"
}

path := urlquery.decode(input.request.uri)
bsn := regex.find_all_string_submatch_n(`^.*identifier=http://fhir.nl/fhir/NamingSystem/bsn\|(\d+)$`, path, -1)[0][1]

fetch_careteam(bsn) := ct if {
system := "http://fhir.nl/fhir/NamingSystem/bsn%7C"
res := http.send({
"method": "get",
"url": concat("", ["http://fhir:8080/fhir/CareTeam?patient.identifier=", system, bsn]),
"raise_error": true,
"force_json_decode": true,
"headers": {
"Accept": "application/json",
"Content-Type": "application/json"
}
})

print("careteam response", res.body)
res.status_code == 200
res.body.total > 0
ct := [ x | x := res.body.entry[_].resource]
}

fetch_consent(bsn) := c if {
print("test_request")
system := "http://fhir.nl/fhir/NamingSystem/bsn%7C"

res := http.send({
"method": "get",
"url": concat("", ["http://fhir:8080/fhir/Consent?patient.identifier=", system, bsn, "&status=active&scope=patient-privacy"]),
"url": concat("", ["http://fhir:8080/fhir/Consent?patient.identifier=", system, bsn, "&status=active&scope=patient-privacy&_include=Consent:actor"]),
"raise_error": false,
"force_json_decode": true,
"headers": {
Expand Down