Generated Narrative: StructureMap Moh505SectionABMap #xD; map "http://example.org/StructureMap/Moh505SectionABMap" = "Moh505SectionABMap"#xD; #xD; // MOH 505 Section A and B QuestionnaireResponse to FHIR resources#xD; // Maps disease tally counts to Observation resources (one per disease per reporting period)#xD; // Observation.component encodes: under-5 cases, under-5 deaths, over-5 cases, over-5 deaths#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/BackboneElement" alias BackboneElement as source#xD; #xD; group Moh505SectionABMap(source src : QuestionnaireResponse, target bundle : Bundle) {#xD; src -> bundle.id = uuid() "bundleId";#xD; src -> bundle.type = 'transaction' "bundleType";#xD; src.item as page where linkId = '306799299' then {#xD; // ── AEFI ──────────────────────────────────────────────────────────────────#xD; page.item as cb where linkId = '745196148424' then {#xD; page.item as u5c where linkId = 'under5-cases' then {#xD; page.item as u5d where linkId = 'under5-deaths' then {#xD; page.item as o5c where linkId = 'over5-cases' then {#xD; page.item as o5d where linkId = 'over5-deaths' then {#xD; cb where answer.exists() -> bundle.entry as e, e.resource = create('Observation') as obs then CreateSectionABObs(cb, u5c, u5d, o5c, o5d, obs) "aefiObs";#xD; } "o5d";#xD; } "o5c";#xD; } "u5d";#xD; } "u5c";#xD; } "aefi";#xD; // ── Acute Jaundice ────────────────────────────────────────────────────────#xD; page.item as cb where linkId = 'acute-jaundice' then {#xD; page.item as u5c where linkId = 'acute-jaundice-under5-cases' then {#xD; page.item as u5d where linkId = 'acute-jaundice-under5-deaths' then {#xD; page.item as o5c where linkId = 'acute-jaundice-over5-cases' then {#xD; page.item as o5d where linkId = 'acute-jaundice-over5-deaths' then {#xD; cb where answer.exists() -> bundle.entry as e, e.resource = create('Observation') as obs then CreateSectionABObs(cb, u5c, u5d, o5c, o5d, obs) "ajObs";#xD; } "o5d";#xD; } "o5c";#xD; } "u5d";#xD; } "u5c";#xD; } "acuteJaundice";#xD; // ── Acute Malnutrition ────────────────────────────────────────────────────#xD; page.item as cb where linkId = 'acute-malnutrition' then {#xD; page.item as u5c where linkId = 'acute-malnutrition-under5-cases' then {#xD; page.item as u5d where linkId = 'acute-malnutrition-under5-deaths' then {#xD; page.item as o5c where linkId = 'acute-malnutrition-over5-cases' then {#xD; page.item as o5d where linkId = 'acute-malnutrition-over5-deaths' then {#xD; cb where answer.exists() -> bundle.entry as e, e.resource = create('Observation') as obs then CreateSectionABObs(cb, u5c, u5d, o5c, o5d, obs) "amObs";#xD; } "o5d";#xD; } "o5c";#xD; } "u5d";#xD; } "u5c";#xD; } "acuteMalnutrition";#xD; // ── AFP (Poliomyelitis) ───────────────────────────────────────────────────#xD; page.item as cb where linkId = 'afp-poliomyelitis' then {#xD; page.item as u5c where linkId = 'afp-poliomyelitis-under5-cases' then {#xD; page.item as u5d where linkId = 'afp-poliomyelitis-under5-deaths' then {#xD; page.item as o5c where linkId = 'afp-poliomyelitis-over5-cases' then {#xD; page.item as o5d where linkId = 'afp-poliomyelitis-over5-deaths' then {#xD; cb where answer.exists() -> bundle.entry as e, e.resource = create('Observation') as obs then CreateSectionABObs(cb, u5c, u5d, o5c, o5d, obs) "afpObs";#xD; } "o5d";#xD; } "o5c";#xD; } "u5d";#xD; } "u5c";#xD; } "afp";#xD; // ── Anthrax ───────────────────────────────────────────────────────────────#xD; page.item as cb where linkId = 'anthrax' then {#xD; page.item as u5c where linkId = 'anthrax-under5-cases' then {#xD; page.item as u5d where linkId = 'anthrax-under5-deaths' then {#xD; page.item as o5c where linkId = 'anthrax-over5-cases' then {#xD; page.item as o5d where linkId = 'anthrax-over5-deaths' then {#xD; cb where answer.exists() -> bundle.entry as e, e.resource = create('Observation') as obs then CreateSectionABObs(cb, u5c, u5d, o5c, o5d, obs) "anthraxObs";#xD; } "o5d";#xD; } "o5c";#xD; } "u5d";#xD; } "u5c";#xD; } "anthrax";#xD; // ── Cholera ───────────────────────────────────────────────────────────────#xD; page.item as cb where linkId = 'cholera' then {#xD; page.item as u5c where linkId = 'cholera-under5-cases' then {#xD; page.item as u5d where linkId = 'cholera-under5-deaths' then {#xD; page.item as o5c where linkId = 'cholera-over5-cases' then {#xD; page.item as o5d where linkId = 'cholera-over5-deaths' then {#xD; cb where answer.exists() -> bundle.entry as e, e.resource = create('Observation') as obs then CreateSectionABObs(cb, u5c, u5d, o5c, o5d, obs) "choleraObs";#xD; } "o5d";#xD; } "o5c";#xD; } "u5d";#xD; } "u5c";#xD; } "cholera";#xD; // ── Chikungunya ───────────────────────────────────────────────────────────#xD; page.item as cb where linkId = 'chikungunya' then {#xD; page.item as u5c where linkId = 'chikungunya-under5-cases' then {#xD; page.item as u5d where linkId = 'chikungunya-under5-deaths' then {#xD; page.item as o5c where linkId = 'chikungunya-over5-cases' then {#xD; page.item as o5d where linkId = 'chikungunya-over5-deaths' then {#xD; cb where answer.exists() -> bundle.entry as e, e.resource = create('Observation') as obs then CreateSectionABObs(cb, u5c, u5d, o5c, o5d, obs) "chikungunyaObs";#xD; } "o5d";#xD; } "o5c";#xD; } "u5d";#xD; } "u5c";#xD; } "chikungunya";#xD; // ── COVID-19 ──────────────────────────────────────────────────────────────#xD; page.item as cb where linkId = 'covid-19' then {#xD; page.item as u5c where linkId = 'covid-19-under5-cases' then {#xD; page.item as u5d where linkId = 'covid-19-under5-deaths' then {#xD; page.item as o5c where linkId = 'covid-19-over5-cases' then {#xD; page.item as o5d where linkId = 'covid-19-over5-deaths' then {#xD; cb where answer.exists() -> bundle.entry as e, e.resource = create('Observation') as obs then CreateSectionABObs(cb, u5c, u5d, o5c, o5d, obs) "covidObs";#xD; } "o5d";#xD; } "o5c";#xD; } "u5d";#xD; } "u5c";#xD; } "covid19";#xD; // ── Dengue ────────────────────────────────────────────────────────────────#xD; page.item as cb where linkId = 'dengue' then {#xD; page.item as u5c where linkId = 'dengue-under5-cases' then {#xD; page.item as u5d where linkId = 'dengue-under5-deaths' then {#xD; page.item as o5c where linkId = 'dengue-over5-cases' then {#xD; page.item as o5d where linkId = 'dengue-over5-deaths' then {#xD; cb where answer.exists() -> bundle.entry as e, e.resource = create('Observation') as obs then CreateSectionABObs(cb, u5c, u5d, o5c, o5d, obs) "dengueObs";#xD; } "o5d";#xD; } "o5c";#xD; } "u5d";#xD; } "u5c";#xD; } "dengue";#xD; // ── Dysentery (Bacillary) ─────────────────────────────────────────────────#xD; page.item as cb where linkId = 'dysentery-bacillary' then {#xD; page.item as u5c where linkId = 'dysentery-bacillary-under5-cases' then {#xD; page.item as u5d where linkId = 'dysentery-bacillary-under5-deaths' then {#xD; page.item as o5c where linkId = 'dysentery-bacillary-over5-cases' then {#xD; page.item as o5d where linkId = 'dysentery-bacillary-over5-deaths' then {#xD; cb where answer.exists() -> bundle.entry as e, e.resource = create('Observation') as obs then CreateSectionABObs(cb, u5c, u5d, o5c, o5d, obs) "dysenteryObs";#xD; } "o5d";#xD; } "o5c";#xD; } "u5d";#xD; } "u5c";#xD; } "dysenteryBacillary";#xD; // ── Guinea Worm Disease ───────────────────────────────────────────────────#xD; page.item as cb where linkId = 'guinea-worm-disease' then {#xD; page.item as u5c where linkId = 'guinea-worm-disease-under5-cases' then {#xD; page.item as u5d where linkId = 'guinea-worm-disease-under5-deaths' then {#xD; page.item as o5c where linkId = 'guinea-worm-disease-over5-cases' then {#xD; page.item as o5d where linkId = 'guinea-worm-disease-over5-deaths' then {#xD; cb where answer.exists() -> bundle.entry as e, e.resource = create('Observation') as obs then CreateSectionABObs(cb, u5c, u5d, o5c, o5d, obs) "guineaWormObs";#xD; } "o5d";#xD; } "o5c";#xD; } "u5d";#xD; } "u5c";#xD; } "guineaWorm";#xD; // ── Measles ───────────────────────────────────────────────────────────────#xD; page.item as cb where linkId = 'measles' then {#xD; page.item as u5c where linkId = 'measles-under5-cases' then {#xD; page.item as u5d where linkId = 'measles-under5-deaths' then {#xD; page.item as o5c where linkId = 'measles-over5-cases' then {#xD; page.item as o5d where linkId = 'measles-over5-deaths' then {#xD; cb where answer.exists() -> bundle.entry as e, e.resource = create('Observation') as obs then CreateSectionABObs(cb, u5c, u5d, o5c, o5d, obs) "measlesObs";#xD; } "o5d";#xD; } "o5c";#xD; } "u5d";#xD; } "u5c";#xD; } "measlesSectionAB";#xD; // ── Suspected Malaria ─────────────────────────────────────────────────────#xD; page.item as cb where linkId = 'suspected-malaria' then {#xD; page.item as u5c where linkId = 'suspected-malaria-under5-cases' then {#xD; page.item as u5d where linkId = 'suspected-malaria-under5-deaths' then {#xD; page.item as o5c where linkId = 'suspected-malaria-over5-cases' then {#xD; page.item as o5d where linkId = 'suspected-malaria-over5-deaths' then {#xD; cb where answer.exists() -> bundle.entry as e, e.resource = create('Observation') as obs then CreateSectionABObs(cb, u5c, u5d, o5c, o5d, obs) "malariaObs";#xD; } "o5d";#xD; } "o5c";#xD; } "u5d";#xD; } "u5c";#xD; } "suspectedMalaria";#xD; // ── Bacterial Meningitis (numeric linkIds) ────────────────────────────────#xD; page.item as cb where linkId = '912271576972' then {#xD; page.item as u5c where linkId = '871055915491' then {#xD; page.item as u5d where linkId = '388760057096' then {#xD; page.item as o5c where linkId = '483347883552' then {#xD; page.item as o5d where linkId = '983942974596' then {#xD; cb where answer.exists() -> bundle.entry as e, e.resource = create('Observation') as obs then CreateSectionABObs(cb, u5c, u5d, o5c, o5d, obs) "bactMenObs";#xD; } "o5d";#xD; } "o5c";#xD; } "u5d";#xD; } "u5c";#xD; } "bacterialMeningitis";#xD; // ── Neonatal Tetanus (numeric linkIds) ────────────────────────────────────#xD; page.item as cb where linkId = '328118347844' then {#xD; page.item as u5c where linkId = '535840524666' then {#xD; page.item as u5d where linkId = '703609548617' then {#xD; cb where answer.exists() -> bundle.entry as e, e.resource = create('Observation') as obs then CreateSectionABObsPartial(cb, u5c, u5d, obs) "neonatalTetObs";#xD; } "u5d";#xD; } "u5c";#xD; } "neonatalTetanus";#xD; // ── Onchocerciasis (numeric linkIds) ──────────────────────────────────────#xD; page.item as cb where linkId = '579664664652' then {#xD; page.item as u5c where linkId = '327509292099' then {#xD; page.item as u5d where linkId = '928912977066' then {#xD; page.item as o5c where linkId = '456099214566' then {#xD; page.item as o5d where linkId = '749207004486' then {#xD; cb where answer.exists() -> bundle.entry as e, e.resource = create('Observation') as obs then CreateSectionABObs(cb, u5c, u5d, o5c, o5d, obs) "onchocerciasisObs";#xD; } "o5d";#xD; } "o5c";#xD; } "u5d";#xD; } "u5c";#xD; } "onchocerciasis";#xD; } "diseasesPage";#xD; }#xD; #xD; // Helper: create a disease Observation with 4 components (under-5 cases/deaths, over-5 cases/deaths)#xD; group CreateSectionABObs(source cb : BackboneElement, source u5CasesItem : BackboneElement, source u5DeathsItem : BackboneElement, source o5CasesItem : BackboneElement, source o5DeathsItem : BackboneElement, target obs : Observation) {#xD; cb -> obs.id = uuid() "obsId";#xD; cb -> obs.status = 'final' "status";#xD; cb -> obs.category as cat then {#xD; cb -> cat.coding as cod, cod.system = 'http://terminology.hl7.org/CodeSystem/observation-category', cod.code = 'survey', cod.display = 'Survey' "cat";#xD; } "category";#xD; // Disease code from the checked answer#xD; cb.answer first as ans -> obs.code as code then {#xD; ans -> code.coding as cod, cod.system = 'http://example.org/CodeSystem/moh505-disease', cod.code = (ans.valueCoding.code), cod.display = (ans.valueCoding.display) "codeCoding";#xD; ans -> code.text = (ans.valueCoding.display) "codeText";#xD; } "diseaseCode";#xD; // Component: Under 5 Cases#xD; u5CasesItem.answer first as ans -> obs.component as comp then {#xD; ans -> comp.code as code, code.text = 'Under 5 Cases' "compCode";#xD; ans -> comp.valueInteger = ans.valueInteger "compValue";#xD; } "u5CasesComp";#xD; // Component: Under 5 Deaths#xD; u5DeathsItem.answer first as ans -> obs.component as comp then {#xD; ans -> comp.code as code, code.text = 'Under 5 Deaths' "compCode";#xD; ans -> comp.valueInteger = ans.valueInteger "compValue";#xD; } "u5DeathsComp";#xD; // Component: Over 5 Cases#xD; o5CasesItem.answer first as ans -> obs.component as comp then {#xD; ans -> comp.code as code, code.text = 'Over 5 Cases' "compCode";#xD; ans -> comp.valueInteger = ans.valueInteger "compValue";#xD; } "o5CasesComp";#xD; // Component: Over 5 Deaths#xD; o5DeathsItem.answer first as ans -> obs.component as comp then {#xD; ans -> comp.code as code, code.text = 'Over 5 Deaths' "compCode";#xD; ans -> comp.valueInteger = ans.valueInteger "compValue";#xD; } "o5DeathsComp";#xD; }#xD; #xD; // Helper: create an Observation with only under-5 components (for diseases like Neonatal Tetanus)#xD; group CreateSectionABObsPartial(source cb : BackboneElement, source u5CasesItem : BackboneElement, source u5DeathsItem : BackboneElement, target obs : Observation) {#xD; cb -> obs.id = uuid() "obsId";#xD; cb -> obs.status = 'final' "status";#xD; cb -> obs.category as cat then {#xD; cb -> cat.coding as cod, cod.system = 'http://terminology.hl7.org/CodeSystem/observation-category', cod.code = 'survey', cod.display = 'Survey' "cat";#xD; } "category";#xD; cb.answer first as ans -> obs.code as code then {#xD; ans -> code.coding as cod, cod.system = 'http://example.org/CodeSystem/moh505-disease', cod.code = (ans.valueCoding.code), cod.display = (ans.valueCoding.display) "codeCoding";#xD; ans -> code.text = (ans.valueCoding.display) "codeText";#xD; } "diseaseCode";#xD; u5CasesItem.answer first as ans -> obs.component as comp then {#xD; ans -> comp.code as code, code.text = 'Under 5 Cases' "compCode";#xD; ans -> comp.valueInteger = ans.valueInteger "compValue";#xD; } "u5CasesComp";#xD; u5DeathsItem.answer first as ans -> obs.component as comp then {#xD; ans -> comp.code as code, code.text = 'Under 5 Deaths' "compCode";#xD; ans -> comp.valueInteger = ans.valueInteger "compValue";#xD; } "u5DeathsComp";#xD; }#xD; #xD;
MOH 505 Section A and B QuestionnaireResponse to FHIR resources Maps disease tally counts to Observation resources (one per disease per reporting period) Observation.component encodes: under-5 cases, under-5 deaths, over-5 cases, over-5 deaths
linkId = 'acute-malnutrition-under5-cases'
linkId = 'acute-malnutrition-under5-deaths'
linkId = 'acute-malnutrition-over5-cases'
linkId = 'acute-malnutrition-over5-deaths'
linkId = 'afp-poliomyelitis-under5-cases'
linkId = 'afp-poliomyelitis-under5-deaths'
linkId = 'afp-poliomyelitis-over5-cases'
linkId = 'afp-poliomyelitis-over5-deaths'
linkId = 'dysentery-bacillary-under5-cases'
linkId = 'dysentery-bacillary-under5-deaths'
linkId = 'dysentery-bacillary-over5-cases'
linkId = 'dysentery-bacillary-over5-deaths'
linkId = 'guinea-worm-disease-under5-cases'
linkId = 'guinea-worm-disease-under5-deaths'
linkId = 'guinea-worm-disease-over5-cases'
linkId = 'guinea-worm-disease-over5-deaths'
linkId = 'suspected-malaria-under5-cases'
linkId = 'suspected-malaria-under5-deaths'
linkId = 'suspected-malaria-over5-cases'
linkId = 'suspected-malaria-over5-deaths'
Helper: create a disease Observation with 4 components (under-5 cases/deaths, over-5 cases/deaths)
Helper: create an Observation with only under-5 components (for diseases like Neonatal Tetanus)