<?xml version="1.0" encoding="UTF-8"?>

<StructureMap xmlns="http://hl7.org/fhir">
  <id value="SmokingStatusQuestionnaireResponseToObservation"/>
  <text>
    <status value="generated"/><div xmlns="http://www.w3.org/1999/xhtml"><p class="res-header-id"><b>Generated Narrative: StructureMap SmokingStatusQuestionnaireResponseToObservation</b></p><a name="SmokingStatusQuestionnaireResponseToObservation"> </a><a name="hcSmokingStatusQuestionnaireResponseToObservation"> </a><pre class="fml">
<b>map</b><span style="color: navy"> &quot;</span>https://fhir.hl7.at/prenudge/appdata/r4/StructureMap/SmokingStatusQuestionnaireResponseToObservation<span style="color: navy">&quot; = &quot;</span>SmokingStatusQuestionnaireResponseToObservation<span style="color: navy">&quot;

</span><span style="color: navy">// </span><span style="color: green">ATHIS-based Smoking Status Q to O</span>

<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/questionnaireresponse.html" title="QuestionnaireResponse">http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse</a><span style="color: navy">&quot; </span><b>alias </b>QR <b>as </b><b>source</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/observation.html" title="Observation">http://hl7.org/fhir/StructureDefinition/Observation</a><span style="color: navy">&quot; </span><b>alias </b>Obs <b>as </b><b>target</b>

<b>group </b>SmokingStatusQuestionnaireResponseToObservation<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"> {
</span>  <span style="color: navy">// </span><span style="color: green">Administrative metadata. Implementations may replace or enrich the identifier</span>
  <span style="color: navy">// </span><span style="color: green">if the Observation needs a separate stable business identifier.</span>
  src<span style="color: navy"><b> -&gt; </b></span>tgt.status = <span style="color: blue">'final'</span> <i>&quot;setFinalStatus&quot;</i><span style="color: navy">;</span>
  src.identifier<b> as </b><span style="color: maroon">identifier</span><span style="color: navy"><b> -&gt; </b></span>tgt.identifier = <span style="color: maroon">identifier</span> <i>&quot;copyIdentifier&quot;</i><span style="color: navy">;</span>
  src.subject<b> as </b><span style="color: maroon">subject</span><span style="color: navy"><b> -&gt; </b></span>tgt.subject = <span style="color: maroon">subject</span> <i>&quot;copySubject&quot;</i><span style="color: navy">;</span>
  src.authored<b> as </b><span style="color: maroon">authored</span><span style="color: navy"><b> -&gt; </b></span> tgt.effective = <span style="color: maroon">authored</span><span style="color: navy">, </span> tgt.issued = <span style="color: maroon">authored</span> <i>&quot;copyAuthoredToObservationTimes&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">IPS/APS-style tobacco smoking status coding.</span>
  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">'72166-2'</span><span style="color: navy">, </span><span style="color: blue">'Tobacco smoking status'</span><span style="color: navy">)</span> <i>&quot;setTobaccoSmokingStatusCode&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">User-entered QuestionnaireResponse data is considered manual input.</span>
  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>&quot;setManualMethod&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">Keep the derivation from QuestionnaireResponse to Observation traceable.</span>
  src.id<b> as </b><span style="color: maroon">id</span><span style="color: navy"><b> -&gt; </b></span>tgt.derivedFrom = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><b> then</b><span style="color: navy"> {
</span>    id<span style="color: navy"><b> -&gt; </b></span>reference.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'QuestionnaireResponse/'</span><span style="color: navy">, </span><span style="color: maroon">id</span><span style="color: navy">)</span> <i>&quot;setDerivedFromReference&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;setDerivedFrom&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">ATHIS answer mapping to the clinical SNOMED CT valueCodeableConcept.</span>
  src.item<b> as </b><span style="color: maroon">groupItem</span><b> where </b>groupItem.linkId = 'smoking-status-athis'<b> then </b>SmokingStatusGroupToObservation<span style="color: navy">(</span><span style="color: maroon">groupItem</span><span style="color: navy">, </span><span style="color: maroon">tgt</span><span style="color: navy">)</span> <i>&quot;mapSmokingStatusGroup&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>SmokingStatusGroupToObservation<span style="color: navy">(</span><b>source</b> <span style="color: maroon">groupItem</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"> {
</span>  <span style="color: navy">// </span><span style="color: green">SK1 = Ja, täglich -&gt; current every day smoker.</span>
  groupItem.item<b> as </b><span style="color: maroon">sk1</span><b> where </b>sk1.linkId = 'sk1'<b> then</b><span style="color: navy"> {
</span>    sk1.answer<b> as </b><span style="color: maroon">answer</span><b> then</b><span style="color: navy"> {
</span>      answer.valueCoding<b> as </b><span style="color: maroon">coding</span><b> where </b>(coding.system = 'https://fhir.hl7.at/prenudge/appdata/r4/CodeSystem/athis-answers') and (coding.code = 'yn-yes-daily')<span style="color: navy"><b> -&gt; </b></span>tgt.valueCodeableConcept = <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">'449868002'</span><span style="color: navy">, </span><span style="color: blue">'Smokes tobacco daily'</span><span style="color: navy">)</span> <i>&quot;mapCurrentDailySmoker&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;evaluateSk1Daily&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;sk1Daily&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">SK1 = Ja, gelegentlich -&gt; current occasional smoker.</span>
  groupItem.item<b> as </b><span style="color: maroon">sk1</span><b> where </b>sk1.linkId = 'sk1'<b> then</b><span style="color: navy"> {
</span>    sk1.answer<b> as </b><span style="color: maroon">answer</span><b> then</b><span style="color: navy"> {
</span>      answer.valueCoding<b> as </b><span style="color: maroon">coding</span><b> where </b>(coding.system = 'https://fhir.hl7.at/prenudge/appdata/r4/CodeSystem/athis-answers') and (coding.code = 'yn-yes-occasionally')<span style="color: navy"><b> -&gt; </b></span>tgt.valueCodeableConcept = <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">'428041000124106'</span><span style="color: navy">, </span><span style="color: blue">'Occasional tobacco smoker'</span><span style="color: navy">)</span> <i>&quot;mapCurrentOccasionalSmoker&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;evaluateSk1Occasional&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;sk1Occasional&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">SK1 = Nein and past tobacco smoking = Ja, täglich or Ja, gelegentlich -&gt; former smoker.</span>
  <span style="color: navy">// </span><span style="color: green">The past-tobacco-smoking item is enabled only when SK1 is negative.</span>
  groupItem.item<b> as </b><span style="color: maroon">past</span><b> where </b>past.linkId = 'past-tobacco-smoking'<b> then</b><span style="color: navy"> {
</span>    past.answer<b> as </b><span style="color: maroon">answer</span><b> then</b><span style="color: navy"> {
</span>      answer.valueCoding<b> as </b><span style="color: maroon">coding</span><b> where </b>(coding.system = 'https://fhir.hl7.at/prenudge/appdata/r4/CodeSystem/athis-answers') and (coding.code = 'yn-yes-daily')<span style="color: navy"><b> -&gt; </b></span>tgt.valueCodeableConcept = <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">'8517006'</span><span style="color: navy">, </span><span style="color: blue">'Ex-smoker'</span><span style="color: navy">)</span> <i>&quot;mapPastDailyToFormerSmoker&quot;</i><span style="color: navy">;</span>
      answer.valueCoding<b> as </b><span style="color: maroon">coding</span><b> where </b>(coding.system = 'https://fhir.hl7.at/prenudge/appdata/r4/CodeSystem/athis-answers') and (coding.code = 'yn-yes-occasionally')<span style="color: navy"><b> -&gt; </b></span>tgt.valueCodeableConcept = <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">'8517006'</span><span style="color: navy">, </span><span style="color: blue">'Ex-smoker'</span><span style="color: navy">)</span> <i>&quot;mapPastOccasionalToFormerSmoker&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;evaluatePastSmoking&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;pastSmokingFormer&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">// </span><span style="color: green">SK1 = Nein and past tobacco smoking = Nein -&gt; never smoker.</span>
  groupItem.item<b> as </b><span style="color: maroon">past</span><b> where </b>past.linkId = 'past-tobacco-smoking'<b> then</b><span style="color: navy"> {
</span>    past.answer<b> as </b><span style="color: maroon">answer</span><b> then</b><span style="color: navy"> {
</span>      answer.valueCoding<b> as </b><span style="color: maroon">coding</span><b> where </b>(coding.system = 'https://fhir.hl7.at/prenudge/appdata/r4/CodeSystem/athis-answers') and (coding.code = 'yn-no')<span style="color: navy"><b> -&gt; </b></span>tgt.valueCodeableConcept = <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">'266919005'</span><span style="color: navy">, </span><span style="color: blue">'Never smoked tobacco'</span><span style="color: navy">)</span> <i>&quot;mapPastNoToNeverSmoker&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;evaluatePastNo&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;pastSmokingNever&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span></pre></div>
  </text>
  <url value="https://fhir.hl7.at/prenudge/appdata/r4/StructureMap/SmokingStatusQuestionnaireResponseToObservation"/>
  <version value="0.1.0"/>
  <name value="SmokingStatusQuestionnaireResponseToObservation"/>
  <title value="ATHIS-based Smoking Status Q to O"/>
  <status value="active"/>
  <date value="2026-06-03T13:38:36+00:00"/>
  <publisher value="The PreNUDGE Consortium"/>
  <contact>
    <name value="The PreNUDGE Consortium"/>
    <telecom>
      <system value="url"/>
      <value value="https://prenudge.at"/>
    </telecom>
  </contact>
  <contact>
    <name value="The PreNUDGE Consortium"/>
    <telecom>
      <system value="url"/>
      <value value="https://prenudge.at"/>
      <use value="work"/>
    </telecom>
  </contact>
  <description value="ATHIS-based Smoking Status Q to O"/>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse"/>
    <mode value="source"/>
    <alias value="QR"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Observation"/>
    <mode value="target"/>
    <alias value="Obs"/>
  </structure>
  <group>
    <name value="SmokingStatusQuestionnaireResponseToObservation"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="QR"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="Obs"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="setFinalStatus"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="final"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="copyIdentifier"/>
      <source>
        <context value="src"/>
        <element value="identifier"/>
        <variable value="identifier"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="identifier"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="copySubject"/>
      <source>
        <context value="src"/>
        <element value="subject"/>
        <variable value="subject"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="subject"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="subject"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="copyAuthoredToObservationTimes"/>
      <source>
        <context value="src"/>
        <element value="authored"/>
        <variable value="authored"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="effective"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="authored"/>
        </parameter>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="issued"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="authored"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="setTobaccoSmokingStatusCode"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="code"/>
        <transform value="cc"/>
        <parameter>
          <valueString value="http://loinc.org"/>
        </parameter>
        <parameter>
          <valueString value="72166-2"/>
        </parameter>
        <parameter>
          <valueString value="Tobacco smoking status"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="setManualMethod"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="method"/>
        <transform value="cc"/>
        <parameter>
          <valueString value="http://snomed.info/sct"/>
        </parameter>
        <parameter>
          <valueString value="87982008"/>
        </parameter>
        <parameter>
          <valueString value="Manual"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="setDerivedFrom"/>
      <source>
        <context value="src"/>
        <element value="id"/>
        <variable value="id"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="derivedFrom"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <rule>
        <name value="setDerivedFromReference"/>
        <source>
          <context value="id"/>
        </source>
        <target>
          <context value="reference"/>
          <contextType value="variable"/>
          <element value="reference"/>
          <transform value="append"/>
          <parameter>
            <valueString value="QuestionnaireResponse/"/>
          </parameter>
          <parameter>
            <valueId value="id"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="mapSmokingStatusGroup"/>
      <source>
        <context value="src"/>
        <element value="item"/>
        <variable value="groupItem"/>
        <condition value="groupItem.linkId = 'smoking-status-athis'"/>
      </source>
      <dependent>
        <name value="SmokingStatusGroupToObservation"/>
        <variable value="groupItem"/>
        <variable value="tgt"/>
      </dependent>
    </rule>
  </group>
  <group>
    <name value="SmokingStatusGroupToObservation"/>
    <typeMode value="none"/>
    <input>
      <name value="groupItem"/>
      <type value="QR"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="Obs"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="sk1Daily"/>
      <source>
        <context value="groupItem"/>
        <element value="item"/>
        <variable value="sk1"/>
        <condition value="sk1.linkId = 'sk1'"/>
      </source>
      <rule>
        <name value="evaluateSk1Daily"/>
        <source>
          <context value="sk1"/>
          <element value="answer"/>
          <variable value="answer"/>
        </source>
        <rule>
          <name value="mapCurrentDailySmoker"/>
          <source>
            <context value="answer"/>
            <element value="valueCoding"/>
            <variable value="coding"/>
            <condition value="(coding.system = 'https://fhir.hl7.at/prenudge/appdata/r4/CodeSystem/athis-answers') and (coding.code = 'yn-yes-daily')"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="valueCodeableConcept"/>
            <transform value="cc"/>
            <parameter>
              <valueString value="http://snomed.info/sct"/>
            </parameter>
            <parameter>
              <valueString value="449868002"/>
            </parameter>
            <parameter>
              <valueString value="Smokes tobacco daily"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="sk1Occasional"/>
      <source>
        <context value="groupItem"/>
        <element value="item"/>
        <variable value="sk1"/>
        <condition value="sk1.linkId = 'sk1'"/>
      </source>
      <rule>
        <name value="evaluateSk1Occasional"/>
        <source>
          <context value="sk1"/>
          <element value="answer"/>
          <variable value="answer"/>
        </source>
        <rule>
          <name value="mapCurrentOccasionalSmoker"/>
          <source>
            <context value="answer"/>
            <element value="valueCoding"/>
            <variable value="coding"/>
            <condition value="(coding.system = 'https://fhir.hl7.at/prenudge/appdata/r4/CodeSystem/athis-answers') and (coding.code = 'yn-yes-occasionally')"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="valueCodeableConcept"/>
            <transform value="cc"/>
            <parameter>
              <valueString value="http://snomed.info/sct"/>
            </parameter>
            <parameter>
              <valueString value="428041000124106"/>
            </parameter>
            <parameter>
              <valueString value="Occasional tobacco smoker"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="pastSmokingFormer"/>
      <source>
        <context value="groupItem"/>
        <element value="item"/>
        <variable value="past"/>
        <condition value="past.linkId = 'past-tobacco-smoking'"/>
      </source>
      <rule>
        <name value="evaluatePastSmoking"/>
        <source>
          <context value="past"/>
          <element value="answer"/>
          <variable value="answer"/>
        </source>
        <rule>
          <name value="mapPastDailyToFormerSmoker"/>
          <source>
            <context value="answer"/>
            <element value="valueCoding"/>
            <variable value="coding"/>
            <condition value="(coding.system = 'https://fhir.hl7.at/prenudge/appdata/r4/CodeSystem/athis-answers') and (coding.code = 'yn-yes-daily')"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="valueCodeableConcept"/>
            <transform value="cc"/>
            <parameter>
              <valueString value="http://snomed.info/sct"/>
            </parameter>
            <parameter>
              <valueString value="8517006"/>
            </parameter>
            <parameter>
              <valueString value="Ex-smoker"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="mapPastOccasionalToFormerSmoker"/>
          <source>
            <context value="answer"/>
            <element value="valueCoding"/>
            <variable value="coding"/>
            <condition value="(coding.system = 'https://fhir.hl7.at/prenudge/appdata/r4/CodeSystem/athis-answers') and (coding.code = 'yn-yes-occasionally')"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="valueCodeableConcept"/>
            <transform value="cc"/>
            <parameter>
              <valueString value="http://snomed.info/sct"/>
            </parameter>
            <parameter>
              <valueString value="8517006"/>
            </parameter>
            <parameter>
              <valueString value="Ex-smoker"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="pastSmokingNever"/>
      <source>
        <context value="groupItem"/>
        <element value="item"/>
        <variable value="past"/>
        <condition value="past.linkId = 'past-tobacco-smoking'"/>
      </source>
      <rule>
        <name value="evaluatePastNo"/>
        <source>
          <context value="past"/>
          <element value="answer"/>
          <variable value="answer"/>
        </source>
        <rule>
          <name value="mapPastNoToNeverSmoker"/>
          <source>
            <context value="answer"/>
            <element value="valueCoding"/>
            <variable value="coding"/>
            <condition value="(coding.system = 'https://fhir.hl7.at/prenudge/appdata/r4/CodeSystem/athis-answers') and (coding.code = 'yn-no')"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="valueCodeableConcept"/>
            <transform value="cc"/>
            <parameter>
              <valueString value="http://snomed.info/sct"/>
            </parameter>
            <parameter>
              <valueString value="266919005"/>
            </parameter>
            <parameter>
              <valueString value="Never smoked tobacco"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
  </group>
</StructureMap>