Generated Narrative: StructureMap ExtractVitalSigns #xD; /// url = 'https://fhir.slade360.co.ke/fhir/StructureMap/ExtractVitalSigns'#xD; /// name = 'ExtractVitalSigns'#xD; /// status = 'draft'#xD; #xD; uses "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse" alias QR as source#xD; uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias Bundle as target#xD; uses "http://hl7.org/fhir/StructureDefinition/Observation" alias Observation as target#xD; #xD; group ExtractVitalSigns(source qr : QR, target bundle : Bundle) {#xD; qr -> bundle.type = 'transaction' "setBundleType";#xD; qr.item as itH where (linkId = '8302-2') then {#xD; itH.answer first as aH then {#xD; aH -> bundle.entry as eH, eH.resource = create('Observation') as oH then {#xD; qr -> oH, eH then BuildBaseObs(qr, oH, eH) "heightBase";#xD; qr -> oH.category as catH then {#xD; qr -> catH.coding as catHCoding then {#xD; qr -> catHCoding.system = 'http://terminology.hl7.org/CodeSystem/observation-category' "catHSys";#xD; qr -> catHCoding.code = 'vital-signs' "catHCode";#xD; qr -> catHCoding.display = 'Vital Signs' "catHDisplay";#xD; } "catHCodingRule";#xD; } "categoryH";#xD; qr -> oH.code as codeH then {#xD; qr -> codeH.coding as codeHCoding then {#xD; qr -> codeHCoding.system = 'http://loinc.org' "codeHSys";#xD; qr -> codeHCoding.code = '8302-2' "codeHCode";#xD; qr -> codeHCoding.display = 'Body Height' "codeHDisplay";#xD; } "codeHCodingRule";#xD; } "codeH";#xD; aH.value as hv -> oH.valueQuantity as vH then {#xD; hv -> vH.value = hv "setVal";#xD; qr -> vH.system = 'http://unitsofmeasure.org' "setSys";#xD; qr -> vH.code = 'cm' "setCode";#xD; qr -> vH.unit = 'centimeter' "setUnit";#xD; } "valH";#xD; } "heightObs";#xD; } "heightAns";#xD; } "heightRule"; // Height#xD; qr.item as itW where (linkId = '29463-7') then {#xD; itW.answer first as aW then {#xD; aW -> bundle.entry as eW, eW.resource = create('Observation') as oW then {#xD; qr -> oW, eW then BuildBaseObs(qr, oW, eW) "weightBase";#xD; qr -> oW.category as catW then {#xD; qr -> catW.coding as catWCoding then {#xD; qr -> catWCoding.system = 'http://terminology.hl7.org/CodeSystem/observation-category' "catWSys";#xD; qr -> catWCoding.code = 'vital-signs' "catWCode";#xD; qr -> catWCoding.display = 'Vital Signs' "catWDisplay";#xD; } "catWCodingRule";#xD; } "categoryW";#xD; qr -> oW.code as codeW then {#xD; qr -> codeW.coding as codeWCoding then {#xD; qr -> codeWCoding.system = 'http://loinc.org' "codeWSys";#xD; qr -> codeWCoding.code = '29463-7' "codeWCode";#xD; qr -> codeWCoding.display = 'Body Weight' "codeWDisplay";#xD; } "codeWCodingRule";#xD; } "codeW";#xD; aW.value as hv -> oW.valueQuantity as vW then {#xD; hv -> vW.value = hv "setVal";#xD; qr -> vW.system = 'http://unitsofmeasure.org' "setSys";#xD; qr -> vW.code = 'kg' "setCode";#xD; qr -> vW.unit = 'kilogram' "setUnit";#xD; } "valW";#xD; } "weightObs";#xD; } "weightAns";#xD; } "weightRule"; // Weight#xD; qr.item as itBmi where (linkId = '39156-5') then {#xD; itBmi.answer first as aBmi then {#xD; aBmi -> bundle.entry as eBmi, eBmi.resource = create('Observation') as oBmi then {#xD; qr -> oBmi, eBmi then BuildBaseObs(qr, oBmi, eBmi) "bmiBase";#xD; qr -> oBmi.category as catBmi then {#xD; qr -> catBmi.coding as catBmiCoding then {#xD; qr -> catBmiCoding.system = 'http://terminology.hl7.org/CodeSystem/observation-category' "catBmiSys";#xD; qr -> catBmiCoding.code = 'vital-signs' "catBmiCode";#xD; qr -> catBmiCoding.display = 'Vital Signs' "catBmiDisplay";#xD; } "catBmiCodingRule";#xD; } "categoryBmi";#xD; qr -> oBmi.code as codeBmi then {#xD; qr -> codeBmi.coding as codeBmiCoding then {#xD; qr -> codeBmiCoding.system = 'http://loinc.org' "codeBmiSys";#xD; qr -> codeBmiCoding.code = '39156-5' "codeBmiCode";#xD; qr -> codeBmiCoding.display = 'Body mass index (BMI) [Ratio]' "codeBmiDisplay";#xD; } "codeBmiCodingRule";#xD; } "codeBmi";#xD; aBmi.value as hv -> oBmi.valueQuantity as vBmi then {#xD; hv -> vBmi.value = hv "setVal";#xD; qr -> vBmi.system = 'http://unitsofmeasure.org' "setSys";#xD; qr -> vBmi.code = 'kg/m2' "setCode";#xD; qr -> vBmi.unit = 'kilogram per square meter' "setUnit";#xD; } "valBmi";#xD; itBmi.item as bmiStatusItem where (linkId = '39156-5_status') then {#xD; bmiStatusItem.answer first as bmiStatusAns -> oBmi.interpretation as iBmi then {#xD; bmiStatusAns.value as statusText -> iBmi.text = statusText "interpBmi";#xD; } "setInterpBmi";#xD; } "findBmiStatus"; // Interpretation 39156-5_status#xD; } "bmiObs";#xD; } "bmiAns";#xD; } "bmiRule"; // BMI#xD; qr.item as itP where (linkId = '8889-8') then {#xD; itP.answer first as aP then {#xD; aP -> bundle.entry as eP, eP.resource = create('Observation') as oP then {#xD; qr -> oP, eP then BuildBaseObs(qr, oP, eP) "pulseBase";#xD; qr -> oP.category as catP then {#xD; qr -> catP.coding as catPCoding then {#xD; qr -> catPCoding.system = 'http://terminology.hl7.org/CodeSystem/observation-category' "catPSys";#xD; qr -> catPCoding.code = 'vital-signs' "catPCode";#xD; qr -> catPCoding.display = 'Vital Signs' "catPDisplay";#xD; } "catPCodingRule";#xD; } "categoryP";#xD; qr -> oP.code as codeP then {#xD; qr -> codeP.coding as codePCoding then {#xD; qr -> codePCoding.system = 'http://loinc.org' "codePSys";#xD; qr -> codePCoding.code = '8889-8' "codePCode";#xD; qr -> codePCoding.display = 'Heart rate by Pulse oximetry' "codePDisplay";#xD; } "codePCodingRule";#xD; } "codeP";#xD; aP.value as hv -> oP.valueQuantity as vP then {#xD; hv -> vP.value = hv "setVal";#xD; qr -> vP.system = 'http://unitsofmeasure.org' "setSys";#xD; qr -> vP.code = '/min' "setCode";#xD; qr -> vP.unit = 'per minute' "setUnit";#xD; } "valP";#xD; } "pulseObs";#xD; } "pulseAns";#xD; } "pulseRule"; // Pulse#xD; qr.item as itBP where (linkId = '55284-4') then {#xD; qr -> bundle.entry as eBP, eBP.resource = create('Observation') as oBP then {#xD; qr -> oBP, eBP then BuildBaseObs(qr, oBP, eBP) "bpBase";#xD; qr -> oBP.category as catBP then {#xD; qr -> catBP.coding as catBPCoding then {#xD; qr -> catBPCoding.system = 'http://terminology.hl7.org/CodeSystem/observation-category' "catBPSys";#xD; qr -> catBPCoding.code = 'vital-signs' "catBPCode";#xD; qr -> catBPCoding.display = 'Vital Signs' "catBPDisplay";#xD; } "catBPCodingRule";#xD; } "categoryBP";#xD; qr -> oBP.code as codeBP then {#xD; qr -> codeBP.coding as codeBPCoding then {#xD; qr -> codeBPCoding.system = 'http://loinc.org' "codeBPSys";#xD; qr -> codeBPCoding.code = '55284-4' "codeBPCode";#xD; qr -> codeBPCoding.display = 'Blood pressure systolic and diastolic' "codeBPDisplay";#xD; } "codeBPCodingRule";#xD; } "codeBP";#xD; itBP.item as itSys where (linkId = '8480-6') then {#xD; itSys.answer first as aSys -> oBP.component as cSys then {#xD; aSys -> cSys.code as bpSysCC then {#xD; aSys -> bpSysCC.coding as bpSysCoding then {#xD; aSys -> bpSysCoding.system = 'http://loinc.org' "bpSysCodingSystem";#xD; aSys -> bpSysCoding.code = '8480-6' "bpSysCodingCode";#xD; aSys -> bpSysCoding.display = 'Systolic blood pressure' "bpSysCodingDisplay";#xD; } "bpSysCodingRule";#xD; } "bpSysCode";#xD; aSys.value as hv -> cSys.valueQuantity as vSys then {#xD; hv -> vSys.value = hv "setVal";#xD; qr -> vSys.system = 'http://unitsofmeasure.org' "setSys";#xD; qr -> vSys.code = 'mm[Hg]' "setCode";#xD; qr -> vSys.unit = 'millimeter of mercury' "setUnit";#xD; } "bpSysVal";#xD; } "bpSysComponent";#xD; } "bpSysRule"; // Systolic 8480-6#xD; itBP.item as itDia where (linkId = '8462-4') then {#xD; itDia.answer first as aDia -> oBP.component as cDia then {#xD; aDia -> cDia.code as bpDiaCC then {#xD; aDia -> bpDiaCC.coding as bpDiaCoding then {#xD; aDia -> bpDiaCoding.system = 'http://loinc.org' "bpDiaCodingSystem";#xD; aDia -> bpDiaCoding.code = '8462-4' "bpDiaCodingCode";#xD; aDia -> bpDiaCoding.display = 'Diastolic blood pressure' "bpDiaCodingDisplay";#xD; } "bpDiaCodingRule";#xD; } "bpDiaCode";#xD; aDia.value as hv -> cDia.valueQuantity as vDia then {#xD; hv -> vDia.value = hv "setVal";#xD; qr -> vDia.system = 'http://unitsofmeasure.org' "setSys";#xD; qr -> vDia.code = 'mm[Hg]' "setCode";#xD; qr -> vDia.unit = 'millimeter of mercury' "setUnit";#xD; } "bpDiaVal";#xD; } "bpDiaComponent";#xD; } "bpDiaRule"; // Diastolic 8462-4#xD; } "bpObs";#xD; } "bpRule"; // Blood Pressure#xD; qr.item as itT where (linkId = '8310-5') then {#xD; itT.answer first as aT then {#xD; aT -> bundle.entry as eT, eT.resource = create('Observation') as oT then {#xD; qr -> oT, eT then BuildBaseObs(qr, oT, eT) "tempBase";#xD; qr -> oT.category as catT then {#xD; qr -> catT.coding as catTCoding then {#xD; qr -> catTCoding.system = 'http://terminology.hl7.org/CodeSystem/observation-category' "catTSys";#xD; qr -> catTCoding.code = 'vital-signs' "catTCode";#xD; qr -> catTCoding.display = 'Vital Signs' "catTDisplay";#xD; } "catTCodingRule";#xD; } "categoryT";#xD; qr -> oT.code as codeT then {#xD; qr -> codeT.coding as codeTCoding then {#xD; qr -> codeTCoding.system = 'http://loinc.org' "codeTSys";#xD; qr -> codeTCoding.code = '8310-5' "codeTCode";#xD; qr -> codeTCoding.display = 'Body Temperature' "codeTDisplay";#xD; } "codeTCodingRule";#xD; } "codeT";#xD; aT.value as hv -> oT.valueQuantity as vT then {#xD; hv -> vT.value = hv "setVal";#xD; qr -> vT.system = 'http://unitsofmeasure.org' "setSys";#xD; qr -> vT.code = 'Cel' "setCode";#xD; qr -> vT.unit = 'degree Celsius' "setUnit";#xD; } "valT";#xD; itT.item as tStatusItem where (linkId = '8310-5_status') then {#xD; tStatusItem.answer first as tStatusAns -> oT.interpretation as iT then {#xD; tStatusAns.value as statusText -> iT.text = statusText "interpT";#xD; } "setInterpT";#xD; } "findTStatus"; // Interpretation 8310-5_status#xD; } "tempObs";#xD; } "tempAns";#xD; } "tempRule"; // Temperature#xD; qr.item as itO2 where (linkId = '20564-1') then {#xD; itO2.answer first as aO2 then {#xD; aO2 -> bundle.entry as eO2, eO2.resource = create('Observation') as oO2 then {#xD; qr -> oO2, eO2 then BuildBaseObs(qr, oO2, eO2) "spo2Base";#xD; qr -> oO2.category as catO2 then {#xD; qr -> catO2.coding as catO2Coding then {#xD; qr -> catO2Coding.system = 'http://terminology.hl7.org/CodeSystem/observation-category' "catO2Sys";#xD; qr -> catO2Coding.code = 'vital-signs' "catO2Code";#xD; qr -> catO2Coding.display = 'Vital Signs' "catO2Display";#xD; } "catO2CodingRule";#xD; } "categoryO2";#xD; qr -> oO2.code as codeO2 then {#xD; qr -> codeO2.coding as codeO2Coding then {#xD; qr -> codeO2Coding.system = 'http://loinc.org' "codeO2Sys";#xD; qr -> codeO2Coding.code = '20564-1' "codeO2Code";#xD; qr -> codeO2Coding.display = 'Oxygen saturation in Blood' "codeO2Display";#xD; } "codeO2CodingRule";#xD; } "codeO2";#xD; aO2.value as hv -> oO2.valueQuantity as vO2 then {#xD; hv -> vO2.value = hv "setVal";#xD; qr -> vO2.system = 'http://unitsofmeasure.org' "setSys";#xD; qr -> vO2.code = '%' "setCode";#xD; qr -> vO2.unit = '%' "setUnit";#xD; } "valO2";#xD; itO2.item as o2StatusItem where (linkId = '20564-1_status') then {#xD; o2StatusItem.answer first as o2StatusAns -> oO2.interpretation as iO2 then {#xD; o2StatusAns.value as statusText -> iO2.text = statusText "interpO2";#xD; } "setInterpO2";#xD; } "findO2Status"; // Interpretation of SpO2 20564-1_status#xD; } "spo2Obs";#xD; } "spo2Ans";#xD; } "spo2Rule"; // SpO2#xD; qr.item as itRR where (linkId = '9279-1') then {#xD; itRR.answer first as aRR then {#xD; aRR -> bundle.entry as eRR, eRR.resource = create('Observation') as oRR then {#xD; qr -> oRR, eRR then BuildBaseObs(qr, oRR, eRR) "rrBase";#xD; qr -> oRR.category as catRR then {#xD; qr -> catRR.coding as catRRCoding then {#xD; qr -> catRRCoding.system = 'http://terminology.hl7.org/CodeSystem/observation-category' "catRRSys";#xD; qr -> catRRCoding.code = 'vital-signs' "catRRCode";#xD; qr -> catRRCoding.display = 'Vital Signs' "catRRDisplay";#xD; } "catRRCodingRule";#xD; } "categoryRR";#xD; qr -> oRR.code as codeRR then {#xD; qr -> codeRR.coding as codeRRCoding then {#xD; qr -> codeRRCoding.system = 'http://loinc.org' "codeRRSys";#xD; qr -> codeRRCoding.code = '9279-1' "codeRRCode";#xD; qr -> codeRRCoding.display = 'Respiratory rate' "codeRRDisplay";#xD; } "codeRRCodingRule";#xD; } "codeRR";#xD; aRR.value as hv -> oRR.valueQuantity as vRR then {#xD; hv -> vRR.value = hv "setVal";#xD; qr -> vRR.system = 'http://unitsofmeasure.org' "setSys";#xD; qr -> vRR.code = '/min' "setCode";#xD; qr -> vRR.unit = 'per minute' "setUnit";#xD; } "valRR";#xD; } "rrObs";#xD; } "rrAns";#xD; } "rrRule"; // Respiratory rate#xD; qr.item as itMuac where (linkId = '9847-5') then {#xD; itMuac.answer first as aMuac then {#xD; aMuac -> bundle.entry as eMuac, eMuac.resource = create('Observation') as oMuac then {#xD; qr -> oMuac, eMuac then BuildBaseObs(qr, oMuac, eMuac) "muacBase";#xD; qr -> oMuac.category as catMuac then {#xD; qr -> catMuac.coding as catMuacCoding then {#xD; qr -> catMuacCoding.system = 'http://terminology.hl7.org/CodeSystem/observation-category' "catMuacSys";#xD; qr -> catMuacCoding.code = 'vital-signs' "catMuacCode";#xD; qr -> catMuacCoding.display = 'Vital Signs' "catMuacDisplay";#xD; } "catMuacCodingRule";#xD; } "categoryMuac";#xD; qr -> oMuac.code as codeMuac then {#xD; qr -> codeMuac.coding as codeMuacCoding then {#xD; qr -> codeMuacCoding.system = 'http://loinc.org' "codeMuacSys";#xD; qr -> codeMuacCoding.code = '9847-5' "codeMuacCode";#xD; qr -> codeMuacCoding.display = 'Circumference' "codeMuacDisplay";#xD; } "codeMuacCodingRule";#xD; } "codeMuac";#xD; aMuac.value as hv -> oMuac.valueQuantity as vMuac then {#xD; hv -> vMuac.value = hv "setVal";#xD; qr -> vMuac.system = 'http://unitsofmeasure.org' "setSys";#xD; qr -> vMuac.code = 'mm' "setCode";#xD; qr -> vMuac.unit = 'millimeter' "setUnit";#xD; } "valMuac";#xD; } "muacObs";#xD; } "muacAns";#xD; } "muacRule"; // MUAC#xD; qr.item as itCC where (linkId = '10154-3') then {#xD; itCC.answer first as aCC then {#xD; aCC -> bundle.entry as eCC, eCC.resource = create('Observation') as oCC then {#xD; qr -> oCC, eCC then BuildBaseObs(qr, oCC, eCC) "chiefComplaintBase";#xD; qr -> oCC.category as catCC then {#xD; qr -> catCC.coding as catCCCoding then {#xD; qr -> catCCCoding.system = 'http://terminology.hl7.org/CodeSystem/observation-category' "catCCSys";#xD; qr -> catCCCoding.code = 'social-history' "catCCCode";#xD; qr -> catCCCoding.display = 'Social History' "catCCDisplay";#xD; } "catCCCodingRule";#xD; } "chiefComplaintCategory";#xD; qr -> oCC.code as codeCC then {#xD; qr -> codeCC.coding as codeCCCoding then {#xD; qr -> codeCCCoding.system = 'http://loinc.org' "codeCCSys";#xD; qr -> codeCCCoding.code = '10154-3' "codeCCCode";#xD; qr -> codeCCCoding.display = 'Chief complaint Narrative - Reported' "codeCCDisplay";#xD; } "codeCCCodingRule";#xD; } "chiefComplaintCode";#xD; aCC.value as textVal -> oCC.valueString = textVal "chiefComplaintValue";#xD; } "chiefComplaintObs";#xD; } "chiefComplaintAns";#xD; } "chiefComplaintRule"; // Chief Complaint#xD; qr.item as hpiCC where (linkId = '8684-3') then {#xD; hpiCC.answer first as aCC then {#xD; aCC -> bundle.entry as eCC, eCC.resource = create('Observation') as oCC then {#xD; qr -> oCC, eCC then BuildBaseObs(qr, oCC, eCC) "historyOfPIBase";#xD; qr -> oCC.category as catHPI then {#xD; qr -> catHPI.coding as catHPICoding then {#xD; qr -> catHPICoding.system = 'http://terminology.hl7.org/CodeSystem/observation-category' "catHPISys";#xD; qr -> catHPICoding.code = 'social-history' "catHPICode";#xD; qr -> catHPICoding.display = 'Social History' "catHPIDisplay";#xD; } "catHPICodingRule";#xD; } "historyOfPICategory";#xD; qr -> oCC.code as codeHPI then {#xD; qr -> codeHPI.coding as codeHPICoding then {#xD; qr -> codeHPICoding.system = 'http://loinc.org' "codeHPISys";#xD; qr -> codeHPICoding.code = '8684-3' "codeHPICode";#xD; qr -> codeHPICoding.display = 'History of Present illness' "codeHPIDisplay";#xD; } "codeHPICodingRule";#xD; } "historyOfPICode";#xD; aCC.value as textVal -> oCC.valueString = textVal "historyOfPIValue";#xD; } "historyOfPIObs";#xD; } "historyOfPIAns";#xD; } "historyOfPIRule"; // History of Presenting Illness#xD; qr.item as hPastCC where (linkId = '11349-8') then {#xD; hPastCC.answer first as aCC then {#xD; aCC -> bundle.entry as eCC, eCC.resource = create('Observation') as oCC then {#xD; qr -> oCC, eCC then BuildBaseObs(qr, oCC, eCC) "historyOfPastIBase";#xD; qr -> oCC.category as catPastI then {#xD; qr -> catPastI.coding as catPastICoding then {#xD; qr -> catPastICoding.system = 'http://terminology.hl7.org/CodeSystem/observation-category' "catPastISys";#xD; qr -> catPastICoding.code = 'social-history' "catPastICode";#xD; qr -> catPastICoding.display = 'Social History' "catPastIDisplay";#xD; } "catPastICodingRule";#xD; } "historyOfPastICategory";#xD; qr -> oCC.code as codePastI then {#xD; qr -> codePastI.coding as codePastICoding then {#xD; qr -> codePastICoding.system = 'http://loinc.org' "codePastISys";#xD; qr -> codePastICoding.code = '11349-8' "codePastICode";#xD; qr -> codePastICoding.display = 'History of Past illness' "codePastIDisplay";#xD; } "codePastICodingRule";#xD; } "historyOfPastICode";#xD; aCC.value as textVal -> oCC.valueString = textVal "historyOfPastIValue";#xD; } "historyOfPastIObs";#xD; } "historyOfPastIAns";#xD; } "historyOfPastIRule"; // History of Past Illness / Past Medical History#xD; qr.item as hFH where (linkId = '8670-2') then {#xD; hFH.answer first as aCC then {#xD; aCC -> bundle.entry as eCC, eCC.resource = create('Observation') as oCC then {#xD; qr -> oCC, eCC then BuildBaseObs(qr, oCC, eCC) "familyFHIBase";#xD; qr -> oCC.category as catFH then {#xD; qr -> catFH.coding as catFHCoding then {#xD; qr -> catFHCoding.system = 'http://terminology.hl7.org/CodeSystem/observation-category' "catFHSys";#xD; qr -> catFHCoding.code = 'social-history' "catFHCode";#xD; qr -> catFHCoding.display = 'Social History' "catFHDisplay";#xD; } "catFHCodingRule";#xD; } "familyHICategory";#xD; qr -> oCC.code as codeFH then {#xD; qr -> codeFH.coding as codeFHCoding then {#xD; qr -> codeFHCoding.system = 'http://loinc.org' "codeFHSys";#xD; qr -> codeFHCoding.code = '8670-2' "codeFHCode";#xD; qr -> codeFHCoding.display = 'History of family member diseases' "codeFHDisplay";#xD; } "codeFHCodingRule";#xD; } "familyHICode";#xD; aCC.value as textVal -> oCC.valueString = textVal "familyHIValue";#xD; } "familyHIObs";#xD; } "familyHIAns";#xD; } "familyHIRule"; // Family History#xD; qr.item as hSH where (linkId = '29762-2') then {#xD; hSH.answer first as aCC then {#xD; aCC -> bundle.entry as eCC, eCC.resource = create('Observation') as oCC then {#xD; qr -> oCC, eCC then BuildBaseObs(qr, oCC, eCC) "socialHistoryIBase";#xD; qr -> oCC.category as catSH then {#xD; qr -> catSH.coding as catSHCoding then {#xD; qr -> catSHCoding.system = 'http://terminology.hl7.org/CodeSystem/observation-category' "catSHSys";#xD; qr -> catSHCoding.code = 'social-history' "catSHCode";#xD; qr -> catSHCoding.display = 'Social History' "catSHDisplay";#xD; } "catSHCodingRule";#xD; } "socialHistoryCategory";#xD; qr -> oCC.code as codeSH then {#xD; qr -> codeSH.coding as codeSHCoding then {#xD; qr -> codeSHCoding.system = 'http://loinc.org' "codeSHSys";#xD; qr -> codeSHCoding.code = '29762-2' "codeSHCode";#xD; qr -> codeSHCoding.display = 'Social history note' "codeSHDisplay";#xD; } "codeSHCodingRule";#xD; } "socialHistoryCode";#xD; aCC.value as textVal -> oCC.valueString = textVal "socialHistoryIValue";#xD; } "socialHistoryIObs";#xD; } "socialHistoryIAns";#xD; } "socialHistoryIRule"; // Social History#xD; qr.item as medicationH where (linkId = '10160-0') then {#xD; medicationH.answer first as aCC then {#xD; aCC -> bundle.entry as eCC, eCC.resource = create('Observation') as oCC then {#xD; qr -> oCC, eCC then BuildBaseObs(qr, oCC, eCC) "medicationHIBase";#xD; qr -> oCC.category as catMedH then {#xD; qr -> catMedH.coding as catMedHCoding then {#xD; qr -> catMedHCoding.system = 'http://terminology.hl7.org/CodeSystem/observation-category' "catMedHSys";#xD; qr -> catMedHCoding.code = 'therapy' "catMedHCode";#xD; qr -> catMedHCoding.display = 'Therapy' "catMedHDisplay";#xD; } "catMedHCodingRule";#xD; } "medicationHCategory";#xD; qr -> oCC.code as codeMedH then {#xD; qr -> codeMedH.coding as codeMedHCoding then {#xD; qr -> codeMedHCoding.system = 'http://loinc.org' "codeMedHSys";#xD; qr -> codeMedHCoding.code = '10160-0' "codeMedHCode";#xD; qr -> codeMedHCoding.display = 'History of Medication use Narrative' "codeMedHDisplay";#xD; } "codeMedHCodingRule";#xD; } "medicationHistoryCode";#xD; aCC.value as textVal -> oCC.valueString = textVal "medicationHistoryIValue";#xD; } "medicationHistoryIObs";#xD; } "medicationHistoryIAns";#xD; } "medicationHistoryIRule"; // Medication History#xD; }#xD; #xD; group BuildBaseObs(source qr : QR, target obs : Observation, target entry) {#xD; qr -> obs.status = 'final' "status";#xD; qr.subject as s -> obs.subject = s;#xD; qr.encounter as e -> obs.encounter = e;#xD; qr.authored as t -> obs.effectiveDateTime = t "effective";#xD; qr.source as src -> obs.performer = create('Reference') as perf then {#xD; src.reference as ref -> perf.reference = ref "perfRef";#xD; src.display as disp -> perf.display = disp "perfDisplay";#xD; } "performer"; // Performer from QuestionnaireResponse.source#xD; qr -> obs.id = uuid() then SetObservationFullUrl(obs, entry) "setObsIdAndFullUrl"; // Observation id and fullUrl#xD; qr -> entry.request as request then {#xD; qr -> request.method = 'POST' "reqMethod";#xD; qr -> request.url = 'Observation' "reqUrl";#xD; } "entryRequest"; // Bundle.entry.request (transaction POST Observation)#xD; qr -> obs.derivedFrom = create('Reference') as newRef then {#xD; qr.id as qid -> newRef.reference = append('QuestionnaireResponse/', qid) "setQRRef";#xD; } "linkQR"; // Link Observation -> QuestionnaireResponse#xD; }#xD; #xD; group SetObservationFullUrl(source obs : Observation, target entry) {#xD; obs.id as id -> entry.fullUrl = append('https://fhir.slade360.co.ke/fhir/Observation/', id) "assignFullUrl";#xD; }#xD; #xD;
History of Past Illness / Past Medical History
Performer from QuestionnaireResponse.source
Bundle.entry.request (transaction POST Observation)
Link Observation -> QuestionnaireResponse