Generated Narrative: StructureMap AfpCaseReportMap #xD; map "http://example.org/StructureMap/AfpCaseReportMap" = "AfpCaseReportMap"#xD; #xD; // AFP Case Report QuestionnaireResponse to FHIR resources#xD; // Maps to: Patient, Encounter, Condition (AFP), Immunization (OPV), Specimen (stool)#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 AfpCaseReportMap(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 MapAfpPatient(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 MapAfpEncounter(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 MapAfpCondition(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 MapAfpImmunization(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 MapAfpSpecimen(src, specimen) "execSpecimen";#xD; src -> e.request as req, req.method = 'POST', req.url = 'Specimen' "specimenReq";#xD; } "specimenEntry";#xD; }#xD; #xD; group MapAfpPatient(source src : QuestionnaireResponse, target patient : Patient) {#xD; src -> patient.id = uuid() "patientId";#xD; src.item as demographics where linkId = '359809652429' 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 (appended to given)#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; // Parent / Guardian name as contact#xD; demographics.item as item where linkId = '856448027666' 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; } "parentName";#xD; // Parent / Guardian phone#xD; demographics.item as item where linkId = '576318206363' then {#xD; item.answer first as ans -> patient.telecom as tel, tel.system = 'phone', tel.value = ans.valueString "phone";#xD; } "phone";#xD; // Residence address#xD; demographics.item as item where linkId = 'residence-details' then {#xD; item.answer first as ans -> patient.address as addr, addr.text = ans.valueString "address";#xD; } "address";#xD; // Neighborhood landmark#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";#xD; }#xD; #xD; group MapAfpEncounter(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; // Subject reference#xD; src.subject as subj -> encounter.subject as ref, ref.reference = ('Patient/' + subj.reference);#xD; // Reporting site page#xD; src.item as reportSite where linkId = '151479012557' then {#xD; // EPID No as identifier#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 page#xD; src.item as caseInfo where linkId = '451840456960' then {#xD; // Date of investigation as period start#xD; caseInfo.item as item where linkId = '502488184403' then {#xD; item.answer first as ans -> encounter.period as period, period.start = ans.valueDate "periodStart";#xD; } "investigationDate";#xD; // Date of notification extension#xD; caseInfo.item as item where linkId = '426321975477' then {#xD; item.answer first as ans -> encounter.extension as ext then {#xD; ans -> ext.url = 'http://example.org/StructureDefinition/notificationDate' "extUrl";#xD; ans -> ext.valueDate = ans.valueDate "extValue";#xD; } "notificationExt";#xD; } "notificationDate";#xD; // Notified by#xD; caseInfo.item as item where linkId = '171292274939' then {#xD; item.answer first as ans -> encounter.extension as ext then {#xD; ans -> ext.url = 'http://example.org/StructureDefinition/notifiedBy' "extUrl";#xD; ans -> ext.valueString = (ans.valueCoding.display) "extValue";#xD; } "notifiedByExt";#xD; } "notifiedBy";#xD; // Admission date#xD; caseInfo.item as item where linkId = '507199621281' then {#xD; item.answer first as ans -> encounter.hospitalization as hosp then {#xD; ans -> hosp.admitSource as src, src.coding as cod then {#xD; ans -> cod.system = 'http://terminology.hl7.org/CodeSystem/admit-source' "admitSys";#xD; ans -> cod.code = 'hosp-trans' "admitCode";#xD; } "admitSource";#xD; } "hospitalization";#xD; item.answer first as ans -> encounter.period as period, period.start = ans.valueDate "admitDate";#xD; } "admissionDate";#xD; // IP/OP number#xD; caseInfo.item as item where linkId = '525996604810' 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; } "caseInfo";#xD; }#xD; #xD; group MapAfpCondition(source src : QuestionnaireResponse, target condition : Condition) {#xD; src -> condition.id = uuid() "conditionId";#xD; // AFP 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 = '398102009' "afpCode";#xD; src -> coding.display = 'Acute flaccid paralysis' "afpDisplay";#xD; } "afpCoding";#xD; src -> code.text = 'Acute Flaccid Paralysis (AFP)' "afpText";#xD; } "afpCodeBlock";#xD; src.subject as subj -> condition.subject as ref, ref.reference = ('Patient/' + subj.reference);#xD; src.item as clinicalInfo where linkId = '735342695013' then {#xD; // Date of onset of paralysis#xD; clinicalInfo.item as item where linkId = '728034137219' then {#xD; item.answer first as ans -> condition.onset = ans.valueDate "onsetDate";#xD; } "onsetDate";#xD; // Outcome → clinical status#xD; clinicalInfo.item as item where linkId = '212304573462' 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; // Fever at onset as note#xD; clinicalInfo.item as item where linkId = '932108244312' then {#xD; item.answer first as ans -> condition.note as note, note.text = (iif(ans.valueCoding.code = 'yes', 'Fever at onset: Yes', 'Fever at onset: No')) "feverNote";#xD; } "fever";#xD; // Site of paralysis as body site#xD; clinicalInfo.item as item where linkId = '828001350323' then {#xD; item.answer as ans -> condition.bodySite as bodySite then {#xD; ans -> bodySite.coding as cod, cod.system = 'http://snomed.info/sct', cod.display = (ans.valueCoding.display) "bodySiteCoding";#xD; } "paralysisBodySite";#xD; } "paralysisBodySites";#xD; // True AFP confirmation#xD; clinicalInfo.item as item where linkId = '564450145870' then {#xD; item.answer first as ans -> condition.verificationStatus as vs then {#xD; ans.valueCoding as val where code = 'yes' -> vs.coding as cod, cod.system = 'http://terminology.hl7.org/CodeSystem/condition-ver-status', cod.code = 'confirmed' "confirmed";#xD; ans.valueCoding as val where code = 'no' -> vs.coding as cod, cod.system = 'http://terminology.hl7.org/CodeSystem/condition-ver-status', cod.code = 'refuted' "refuted";#xD; } "verificationStatus";#xD; } "trueAfp";#xD; } "clinicalInfo";#xD; }#xD; #xD; group MapAfpImmunization(source src : QuestionnaireResponse, target immunization : Immunization) {#xD; src -> immunization.id = uuid() "immunizationId";#xD; src -> immunization.status = 'completed' "status";#xD; // OPV 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 = '02' "opvCode";#xD; src -> coding.display = 'Oral Poliovirus Vaccine (OPV)' "opvDisplay";#xD; } "opvCoding";#xD; } "vaccineCode";#xD; src.subject as subj -> immunization.patient as ref, ref.reference = ('Patient/' + subj.reference) "patient";#xD; src.item as vaccination where linkId = '446305443608' then {#xD; // Vaccination status#xD; vaccination.item as item where linkId = '970455623029' 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; // Date of OPV at birth#xD; vaccination.item as item where linkId = '413372430071' then {#xD; item.answer first as ans -> immunization.occurrenceDateTime = ans.valueDate "opvBirthDate";#xD; } "opvBirth";#xD; // Date of last OPV dose through SIA#xD; vaccination.item as item where linkId = '910678978959' then {#xD; item.answer first as ans -> immunization.extension as ext then {#xD; ans -> ext.url = 'http://example.org/StructureDefinition/lastSIADate' "extUrl";#xD; ans -> ext.valueDate = ans.valueDate "extValue";#xD; } "lastSIADate";#xD; } "siaDate";#xD; // Source of vaccination information#xD; vaccination.item as item where linkId = '650080600932' then {#xD; item.answer first as ans -> immunization.reportOrigin as origin then {#xD; ans -> origin.coding as cod, cod.system = 'http://example.org/CodeSystem/vaccination-info-source', cod.code = (ans.valueCoding.code), cod.display = (ans.valueCoding.display) "origin";#xD; } "reportOrigin";#xD; } "infoSource";#xD; } "vaccination";#xD; }#xD; #xD; group MapAfpSpecimen(source src : QuestionnaireResponse, target specimen : Specimen) {#xD; src -> specimen.id = uuid() "specimenId";#xD; // Stool specimen type#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 = '119339001' "stoolCode";#xD; src -> coding.display = 'Stool specimen' "stoolDisplay";#xD; } "stoolCoding";#xD; } "specimenType";#xD; src.subject as subj -> specimen.subject as ref, ref.reference = ('Patient/' + subj.reference);#xD; src.item as stoolCollection where linkId = '350784256533' then {#xD; // Date of first specimen collection#xD; stoolCollection.item as item where linkId = '737703942433' then {#xD; item.answer first as ans -> specimen.collection as coll, coll.collectedDateTime = ans.valueDate "firstSpecimen";#xD; } "firstSpecimenDate";#xD; // Date of second specimen (as processing step)#xD; stoolCollection.item as item where linkId = '711388438654' then {#xD; item.answer first as ans -> specimen.processing as proc then {#xD; ans -> proc.description = '2nd specimen collected' "procDesc";#xD; ans -> proc.timeDateTime = ans.valueDate "procTime";#xD; } "secondSpecimen";#xD; } "secondSpecimenDate";#xD; // Date sent to national level#xD; stoolCollection.item as item where linkId = '808177332790' then {#xD; item.answer first as ans -> specimen.processing as proc then {#xD; ans -> proc.description = 'Specimen sent to national level' "procDesc";#xD; ans -> proc.timeDateTime = ans.valueDate "procTime";#xD; } "sentToNational";#xD; } "sentToNationalDate";#xD; } "stoolCollection";#xD; }#xD; #xD;
AFP Case Report QuestionnaireResponse to FHIR resources Maps to: Patient, Encounter, Condition (AFP), Immunization (OPV), Specimen (stool)
iif(ans.valueCoding.code = 'yes', 'Fever at onset: Yes', 'Fever at onset: No')