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-07-01 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)
// Q9-total-hours (decimal, SDC calculatedExpression) is read using the
// MaLaC-HD 1.6.0 two-level .value unwrap pattern (valueDecimal → .value).
// The arithmetic Q9-hours + (Q9-minutes / 60) is pre-computed by the
// questionnaire; this map copies the result without evaluate().
// ---------------------------------------------------------------------------
group MapQ9ToSittingHours(source src : QR, target tgt : Obs) {
  src.item as totHours where linkId = 'Q9-total-hours' then {
    totHours.answer as ans then {
      ans.valueDecimal as decElem then {
        decElem.value as numVal ->  tgt.value = create('Quantity') as qty,  qty.value = numVal,  qty.unit = 'h',  qty.system = 'http://unitsofmeasure.org',  qty.code = 'h' "SetSittingQuantity";
      } "UnwrapDecimal";
    } "GetAnswer";
  } "GetTotalHours";
}