@prefix fhir: <http://hl7.org/fhir/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

# - resource -------------------------------------------------------------------

<https://fhir.hl7.at/prenudge/appdata/r4/StructureMap/PhysicalActivityMinutesQtoO> a fhir:StructureMap ;
  fhir:nodeRole fhir:treeRoot ;
  fhir:Resource.id [ fhir:value "PhysicalActivityMinutesQtoO"] ;
  fhir:DomainResource.text [
     fhir:Narrative.status [ fhir:value "generated" ] ;
     fhir:Narrative.div "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p class=\"res-header-id\"><b>Generated Narrative: StructureMap PhysicalActivityMinutesQtoO</b></p><a name=\"PhysicalActivityMinutesQtoO\"> </a><a name=\"hcPhysicalActivityMinutesQtoO\"> </a><pre class=\"fml\">#xD;\n<b>map</b><span style=\"color: navy\"> \"</span>https://fhir.hl7.at/prenudge/appdata/r4/StructureMap/PhysicalActivityMinutesQtoO<span style=\"color: navy\">\" = \"</span>Physical Activity Minutes Q to O<span style=\"color: navy\">\"#xD;\n#xD;\n</span><span style=\"color: navy\">// </span><span style=\"color: green\">Physical Activity EHIS-PAQ Q7 / ATHIS PE7 to O (aggregate-only variant)</span>#xD;\n#xD;\n<b>uses</b><span style=\"color: navy\"> \"</span><a href=\"http://hl7.org/fhir/R4/questionnaireresponse.html\" title=\"QuestionnaireResponse\">http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse</a><span style=\"color: navy\">\" </span><b>alias </b>QR <b>as </b><b>source</b>#xD;\n<b>uses</b><span style=\"color: navy\"> \"</span><a href=\"http://hl7.org/fhir/R4/observation.html\" title=\"Observation\">http://hl7.org/fhir/StructureDefinition/Observation</a><span style=\"color: navy\">\" </span><b>alias </b>Obs <b>as </b><b>target</b>#xD;\n#xD;\n<b>imports</b><span style=\"color: navy\"> \"</span>http://hl7.org/fhir/StructureMap/*<span style=\"color: navy\">\"#xD;\n</span><b>imports</b><span style=\"color: navy\"> \"</span><a href=\"StructureMap-QuestionnaireResponseToObservationBase.html\" title=\"Shared base for Q to O\">https://fhir.hl7.at/prenudge/appdata/r4/StructureMap/QuestionnaireResponseToObservationBase</a><span style=\"color: navy\">\"#xD;\n</span>#xD;\n<span style=\"color: navy\">// </span><span style=\"color: green\">---------------------------------------------------------------------------</span>#xD;\n<span style=\"color: navy\">// </span><span style=\"color: green\">Main entry group</span>#xD;\n<span style=\"color: navy\">// </span><span style=\"color: green\">---------------------------------------------------------------------------</span>#xD;\n<b>group </b>PhysicalActivityQuestionnaireResponseToObservation<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">src</span><span style=\"color: navy\"> : </span>QR, <b>target</b> <span style=\"color: maroon\">tgt</span><span style=\"color: navy\"> : </span>Obs<span style=\"color: navy\">)</span><span style=\"color: navy\"> {#xD;\n</span>  <span style=\"color: navy\">// </span><span style=\"color: green\">Shared base: identifier copy, derivedFrom, subject, issued.</span>#xD;\n  <span style=\"color: navy\">// </span><span style=\"color: green\">SetObservationBase also sets method = SCT 87982008 (Manual) — correct for</span>#xD;\n  <span style=\"color: navy\">// </span><span style=\"color: green\">all questionnaire-derived observations in this IG.</span>#xD;\n  src<b> then </b>SetObservationBase<span style=\"color: navy\">(</span><span style=\"color: maroon\">src</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">tgt</span><span style=\"color: navy\">)</span> <i>\"Base\"</i><span style=\"color: navy\">;</span>#xD;\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Explicitly confirm method = Manual (base already does this; listed for clarity).</span>#xD;\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgt.method = <b>cc</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'http://snomed.info/sct'</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'87982008'</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'Manual'</span><span style=\"color: navy\">)</span> <i>\"SetMethodManual\"</i><span style=\"color: navy\">;</span>#xD;\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Target profile</span>#xD;\n  src<span style=\"color: navy\"><b> -&gt; </b></span> tgt.meta = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Meta'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">meta</span><span style=\"color: navy\">, </span> meta.profile = <span style=\"color: blue\">'https://fhir.hl7.at/prenudge/appdata/r4/StructureDefinition/at-prenudge-physical-activity-minutes-observation'</span> <i>\"SetProfile\"</i><span style=\"color: navy\">;</span>#xD;\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Panel code</span>#xD;\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgt.code = <b>cc</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'http://loinc.org'</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'101691-4'</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'Duration of physical activity'</span><span style=\"color: navy\">)</span> <i>\"SetCode\"</i><span style=\"color: navy\">;</span>#xD;\n  <span style=\"color: navy\">// </span><span style=\"color: green\">effectiveDateTime from authored (EHIS-PAQ Q7 has no embedded date item)</span>#xD;\n  src.authored<b> as </b><span style=\"color: maroon\">authored</span><span style=\"color: navy\"><b> -&gt; </b></span>tgt.effectiveDateTime = <span style=\"color: maroon\">authored</span> <i>\"SetEffectiveDateTime\"</i><span style=\"color: navy\">;</span>#xD;\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Map Q7 group to component[aggregateActivity]</span>#xD;\n  src.item<b> as </b><span style=\"color: maroon\">q7</span><b> where </b>linkId = 'Q7'<b> then </b>MapQ7ToAggregate<span style=\"color: navy\">(</span><span style=\"color: maroon\">q7</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">tgt</span><span style=\"color: navy\">)</span> <i>\"ProcessQ7\"</i><span style=\"color: navy\">;</span>#xD;\n<span style=\"color: navy\">// </span><span style=\"color: green\">component[moderateActivity] : NOT mapped</span>#xD;\n<span style=\"color: navy\">// </span><span style=\"color: green\">Q7 asks for total leisure activity time without separating intensity levels.</span>#xD;\n<span style=\"color: navy\">// </span><span style=\"color: green\">There is no questionnaire source for a moderate-only figure.</span>#xD;\n<span style=\"color: navy\">// </span><span style=\"color: green\">component[vigorousActivity] : NOT mapped</span>#xD;\n<span style=\"color: navy\">// </span><span style=\"color: green\">Total leisure time maps directly to aggregateActivity (see MapQ7ToAggregate).</span>#xD;\n<span style=\"color: navy\">// </span><span style=\"color: green\">component[classificationMethod] : NOT mapped</span>#xD;\n<span style=\"color: navy\">// </span><span style=\"color: green\">method = Manual → component must be absent or self-rp (pa-manual-comp-01).</span>#xD;\n<span style=\"color: navy\">// </span><span style=\"color: green\">The map does not set it; a consuming system may add self-rp post-transform</span>#xD;\n<span style=\"color: navy\">// </span><span style=\"color: green\">if explicit documentation of the classification basis is required.</span>#xD;\n<span style=\"color: navy\">}#xD;\n#xD;\n</span><span style=\"color: navy\">// </span><span style=\"color: green\">---------------------------------------------------------------------------</span>#xD;\n<span style=\"color: navy\">// </span><span style=\"color: green\">Q7 → component[aggregateActivity]  (LOINC 101691-4)</span>#xD;\n<span style=\"color: navy\">// </span><span style=\"color: green\">Formula: aggregateMinutes = (Q7-hours × 60) + Q7-minutes</span>#xD;\n<span style=\"color: navy\">// </span><span style=\"color: green\">The arithmetic is performed by the questionnaire via the SDC</span>#xD;\n<span style=\"color: navy\">// </span><span style=\"color: green\">calculatedExpression extension on item Q7-total-minutes (FHIRPath:</span>#xD;\n<span style=\"color: navy\">// </span><span style=\"color: green\">(%resource.item.where(linkId='Q7').item.where(linkId='Q7-hours').answer.valueInteger * 60)</span>#xD;\n<span style=\"color: navy\">// </span><span style=\"color: green\">+ %resource.item.where(linkId='Q7').item.where(linkId='Q7-minutes').answer.valueInteger</span>#xD;\n<span style=\"color: navy\">// </span><span style=\"color: green\">). This map reads the pre-computed integer — no evaluate() needed.</span>#xD;\n<span style=\"color: navy\">// </span><span style=\"color: green\">MaLaC-HD 1.6.0 integer extraction pattern used here:</span>#xD;\n<span style=\"color: navy\">// </span><span style=\"color: green\">answer.valueInteger as intElem then { intElem.value as numVal → ... }</span>#xD;\n<span style=\"color: navy\">// </span><span style=\"color: green\">The double .value unwrap gives MaLaC-HD a raw primitive it can copy</span>#xD;\n<span style=\"color: navy\">// </span><span style=\"color: green\">into Quantity.value without a type-coercion crash (direct integer→decimal</span>#xD;\n<span style=\"color: navy\">// </span><span style=\"color: green\">copy fails in MaLaC-HD). All Quantity fields are set in one rule so that</span>#xD;\n<span style=\"color: navy\">// </span><span style=\"color: green\">no cross-scope variable reference occurs (also a MaLaC-HD limitation).</span>#xD;\n<span style=\"color: navy\">// </span><span style=\"color: green\">---------------------------------------------------------------------------</span>#xD;\n<b>group </b>MapQ7ToAggregate<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">src</span><span style=\"color: navy\"> : </span>QR, <b>target</b> <span style=\"color: maroon\">tgt</span><span style=\"color: navy\"> : </span>Obs<span style=\"color: navy\">)</span><span style=\"color: navy\"> {#xD;\n</span>  <span style=\"color: navy\">// </span><span style=\"color: green\">src is the Q7 group item; Q7-total-minutes is a calculated child item.</span>#xD;\n  src.item<b> as </b><span style=\"color: maroon\">totMins</span><b> where </b>linkId = 'Q7-total-minutes'<b> then</b><span style=\"color: navy\"> {#xD;\n</span>    totMins.answer<b> as </b><span style=\"color: maroon\">ans</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>      ans.valueInteger<b> as </b><span style=\"color: maroon\">intElem</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>        intElem.value<b> as </b><span style=\"color: maroon\">numVal</span><span style=\"color: navy\"><b> -&gt; </b></span> tgt.component<b> as </b><span style=\"color: maroon\">aggComp</span><span style=\"color: navy\">, </span> aggComp.code = <b>cc</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'http://loinc.org'</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'101691-4'</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'Duration of physical activity'</span><span style=\"color: navy\">)</span><span style=\"color: navy\">, </span> aggComp.value = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Quantity'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">qty</span><span style=\"color: navy\">, </span> qty.value = <span style=\"color: maroon\">numVal</span><span style=\"color: navy\">, </span> qty.unit = <span style=\"color: blue\">'min/wk'</span><span style=\"color: navy\">, </span> qty.system = <span style=\"color: blue\">'http://unitsofmeasure.org'</span><span style=\"color: navy\">, </span> qty.code = <span style=\"color: blue\">'min/wk'</span> <i>\"SetAggregateComponent\"</i><span style=\"color: navy\">;</span>#xD;\n      <span style=\"color: navy\">}</span> <i>\"UnwrapInteger\"</i><span style=\"color: navy\">;</span>#xD;\n    <span style=\"color: navy\">}</span> <i>\"GetAnswer\"</i><span style=\"color: navy\">;</span>#xD;\n  <span style=\"color: navy\">}</span> <i>\"GetTotalMins\"</i><span style=\"color: navy\">;</span>#xD;\n<span style=\"color: navy\">}#xD;\n#xD;\n</span></pre></div>"
  ] ;
  fhir:StructureMap.url [ fhir:value "https://fhir.hl7.at/prenudge/appdata/r4/StructureMap/PhysicalActivityMinutesQtoO"] ;
  fhir:StructureMap.version [ fhir:value "0.1.0"] ;
  fhir:StructureMap.name [ fhir:value "Physical Activity Minutes Q to O"] ;
  fhir:StructureMap.status [ fhir:value "draft"] ;
  fhir:StructureMap.date [ fhir:value "2026-07-01T10:20:10+00:00"^^xsd:dateTime] ;
  fhir:StructureMap.publisher [ fhir:value "The PreNUDGE Consortium"] ;
  fhir:StructureMap.contact [
     fhir:index 0 ;
     fhir:ContactDetail.name [ fhir:value "The PreNUDGE Consortium" ] ;
     fhir:ContactDetail.telecom [
       fhir:index 0 ;
       fhir:ContactPoint.system [ fhir:value "url" ] ;
       fhir:ContactPoint.value [ fhir:value "https://prenudge.at" ]
     ]
  ], [
     fhir:index 1 ;
     fhir:ContactDetail.name [ fhir:value "The PreNUDGE Consortium" ] ;
     fhir:ContactDetail.telecom [
       fhir:index 0 ;
       fhir:ContactPoint.system [ fhir:value "url" ] ;
       fhir:ContactPoint.value [ fhir:value "https://prenudge.at" ] ;
       fhir:ContactPoint.use [ fhir:value "work" ]
     ]
  ] ;
  fhir:StructureMap.description [ fhir:value "Physical Activity EHIS-PAQ Q7 / ATHIS PE7 to O (aggregate-only variant)"] ;
  fhir:StructureMap.structure [
     fhir:index 0 ;
     fhir:StructureMap.structure.url [
       fhir:value "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse" ;
       fhir:link <http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse>
     ] ;
     fhir:StructureMap.structure.mode [ fhir:value "source" ] ;
     fhir:StructureMap.structure.alias [ fhir:value "QR" ]
  ], [
     fhir:index 1 ;
     fhir:StructureMap.structure.url [
       fhir:value "http://hl7.org/fhir/StructureDefinition/Observation" ;
       fhir:link <http://hl7.org/fhir/StructureDefinition/Observation>
     ] ;
     fhir:StructureMap.structure.mode [ fhir:value "target" ] ;
     fhir:StructureMap.structure.alias [ fhir:value "Obs" ]
  ] ;
  fhir:StructureMap.import [
     fhir:value "http://hl7.org/fhir/StructureMap/*" ;
     fhir:index 0 ;
     fhir:link <http://hl7.org/fhir/StructureMap/*>
  ], [
     fhir:value "https://fhir.hl7.at/prenudge/appdata/r4/StructureMap/QuestionnaireResponseToObservationBase" ;
     fhir:index 1 ;
     fhir:link <https://fhir.hl7.at/prenudge/appdata/r4/StructureMap/QuestionnaireResponseToObservationBase>
  ] ;
  fhir:StructureMap.group [
     fhir:index 0 ;
     fhir:StructureMap.group.name [ fhir:value "PhysicalActivityQuestionnaireResponseToObservation" ] ;
     fhir:StructureMap.group.typeMode [ fhir:value "none" ] ;
     fhir:StructureMap.group.documentation [ fhir:value "---------------------------------------------------------------------------\r\nMain entry group\r\n---------------------------------------------------------------------------" ] ;
     fhir:StructureMap.group.input [
       fhir:index 0 ;
       fhir:StructureMap.group.input.name [ fhir:value "src" ] ;
       fhir:StructureMap.group.input.type [ fhir:value "QR" ] ;
       fhir:StructureMap.group.input.mode [ fhir:value "source" ]
     ], [
       fhir:index 1 ;
       fhir:StructureMap.group.input.name [ fhir:value "tgt" ] ;
       fhir:StructureMap.group.input.type [ fhir:value "Obs" ] ;
       fhir:StructureMap.group.input.mode [ fhir:value "target" ]
     ] ;
     fhir:StructureMap.group.rule [
       fhir:index 0 ;
       fhir:StructureMap.group.rule.name [ fhir:value "Base" ] ;
       fhir:StructureMap.group.rule.source [
         fhir:index 0 ;
         fhir:StructureMap.group.rule.source.context [ fhir:value "src" ]
       ] ;
       fhir:StructureMap.group.rule.dependent [
         fhir:index 0 ;
         fhir:StructureMap.group.rule.dependent.name [ fhir:value "SetObservationBase" ] ;
         fhir:StructureMap.group.rule.dependent.variable [
           fhir:value "src" ;
           fhir:index 0
         ], [
           fhir:value "tgt" ;
           fhir:index 1
         ]
       ]
     ], [
       fhir:index 1 ;
       fhir:StructureMap.group.rule.name [ fhir:value "SetMethodManual" ] ;
       fhir:StructureMap.group.rule.source [
         fhir:index 0 ;
         fhir:StructureMap.group.rule.source.context [ fhir:value "src" ]
       ] ;
       fhir:StructureMap.group.rule.target [
         fhir:index 0 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "tgt" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "method" ] ;
         fhir:StructureMap.group.rule.target.transform [ fhir:value "cc" ] ;
         fhir:StructureMap.group.rule.target.parameter [
           fhir:index 0 ;
           fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "http://snomed.info/sct" ]
         ], [
           fhir:index 1 ;
           fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "87982008" ]
         ], [
           fhir:index 2 ;
           fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "Manual" ]
         ]
       ]
     ], [
       fhir:index 2 ;
       fhir:StructureMap.group.rule.name [ fhir:value "SetProfile" ] ;
       fhir:StructureMap.group.rule.source [
         fhir:index 0 ;
         fhir:StructureMap.group.rule.source.context [ fhir:value "src" ]
       ] ;
       fhir:StructureMap.group.rule.target [
         fhir:index 0 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "tgt" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "meta" ] ;
         fhir:StructureMap.group.rule.target.variable [ fhir:value "meta" ] ;
         fhir:StructureMap.group.rule.target.transform [ fhir:value "create" ] ;
         fhir:StructureMap.group.rule.target.parameter [
           fhir:index 0 ;
           fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "Meta" ]
         ]
       ], [
         fhir:index 1 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "meta" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "profile" ] ;
         fhir:StructureMap.group.rule.target.transform [ fhir:value "copy" ] ;
         fhir:StructureMap.group.rule.target.parameter [
           fhir:index 0 ;
           fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "https://fhir.hl7.at/prenudge/appdata/r4/StructureDefinition/at-prenudge-physical-activity-minutes-observation" ]
         ]
       ]
     ], [
       fhir:index 3 ;
       fhir:StructureMap.group.rule.name [ fhir:value "SetCode" ] ;
       fhir:StructureMap.group.rule.source [
         fhir:index 0 ;
         fhir:StructureMap.group.rule.source.context [ fhir:value "src" ]
       ] ;
       fhir:StructureMap.group.rule.target [
         fhir:index 0 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "tgt" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "code" ] ;
         fhir:StructureMap.group.rule.target.transform [ fhir:value "cc" ] ;
         fhir:StructureMap.group.rule.target.parameter [
           fhir:index 0 ;
           fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "http://loinc.org" ]
         ], [
           fhir:index 1 ;
           fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "101691-4" ]
         ], [
           fhir:index 2 ;
           fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "Duration of physical activity" ]
         ]
       ]
     ], [
       fhir:index 4 ;
       fhir:StructureMap.group.rule.name [ fhir:value "SetEffectiveDateTime" ] ;
       fhir:StructureMap.group.rule.source [
         fhir:index 0 ;
         fhir:StructureMap.group.rule.source.context [ fhir:value "src" ] ;
         fhir:StructureMap.group.rule.source.element [ fhir:value "authored" ] ;
         fhir:StructureMap.group.rule.source.variable [ fhir:value "authored" ]
       ] ;
       fhir:StructureMap.group.rule.target [
         fhir:index 0 ;
         fhir:StructureMap.group.rule.target.context [ fhir:value "tgt" ] ;
         fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
         fhir:StructureMap.group.rule.target.element [ fhir:value "effectiveDateTime" ] ;
         fhir:StructureMap.group.rule.target.transform [ fhir:value "copy" ] ;
         fhir:StructureMap.group.rule.target.parameter [
           fhir:index 0 ;
           fhir:StructureMap.group.rule.target.parameter.valueId [ fhir:value "authored" ]
         ]
       ]
     ], [
       fhir:index 5 ;
       fhir:StructureMap.group.rule.name [ fhir:value "ProcessQ7" ] ;
       fhir:StructureMap.group.rule.source [
         fhir:index 0 ;
         fhir:StructureMap.group.rule.source.context [ fhir:value "src" ] ;
         fhir:StructureMap.group.rule.source.element [ fhir:value "item" ] ;
         fhir:StructureMap.group.rule.source.variable [ fhir:value "q7" ] ;
         fhir:StructureMap.group.rule.source.condition [ fhir:value "linkId = 'Q7'" ]
       ] ;
       fhir:StructureMap.group.rule.dependent [
         fhir:index 0 ;
         fhir:StructureMap.group.rule.dependent.name [ fhir:value "MapQ7ToAggregate" ] ;
         fhir:StructureMap.group.rule.dependent.variable [
           fhir:value "q7" ;
           fhir:index 0
         ], [
           fhir:value "tgt" ;
           fhir:index 1
         ]
       ]
     ]
  ], [
     fhir:index 1 ;
     fhir:StructureMap.group.name [ fhir:value "MapQ7ToAggregate" ] ;
     fhir:StructureMap.group.typeMode [ fhir:value "none" ] ;
     fhir:StructureMap.group.documentation [ fhir:value "---------------------------------------------------------------------------\r\nQ7 → component[aggregateActivity]  (LOINC 101691-4)\r\nFormula: aggregateMinutes = (Q7-hours × 60) + Q7-minutes\r\nThe arithmetic is performed by the questionnaire via the SDC\r\ncalculatedExpression extension on item Q7-total-minutes (FHIRPath:\r\n(%resource.item.where(linkId='Q7').item.where(linkId='Q7-hours').answer.valueInteger * 60)\r\n+ %resource.item.where(linkId='Q7').item.where(linkId='Q7-minutes').answer.valueInteger\r\n). This map reads the pre-computed integer — no evaluate() needed.\r\nMaLaC-HD 1.6.0 integer extraction pattern used here:\r\nanswer.valueInteger as intElem then { intElem.value as numVal → ... }\r\nThe double .value unwrap gives MaLaC-HD a raw primitive it can copy\r\ninto Quantity.value without a type-coercion crash (direct integer→decimal\r\ncopy fails in MaLaC-HD). All Quantity fields are set in one rule so that\r\nno cross-scope variable reference occurs (also a MaLaC-HD limitation).\r\n---------------------------------------------------------------------------" ] ;
     fhir:StructureMap.group.input [
       fhir:index 0 ;
       fhir:StructureMap.group.input.name [ fhir:value "src" ] ;
       fhir:StructureMap.group.input.type [ fhir:value "QR" ] ;
       fhir:StructureMap.group.input.mode [ fhir:value "source" ]
     ], [
       fhir:index 1 ;
       fhir:StructureMap.group.input.name [ fhir:value "tgt" ] ;
       fhir:StructureMap.group.input.type [ fhir:value "Obs" ] ;
       fhir:StructureMap.group.input.mode [ fhir:value "target" ]
     ] ;
     fhir:StructureMap.group.rule [
       fhir:index 0 ;
       fhir:StructureMap.group.rule.name [ fhir:value "GetTotalMins" ] ;
       fhir:StructureMap.group.rule.source [
         fhir:index 0 ;
         fhir:StructureMap.group.rule.source.context [ fhir:value "src" ] ;
         fhir:StructureMap.group.rule.source.element [ fhir:value "item" ] ;
         fhir:StructureMap.group.rule.source.variable [ fhir:value "totMins" ] ;
         fhir:StructureMap.group.rule.source.condition [ fhir:value "linkId = 'Q7-total-minutes'" ]
       ] ;
       fhir:StructureMap.group.rule.rule [
         fhir:index 0 ;
         fhir:StructureMap.group.rule.name [ fhir:value "GetAnswer" ] ;
         fhir:StructureMap.group.rule.source [
           fhir:index 0 ;
           fhir:StructureMap.group.rule.source.context [ fhir:value "totMins" ] ;
           fhir:StructureMap.group.rule.source.element [ fhir:value "answer" ] ;
           fhir:StructureMap.group.rule.source.variable [ fhir:value "ans" ]
         ] ;
         fhir:StructureMap.group.rule.rule [
           fhir:index 0 ;
           fhir:StructureMap.group.rule.name [ fhir:value "UnwrapInteger" ] ;
           fhir:StructureMap.group.rule.source [
             fhir:index 0 ;
             fhir:StructureMap.group.rule.source.context [ fhir:value "ans" ] ;
             fhir:StructureMap.group.rule.source.element [ fhir:value "valueInteger" ] ;
             fhir:StructureMap.group.rule.source.variable [ fhir:value "intElem" ]
           ] ;
           fhir:StructureMap.group.rule.rule [
             fhir:index 0 ;
             fhir:StructureMap.group.rule.name [ fhir:value "SetAggregateComponent" ] ;
             fhir:StructureMap.group.rule.source [
               fhir:index 0 ;
               fhir:StructureMap.group.rule.source.context [ fhir:value "intElem" ] ;
               fhir:StructureMap.group.rule.source.element [ fhir:value "value" ] ;
               fhir:StructureMap.group.rule.source.variable [ fhir:value "numVal" ]
             ] ;
             fhir:StructureMap.group.rule.target [
               fhir:index 0 ;
               fhir:StructureMap.group.rule.target.context [ fhir:value "tgt" ] ;
               fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
               fhir:StructureMap.group.rule.target.element [ fhir:value "component" ] ;
               fhir:StructureMap.group.rule.target.variable [ fhir:value "aggComp" ]
             ], [
               fhir:index 1 ;
               fhir:StructureMap.group.rule.target.context [ fhir:value "aggComp" ] ;
               fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
               fhir:StructureMap.group.rule.target.element [ fhir:value "code" ] ;
               fhir:StructureMap.group.rule.target.transform [ fhir:value "cc" ] ;
               fhir:StructureMap.group.rule.target.parameter [
                 fhir:index 0 ;
                 fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "http://loinc.org" ]
               ], [
                 fhir:index 1 ;
                 fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "101691-4" ]
               ], [
                 fhir:index 2 ;
                 fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "Duration of physical activity" ]
               ]
             ], [
               fhir:index 2 ;
               fhir:StructureMap.group.rule.target.context [ fhir:value "aggComp" ] ;
               fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
               fhir:StructureMap.group.rule.target.element [ fhir:value "value" ] ;
               fhir:StructureMap.group.rule.target.variable [ fhir:value "qty" ] ;
               fhir:StructureMap.group.rule.target.transform [ fhir:value "create" ] ;
               fhir:StructureMap.group.rule.target.parameter [
                 fhir:index 0 ;
                 fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "Quantity" ]
               ]
             ], [
               fhir:index 3 ;
               fhir:StructureMap.group.rule.target.context [ fhir:value "qty" ] ;
               fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
               fhir:StructureMap.group.rule.target.element [ fhir:value "value" ] ;
               fhir:StructureMap.group.rule.target.transform [ fhir:value "copy" ] ;
               fhir:StructureMap.group.rule.target.parameter [
                 fhir:index 0 ;
                 fhir:StructureMap.group.rule.target.parameter.valueId [ fhir:value "numVal" ]
               ]
             ], [
               fhir:index 4 ;
               fhir:StructureMap.group.rule.target.context [ fhir:value "qty" ] ;
               fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
               fhir:StructureMap.group.rule.target.element [ fhir:value "unit" ] ;
               fhir:StructureMap.group.rule.target.transform [ fhir:value "copy" ] ;
               fhir:StructureMap.group.rule.target.parameter [
                 fhir:index 0 ;
                 fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "min/wk" ]
               ]
             ], [
               fhir:index 5 ;
               fhir:StructureMap.group.rule.target.context [ fhir:value "qty" ] ;
               fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
               fhir:StructureMap.group.rule.target.element [ fhir:value "system" ] ;
               fhir:StructureMap.group.rule.target.transform [ fhir:value "copy" ] ;
               fhir:StructureMap.group.rule.target.parameter [
                 fhir:index 0 ;
                 fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "http://unitsofmeasure.org" ]
               ]
             ], [
               fhir:index 6 ;
               fhir:StructureMap.group.rule.target.context [ fhir:value "qty" ] ;
               fhir:StructureMap.group.rule.target.contextType [ fhir:value "variable" ] ;
               fhir:StructureMap.group.rule.target.element [ fhir:value "code" ] ;
               fhir:StructureMap.group.rule.target.transform [ fhir:value "copy" ] ;
               fhir:StructureMap.group.rule.target.parameter [
                 fhir:index 0 ;
                 fhir:StructureMap.group.rule.target.parameter.valueString [ fhir:value "min/wk" ]
               ]
             ]
           ]
         ]
       ]
     ]
  ] .

# - ontology header ------------------------------------------------------------

<https://fhir.hl7.at/prenudge/appdata/r4/StructureMap/PhysicalActivityMinutesQtoO.ttl> a owl:Ontology ;
  owl:imports fhir:fhir.ttl .

# -------------------------------------------------------------------------------------

