Skip to content

Commit 583e7a1

Browse files
committed
annotate map, clean up, add transaction
1 parent 336cc03 commit 583e7a1

File tree

1 file changed

+45
-20
lines changed

1 file changed

+45
-20
lines changed

input/maps/HIVObservationHIVCondition.map

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,70 @@
1+
// name the map and its canonical url
12
map "https://path-global-health.github.io/MERindicators/StructureMap/HIVObservationHIVCondition" = "HIVObservationHIVCondition"
23

3-
uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias bund as source
4+
// declare the structure defs used
5+
uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias input as source
46
uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias output as target
57

68

7-
9+
// declare group with local vars (src, tgt) and their aliases
10+
// anything ending with semicolon is a rule
811
group HIVObservationHIVCondition(
9-
source src: bund,
12+
source src: input,
1013
target tgt: output
1114
) {
15+
// set bundle type for the output bundle
16+
src -> tgt.type = 'transaction' "setBundleType";
1217

13-
src -> tgt.type = 'collection' "setBundleType";
14-
15-
src.entry as entry -> tgt.entry as tentry then {
16-
entry.resource : Patient as patient -> tentry.resource = patient then {
17-
18-
src.entry as obsentry where resource.is(Observation) and resource.subject.exists(reference=("Patient/" & patient.id)) and resource.code.exists(coding.exists(system='https://openconceptlab.org/orgs/CIEL/sources/CIEL' and code='160540'))
19-
-> tgt.entry as newentry, newentry.resource = create("Condition") as cond, uuid() as cid then {
20-
obsentry.resource as obs -> newentry.fullUrl = ( "urn:uuid:" & cid ) then {
21-
//obsentry -> newentry.resource = cond, cond.id = cid "setConditionRes";
18+
// loop through patients in input bundle
19+
src.entry as entry -> tgt.entry as tentry
20+
then {
21+
entry.resource : Patient as patient -> tentry.resource = patient
22+
then {
23+
// for observations of that patient look for art program enrollment
24+
// create a condition resource in output with uuid
25+
src.entry as obsentry where resource.is(Observation)
26+
and resource.subject.exists(reference=("Patient/" & patient.id))
27+
and resource.code.exists(coding.exists(system='https://openconceptlab.org/orgs/CIEL/sources/CIEL' and code='160540'))
28+
-> tgt.entry as newentry, newentry.resource = create("Condition") as cond, uuid() as cid
29+
then {
30+
obsentry.resource as obs -> newentry.fullUrl = ( "urn:uuid:" & cid ),
31+
// var for request bit of resources in transaction bundle
32+
newentry.request as newrequest
33+
then {
2234
obsentry -> cond.id = cid "setCId";
23-
patient -> cond.subject as subject then {
35+
// setrequest rule for resource in transaction bundle
36+
// needs to be processed properly before putting on existing data on fhir server
37+
obsentry -> newrequest.method = "PUT", newrequest.url = "Condition" "setrequest";
38+
patient -> cond.subject as subject
39+
then {
2440
patient -> subject.reference = reference(patient) "setSubjectRef";
2541
} "setSubject";
2642
obsentry.effective as effective -> cond.onset = effective "setOnset";
27-
obsentry -> cond.code as ccode then {
28-
obsentry -> ccode.coding as coding then {
43+
obsentry -> cond.code as ccode
44+
then {
45+
obsentry -> ccode.coding as coding
46+
then {
2947
obsentry -> coding.code = '86406008',
3048
coding.display = "HIV Condition Positive",
3149
coding.system = 'http://snomed.info/sct' "setCondSystemCode";
3250
} "setCondCoding";
3351
} "SetCondCode";
34-
obs -> tgt.entry as pentry, pentry.resource = create("Provenance") as prov, uuid() as pid then {
52+
// create provenance resource to document input/output resources links
53+
obs -> tgt.entry as pentry, pentry.resource = create("Provenance") as prov, uuid() as pid,
54+
pentry.request as prequest
55+
then {
3556
obs -> prov.id = pid "setPId";
3657
obs -> pentry.fullUrl = ( "urn:uuid:" & pid ) "setFullUrl";
37-
obs -> prov.target as ptarg then {
38-
obs -> ptarg.reference = reference(cond) "setTargetRef";
58+
obs -> prequest.method = "PUT", prequest.url = "Provenance" "setrequest";
59+
obs -> prov.target as ptarg
60+
then {
61+
obs -> ptarg.reference = ( "urn:uuid:" & cid ) "setTargetRef";
3962
} "setTarget";
40-
obs -> prov.entity as entity then {
63+
obs -> prov.entity as entity
64+
then {
4165
obs -> entity.role = "source" "setRole";
42-
obs -> entity.what as pwhat then {
66+
obs -> entity.what as pwhat
67+
then {
4368
obs -> pwhat.reference = reference(obs) "setWhatRef";
4469
} "setWhat";
4570
} "setEntity";

0 commit comments

Comments
 (0)