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) - JSON Representation

Active as of 2026-03-31

Raw json | Download

    {
      "resourceType" : "StructureMap",
      "id" : "DocumentReferenceToT02",
      "text" : {
        "status" : "generated",
        "div" : "<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\">\r\n<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;\r\n\r\n</span><span style=\"color: navy\">// </span><span style=\"color: green\">Transformation FHIR DocumentReference en message HL7v2 MDM^T02 (description)</span>\r\n\r\n<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>\r\n<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>\r\n<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>\r\n<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>\r\n\r\n<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\"> {\r\n</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>\r\n  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>\r\n<span style=\"color: navy\">}\r\n\r\n</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\"> {\r\n</span>  <span style=\"color: navy\">// </span><span style=\"color: green\">--- Champs fixes MSH ---</span>\r\n  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>\r\n  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>\r\n  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>\r\n  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>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">msh7 : date/heure au format HL7 v2 (YYYYMMDDHHmmss)</span>\r\n  <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>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">now() retourne un format ISO 8601 (ex: 2024-01-15T14:30:00+01:00) ;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">on supprime les séparateurs '-', 'T', ':' puis on tronque à 14 caractères.</span>\r\n  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>\r\n  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>\r\n  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>\r\n  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>\r\n  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>\r\n  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>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">--- Champs variables MSH ---</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">msh3 : application d'envoi (identifiant Hopex du custodian)</span>\r\n  srcDocRef.custodian<b> as </b><span style=\"color: maroon\">srcCustodian</span><b> then</b><span style=\"color: navy\"> {\r\n</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\"> {\r\n</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>\r\n    <span style=\"color: navy\">}</span> <i>&quot;navCustIdentifier&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;navCustodian&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">msh4 : code hôpital (3 premiers caractères de l'identifiant Sirius)</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Précondition : la valeur doit faire au moins 3 caractères (garde explicite).</span>\r\n  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\"> {\r\n</span>    srcServiceRespMed.identifier<b> as </b><span style=\"color: maroon\">srcServiceRespMedId</span><b> then</b><span style=\"color: navy\"> {\r\n</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>\r\n    <span style=\"color: navy\">}</span> <i>&quot;navUnitIdentifier&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;navUnit&quot;</i><span style=\"color: navy\">;</span>\r\n<span style=\"color: navy\">}\r\n\r\n</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\"> {\r\n</span>  <span style=\"color: navy\">// </span><span style=\"color: green\">Précondition : subject.reference doit pointer vers une ressource Patient contained (#id).</span>\r\n  <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>\r\n  srcDocRef.subject<b> as </b><span style=\"color: maroon\">srcSubject</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    srcSubject.reference<b> as </b><span style=\"color: maroon\">srcSubjectReference</span><b> then</b><span style=\"color: navy\"> {\r\n</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\"> {\r\n</span>        <span style=\"color: navy\">// </span><span style=\"color: green\">pid3 : IPP patient</span>\r\n        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>\r\n        <span style=\"color: navy\">// </span><span style=\"color: green\">pid5 : nom officiel</span>\r\n        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\"> {\r\n</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>\r\n          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\"> {\r\n</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>\r\n            <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>\r\n            <span style=\"color: navy\">// </span><span style=\"color: green\">puis des prénoms secondaires (ex: &quot;Jean Pierre Marie&quot;).</span>\r\n            <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>\r\n            <span style=\"color: navy\">// </span><span style=\"color: green\">Si le format de l'extension change, cette logique doit être revisitée.</span>\r\n            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\"> {\r\n</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>\r\n            <span style=\"color: navy\">}</span> <i>&quot;navGivenNamesExt&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;setGivenName&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;navName&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">// </span><span style=\"color: green\">pid7 : date de naissance au format HL7 v2 (YYYYMMDD)</span>\r\n        <span style=\"color: navy\">// </span><span style=\"color: green\">On supprime les tirets du format ISO 8601 (YYYY-MM-DD -&gt; YYYYMMDD).</span>\r\n        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>\r\n        <span style=\"color: navy\">// </span><span style=\"color: green\">pid8 : sexe (via ConceptMap FHIR -&gt; table HL7 0001)</span>\r\n        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>\r\n        <span style=\"color: navy\">// </span><span style=\"color: green\">pid18 : NDA (valeur fixe provisoire — TODO: voir pv1-19)</span>\r\n        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>\r\n      <span style=\"color: navy\">}</span> <i>&quot;navContainedSubject&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;navSubjectReference&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;navSubject&quot;</i><span style=\"color: navy\">;</span>\r\n<span style=\"color: navy\">}\r\n\r\n</span></pre></div>"
      },
      "url" : "https://interop.aphp.fr/ig/fhir/atelier/StructureMap/DocumentReferenceToT02",
      "version" : "0.1.0",
      "name" : "DocumentReferenceToT02",
      "title" : "Transformation FHIR DocumentReference en message HL7v2 MDM^T02 (description)",
      "status" : "active",
      "date" : "2026-03-31T08:46:55+00:00",
      "publisher" : "AP-HP",
      "contact" : [
        {
          "name" : "AP-HP",
          "telecom" : [
            {
              "system" : "url",
              "value" : "https://aphp.fr"
            }
          ]
        }
      ],
      "description" : "Transformation FHIR DocumentReference en message HL7v2 MDM^T02 (description)",
      "jurisdiction" : [
        {
          "coding" : [
            {
              "system" : "urn:iso:std:iso:3166",
              "code" : "FRA"
            }
          ]
        }
      ],
      "structure" : [
        {
          "url" : "http://hl7.org/fhir/StructureDefinition/DocumentReference|4.0.1",
          "mode" : "source",
          "alias" : "DocumentReference"
        },
        {
          "url" : "https://interop.aphp.fr/ig/fhir/atelier/StructureDefinition/mdm|0.1.0",
          "mode" : "target",
          "alias" : "Mdm"
        },
        {
          "url" : "https://interop.aphp.fr/ig/fhir/atelier/StructureDefinition/msh|0.1.0",
          "mode" : "target",
          "alias" : "Msh"
        },
        {
          "url" : "https://interop.aphp.fr/ig/fhir/atelier/StructureDefinition/pid|0.1.0",
          "mode" : "target",
          "alias" : "Pid"
        }
      ],
      "group" : [
        {
          "name" : "documentReferenceToT02",
          "typeMode" : "none",
          "input" : [
            {
              "name" : "srcDocRef",
              "type" : "DocumentReference",
              "mode" : "source"
            },
            {
              "name" : "tgtMdm",
              "type" : "Mdm",
              "mode" : "target"
            }
          ],
          "rule" : [
            {
              "name" : "toMsh",
              "source" : [
                {
                  "context" : "srcDocRef"
                }
              ],
              "target" : [
                {
                  "context" : "tgtMdm",
                  "contextType" : "variable",
                  "element" : "msh",
                  "variable" : "tgtMsh"
                }
              ],
              "dependent" : [
                {
                  "name" : "toMsh",
                  "variable" : [
                    "srcDocRef",
                    "tgtMsh"
                  ]
                }
              ]
            },
            {
              "name" : "toPid",
              "source" : [
                {
                  "context" : "srcDocRef"
                }
              ],
              "target" : [
                {
                  "context" : "tgtMdm",
                  "contextType" : "variable",
                  "element" : "pid",
                  "variable" : "tgtPid"
                }
              ],
              "dependent" : [
                {
                  "name" : "toPid",
                  "variable" : [
                    "srcDocRef",
                    "tgtPid"
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "toMsh",
          "typeMode" : "none",
          "input" : [
            {
              "name" : "srcDocRef",
              "mode" : "source"
            },
            {
              "name" : "tgtMsh",
              "type" : "Msh",
              "mode" : "target"
            }
          ],
          "rule" : [
            {
              "name" : "setFieldSep",
              "source" : [
                {
                  "context" : "srcDocRef"
                }
              ],
              "target" : [
                {
                  "context" : "tgtMsh",
                  "contextType" : "variable",
                  "element" : "msh1",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "|"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "setEncoding",
              "source" : [
                {
                  "context" : "srcDocRef"
                }
              ],
              "target" : [
                {
                  "context" : "tgtMsh",
                  "contextType" : "variable",
                  "element" : "msh2",
                  "transform" : "evaluate",
                  "parameter" : [
                    {
                      "valueString" : "'^~\\\\&'"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "setReceivingApp",
              "source" : [
                {
                  "context" : "srcDocRef"
                }
              ],
              "target" : [
                {
                  "context" : "tgtMsh",
                  "contextType" : "variable",
                  "element" : "msh5",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "DPI"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "setReceivingFacility",
              "source" : [
                {
                  "context" : "srcDocRef"
                }
              ],
              "target" : [
                {
                  "context" : "tgtMsh",
                  "contextType" : "variable",
                  "element" : "msh6",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "APHP"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "setDateTime",
              "source" : [
                {
                  "context" : "srcDocRef"
                }
              ],
              "target" : [
                {
                  "context" : "tgtMsh",
                  "contextType" : "variable",
                  "element" : "msh7",
                  "transform" : "evaluate",
                  "parameter" : [
                    {
                      "valueString" : "now().toString().replace('-', '').replace('T', '').replace(':', '').substring(0, 14)"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "setMessageType",
              "source" : [
                {
                  "context" : "srcDocRef"
                }
              ],
              "target" : [
                {
                  "context" : "tgtMsh",
                  "contextType" : "variable",
                  "element" : "msh9",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "MDM^T02"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "setMsgControlId",
              "source" : [
                {
                  "context" : "srcDocRef"
                }
              ],
              "target" : [
                {
                  "context" : "tgtMsh",
                  "contextType" : "variable",
                  "element" : "msh10",
                  "transform" : "uuid"
                }
              ]
            },
            {
              "name" : "setProcessingId",
              "source" : [
                {
                  "context" : "srcDocRef"
                }
              ],
              "target" : [
                {
                  "context" : "tgtMsh",
                  "contextType" : "variable",
                  "element" : "msh11",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "P"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "setVersion",
              "source" : [
                {
                  "context" : "srcDocRef"
                }
              ],
              "target" : [
                {
                  "context" : "tgtMsh",
                  "contextType" : "variable",
                  "element" : "msh12",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "2.5"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "setCharSet",
              "source" : [
                {
                  "context" : "srcDocRef"
                }
              ],
              "target" : [
                {
                  "context" : "tgtMsh",
                  "contextType" : "variable",
                  "element" : "msh18",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "8859/15"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "navCustodian",
              "source" : [
                {
                  "context" : "srcDocRef",
                  "element" : "custodian",
                  "variable" : "srcCustodian"
                }
              ],
              "rule" : [
                {
                  "name" : "navCustIdentifier",
                  "source" : [
                    {
                      "context" : "srcCustodian",
                      "element" : "identifier",
                      "variable" : "srcCustIdentifier",
                      "condition" : "system = 'https://interop.aphp.fr/info/Device/hopex'"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "setMsh3",
                      "source" : [
                        {
                          "context" : "srcCustIdentifier",
                          "element" : "value",
                          "variable" : "srcCustIdentVal"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "tgtMsh",
                          "contextType" : "variable",
                          "element" : "msh3",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueId" : "srcCustIdentVal"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "navUnit",
              "source" : [
                {
                  "context" : "srcDocRef",
                  "element" : "author",
                  "variable" : "srcServiceRespMed",
                  "condition" : "(identifier.system = 'https://interop.aphp.fr/info/Organization/Sirius')"
                }
              ],
              "rule" : [
                {
                  "name" : "navUnitIdentifier",
                  "source" : [
                    {
                      "context" : "srcServiceRespMed",
                      "element" : "identifier",
                      "variable" : "srcServiceRespMedId"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "setMsh4",
                      "source" : [
                        {
                          "context" : "srcServiceRespMedId",
                          "element" : "value",
                          "variable" : "srcServiceRespMedIdValue",
                          "condition" : "($this.length() >= 3)"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "tgtMsh",
                          "contextType" : "variable",
                          "element" : "msh4",
                          "transform" : "evaluate",
                          "parameter" : [
                            {
                              "valueString" : "%srcServiceRespMedIdValue.substring(0, 3)"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "toPid",
          "typeMode" : "none",
          "input" : [
            {
              "name" : "srcDocRef",
              "mode" : "source"
            },
            {
              "name" : "tgtPid",
              "type" : "Pid",
              "mode" : "target"
            }
          ],
          "rule" : [
            {
              "name" : "navSubject",
              "source" : [
                {
                  "context" : "srcDocRef",
                  "element" : "subject",
                  "variable" : "srcSubject"
                }
              ],
              "rule" : [
                {
                  "name" : "navSubjectReference",
                  "source" : [
                    {
                      "context" : "srcSubject",
                      "element" : "reference",
                      "variable" : "srcSubjectReference"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "navContainedSubject",
                      "source" : [
                        {
                          "context" : "srcDocRef",
                          "type" : "Patient",
                          "element" : "contained",
                          "variable" : "srcDocSubj",
                          "condition" : "(('#' + id) = %srcSubjectReference)"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "setPid3",
                          "source" : [
                            {
                              "context" : "srcDocSubj",
                              "element" : "identifier",
                              "variable" : "srcDocSubjIdentifier",
                              "condition" : "system = 'https://interop.aphp.fr/info/Patient/ipp'"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "tgtPid",
                              "contextType" : "variable",
                              "element" : "pid3",
                              "variable" : "tgtPid3"
                            },
                            {
                              "context" : "tgtPid3",
                              "contextType" : "variable",
                              "element" : "cx5",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueString" : "PN"
                                }
                              ]
                            },
                            {
                              "context" : "tgtPid3",
                              "contextType" : "variable",
                              "element" : "cx4",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueString" : "APHP"
                                }
                              ]
                            },
                            {
                              "context" : "tgtPid3",
                              "contextType" : "variable",
                              "element" : "cx1",
                              "transform" : "evaluate",
                              "parameter" : [
                                {
                                  "valueString" : "%srcDocSubjIdentifier.value"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "navName",
                          "source" : [
                            {
                              "context" : "srcDocSubj",
                              "element" : "name",
                              "variable" : "srcSubjName",
                              "condition" : "use = 'official'"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "tgtPid",
                              "contextType" : "variable",
                              "element" : "pid5",
                              "variable" : "tgtPid5"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "setFamilyName",
                              "source" : [
                                {
                                  "context" : "srcSubjName",
                                  "element" : "family",
                                  "variable" : "srcSubjFamilyName"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "tgtPid5",
                                  "contextType" : "variable",
                                  "element" : "xpn1",
                                  "transform" : "copy",
                                  "parameter" : [
                                    {
                                      "valueId" : "srcSubjFamilyName"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "setGivenName",
                              "source" : [
                                {
                                  "context" : "srcSubjName",
                                  "element" : "given",
                                  "variable" : "srcSubjGivenName"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "tgtPid5",
                                  "contextType" : "variable",
                                  "element" : "xpn2",
                                  "transform" : "copy",
                                  "parameter" : [
                                    {
                                      "valueId" : "srcSubjGivenName"
                                    }
                                  ]
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "navGivenNamesExt",
                                  "source" : [
                                    {
                                      "context" : "srcSubjName",
                                      "element" : "extension",
                                      "variable" : "srcSubjectGivenNamesExt",
                                      "condition" : "url = 'https://hl7.fr/ig/fhir/core/StructureDefinition/fr-core-patient-birth-list-given-name'"
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "setGivenNames",
                                      "source" : [
                                        {
                                          "context" : "srcSubjectGivenNamesExt",
                                          "type" : "string",
                                          "element" : "value",
                                          "variable" : "srcSubjectGivenNamesValue"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "tgtPid5",
                                          "contextType" : "variable",
                                          "element" : "xpn3",
                                          "transform" : "evaluate",
                                          "parameter" : [
                                            {
                                              "valueString" : "%srcSubjectGivenNamesValue.toString().substring(%srcSubjGivenName.length() + 1)"
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "setBirthDate",
                          "source" : [
                            {
                              "context" : "srcDocSubj",
                              "element" : "birthDate",
                              "variable" : "srcSubjBirthDate"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "tgtPid",
                              "contextType" : "variable",
                              "element" : "pid7",
                              "transform" : "evaluate",
                              "parameter" : [
                                {
                                  "valueString" : "%srcSubjBirthDate.toString().replace('-', '')"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "setGender",
                          "source" : [
                            {
                              "context" : "srcDocSubj",
                              "element" : "gender",
                              "variable" : "srcSubjGender"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "tgtPid",
                              "contextType" : "variable",
                              "element" : "pid8",
                              "transform" : "translate",
                              "parameter" : [
                                {
                                  "valueId" : "srcSubjGender"
                                },
                                {
                                  "valueString" : "https://interop.aphp.fr/ig/fhir/atelier/ConceptMap/patient-gender-to-aphp-table-0001"
                                },
                                {
                                  "valueString" : "code"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "setPid18",
                          "source" : [
                            {
                              "context" : "srcDocSubj"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "tgtPid",
                              "contextType" : "variable",
                              "element" : "pid18",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueString" : "NDA"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }