FHIR Mapping Language (FML)
0.1.0 - STU 1 World

FHIR Mapping Language (FML), published by HL7 International / FHIR Infrastructure. This guide is not an authorized publication; it is the continuous build for version 0.1.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/HL7/mapping-language-ig/ and changes regularly. See the Directory of published versions

: FhirPathSourceAsVar

Page standards status: Informative

Raw xml | Download


<StructureMap xmlns="http://hl7.org/fhir"
              resourceDefinition="http://hl7.org/fhir/StructureDefinition/StructureMap|0.1.0">
  <text>
    <status value="generated"/>
    <div xmlns="http://www.w3.org/1999/xhtml"><p class="res-header-id"><b>Generated Narrative: StructureMap FhirPathSourceAsVar</b></p><a name="FhirPathSourceAsVar"> </a><a name="hcFhirPathSourceAsVar"> </a><pre class="fml">
<span style="color: #cc00cc">/// <b>url</b> = </span><span style="color: blue">'http://hl7.org/fhir/uv/mapping-language/StructureMap/FhirPathSourceAsVar'</span>
<span style="color: #cc00cc">/// <b>name</b> = </span><span style="color: blue">'FhirPathSourceAsVar'</span>
<span style="color: #cc00cc">/// <b>status</b> = </span><span style="color: blue">'active'</span>
<span style="color: #cc00cc">/// <b>description</b> = </span><span style="color: blue">'Example demonstrating the where clause for filtering source elements with FHIRPath'</span>

<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/6.0.0-ballot5/patient.html" title="Patient">http://hl7.org/fhir/StructureDefinition/Patient</a><span style="color: navy">&quot; </span><b>as </b><b>source</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/6.0.0-ballot5/patient.html" title="Patient">http://hl7.org/fhir/StructureDefinition/Patient</a><span style="color: navy">&quot; </span><b>as </b><b>target</b>

<b>group </b>FhirPathSourceAsVar<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>Patient, <b>target</b> <span style="color: maroon">tgt</span><span style="color: navy"> : </span>Patient<span style="color: navy">)</span><span style="color: navy"> {
</span>  <span style="color: navy">// </span><span style="color: green">trigger on src, and stash a constant</span>
  src<span style="color: navy"><b> -&gt; </b></span><span style="color: navy">(</span>'http://example.org/'<span style="color: navy">)</span><b> as </b><span style="color: maroon">extBase</span><b> then</b><span style="color: navy"> {
</span>    <span style="color: navy">// </span><span style="color: green">use the stashed constant as a variable in a where clause to filter source elements</span>
    src.name<b> as </b><span style="color: maroon">sn</span><span style="color: navy"><b> -&gt; </b></span>tgt.name<b> as </b><span style="color: maroon">tn</span><b> then</b><span style="color: navy"> {
</span>      sn.family<b> as </b><span style="color: maroon">f</span><span style="color: navy"><b> -&gt; </b></span> tn.family = <span style="color: maroon">f</span><span style="color: navy">, </span> tn.extension<b> as </b><span style="color: maroon">e</span><span style="color: navy">, </span> e.url = <span style="color: navy">(</span>extBase &amp; 'family'<span style="color: navy">)</span><span style="color: navy">, </span> e.value = <span style="color: maroon">f</span> <i>&quot;r1&quot;</i><span style="color: navy">;</span>
      sn.suffix<b> as </b><span style="color: maroon">f</span><span style="color: navy"><b> -&gt; </b></span> tn.suffix = <span style="color: maroon">f</span><span style="color: navy">, </span> tn.extension<b> as </b><span style="color: maroon">e</span><span style="color: navy">, </span> e.url = <span style="color: navy">(</span>extBase &amp; 'suffix'<span style="color: navy">)</span><span style="color: navy">, </span> e.value = <span style="color: maroon">f</span> <i>&quot;r1&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;r2&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;r3&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span></pre></div>
  </text>
  <url
       value="http://hl7.org/fhir/uv/mapping-language/StructureMap/FhirPathSourceAsVar"/>
  <name value="FhirPathSourceAsVar"/>
  <status value="active"/>
  <description
               value="Example demonstrating the where clause for filtering source elements with FHIRPath"/>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Patient"/>
    <mode value="source"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Patient"/>
    <mode value="target"/>
  </structure>
  <group>
    <name value="FhirPathSourceAsVar"/>
    <input>
      <mode value="source"/>
      <name value="src"/>
      <type value="Patient"/>
    </input>
    <input>
      <mode value="target"/>
      <name value="tgt"/>
      <type value="Patient"/>
    </input>
    <rule>
      <source>
        <context value="src"/>
      </source>
      <target>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'http://example.org/'"/>
        </parameter>
        <variable value="extBase"/>
      </target>
      <rule>
        <source>
          <context value="src"/>
          <element value="name"/>
          <variable value="sn"/>
        </source>
        <target>
          <context value="tgt"/>
          <element value="name"/>
          <variable value="tn"/>
        </target>
        <rule>
          <source>
            <context value="sn"/>
            <element value="family"/>
            <variable value="f"/>
          </source>
          <target>
            <context value="tn"/>
            <element value="family"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="f"/>
            </parameter>
          </target>
          <target>
            <context value="tn"/>
            <element value="extension"/>
            <variable value="e"/>
          </target>
          <target>
            <context value="e"/>
            <element value="url"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="extBase &amp; 'family'"/>
            </parameter>
          </target>
          <target>
            <context value="e"/>
            <element value="value"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="f"/>
            </parameter>
          </target>
          <name value="r1"/>
        </rule>
        <rule>
          <source>
            <context value="sn"/>
            <element value="suffix"/>
            <variable value="f"/>
          </source>
          <target>
            <context value="tn"/>
            <element value="suffix"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="f"/>
            </parameter>
          </target>
          <target>
            <context value="tn"/>
            <element value="extension"/>
            <variable value="e"/>
          </target>
          <target>
            <context value="e"/>
            <element value="url"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="extBase &amp; 'suffix'"/>
            </parameter>
          </target>
          <target>
            <context value="e"/>
            <element value="value"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="f"/>
            </parameter>
          </target>
          <name value="r1"/>
        </rule>
        <documentation
                       value="use the stashed constant as a variable in a where clause to filter source elements"/>
        <name value="r2"/>
      </rule>
      <documentation value="trigger on src, and stash a constant"/>
      <name value="r3"/>
    </rule>
  </group>
  <id value="FhirPathSourceAsVar"/>
  <language value="en"/>
</StructureMap>