Generated Narrative: StructureMap MeaslesCaseReportMap #xD; map "http://example.org/StructureMap/MeaslesCaseReportMap" = "MeaslesCaseReportMap"#xD; #xD; // Measles Case Report QuestionnaireResponse to FHIR resources#xD; // Maps to: Patient, Encounter, Condition (Measles), Immunization (MR/Measles), Specimen#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/Patient" alias Patient as target#xD; uses "http://hl7.org/fhir/StructureDefinition/Encounter" alias Encounter as target#xD; uses "http://hl7.org/fhir/StructureDefinition/Condition" alias Condition as target#xD; uses "http://hl7.org/fhir/StructureDefinition/Immunization" alias Immunization as target#xD; uses "http://hl7.org/fhir/StructureDefinition/Specimen" alias Specimen as target#xD; #xD; group MeaslesCaseReportMap(source src : QuestionnaireResponse, target bundle : Bundle) {#xD; src -> bundle.id = uuid() "bundleId";#xD; src -> bundle.type = 'transaction' "bundleType";#xD; src -> bundle.entry as e then {#xD; src -> e.resource = create('Patient') as patient then MapMeaslesPatient(src, patient) "execPatient";#xD; src -> e.request as req, req.method = 'PUT', req.url = ('Patient/' + %src.subject.reference) "patientReq";#xD; } "patientEntry";#xD; src -> bundle.entry as e then {#xD; src -> e.resource = create('Encounter') as encounter then MapMeaslesEncounter(src, encounter) "execEncounter";#xD; src -> e.request as req, req.method = 'POST', req.url = 'Encounter' "encounterReq";#xD; } "encounterEntry";#xD; src -> bundle.entry as e then {#xD; src -> e.resource = create('Condition') as condition then MapMeaslesCondition(src, condition) "execCondition";#xD; src -> e.request as req, req.method = 'POST', req.url = 'Condition' "conditionReq";#xD; } "conditionEntry";#xD; src -> bundle.entry as e then {#xD; src -> e.resource = create('Immunization') as immunization then MapMeaslesImmunization(src, immunization) "execImmunization";#xD; src -> e.request as req, req.method = 'POST', req.url = 'Immunization' "immunizationReq";#xD; } "immunizationEntry";#xD; src -> bundle.entry as e then {#xD; src -> e.resource = create('Specimen') as specimen then MapMeaslesSpecimen(src, specimen) "execSpecimen";#xD; src -> e.request as req, req.method = 'POST', req.url = 'Specimen' "specimenReq";#xD; } "specimenEntry";#xD; }#xD; #xD; group MapMeaslesPatient(source src : QuestionnaireResponse, target patient : Patient) {#xD; src -> patient.id = uuid() "patientId";#xD; src.item as demographics where linkId = '670954892057' then {#xD; // Given name#xD; demographics.item as item where linkId = '873240407472' then {#xD; item.answer first as ans -> patient.name as name, name.given = ans.valueString "givenName";#xD; } "firstName";#xD; // Middle name#xD; demographics.item as item where linkId = '246751846436' then {#xD; item.answer first as ans -> patient.name as name, name.given = ans.valueString "middleName";#xD; } "middleName";#xD; // Family name#xD; demographics.item as item where linkId = '486402457213' then {#xD; item.answer first as ans -> patient.name as name, name.family = ans.valueString "familyName";#xD; } "familyName";#xD; // Gender#xD; demographics.item as item where linkId = '929966324957' then {#xD; item.answer first as ans -> patient.gender = (ans.valueCoding.code) "gender";#xD; } "gender";#xD; // Date of birth#xD; demographics.item as item where linkId = '257830485990' then {#xD; item.answer first as ans -> patient.birthDate = ans.valueDate "birthDate";#xD; } "birthDate";#xD; // Residence (Urban/Rural) as address use#xD; demographics.item as item where linkId = 'residence' then {#xD; item.answer first as ans -> patient.address as addr then {#xD; ans.valueCoding as val where code = 'Urban' -> addr.use = 'home', addr.type = 'physical' "urbanAddr";#xD; ans.valueCoding as val where code = 'Rural' -> addr.use = 'home', addr.type = 'physical', addr.district = 'Rural' "ruralAddr";#xD; } "residenceType";#xD; } "residence";#xD; // Parent / Guardian#xD; demographics.item as item where linkId = 'parent' then {#xD; item.answer first as ans -> patient.contact as contact then {#xD; ans -> contact.name as cname, cname.text = ans.valueString "contactName";#xD; } "parentContact";#xD; } "parent";#xD; // Phone#xD; demographics.item as item where linkId = '754217593839' then {#xD; item.answer first as ans -> patient.telecom as tel, tel.system = 'phone', tel.value = ans.valueString "phone";#xD; } "phone";#xD; // County/Sub-County/Ward address#xD; demographics.item as item where linkId = '242811643559' then {#xD; item.answer first as ans -> patient.address as addr, addr.line = ans.valueString "village";#xD; } "village";#xD; demographics.item as item where linkId = '946232932304' then {#xD; item.answer first as ans -> patient.address as addr, addr.district = ans.valueString "landmark";#xD; } "landmark";#xD; demographics.item as item where linkId = '424111786438' then {#xD; item.answer first as ans -> patient.address as addr, addr.line = ans.valueString "street";#xD; } "street";#xD; } "demographics";#xD; }#xD; #xD; group MapMeaslesEncounter(source src : QuestionnaireResponse, target encounter : Encounter) {#xD; src -> encounter.id = uuid() "encounterId";#xD; src -> encounter.status = 'finished' "status";#xD; src -> encounter.class as cls then {#xD; src -> cls.system = 'http://terminology.hl7.org/CodeSystem/v3-ActCode' "clsSys";#xD; src -> cls.code = 'AMB' "clsCode";#xD; } "class";#xD; src.subject as subj -> encounter.subject as ref, ref.reference = ('Patient/' + subj.reference);#xD; // EPID No from reporting site#xD; src.item as reportSite where linkId = '151479012557' then {#xD; reportSite.item as item where linkId = '992818778559' then {#xD; item.answer first as ans -> encounter.identifier as id then {#xD; ans -> id.system = 'http://example.org/identifier/epid' "epidSys";#xD; ans -> id.value = ans.valueString "epidValue";#xD; } "epidId";#xD; } "epidNo";#xD; } "reportSite";#xD; // Case information#xD; src.item as caseInfo where linkId = '216343227137' then {#xD; // Date first seen at facility → period start#xD; caseInfo.item as item where linkId = '554231819382' then {#xD; item.answer first as ans -> encounter.period as period, period.start = ans.valueDate "periodStart";#xD; } "firstSeen";#xD; // IP/OP number#xD; caseInfo.item as item where linkId = '755731625544' then {#xD; item.answer first as ans -> encounter.identifier as id then {#xD; ans -> id.system = 'http://example.org/identifier/ip-op' "ipopSys";#xD; ans -> id.value = ans.valueString "ipopValue";#xD; } "ipopId";#xD; } "ipopNo";#xD; // Hospitalization#xD; caseInfo.item as item where linkId = '483042281962' then {#xD; item.answer first as ans where valueCoding.code = 'yes' -> encounter.hospitalization as hosp then {#xD; ans -> hosp.admitSource as src, src.coding as cod, cod.system = 'http://terminology.hl7.org/CodeSystem/admit-source', cod.code = 'hosp-trans' "admitSource";#xD; } "hospitalization";#xD; } "hospitalized";#xD; // Date of admission#xD; caseInfo.item as item where linkId = '340908984116' then {#xD; item.answer first as ans -> encounter.period as period, period.start = ans.valueDate "admitDate";#xD; } "admitDate";#xD; // Outcome → disposition#xD; caseInfo.item as item where linkId = '508745697175' then {#xD; item.answer first as ans -> encounter.hospitalization as hosp then {#xD; ans.valueCoding as val where code = 'Alive' -> hosp.dischargeDisposition as disp, disp.coding as cod, cod.system = 'http://terminology.hl7.org/CodeSystem/discharge-disposition', cod.code = 'home' "alive";#xD; ans.valueCoding as val where code = 'Dead' -> hosp.dischargeDisposition as disp, disp.coding as cod, cod.system = 'http://terminology.hl7.org/CodeSystem/discharge-disposition', cod.code = 'exp' "dead";#xD; } "outcomeDisp";#xD; } "outcome";#xD; } "caseInfo";#xD; // Case type (Case or Line List) as type#xD; src.item as clinicalHistory where linkId = '477144604557' then {#xD; clinicalHistory.item as item where linkId = '865158268604' then {#xD; item.answer first as ans -> encounter.type as type then {#xD; ans -> type.coding as cod, cod.system = 'http://example.org/CodeSystem/measles-case-type', cod.code = (ans.valueCoding.code), cod.display = (ans.valueCoding.display) "caseType";#xD; } "encounterType";#xD; } "caseOrLineList";#xD; } "clinicalHistory";#xD; }#xD; #xD; group MapMeaslesCondition(source src : QuestionnaireResponse, target condition : Condition) {#xD; src -> condition.id = uuid() "conditionId";#xD; // Measles SNOMED code#xD; src -> condition.code as code then {#xD; src -> code.coding as coding then {#xD; src -> coding.system = 'http://snomed.info/sct' "snomedSys";#xD; src -> coding.code = '14189004' "measlesCode";#xD; src -> coding.display = 'Measles' "measlesDisplay";#xD; } "measlesCoding";#xD; src -> code.text = 'Measles' "measlesText";#xD; } "codeBlock";#xD; src.subject as subj -> condition.subject as ref, ref.reference = ('Patient/' + subj.reference);#xD; src.item as clinicalHistory where linkId = '477144604557' then {#xD; // Date of onset of illness#xD; clinicalHistory.item as item where linkId = '728034137219' then {#xD; item.answer first as ans -> condition.onset = ans.valueDate "onsetDate";#xD; } "onsetDate";#xD; // Clinical symptoms as body site / note#xD; clinicalHistory.item as item where linkId = '745196148424' then {#xD; item.answer as ans -> condition.note as note, note.text = (ans.valueCoding.display) "symptomNote";#xD; } "symptoms";#xD; // Date of rash onset#xD; clinicalHistory.item as item where linkId = '576528567552' then {#xD; item.answer first as ans -> condition.extension as ext then {#xD; ans -> ext.url = 'http://example.org/StructureDefinition/rashOnsetDate' "extUrl";#xD; ans -> ext.valueDate = ans.valueDate "extValue";#xD; } "rashOnset";#xD; } "rashDate";#xD; // Type of rash#xD; clinicalHistory.item as item where linkId = '704922081985' then {#xD; item.answer first as ans -> condition.note as note, note.text = ('Rash type: ' + ans.valueCoding.display) "rashTypeNote";#xD; } "rashType";#xD; // Home visited for contact investigation#xD; clinicalHistory.item as item where linkId = '207408507040' then {#xD; item.answer first as ans -> condition.note as note, note.text = (iif(ans.valueCoding.code = 'yes', 'Home visited for contact investigation: Yes', 'Home visited for contact investigation: No')) "contactInvestNote";#xD; } "homeVisited";#xD; // Date of home visit#xD; clinicalHistory.item as item where linkId = '566661890668' then {#xD; item.answer first as ans -> condition.extension as ext then {#xD; ans -> ext.url = 'http://example.org/StructureDefinition/contactInvestigationDate' "extUrl";#xD; ans -> ext.valueDate = ans.valueDate "extValue";#xD; } "homeVisitExt";#xD; } "homeVisitDate";#xD; } "clinicalHistory";#xD; // Outcome → clinical status from case info#xD; src.item as caseInfo where linkId = '216343227137' then {#xD; caseInfo.item as item where linkId = '508745697175' then {#xD; item.answer first as ans -> condition.clinicalStatus as status then {#xD; ans.valueCoding as val where code = 'Dead' -> status.coding as cod, cod.system = 'http://terminology.hl7.org/CodeSystem/condition-clinical', cod.code = 'inactive' "deadStatus";#xD; ans.valueCoding as val where code = 'Alive' -> status.coding as cod, cod.system = 'http://terminology.hl7.org/CodeSystem/condition-clinical', cod.code = 'active' "aliveStatus";#xD; } "clinicalStatus";#xD; } "outcome";#xD; } "caseInfoStatus";#xD; }#xD; #xD; group MapMeaslesImmunization(source src : QuestionnaireResponse, target immunization : Immunization) {#xD; src -> immunization.id = uuid() "immunizationId";#xD; src -> immunization.status = 'completed' "status";#xD; // MR / Measles vaccine code#xD; src -> immunization.vaccineCode as code then {#xD; src -> code.coding as coding then {#xD; src -> coding.system = 'http://hl7.org/fhir/sid/cvx' "cvxSys";#xD; src -> coding.code = '05' "measlesCode";#xD; src -> coding.display = 'Measles-Rubella (MR) Vaccine' "mrDisplay";#xD; } "mrCoding";#xD; } "vaccineCode";#xD; src.subject as subj -> immunization.patient as ref, ref.reference = ('Patient/' + subj.reference) "patient";#xD; src.item as vaccination where linkId = '736291402384' then {#xD; // Vaccination status#xD; vaccination.item as item where linkId = '517772812375' then {#xD; item.answer first as ans where valueCoding.code = 'no' -> immunization.status = 'not-done' "notVaccinated";#xD; item.answer first as ans where valueCoding.code = 'unknown' -> immunization.statusReason as reason, reason.text = 'Unknown vaccination status' "unknownStatus";#xD; } "vaccinationStatus";#xD; // Number of doses#xD; vaccination.item as item where linkId = '886125589225' then {#xD; item.answer first as ans -> immunization.protocolApplied as protocol then {#xD; ans -> protocol.doseNumber = ans.valueInteger "doseNumber";#xD; } "protocol";#xD; } "doses";#xD; // MR vaccination in last 30 days#xD; vaccination.item as item where linkId = '308128177300' then {#xD; item.answer first as ans -> immunization.extension as ext then {#xD; ans -> ext.url = 'http://example.org/StructureDefinition/vaccineLast30Days' "extUrl";#xD; ans -> ext.valueCoding = ans.valueCoding "extValue";#xD; } "last30DaysExt";#xD; } "last30Days";#xD; // Date of last vaccination#xD; vaccination.item as item where linkId = '544290619304' then {#xD; item.answer first as ans -> immunization.occurrenceDateTime = ans.valueDate "lastVaccDate";#xD; } "lastVaccDate";#xD; } "vaccination";#xD; }#xD; #xD; group MapMeaslesSpecimen(source src : QuestionnaireResponse, target specimen : Specimen) {#xD; src -> specimen.id = uuid() "specimenId";#xD; // Blood/Urine/Respiratory type (default to blood serum for measles serology)#xD; src -> specimen.type as type then {#xD; src -> type.coding as coding then {#xD; src -> coding.system = 'http://snomed.info/sct' "snomedSys";#xD; src -> coding.code = '119364003' "serumCode";#xD; src -> coding.display = 'Serum specimen' "serumDisplay";#xD; } "serumCoding";#xD; } "specimenType";#xD; src.subject as subj -> specimen.subject as ref, ref.reference = ('Patient/' + subj.reference);#xD; src.item as specimenCollection where linkId = '271053545237' then {#xD; // Specimen type(s) selected#xD; specimenCollection.item as item where linkId = '412689284625' then {#xD; item.answer as ans -> specimen.note as note, note.text = ('Specimen collected: ' + ans.valueCoding.display) "specimenNote";#xD; } "specimenTypes";#xD; // Date of specimen collection#xD; specimenCollection.item as item where linkId = '8962468583341' then {#xD; item.answer first as ans -> specimen.collection as coll, coll.collectedDateTime = ans.valueDate "collectionDate";#xD; } "collectionDate";#xD; // Date specimen sent to lab#xD; specimenCollection.item as item where linkId = '718251724172' then {#xD; item.answer first as ans -> specimen.processing as proc then {#xD; ans -> proc.description = 'Specimen sent to lab' "procDesc";#xD; ans -> proc.timeDateTime = ans.valueDate "procTime";#xD; } "sentToLab";#xD; } "sentToLabDate";#xD; // Other specimen types#xD; specimenCollection.item as item where linkId = '340507649387' then {#xD; item.answer first as ans -> specimen.note as note, note.text = ('Other specimen type: ' + ans.valueString) "otherSpecimenNote";#xD; } "otherSpecimen";#xD; } "specimenCollection";#xD; }#xD; #xD;
Measles Case Report QuestionnaireResponse to FHIR resources Maps to: Patient, Encounter, Condition (Measles), Immunization (MR/Measles), Specimen
iif(ans.valueCoding.code = 'yes', 'Home visited for contact investigation: Yes', 'Home visited for contact investigation: No')
'Specimen collected: ' + ans.valueCoding.display
'Other specimen type: ' + ans.valueString