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

<StructureMap xmlns="http://hl7.org/fhir">
  <id value="SleepQualityBase"/>
  <text>
    <status value="generated"/><div xmlns="http://www.w3.org/1999/xhtml"><p class="res-header-id"><b>Generated Narrative: StructureMap SleepQualityBase</b></p><a name="SleepQualityBase"> </a><a name="hcSleepQualityBase"> </a><pre class="fml">
<b>map</b><span style="color: navy"> &quot;</span>https://fhir.hl7.at/prenudge/appdata/r4/StructureMap/SleepQualityBase<span style="color: navy">&quot; = &quot;</span>SleepQualityBase<span style="color: navy">&quot;

</span><span style="color: navy">// </span><span style="color: green">Sleep Quality Base (WHOQOL-BREF scale to LOINC)</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>imports</b><span style="color: navy"> &quot;</span>http://hl7.org/fhir/StructureMap/*<span style="color: navy">&quot;
</span>
<b>group </b>SetSleepQualityObservation<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>  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-sleep-quality-observation'</span> <i>&quot;SetProfile&quot;</i><span style="color: navy">;</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">'61987-4'</span><span style="color: navy">, </span><span style="color: blue">'My sleep quality was...in past 7 days [PROMIS]'</span><span style="color: navy">)</span> <i>&quot;SetCode&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.effectiveDateTime = <b>create</b><span style="color: navy">(</span><span style="color: blue">'dateTime'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">dt</span><span style="color: navy">, </span> dt.value = <span style="color: maroon">authored</span> <i>&quot;SetEffective&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><span style="color: navy">// </span><span style="color: green">https://loinc.org/61987-4 My sleep quality was...in past 7 days [PROMIS]</span>
<span style="color: navy">// </span><span style="color: green">https://loinc.org/LL1023-2 [PROMIS] Very poor|Poor|Fair|Good|Very good</span>
<b>group </b>MapWhoQolToLoinc<span style="color: navy">(</span><b>source</b> <span style="color: maroon">coding</span><span style="color: navy"> : </span>Coding, <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>  coding.code<b> as </b><span style="color: maroon">c</span><b> where </b>$this = 'S1'<span style="color: navy"><b> -&gt; </b></span> tgt.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.coding = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">loinc</span><span style="color: navy">, </span> loinc.system = <span style="color: blue">'http://loinc.org'</span><span style="color: navy">, </span> loinc.code = <span style="color: blue">'LA9615-1'</span><span style="color: navy">, </span> loinc.display = <span style="color: blue">'Very poor'</span> <i>&quot;MapS1&quot;</i><span style="color: navy">;</span>
  coding.code<b> as </b><span style="color: maroon">c</span><b> where </b>$this = 'S2'<span style="color: navy"><b> -&gt; </b></span> tgt.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.coding = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">loinc</span><span style="color: navy">, </span> loinc.system = <span style="color: blue">'http://loinc.org'</span><span style="color: navy">, </span> loinc.code = <span style="color: blue">'LA8969-3'</span><span style="color: navy">, </span> loinc.display = <span style="color: blue">'Poor'</span> <i>&quot;MapS2&quot;</i><span style="color: navy">;</span>
  coding.code<b> as </b><span style="color: maroon">c</span><b> where </b>$this = 'S3'<span style="color: navy"><b> -&gt; </b></span> tgt.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.coding = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">loinc</span><span style="color: navy">, </span> loinc.system = <span style="color: blue">'http://loinc.org'</span><span style="color: navy">, </span> loinc.code = <span style="color: blue">'LA8968-5'</span><span style="color: navy">, </span> loinc.display = <span style="color: blue">'Fair'</span> <i>&quot;MapS3&quot;</i><span style="color: navy">;</span>
  coding.code<b> as </b><span style="color: maroon">c</span><b> where </b>$this = 'S4'<span style="color: navy"><b> -&gt; </b></span> tgt.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.coding = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">loinc</span><span style="color: navy">, </span> loinc.system = <span style="color: blue">'http://loinc.org'</span><span style="color: navy">, </span> loinc.code = <span style="color: blue">'LA8967-7'</span><span style="color: navy">, </span> loinc.display = <span style="color: blue">'Good'</span> <i>&quot;MapS4&quot;</i><span style="color: navy">;</span>
  coding.code<b> as </b><span style="color: maroon">c</span><b> where </b>$this = 'S5'<span style="color: navy"><b> -&gt; </b></span> tgt.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">cc</span><span style="color: navy">, </span> cc.coding = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Coding'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">loinc</span><span style="color: navy">, </span> loinc.system = <span style="color: blue">'http://loinc.org'</span><span style="color: navy">, </span> loinc.code = <span style="color: blue">'LA13913-1'</span><span style="color: navy">, </span> loinc.display = <span style="color: blue">'Very Good'</span> <i>&quot;MapS5&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/SleepQualityBase"/>
  <version value="0.1.0"/>
  <name value="SleepQualityBase"/>
  <title value="Sleep Quality Base (WHOQOL-BREF scale to LOINC)"/>
  <status value="active"/>
  <date value="2026-05-28T10:55:10+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="Sleep Quality Base (WHOQOL-BREF scale to LOINC)"/>
  <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>
  <import value="http://hl7.org/fhir/StructureMap/*"/>
  <group>
    <name value="SetSleepQualityObservation"/>
    <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="SetProfile"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="meta"/>
        <variable value="meta"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Meta"/>
        </parameter>
      </target>
      <target>
        <context value="meta"/>
        <contextType value="variable"/>
        <element value="profile"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="https://fhir.hl7.at/prenudge/appdata/r4/StructureDefinition/at-prenudge-sleep-quality-observation"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="SetCode"/>
      <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="61987-4"/>
        </parameter>
        <parameter>
          <valueString value="My sleep quality was...in past 7 days [PROMIS]"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="SetEffective"/>
      <source>
        <context value="src"/>
        <element value="authored"/>
        <variable value="authored"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="effectiveDateTime"/>
        <variable value="dt"/>
        <transform value="create"/>
        <parameter>
          <valueString value="dateTime"/>
        </parameter>
      </target>
      <target>
        <context value="dt"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="authored"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="MapWhoQolToLoinc"/>
    <typeMode value="none"/>
    <documentation value="https://loinc.org/61987-4 My sleep quality was...in past 7 days [PROMIS]&#xD;&#xA;https://loinc.org/LL1023-2 [PROMIS] Very poor|Poor|Fair|Good|Very good"/>
    <input>
      <name value="coding"/>
      <type value="Coding"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="Obs"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="MapS1"/>
      <source>
        <context value="coding"/>
        <element value="code"/>
        <variable value="c"/>
        <condition value="$this = 'S1'"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="cc"/>
        <transform value="create"/>
        <parameter>
          <valueString value="CodeableConcept"/>
        </parameter>
      </target>
      <target>
        <context value="cc"/>
        <contextType value="variable"/>
        <element value="coding"/>
        <variable value="loinc"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Coding"/>
        </parameter>
      </target>
      <target>
        <context value="loinc"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="http://loinc.org"/>
        </parameter>
      </target>
      <target>
        <context value="loinc"/>
        <contextType value="variable"/>
        <element value="code"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="LA9615-1"/>
        </parameter>
      </target>
      <target>
        <context value="loinc"/>
        <contextType value="variable"/>
        <element value="display"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="Very poor"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="MapS2"/>
      <source>
        <context value="coding"/>
        <element value="code"/>
        <variable value="c"/>
        <condition value="$this = 'S2'"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="cc"/>
        <transform value="create"/>
        <parameter>
          <valueString value="CodeableConcept"/>
        </parameter>
      </target>
      <target>
        <context value="cc"/>
        <contextType value="variable"/>
        <element value="coding"/>
        <variable value="loinc"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Coding"/>
        </parameter>
      </target>
      <target>
        <context value="loinc"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="http://loinc.org"/>
        </parameter>
      </target>
      <target>
        <context value="loinc"/>
        <contextType value="variable"/>
        <element value="code"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="LA8969-3"/>
        </parameter>
      </target>
      <target>
        <context value="loinc"/>
        <contextType value="variable"/>
        <element value="display"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="Poor"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="MapS3"/>
      <source>
        <context value="coding"/>
        <element value="code"/>
        <variable value="c"/>
        <condition value="$this = 'S3'"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="cc"/>
        <transform value="create"/>
        <parameter>
          <valueString value="CodeableConcept"/>
        </parameter>
      </target>
      <target>
        <context value="cc"/>
        <contextType value="variable"/>
        <element value="coding"/>
        <variable value="loinc"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Coding"/>
        </parameter>
      </target>
      <target>
        <context value="loinc"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="http://loinc.org"/>
        </parameter>
      </target>
      <target>
        <context value="loinc"/>
        <contextType value="variable"/>
        <element value="code"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="LA8968-5"/>
        </parameter>
      </target>
      <target>
        <context value="loinc"/>
        <contextType value="variable"/>
        <element value="display"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="Fair"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="MapS4"/>
      <source>
        <context value="coding"/>
        <element value="code"/>
        <variable value="c"/>
        <condition value="$this = 'S4'"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="cc"/>
        <transform value="create"/>
        <parameter>
          <valueString value="CodeableConcept"/>
        </parameter>
      </target>
      <target>
        <context value="cc"/>
        <contextType value="variable"/>
        <element value="coding"/>
        <variable value="loinc"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Coding"/>
        </parameter>
      </target>
      <target>
        <context value="loinc"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="http://loinc.org"/>
        </parameter>
      </target>
      <target>
        <context value="loinc"/>
        <contextType value="variable"/>
        <element value="code"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="LA8967-7"/>
        </parameter>
      </target>
      <target>
        <context value="loinc"/>
        <contextType value="variable"/>
        <element value="display"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="Good"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="MapS5"/>
      <source>
        <context value="coding"/>
        <element value="code"/>
        <variable value="c"/>
        <condition value="$this = 'S5'"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="cc"/>
        <transform value="create"/>
        <parameter>
          <valueString value="CodeableConcept"/>
        </parameter>
      </target>
      <target>
        <context value="cc"/>
        <contextType value="variable"/>
        <element value="coding"/>
        <variable value="loinc"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Coding"/>
        </parameter>
      </target>
      <target>
        <context value="loinc"/>
        <contextType value="variable"/>
        <element value="system"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="http://loinc.org"/>
        </parameter>
      </target>
      <target>
        <context value="loinc"/>
        <contextType value="variable"/>
        <element value="code"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="LA13913-1"/>
        </parameter>
      </target>
      <target>
        <context value="loinc"/>
        <contextType value="variable"/>
        <element value="display"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="Very Good"/>
        </parameter>
      </target>
    </rule>
  </group>
</StructureMap>