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: Sitting Hours Q to O

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

Sitting Hours EHIS-PAQ Q9 / ATHIS PE9 to O

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

    // Sitting Hours EHIS-PAQ Q9 / ATHIS PE9 to O

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

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

    // ---------------------------------------------------------------------------
    // Main entry group
    // ---------------------------------------------------------------------------
    group SittingHoursQuestionnaireResponseToObservation(source src : QR, target tgt : Obs) {
      // Shared base: identifier copy, derivedFrom, subject, issued, status, method.
      src then SetObservationBase(src, tgt) "Base";
      // Target profile
      src ->  tgt.meta = create('Meta') as meta,  meta.profile = 'https://fhir.hl7.at/prenudge/appdata/r4/StructureDefinition/at-prenudge-sitting-hours-observation' "SetProfile";
      // Observation code
      src -> tgt.code = cc('http://loinc.org', '87705-0', 'Sedentary activity 24 hour') "SetCode";
      // effectiveDateTime from authored (Q9 has no embedded date sub-item)
      src.authored as authored -> tgt.effectiveDateTime = authored "SetEffectiveDateTime";
      // Map Q9 group to Observation.value
      src.item as item where linkId = 'Q9' then MapQ9ToSittingHours(item, tgt) "ProcessQ9";
    }

    // ---------------------------------------------------------------------------
    // Q9 → Observation.valueQuantity (h)
    // Only Q9-hours (integer) is mapped to Observation.valueQuantity.value.
    // Q9-minutes is not included because MaLaC-HD does not support evaluate()
    // with complex FHIRPath expressions (arithmetic or multi-token paths).
    // Sub-hour precision requires an engine that supports evaluate(), e.g. matchbox.
    // ---------------------------------------------------------------------------
    group MapQ9ToSittingHours(source src : QR, target tgt : Obs) {
      src.item as hoursItem where linkId = 'Q9-hours' then {
        hoursItem.answer as hoursAnswer then {
          hoursAnswer.valueInteger as hoursElem then {
            hoursElem.value as numVal ->  tgt.value = create('Quantity') as qty,  qty.value = numVal,  qty.unit = 'h',  qty.system = 'http://unitsofmeasure.org',  qty.code = 'h' "SetSittingQuantity";
          } "ExtractValue";
        } "ExtractHoursAnswer";
      } "ProcessHoursItem";
    }