Guide d'implémentation pour l'atelier
0.1.0 - ci-build

Guide d'implémentation pour l'atelier - version de développement local (intégration continue v0.1.0) construite par les outils de publication FHIR (HL7® FHIR® Standard). Voir le répertoire des versions publiées

## : Transformation FHIR DocumentReference en message HL7v2 MDM^T02 (description) - XML Representation

Active as of 2026-03-31

Raw xml | Download

    <StructureMap xmlns="http://hl7.org/fhir">
      <id value="DocumentReferenceToT02"/>
      <text>
        <status value="generated"/>
        <div xmlns="http://www.w3.org/1999/xhtml"><p class="res-header-id"><b>Narratif généré : StructureMap DocumentReferenceToT02</b></p><a name="DocumentReferenceToT02"> </a><a name="hcDocumentReferenceToT02"> </a><pre class="fml">
    <b>map</b><span style="color: navy"> &quot;</span>https://interop.aphp.fr/ig/fhir/atelier/StructureMap/DocumentReferenceToT02<span style="color: navy">&quot; = &quot;</span>DocumentReferenceToT02<span style="color: navy">&quot;

    </span><span style="color: navy">// </span><span style="color: green">Transformation FHIR DocumentReference en message HL7v2 MDM^T02 (description)</span>

    <b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/documentreference.html" title="DocumentReference">http://hl7.org/fhir/StructureDefinition/DocumentReference|4.0.1</a><span style="color: navy">&quot; </span><b>alias </b>DocumentReference <b>as </b><b>source</b>
    <b>uses</b><span style="color: navy"> &quot;</span><a href="StructureDefinition-mdm.html" title="MDM - full message">https://interop.aphp.fr/ig/fhir/atelier/StructureDefinition/mdm|0.1.0</a><span style="color: navy">&quot; </span><b>alias </b>Mdm <b>as </b><b>target</b>
    <b>uses</b><span style="color: navy"> &quot;</span><a href="StructureDefinition-msh.html" title="MSH - Message header">https://interop.aphp.fr/ig/fhir/atelier/StructureDefinition/msh|0.1.0</a><span style="color: navy">&quot; </span><b>alias </b>Msh <b>as </b><b>target</b>
    <b>uses</b><span style="color: navy"> &quot;</span><a href="StructureDefinition-pid.html" title="PID - Patient Identification">https://interop.aphp.fr/ig/fhir/atelier/StructureDefinition/pid|0.1.0</a><span style="color: navy">&quot; </span><b>alias </b>Pid <b>as </b><b>target</b>

    <b>group </b>documentReferenceToT02<span style="color: navy">(</span><b>source</b> <span style="color: maroon">srcDocRef</span><span style="color: navy"> : </span>DocumentReference, <b>target</b> <span style="color: maroon">tgtMdm</span><span style="color: navy"> : </span>Mdm<span style="color: navy">)</span><span style="color: navy"> {
    </span>  srcDocRef<span style="color: navy"><b> -&gt; </b></span>tgtMdm.msh<b> as </b><span style="color: maroon">tgtMsh</span><b> then </b>toMsh<span style="color: navy">(</span><span style="color: maroon">srcDocRef</span><span style="color: navy">, </span><span style="color: maroon">tgtMsh</span><span style="color: navy">)</span> <i>&quot;toMsh&quot;</i><span style="color: navy">;</span>
      srcDocRef<span style="color: navy"><b> -&gt; </b></span>tgtMdm.pid<b> as </b><span style="color: maroon">tgtPid</span><b> then </b>toPid<span style="color: navy">(</span><span style="color: maroon">srcDocRef</span><span style="color: navy">, </span><span style="color: maroon">tgtPid</span><span style="color: navy">)</span> <i>&quot;toPid&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}

    </span><b>group </b>toMsh<span style="color: navy">(</span><b>source</b> <span style="color: maroon">srcDocRef</span>, <b>target</b> <span style="color: maroon">tgtMsh</span><span style="color: navy"> : </span>Msh<span style="color: navy">)</span><span style="color: navy"> {
    </span>  <span style="color: navy">// </span><span style="color: green">--- Champs fixes MSH ---</span>
      srcDocRef<span style="color: navy"><b> -&gt; </b></span>tgtMsh.msh1 = <span style="color: blue">'|'</span> <i>&quot;setFieldSep&quot;</i><span style="color: navy">;</span>
      srcDocRef<span style="color: navy"><b> -&gt; </b></span>tgtMsh.msh2 = <span style="color: navy">(</span>'^~\\&amp;'<span style="color: navy">)</span> <i>&quot;setEncoding&quot;</i><span style="color: navy">;</span>
      srcDocRef<span style="color: navy"><b> -&gt; </b></span>tgtMsh.msh5 = <span style="color: blue">'DPI'</span> <i>&quot;setReceivingApp&quot;</i><span style="color: navy">;</span>
      srcDocRef<span style="color: navy"><b> -&gt; </b></span>tgtMsh.msh6 = <span style="color: blue">'APHP'</span> <i>&quot;setReceivingFacility&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">// </span><span style="color: green">msh7 : date/heure au format HL7 v2 (YYYYMMDDHHmmss)</span>
      <span style="color: navy">// </span><span style="color: green">On utilise une expression unique sur now() pour éviter plusieurs appels retournant des timestamps différents.</span>
      <span style="color: navy">// </span><span style="color: green">now() retourne un format ISO 8601 (ex: 2024-01-15T14:30:00+01:00) ;</span>
      <span style="color: navy">// </span><span style="color: green">on supprime les séparateurs '-', 'T', ':' puis on tronque à 14 caractères.</span>
      srcDocRef<span style="color: navy"><b> -&gt; </b></span>tgtMsh.msh7 = <span style="color: navy">(</span>now().toString().replace('-', '').replace('T', '').replace(':', '').substring(0, 14)<span style="color: navy">)</span> <i>&quot;setDateTime&quot;</i><span style="color: navy">;</span>
      srcDocRef<span style="color: navy"><b> -&gt; </b></span>tgtMsh.msh9 = <span style="color: blue">'MDM^T02'</span> <i>&quot;setMessageType&quot;</i><span style="color: navy">;</span>
      srcDocRef<span style="color: navy"><b> -&gt; </b></span>tgtMsh.msh10 = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span> <i>&quot;setMsgControlId&quot;</i><span style="color: navy">;</span>
      srcDocRef<span style="color: navy"><b> -&gt; </b></span>tgtMsh.msh11 = <span style="color: blue">'P'</span> <i>&quot;setProcessingId&quot;</i><span style="color: navy">;</span>
      srcDocRef<span style="color: navy"><b> -&gt; </b></span>tgtMsh.msh12 = <span style="color: blue">'2.5'</span> <i>&quot;setVersion&quot;</i><span style="color: navy">;</span>
      srcDocRef<span style="color: navy"><b> -&gt; </b></span>tgtMsh.msh18 = <span style="color: blue">'8859/15'</span> <i>&quot;setCharSet&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">// </span><span style="color: green">--- Champs variables MSH ---</span>
      <span style="color: navy">// </span><span style="color: green">msh3 : application d'envoi (identifiant Hopex du custodian)</span>
      srcDocRef.custodian<b> as </b><span style="color: maroon">srcCustodian</span><b> then</b><span style="color: navy"> {
    </span>    srcCustodian.identifier<b> as </b><span style="color: maroon">srcCustIdentifier</span><b> where </b>system = 'https://interop.aphp.fr/info/Device/hopex'<b> then</b><span style="color: navy"> {
    </span>      srcCustIdentifier.value<b> as </b><span style="color: maroon">srcCustIdentVal</span><span style="color: navy"><b> -&gt; </b></span>tgtMsh.msh3 = <span style="color: maroon">srcCustIdentVal</span> <i>&quot;setMsh3&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;navCustIdentifier&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;navCustodian&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">// </span><span style="color: green">msh4 : code hôpital (3 premiers caractères de l'identifiant Sirius)</span>
      <span style="color: navy">// </span><span style="color: green">Précondition : la valeur doit faire au moins 3 caractères (garde explicite).</span>
      srcDocRef.author<b> as </b><span style="color: maroon">srcServiceRespMed</span><b> where </b>(identifier.system = 'https://interop.aphp.fr/info/Organization/Sirius')<b> then</b><span style="color: navy"> {
    </span>    srcServiceRespMed.identifier<b> as </b><span style="color: maroon">srcServiceRespMedId</span><b> then</b><span style="color: navy"> {
    </span>      srcServiceRespMedId.value<b> as </b><span style="color: maroon">srcServiceRespMedIdValue</span><b> where </b>($this.length() &gt;= 3)<span style="color: navy"><b> -&gt; </b></span>tgtMsh.msh4 = <span style="color: navy">(</span>%srcServiceRespMedIdValue.substring(0, 3)<span style="color: navy">)</span> <i>&quot;setMsh4&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;navUnitIdentifier&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;navUnit&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}

    </span><b>group </b>toPid<span style="color: navy">(</span><b>source</b> <span style="color: maroon">srcDocRef</span>, <b>target</b> <span style="color: maroon">tgtPid</span><span style="color: navy"> : </span>Pid<span style="color: navy">)</span><span style="color: navy"> {
    </span>  <span style="color: navy">// </span><span style="color: green">Précondition : subject.reference doit pointer vers une ressource Patient contained (#id).</span>
      <span style="color: navy">// </span><span style="color: green">Si la référence est externe, aucun segment PID ne sera généré (échec silencieux documenté).</span>
      srcDocRef.subject<b> as </b><span style="color: maroon">srcSubject</span><b> then</b><span style="color: navy"> {
    </span>    srcSubject.reference<b> as </b><span style="color: maroon">srcSubjectReference</span><b> then</b><span style="color: navy"> {
    </span>      srcDocRef.contained<span style="color: navy"> : </span>Patient<b> as </b><span style="color: maroon">srcDocSubj</span><b> where </b>(('#' + id) = %srcSubjectReference)<b> then</b><span style="color: navy"> {
    </span>        <span style="color: navy">// </span><span style="color: green">pid3 : IPP patient</span>
            srcDocSubj.identifier<b> as </b><span style="color: maroon">srcDocSubjIdentifier</span><b> where </b>system = 'https://interop.aphp.fr/info/Patient/ipp'<span style="color: navy"><b> -&gt; </b></span> tgtPid.pid3<b> as </b><span style="color: maroon">tgtPid3</span><span style="color: navy">, </span> tgtPid3.cx5 = <span style="color: blue">'PN'</span><span style="color: navy">, </span> tgtPid3.cx4 = <span style="color: blue">'APHP'</span><span style="color: navy">, </span> tgtPid3.cx1 = <span style="color: navy">(</span>%srcDocSubjIdentifier.value<span style="color: navy">)</span> <i>&quot;setPid3&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">// </span><span style="color: green">pid5 : nom officiel</span>
            srcDocSubj.name<b> as </b><span style="color: maroon">srcSubjName</span><b> where </b>use = 'official'<span style="color: navy"><b> -&gt; </b></span>tgtPid.pid5<b> as </b><span style="color: maroon">tgtPid5</span><b> then</b><span style="color: navy"> {
    </span>          srcSubjName.family<b> as </b><span style="color: maroon">srcSubjFamilyName</span><span style="color: navy"><b> -&gt; </b></span>tgtPid5.xpn1 = <span style="color: maroon">srcSubjFamilyName</span> <i>&quot;setFamilyName&quot;</i><span style="color: navy">;</span>
              srcSubjName.given<b> as </b><span style="color: maroon">srcSubjGivenName</span><span style="color: navy"><b> -&gt; </b></span>tgtPid5.xpn2 = <span style="color: maroon">srcSubjGivenName</span><b> then</b><span style="color: navy"> {
    </span>            <span style="color: navy">// </span><span style="color: green">xpn3 : prénoms secondaires extraits de l'extension fr-core birth-list-given-name.</span>
                <span style="color: navy">// </span><span style="color: green">Hypothèse : la valeur de l'extension contient le prénom usuel suivi d'un espace</span>
                <span style="color: navy">// </span><span style="color: green">puis des prénoms secondaires (ex: &quot;Jean Pierre Marie&quot;).</span>
                <span style="color: navy">// </span><span style="color: green">On extrait la partie après le prénom usuel (longueur + 1 pour l'espace).</span>
                <span style="color: navy">// </span><span style="color: green">Si le format de l'extension change, cette logique doit être revisitée.</span>
                srcSubjName.extension<b> as </b><span style="color: maroon">srcSubjectGivenNamesExt</span><b> where </b>url = 'https://hl7.fr/ig/fhir/core/StructureDefinition/fr-core-patient-birth-list-given-name'<b> then</b><span style="color: navy"> {
    </span>              srcSubjectGivenNamesExt.value<span style="color: navy"> : </span>string<b> as </b><span style="color: maroon">srcSubjectGivenNamesValue</span><span style="color: navy"><b> -&gt; </b></span>tgtPid5.xpn3 = <span style="color: navy">(</span>%srcSubjectGivenNamesValue.toString().substring(%srcSubjGivenName.length() + 1)<span style="color: navy">)</span> <i>&quot;setGivenNames&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;navGivenNamesExt&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;setGivenName&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;navName&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">// </span><span style="color: green">pid7 : date de naissance au format HL7 v2 (YYYYMMDD)</span>
            <span style="color: navy">// </span><span style="color: green">On supprime les tirets du format ISO 8601 (YYYY-MM-DD -&gt; YYYYMMDD).</span>
            srcDocSubj.birthDate<b> as </b><span style="color: maroon">srcSubjBirthDate</span><span style="color: navy"><b> -&gt; </b></span>tgtPid.pid7 = <span style="color: navy">(</span>%srcSubjBirthDate.toString().replace('-', '')<span style="color: navy">)</span> <i>&quot;setBirthDate&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">// </span><span style="color: green">pid8 : sexe (via ConceptMap FHIR -&gt; table HL7 0001)</span>
            srcDocSubj.gender<b> as </b><span style="color: maroon">srcSubjGender</span><span style="color: navy"><b> -&gt; </b></span>tgtPid.pid8 = <b>translate</b><span style="color: navy">(</span><span style="color: maroon">srcSubjGender</span><span style="color: navy">, </span><span style="color: blue">'https://interop.aphp.fr/ig/fhir/atelier/ConceptMap/patient-gender-to-aphp-table-0001'</span><span style="color: navy">, </span><span style="color: blue">'code'</span><span style="color: navy">)</span> <i>&quot;setGender&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">// </span><span style="color: green">pid18 : NDA (valeur fixe provisoire — TODO: voir pv1-19)</span>
            srcDocSubj<span style="color: navy"><b> -&gt; </b></span>tgtPid.pid18 = <span style="color: blue">'NDA'</span> <i>&quot;setPid18&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;navContainedSubject&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;navSubjectReference&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;navSubject&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}

    </span></pre></div>
      </text>
      <url
           value="https://interop.aphp.fr/ig/fhir/atelier/StructureMap/DocumentReferenceToT02"/>
      <version value="0.1.0"/>
      <name value="DocumentReferenceToT02"/>
      <title
             value="Transformation FHIR DocumentReference en message HL7v2 MDM^T02 (description)"/>
      <status value="active"/>
      <date value="2026-03-31T08:46:55+00:00"/>
      <publisher value="AP-HP"/>
      <contact>
        <name value="AP-HP"/>
        <telecom>
          <system value="url"/>
          <value value="https://aphp.fr"/>
        </telecom>
      </contact>
      <description
                   value="Transformation FHIR DocumentReference en message HL7v2 MDM^T02 (description)"/>
      <jurisdiction>
        <coding>
          <system value="urn:iso:std:iso:3166"/>
          <code value="FRA"/>
        </coding>
      </jurisdiction>
      <structure>
        <url
             value="http://hl7.org/fhir/StructureDefinition/DocumentReference|4.0.1"/>
        <mode value="source"/>
        <alias value="DocumentReference"/>
      </structure>
      <structure>
        <url
             value="https://interop.aphp.fr/ig/fhir/atelier/StructureDefinition/mdm|0.1.0"/>
        <mode value="target"/>
        <alias value="Mdm"/>
      </structure>
      <structure>
        <url
             value="https://interop.aphp.fr/ig/fhir/atelier/StructureDefinition/msh|0.1.0"/>
        <mode value="target"/>
        <alias value="Msh"/>
      </structure>
      <structure>
        <url
             value="https://interop.aphp.fr/ig/fhir/atelier/StructureDefinition/pid|0.1.0"/>
        <mode value="target"/>
        <alias value="Pid"/>
      </structure>
      <group>
        <name value="documentReferenceToT02"/>
        <typeMode value="none"/>
        <input>
          <name value="srcDocRef"/>
          <type value="DocumentReference"/>
          <mode value="source"/>
        </input>
        <input>
          <name value="tgtMdm"/>
          <type value="Mdm"/>
          <mode value="target"/>
        </input>
        <rule>
          <name value="toMsh"/>
          <source>
            <context value="srcDocRef"/>
          </source>
          <target>
            <context value="tgtMdm"/>
            <contextType value="variable"/>
            <element value="msh"/>
            <variable value="tgtMsh"/>
          </target>
          <dependent>
            <name value="toMsh"/>
            <variable value="srcDocRef"/>
            <variable value="tgtMsh"/>
          </dependent>
        </rule>
        <rule>
          <name value="toPid"/>
          <source>
            <context value="srcDocRef"/>
          </source>
          <target>
            <context value="tgtMdm"/>
            <contextType value="variable"/>
            <element value="pid"/>
            <variable value="tgtPid"/>
          </target>
          <dependent>
            <name value="toPid"/>
            <variable value="srcDocRef"/>
            <variable value="tgtPid"/>
          </dependent>
        </rule>
      </group>
      <group>
        <name value="toMsh"/>
        <typeMode value="none"/>
        <input>
          <name value="srcDocRef"/>
          <mode value="source"/>
        </input>
        <input>
          <name value="tgtMsh"/>
          <type value="Msh"/>
          <mode value="target"/>
        </input>
        <rule>
          <name value="setFieldSep"/>
          <source>
            <context value="srcDocRef"/>
          </source>
          <target>
            <context value="tgtMsh"/>
            <contextType value="variable"/>
            <element value="msh1"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="|"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="setEncoding"/>
          <source>
            <context value="srcDocRef"/>
          </source>
          <target>
            <context value="tgtMsh"/>
            <contextType value="variable"/>
            <element value="msh2"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="'^~\\&amp;'"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="setReceivingApp"/>
          <source>
            <context value="srcDocRef"/>
          </source>
          <target>
            <context value="tgtMsh"/>
            <contextType value="variable"/>
            <element value="msh5"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="DPI"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="setReceivingFacility"/>
          <source>
            <context value="srcDocRef"/>
          </source>
          <target>
            <context value="tgtMsh"/>
            <contextType value="variable"/>
            <element value="msh6"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="APHP"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="setDateTime"/>
          <source>
            <context value="srcDocRef"/>
          </source>
          <target>
            <context value="tgtMsh"/>
            <contextType value="variable"/>
            <element value="msh7"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString
                           value="now().toString().replace('-', '').replace('T', '').replace(':', '').substring(0, 14)"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="setMessageType"/>
          <source>
            <context value="srcDocRef"/>
          </source>
          <target>
            <context value="tgtMsh"/>
            <contextType value="variable"/>
            <element value="msh9"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="MDM^T02"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="setMsgControlId"/>
          <source>
            <context value="srcDocRef"/>
          </source>
          <target>
            <context value="tgtMsh"/>
            <contextType value="variable"/>
            <element value="msh10"/>
            <transform value="uuid"/>
          </target>
        </rule>
        <rule>
          <name value="setProcessingId"/>
          <source>
            <context value="srcDocRef"/>
          </source>
          <target>
            <context value="tgtMsh"/>
            <contextType value="variable"/>
            <element value="msh11"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="P"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="setVersion"/>
          <source>
            <context value="srcDocRef"/>
          </source>
          <target>
            <context value="tgtMsh"/>
            <contextType value="variable"/>
            <element value="msh12"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="2.5"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="setCharSet"/>
          <source>
            <context value="srcDocRef"/>
          </source>
          <target>
            <context value="tgtMsh"/>
            <contextType value="variable"/>
            <element value="msh18"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="8859/15"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="navCustodian"/>
          <source>
            <context value="srcDocRef"/>
            <element value="custodian"/>
            <variable value="srcCustodian"/>
          </source>
          <rule>
            <name value="navCustIdentifier"/>
            <source>
              <context value="srcCustodian"/>
              <element value="identifier"/>
              <variable value="srcCustIdentifier"/>
              <condition
                         value="system = 'https://interop.aphp.fr/info/Device/hopex'"/>
            </source>
            <rule>
              <name value="setMsh3"/>
              <source>
                <context value="srcCustIdentifier"/>
                <element value="value"/>
                <variable value="srcCustIdentVal"/>
              </source>
              <target>
                <context value="tgtMsh"/>
                <contextType value="variable"/>
                <element value="msh3"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="srcCustIdentVal"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="navUnit"/>
          <source>
            <context value="srcDocRef"/>
            <element value="author"/>
            <variable value="srcServiceRespMed"/>
            <condition
                       value="(identifier.system = 'https://interop.aphp.fr/info/Organization/Sirius')"/>
          </source>
          <rule>
            <name value="navUnitIdentifier"/>
            <source>
              <context value="srcServiceRespMed"/>
              <element value="identifier"/>
              <variable value="srcServiceRespMedId"/>
            </source>
            <rule>
              <name value="setMsh4"/>
              <source>
                <context value="srcServiceRespMedId"/>
                <element value="value"/>
                <variable value="srcServiceRespMedIdValue"/>
                <condition value="($this.length() &gt;= 3)"/>
              </source>
              <target>
                <context value="tgtMsh"/>
                <contextType value="variable"/>
                <element value="msh4"/>
                <transform value="evaluate"/>
                <parameter>
                  <valueString value="%srcServiceRespMedIdValue.substring(0, 3)"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
      </group>
      <group>
        <name value="toPid"/>
        <typeMode value="none"/>
        <input>
          <name value="srcDocRef"/>
          <mode value="source"/>
        </input>
        <input>
          <name value="tgtPid"/>
          <type value="Pid"/>
          <mode value="target"/>
        </input>
        <rule>
          <name value="navSubject"/>
          <source>
            <context value="srcDocRef"/>
            <element value="subject"/>
            <variable value="srcSubject"/>
          </source>
          <rule>
            <name value="navSubjectReference"/>
            <source>
              <context value="srcSubject"/>
              <element value="reference"/>
              <variable value="srcSubjectReference"/>
            </source>
            <rule>
              <name value="navContainedSubject"/>
              <source>
                <context value="srcDocRef"/>
                <type value="Patient"/>
                <element value="contained"/>
                <variable value="srcDocSubj"/>
                <condition value="(('#' + id) = %srcSubjectReference)"/>
              </source>
              <rule>
                <name value="setPid3"/>
                <source>
                  <context value="srcDocSubj"/>
                  <element value="identifier"/>
                  <variable value="srcDocSubjIdentifier"/>
                  <condition
                             value="system = 'https://interop.aphp.fr/info/Patient/ipp'"/>
                </source>
                <target>
                  <context value="tgtPid"/>
                  <contextType value="variable"/>
                  <element value="pid3"/>
                  <variable value="tgtPid3"/>
                </target>
                <target>
                  <context value="tgtPid3"/>
                  <contextType value="variable"/>
                  <element value="cx5"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="PN"/>
                  </parameter>
                </target>
                <target>
                  <context value="tgtPid3"/>
                  <contextType value="variable"/>
                  <element value="cx4"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="APHP"/>
                  </parameter>
                </target>
                <target>
                  <context value="tgtPid3"/>
                  <contextType value="variable"/>
                  <element value="cx1"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%srcDocSubjIdentifier.value"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="navName"/>
                <source>
                  <context value="srcDocSubj"/>
                  <element value="name"/>
                  <variable value="srcSubjName"/>
                  <condition value="use = 'official'"/>
                </source>
                <target>
                  <context value="tgtPid"/>
                  <contextType value="variable"/>
                  <element value="pid5"/>
                  <variable value="tgtPid5"/>
                </target>
                <rule>
                  <name value="setFamilyName"/>
                  <source>
                    <context value="srcSubjName"/>
                    <element value="family"/>
                    <variable value="srcSubjFamilyName"/>
                  </source>
                  <target>
                    <context value="tgtPid5"/>
                    <contextType value="variable"/>
                    <element value="xpn1"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueId value="srcSubjFamilyName"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="setGivenName"/>
                  <source>
                    <context value="srcSubjName"/>
                    <element value="given"/>
                    <variable value="srcSubjGivenName"/>
                  </source>
                  <target>
                    <context value="tgtPid5"/>
                    <contextType value="variable"/>
                    <element value="xpn2"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueId value="srcSubjGivenName"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="navGivenNamesExt"/>
                    <source>
                      <context value="srcSubjName"/>
                      <element value="extension"/>
                      <variable value="srcSubjectGivenNamesExt"/>
                      <condition
                                 value="url = 'https://hl7.fr/ig/fhir/core/StructureDefinition/fr-core-patient-birth-list-given-name'"/>
                    </source>
                    <rule>
                      <name value="setGivenNames"/>
                      <source>
                        <context value="srcSubjectGivenNamesExt"/>
                        <type value="string"/>
                        <element value="value"/>
                        <variable value="srcSubjectGivenNamesValue"/>
                      </source>
                      <target>
                        <context value="tgtPid5"/>
                        <contextType value="variable"/>
                        <element value="xpn3"/>
                        <transform value="evaluate"/>
                        <parameter>
                          <valueString
                                       value="%srcSubjectGivenNamesValue.toString().substring(%srcSubjGivenName.length() + 1)"/>
                        </parameter>
                      </target>
                    </rule>
                  </rule>
                </rule>
              </rule>
              <rule>
                <name value="setBirthDate"/>
                <source>
                  <context value="srcDocSubj"/>
                  <element value="birthDate"/>
                  <variable value="srcSubjBirthDate"/>
                </source>
                <target>
                  <context value="tgtPid"/>
                  <contextType value="variable"/>
                  <element value="pid7"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString
                                 value="%srcSubjBirthDate.toString().replace('-', '')"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="setGender"/>
                <source>
                  <context value="srcDocSubj"/>
                  <element value="gender"/>
                  <variable value="srcSubjGender"/>
                </source>
                <target>
                  <context value="tgtPid"/>
                  <contextType value="variable"/>
                  <element value="pid8"/>
                  <transform value="translate"/>
                  <parameter>
                    <valueId value="srcSubjGender"/>
                  </parameter>
                  <parameter>
                    <valueString
                                 value="https://interop.aphp.fr/ig/fhir/atelier/ConceptMap/patient-gender-to-aphp-table-0001"/>
                  </parameter>
                  <parameter>
                    <valueString value="code"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="setPid18"/>
                <source>
                  <context value="srcDocSubj"/>
                </source>
                <target>
                  <context value="tgtPid"/>
                  <contextType value="variable"/>
                  <element value="pid18"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="NDA"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </group>
    </StructureMap>