PreNUDGE FHIR® IG for Data Provider / Data from Apps (R4)
0.1.0 - ci-build

PreNUDGE FHIR® IG for Data Provider / Data from Apps (R4) - Local Development build (v0.1.0) built by the FHIR (HL7® FHIR® Standard) Build Tools. See the Directory of published versions

StructureMap: Blood Glucose Q to O

Official URL: https://fhir.hl7.at/prenudge/appdata/r4/StructureMap/BloodGlucoseQuestionnaireResponseToObservation Version: 0.1.0
Active as of 2026-03-03 Responsible: The PreNUDGE Consortium Computable Name: BloodGlucoseQuestionnaireResponseToObservation

Blood Glucose Q to O

map "https://fhir.hl7.at/prenudge/appdata/r4/StructureMap/BloodGlucoseQuestionnaireResponseToObservation" = "BloodGlucoseQuestionnaireResponseToObservation"

// Blood Glucose Q to O

uses "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse" alias QR as source
uses "http://hl7.org/fhir/StructureDefinition/Observation" alias Obs as target
uses "http://hl7.org/fhir/StructureDefinition/Quantity" alias Quantity as source

imports "http://hl7.org/fhir/StructureMap/*"
imports "https://fhir.hl7.at/prenudge/appdata/r4/StructureMap/QuestionnaireResponseToObservationBase"

group BloodGlucoseQuestionnaireResponseToObservation(source src : QR, target tgt : Obs) {
  src then SetObservationBase(src, tgt) "Base";
  src ->  tgt.meta = create('Meta') as meta,  meta.profile = 'https://fhir.hl7.at/prenudge/appdata/r4/StructureDefinition/at-prenudge-bloodglucose-observation' "SetProfile";
  src -> tgt.code = cc('http://loinc.org', '1556-0', 'Fasting glucose [Mass/volume] in Capillary blood') "SetCode";
  src.item as item where linkId = 'blood-glucose-now' then MapBloodGlucose(item, tgt) "ProcessItem";
}

group MapBloodGlucose(source src : QR, target tgt : Obs) {
  src.answer as answer then {
    answer.valueQuantity as srcQty then MapBloodGlucoseQuantity(srcQty, tgt) "MapValueQuantity";
  } "ProcessAnswer";
// TODO: Note mapping disabled due to MaLaC-HD limitation
// Annotation.text (markdown) target not supported with FHIR string source
// See: https://gitlab.com/cdehealth/malac-hd/-/issues/128
// Map comment to note
// answer.item as commentItem where linkId = 'comment' then {
// commentItem.answer as commentAnswer then {
// commentAnswer.valueString as commentText then {
// commentText.value as tv -> tgt.note as note, note.text = tv "SetNoteText";
// } "ExtractText";
// } "ProcessCommentAnswer";
// } "ProcessComment";
}

group MapBloodGlucoseQuantity(source srcQty : Quantity, target tgt : Obs) {
  srcQty.value as v then {
    v.value as numVal ->  tgt.value = create('Quantity') as qty,  qty.value = numVal,  qty.unit = 'mg/dL',  qty.system = 'http://unitsofmeasure.org',  qty.code = 'mg/dL' "SetQuantity";
  } "ExtractValue";
}