0.1.0 - ci-build
HIVFHIRIG, published by intellisoftkenya. This guide is not an authorized publication; it is the continuous build for version 0.1.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/IntelliSOFT-Consulting/HIV-FHIR-IG/ and changes regularly. See the Directory of published versions
Draft as of 2024-09-18 |
{
"resourceType" : "StructureMap",
"id" : "HIVObservationHIVCondition",
"text" : {
"status" : "generated",
"div" : "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p class=\"res-header-id\"><b>Generated Narrative: StructureMap HIVObservationHIVCondition</b></p><a name=\"HIVObservationHIVCondition\"> </a><a name=\"hcHIVObservationHIVCondition\"> </a><a name=\"HIVObservationHIVCondition-en-US\"> </a><pre class=\"fml\">\r\n<b>map</b><span style=\"color: navy\"> "</span>https://IntelliSOFT-Consulting.github.io/HIV-FHIR-IG/StructureMap/HIVObservationHIVCondition<span style=\"color: navy\">" = "</span>HIVObservationHIVCondition<span style=\"color: navy\">"\r\n\r\n</span><span style=\"color: navy\">// </span><span style=\"color: green\">declare the structure defs used</span>\r\n\r\n<b>uses</b><span style=\"color: navy\"> "</span><a href=\"http://hl7.org/fhir/R4/bundle.html\" title=\"Bundle\">http://hl7.org/fhir/StructureDefinition/Bundle</a><span style=\"color: navy\">" </span><b>alias </b>input <b>as </b><b>source</b>\r\n<b>uses</b><span style=\"color: navy\"> "</span><a href=\"http://hl7.org/fhir/R4/bundle.html\" title=\"Bundle\">http://hl7.org/fhir/StructureDefinition/Bundle</a><span style=\"color: navy\">" </span><b>alias </b>output <b>as </b><b>target</b>\r\n\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">declare group with local vars (src, tgt) and their aliases</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">anything ending with semicolon is a rule</span>\r\n<b>group </b>HIVObservationHIVCondition<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">src</span><span style=\"color: navy\"> : </span>input, <b>target</b> <span style=\"color: maroon\">tgt</span><span style=\"color: navy\"> : </span>output<span style=\"color: navy\">)</span><span style=\"color: navy\"> {\r\n</span> <span style=\"color: navy\">// </span><span style=\"color: green\">set bundle type for the output bundle</span>\r\n src<span style=\"color: navy\"><b> -> </b></span>tgt.type = <span style=\"color: blue\">'transaction'</span> <i>"setBundleType"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">// </span><span style=\"color: green\">loop through patients in input bundle</span>\r\n src.entry<b> as </b><span style=\"color: maroon\">entry</span><span style=\"color: navy\"><b> -> </b></span>tgt.entry<b> as </b><span style=\"color: maroon\">tentry</span><b> then</b><span style=\"color: navy\"> {\r\n</span> entry.resource<span style=\"color: navy\"> : </span>Patient<b> as </b><span style=\"color: maroon\">patient</span><span style=\"color: navy\"><b> -> </b></span> tentry.resource = <span style=\"color: maroon\">patient</span><span style=\"color: navy\">, </span> tentry.request<b> as </b><span style=\"color: maroon\">newrequest</span><b> then</b><span style=\"color: navy\"> {\r\n</span> entry<span style=\"color: navy\"><b> -> </b></span>tentry.fullUrl = <span style=\"color: navy\">(</span>'urn:uuid:' & patient.id<span style=\"color: navy\">)</span> <i>"setFullUrl"</i><span style=\"color: navy\">;</span>\r\n entry<span style=\"color: navy\"><b> -> </b></span> newrequest.method = <span style=\"color: blue\">'PUT'</span><span style=\"color: navy\">, </span> newrequest.url = <span style=\"color: navy\">(</span>'Patient/' & patient.id<span style=\"color: navy\">)</span> <i>"setPatientRequest"</i><span style=\"color: navy\">;</span>\r\n entry<span style=\"color: navy\"><b> -> </b></span> tgt.entry<b> as </b><span style=\"color: maroon\">pentry</span><span style=\"color: navy\">, </span> pentry.resource = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Provenance'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">prov</span><span style=\"color: navy\">, </span> <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">pid</span><span style=\"color: navy\">, </span> pentry.request<b> as </b><span style=\"color: maroon\">prequest</span><b> then</b><span style=\"color: navy\"> {\r\n</span> patient<span style=\"color: navy\"><b> -> </b></span>prov.id = <span style=\"color: maroon\">pid</span> <i>"setPId"</i><span style=\"color: navy\">;</span>\r\n patient<span style=\"color: navy\"><b> -> </b></span>pentry.fullUrl = <span style=\"color: navy\">(</span>'urn:uuid:' & pid<span style=\"color: navy\">)</span> <i>"setFullUrl"</i><span style=\"color: navy\">;</span>\r\n patient<span style=\"color: navy\"><b> -> </b></span> prequest.method = <span style=\"color: blue\">'PUT'</span><span style=\"color: navy\">, </span> prequest.url = <span style=\"color: navy\">(</span>'Provenance/' & pid<span style=\"color: navy\">)</span> <i>"setrequest"</i><span style=\"color: navy\">;</span>\r\n patient<span style=\"color: navy\"><b> -> </b></span>prov.target<b> as </b><span style=\"color: maroon\">ptarg</span><b> then</b><span style=\"color: navy\"> {\r\n</span> patient<span style=\"color: navy\"><b> -> </b></span>ptarg.reference = <span style=\"color: navy\">(</span>'urn:uuid:' & patient.id<span style=\"color: navy\">)</span> <i>"setTargetRef"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"setTarget"</i><span style=\"color: navy\">;</span>\r\n patient<span style=\"color: navy\"><b> -> </b></span>prov.entity<b> as </b><span style=\"color: maroon\">entity</span><b> then</b><span style=\"color: navy\"> {\r\n</span> patient<span style=\"color: navy\"><b> -> </b></span>entity.role = <span style=\"color: blue\">'source'</span> <i>"setRole"</i><span style=\"color: navy\">;</span>\r\n patient<span style=\"color: navy\"><b> -> </b></span>entity.what<b> as </b><span style=\"color: maroon\">pwhat</span><b> then </b>setProvenanceFromBundleId<span style=\"color: navy\">(</span><span style=\"color: maroon\">src</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">pwhat</span><span style=\"color: navy\">)</span> <i>"setWhatId"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"setEntity"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"setProvenance"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">// </span><span style=\"color: green\">for observations of that patient look for art program enrollment</span>\r\n <span style=\"color: navy\">// </span><span style=\"color: green\">create a condition resource in output with uuid</span>\r\n src.entry<b> as </b><span style=\"color: maroon\">obsentry</span><b> where </b>resource.is(Observation) and resource.subject.exists(reference = ('Patient/' & patient.id)) and resource.code.exists(coding.exists((system = 'https://cielterminology.org') and (code = '160540')))<span style=\"color: navy\"><b> -> </b></span> tgt.entry<b> as </b><span style=\"color: maroon\">newentry</span><span style=\"color: navy\">, </span> newentry.resource = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Condition'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">cond</span><span style=\"color: navy\">, </span> <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">cid</span><b> then</b><span style=\"color: navy\"> {\r\n</span> obsentry.resource<b> as </b><span style=\"color: maroon\">obs</span><span style=\"color: navy\"><b> -> </b></span> newentry.fullUrl = <span style=\"color: navy\">(</span>'urn:uuid:' & cid<span style=\"color: navy\">)</span><span style=\"color: navy\">, </span> newentry.request<b> as </b><span style=\"color: maroon\">newrequest</span><b> then</b><span style=\"color: navy\"> {\r\n</span> obsentry<span style=\"color: navy\"><b> -> </b></span>cond.id = <span style=\"color: maroon\">cid</span> <i>"setCId"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">// </span><span style=\"color: green\">setrequest rule for resource in transaction bundle</span>\r\n <span style=\"color: navy\">// </span><span style=\"color: green\">needs to be processed properly before putting on existing data on fhir server</span>\r\n obsentry<span style=\"color: navy\"><b> -> </b></span> newrequest.method = <span style=\"color: blue\">'PUT'</span><span style=\"color: navy\">, </span> newrequest.url = <span style=\"color: navy\">(</span>'Condition/' & cid<span style=\"color: navy\">)</span> <i>"setrequest"</i><span style=\"color: navy\">;</span>\r\n patient<span style=\"color: navy\"><b> -> </b></span>cond.subject<b> as </b><span style=\"color: maroon\">subject</span><b> then</b><span style=\"color: navy\"> {\r\n</span> patient<span style=\"color: navy\"><b> -> </b></span>subject.reference = <b>reference</b><span style=\"color: navy\">(</span><span style=\"color: maroon\">patient</span><span style=\"color: navy\">)</span> <i>"setSubjectRef"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"setSubject"</i><span style=\"color: navy\">;</span>\r\n obs.effective<b> as </b><span style=\"color: maroon\">effective</span><span style=\"color: navy\"><b> -> </b></span>cond.onset = <span style=\"color: maroon\">effective</span> <i>"setOnset"</i><span style=\"color: navy\">;</span>\r\n obsentry<span style=\"color: navy\"><b> -> </b></span>cond.clinicalStatus = <b>cc</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'http://terminology.hl7.org/CodeSystem/condition-clinical'</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'active'</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'Active'</span><span style=\"color: navy\">)</span> <i>"setClinicalStatus"</i><span style=\"color: navy\">;</span>\r\n obsentry<span style=\"color: navy\"><b> -> </b></span>cond.code = <b>cc</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'http://smart.who.int/hiv/CodeSystem/HIVConcepts'</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'HIV.B.DE116'</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'HIV-positive'</span><span style=\"color: navy\">)</span> <i>"setCode"</i><span style=\"color: navy\">;</span>\r\n obsentry<span style=\"color: navy\"><b> -> </b></span>cond.category = <b>cc</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'http://terminology.hl7.org/CodeSystem/condition-category'</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'encounter-diagnosis'</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'Encounter Diagnosis'</span><span style=\"color: navy\">)</span> <i>"setCategory"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">// </span><span style=\"color: green\">create provenance resource to document input/output resources links</span>\r\n obs<span style=\"color: navy\"><b> -> </b></span> tgt.entry<b> as </b><span style=\"color: maroon\">pentry</span><span style=\"color: navy\">, </span> pentry.resource = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Provenance'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">prov</span><span style=\"color: navy\">, </span> <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">pid</span><span style=\"color: navy\">, </span> pentry.request<b> as </b><span style=\"color: maroon\">prequest</span><b> then</b><span style=\"color: navy\"> {\r\n</span> obs<span style=\"color: navy\"><b> -> </b></span>prov.id = <span style=\"color: maroon\">pid</span> <i>"setPId"</i><span style=\"color: navy\">;</span>\r\n obs<span style=\"color: navy\"><b> -> </b></span>pentry.fullUrl = <span style=\"color: navy\">(</span>'urn:uuid:' & pid<span style=\"color: navy\">)</span> <i>"setFullUrl"</i><span style=\"color: navy\">;</span>\r\n obs<span style=\"color: navy\"><b> -> </b></span> prequest.method = <span style=\"color: blue\">'PUT'</span><span style=\"color: navy\">, </span> prequest.url = <span style=\"color: navy\">(</span>'Provenance/' & pid<span style=\"color: navy\">)</span> <i>"setrequest"</i><span style=\"color: navy\">;</span>\r\n obs<span style=\"color: navy\"><b> -> </b></span>prov.target<b> as </b><span style=\"color: maroon\">ptarg</span><b> then</b><span style=\"color: navy\"> {\r\n</span> obs<span style=\"color: navy\"><b> -> </b></span>ptarg.reference = <span style=\"color: navy\">(</span>'urn:uuid:' & cid<span style=\"color: navy\">)</span> <i>"setTargetRef"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"setTarget"</i><span style=\"color: navy\">;</span>\r\n obs<span style=\"color: navy\"><b> -> </b></span>prov.entity<b> as </b><span style=\"color: maroon\">entity</span><b> then</b><span style=\"color: navy\"> {\r\n</span> obs<span style=\"color: navy\"><b> -> </b></span>entity.role = <span style=\"color: blue\">'source'</span> <i>"setRole"</i><span style=\"color: navy\">;</span>\r\n obs<span style=\"color: navy\"><b> -> </b></span>entity.what<b> as </b><span style=\"color: maroon\">pwhat</span><b> then </b>setProvenanceFromBundleId<span style=\"color: navy\">(</span><span style=\"color: maroon\">src</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">pwhat</span><span style=\"color: navy\">)</span> <i>"setWhatId"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"setEntity"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"setProvenance"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"setCondition"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"getOnARTObservation"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">// </span><span style=\"color: green\">for observations of that patient look for return visit date</span>\r\n <span style=\"color: navy\">// </span><span style=\"color: green\">create a medication request resource in output with uuid</span>\r\n src.entry<b> as </b><span style=\"color: maroon\">obsentry</span><b> where </b>resource.is(Observation) and resource.subject.exists(reference = ('Patient/' & patient.id)) and resource.code.exists(coding.exists((system = 'https://cielterminology.org') and (code = '5096')))<span style=\"color: navy\"><b> -> </b></span> tgt.entry<b> as </b><span style=\"color: maroon\">newentry</span><span style=\"color: navy\">, </span> newentry.resource = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'MedicationStatement'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">ms</span><span style=\"color: navy\">, </span> <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">msid</span><b> then</b><span style=\"color: navy\"> {\r\n</span> obsentry.resource<b> as </b><span style=\"color: maroon\">obs</span><span style=\"color: navy\"><b> -> </b></span> newentry.fullUrl = <span style=\"color: navy\">(</span>'urn:uuid:' & msid<span style=\"color: navy\">)</span><span style=\"color: navy\">, </span> newentry.request<b> as </b><span style=\"color: maroon\">newrequest</span><b> then</b><span style=\"color: navy\"> {\r\n</span> obsentry<span style=\"color: navy\"><b> -> </b></span>ms.id = <span style=\"color: maroon\">msid</span> <i>"setMSId"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">// </span><span style=\"color: green\">setrequest rule for resource in transaction bundle</span>\r\n <span style=\"color: navy\">// </span><span style=\"color: green\">needs to be processed properly before putting on existing data on fhir server</span>\r\n obsentry<span style=\"color: navy\"><b> -> </b></span> newrequest.method = <span style=\"color: blue\">'PUT'</span><span style=\"color: navy\">, </span> newrequest.url = <span style=\"color: navy\">(</span>'MedicationStatement/' & msid<span style=\"color: navy\">)</span> <i>"setrequest"</i><span style=\"color: navy\">;</span>\r\n patient<span style=\"color: navy\"><b> -> </b></span>ms.subject<b> as </b><span style=\"color: maroon\">subject</span><b> then</b><span style=\"color: navy\"> {\r\n</span> patient<span style=\"color: navy\"><b> -> </b></span>subject.reference = <b>reference</b><span style=\"color: navy\">(</span><span style=\"color: maroon\">patient</span><span style=\"color: navy\">)</span> <i>"setSubjectRef"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"setSubject"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">// </span><span style=\"color: green\">obs.effective as effective -> ms.effective = effective "setEffective";</span>\r\n obs.effective<span style=\"color: navy\"> : </span>dateTime<b> as </b><span style=\"color: maroon\">effective</span><span style=\"color: navy\"><b> -> </b></span>ms.effective = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Period'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">mseffective</span><b> then</b><span style=\"color: navy\"> {\r\n</span> effective<span style=\"color: navy\"><b> -> </b></span>mseffective.start = <span style=\"color: maroon\">effective</span> <i>"setEffectiveStart"</i><span style=\"color: navy\">;</span>\r\n effective<span style=\"color: navy\"><b> -> </b></span>mseffective.end = <span style=\"color: navy\">(</span>%effective + 30 'days'<span style=\"color: navy\">)</span> <i>"setEffectiveEnd"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"setEffective"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">// </span><span style=\"color: green\">not correct in hiv l3</span>\r\n obsentry<span style=\"color: navy\"><b> -> </b></span>ms.status = <span style=\"color: blue\">'active'</span> <i>"setStatus"</i><span style=\"color: navy\">;</span>\r\n obsentry<span style=\"color: navy\"><b> -> </b></span>ms.reasonCode = <b>cc</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'http://smart.who.int/hiv/CodeSystem/HIVConcepts'</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'HIV.H.DE47'</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'On ART'</span><span style=\"color: navy\">)</span> <i>"setMSReasonCode"</i><span style=\"color: navy\">;</span>\r\n obsentry<span style=\"color: navy\"><b> -> </b></span>ms.medication = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'CodeableConcept'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">medication</span><b> then</b><span style=\"color: navy\"> {\r\n</span> obsentry<span style=\"color: navy\"><b> -> </b></span>medication.coding<b> as </b><span style=\"color: maroon\">coding</span><b> then</b><span style=\"color: navy\"> {\r\n</span> obsentry<span style=\"color: navy\"><b> -> </b></span> coding.code = <span style=\"color: blue\">'160119'</span><span style=\"color: navy\">, </span> coding.display = <span style=\"color: blue\">'CURRENTLY TAKING ARV'</span><span style=\"color: navy\">, </span> coding.system = <span style=\"color: blue\">'https://cielterminology.org'</span> <i>"setMSCoding"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"setMSCoding"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"SetMSMedication"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">// </span><span style=\"color: green\">create provenance resource to document input/output resources links</span>\r\n obs<span style=\"color: navy\"><b> -> </b></span> tgt.entry<b> as </b><span style=\"color: maroon\">pentry</span><span style=\"color: navy\">, </span> pentry.resource = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Provenance'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">prov</span><span style=\"color: navy\">, </span> <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">pid</span><span style=\"color: navy\">, </span> pentry.request<b> as </b><span style=\"color: maroon\">prequest</span><b> then</b><span style=\"color: navy\"> {\r\n</span> obs<span style=\"color: navy\"><b> -> </b></span>prov.id = <span style=\"color: maroon\">pid</span> <i>"setPId"</i><span style=\"color: navy\">;</span>\r\n obs<span style=\"color: navy\"><b> -> </b></span>pentry.fullUrl = <span style=\"color: navy\">(</span>'urn:uuid:' & pid<span style=\"color: navy\">)</span> <i>"setFullUrl"</i><span style=\"color: navy\">;</span>\r\n obs<span style=\"color: navy\"><b> -> </b></span> prequest.method = <span style=\"color: blue\">'PUT'</span><span style=\"color: navy\">, </span> prequest.url = <span style=\"color: navy\">(</span>'Provenance/' & pid<span style=\"color: navy\">)</span> <i>"setrequest"</i><span style=\"color: navy\">;</span>\r\n obs<span style=\"color: navy\"><b> -> </b></span>prov.target<b> as </b><span style=\"color: maroon\">ptarg</span><b> then</b><span style=\"color: navy\"> {\r\n</span> obs<span style=\"color: navy\"><b> -> </b></span>ptarg.reference = <span style=\"color: navy\">(</span>'urn:uuid:' & msid<span style=\"color: navy\">)</span> <i>"setTargetRef"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"setTarget"</i><span style=\"color: navy\">;</span>\r\n obs<span style=\"color: navy\"><b> -> </b></span>prov.entity<b> as </b><span style=\"color: maroon\">entity</span><b> then</b><span style=\"color: navy\"> {\r\n</span> obs<span style=\"color: navy\"><b> -> </b></span>entity.role = <span style=\"color: blue\">'source'</span> <i>"setRole"</i><span style=\"color: navy\">;</span>\r\n obs<span style=\"color: navy\"><b> -> </b></span>entity.what<b> as </b><span style=\"color: maroon\">pwhat</span><b> then </b>setProvenanceFromBundleId<span style=\"color: navy\">(</span><span style=\"color: maroon\">src</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">pwhat</span><span style=\"color: navy\">)</span> <i>"setWhatId"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"setEntity"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"setProvenance"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"setMedicationStatement"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"getVisitObservation"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">// </span><span style=\"color: green\">create observation resource with the positive hiv test codes</span>\r\n <span style=\"color: navy\">// </span><span style=\"color: green\">this will have to be one for hiv positive and one for hiv negative</span>\r\n src.entry<b> as </b><span style=\"color: maroon\">obsentry</span><b> where </b>resource.is(Observation) and resource.subject.exists(reference = ('Patient/' & patient.id)) and resource.code.exists(coding.exists((system = 'https://cielterminology.org') and (code = '159427')))<span style=\"color: navy\"><b> -> </b></span> tgt.entry<b> as </b><span style=\"color: maroon\">newentry</span><span style=\"color: navy\">, </span> newentry.resource = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Observation'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">observe</span><span style=\"color: navy\">, </span> <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">obsd</span><b> then</b><span style=\"color: navy\"> {\r\n</span> obsentry.resource<b> as </b><span style=\"color: maroon\">obs</span><span style=\"color: navy\"><b> -> </b></span> newentry.fullUrl = <span style=\"color: navy\">(</span>'urn:uuid:' & obsd<span style=\"color: navy\">)</span><span style=\"color: navy\">, </span> newentry.request<b> as </b><span style=\"color: maroon\">newrequest</span><b> then</b><span style=\"color: navy\"> {\r\n</span> obsentry<span style=\"color: navy\"><b> -> </b></span>observe.id = <span style=\"color: maroon\">obsd</span> <i>"setOBSd"</i><span style=\"color: navy\">;</span>\r\n obsentry<span style=\"color: navy\"><b> -> </b></span> newrequest.method = <span style=\"color: blue\">'PUT'</span><span style=\"color: navy\">, </span> newrequest.url = <span style=\"color: navy\">(</span>'Observation/' & obsd<span style=\"color: navy\">)</span> <i>"setrequest"</i><span style=\"color: navy\">;</span>\r\n patient<span style=\"color: navy\"><b> -> </b></span>observe.subject<b> as </b><span style=\"color: maroon\">subject</span><b> then</b><span style=\"color: navy\"> {\r\n</span> patient<span style=\"color: navy\"><b> -> </b></span>subject.reference = <b>reference</b><span style=\"color: navy\">(</span><span style=\"color: maroon\">patient</span><span style=\"color: navy\">)</span> <i>"setSubjectRef"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"setSubject"</i><span style=\"color: navy\">;</span>\r\n obs.effective<b> as </b><span style=\"color: maroon\">effective</span><span style=\"color: navy\"><b> -> </b></span>observe.effective = <span style=\"color: maroon\">effective</span> <i>"setOnset"</i><span style=\"color: navy\">;</span>\r\n obs.code<b> as </b><span style=\"color: maroon\">code</span><span style=\"color: navy\"><b> -> </b></span>observe.code = <span style=\"color: maroon\">code</span> <i>"setCode"</i><span style=\"color: navy\">;</span>\r\n obs.value<span style=\"color: navy\"> : </span>CodeableConcept<b> as </b><span style=\"color: maroon\">value</span><b> where </b>coding.exists((system = 'https://cielterminology.org') and (code = '664'))<span style=\"color: navy\"><b> -> </b></span>observe.value = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'CodeableConcept'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">val</span><b> then</b><span style=\"color: navy\"> {\r\n</span> value<span style=\"color: navy\"><b> -> </b></span>val.coding<b> as </b><span style=\"color: maroon\">coding</span><b> then</b><span style=\"color: navy\"> {\r\n</span> value<span style=\"color: navy\"><b> -> </b></span> coding.system = <span style=\"color: blue\">'http://smart.who.int/hiv/CodeSystem/HIVConcepts'</span><span style=\"color: navy\">, </span> coding.code = <span style=\"color: blue\">'HIV.B.DE117'</span><span style=\"color: navy\">, </span> coding.display = <span style=\"color: blue\">'HIV-negative'</span> <i>"setNegativeCC"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"setNegativeCoding"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"setValueNegative"</i><span style=\"color: navy\">;</span>\r\n obs.value<span style=\"color: navy\"> : </span>CodeableConcept<b> as </b><span style=\"color: maroon\">value</span><b> where </b>coding.exists((system = 'https://cielterminology.org') and (code = '138571'))<span style=\"color: navy\"><b> -> </b></span>observe.value = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'CodeableConcept'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">val</span><b> then</b><span style=\"color: navy\"> {\r\n</span> value<span style=\"color: navy\"><b> -> </b></span>val.coding<b> as </b><span style=\"color: maroon\">coding</span><b> then</b><span style=\"color: navy\"> {\r\n</span> value<span style=\"color: navy\"><b> -> </b></span> coding.system = <span style=\"color: blue\">'http://smart.who.int/hiv/CodeSystem/HIVConcepts'</span><span style=\"color: navy\">, </span> coding.code = <span style=\"color: blue\">'HIV.B.DE116'</span><span style=\"color: navy\">, </span> coding.display = <span style=\"color: blue\">'HIV-positive'</span> <i>"setPositiveCC"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"setPositiveCoding"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"setValuePositive1"</i><span style=\"color: navy\">;</span>\r\n obs.value<span style=\"color: navy\"> : </span>CodeableConcept<b> as </b><span style=\"color: maroon\">value</span><b> where </b>coding.exists((system = 'https://cielterminology.org') and (code = '703'))<span style=\"color: navy\"><b> -> </b></span>observe.value = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'CodeableConcept'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">val</span><b> then</b><span style=\"color: navy\"> {\r\n</span> value<span style=\"color: navy\"><b> -> </b></span>val.coding<b> as </b><span style=\"color: maroon\">coding</span><b> then</b><span style=\"color: navy\"> {\r\n</span> value<span style=\"color: navy\"><b> -> </b></span> coding.system = <span style=\"color: blue\">'http://smart.who.int/hiv/CodeSystem/HIVConcepts'</span><span style=\"color: navy\">, </span> coding.code = <span style=\"color: blue\">'HIV.B.DE116'</span><span style=\"color: navy\">, </span> coding.display = <span style=\"color: blue\">'HIV-positive'</span> <i>"setPositiveCC"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"setPositiveCoding"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"setValuePositive2"</i><span style=\"color: navy\">;</span>\r\n obsentry<span style=\"color: navy\"><b> -> </b></span>observe.status = <b>cc</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'http://hl7.org/fhir/observation-status'</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'final'</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'Final'</span><span style=\"color: navy\">)</span> <i>"setStatus"</i><span style=\"color: navy\">;</span>\r\n obs<span style=\"color: navy\"><b> -> </b></span> tgt.entry<b> as </b><span style=\"color: maroon\">pentry</span><span style=\"color: navy\">, </span> pentry.resource = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Provenance'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">prov</span><span style=\"color: navy\">, </span> <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">pid</span><span style=\"color: navy\">, </span> pentry.request<b> as </b><span style=\"color: maroon\">prequest</span><b> then</b><span style=\"color: navy\"> {\r\n</span> obs<span style=\"color: navy\"><b> -> </b></span>prov.id = <span style=\"color: maroon\">pid</span> <i>"setPId"</i><span style=\"color: navy\">;</span>\r\n obs<span style=\"color: navy\"><b> -> </b></span>pentry.fullUrl = <span style=\"color: navy\">(</span>'urn:uuid:' & pid<span style=\"color: navy\">)</span> <i>"setFullUrl"</i><span style=\"color: navy\">;</span>\r\n obs<span style=\"color: navy\"><b> -> </b></span> prequest.method = <span style=\"color: blue\">'PUT'</span><span style=\"color: navy\">, </span> prequest.url = <span style=\"color: navy\">(</span>'Provenance/' & pid<span style=\"color: navy\">)</span> <i>"setrequest"</i><span style=\"color: navy\">;</span>\r\n obs<span style=\"color: navy\"><b> -> </b></span>prov.target<b> as </b><span style=\"color: maroon\">ptarg</span><b> then</b><span style=\"color: navy\"> {\r\n</span> obs<span style=\"color: navy\"><b> -> </b></span>ptarg.reference = <span style=\"color: navy\">(</span>'urn:uuid:' & cid<span style=\"color: navy\">)</span> <i>"setTargetRef"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"setTarget"</i><span style=\"color: navy\">;</span>\r\n obs<span style=\"color: navy\"><b> -> </b></span>prov.entity<b> as </b><span style=\"color: maroon\">entity</span><b> then</b><span style=\"color: navy\"> {\r\n</span> obs<span style=\"color: navy\"><b> -> </b></span>entity.role = <span style=\"color: blue\">'source'</span> <i>"setRole"</i><span style=\"color: navy\">;</span>\r\n obs<span style=\"color: navy\"><b> -> </b></span>entity.what<b> as </b><span style=\"color: maroon\">pwhat</span><b> then </b>setProvenanceFromBundleId<span style=\"color: navy\">(</span><span style=\"color: maroon\">src</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">pwhat</span><span style=\"color: navy\">)</span> <i>"setWhatId"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"setEntity"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"setProvenance"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"setHIVPositiveTest"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"getOnARTObservation"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"patientResource"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"copyPatient"</i><span style=\"color: navy\">;</span>\r\n<span style=\"color: navy\">}\r\n\r\n</span><b>group </b>setProvenanceFromBundleId<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">bundle</span><span style=\"color: navy\"> : </span>input, <b>target</b> <span style=\"color: maroon\">provwhat</span><span style=\"color: navy\"> : </span>Reference<span style=\"color: navy\">)</span><span style=\"color: navy\"> {\r\n</span> bundle.id<b> as </b><span style=\"color: maroon\">bundleid</span><span style=\"color: navy\"><b> -> </b></span>provwhat.identifier<b> as </b><span style=\"color: maroon\">whatid</span><b> then</b><span style=\"color: navy\"> {\r\n</span> bundleid<span style=\"color: navy\"><b> -> </b></span>whatid.value = <span style=\"color: navy\">(</span>'Bundle/' & bundleid<span style=\"color: navy\">)</span> <i>"setWhatIdValue"</i><span style=\"color: navy\">;</span>\r\n <span style=\"color: navy\">}</span> <i>"setWhatId"</i><span style=\"color: navy\">;</span>\r\n<span style=\"color: navy\">}\r\n\r\n</span></pre></div>"
},
"url" : "https://IntelliSOFT-Consulting.github.io/HIV-FHIR-IG/StructureMap/HIVObservationHIVCondition",
"version" : "0.1.0",
"name" : "HIVObservationHIVCondition",
"status" : "draft",
"date" : "2024-09-18T19:24:24+00:00",
"publisher" : "intellisoftkenya",
"contact" : [
{
"name" : "intellisoftkenya",
"telecom" : [
{
"system" : "url",
"value" : "https://www.intellisoftkenya.com/"
}
]
}
],
"description" : "declare the structure defs used",
"structure" : [
{
"url" : "http://hl7.org/fhir/StructureDefinition/Bundle",
"mode" : "source",
"alias" : "input"
},
{
"url" : "http://hl7.org/fhir/StructureDefinition/Bundle",
"mode" : "target",
"alias" : "output"
}
],
"group" : [
{
"name" : "HIVObservationHIVCondition",
"typeMode" : "none",
"documentation" : "declare group with local vars (src, tgt) and their aliases\r\nanything ending with semicolon is a rule",
"input" : [
{
"name" : "src",
"type" : "input",
"mode" : "source"
},
{
"name" : "tgt",
"type" : "output",
"mode" : "target"
}
],
"rule" : [
{
"name" : "setBundleType",
"source" : [
{
"context" : "src"
}
],
"target" : [
{
"context" : "tgt",
"contextType" : "variable",
"element" : "type",
"transform" : "copy",
"parameter" : [
{
"valueString" : "transaction"
}
]
}
]
},
{
"name" : "copyPatient",
"source" : [
{
"context" : "src",
"element" : "entry",
"variable" : "entry"
}
],
"target" : [
{
"context" : "tgt",
"contextType" : "variable",
"element" : "entry",
"variable" : "tentry"
}
],
"rule" : [
{
"name" : "patientResource",
"source" : [
{
"context" : "entry",
"type" : "Patient",
"element" : "resource",
"variable" : "patient"
}
],
"target" : [
{
"context" : "tentry",
"contextType" : "variable",
"element" : "resource",
"transform" : "copy",
"parameter" : [
{
"valueId" : "patient"
}
]
},
{
"context" : "tentry",
"contextType" : "variable",
"element" : "request",
"variable" : "newrequest"
}
],
"rule" : [
{
"name" : "setFullUrl",
"source" : [
{
"context" : "entry"
}
],
"target" : [
{
"context" : "tentry",
"contextType" : "variable",
"element" : "fullUrl",
"transform" : "evaluate",
"parameter" : [
{
"valueString" : "'urn:uuid:' & patient.id"
}
]
}
]
},
{
"name" : "setPatientRequest",
"source" : [
{
"context" : "entry"
}
],
"target" : [
{
"context" : "newrequest",
"contextType" : "variable",
"element" : "method",
"transform" : "copy",
"parameter" : [
{
"valueString" : "PUT"
}
]
},
{
"context" : "newrequest",
"contextType" : "variable",
"element" : "url",
"transform" : "evaluate",
"parameter" : [
{
"valueString" : "'Patient/' & patient.id"
}
]
}
]
},
{
"name" : "setProvenance",
"source" : [
{
"context" : "entry"
}
],
"target" : [
{
"context" : "tgt",
"contextType" : "variable",
"element" : "entry",
"variable" : "pentry"
},
{
"context" : "pentry",
"contextType" : "variable",
"element" : "resource",
"variable" : "prov",
"transform" : "create",
"parameter" : [
{
"valueString" : "Provenance"
}
]
},
{
"contextType" : "variable",
"variable" : "pid",
"transform" : "uuid"
},
{
"context" : "pentry",
"contextType" : "variable",
"element" : "request",
"variable" : "prequest"
}
],
"rule" : [
{
"name" : "setPId",
"source" : [
{
"context" : "patient"
}
],
"target" : [
{
"context" : "prov",
"contextType" : "variable",
"element" : "id",
"transform" : "copy",
"parameter" : [
{
"valueId" : "pid"
}
]
}
]
},
{
"name" : "setFullUrl",
"source" : [
{
"context" : "patient"
}
],
"target" : [
{
"context" : "pentry",
"contextType" : "variable",
"element" : "fullUrl",
"transform" : "evaluate",
"parameter" : [
{
"valueString" : "'urn:uuid:' & pid"
}
]
}
]
},
{
"name" : "setrequest",
"source" : [
{
"context" : "patient"
}
],
"target" : [
{
"context" : "prequest",
"contextType" : "variable",
"element" : "method",
"transform" : "copy",
"parameter" : [
{
"valueString" : "PUT"
}
]
},
{
"context" : "prequest",
"contextType" : "variable",
"element" : "url",
"transform" : "evaluate",
"parameter" : [
{
"valueString" : "'Provenance/' & pid"
}
]
}
]
},
{
"name" : "setTarget",
"source" : [
{
"context" : "patient"
}
],
"target" : [
{
"context" : "prov",
"contextType" : "variable",
"element" : "target",
"variable" : "ptarg"
}
],
"rule" : [
{
"name" : "setTargetRef",
"source" : [
{
"context" : "patient"
}
],
"target" : [
{
"context" : "ptarg",
"contextType" : "variable",
"element" : "reference",
"transform" : "evaluate",
"parameter" : [
{
"valueString" : "'urn:uuid:' & patient.id"
}
]
}
]
}
]
},
{
"name" : "setEntity",
"source" : [
{
"context" : "patient"
}
],
"target" : [
{
"context" : "prov",
"contextType" : "variable",
"element" : "entity",
"variable" : "entity"
}
],
"rule" : [
{
"name" : "setRole",
"source" : [
{
"context" : "patient"
}
],
"target" : [
{
"context" : "entity",
"contextType" : "variable",
"element" : "role",
"transform" : "copy",
"parameter" : [
{
"valueString" : "source"
}
]
}
]
},
{
"name" : "setWhatId",
"source" : [
{
"context" : "patient"
}
],
"target" : [
{
"context" : "entity",
"contextType" : "variable",
"element" : "what",
"variable" : "pwhat"
}
],
"dependent" : [
{
"name" : "setProvenanceFromBundleId",
"variable" : [
"src",
"pwhat"
]
}
]
}
]
}
]
},
{
"name" : "getOnARTObservation",
"source" : [
{
"context" : "src",
"element" : "entry",
"variable" : "obsentry",
"condition" : "resource.is(Observation) and resource.subject.exists(reference = ('Patient/' & patient.id)) and resource.code.exists(coding.exists((system = 'https://cielterminology.org') and (code = '160540')))"
}
],
"target" : [
{
"context" : "tgt",
"contextType" : "variable",
"element" : "entry",
"variable" : "newentry"
},
{
"context" : "newentry",
"contextType" : "variable",
"element" : "resource",
"variable" : "cond",
"transform" : "create",
"parameter" : [
{
"valueString" : "Condition"
}
]
},
{
"contextType" : "variable",
"variable" : "cid",
"transform" : "uuid"
}
],
"rule" : [
{
"name" : "setCondition",
"source" : [
{
"context" : "obsentry",
"element" : "resource",
"variable" : "obs"
}
],
"target" : [
{
"context" : "newentry",
"contextType" : "variable",
"element" : "fullUrl",
"transform" : "evaluate",
"parameter" : [
{
"valueString" : "'urn:uuid:' & cid"
}
]
},
{
"context" : "newentry",
"contextType" : "variable",
"element" : "request",
"variable" : "newrequest"
}
],
"rule" : [
{
"name" : "setCId",
"source" : [
{
"context" : "obsentry"
}
],
"target" : [
{
"context" : "cond",
"contextType" : "variable",
"element" : "id",
"transform" : "copy",
"parameter" : [
{
"valueId" : "cid"
}
]
}
]
},
{
"name" : "setrequest",
"source" : [
{
"context" : "obsentry"
}
],
"target" : [
{
"context" : "newrequest",
"contextType" : "variable",
"element" : "method",
"transform" : "copy",
"parameter" : [
{
"valueString" : "PUT"
}
]
},
{
"context" : "newrequest",
"contextType" : "variable",
"element" : "url",
"transform" : "evaluate",
"parameter" : [
{
"valueString" : "'Condition/' & cid"
}
]
}
]
},
{
"name" : "setSubject",
"source" : [
{
"context" : "patient"
}
],
"target" : [
{
"context" : "cond",
"contextType" : "variable",
"element" : "subject",
"variable" : "subject"
}
],
"rule" : [
{
"name" : "setSubjectRef",
"source" : [
{
"context" : "patient"
}
],
"target" : [
{
"context" : "subject",
"contextType" : "variable",
"element" : "reference",
"transform" : "reference",
"parameter" : [
{
"valueId" : "patient"
}
]
}
]
}
]
},
{
"name" : "setOnset",
"source" : [
{
"context" : "obs",
"element" : "effective",
"variable" : "effective"
}
],
"target" : [
{
"context" : "cond",
"contextType" : "variable",
"element" : "onset",
"transform" : "copy",
"parameter" : [
{
"valueId" : "effective"
}
]
}
]
},
{
"name" : "setClinicalStatus",
"source" : [
{
"context" : "obsentry"
}
],
"target" : [
{
"context" : "cond",
"contextType" : "variable",
"element" : "clinicalStatus",
"transform" : "cc",
"parameter" : [
{
"valueString" : "http://terminology.hl7.org/CodeSystem/condition-clinical"
},
{
"valueString" : "active"
},
{
"valueString" : "Active"
}
]
}
]
},
{
"name" : "setCode",
"source" : [
{
"context" : "obsentry"
}
],
"target" : [
{
"context" : "cond",
"contextType" : "variable",
"element" : "code",
"transform" : "cc",
"parameter" : [
{
"valueString" : "http://smart.who.int/hiv/CodeSystem/HIVConcepts"
},
{
"valueString" : "HIV.B.DE116"
},
{
"valueString" : "HIV-positive"
}
]
}
]
},
{
"name" : "setCategory",
"source" : [
{
"context" : "obsentry"
}
],
"target" : [
{
"context" : "cond",
"contextType" : "variable",
"element" : "category",
"transform" : "cc",
"parameter" : [
{
"valueString" : "http://terminology.hl7.org/CodeSystem/condition-category"
},
{
"valueString" : "encounter-diagnosis"
},
{
"valueString" : "Encounter Diagnosis"
}
]
}
]
},
{
"name" : "setProvenance",
"source" : [
{
"context" : "obs"
}
],
"target" : [
{
"context" : "tgt",
"contextType" : "variable",
"element" : "entry",
"variable" : "pentry"
},
{
"context" : "pentry",
"contextType" : "variable",
"element" : "resource",
"variable" : "prov",
"transform" : "create",
"parameter" : [
{
"valueString" : "Provenance"
}
]
},
{
"contextType" : "variable",
"variable" : "pid",
"transform" : "uuid"
},
{
"context" : "pentry",
"contextType" : "variable",
"element" : "request",
"variable" : "prequest"
}
],
"rule" : [
{
"name" : "setPId",
"source" : [
{
"context" : "obs"
}
],
"target" : [
{
"context" : "prov",
"contextType" : "variable",
"element" : "id",
"transform" : "copy",
"parameter" : [
{
"valueId" : "pid"
}
]
}
]
},
{
"name" : "setFullUrl",
"source" : [
{
"context" : "obs"
}
],
"target" : [
{
"context" : "pentry",
"contextType" : "variable",
"element" : "fullUrl",
"transform" : "evaluate",
"parameter" : [
{
"valueString" : "'urn:uuid:' & pid"
}
]
}
]
},
{
"name" : "setrequest",
"source" : [
{
"context" : "obs"
}
],
"target" : [
{
"context" : "prequest",
"contextType" : "variable",
"element" : "method",
"transform" : "copy",
"parameter" : [
{
"valueString" : "PUT"
}
]
},
{
"context" : "prequest",
"contextType" : "variable",
"element" : "url",
"transform" : "evaluate",
"parameter" : [
{
"valueString" : "'Provenance/' & pid"
}
]
}
]
},
{
"name" : "setTarget",
"source" : [
{
"context" : "obs"
}
],
"target" : [
{
"context" : "prov",
"contextType" : "variable",
"element" : "target",
"variable" : "ptarg"
}
],
"rule" : [
{
"name" : "setTargetRef",
"source" : [
{
"context" : "obs"
}
],
"target" : [
{
"context" : "ptarg",
"contextType" : "variable",
"element" : "reference",
"transform" : "evaluate",
"parameter" : [
{
"valueString" : "'urn:uuid:' & cid"
}
]
}
]
}
]
},
{
"name" : "setEntity",
"source" : [
{
"context" : "obs"
}
],
"target" : [
{
"context" : "prov",
"contextType" : "variable",
"element" : "entity",
"variable" : "entity"
}
],
"rule" : [
{
"name" : "setRole",
"source" : [
{
"context" : "obs"
}
],
"target" : [
{
"context" : "entity",
"contextType" : "variable",
"element" : "role",
"transform" : "copy",
"parameter" : [
{
"valueString" : "source"
}
]
}
]
},
{
"name" : "setWhatId",
"source" : [
{
"context" : "obs"
}
],
"target" : [
{
"context" : "entity",
"contextType" : "variable",
"element" : "what",
"variable" : "pwhat"
}
],
"dependent" : [
{
"name" : "setProvenanceFromBundleId",
"variable" : [
"src",
"pwhat"
]
}
]
}
]
}
]
}
]
}
]
},
{
"name" : "getVisitObservation",
"source" : [
{
"context" : "src",
"element" : "entry",
"variable" : "obsentry",
"condition" : "resource.is(Observation) and resource.subject.exists(reference = ('Patient/' & patient.id)) and resource.code.exists(coding.exists((system = 'https://cielterminology.org') and (code = '5096')))"
}
],
"target" : [
{
"context" : "tgt",
"contextType" : "variable",
"element" : "entry",
"variable" : "newentry"
},
{
"context" : "newentry",
"contextType" : "variable",
"element" : "resource",
"variable" : "ms",
"transform" : "create",
"parameter" : [
{
"valueString" : "MedicationStatement"
}
]
},
{
"contextType" : "variable",
"variable" : "msid",
"transform" : "uuid"
}
],
"rule" : [
{
"name" : "setMedicationStatement",
"source" : [
{
"context" : "obsentry",
"element" : "resource",
"variable" : "obs"
}
],
"target" : [
{
"context" : "newentry",
"contextType" : "variable",
"element" : "fullUrl",
"transform" : "evaluate",
"parameter" : [
{
"valueString" : "'urn:uuid:' & msid"
}
]
},
{
"context" : "newentry",
"contextType" : "variable",
"element" : "request",
"variable" : "newrequest"
}
],
"rule" : [
{
"name" : "setMSId",
"source" : [
{
"context" : "obsentry"
}
],
"target" : [
{
"context" : "ms",
"contextType" : "variable",
"element" : "id",
"transform" : "copy",
"parameter" : [
{
"valueId" : "msid"
}
]
}
]
},
{
"name" : "setrequest",
"source" : [
{
"context" : "obsentry"
}
],
"target" : [
{
"context" : "newrequest",
"contextType" : "variable",
"element" : "method",
"transform" : "copy",
"parameter" : [
{
"valueString" : "PUT"
}
]
},
{
"context" : "newrequest",
"contextType" : "variable",
"element" : "url",
"transform" : "evaluate",
"parameter" : [
{
"valueString" : "'MedicationStatement/' & msid"
}
]
}
]
},
{
"name" : "setSubject",
"source" : [
{
"context" : "patient"
}
],
"target" : [
{
"context" : "ms",
"contextType" : "variable",
"element" : "subject",
"variable" : "subject"
}
],
"rule" : [
{
"name" : "setSubjectRef",
"source" : [
{
"context" : "patient"
}
],
"target" : [
{
"context" : "subject",
"contextType" : "variable",
"element" : "reference",
"transform" : "reference",
"parameter" : [
{
"valueId" : "patient"
}
]
}
]
}
]
},
{
"name" : "setEffective",
"source" : [
{
"context" : "obs",
"type" : "dateTime",
"element" : "effective",
"variable" : "effective"
}
],
"target" : [
{
"context" : "ms",
"contextType" : "variable",
"element" : "effective",
"variable" : "mseffective",
"transform" : "create",
"parameter" : [
{
"valueString" : "Period"
}
]
}
],
"rule" : [
{
"name" : "setEffectiveStart",
"source" : [
{
"context" : "effective"
}
],
"target" : [
{
"context" : "mseffective",
"contextType" : "variable",
"element" : "start",
"transform" : "copy",
"parameter" : [
{
"valueId" : "effective"
}
]
}
]
},
{
"name" : "setEffectiveEnd",
"source" : [
{
"context" : "effective"
}
],
"target" : [
{
"context" : "mseffective",
"contextType" : "variable",
"element" : "end",
"transform" : "evaluate",
"parameter" : [
{
"valueString" : "%effective + 30 'days'"
}
]
}
]
}
]
},
{
"name" : "setStatus",
"source" : [
{
"context" : "obsentry"
}
],
"target" : [
{
"context" : "ms",
"contextType" : "variable",
"element" : "status",
"transform" : "copy",
"parameter" : [
{
"valueString" : "active"
}
]
}
]
},
{
"name" : "setMSReasonCode",
"source" : [
{
"context" : "obsentry"
}
],
"target" : [
{
"context" : "ms",
"contextType" : "variable",
"element" : "reasonCode",
"transform" : "cc",
"parameter" : [
{
"valueString" : "http://smart.who.int/hiv/CodeSystem/HIVConcepts"
},
{
"valueString" : "HIV.H.DE47"
},
{
"valueString" : "On ART"
}
]
}
]
},
{
"name" : "SetMSMedication",
"source" : [
{
"context" : "obsentry"
}
],
"target" : [
{
"context" : "ms",
"contextType" : "variable",
"element" : "medication",
"variable" : "medication",
"transform" : "create",
"parameter" : [
{
"valueString" : "CodeableConcept"
}
]
}
],
"rule" : [
{
"name" : "setMSCoding",
"source" : [
{
"context" : "obsentry"
}
],
"target" : [
{
"context" : "medication",
"contextType" : "variable",
"element" : "coding",
"variable" : "coding"
}
],
"rule" : [
{
"name" : "setMSCoding",
"source" : [
{
"context" : "obsentry"
}
],
"target" : [
{
"context" : "coding",
"contextType" : "variable",
"element" : "code",
"transform" : "copy",
"parameter" : [
{
"valueString" : "160119"
}
]
},
{
"context" : "coding",
"contextType" : "variable",
"element" : "display",
"transform" : "copy",
"parameter" : [
{
"valueString" : "CURRENTLY TAKING ARV"
}
]
},
{
"context" : "coding",
"contextType" : "variable",
"element" : "system",
"transform" : "copy",
"parameter" : [
{
"valueString" : "https://cielterminology.org"
}
]
}
]
}
]
}
]
},
{
"name" : "setProvenance",
"source" : [
{
"context" : "obs"
}
],
"target" : [
{
"context" : "tgt",
"contextType" : "variable",
"element" : "entry",
"variable" : "pentry"
},
{
"context" : "pentry",
"contextType" : "variable",
"element" : "resource",
"variable" : "prov",
"transform" : "create",
"parameter" : [
{
"valueString" : "Provenance"
}
]
},
{
"contextType" : "variable",
"variable" : "pid",
"transform" : "uuid"
},
{
"context" : "pentry",
"contextType" : "variable",
"element" : "request",
"variable" : "prequest"
}
],
"rule" : [
{
"name" : "setPId",
"source" : [
{
"context" : "obs"
}
],
"target" : [
{
"context" : "prov",
"contextType" : "variable",
"element" : "id",
"transform" : "copy",
"parameter" : [
{
"valueId" : "pid"
}
]
}
]
},
{
"name" : "setFullUrl",
"source" : [
{
"context" : "obs"
}
],
"target" : [
{
"context" : "pentry",
"contextType" : "variable",
"element" : "fullUrl",
"transform" : "evaluate",
"parameter" : [
{
"valueString" : "'urn:uuid:' & pid"
}
]
}
]
},
{
"name" : "setrequest",
"source" : [
{
"context" : "obs"
}
],
"target" : [
{
"context" : "prequest",
"contextType" : "variable",
"element" : "method",
"transform" : "copy",
"parameter" : [
{
"valueString" : "PUT"
}
]
},
{
"context" : "prequest",
"contextType" : "variable",
"element" : "url",
"transform" : "evaluate",
"parameter" : [
{
"valueString" : "'Provenance/' & pid"
}
]
}
]
},
{
"name" : "setTarget",
"source" : [
{
"context" : "obs"
}
],
"target" : [
{
"context" : "prov",
"contextType" : "variable",
"element" : "target",
"variable" : "ptarg"
}
],
"rule" : [
{
"name" : "setTargetRef",
"source" : [
{
"context" : "obs"
}
],
"target" : [
{
"context" : "ptarg",
"contextType" : "variable",
"element" : "reference",
"transform" : "evaluate",
"parameter" : [
{
"valueString" : "'urn:uuid:' & msid"
}
]
}
]
}
]
},
{
"name" : "setEntity",
"source" : [
{
"context" : "obs"
}
],
"target" : [
{
"context" : "prov",
"contextType" : "variable",
"element" : "entity",
"variable" : "entity"
}
],
"rule" : [
{
"name" : "setRole",
"source" : [
{
"context" : "obs"
}
],
"target" : [
{
"context" : "entity",
"contextType" : "variable",
"element" : "role",
"transform" : "copy",
"parameter" : [
{
"valueString" : "source"
}
]
}
]
},
{
"name" : "setWhatId",
"source" : [
{
"context" : "obs"
}
],
"target" : [
{
"context" : "entity",
"contextType" : "variable",
"element" : "what",
"variable" : "pwhat"
}
],
"dependent" : [
{
"name" : "setProvenanceFromBundleId",
"variable" : [
"src",
"pwhat"
]
}
]
}
]
}
]
}
]
}
]
},
{
"name" : "getOnARTObservation",
"source" : [
{
"context" : "src",
"element" : "entry",
"variable" : "obsentry",
"condition" : "resource.is(Observation) and resource.subject.exists(reference = ('Patient/' & patient.id)) and resource.code.exists(coding.exists((system = 'https://cielterminology.org') and (code = '159427')))"
}
],
"target" : [
{
"context" : "tgt",
"contextType" : "variable",
"element" : "entry",
"variable" : "newentry"
},
{
"context" : "newentry",
"contextType" : "variable",
"element" : "resource",
"variable" : "observe",
"transform" : "create",
"parameter" : [
{
"valueString" : "Observation"
}
]
},
{
"contextType" : "variable",
"variable" : "obsd",
"transform" : "uuid"
}
],
"rule" : [
{
"name" : "setHIVPositiveTest",
"source" : [
{
"context" : "obsentry",
"element" : "resource",
"variable" : "obs"
}
],
"target" : [
{
"context" : "newentry",
"contextType" : "variable",
"element" : "fullUrl",
"transform" : "evaluate",
"parameter" : [
{
"valueString" : "'urn:uuid:' & obsd"
}
]
},
{
"context" : "newentry",
"contextType" : "variable",
"element" : "request",
"variable" : "newrequest"
}
],
"rule" : [
{
"name" : "setOBSd",
"source" : [
{
"context" : "obsentry"
}
],
"target" : [
{
"context" : "observe",
"contextType" : "variable",
"element" : "id",
"transform" : "copy",
"parameter" : [
{
"valueId" : "obsd"
}
]
}
]
},
{
"name" : "setrequest",
"source" : [
{
"context" : "obsentry"
}
],
"target" : [
{
"context" : "newrequest",
"contextType" : "variable",
"element" : "method",
"transform" : "copy",
"parameter" : [
{
"valueString" : "PUT"
}
]
},
{
"context" : "newrequest",
"contextType" : "variable",
"element" : "url",
"transform" : "evaluate",
"parameter" : [
{
"valueString" : "'Observation/' & obsd"
}
]
}
]
},
{
"name" : "setSubject",
"source" : [
{
"context" : "patient"
}
],
"target" : [
{
"context" : "observe",
"contextType" : "variable",
"element" : "subject",
"variable" : "subject"
}
],
"rule" : [
{
"name" : "setSubjectRef",
"source" : [
{
"context" : "patient"
}
],
"target" : [
{
"context" : "subject",
"contextType" : "variable",
"element" : "reference",
"transform" : "reference",
"parameter" : [
{
"valueId" : "patient"
}
]
}
]
}
]
},
{
"name" : "setOnset",
"source" : [
{
"context" : "obs",
"element" : "effective",
"variable" : "effective"
}
],
"target" : [
{
"context" : "observe",
"contextType" : "variable",
"element" : "effective",
"transform" : "copy",
"parameter" : [
{
"valueId" : "effective"
}
]
}
]
},
{
"name" : "setCode",
"source" : [
{
"context" : "obs",
"element" : "code",
"variable" : "code"
}
],
"target" : [
{
"context" : "observe",
"contextType" : "variable",
"element" : "code",
"transform" : "copy",
"parameter" : [
{
"valueId" : "code"
}
]
}
]
},
{
"name" : "setValueNegative",
"source" : [
{
"context" : "obs",
"type" : "CodeableConcept",
"element" : "value",
"variable" : "value",
"condition" : "coding.exists((system = 'https://cielterminology.org') and (code = '664'))"
}
],
"target" : [
{
"context" : "observe",
"contextType" : "variable",
"element" : "value",
"variable" : "val",
"transform" : "create",
"parameter" : [
{
"valueString" : "CodeableConcept"
}
]
}
],
"rule" : [
{
"name" : "setNegativeCoding",
"source" : [
{
"context" : "value"
}
],
"target" : [
{
"context" : "val",
"contextType" : "variable",
"element" : "coding",
"variable" : "coding"
}
],
"rule" : [
{
"name" : "setNegativeCC",
"source" : [
{
"context" : "value"
}
],
"target" : [
{
"context" : "coding",
"contextType" : "variable",
"element" : "system",
"transform" : "copy",
"parameter" : [
{
"valueString" : "http://smart.who.int/hiv/CodeSystem/HIVConcepts"
}
]
},
{
"context" : "coding",
"contextType" : "variable",
"element" : "code",
"transform" : "copy",
"parameter" : [
{
"valueString" : "HIV.B.DE117"
}
]
},
{
"context" : "coding",
"contextType" : "variable",
"element" : "display",
"transform" : "copy",
"parameter" : [
{
"valueString" : "HIV-negative"
}
]
}
]
}
]
}
]
},
{
"name" : "setValuePositive1",
"source" : [
{
"context" : "obs",
"type" : "CodeableConcept",
"element" : "value",
"variable" : "value",
"condition" : "coding.exists((system = 'https://cielterminology.org') and (code = '138571'))"
}
],
"target" : [
{
"context" : "observe",
"contextType" : "variable",
"element" : "value",
"variable" : "val",
"transform" : "create",
"parameter" : [
{
"valueString" : "CodeableConcept"
}
]
}
],
"rule" : [
{
"name" : "setPositiveCoding",
"source" : [
{
"context" : "value"
}
],
"target" : [
{
"context" : "val",
"contextType" : "variable",
"element" : "coding",
"variable" : "coding"
}
],
"rule" : [
{
"name" : "setPositiveCC",
"source" : [
{
"context" : "value"
}
],
"target" : [
{
"context" : "coding",
"contextType" : "variable",
"element" : "system",
"transform" : "copy",
"parameter" : [
{
"valueString" : "http://smart.who.int/hiv/CodeSystem/HIVConcepts"
}
]
},
{
"context" : "coding",
"contextType" : "variable",
"element" : "code",
"transform" : "copy",
"parameter" : [
{
"valueString" : "HIV.B.DE116"
}
]
},
{
"context" : "coding",
"contextType" : "variable",
"element" : "display",
"transform" : "copy",
"parameter" : [
{
"valueString" : "HIV-positive"
}
]
}
]
}
]
}
]
},
{
"name" : "setValuePositive2",
"source" : [
{
"context" : "obs",
"type" : "CodeableConcept",
"element" : "value",
"variable" : "value",
"condition" : "coding.exists((system = 'https://cielterminology.org') and (code = '703'))"
}
],
"target" : [
{
"context" : "observe",
"contextType" : "variable",
"element" : "value",
"variable" : "val",
"transform" : "create",
"parameter" : [
{
"valueString" : "CodeableConcept"
}
]
}
],
"rule" : [
{
"name" : "setPositiveCoding",
"source" : [
{
"context" : "value"
}
],
"target" : [
{
"context" : "val",
"contextType" : "variable",
"element" : "coding",
"variable" : "coding"
}
],
"rule" : [
{
"name" : "setPositiveCC",
"source" : [
{
"context" : "value"
}
],
"target" : [
{
"context" : "coding",
"contextType" : "variable",
"element" : "system",
"transform" : "copy",
"parameter" : [
{
"valueString" : "http://smart.who.int/hiv/CodeSystem/HIVConcepts"
}
]
},
{
"context" : "coding",
"contextType" : "variable",
"element" : "code",
"transform" : "copy",
"parameter" : [
{
"valueString" : "HIV.B.DE116"
}
]
},
{
"context" : "coding",
"contextType" : "variable",
"element" : "display",
"transform" : "copy",
"parameter" : [
{
"valueString" : "HIV-positive"
}
]
}
]
}
]
}
]
},
{
"name" : "setStatus",
"source" : [
{
"context" : "obsentry"
}
],
"target" : [
{
"context" : "observe",
"contextType" : "variable",
"element" : "status",
"transform" : "cc",
"parameter" : [
{
"valueString" : "http://hl7.org/fhir/observation-status"
},
{
"valueString" : "final"
},
{
"valueString" : "Final"
}
]
}
]
},
{
"name" : "setProvenance",
"source" : [
{
"context" : "obs"
}
],
"target" : [
{
"context" : "tgt",
"contextType" : "variable",
"element" : "entry",
"variable" : "pentry"
},
{
"context" : "pentry",
"contextType" : "variable",
"element" : "resource",
"variable" : "prov",
"transform" : "create",
"parameter" : [
{
"valueString" : "Provenance"
}
]
},
{
"contextType" : "variable",
"variable" : "pid",
"transform" : "uuid"
},
{
"context" : "pentry",
"contextType" : "variable",
"element" : "request",
"variable" : "prequest"
}
],
"rule" : [
{
"name" : "setPId",
"source" : [
{
"context" : "obs"
}
],
"target" : [
{
"context" : "prov",
"contextType" : "variable",
"element" : "id",
"transform" : "copy",
"parameter" : [
{
"valueId" : "pid"
}
]
}
]
},
{
"name" : "setFullUrl",
"source" : [
{
"context" : "obs"
}
],
"target" : [
{
"context" : "pentry",
"contextType" : "variable",
"element" : "fullUrl",
"transform" : "evaluate",
"parameter" : [
{
"valueString" : "'urn:uuid:' & pid"
}
]
}
]
},
{
"name" : "setrequest",
"source" : [
{
"context" : "obs"
}
],
"target" : [
{
"context" : "prequest",
"contextType" : "variable",
"element" : "method",
"transform" : "copy",
"parameter" : [
{
"valueString" : "PUT"
}
]
},
{
"context" : "prequest",
"contextType" : "variable",
"element" : "url",
"transform" : "evaluate",
"parameter" : [
{
"valueString" : "'Provenance/' & pid"
}
]
}
]
},
{
"name" : "setTarget",
"source" : [
{
"context" : "obs"
}
],
"target" : [
{
"context" : "prov",
"contextType" : "variable",
"element" : "target",
"variable" : "ptarg"
}
],
"rule" : [
{
"name" : "setTargetRef",
"source" : [
{
"context" : "obs"
}
],
"target" : [
{
"context" : "ptarg",
"contextType" : "variable",
"element" : "reference",
"transform" : "evaluate",
"parameter" : [
{
"valueString" : "'urn:uuid:' & cid"
}
]
}
]
}
]
},
{
"name" : "setEntity",
"source" : [
{
"context" : "obs"
}
],
"target" : [
{
"context" : "prov",
"contextType" : "variable",
"element" : "entity",
"variable" : "entity"
}
],
"rule" : [
{
"name" : "setRole",
"source" : [
{
"context" : "obs"
}
],
"target" : [
{
"context" : "entity",
"contextType" : "variable",
"element" : "role",
"transform" : "copy",
"parameter" : [
{
"valueString" : "source"
}
]
}
]
},
{
"name" : "setWhatId",
"source" : [
{
"context" : "obs"
}
],
"target" : [
{
"context" : "entity",
"contextType" : "variable",
"element" : "what",
"variable" : "pwhat"
}
],
"dependent" : [
{
"name" : "setProvenanceFromBundleId",
"variable" : [
"src",
"pwhat"
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
},
{
"name" : "setProvenanceFromBundleId",
"typeMode" : "none",
"input" : [
{
"name" : "bundle",
"type" : "input",
"mode" : "source"
},
{
"name" : "provwhat",
"type" : "Reference",
"mode" : "target"
}
],
"rule" : [
{
"name" : "setWhatId",
"source" : [
{
"context" : "bundle",
"element" : "id",
"variable" : "bundleid"
}
],
"target" : [
{
"context" : "provwhat",
"contextType" : "variable",
"element" : "identifier",
"variable" : "whatid"
}
],
"rule" : [
{
"name" : "setWhatIdValue",
"source" : [
{
"context" : "bundleid"
}
],
"target" : [
{
"context" : "whatid",
"contextType" : "variable",
"element" : "value",
"transform" : "evaluate",
"parameter" : [
{
"valueString" : "'Bundle/' & bundleid"
}
]
}
]
}
]
}
]
}
]
}