Generated Narrative: StructureMap MeaslesLabResultsMap #xD; map "http://example.org/StructureMap/MeaslesLabResultsMap" = "MeaslesLabResultsMap"#xD; #xD; // Measles Lab Results QuestionnaireResponse to FHIR resources#xD; // Maps to: Observation (Measles IgM), Observation (Rubella IgM), DiagnosticReport#xD; #xD; uses "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse" alias QuestionnaireResponse 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; uses "http://hl7.org/fhir/StructureDefinition/DiagnosticReport" alias DiagnosticReport as target#xD; #xD; group MeaslesLabResultsMap(source src : QuestionnaireResponse, target bundle : Bundle) {#xD; src -> bundle.id = uuid() "bundleId";#xD; src -> bundle.type = 'transaction' "bundleType";#xD; // Measles IgM Observation#xD; src -> bundle.entry as e then {#xD; src -> e.resource = create('Observation') as measlesObs then MapMeaslesIgM(src, measlesObs) "execMeaslesIgM";#xD; src -> e.request as req, req.method = 'POST', req.url = 'Observation' "measlesObsReq";#xD; } "measlesIgMEntry";#xD; // Rubella IgM Observation#xD; src -> bundle.entry as e then {#xD; src -> e.resource = create('Observation') as rubellaObs then MapRubellaIgM(src, rubellaObs) "execRubellaIgM";#xD; src -> e.request as req, req.method = 'POST', req.url = 'Observation' "rubellaObsReq";#xD; } "rubellaIgMEntry";#xD; // DiagnosticReport#xD; src -> bundle.entry as e then {#xD; src -> e.resource = create('DiagnosticReport') as report then MapLabDiagnosticReport(src, report) "execReport";#xD; src -> e.request as req, req.method = 'POST', req.url = 'DiagnosticReport' "reportReq";#xD; } "diagnosticReportEntry";#xD; }#xD; #xD; group MapMeaslesIgM(source src : QuestionnaireResponse, target obs : Observation) {#xD; src -> obs.id = uuid() "obsId";#xD; src -> obs.status = 'final' "status";#xD; // LOINC code for Measles virus IgM Ab in Serum#xD; src -> obs.code as code then {#xD; src -> code.coding as coding then {#xD; src -> coding.system = 'http://loinc.org' "loincSys";#xD; src -> coding.code = '20479-4' "measlesIgMCode";#xD; src -> coding.display = 'Measles virus IgM Ab [Presence] in Serum' "measlesIgMDisplay";#xD; } "measlesIgMCoding";#xD; src -> code.text = 'Measles IgM' "obsText";#xD; } "codeBlock";#xD; src.subject as subj -> obs.subject as ref, ref.reference = ('Patient/' + subj.reference);#xD; // Lab ID as identifier#xD; src.item as item where linkId = '8732404074721' then {#xD; item.answer first as ans -> obs.identifier as id then {#xD; ans -> id.system = 'http://example.org/identifier/lab-id' "labIdSys";#xD; ans -> id.value = ans.valueString "labIdValue";#xD; } "labId";#xD; } "labIdItem";#xD; // Specimen sent date → effective period start#xD; src.item as item where linkId = '718251724172' then {#xD; item.answer first as ans -> obs.effective = ans.valueDate "effectiveDate";#xD; } "specimenSentDate";#xD; // Date specimen received → issued#xD; src.item as item where linkId = 'date-specimen-received' then {#xD; item.answer first as ans -> obs.issued = ans.valueDate "issued";#xD; } "receivedDate";#xD; // Specimen condition as note#xD; src.item as item where linkId = 'specimen-condition' then {#xD; item.answer first as ans -> obs.note as note, note.text = ('Specimen condition: ' + ans.valueCoding.display) "conditionNote";#xD; } "specimenCondition";#xD; // Measles IgM result → value#xD; src.item as item where linkId = 'measles-igm' then {#xD; item.answer first as ans -> obs.valueCodeableConcept as coding then {#xD; ans -> coding.coding as cod then {#xD; ans -> cod.system = 'http://example.org/CodeSystem/lab-result' "resultSys";#xD; ans -> cod.code = (ans.valueCoding.code) "resultCode";#xD; ans -> cod.display = (ans.valueCoding.display) "resultDisplay";#xD; } "resultCoding";#xD; } "measlesIgMResult";#xD; // Interpretation#xD; item.answer first as ans -> obs.interpretation as interp then {#xD; ans.valueCoding as val where code = 'Positive' -> interp.coding as cod, cod.system = 'http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation', cod.code = 'POS', cod.display = 'Positive' "posInterp";#xD; ans.valueCoding as val where code = 'Negative' -> interp.coding as cod, cod.system = 'http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation', cod.code = 'NEG', cod.display = 'Negative' "negInterp";#xD; ans.valueCoding as val where code = 'Indeterminate' -> interp.coding as cod, cod.system = 'http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation', cod.code = 'IND', cod.display = 'Indeterminate' "indInterp";#xD; } "interpretation";#xD; } "measlesIgMItem";#xD; // Date results sent out#xD; src.item as item where linkId = 'date-lab-sent-results' then {#xD; item.answer first as ans -> obs.extension as ext then {#xD; ans -> ext.url = 'http://example.org/StructureDefinition/resultsSentDate' "extUrl";#xD; ans -> ext.valueDate = ans.valueDate "extValue";#xD; } "resultsSentExt";#xD; } "resultsSentDate";#xD; // Regional lab referral date#xD; src.item as item where linkId = '655865451155' then {#xD; item.answer first as ans -> obs.extension as ext then {#xD; ans -> ext.url = 'http://example.org/StructureDefinition/regionalLabDate' "extUrl";#xD; ans -> ext.valueDate = ans.valueDate "extValue";#xD; } "regionalLabExt";#xD; } "regionalLabDate";#xD; // Final classification as note#xD; src.item as item where linkId = 'final-classification' then {#xD; item.answer first as ans -> obs.note as note, note.text = ('Final classification: ' + ans.valueCoding.display) "classificationNote";#xD; } "finalClassification";#xD; }#xD; #xD; group MapRubellaIgM(source src : QuestionnaireResponse, target obs : Observation) {#xD; src -> obs.id = uuid() "obsId";#xD; src -> obs.status = 'final' "status";#xD; // LOINC code for Rubella virus IgM Ab in Serum#xD; src -> obs.code as code then {#xD; src -> code.coding as coding then {#xD; src -> coding.system = 'http://loinc.org' "loincSys";#xD; src -> coding.code = '22501-3' "rubellaIgMCode";#xD; src -> coding.display = 'Rubella virus IgM Ab [Presence] in Serum' "rubellaIgMDisplay";#xD; } "rubellaIgMCoding";#xD; src -> code.text = 'Rubella IgM' "obsText";#xD; } "codeBlock";#xD; src.subject as subj -> obs.subject as ref, ref.reference = ('Patient/' + subj.reference);#xD; // Lab ID as identifier#xD; src.item as item where linkId = '8732404074721' then {#xD; item.answer first as ans -> obs.identifier as id then {#xD; ans -> id.system = 'http://example.org/identifier/lab-id' "labIdSys";#xD; ans -> id.value = ans.valueString "labIdValue";#xD; } "labId";#xD; } "labIdItem";#xD; // Specimen received date → effective#xD; src.item as item where linkId = 'date-specimen-received' then {#xD; item.answer first as ans -> obs.effective = ans.valueDate "effectiveDate";#xD; } "receivedDate";#xD; // Rubella IgM result → value#xD; src.item as item where linkId = 'rubella-igm' then {#xD; item.answer first as ans -> obs.valueCodeableConcept as coding then {#xD; ans -> coding.coding as cod then {#xD; ans -> cod.system = 'http://example.org/CodeSystem/lab-result' "resultSys";#xD; ans -> cod.code = (ans.valueCoding.code) "resultCode";#xD; ans -> cod.display = (ans.valueCoding.display) "resultDisplay";#xD; } "resultCoding";#xD; } "rubellaIgMResult";#xD; // Interpretation#xD; item.answer first as ans -> obs.interpretation as interp then {#xD; ans.valueCoding as val where code = 'Positive' -> interp.coding as cod, cod.system = 'http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation', cod.code = 'POS', cod.display = 'Positive' "posInterp";#xD; ans.valueCoding as val where code = 'Negative' -> interp.coding as cod, cod.system = 'http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation', cod.code = 'NEG', cod.display = 'Negative' "negInterp";#xD; ans.valueCoding as val where code = 'Indeterminate' -> interp.coding as cod, cod.system = 'http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation', cod.code = 'IND', cod.display = 'Indeterminate' "indInterp";#xD; } "interpretation";#xD; } "rubellaIgMItem";#xD; // Status: not done if absent#xD; src.item as item where linkId = 'rubella-igm' then {#xD; item where answer.empty() -> obs.status = 'cancelled', obs.dataAbsentReason as reason, reason.coding as cod, cod.system = 'http://terminology.hl7.org/CodeSystem/data-absent-reason', cod.code = 'not-performed' "notDone";#xD; } "rubellaNotDone";#xD; }#xD; #xD; group MapLabDiagnosticReport(source src : QuestionnaireResponse, target report : DiagnosticReport) {#xD; src -> report.id = uuid() "reportId";#xD; src -> report.status = 'final' "status";#xD; // Category: Laboratory#xD; src -> report.category as cat then {#xD; src -> cat.coding as coding then {#xD; src -> coding.system = 'http://terminology.hl7.org/CodeSystem/v2-0074' "catSys";#xD; src -> coding.code = 'LAB' "catCode";#xD; src -> coding.display = 'Laboratory' "catDisplay";#xD; } "catCoding";#xD; } "category";#xD; // Measles serology panel LOINC#xD; src -> report.code as code then {#xD; src -> code.coding as coding then {#xD; src -> coding.system = 'http://loinc.org' "loincSys";#xD; src -> coding.code = '41852-5' "panelCode";#xD; src -> coding.display = 'Microorganism or agent identified in Specimen' "panelDisplay";#xD; } "panelCoding";#xD; src -> code.text = 'Measles/Rubella Serology Panel' "codeText";#xD; } "codeBlock";#xD; src.subject as subj -> report.subject as ref, ref.reference = ('Patient/' + subj.reference);#xD; // Lab ID#xD; src.item as item where linkId = '8732404074721' then {#xD; item.answer first as ans -> report.identifier as id then {#xD; ans -> id.system = 'http://example.org/identifier/lab-id' "labIdSys";#xD; ans -> id.value = ans.valueString "labIdValue";#xD; } "labId";#xD; } "labIdItem";#xD; // Effective date from specimen received#xD; src.item as item where linkId = 'date-specimen-received' then {#xD; item.answer first as ans -> report.effective = ans.valueDate "effectiveDate";#xD; } "effectiveDate";#xD; // Issued date from results sent#xD; src.item as item where linkId = 'date-lab-sent-results' then {#xD; item.answer first as ans -> report.issued = ans.valueDate "issued";#xD; } "issuedDate";#xD; // Final classification as conclusion#xD; src.item as item where linkId = 'final-classification' then {#xD; item.answer first as ans -> report.conclusion = (ans.valueCoding.display) "conclusion";#xD; item.answer first as ans -> report.conclusionCode as code then {#xD; ans -> code.coding as cod, cod.system = 'http://example.org/CodeSystem/measles-classification', cod.code = (ans.valueCoding.code), cod.display = (ans.valueCoding.display) "conclusionCode";#xD; } "conclusionCode";#xD; } "classification";#xD; }#xD; #xD;
Measles Lab Results QuestionnaireResponse to FHIR resources Maps to: Observation (Measles IgM), Observation (Rubella IgM), DiagnosticReport
Measles virus IgM Ab [Presence] in Serum
'Specimen condition: ' + ans.valueCoding.display
'Final classification: ' + ans.valueCoding.display
Rubella virus IgM Ab [Presence] in Serum
Microorganism or agent identified in Specimen