Generated Narrative: StructureMap BmiQuestionnaireResponseToObservations #xD; map "https://fhir.hl7.at/prenudge/appdata/r4/StructureMap/BmiQuestionnaireResponseToObservations" = "BmiQuestionnaireResponseToObservations"#xD; #xD; // BMI Q to Body Height, Body Weight and BMI Observations Bundle#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 Obs as target#xD; #xD; group BmiQuestionnaireResponseToObservations(source src : QR, target tgt : Bundle) {#xD; src -> tgt.type = 'collection' "SetBundleType";#xD; src -> tgt.entry as heightEntry, heightEntry.resource = create('Observation') as heightObs then {#xD; src then MapBodyHeightObservation(src, heightObs) "MapBodyHeightObservation";#xD; } "CreateBodyHeightEntry";#xD; src -> tgt.entry as weightEntry, weightEntry.resource = create('Observation') as weightObs then {#xD; src then MapBodyWeightObservation(src, weightObs) "MapBodyWeightObservation";#xD; } "CreateBodyWeightEntry";#xD; src -> tgt.entry as bmiEntry, bmiEntry.resource = create('Observation') as bmiObs then {#xD; src then MapBodyMassIndexObservation(src, bmiObs) "MapBodyMassIndexObservation";#xD; } "CreateBmiEntry";#xD; }#xD; #xD; group SetCommonObservationFields(source src : QR, target tgt : Obs) {#xD; src -> tgt.status = 'final' "setFinalStatus";#xD; src.subject as subject -> tgt.subject = subject "copySubject";#xD; src.authored as authored -> tgt.effective = authored "copyAuthoredToEffective";#xD; src.authored as authored -> tgt.issued = authored "copyAuthoredToIssued";#xD; src -> tgt.method = cc('http://snomed.info/sct', '87982008', 'Manual') "setManualMethod";#xD; src.id as id -> tgt.derivedFrom = create('Reference') as reference then {#xD; id -> reference.reference = append('QuestionnaireResponse/', id) "setDerivedFromReference";#xD; } "setDerivedFrom";#xD; }#xD; #xD; group MapBodyHeightObservation(source src : QR, target tgt : Obs) {#xD; src then SetCommonObservationFields(src, tgt) "SetCommonFields";#xD; src -> tgt.meta as meta, meta.profile = 'https://fhir.hl7.at/prenudge/appdata/r4/StructureDefinition/at-prenudge-bodyheight-observation' "SetProfile";#xD; src -> tgt.category = cc('http://terminology.hl7.org/CodeSystem/observation-category', 'vital-signs', 'Vital Signs') "SetCategory";#xD; src -> tgt.code = cc('http://loinc.org', '8302-2', 'Body height') "SetCode";#xD; src.identifier as identifier -> tgt.identifier = create('Identifier') as targetIdentifier then {#xD; identifier.system as system -> targetIdentifier.system = system "SetIdentifierSystem";#xD; identifier.value as value -> targetIdentifier.value = append(value, '-bodyheight') "SetIdentifierValue";#xD; } "SetIdentifier";#xD; src.item as bmiGroup where bmiGroup.linkId = 'bmi' then {#xD; bmiGroup.item as heightItem where heightItem.linkId = 'height-cm' then {#xD; heightItem.answer as answer then {#xD; answer.value as val then {#xD; val.value as numVal -> tgt.value = create('Quantity') as qty, qty.value = numVal, qty.unit = 'cm', qty.system = 'http://unitsofmeasure.org', qty.code = 'cm' "SetValue";#xD; } "ExtractPrimitiveValue";#xD; } "ProcessAnswer";#xD; } "ProcessHeightItem";#xD; } "ProcessBmiGroup";#xD; }#xD; #xD; group MapBodyWeightObservation(source src : QR, target tgt : Obs) {#xD; src then SetCommonObservationFields(src, tgt) "SetCommonFields";#xD; src -> tgt.meta as meta, meta.profile = 'https://fhir.hl7.at/prenudge/appdata/r4/StructureDefinition/at-prenudge-bodyweight-observation' "SetProfile";#xD; src -> tgt.category = cc('http://terminology.hl7.org/CodeSystem/observation-category', 'vital-signs', 'Vital Signs') "SetCategory";#xD; src -> tgt.code = cc('http://loinc.org', '29463-7', 'Body weight') "SetCode";#xD; src.identifier as identifier -> tgt.identifier = create('Identifier') as targetIdentifier then {#xD; identifier.system as system -> targetIdentifier.system = system "SetIdentifierSystem";#xD; identifier.value as value -> targetIdentifier.value = append(value, '-bodyweight') "SetIdentifierValue";#xD; } "SetIdentifier";#xD; src.item as bmiGroup where bmiGroup.linkId = 'bmi' then {#xD; bmiGroup.item as weightItem where weightItem.linkId = 'weight-kg' then {#xD; weightItem.answer as answer then {#xD; answer.value as val then {#xD; val.value as numVal -> tgt.value = create('Quantity') as qty, qty.value = numVal, qty.unit = 'kg', qty.system = 'http://unitsofmeasure.org', qty.code = 'kg' "SetValue";#xD; } "ExtractPrimitiveValue";#xD; } "ProcessAnswer";#xD; } "ProcessWeightItem";#xD; } "ProcessBmiGroup";#xD; }#xD; #xD; group MapBodyMassIndexObservation(source src : QR, target tgt : Obs) {#xD; src then SetCommonObservationFields(src, tgt) "SetCommonFields";#xD; src -> tgt.meta as meta, meta.profile = 'https://fhir.hl7.at/prenudge/appdata/r4/StructureDefinition/at-prenudge-bmi-observation' "SetProfile";#xD; src -> tgt.category = cc('http://terminology.hl7.org/CodeSystem/observation-category', 'vital-signs', 'Vital Signs') "SetCategory";#xD; src -> tgt.code = cc('http://loinc.org', '39156-5', 'Body mass index (BMI) [Ratio]') "SetCode";#xD; src.identifier as identifier -> tgt.identifier = create('Identifier') as targetIdentifier then {#xD; identifier.system as system -> targetIdentifier.system = system "SetIdentifierSystem";#xD; identifier.value as value -> targetIdentifier.value = append(value, '-bmi') "SetIdentifierValue";#xD; } "SetIdentifier";#xD; src.item as bmiGroup where bmiGroup.linkId = 'bmi' then {#xD; bmiGroup.item as bmiItem where bmiItem.linkId = 'bmi-kg-m2' then {#xD; bmiItem.answer as answer then {#xD; answer.value as val then {#xD; val.value as numVal -> tgt.value = create('Quantity') as qty, qty.value = numVal, qty.unit = 'kg/m2', qty.system = 'http://unitsofmeasure.org', qty.code = 'kg/m2' "SetValue";#xD; } "ExtractPrimitiveValue";#xD; } "ProcessAnswer";#xD; } "ProcessBmiItem";#xD; } "ProcessBmiGroup";#xD; }#xD; #xD;
BMI Q to Body Height, Body Weight and BMI Observations Bundle