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: Muscle Strengthening Sessions Q to O

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

Muscle Strengthening Sessions Q to O

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

// Muscle Strengthening Sessions 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 MuscleStrengtheningQuestionnaireResponseToObservation(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-muscle-strengthening-observation' "SetProfile";
  src -> tgt.code = cc('http://loinc.org', '82291-6', 'Frequency of muscle-strengthening physical activity') "SetCode";
  // effectiveDateTime from authored as quantity questionnaire has no embedded date item
  src.authored as authored -> tgt.effectiveDateTime = authored "SetEffectiveDateTime";
  src.item as item where linkId = 'muscle-strengthening-sessions' then MapMuscleStrengthening(item, tgt) "ProcessItem";
}

group MapMuscleStrengthening(source src : QR, target tgt : Obs) {
  src.answer as answer then {
    // Map quantity answer directly to Observation.value
    answer.valueQuantity as srcQty then MapMuscleStrengtheningQuantity(srcQty, tgt) "MapValueQuantity";
  } "ProcessAnswer";
}

group MapMuscleStrengtheningQuantity(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 = '{sessions}/wk',  qty.system = 'http://unitsofmeasure.org',  qty.code = '{sessions}/wk' "SetQuantity";
  } "ExtractValue";
}