Search FHIR

POC - Mapping CDA to FHIR
0.1.0 - ci-build France flag

POC - Mapping CDA to FHIR - Local Development build (v0.1.0) built by the FHIR (HL7® FHIR® Standard) Build Tools. See the Directory of published versions

: Mapping de CDA vers FHIR Bundle (A partir des sources de Oliver Egger) - XML Representation

Draft as of 2025-11-07

Raw xml | Download


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

</span><span style="color: navy">// </span><span style="color: green">Mapping de CDA vers FHIR Bundle (A partir des sources de Oliver Egger)</span>

<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/cda/stds/core/2.0.0-sd/StructureDefinition-ClinicalDocument.html" title="ClinicalDocument (CDA Class)">http://hl7.org/cda/stds/core/StructureDefinition/ClinicalDocument</a><span style="color: navy">&quot; </span><b>alias </b>ClinicalDocument <b>as </b><b>source</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/cda/stds/core/2.0.0-sd/StructureDefinition-AssignedAuthor.html" title="AssignedAuthor (CDA Class)">http://hl7.org/cda/stds/core/StructureDefinition/AssignedAuthor</a><span style="color: navy">&quot; </span><b>alias </b>AssignedAuthor <b>as </b><b>source</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/cda/stds/core/2.0.0-sd/StructureDefinition-AssignedEntity.html" title="AssignedEntity (CDA Class)">http://hl7.org/cda/stds/core/StructureDefinition/AssignedEntity</a><span style="color: navy">&quot; </span><b>alias </b>AssignedEntity <b>as </b><b>source</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/cda/stds/core/2.0.0-sd/StructureDefinition-CustodianOrganization.html" title="CustodianOrganization (CDA Class)">http://hl7.org/cda/stds/core/StructureDefinition/CustodianOrganization</a><span style="color: navy">&quot; </span><b>alias </b>CustodianOrganization <b>as </b><b>source</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/cda/stds/core/2.0.0-sd/StructureDefinition-Section.html" title="Section (CDA Class)">http://hl7.org/cda/stds/core/StructureDefinition/Section</a><span style="color: navy">&quot; </span><b>alias </b>Section <b>as </b><b>source</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/cda/stds/core/2.0.0-sd/StructureDefinition-PatientRole.html" title="PatientRole (CDA Class)">http://hl7.org/cda/stds/core/StructureDefinition/PatientRole</a><span style="color: navy">&quot; </span><b>alias </b>PatientRole <b>as </b><b>source</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/bundle.html" title="Bundle">http://hl7.org/fhir/StructureDefinition/Bundle</a><span style="color: navy">&quot; </span><b>alias </b>Bundle <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/composition.html" title="Composition">http://hl7.org/fhir/StructureDefinition/Composition</a><span style="color: navy">&quot; </span><b>alias </b>Composition <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/patient.html" title="Patient">http://hl7.org/fhir/StructureDefinition/Patient</a><span style="color: navy">&quot; </span><b>alias </b>Patient <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/person.html" title="Person">http://hl7.org/fhir/StructureDefinition/Person</a><span style="color: navy">&quot; </span><b>alias </b>Person <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/practitioner.html" title="Practitioner">http://hl7.org/fhir/StructureDefinition/Practitioner</a><span style="color: navy">&quot; </span><b>alias </b>Practitioner <b>as </b><b>target</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/organization.html" title="Organization">http://hl7.org/fhir/StructureDefinition/Organization</a><span style="color: navy">&quot; </span><b>alias </b>Organization <b>as </b><b>target</b>

<b>imports</b><span style="color: navy"> &quot;</span><a href="StructureMap-CdaToFHIRTypes.html" title="Mapping de CDA vers les FHIR Types (A partir des sources de Oliver Egger)">https://interop.esante.gouv.fr/ig/fhir/mappingcdafhir/StructureMap/CdaToFHIRTypes</a><span style="color: navy">&quot;
</span>
<span style="color: navy">// </span><span style="color: green">_________________________ Document Level Template  _________________________</span>
<b>group </b>CdaToBundle<span style="color: navy">(</span><b>source</b> <span style="color: maroon">cda</span><span style="color: navy"> : </span>ClinicalDocument, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle<span style="color: navy">)</span><span style="color: navy"> {
</span>  cda<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e</span><span style="color: navy">, </span> e.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Composition'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">composition</span><span style="color: navy">, </span> composition.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid</span><span style="color: navy">, </span> e.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">uuid</span><span style="color: navy">)</span><span style="color: navy">, </span> bundle.entry<b> as </b><span style="color: maroon">e2</span><span style="color: navy">, </span> e2.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Patient'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">patient</span><span style="color: navy">, </span> patient.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid2</span><span style="color: navy">, </span> e2.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">uuid2</span><span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    cda<b> then </b>ClinicalDocumentToBundle<span style="color: navy">(</span><span style="color: maroon">cda</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">composition</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">)</span> <i>&quot;cdatobundle&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;ClinicalDocumentToBody&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>ClinicalDocumentToBundle<span style="color: navy">(</span><b>source</b> <span style="color: maroon">cda</span><span style="color: navy"> : </span>ClinicalDocument, <b>target</b> <span style="color: maroon">patient</span><span style="color: navy"> : </span>Patient, <b>target</b> <span style="color: maroon">composition</span><span style="color: navy"> : </span>Composition, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle<span style="color: navy">)</span><span style="color: navy"> {
</span>  cda<span style="color: navy"><b> -&gt; </b></span>bundle.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span> <i>&quot;id&quot;</i><span style="color: navy">;</span>
  cda.id<b> as </b><span style="color: maroon">cdaId</span><span style="color: navy"><b> -&gt; </b></span>bundle.identifier<b> as </b><span style="color: maroon">identifier</span><b> then</b><span style="color: navy"> {
</span>    cdaId.root<b> as </b><span style="color: maroon">root</span><b> where </b>cdaId.extension.exists()<span style="color: navy"><b> -&gt; </b></span>identifier.system = <b>translate</b><span style="color: navy">(</span><span style="color: maroon">root</span><span style="color: navy">, </span><span style="color: blue">'#oid2uri'</span><span style="color: navy">, </span><span style="color: blue">'uri'</span><span style="color: navy">)</span> <i>&quot;system&quot;</i><span style="color: navy">;</span>
    cdaId.extension<b> as </b><span style="color: maroon">extension</span><span style="color: navy"><b> -&gt; </b></span>identifier.value = <span style="color: maroon">extension</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
    cdaId.root<b> as </b><span style="color: maroon">root</span><b> where </b>cdaId.extension.empty()<span style="color: navy"><b> -&gt; </b></span>identifier.system = <span style="color: blue">'urn:ietf:rfc:3986'</span> <i>&quot;systemOid&quot;</i><span style="color: navy">;</span>
    cdaId.root<b> as </b><span style="color: maroon">root</span><b> where </b>cdaId.extension.empty()<span style="color: navy"><b> -&gt; </b></span>identifier.value = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:oid:'</span><span style="color: navy">, </span><span style="color: maroon">root</span><span style="color: navy">)</span> <i>&quot;valueOid&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;identifier&quot;</i><span style="color: navy">;</span>
  cda<span style="color: navy"><b> -&gt; </b></span>bundle.type = <span style="color: blue">'document'</span> <i>&quot;type&quot;</i><span style="color: navy">;</span>
  cda.effectiveTime<b> as </b><span style="color: maroon">effectiveTime</span><span style="color: navy"><b> -&gt; </b></span>bundle.timestamp = <b>create</b><span style="color: navy">(</span><span style="color: blue">'instant'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">timestamp</span><b> then </b>TSInstant<span style="color: navy">(</span><span style="color: maroon">effectiveTime</span><span style="color: navy">, </span><span style="color: maroon">timestamp</span><span style="color: navy">)</span> <i>&quot;timestamp&quot;</i><span style="color: navy">;</span>
  cda<b> then </b>ClinicalDocumentComposition<span style="color: navy">(</span><span style="color: maroon">cda</span><span style="color: navy">, </span><span style="color: maroon">composition</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">)</span> <i>&quot;composition&quot;</i><span style="color: navy">;</span>
  cda.component<b> as </b><span style="color: maroon">cdaComponent</span><b> then</b><span style="color: navy"> {
</span>    cdaComponent.structuredBody<b> as </b><span style="color: maroon">body</span><b> then</b><span style="color: navy"> {
</span>      body.component<b> as </b><span style="color: maroon">bodyComponent</span><b> then</b><span style="color: navy"> {
</span>        bodyComponent.section<b> as </b><span style="color: maroon">srcSection</span><b> where </b>$this.code.empty()<span style="color: navy"><b> -&gt; </b></span>composition.section<b> as </b><span style="color: maroon">tgtSection</span><b> then </b>ClinicalDocumentSection<span style="color: navy">(</span><span style="color: maroon">cda</span><span style="color: navy">, </span><span style="color: maroon">srcSection</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">tgtSection</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">)</span><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;bodyComponent&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;body&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;cdaComponent&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><span style="color: navy">// </span><span style="color: green">// _________________________ Section Level Templates _________________________</span>
<b>group </b>ClinicalDocumentSection<span style="color: navy">(</span><b>source</b> <span style="color: maroon">cda</span><span style="color: navy"> : </span>ClinicalDocument, <b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>Section, <b>source</b> <span style="color: maroon">patient</span><span style="color: navy"> : </span>Patient, <b>target</b> <span style="color: maroon">tgt</span>, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.title<b> as </b><span style="color: maroon">t</span><span style="color: navy"><b> -&gt; </b></span>tgt.title = <span style="color: navy">(</span>t.xmlText<span style="color: navy">)</span><span style="color: navy">;</span>
  src.code<b> as </b><span style="color: maroon">srcCode</span><span style="color: navy"><b> -&gt; </b></span>tgt.code = <span style="color: maroon">srcCode</span><span style="color: navy">;</span>
  src.text<b> as </b><span style="color: maroon">cdaText</span><span style="color: navy"><b> -&gt; </b></span>tgt.text<b> as </b><span style="color: maroon">fhirText</span><b> then</b><span style="color: navy"> {
</span>    cdaText<span style="color: navy"><b> -&gt; </b></span>fhirText.status = <span style="color: blue">'generated'</span> <i>&quot;narrativeStatus&quot;</i><span style="color: navy">;</span>
    cdaText<b> as </b><span style="color: maroon">t</span><span style="color: navy"><b> -&gt; </b></span>fhirText.div = <span style="color: maroon">t</span> <i>&quot;narrativeText&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;cdaText&quot;</i><span style="color: navy">;</span>
  src.section<b> as </b><span style="color: maroon">srcSection</span><span style="color: navy"><b> -&gt; </b></span>tgt.section<b> as </b><span style="color: maroon">tgtSection</span><b> then </b>ClinicalDocumentSection<span style="color: navy">(</span><span style="color: maroon">cda</span><span style="color: navy">, </span><span style="color: maroon">srcSection</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">tgtSection</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">)</span><span style="color: navy">;</span>
<span style="color: navy">}

</span><span style="color: navy">// </span><span style="color: green">_________________________ Entry Level Templates   ________________________</span>
<span style="color: navy">// </span><span style="color: green">_________________________ Header Level Templates _________________________</span>
<b>group </b>ClinicalDocumentComposition<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>ClinicalDocument, <b>target</b> <span style="color: maroon">tgt</span><span style="color: navy"> : </span>Composition, <b>target</b> <span style="color: maroon">patientResource</span><span style="color: navy"> : </span>Patient, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.languageCode<b> as </b><span style="color: maroon">languageCode</span><span style="color: navy"><b> -&gt; </b></span>tgt.language = <b>create</b><span style="color: navy">(</span><span style="color: blue">'code'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">code</span><b> then </b>CSCode<span style="color: navy">(</span><span style="color: maroon">languageCode</span><span style="color: navy">, </span><span style="color: maroon">code</span><span style="color: navy">)</span><span style="color: navy">;</span>
  src.id<b> as </b><span style="color: maroon">id</span><b> where </b>src.setId.exists().not()<span style="color: navy"><b> -&gt; </b></span>tgt.identifier = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Identifier'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">identifier</span><b> then </b>II<span style="color: navy">(</span><span style="color: maroon">id</span><span style="color: navy">, </span><span style="color: maroon">identifier</span><span style="color: navy">)</span> <i>&quot;identifier&quot;</i><span style="color: navy">;</span>
  src.setId<b> as </b><span style="color: maroon">setId</span><span style="color: navy"><b> -&gt; </b></span>tgt.identifier = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Identifier'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">identifier</span><b> then </b>II<span style="color: navy">(</span><span style="color: maroon">setId</span><span style="color: navy">, </span><span style="color: maroon">identifier</span><span style="color: navy">)</span> <i>&quot;setIdentifier&quot;</i><span style="color: navy">;</span>
  src<span style="color: navy"><b> -&gt; </b></span>tgt.status = <span style="color: blue">'final'</span> <i>&quot;status&quot;</i><span style="color: navy">;</span>
  src.code<b> as </b><span style="color: maroon">srcCode</span><span style="color: navy"><b> -&gt; </b></span>tgt.type = <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><b> then </b>CDCodeableConcept<span style="color: navy">(</span><span style="color: maroon">srcCode</span><span style="color: navy">, </span><span style="color: maroon">cc</span><span style="color: navy">)</span><span style="color: navy">;</span>
  src.title<b> as </b><span style="color: maroon">t</span><span style="color: navy"><b> -&gt; </b></span>tgt.title = <span style="color: navy">(</span>t.xmlText<span style="color: navy">)</span><span style="color: navy">;</span>
  src.recordTarget<b> as </b><span style="color: maroon">recordTarget</span><b> then</b><span style="color: navy"> {
</span>    recordTarget.patientRole<b> as </b><span style="color: maroon">patient</span><span style="color: navy"><b> -&gt; </b></span> tgt.subject = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.reference = <span style="color: navy">(</span>'urn:uuid:' + %patientResource.id<span style="color: navy">)</span><b> then </b>ClinicalDocumentPatientRole<span style="color: navy">(</span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">patientResource</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">)</span> <i>&quot;subject&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;patientRole&quot;</i><span style="color: navy">;</span>
  src.componentOf<b> as </b><span style="color: maroon">comp</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e</span><span style="color: navy">, </span> e.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Encounter'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">encounter</span><span style="color: navy">, </span> encounter.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid</span><span style="color: navy">, </span> e.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">uuid</span><span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    comp.encompassingEncounter<b> as </b><span style="color: maroon">srcEnc</span><span style="color: navy"><b> -&gt; </b></span> tgt.encounter = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.reference = <span style="color: navy">(</span>'urn:uuid:' + %encounter.id<span style="color: navy">)</span><b> then </b>ClinicalDocumentEncounter<span style="color: navy">(</span><span style="color: maroon">srcEnc</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">, </span><span style="color: maroon">encounter</span><span style="color: navy">)</span> <i>&quot;srcEncounter&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;encompassingEncounter&quot;</i><span style="color: navy">;</span>
  src.effectiveTime<b> as </b><span style="color: maroon">effectiveTime</span><span style="color: navy"><b> -&gt; </b></span>tgt.date = <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">date</span><b> then </b>TSDateTime<span style="color: navy">(</span><span style="color: maroon">effectiveTime</span><span style="color: navy">, </span><span style="color: maroon">date</span><span style="color: navy">)</span> <i>&quot;compositionDate&quot;</i><span style="color: navy">;</span>
  src.author<b> as </b><span style="color: maroon">srcAuthor</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e</span><span style="color: navy">, </span> e.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Practitioner'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">practitioner</span><span style="color: navy">, </span> practitioner.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid2</span><span style="color: navy">, </span> e.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">uuid2</span><span style="color: navy">)</span><span style="color: navy">, </span> bundle.entry<b> as </b><span style="color: maroon">eRole</span><span style="color: navy">, </span> eRole.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'PractitionerRole'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">practitionerRole</span><span style="color: navy">, </span> practitionerRole.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuidRole</span><span style="color: navy">, </span> eRole.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">uuidRole</span><span style="color: navy">)</span><span style="color: navy">, </span> tgt.author = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.reference = <span style="color: navy">(</span>'urn:uuid:' + %practitionerRole.id<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    srcAuthor<span style="color: navy"><b> -&gt; </b></span>practitioner.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><b> then</b><span style="color: navy"> {
</span>      srcAuthor<span style="color: navy"><b> -&gt; </b></span>meta.profile = <span style="color: blue">'https://interop.esante.gouv.fr/ig/fhir/annuaire/StructureDefinition/as-practitioner'</span> <i>&quot;practitionerProfile&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;practitionerMeta&quot;</i><span style="color: navy">;</span>
    srcAuthor<span style="color: navy"><b> -&gt; </b></span>practitionerRole.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">metaRole</span><b> then</b><span style="color: navy"> {
</span>      srcAuthor<span style="color: navy"><b> -&gt; </b></span>metaRole.profile = <span style="color: blue">'https://interop.esante.gouv.fr/ig/fhir/annuaire/StructureDefinition/as-practitionerrole'</span> <i>&quot;practitionerRoleProfile&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;practitionerRoleMeta&quot;</i><span style="color: navy">;</span>
    srcAuthor<span style="color: navy"><b> -&gt; </b></span> practitionerRole.practitioner = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">refPract</span><span style="color: navy">, </span> refPract.reference = <span style="color: navy">(</span>'urn:uuid:' + %practitioner.id<span style="color: navy">)</span> <i>&quot;practitionerRef&quot;</i><span style="color: navy">;</span>
    srcAuthor.assignedAuthor<b> as </b><span style="color: maroon">assignedAuthor</span><b> then</b><span style="color: navy"> {
</span>      assignedAuthor.id<b> as </b><span style="color: maroon">id</span><span style="color: navy"><b> -&gt; </b></span>practitioner.identifier = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Identifier'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">identifier</span><b> then</b><span style="color: navy"> {
</span>        id<span style="color: navy"><b> -&gt; </b></span>identifier<b> then </b>II<span style="color: navy">(</span><span style="color: maroon">id</span><span style="color: navy">, </span><span style="color: maroon">identifier</span><span style="color: navy">)</span> <i>&quot;baseIdentifier&quot;</i><span style="color: navy">;</span>
        id<b> where </b>root = '1.2.250.1.71.4.2.1'<span style="color: navy"><b> -&gt; </b></span>identifier.type = <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">type</span><b> then</b><span style="color: navy"> {
</span>          id<span style="color: navy"><b> -&gt; </b></span>type.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">coding</span><b> then</b><span style="color: navy"> {
</span>            id<span style="color: navy"><b> -&gt; </b></span>coding.system = <span style="color: blue">'https://hl7.fr/ig/fhir/core/CodeSystem/fr-core-cs-v2-0203'</span> <i>&quot;system&quot;</i><span style="color: navy">;</span>
            id<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'IDNPS'</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;idNatPs&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;identifier&quot;</i><span style="color: navy">;</span>
      assignedAuthor.addr<b> as </b><span style="color: maroon">addr</span><span style="color: navy"><b> -&gt; </b></span>practitioner.address = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Address'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">address</span><b> then </b>ADAddress<span style="color: navy">(</span><span style="color: maroon">addr</span><span style="color: navy">, </span><span style="color: maroon">address</span><span style="color: navy">)</span><span style="color: navy">;</span>
      assignedAuthor.telecom<b> as </b><span style="color: maroon">tlc</span><span style="color: navy"><b> -&gt; </b></span>practitioner.telecom = <b>create</b><span style="color: navy">(</span><span style="color: blue">'ContactPoint'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">contactPoint</span><b> then </b>TELContactPoint<span style="color: navy">(</span><span style="color: maroon">tlc</span><span style="color: navy">, </span><span style="color: maroon">contactPoint</span><span style="color: navy">)</span><span style="color: navy">;</span>
      assignedAuthor.assignedPerson<b> as </b><span style="color: maroon">assPerson</span><b> then</b><span style="color: navy"> {
</span>        assPerson.name<b> as </b><span style="color: maroon">pName</span><span style="color: navy"><b> -&gt; </b></span>practitioner.name = <b>create</b><span style="color: navy">(</span><span style="color: blue">'HumanName'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">humanName</span><b> then </b>ENHumanName<span style="color: navy">(</span><span style="color: maroon">pName</span><span style="color: navy">, </span><span style="color: maroon">humanName</span><span style="color: navy">)</span><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;name&quot;</i><span style="color: navy">;</span>
      assignedAuthor.code<b> as </b><span style="color: maroon">roleCode</span><span style="color: navy"><b> -&gt; </b></span>practitionerRole.code = <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><b> then </b>CDCodeableConcept<span style="color: navy">(</span><span style="color: maroon">roleCode</span><span style="color: navy">, </span><span style="color: maroon">cc</span><span style="color: navy">)</span> <i>&quot;roleCode&quot;</i><span style="color: navy">;</span>
      assignedAuthor.code<b> as </b><span style="color: maroon">roleCode</span><b> where </b>code.contains('/')<span style="color: navy"><b> -&gt; </b></span>practitioner.qualification<b> as </b><span style="color: maroon">qualification</span><b> then</b><span style="color: navy"> {
</span>        roleCode<span style="color: navy"><b> -&gt; </b></span>qualification.code = <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">qualCode</span><b> then</b><span style="color: navy"> {
</span>          roleCode.code<b> as </b><span style="color: maroon">fullCode</span><span style="color: navy"><b> -&gt; </b></span>qualCode.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">coding</span><b> then</b><span style="color: navy"> {
</span>            fullCode<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: navy">(</span>%fullCode.substring(%fullCode.indexOf('/') + 1)<span style="color: navy">)</span> <i>&quot;savoirFaireCode&quot;</i><span style="color: navy">;</span>
            fullCode<span style="color: navy"><b> -&gt; </b></span>coding.system = <span style="color: blue">'https://mos.esante.gouv.fr/NOS/TRE_R38-SpecialiteOrdinale/FHIR/TRE-R38-SpecialiteOrdinale'</span> <i>&quot;systemSavoirFaire&quot;</i><span style="color: navy">;</span>
            roleCode.displayName<b> as </b><span style="color: maroon">display</span><span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: maroon">display</span> <i>&quot;display&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;qualCode&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;savoirFaire&quot;</i><span style="color: navy">;</span>
      assignedAuthor.code<b> as </b><span style="color: maroon">roleCode</span><b> where </b>code.contains('/') and code.contains('_')<span style="color: navy"><b> -&gt; </b></span>practitioner.qualification<b> as </b><span style="color: maroon">qualification</span><b> then</b><span style="color: navy"> {
</span>        roleCode<span style="color: navy"><b> -&gt; </b></span>qualification.code = <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">qualCode</span><b> then</b><span style="color: navy"> {
</span>          roleCode.code<b> as </b><span style="color: maroon">fullCode</span><span style="color: navy"><b> -&gt; </b></span>qualCode.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">coding</span><b> then</b><span style="color: navy"> {
</span>            fullCode<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: navy">(</span>%fullCode.substring(%fullCode.indexOf('_') + 1).substring(0, %fullCode.substring(%fullCode.indexOf('_') + 1).indexOf('/'))<span style="color: navy">)</span> <i>&quot;professionCode&quot;</i><span style="color: navy">;</span>
            fullCode<span style="color: navy"><b> -&gt; </b></span>coding.system = <span style="color: blue">'https://mos.esante.gouv.fr/NOS/TRE_G15-ProfessionSante/FHIR/TRE-G15-ProfessionSante'</span> <i>&quot;systemProfession&quot;</i><span style="color: navy">;</span>
            fullCode<b> where </b>%fullCode.substring(%fullCode.indexOf('_') + 1).substring(0, %fullCode.substring(%fullCode.indexOf('_') + 1).indexOf('/')) = '10'<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Médecin'</span> <i>&quot;displayMedecin&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;qualCode&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;profession&quot;</i><span style="color: navy">;</span>
      assignedAuthor.representedOrganization<b> as </b><span style="color: maroon">srcOrg</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e2</span><span style="color: navy">, </span> e2.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Organization'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">organization</span><span style="color: navy">, </span> organization.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid3</span><span style="color: navy">, </span> e2.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">uuid3</span><span style="color: navy">)</span><span style="color: navy">, </span> practitionerRole.organization = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">refOrg</span><span style="color: navy">, </span> refOrg.reference = <span style="color: navy">(</span>'urn:uuid:' + %organization.id<span style="color: navy">)</span><b> then </b>ClinicalDocumentOrganization<span style="color: navy">(</span><span style="color: maroon">srcOrg</span><span style="color: navy">, </span><span style="color: maroon">organization</span><span style="color: navy">)</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;author&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;srcAuthor&quot;</i><span style="color: navy">;</span>
  src.informant<b> as </b><span style="color: maroon">srcInformant</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e</span><span style="color: navy">, </span> e.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'RelatedPerson'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">relatedPerson</span><span style="color: navy">, </span> relatedPerson.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuidRelated</span><span style="color: navy">, </span> e.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">uuidRelated</span><span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    srcInformant.relatedEntity<b> as </b><span style="color: maroon">relatedEntity</span><b> then</b><span style="color: navy"> {
</span>      relatedEntity<span style="color: navy"><b> -&gt; </b></span> relatedPerson.patient = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">patientRef</span><span style="color: navy">, </span> patientRef.reference = <span style="color: navy">(</span>'urn:uuid:' + %patientResource.id<span style="color: navy">)</span> <i>&quot;patientRef&quot;</i><span style="color: navy">;</span>
      relatedEntity.code<b> as </b><span style="color: maroon">relationCode</span><span style="color: navy"><b> -&gt; </b></span>relatedPerson.relationship = <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><b> then </b>CDCodeableConcept<span style="color: navy">(</span><span style="color: maroon">relationCode</span><span style="color: navy">, </span><span style="color: maroon">cc</span><span style="color: navy">)</span> <i>&quot;relationship&quot;</i><span style="color: navy">;</span>
      relatedEntity.addr<b> as </b><span style="color: maroon">addr</span><span style="color: navy"><b> -&gt; </b></span>relatedPerson.address = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Address'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">address</span><b> then </b>ADAddress<span style="color: navy">(</span><span style="color: maroon">addr</span><span style="color: navy">, </span><span style="color: maroon">address</span><span style="color: navy">)</span> <i>&quot;address&quot;</i><span style="color: navy">;</span>
      relatedEntity.telecom<b> as </b><span style="color: maroon">tlc</span><span style="color: navy"><b> -&gt; </b></span>relatedPerson.telecom = <b>create</b><span style="color: navy">(</span><span style="color: blue">'ContactPoint'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">contactPoint</span><b> then </b>TELContactPoint<span style="color: navy">(</span><span style="color: maroon">tlc</span><span style="color: navy">, </span><span style="color: maroon">contactPoint</span><span style="color: navy">)</span><span style="color: navy">;</span>
      relatedEntity.relatedPerson<b> as </b><span style="color: maroon">relPerson</span><b> then</b><span style="color: navy"> {
</span>        relPerson.name<b> as </b><span style="color: maroon">pName</span><span style="color: navy"><b> -&gt; </b></span>relatedPerson.name = <b>create</b><span style="color: navy">(</span><span style="color: blue">'HumanName'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">humanName</span><b> then </b>ENHumanName<span style="color: navy">(</span><span style="color: maroon">pName</span><span style="color: navy">, </span><span style="color: maroon">humanName</span><span style="color: navy">)</span><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;relatedPersonName&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span><span style="color: navy">;</span>
  <span style="color: navy">}</span><span style="color: navy">;</span>
  src.confidentialityCode<b> as </b><span style="color: maroon">confCode</span><span style="color: navy"><b> -&gt; </b></span>tgt.confidentiality = <b>create</b><span style="color: navy">(</span><span style="color: blue">'code'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">code</span><b> then </b>CSCode<span style="color: navy">(</span><span style="color: maroon">confCode</span><span style="color: navy">, </span><span style="color: maroon">code</span><span style="color: navy">)</span><span style="color: navy">;</span>
  src.legalAuthenticator<b> as </b><span style="color: maroon">legalAuth</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e</span><span style="color: navy">, </span> e.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Practitioner'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">practitioner</span><span style="color: navy">, </span> practitioner.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid2</span><span style="color: navy">, </span> e.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">uuid2</span><span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    legalAuth<span style="color: navy"><b> -&gt; </b></span>tgt.attester<b> as </b><span style="color: maroon">attester</span><b> then</b><span style="color: navy"> {
</span>      legalAuth<span style="color: navy"><b> -&gt; </b></span>attester.mode = <span style="color: blue">'legal'</span> <i>&quot;mode&quot;</i><span style="color: navy">;</span>
      legalAuth.time<b> as </b><span style="color: maroon">time</span><span style="color: navy"><b> -&gt; </b></span>attester.time = <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><b> then </b>TSDateTime<span style="color: navy">(</span><span style="color: maroon">time</span><span style="color: navy">, </span><span style="color: maroon">dt</span><span style="color: navy">)</span><span style="color: navy">;</span>
      legalAuth.assignedEntity<b> as </b><span style="color: maroon">entity</span><span style="color: navy"><b> -&gt; </b></span> attester.party = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.reference = <span style="color: navy">(</span>'urn:uuid:' + %practitioner.id<span style="color: navy">)</span><b> then </b>ClinicalDocumentEntityPractitioner<span style="color: navy">(</span><span style="color: maroon">entity</span><span style="color: navy">, </span><span style="color: maroon">practitioner</span><span style="color: navy">)</span> <i>&quot;entity&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;attester&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;legalAuth&quot;</i><span style="color: navy">;</span>
  src.authenticator<b> as </b><span style="color: maroon">auth</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e</span><span style="color: navy">, </span> e.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Practitioner'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">practitioner</span><span style="color: navy">, </span> practitioner.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid2</span><span style="color: navy">, </span> e.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">uuid2</span><span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    auth<span style="color: navy"><b> -&gt; </b></span>tgt.attester<b> as </b><span style="color: maroon">attester</span><b> then</b><span style="color: navy"> {
</span>      auth<span style="color: navy"><b> -&gt; </b></span>attester.mode = <span style="color: blue">'official'</span> <i>&quot;mode&quot;</i><span style="color: navy">;</span>
      auth.time<b> as </b><span style="color: maroon">time</span><span style="color: navy"><b> -&gt; </b></span>attester.time = <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><b> then </b>TSDateTime<span style="color: navy">(</span><span style="color: maroon">time</span><span style="color: navy">, </span><span style="color: maroon">dt</span><span style="color: navy">)</span><span style="color: navy">;</span>
      auth.assignedEntity<b> as </b><span style="color: maroon">entity</span><span style="color: navy"><b> -&gt; </b></span> attester.party = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.reference = <span style="color: navy">(</span>'urn:uuid:' + %practitioner.id<span style="color: navy">)</span><b> then </b>ClinicalDocumentEntityPractitioner<span style="color: navy">(</span><span style="color: maroon">entity</span><span style="color: navy">, </span><span style="color: maroon">practitioner</span><span style="color: navy">)</span> <i>&quot;entity&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;attester&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;auth&quot;</i><span style="color: navy">;</span>
  src.custodian<b> as </b><span style="color: maroon">custodian</span><span style="color: navy"><b> -&gt; </b></span>bundle.entry<b> as </b><span style="color: maroon">e</span><b> then</b><span style="color: navy"> {
</span>    custodian.assignedCustodian<b> as </b><span style="color: maroon">assignedCustodian</span><span style="color: navy"><b> -&gt; </b></span> e.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Organization'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">organization</span><span style="color: navy">, </span> organization.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid3</span><span style="color: navy">, </span> e.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">uuid3</span><span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      assignedCustodian.representedCustodianOrganization<b> as </b><span style="color: maroon">srcOrg</span><span style="color: navy"><b> -&gt; </b></span> tgt.custodian = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.reference = <span style="color: navy">(</span>'urn:uuid:' + %organization.id<span style="color: navy">)</span><b> then </b>ClinicalDocumentOrganization<span style="color: navy">(</span><span style="color: maroon">srcOrg</span><span style="color: navy">, </span><span style="color: maroon">organization</span><span style="color: navy">)</span> <i>&quot;assignedCustodian&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;custodian&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;cust&quot;</i><span style="color: navy">;</span>
  src.documentationOf<b> as </b><span style="color: maroon">docOf</span><b> then</b><span style="color: navy"> {
</span>    docOf.serviceEvent<b> as </b><span style="color: maroon">serviceEvent</span><span style="color: navy"><b> -&gt; </b></span>tgt.event<b> as </b><span style="color: maroon">event</span><b> then</b><span style="color: navy"> {
</span>      serviceEvent.code<b> as </b><span style="color: maroon">eventCode</span><span style="color: navy"><b> -&gt; </b></span>event.code = <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><b> then </b>CDCodeableConcept<span style="color: navy">(</span><span style="color: maroon">eventCode</span><span style="color: navy">, </span><span style="color: maroon">cc</span><span style="color: navy">)</span> <i>&quot;eventCode&quot;</i><span style="color: navy">;</span>
      serviceEvent.effectiveTime<b> as </b><span style="color: maroon">effectivetime</span><span style="color: navy"><b> -&gt; </b></span>event.period = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Period'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">period</span><b> then </b>IVLTSPeriod<span style="color: navy">(</span><span style="color: maroon">effectivetime</span><span style="color: navy">, </span><span style="color: maroon">period</span><span style="color: navy">)</span> <i>&quot;eventTime&quot;</i><span style="color: navy">;</span> <span style="color: navy">// </span><span style="color: green">performerType: for src.performer.typeCode ...</span>
    <span style="color: navy">}</span> <i>&quot;docOf&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span><span style="color: navy">;</span>
  src.relatedDocument<b> as </b><span style="color: maroon">relatedDoc</span><span style="color: navy"><b> -&gt; </b></span>tgt.relatesTo<b> as </b><span style="color: maroon">relates</span><b> then</b><span style="color: navy"> {
</span>    relatedDoc.typeCode<b> as </b><span style="color: maroon">typeCode</span><span style="color: navy"><b> -&gt; </b></span>relates.code = <span style="color: maroon">typeCode</span><span style="color: navy">;</span>
    relatedDoc.parentDocument<b> as </b><span style="color: maroon">parentDoc</span><b> then</b><span style="color: navy"> {
</span>      parentDoc.setId<b> as </b><span style="color: maroon">sid</span><span style="color: navy"><b> -&gt; </b></span>relates.targetIdentifier = <span style="color: maroon">sid</span><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;parentDoc&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;relatedDoc&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>ClinicalDocumentEntityPractitioner<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>AssignedEntity, <b>target</b> <span style="color: maroon">tgt</span><span style="color: navy"> : </span>Practitioner<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><b> then</b><span style="color: navy"> {
</span>    src<span style="color: navy"><b> -&gt; </b></span>meta.profile = <span style="color: blue">'https://interop.esante.gouv.fr/ig/fhir/annuaire/StructureDefinition/as-practitioner'</span> <i>&quot;profile&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;meta&quot;</i><span style="color: navy">;</span>
  src.id<b> as </b><span style="color: maroon">srcId</span><span style="color: navy"><b> -&gt; </b></span>tgt.identifier = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Identifier'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">identifier</span><b> then</b><span style="color: navy"> {
</span>    srcId<span style="color: navy"><b> -&gt; </b></span>identifier<b> then </b>II<span style="color: navy">(</span><span style="color: maroon">srcId</span><span style="color: navy">, </span><span style="color: maroon">identifier</span><span style="color: navy">)</span> <i>&quot;baseIdentifier&quot;</i><span style="color: navy">;</span>
    srcId<b> where </b>root = '1.2.250.1.71.4.2.1'<span style="color: navy"><b> -&gt; </b></span>identifier.type = <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">type</span><b> then</b><span style="color: navy"> {
</span>      srcId<span style="color: navy"><b> -&gt; </b></span>type.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">coding</span><b> then</b><span style="color: navy"> {
</span>        srcId<span style="color: navy"><b> -&gt; </b></span>coding.system = <span style="color: blue">'https://hl7.fr/ig/fhir/core/CodeSystem/fr-core-cs-v2-0203'</span> <i>&quot;system&quot;</i><span style="color: navy">;</span>
        srcId<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'IDNPS'</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;idNatPs&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;identifier&quot;</i><span style="color: navy">;</span>
  src.addr<b> as </b><span style="color: maroon">srcAddr</span><span style="color: navy"><b> -&gt; </b></span>tgt.address = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Address'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">address</span><b> then </b>ADAddress<span style="color: navy">(</span><span style="color: maroon">srcAddr</span><span style="color: navy">, </span><span style="color: maroon">address</span><span style="color: navy">)</span><span style="color: navy">;</span>
  src.telecom<b> as </b><span style="color: maroon">srcTelecom</span><span style="color: navy"><b> -&gt; </b></span>tgt.telecom = <b>create</b><span style="color: navy">(</span><span style="color: blue">'ContactPoint'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">contactPoint</span><b> then </b>TELContactPoint<span style="color: navy">(</span><span style="color: maroon">srcTelecom</span><span style="color: navy">, </span><span style="color: maroon">contactPoint</span><span style="color: navy">)</span><span style="color: navy">;</span>
  src.assignedPerson<b> as </b><span style="color: maroon">person</span><b> then</b><span style="color: navy"> {
</span>    person.name<b> as </b><span style="color: maroon">pName</span><span style="color: navy"><b> -&gt; </b></span>tgt.name = <b>create</b><span style="color: navy">(</span><span style="color: blue">'HumanName'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">humanName</span><b> then </b>ENHumanName<span style="color: navy">(</span><span style="color: maroon">pName</span><span style="color: navy">, </span><span style="color: maroon">humanName</span><span style="color: navy">)</span><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;name&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>ClinicalDocumentOrganization<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>CustodianOrganization, <b>target</b> <span style="color: maroon">tgt</span><span style="color: navy"> : </span>Organization<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><b> then</b><span style="color: navy"> {
</span>    src<span style="color: navy"><b> -&gt; </b></span>meta.profile = <span style="color: blue">'https://interop.esante.gouv.fr/ig/fhir/annuaire/StructureDefinition/as-organization'</span> <i>&quot;profile&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;meta&quot;</i><span style="color: navy">;</span>
  src.id<b> as </b><span style="color: maroon">srcId</span><span style="color: navy"><b> -&gt; </b></span>tgt.identifier = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Identifier'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">identifier</span><b> then </b>II<span style="color: navy">(</span><span style="color: maroon">srcId</span><span style="color: navy">, </span><span style="color: maroon">identifier</span><span style="color: navy">)</span><span style="color: navy">;</span>
  src.name<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>tgt.name = <span style="color: navy">(</span>v.other<span style="color: navy">)</span><span style="color: navy">;</span>
  src.telecom<b> as </b><span style="color: maroon">srcTelecom</span><span style="color: navy"><b> -&gt; </b></span>tgt.telecom = <b>create</b><span style="color: navy">(</span><span style="color: blue">'ContactPoint'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">contactPoint</span><b> then </b>TELContactPoint<span style="color: navy">(</span><span style="color: maroon">srcTelecom</span><span style="color: navy">, </span><span style="color: maroon">contactPoint</span><span style="color: navy">)</span><span style="color: navy">;</span>
  src.addr<b> as </b><span style="color: maroon">srcAddr</span><span style="color: navy"><b> -&gt; </b></span>tgt.address = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Address'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">address</span><b> then </b>ADAddress<span style="color: navy">(</span><span style="color: maroon">srcAddr</span><span style="color: navy">, </span><span style="color: maroon">address</span><span style="color: navy">)</span><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>ClinicalDocumentPatientRole<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>PatientRole, <b>target</b> <span style="color: maroon">tgt</span><span style="color: navy"> : </span>Patient, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle<span style="color: navy">)</span><span style="color: navy"> {
</span>  <span style="color: #b36b00" title="Cet élément nétait pas défini avant R5">// src.id -&gt; tgt.identifier;</span>
  <span style="color: navy">// </span><span style="color: green">Patient.identifier.type for EPR context, because there is only the identifier &quot;LocalPid&quot; allowed, LocalPid requires an type -&gt; http://build.fhir.org/ig/hl7ch/ch-core/branches/master/StructureDefinition-ch-core-composition-patient-epr.html</span>
  <span style="color: navy">// </span><span style="color: green">Modification NR</span>
  src.id<b> as </b><span style="color: maroon">id</span><span style="color: navy"><b> -&gt; </b></span>tgt.identifier = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Identifier'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">identifier</span><b> then </b>setFrPatientIdentifier<span style="color: navy">(</span><span style="color: maroon">id</span><span style="color: navy">, </span><span style="color: maroon">identifier</span><span style="color: navy">)</span><span style="color: navy">;</span>
  src.addr<b> as </b><span style="color: maroon">srcAddr</span><span style="color: navy"><b> -&gt; </b></span>tgt.address = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Address'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">address</span><b> then </b>ADAddress<span style="color: navy">(</span><span style="color: maroon">srcAddr</span><span style="color: navy">, </span><span style="color: maroon">address</span><span style="color: navy">)</span><span style="color: navy">;</span>
  src.telecom<b> as </b><span style="color: maroon">srcTelecom</span><span style="color: navy"><b> -&gt; </b></span>tgt.telecom = <b>create</b><span style="color: navy">(</span><span style="color: blue">'ContactPoint'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">contactPoint</span><b> then </b>TELContactPoint<span style="color: navy">(</span><span style="color: maroon">srcTelecom</span><span style="color: navy">, </span><span style="color: maroon">contactPoint</span><span style="color: navy">)</span><span style="color: navy">;</span>
  src.patient<b> as </b><span style="color: maroon">patient</span><b> then</b><span style="color: navy"> {
</span>    patient.name<b> as </b><span style="color: maroon">patientName</span><span style="color: navy"><b> -&gt; </b></span>tgt.name = <b>create</b><span style="color: navy">(</span><span style="color: blue">'HumanName'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">humanName</span><b> then </b>ENHumanName<span style="color: navy">(</span><span style="color: maroon">patientName</span><span style="color: navy">, </span><span style="color: maroon">humanName</span><span style="color: navy">)</span><span style="color: navy">;</span>
    patient.administrativeGenderCode<b> as </b><span style="color: maroon">gender</span><b> then</b><span style="color: navy"> {
</span>      gender.code<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>tgt.gender = <b>translate</b><span style="color: navy">(</span><span style="color: maroon">v</span><span style="color: navy">, </span><span style="color: blue">'https://interop.esante.gouv.fr/ig/fhir/mappingcdafhir/ConceptMap/cm-v3-administrative-gender'</span><span style="color: navy">, </span><span style="color: blue">'code'</span><span style="color: navy">)</span> <i>&quot;gender&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;gender&quot;</i><span style="color: navy">;</span>
    patient.birthTime<b> as </b><span style="color: maroon">birthTime</span><span style="color: navy"><b> -&gt; </b></span>tgt.birthDate = <b>create</b><span style="color: navy">(</span><span style="color: blue">'date'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">date</span><b> then </b>TSDate<span style="color: navy">(</span><span style="color: maroon">birthTime</span><span style="color: navy">, </span><span style="color: maroon">date</span><span style="color: navy">)</span> <i>&quot;birthDate&quot;</i><span style="color: navy">;</span>
    patient.deceasedInd<b> as </b><span style="color: maroon">indicator</span><b> where </b>patient.deceasedTime.empty()<span style="color: navy"><b> -&gt; </b></span>tgt.deceased = <b>create</b><span style="color: navy">(</span><span style="color: blue">'boolean'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">bool</span><b> then </b>boolean<span style="color: navy">(</span><span style="color: maroon">indicator</span><span style="color: navy">, </span><span style="color: maroon">bool</span><span style="color: navy">)</span> <i>&quot;deceasedBL&quot;</i><span style="color: navy">;</span>
    patient.deceasedTime<b> as </b><span style="color: maroon">dTime</span><span style="color: navy"><b> -&gt; </b></span>tgt.deceased = <span style="color: maroon">dTime</span><span style="color: navy">;</span>
    patient.maritalStatusCode<b> as </b><span style="color: maroon">mStatus</span><span style="color: navy"><b> -&gt; </b></span>tgt.maritalStatus = <span style="color: maroon">mStatus</span> <i>&quot;maritalStatus&quot;</i><span style="color: navy">;</span>
    patient.languageCommunication<b> as </b><span style="color: maroon">language</span><span style="color: navy"><b> -&gt; </b></span>tgt.communication<b> as </b><span style="color: maroon">communication</span><b> then</b><span style="color: navy"> {
</span>      language.languageCode<b> as </b><span style="color: maroon">lCode</span><span style="color: navy"><b> -&gt; </b></span>communication.language = <span style="color: maroon">lCode</span> <i>&quot;communication&quot;</i><span style="color: navy">;</span> <span style="color: navy">// </span><span style="color: green">preference: for language.preferenceInd make communication.preferred</span>
    <span style="color: navy">}</span> <i>&quot;language&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;patientrole&quot;</i><span style="color: navy">;</span>
  src.providerOrganization<b> as </b><span style="color: maroon">org</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e</span><span style="color: navy">, </span> e.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Organization'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">organization</span><span style="color: navy">, </span> organization.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid3</span><span style="color: navy">, </span> e.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">uuid3</span><span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    org<span style="color: navy"><b> -&gt; </b></span> tgt.managingOrganization = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.reference = <span style="color: navy">(</span>'urn:uuid:' + %organization.id<span style="color: navy">)</span> <i>&quot;reference&quot;</i><span style="color: navy">;</span>
    org.id<b> as </b><span style="color: maroon">orgId</span><span style="color: navy"><b> -&gt; </b></span>organization.identifier = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Identifier'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">identifier</span><b> then </b>II<span style="color: navy">(</span><span style="color: maroon">orgId</span><span style="color: navy">, </span><span style="color: maroon">identifier</span><span style="color: navy">)</span><span style="color: navy">;</span>
    org.name<b> as </b><span style="color: maroon">v</span><span style="color: navy"><b> -&gt; </b></span>organization.name = <span style="color: navy">(</span>v.other<span style="color: navy">)</span><span style="color: navy">;</span>
    org.telecom<b> as </b><span style="color: maroon">orgTel</span><span style="color: navy"><b> -&gt; </b></span>organization.telecom = <b>create</b><span style="color: navy">(</span><span style="color: blue">'ContactPoint'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">contactPoint</span><b> then </b>TELContactPoint<span style="color: navy">(</span><span style="color: maroon">orgTel</span><span style="color: navy">, </span><span style="color: maroon">contactPoint</span><span style="color: navy">)</span><span style="color: navy">;</span>
    org.addr<b> as </b><span style="color: maroon">orgAddr</span><span style="color: navy"><b> -&gt; </b></span>organization.address = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Address'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">address</span><b> then </b>ADAddress<span style="color: navy">(</span><span style="color: maroon">orgAddr</span><span style="color: navy">, </span><span style="color: maroon">address</span><span style="color: navy">)</span><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;organization&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>setFrPatientIdentifier<span style="color: navy">(</span><b>source</b> <span style="color: maroon">id</span><span style="color: navy"> : </span>II, <b>target</b> <span style="color: maroon">identifier</span><span style="color: navy"> : </span>Identifier<span style="color: navy">)</span><span style="color: navy"> {
</span>  id<span style="color: navy"><b> -&gt; </b></span> identifier<span style="color: navy">, </span> identifier.type<b> as </b><span style="color: maroon">type</span><span style="color: navy">, </span> type.coding<b> as </b><span style="color: maroon">coding</span><span style="color: navy">, </span> coding.system<b> as </b><span style="color: maroon">system</span><span style="color: navy">, </span> coding.code<b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span>    <span style="color: navy">// </span><span style="color: green">src -&gt; system.value = 'http://terminology.hl7.org/CodeSystem/v2-0203' &quot;system&quot;;</span>
    <span style="color: navy">// </span><span style="color: green">INS-NIR - 1.2.250.1.213.1.4.8</span>
    id<b> where </b>(id.root = '1.2.250.1.213.1.4.8')<span style="color: navy"><b> -&gt; </b></span>system.value = <span style="color: blue">'https://hl7.fr/ig/fhir/core/CodeSystem/fr-core-cs-v2-0203'</span> <i>&quot;system&quot;</i><span style="color: navy">;</span>
    id<b> where </b>(id.root = '1.2.250.1.213.1.4.8')<span style="color: navy"><b> -&gt; </b></span>code.value = <span style="color: blue">'INS-NIR'</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">// </span><span style="color: green">IPP - 1.2.3.4.5.6.7.8.9.10</span>
    id<b> where </b>(id.root = '1.2.3.4.5.6.7.8.9.10')<span style="color: navy"><b> -&gt; </b></span>system.value = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/v2-0203'</span> <i>&quot;system&quot;</i><span style="color: navy">;</span>
    id<b> where </b>(id.root = '1.2.3.4.5.6.7.8.9.10')<span style="color: navy"><b> -&gt; </b></span>code.value = <span style="color: blue">'PI'</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;identifierType&quot;</i><span style="color: navy">;</span>
  id.extension<b> as </b><span style="color: maroon">extension</span><span style="color: navy"><b> -&gt; </b></span> identifier.value<b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.value = <span style="color: maroon">extension</span><span style="color: navy">;</span>
  id.root<b> as </b><span style="color: maroon">root</span><span style="color: navy"><b> -&gt; </b></span> identifier.system<b> as </b><span style="color: maroon">system</span><span style="color: navy">, </span> system.value = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:oid:'</span><span style="color: navy">, </span><span style="color: maroon">root</span><span style="color: navy">)</span><span style="color: navy">;</span>
<span style="color: navy">}

</span><span style="color: navy">// </span><span style="color: green">Fin modification NR</span>
<span style="color: navy">// </span><span style="color: green">Etat initial</span>
<span style="color: #b36b00" title="Cet élément nétait pas défini avant R5">// src -&gt; tgt.identifier as identifier then {</span>
<span style="color: #b36b00" title="Cet élément nétait pas défini avant R5">// src.id as id -&gt; identifier.type as type, type.coding as coding, coding.system as system, coding.code as code then {</span>
<span style="color: #b36b00" title="Cet élément nétait pas défini avant R5">// src -&gt; system.value = 'http://terminology.hl7.org/CodeSystem/v2-0203' &quot;system&quot;;</span>
<span style="color: #b36b00" title="Cet élément nétait pas défini avant R5">// src -&gt; code.value = 'MR' &quot;code&quot;;</span>
<span style="color: navy">// </span><span style="color: green">id.extension as extension -&gt; identifier.value as value, value.value = extension &quot;extension&quot;;</span>
<span style="color: navy">// </span><span style="color: green">id.root as root -&gt; identifier.system as system, system.value = append('urn:oid:', root) &quot;root&quot;;</span>
<span style="color: navy">// </span><span style="color: green">} &quot;id&quot;;</span>
<span style="color: navy">// </span><span style="color: green">} &quot;identifier&quot;;</span>
<span style="color: navy">// </span><span style="color: green">Fin état initial</span>
<b>group </b>ClinicalDocumentEncounter<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>EncompassingEncounter, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle, <b>target</b> <span style="color: maroon">tgt</span><span style="color: navy"> : </span>Encounter<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.id<b> as </b><span style="color: maroon">Id</span><span style="color: navy"><b> -&gt; </b></span>tgt.identifier = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Identifier'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">identifier</span><b> then </b>II<span style="color: navy">(</span><span style="color: maroon">Id</span><span style="color: navy">, </span><span style="color: maroon">identifier</span><span style="color: navy">)</span><span style="color: navy">;</span>
  src<span style="color: navy"><b> -&gt; </b></span>tgt.status = <span style="color: blue">'finished'</span> <i>&quot;status&quot;</i><span style="color: navy">;</span>
  src.code<b> as </b><span style="color: maroon">srcCode</span><span style="color: navy"><b> -&gt; </b></span>tgt.class = <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">coding</span><b> then</b><span style="color: navy"> {
</span>    srcCode.code<b> as </b><span style="color: maroon">code</span><span style="color: navy"><b> -&gt; </b></span>coding.code = <b>cast</b><span style="color: navy">(</span><span style="color: maroon">code</span><span style="color: navy">, </span><span style="color: blue">'string'</span><span style="color: navy">)</span><span style="color: navy">;</span>
    srcCode.codeSystem<b> as </b><span style="color: maroon">system</span><span style="color: navy"><b> -&gt; </b></span>coding.system = <b>translate</b><span style="color: navy">(</span><span style="color: maroon">system</span><span style="color: navy">, </span><span style="color: blue">'http://hl7.org/fhir/ConceptMap/special-oid2uri'</span><span style="color: navy">, </span><span style="color: blue">'uri'</span><span style="color: navy">)</span><span style="color: navy">;</span>
    srcCode.displayName<b> as </b><span style="color: maroon">display</span><span style="color: navy"><b> -&gt; </b></span>coding.display = <b>cast</b><span style="color: navy">(</span><span style="color: maroon">display</span><span style="color: navy">, </span><span style="color: blue">'string'</span><span style="color: navy">)</span><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;class&quot;</i><span style="color: navy">;</span>
  src.code<b> as </b><span style="color: maroon">srcCode</span><span style="color: navy"><b> -&gt; </b></span>tgt.type = <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><b> then </b>CDCodeableConcept<span style="color: navy">(</span><span style="color: maroon">srcCode</span><span style="color: navy">, </span><span style="color: maroon">cc</span><span style="color: navy">)</span><span style="color: navy">;</span>
  src.effectiveTime<b> as </b><span style="color: maroon">effTime</span><span style="color: navy"><b> -&gt; </b></span>tgt.period = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Period'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">period</span><b> then </b>IVLTSPeriod<span style="color: navy">(</span><span style="color: maroon">effTime</span><span style="color: navy">, </span><span style="color: maroon">period</span><span style="color: navy">)</span><span style="color: navy">;</span>
  src<b> where </b>admissionReferralSourceCode.exists() or dischargeDispositionCode.exists()<span style="color: navy"><b> -&gt; </b></span>tgt.hospitalization<b> as </b><span style="color: maroon">hosp</span><b> then</b><span style="color: navy"> {
</span>    src.admissionReferralSourceCode<b> as </b><span style="color: maroon">admRef</span><span style="color: navy"><b> -&gt; </b></span>hosp.admitSource = <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><b> then </b>CDCodeableConcept<span style="color: navy">(</span><span style="color: maroon">admRef</span><span style="color: navy">, </span><span style="color: maroon">cc</span><span style="color: navy">)</span> <i>&quot;adminReferral&quot;</i><span style="color: navy">;</span>
    src.dischargeDispositionCode<b> as </b><span style="color: maroon">discDispo</span><span style="color: navy"><b> -&gt; </b></span>hosp.dischargeDisposition = <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><b> then </b>CDCodeableConcept<span style="color: navy">(</span><span style="color: maroon">discDispo</span><span style="color: navy">, </span><span style="color: maroon">cc</span><span style="color: navy">)</span> <i>&quot;discDisposition&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;hospitalization&quot;</i><span style="color: navy">;</span>
  src.encounterParticipant<b> as </b><span style="color: maroon">srcPart</span><span style="color: navy"><b> -&gt; </b></span>tgt.participant<b> as </b><span style="color: maroon">tgtPart</span><b> then</b><span style="color: navy"> {
</span>    srcPart.typeCode<b> as </b><span style="color: maroon">code</span><span style="color: navy"><b> -&gt; </b></span>tgtPart.type = <b>cc</b><span style="color: navy">(</span><span style="color: blue">'http://terminology.hl7.org/CodeSystem/v3-ParticipationType'</span><span style="color: navy">, </span><span style="color: maroon">code</span><span style="color: navy">)</span><span style="color: navy">;</span>
    srcPart.time<b> as </b><span style="color: maroon">srcTime</span><span style="color: navy"><b> -&gt; </b></span>tgtPart.period = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Period'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">period</span><b> then </b>IVLTSPeriod<span style="color: navy">(</span><span style="color: maroon">srcTime</span><span style="color: navy">, </span><span style="color: maroon">period</span><span style="color: navy">)</span><span style="color: navy">;</span>
    srcPart.assignedEntity<b> as </b><span style="color: maroon">entity</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e</span><span style="color: navy">, </span> e.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Practitioner'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">practitioner</span><span style="color: navy">, </span> practitioner.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid2</span><span style="color: navy">, </span> e.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">uuid2</span><span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      entity<span style="color: navy"><b> -&gt; </b></span> tgtPart.individual = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.reference = <span style="color: navy">(</span>'urn:uuid:' + %practitioner.id<span style="color: navy">)</span><b> then </b>ClinicalDocumentEntityPractitioner<span style="color: navy">(</span><span style="color: maroon">entity</span><span style="color: navy">, </span><span style="color: maroon">practitioner</span><span style="color: navy">)</span> <i>&quot;entry&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;entity&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;participant&quot;</i><span style="color: navy">;</span>
  src.location<b> as </b><span style="color: maroon">srcLocation</span><b> then</b><span style="color: navy"> {
</span>    srcLocation.healthCareFacility<b> as </b><span style="color: maroon">facility</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e</span><span style="color: navy">, </span> e.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Location'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">location</span><span style="color: navy">, </span> location.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid2</span><span style="color: navy">, </span> e.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">uuid2</span><span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      facility<span style="color: navy"><b> -&gt; </b></span> tgt.location<b> as </b><span style="color: maroon">tgtLocation</span><span style="color: navy">, </span> tgtLocation.location = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.reference = <span style="color: navy">(</span>'urn:uuid:' + %location.id<span style="color: navy">)</span><b> then </b>ClinicalDocumentLocation<span style="color: navy">(</span><span style="color: maroon">facility</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">, </span><span style="color: maroon">location</span><span style="color: navy">)</span> <i>&quot;facLocation&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;facility&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span><span style="color: navy">;</span>
<span style="color: navy">}

</span><b>group </b>ClinicalDocumentLocation<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>HealthCareFacility, <b>target</b> <span style="color: maroon">bundle</span><span style="color: navy"> : </span>Bundle, <b>target</b> <span style="color: maroon">tgt</span><span style="color: navy"> : </span>Location<span style="color: navy">)</span><span style="color: navy"> {
</span>  src.id<b> as </b><span style="color: maroon">srcIdentifier</span><span style="color: navy"><b> -&gt; </b></span>tgt.identifier = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Identifier'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">identifier</span><b> then </b>II<span style="color: navy">(</span><span style="color: maroon">srcIdentifier</span><span style="color: navy">, </span><span style="color: maroon">identifier</span><span style="color: navy">)</span><span style="color: navy">;</span>
  src.code<b> as </b><span style="color: maroon">srcCode</span><span style="color: navy"><b> -&gt; </b></span>tgt.type = <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><b> then</b><span style="color: navy"> {
</span>    srcCode.code<b> as </b><span style="color: maroon">code</span><span style="color: navy"><b> -&gt; </b></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">coding</span><b> then</b><span style="color: navy"> {
</span>      code<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: maroon">code</span> <i>&quot;code&quot;</i><span style="color: navy">;</span>
      code<span style="color: navy"><b> -&gt; </b></span>coding.system = <span style="color: blue">'https://mos.esante.gouv.fr/NOS/TRE_R02-SecteurActivite/FHIR/TRE-R02-SecteurActivite'</span> <i>&quot;system&quot;</i><span style="color: navy">;</span>
      srcCode.displayName<b> as </b><span style="color: maroon">display</span><span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: maroon">display</span> <i>&quot;display&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;coding&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;locationType&quot;</i><span style="color: navy">;</span>
  src.location<b> as </b><span style="color: maroon">location</span><b> then</b><span style="color: navy"> {
</span>    <span style="color: navy">// </span><span style="color: green">place names are usually stored with no parts    location.name as srcName -&gt; tgt.name = cast(srcName, 'string');</span>
    location.addr<b> as </b><span style="color: maroon">locAddr</span><span style="color: navy"><b> -&gt; </b></span>tgt.address = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Address'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">address</span><b> then </b>ADAddress<span style="color: navy">(</span><span style="color: maroon">locAddr</span><span style="color: navy">, </span><span style="color: maroon">address</span><span style="color: navy">)</span><span style="color: navy">;</span>
    location.serviceProviderOrganization<b> as </b><span style="color: maroon">srcOrg</span><span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">e</span><span style="color: navy">, </span> e.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Organization'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">organization</span><span style="color: navy">, </span> organization.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">uuid3</span><span style="color: navy">, </span> e.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">uuid3</span><span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      srcOrg<span style="color: navy"><b> -&gt; </b></span> tgt.managingOrganization = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Reference'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">reference</span><span style="color: navy">, </span> reference.reference = <span style="color: navy">(</span>'urn:uuid:' + %organization.id<span style="color: navy">)</span><b> then </b>ClinicalDocumentOrganization<span style="color: navy">(</span><span style="color: maroon">srcOrg</span><span style="color: navy">, </span><span style="color: maroon">organization</span><span style="color: navy">)</span> <i>&quot;organization&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span> <i>&quot;org&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span><span style="color: navy">;</span> <span style="color: navy">// </span><span style="color: green">place names are usually stored with no parts</span>
<span style="color: navy">}

</span><span style="color: navy">// </span><span style="color: green">_________________________ Template Type not specified  ___________________</span>
<b>group </b>NarrativeLink<span style="color: navy">(</span><b>source</b> <span style="color: maroon">url</span>, <b>target</b> <span style="color: maroon">ext</span><span style="color: navy"> : </span>Extension<span style="color: navy">)</span><span style="color: navy"> {
</span>  url<span style="color: navy"><b> -&gt; </b></span>ext.url = <span style="color: blue">'http://hl7.org/fhir/StructureDefinition/narrativeLink'</span> <i>&quot;url&quot;</i><span style="color: navy">;</span>
  url<span style="color: navy"><b> -&gt; </b></span> ext.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'url'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">value</span><span style="color: navy">, </span> value.value = <span style="color: maroon">url</span> <i>&quot;value&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span></pre></div>
  </text>
  <url
       value="https://interop.esante.gouv.fr/ig/fhir/mappingcdafhir/StructureMap/CdaToBundle"/>
  <version value="0.1.0"/>
  <name value="CdaToBundle"/>
  <title
         value="Mapping de CDA vers FHIR Bundle (A partir des sources de Oliver Egger)"/>
  <status value="draft"/>
  <date value="2025-11-07T10:30:30+00:00"/>
  <publisher
             value="Agence du Numérique en Santé (ANS) - 2-10 Rue d'Oradour-sur-Glane, 75015 Paris"/>
  <contact>
    <name
          value="Agence du Numérique en Santé (ANS) - 2-10 Rue d'Oradour-sur-Glane, 75015 Paris"/>
    <telecom>
      <system value="url"/>
      <value value="https://esante.gouv.fr"/>
    </telecom>
  </contact>
  <description
               value="Mapping de CDA vers FHIR Bundle (A partir des sources de Oliver Egger)"/>
  <jurisdiction>
    <coding>
      <system value="urn:iso:std:iso:3166"/>
      <code value="FR"/>
      <display value="FRANCE"/>
    </coding>
  </jurisdiction>
  <structure>
    <url
         value="http://hl7.org/cda/stds/core/StructureDefinition/ClinicalDocument"/>
    <mode value="source"/>
    <alias value="ClinicalDocument"/>
  </structure>
  <structure>
    <url
         value="http://hl7.org/cda/stds/core/StructureDefinition/AssignedAuthor"/>
    <mode value="source"/>
    <alias value="AssignedAuthor"/>
  </structure>
  <structure>
    <url
         value="http://hl7.org/cda/stds/core/StructureDefinition/AssignedEntity"/>
    <mode value="source"/>
    <alias value="AssignedEntity"/>
  </structure>
  <structure>
    <url
         value="http://hl7.org/cda/stds/core/StructureDefinition/CustodianOrganization"/>
    <mode value="source"/>
    <alias value="CustodianOrganization"/>
  </structure>
  <structure>
    <url value="http://hl7.org/cda/stds/core/StructureDefinition/Section"/>
    <mode value="source"/>
    <alias value="Section"/>
  </structure>
  <structure>
    <url
         value="http://hl7.org/cda/stds/core/StructureDefinition/PatientRole"/>
    <mode value="source"/>
    <alias value="PatientRole"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Bundle"/>
    <mode value="target"/>
    <alias value="Bundle"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Composition"/>
    <mode value="target"/>
    <alias value="Composition"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Patient"/>
    <mode value="target"/>
    <alias value="Patient"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Person"/>
    <mode value="target"/>
    <alias value="Person"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Practitioner"/>
    <mode value="target"/>
    <alias value="Practitioner"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Organization"/>
    <mode value="target"/>
    <alias value="Organization"/>
  </structure>
  <import
          value="https://interop.esante.gouv.fr/ig/fhir/mappingcdafhir/StructureMap/CdaToFHIRTypes"/>
  <group>
    <name value="CdaToBundle"/>
    <typeMode value="none"/>
    <documentation
                   value="_________________________ Document Level Template  _________________________"/>
    <input>
      <name value="cda"/>
      <type value="ClinicalDocument"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="ClinicalDocumentToBody"/>
      <source>
        <context value="cda"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="composition"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Composition"/>
        </parameter>
      </target>
      <target>
        <context value="composition"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid"/>
        </parameter>
      </target>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e2"/>
      </target>
      <target>
        <context value="e2"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="patient"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Patient"/>
        </parameter>
      </target>
      <target>
        <context value="patient"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid2"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e2"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid2"/>
        </parameter>
      </target>
      <rule>
        <name value="cdatobundle"/>
        <source>
          <context value="cda"/>
        </source>
        <dependent>
          <name value="ClinicalDocumentToBundle"/>
          <variable value="cda"/>
          <variable value="patient"/>
          <variable value="composition"/>
          <variable value="bundle"/>
        </dependent>
      </rule>
    </rule>
  </group>
  <group>
    <name value="ClinicalDocumentToBundle"/>
    <typeMode value="none"/>
    <input>
      <name value="cda"/>
      <type value="ClinicalDocument"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="composition"/>
      <type value="Composition"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="id"/>
      <source>
        <context value="cda"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="id"/>
        <transform value="uuid"/>
      </target>
    </rule>
    <rule>
      <name value="identifier"/>
      <source>
        <context value="cda"/>
        <element value="id"/>
        <variable value="cdaId"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="identifier"/>
      </target>
      <rule>
        <name value="system"/>
        <source>
          <context value="cdaId"/>
          <element value="root"/>
          <variable value="root"/>
          <condition value="cdaId.extension.exists()"/>
        </source>
        <target>
          <context value="identifier"/>
          <contextType value="variable"/>
          <element value="system"/>
          <transform value="translate"/>
          <parameter>
            <valueId value="root"/>
          </parameter>
          <parameter>
            <valueString value="#oid2uri"/>
          </parameter>
          <parameter>
            <valueString value="uri"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="value"/>
        <source>
          <context value="cdaId"/>
          <element value="extension"/>
          <variable value="extension"/>
        </source>
        <target>
          <context value="identifier"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="extension"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="systemOid"/>
        <source>
          <context value="cdaId"/>
          <element value="root"/>
          <variable value="root"/>
          <condition value="cdaId.extension.empty()"/>
        </source>
        <target>
          <context value="identifier"/>
          <contextType value="variable"/>
          <element value="system"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="urn:ietf:rfc:3986"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="valueOid"/>
        <source>
          <context value="cdaId"/>
          <element value="root"/>
          <variable value="root"/>
          <condition value="cdaId.extension.empty()"/>
        </source>
        <target>
          <context value="identifier"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="append"/>
          <parameter>
            <valueString value="urn:oid:"/>
          </parameter>
          <parameter>
            <valueId value="root"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="type"/>
      <source>
        <context value="cda"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="type"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="document"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="timestamp"/>
      <source>
        <context value="cda"/>
        <element value="effectiveTime"/>
        <variable value="effectiveTime"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="timestamp"/>
        <variable value="timestamp"/>
        <transform value="create"/>
        <parameter>
          <valueString value="instant"/>
        </parameter>
      </target>
      <dependent>
        <name value="TSInstant"/>
        <variable value="effectiveTime"/>
        <variable value="timestamp"/>
      </dependent>
    </rule>
    <rule>
      <name value="composition"/>
      <source>
        <context value="cda"/>
      </source>
      <dependent>
        <name value="ClinicalDocumentComposition"/>
        <variable value="cda"/>
        <variable value="composition"/>
        <variable value="patient"/>
        <variable value="bundle"/>
      </dependent>
    </rule>
    <rule>
      <name value="cdaComponent"/>
      <source>
        <context value="cda"/>
        <element value="component"/>
        <variable value="cdaComponent"/>
      </source>
      <rule>
        <name value="body"/>
        <source>
          <context value="cdaComponent"/>
          <element value="structuredBody"/>
          <variable value="body"/>
        </source>
        <rule>
          <name value="bodyComponent"/>
          <source>
            <context value="body"/>
            <element value="component"/>
            <variable value="bodyComponent"/>
          </source>
          <rule>
            <name value="section"/>
            <source>
              <context value="bodyComponent"/>
              <element value="section"/>
              <variable value="srcSection"/>
              <condition value="$this.code.empty()"/>
            </source>
            <target>
              <context value="composition"/>
              <contextType value="variable"/>
              <element value="section"/>
              <variable value="tgtSection"/>
            </target>
            <dependent>
              <name value="ClinicalDocumentSection"/>
              <variable value="cda"/>
              <variable value="srcSection"/>
              <variable value="patient"/>
              <variable value="tgtSection"/>
              <variable value="bundle"/>
            </dependent>
          </rule>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="ClinicalDocumentSection"/>
    <typeMode value="none"/>
    <documentation
                   value="// _________________________ Section Level Templates _________________________"/>
    <input>
      <name value="cda"/>
      <type value="ClinicalDocument"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="src"/>
      <type value="Section"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="title"/>
      <source>
        <context value="src"/>
        <element value="title"/>
        <variable value="t"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="title"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="t.xmlText"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="code"/>
      <source>
        <context value="src"/>
        <element value="code"/>
        <variable value="srcCode"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="code"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="srcCode"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="cdaText"/>
      <source>
        <context value="src"/>
        <element value="text"/>
        <variable value="cdaText"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="text"/>
        <variable value="fhirText"/>
      </target>
      <rule>
        <name value="narrativeStatus"/>
        <source>
          <context value="cdaText"/>
        </source>
        <target>
          <context value="fhirText"/>
          <contextType value="variable"/>
          <element value="status"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="generated"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="narrativeText"/>
        <source>
          <context value="cdaText"/>
          <variable value="t"/>
        </source>
        <target>
          <context value="fhirText"/>
          <contextType value="variable"/>
          <element value="div"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="t"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="section"/>
      <source>
        <context value="src"/>
        <element value="section"/>
        <variable value="srcSection"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="section"/>
        <variable value="tgtSection"/>
      </target>
      <dependent>
        <name value="ClinicalDocumentSection"/>
        <variable value="cda"/>
        <variable value="srcSection"/>
        <variable value="patient"/>
        <variable value="tgtSection"/>
        <variable value="bundle"/>
      </dependent>
    </rule>
  </group>
  <group>
    <name value="ClinicalDocumentComposition"/>
    <typeMode value="none"/>
    <documentation
                   value="_________________________ Entry Level Templates   ________________________
_________________________ Header Level Templates _________________________"/>
    <input>
      <name value="src"/>
      <type value="ClinicalDocument"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="Composition"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="patientResource"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="languageCode"/>
      <source>
        <context value="src"/>
        <element value="languageCode"/>
        <variable value="languageCode"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="language"/>
        <variable value="code"/>
        <transform value="create"/>
        <parameter>
          <valueString value="code"/>
        </parameter>
      </target>
      <dependent>
        <name value="CSCode"/>
        <variable value="languageCode"/>
        <variable value="code"/>
      </dependent>
    </rule>
    <rule>
      <name value="identifier"/>
      <source>
        <context value="src"/>
        <element value="id"/>
        <variable value="id"/>
        <condition value="src.setId.exists().not()"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="identifier"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Identifier"/>
        </parameter>
      </target>
      <dependent>
        <name value="II"/>
        <variable value="id"/>
        <variable value="identifier"/>
      </dependent>
    </rule>
    <rule>
      <name value="setIdentifier"/>
      <source>
        <context value="src"/>
        <element value="setId"/>
        <variable value="setId"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="identifier"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Identifier"/>
        </parameter>
      </target>
      <dependent>
        <name value="II"/>
        <variable value="setId"/>
        <variable value="identifier"/>
      </dependent>
    </rule>
    <rule>
      <name value="status"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="final"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="code"/>
      <source>
        <context value="src"/>
        <element value="code"/>
        <variable value="srcCode"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="type"/>
        <variable value="cc"/>
        <transform value="create"/>
        <parameter>
          <valueString value="CodeableConcept"/>
        </parameter>
      </target>
      <dependent>
        <name value="CDCodeableConcept"/>
        <variable value="srcCode"/>
        <variable value="cc"/>
      </dependent>
    </rule>
    <rule>
      <name value="title"/>
      <source>
        <context value="src"/>
        <element value="title"/>
        <variable value="t"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="title"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="t.xmlText"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="patientRole"/>
      <source>
        <context value="src"/>
        <element value="recordTarget"/>
        <variable value="recordTarget"/>
      </source>
      <rule>
        <name value="subject"/>
        <source>
          <context value="recordTarget"/>
          <element value="patientRole"/>
          <variable value="patient"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="subject"/>
          <variable value="reference"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Reference"/>
          </parameter>
        </target>
        <target>
          <context value="reference"/>
          <contextType value="variable"/>
          <element value="reference"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="'urn:uuid:' + %patientResource.id"/>
          </parameter>
        </target>
        <dependent>
          <name value="ClinicalDocumentPatientRole"/>
          <variable value="patient"/>
          <variable value="patientResource"/>
          <variable value="bundle"/>
        </dependent>
      </rule>
    </rule>
    <rule>
      <name value="encompassingEncounter"/>
      <source>
        <context value="src"/>
        <element value="componentOf"/>
        <variable value="comp"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="encounter"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Encounter"/>
        </parameter>
      </target>
      <target>
        <context value="encounter"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid"/>
        </parameter>
      </target>
      <rule>
        <name value="srcEncounter"/>
        <source>
          <context value="comp"/>
          <element value="encompassingEncounter"/>
          <variable value="srcEnc"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="encounter"/>
          <variable value="reference"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Reference"/>
          </parameter>
        </target>
        <target>
          <context value="reference"/>
          <contextType value="variable"/>
          <element value="reference"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="'urn:uuid:' + %encounter.id"/>
          </parameter>
        </target>
        <dependent>
          <name value="ClinicalDocumentEncounter"/>
          <variable value="srcEnc"/>
          <variable value="bundle"/>
          <variable value="encounter"/>
        </dependent>
      </rule>
    </rule>
    <rule>
      <name value="compositionDate"/>
      <source>
        <context value="src"/>
        <element value="effectiveTime"/>
        <variable value="effectiveTime"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="date"/>
        <variable value="date"/>
        <transform value="create"/>
        <parameter>
          <valueString value="dateTime"/>
        </parameter>
      </target>
      <dependent>
        <name value="TSDateTime"/>
        <variable value="effectiveTime"/>
        <variable value="date"/>
      </dependent>
    </rule>
    <rule>
      <name value="srcAuthor"/>
      <source>
        <context value="src"/>
        <element value="author"/>
        <variable value="srcAuthor"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="practitioner"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Practitioner"/>
        </parameter>
      </target>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid2"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid2"/>
        </parameter>
      </target>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="eRole"/>
      </target>
      <target>
        <context value="eRole"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="practitionerRole"/>
        <transform value="create"/>
        <parameter>
          <valueString value="PractitionerRole"/>
        </parameter>
      </target>
      <target>
        <context value="practitionerRole"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuidRole"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="eRole"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuidRole"/>
        </parameter>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="author"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="'urn:uuid:' + %practitionerRole.id"/>
        </parameter>
      </target>
      <rule>
        <name value="practitionerMeta"/>
        <source>
          <context value="srcAuthor"/>
        </source>
        <target>
          <context value="practitioner"/>
          <contextType value="variable"/>
          <element value="meta"/>
          <variable value="meta"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Meta"/>
          </parameter>
        </target>
        <rule>
          <name value="practitionerProfile"/>
          <source>
            <context value="srcAuthor"/>
          </source>
          <target>
            <context value="meta"/>
            <contextType value="variable"/>
            <element value="profile"/>
            <transform value="copy"/>
            <parameter>
              <valueString
                           value="https://interop.esante.gouv.fr/ig/fhir/annuaire/StructureDefinition/as-practitioner"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="practitionerRoleMeta"/>
        <source>
          <context value="srcAuthor"/>
        </source>
        <target>
          <context value="practitionerRole"/>
          <contextType value="variable"/>
          <element value="meta"/>
          <variable value="metaRole"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Meta"/>
          </parameter>
        </target>
        <rule>
          <name value="practitionerRoleProfile"/>
          <source>
            <context value="srcAuthor"/>
          </source>
          <target>
            <context value="metaRole"/>
            <contextType value="variable"/>
            <element value="profile"/>
            <transform value="copy"/>
            <parameter>
              <valueString
                           value="https://interop.esante.gouv.fr/ig/fhir/annuaire/StructureDefinition/as-practitionerrole"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="practitionerRef"/>
        <source>
          <context value="srcAuthor"/>
        </source>
        <target>
          <context value="practitionerRole"/>
          <contextType value="variable"/>
          <element value="practitioner"/>
          <variable value="refPract"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Reference"/>
          </parameter>
        </target>
        <target>
          <context value="refPract"/>
          <contextType value="variable"/>
          <element value="reference"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="'urn:uuid:' + %practitioner.id"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="author"/>
        <source>
          <context value="srcAuthor"/>
          <element value="assignedAuthor"/>
          <variable value="assignedAuthor"/>
        </source>
        <rule>
          <name value="identifier"/>
          <source>
            <context value="assignedAuthor"/>
            <element value="id"/>
            <variable value="id"/>
          </source>
          <target>
            <context value="practitioner"/>
            <contextType value="variable"/>
            <element value="identifier"/>
            <variable value="identifier"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Identifier"/>
            </parameter>
          </target>
          <rule>
            <name value="baseIdentifier"/>
            <source>
              <context value="id"/>
            </source>
            <target>
              <context value="identifier"/>
              <contextType value="variable"/>
            </target>
            <dependent>
              <name value="II"/>
              <variable value="id"/>
              <variable value="identifier"/>
            </dependent>
          </rule>
          <rule>
            <name value="idNatPs"/>
            <source>
              <context value="id"/>
              <condition value="root = '1.2.250.1.71.4.2.1'"/>
            </source>
            <target>
              <context value="identifier"/>
              <contextType value="variable"/>
              <element value="type"/>
              <variable value="type"/>
              <transform value="create"/>
              <parameter>
                <valueString value="CodeableConcept"/>
              </parameter>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="id"/>
              </source>
              <target>
                <context value="type"/>
                <contextType value="variable"/>
                <element value="coding"/>
                <variable value="coding"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Coding"/>
                </parameter>
              </target>
              <rule>
                <name value="system"/>
                <source>
                  <context value="id"/>
                </source>
                <target>
                  <context value="coding"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="https://hl7.fr/ig/fhir/core/CodeSystem/fr-core-cs-v2-0203"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="code"/>
                <source>
                  <context value="id"/>
                </source>
                <target>
                  <context value="coding"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="IDNPS"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="addr"/>
          <source>
            <context value="assignedAuthor"/>
            <element value="addr"/>
            <variable value="addr"/>
          </source>
          <target>
            <context value="practitioner"/>
            <contextType value="variable"/>
            <element value="address"/>
            <variable value="address"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Address"/>
            </parameter>
          </target>
          <dependent>
            <name value="ADAddress"/>
            <variable value="addr"/>
            <variable value="address"/>
          </dependent>
        </rule>
        <rule>
          <name value="telecom"/>
          <source>
            <context value="assignedAuthor"/>
            <element value="telecom"/>
            <variable value="tlc"/>
          </source>
          <target>
            <context value="practitioner"/>
            <contextType value="variable"/>
            <element value="telecom"/>
            <variable value="contactPoint"/>
            <transform value="create"/>
            <parameter>
              <valueString value="ContactPoint"/>
            </parameter>
          </target>
          <dependent>
            <name value="TELContactPoint"/>
            <variable value="tlc"/>
            <variable value="contactPoint"/>
          </dependent>
        </rule>
        <rule>
          <name value="name"/>
          <source>
            <context value="assignedAuthor"/>
            <element value="assignedPerson"/>
            <variable value="assPerson"/>
          </source>
          <rule>
            <name value="name"/>
            <source>
              <context value="assPerson"/>
              <element value="name"/>
              <variable value="pName"/>
            </source>
            <target>
              <context value="practitioner"/>
              <contextType value="variable"/>
              <element value="name"/>
              <variable value="humanName"/>
              <transform value="create"/>
              <parameter>
                <valueString value="HumanName"/>
              </parameter>
            </target>
            <dependent>
              <name value="ENHumanName"/>
              <variable value="pName"/>
              <variable value="humanName"/>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="roleCode"/>
          <source>
            <context value="assignedAuthor"/>
            <element value="code"/>
            <variable value="roleCode"/>
          </source>
          <target>
            <context value="practitionerRole"/>
            <contextType value="variable"/>
            <element value="code"/>
            <variable value="cc"/>
            <transform value="create"/>
            <parameter>
              <valueString value="CodeableConcept"/>
            </parameter>
          </target>
          <dependent>
            <name value="CDCodeableConcept"/>
            <variable value="roleCode"/>
            <variable value="cc"/>
          </dependent>
        </rule>
        <rule>
          <name value="savoirFaire"/>
          <source>
            <context value="assignedAuthor"/>
            <element value="code"/>
            <variable value="roleCode"/>
            <condition value="code.contains('/')"/>
          </source>
          <target>
            <context value="practitioner"/>
            <contextType value="variable"/>
            <element value="qualification"/>
            <variable value="qualification"/>
          </target>
          <rule>
            <name value="qualCode"/>
            <source>
              <context value="roleCode"/>
            </source>
            <target>
              <context value="qualification"/>
              <contextType value="variable"/>
              <element value="code"/>
              <variable value="qualCode"/>
              <transform value="create"/>
              <parameter>
                <valueString value="CodeableConcept"/>
              </parameter>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="roleCode"/>
                <element value="code"/>
                <variable value="fullCode"/>
              </source>
              <target>
                <context value="qualCode"/>
                <contextType value="variable"/>
                <element value="coding"/>
                <variable value="coding"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Coding"/>
                </parameter>
              </target>
              <rule>
                <name value="savoirFaireCode"/>
                <source>
                  <context value="fullCode"/>
                </source>
                <target>
                  <context value="coding"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString
                                 value="%fullCode.substring(%fullCode.indexOf('/') + 1)"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="systemSavoirFaire"/>
                <source>
                  <context value="fullCode"/>
                </source>
                <target>
                  <context value="coding"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="https://mos.esante.gouv.fr/NOS/TRE_R38-SpecialiteOrdinale/FHIR/TRE-R38-SpecialiteOrdinale"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="display"/>
                <source>
                  <context value="roleCode"/>
                  <element value="displayName"/>
                  <variable value="display"/>
                </source>
                <target>
                  <context value="coding"/>
                  <contextType value="variable"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueId value="display"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="profession"/>
          <source>
            <context value="assignedAuthor"/>
            <element value="code"/>
            <variable value="roleCode"/>
            <condition value="code.contains('/') and code.contains('_')"/>
          </source>
          <target>
            <context value="practitioner"/>
            <contextType value="variable"/>
            <element value="qualification"/>
            <variable value="qualification"/>
          </target>
          <rule>
            <name value="qualCode"/>
            <source>
              <context value="roleCode"/>
            </source>
            <target>
              <context value="qualification"/>
              <contextType value="variable"/>
              <element value="code"/>
              <variable value="qualCode"/>
              <transform value="create"/>
              <parameter>
                <valueString value="CodeableConcept"/>
              </parameter>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="roleCode"/>
                <element value="code"/>
                <variable value="fullCode"/>
              </source>
              <target>
                <context value="qualCode"/>
                <contextType value="variable"/>
                <element value="coding"/>
                <variable value="coding"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Coding"/>
                </parameter>
              </target>
              <rule>
                <name value="professionCode"/>
                <source>
                  <context value="fullCode"/>
                </source>
                <target>
                  <context value="coding"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString
                                 value="%fullCode.substring(%fullCode.indexOf('_') + 1).substring(0, %fullCode.substring(%fullCode.indexOf('_') + 1).indexOf('/'))"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="systemProfession"/>
                <source>
                  <context value="fullCode"/>
                </source>
                <target>
                  <context value="coding"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="https://mos.esante.gouv.fr/NOS/TRE_G15-ProfessionSante/FHIR/TRE-G15-ProfessionSante"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="displayMedecin"/>
                <source>
                  <context value="fullCode"/>
                  <condition
                             value="%fullCode.substring(%fullCode.indexOf('_') + 1).substring(0, %fullCode.substring(%fullCode.indexOf('_') + 1).indexOf('/')) = '10'"/>
                </source>
                <target>
                  <context value="coding"/>
                  <contextType value="variable"/>
                  <element value="display"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Médecin"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="representedOrganization"/>
          <source>
            <context value="assignedAuthor"/>
            <element value="representedOrganization"/>
            <variable value="srcOrg"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e2"/>
          </target>
          <target>
            <context value="e2"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="organization"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Organization"/>
            </parameter>
          </target>
          <target>
            <context value="organization"/>
            <contextType value="variable"/>
            <element value="id"/>
            <variable value="uuid3"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="e2"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="append"/>
            <parameter>
              <valueString value="urn:uuid:"/>
            </parameter>
            <parameter>
              <valueId value="uuid3"/>
            </parameter>
          </target>
          <target>
            <context value="practitionerRole"/>
            <contextType value="variable"/>
            <element value="organization"/>
            <variable value="refOrg"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Reference"/>
            </parameter>
          </target>
          <target>
            <context value="refOrg"/>
            <contextType value="variable"/>
            <element value="reference"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="'urn:uuid:' + %organization.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="ClinicalDocumentOrganization"/>
            <variable value="srcOrg"/>
            <variable value="organization"/>
          </dependent>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="informant"/>
      <source>
        <context value="src"/>
        <element value="informant"/>
        <variable value="srcInformant"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="relatedPerson"/>
        <transform value="create"/>
        <parameter>
          <valueString value="RelatedPerson"/>
        </parameter>
      </target>
      <target>
        <context value="relatedPerson"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuidRelated"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuidRelated"/>
        </parameter>
      </target>
      <rule>
        <name value="relatedEntity"/>
        <source>
          <context value="srcInformant"/>
          <element value="relatedEntity"/>
          <variable value="relatedEntity"/>
        </source>
        <rule>
          <name value="patientRef"/>
          <source>
            <context value="relatedEntity"/>
          </source>
          <target>
            <context value="relatedPerson"/>
            <contextType value="variable"/>
            <element value="patient"/>
            <variable value="patientRef"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Reference"/>
            </parameter>
          </target>
          <target>
            <context value="patientRef"/>
            <contextType value="variable"/>
            <element value="reference"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="'urn:uuid:' + %patientResource.id"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="relationship"/>
          <source>
            <context value="relatedEntity"/>
            <element value="code"/>
            <variable value="relationCode"/>
          </source>
          <target>
            <context value="relatedPerson"/>
            <contextType value="variable"/>
            <element value="relationship"/>
            <variable value="cc"/>
            <transform value="create"/>
            <parameter>
              <valueString value="CodeableConcept"/>
            </parameter>
          </target>
          <dependent>
            <name value="CDCodeableConcept"/>
            <variable value="relationCode"/>
            <variable value="cc"/>
          </dependent>
        </rule>
        <rule>
          <name value="address"/>
          <source>
            <context value="relatedEntity"/>
            <element value="addr"/>
            <variable value="addr"/>
          </source>
          <target>
            <context value="relatedPerson"/>
            <contextType value="variable"/>
            <element value="address"/>
            <variable value="address"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Address"/>
            </parameter>
          </target>
          <dependent>
            <name value="ADAddress"/>
            <variable value="addr"/>
            <variable value="address"/>
          </dependent>
        </rule>
        <rule>
          <name value="telecom"/>
          <source>
            <context value="relatedEntity"/>
            <element value="telecom"/>
            <variable value="tlc"/>
          </source>
          <target>
            <context value="relatedPerson"/>
            <contextType value="variable"/>
            <element value="telecom"/>
            <variable value="contactPoint"/>
            <transform value="create"/>
            <parameter>
              <valueString value="ContactPoint"/>
            </parameter>
          </target>
          <dependent>
            <name value="TELContactPoint"/>
            <variable value="tlc"/>
            <variable value="contactPoint"/>
          </dependent>
        </rule>
        <rule>
          <name value="relatedPersonName"/>
          <source>
            <context value="relatedEntity"/>
            <element value="relatedPerson"/>
            <variable value="relPerson"/>
          </source>
          <rule>
            <name value="name"/>
            <source>
              <context value="relPerson"/>
              <element value="name"/>
              <variable value="pName"/>
            </source>
            <target>
              <context value="relatedPerson"/>
              <contextType value="variable"/>
              <element value="name"/>
              <variable value="humanName"/>
              <transform value="create"/>
              <parameter>
                <valueString value="HumanName"/>
              </parameter>
            </target>
            <dependent>
              <name value="ENHumanName"/>
              <variable value="pName"/>
              <variable value="humanName"/>
            </dependent>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="confidentialityCode"/>
      <source>
        <context value="src"/>
        <element value="confidentialityCode"/>
        <variable value="confCode"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="confidentiality"/>
        <variable value="code"/>
        <transform value="create"/>
        <parameter>
          <valueString value="code"/>
        </parameter>
      </target>
      <dependent>
        <name value="CSCode"/>
        <variable value="confCode"/>
        <variable value="code"/>
      </dependent>
    </rule>
    <rule>
      <name value="legalAuth"/>
      <source>
        <context value="src"/>
        <element value="legalAuthenticator"/>
        <variable value="legalAuth"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="practitioner"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Practitioner"/>
        </parameter>
      </target>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid2"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid2"/>
        </parameter>
      </target>
      <rule>
        <name value="attester"/>
        <source>
          <context value="legalAuth"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="attester"/>
          <variable value="attester"/>
        </target>
        <rule>
          <name value="mode"/>
          <source>
            <context value="legalAuth"/>
          </source>
          <target>
            <context value="attester"/>
            <contextType value="variable"/>
            <element value="mode"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="legal"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="time"/>
          <source>
            <context value="legalAuth"/>
            <element value="time"/>
            <variable value="time"/>
          </source>
          <target>
            <context value="attester"/>
            <contextType value="variable"/>
            <element value="time"/>
            <variable value="dt"/>
            <transform value="create"/>
            <parameter>
              <valueString value="dateTime"/>
            </parameter>
          </target>
          <dependent>
            <name value="TSDateTime"/>
            <variable value="time"/>
            <variable value="dt"/>
          </dependent>
        </rule>
        <rule>
          <name value="entity"/>
          <source>
            <context value="legalAuth"/>
            <element value="assignedEntity"/>
            <variable value="entity"/>
          </source>
          <target>
            <context value="attester"/>
            <contextType value="variable"/>
            <element value="party"/>
            <variable value="reference"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Reference"/>
            </parameter>
          </target>
          <target>
            <context value="reference"/>
            <contextType value="variable"/>
            <element value="reference"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="'urn:uuid:' + %practitioner.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="ClinicalDocumentEntityPractitioner"/>
            <variable value="entity"/>
            <variable value="practitioner"/>
          </dependent>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="auth"/>
      <source>
        <context value="src"/>
        <element value="authenticator"/>
        <variable value="auth"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="practitioner"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Practitioner"/>
        </parameter>
      </target>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid2"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid2"/>
        </parameter>
      </target>
      <rule>
        <name value="attester"/>
        <source>
          <context value="auth"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="attester"/>
          <variable value="attester"/>
        </target>
        <rule>
          <name value="mode"/>
          <source>
            <context value="auth"/>
          </source>
          <target>
            <context value="attester"/>
            <contextType value="variable"/>
            <element value="mode"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="official"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="time"/>
          <source>
            <context value="auth"/>
            <element value="time"/>
            <variable value="time"/>
          </source>
          <target>
            <context value="attester"/>
            <contextType value="variable"/>
            <element value="time"/>
            <variable value="dt"/>
            <transform value="create"/>
            <parameter>
              <valueString value="dateTime"/>
            </parameter>
          </target>
          <dependent>
            <name value="TSDateTime"/>
            <variable value="time"/>
            <variable value="dt"/>
          </dependent>
        </rule>
        <rule>
          <name value="entity"/>
          <source>
            <context value="auth"/>
            <element value="assignedEntity"/>
            <variable value="entity"/>
          </source>
          <target>
            <context value="attester"/>
            <contextType value="variable"/>
            <element value="party"/>
            <variable value="reference"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Reference"/>
            </parameter>
          </target>
          <target>
            <context value="reference"/>
            <contextType value="variable"/>
            <element value="reference"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="'urn:uuid:' + %practitioner.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="ClinicalDocumentEntityPractitioner"/>
            <variable value="entity"/>
            <variable value="practitioner"/>
          </dependent>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="cust"/>
      <source>
        <context value="src"/>
        <element value="custodian"/>
        <variable value="custodian"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e"/>
      </target>
      <rule>
        <name value="custodian"/>
        <source>
          <context value="custodian"/>
          <element value="assignedCustodian"/>
          <variable value="assignedCustodian"/>
        </source>
        <target>
          <context value="e"/>
          <contextType value="variable"/>
          <element value="resource"/>
          <variable value="organization"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Organization"/>
          </parameter>
        </target>
        <target>
          <context value="organization"/>
          <contextType value="variable"/>
          <element value="id"/>
          <variable value="uuid3"/>
          <transform value="uuid"/>
        </target>
        <target>
          <context value="e"/>
          <contextType value="variable"/>
          <element value="fullUrl"/>
          <transform value="append"/>
          <parameter>
            <valueString value="urn:uuid:"/>
          </parameter>
          <parameter>
            <valueId value="uuid3"/>
          </parameter>
        </target>
        <rule>
          <name value="assignedCustodian"/>
          <source>
            <context value="assignedCustodian"/>
            <element value="representedCustodianOrganization"/>
            <variable value="srcOrg"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="custodian"/>
            <variable value="reference"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Reference"/>
            </parameter>
          </target>
          <target>
            <context value="reference"/>
            <contextType value="variable"/>
            <element value="reference"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="'urn:uuid:' + %organization.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="ClinicalDocumentOrganization"/>
            <variable value="srcOrg"/>
            <variable value="organization"/>
          </dependent>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="documentationOf"/>
      <source>
        <context value="src"/>
        <element value="documentationOf"/>
        <variable value="docOf"/>
      </source>
      <rule>
        <name value="docOf"/>
        <source>
          <context value="docOf"/>
          <element value="serviceEvent"/>
          <variable value="serviceEvent"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="event"/>
          <variable value="event"/>
        </target>
        <rule>
          <name value="eventCode"/>
          <source>
            <context value="serviceEvent"/>
            <element value="code"/>
            <variable value="eventCode"/>
          </source>
          <target>
            <context value="event"/>
            <contextType value="variable"/>
            <element value="code"/>
            <variable value="cc"/>
            <transform value="create"/>
            <parameter>
              <valueString value="CodeableConcept"/>
            </parameter>
          </target>
          <dependent>
            <name value="CDCodeableConcept"/>
            <variable value="eventCode"/>
            <variable value="cc"/>
          </dependent>
        </rule>
        <rule>
          <name value="eventTime"/>
          <source>
            <context value="serviceEvent"/>
            <element value="effectiveTime"/>
            <variable value="effectivetime"/>
          </source>
          <target>
            <context value="event"/>
            <contextType value="variable"/>
            <element value="period"/>
            <variable value="period"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Period"/>
            </parameter>
          </target>
          <dependent>
            <name value="IVLTSPeriod"/>
            <variable value="effectivetime"/>
            <variable value="period"/>
          </dependent>
          <documentation
                         value="performerType: for src.performer.typeCode ..."/>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="relatedDoc"/>
      <source>
        <context value="src"/>
        <element value="relatedDocument"/>
        <variable value="relatedDoc"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="relatesTo"/>
        <variable value="relates"/>
      </target>
      <rule>
        <name value="typeCode"/>
        <source>
          <context value="relatedDoc"/>
          <element value="typeCode"/>
          <variable value="typeCode"/>
        </source>
        <target>
          <context value="relates"/>
          <contextType value="variable"/>
          <element value="code"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="typeCode"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="parentDoc"/>
        <source>
          <context value="relatedDoc"/>
          <element value="parentDocument"/>
          <variable value="parentDoc"/>
        </source>
        <rule>
          <name value="setId"/>
          <source>
            <context value="parentDoc"/>
            <element value="setId"/>
            <variable value="sid"/>
          </source>
          <target>
            <context value="relates"/>
            <contextType value="variable"/>
            <element value="targetIdentifier"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="sid"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="ClinicalDocumentEntityPractitioner"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="AssignedEntity"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="Practitioner"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="meta"/>
      <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>
      <rule>
        <name value="profile"/>
        <source>
          <context value="src"/>
        </source>
        <target>
          <context value="meta"/>
          <contextType value="variable"/>
          <element value="profile"/>
          <transform value="copy"/>
          <parameter>
            <valueString
                         value="https://interop.esante.gouv.fr/ig/fhir/annuaire/StructureDefinition/as-practitioner"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="identifier"/>
      <source>
        <context value="src"/>
        <element value="id"/>
        <variable value="srcId"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="identifier"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Identifier"/>
        </parameter>
      </target>
      <rule>
        <name value="baseIdentifier"/>
        <source>
          <context value="srcId"/>
        </source>
        <target>
          <context value="identifier"/>
          <contextType value="variable"/>
        </target>
        <dependent>
          <name value="II"/>
          <variable value="srcId"/>
          <variable value="identifier"/>
        </dependent>
      </rule>
      <rule>
        <name value="idNatPs"/>
        <source>
          <context value="srcId"/>
          <condition value="root = '1.2.250.1.71.4.2.1'"/>
        </source>
        <target>
          <context value="identifier"/>
          <contextType value="variable"/>
          <element value="type"/>
          <variable value="type"/>
          <transform value="create"/>
          <parameter>
            <valueString value="CodeableConcept"/>
          </parameter>
        </target>
        <rule>
          <name value="coding"/>
          <source>
            <context value="srcId"/>
          </source>
          <target>
            <context value="type"/>
            <contextType value="variable"/>
            <element value="coding"/>
            <variable value="coding"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Coding"/>
            </parameter>
          </target>
          <rule>
            <name value="system"/>
            <source>
              <context value="srcId"/>
            </source>
            <target>
              <context value="coding"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="https://hl7.fr/ig/fhir/core/CodeSystem/fr-core-cs-v2-0203"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="code"/>
            <source>
              <context value="srcId"/>
            </source>
            <target>
              <context value="coding"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="IDNPS"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="addr"/>
      <source>
        <context value="src"/>
        <element value="addr"/>
        <variable value="srcAddr"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Address"/>
        </parameter>
      </target>
      <dependent>
        <name value="ADAddress"/>
        <variable value="srcAddr"/>
        <variable value="address"/>
      </dependent>
    </rule>
    <rule>
      <name value="telecom"/>
      <source>
        <context value="src"/>
        <element value="telecom"/>
        <variable value="srcTelecom"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="telecom"/>
        <variable value="contactPoint"/>
        <transform value="create"/>
        <parameter>
          <valueString value="ContactPoint"/>
        </parameter>
      </target>
      <dependent>
        <name value="TELContactPoint"/>
        <variable value="srcTelecom"/>
        <variable value="contactPoint"/>
      </dependent>
    </rule>
    <rule>
      <name value="name"/>
      <source>
        <context value="src"/>
        <element value="assignedPerson"/>
        <variable value="person"/>
      </source>
      <rule>
        <name value="name"/>
        <source>
          <context value="person"/>
          <element value="name"/>
          <variable value="pName"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="name"/>
          <variable value="humanName"/>
          <transform value="create"/>
          <parameter>
            <valueString value="HumanName"/>
          </parameter>
        </target>
        <dependent>
          <name value="ENHumanName"/>
          <variable value="pName"/>
          <variable value="humanName"/>
        </dependent>
      </rule>
    </rule>
  </group>
  <group>
    <name value="ClinicalDocumentOrganization"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="CustodianOrganization"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="Organization"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="meta"/>
      <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>
      <rule>
        <name value="profile"/>
        <source>
          <context value="src"/>
        </source>
        <target>
          <context value="meta"/>
          <contextType value="variable"/>
          <element value="profile"/>
          <transform value="copy"/>
          <parameter>
            <valueString
                         value="https://interop.esante.gouv.fr/ig/fhir/annuaire/StructureDefinition/as-organization"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="id"/>
      <source>
        <context value="src"/>
        <element value="id"/>
        <variable value="srcId"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="identifier"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Identifier"/>
        </parameter>
      </target>
      <dependent>
        <name value="II"/>
        <variable value="srcId"/>
        <variable value="identifier"/>
      </dependent>
    </rule>
    <rule>
      <name value="name"/>
      <source>
        <context value="src"/>
        <element value="name"/>
        <variable value="v"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="name"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="v.other"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="telecom"/>
      <source>
        <context value="src"/>
        <element value="telecom"/>
        <variable value="srcTelecom"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="telecom"/>
        <variable value="contactPoint"/>
        <transform value="create"/>
        <parameter>
          <valueString value="ContactPoint"/>
        </parameter>
      </target>
      <dependent>
        <name value="TELContactPoint"/>
        <variable value="srcTelecom"/>
        <variable value="contactPoint"/>
      </dependent>
    </rule>
    <rule>
      <name value="addr"/>
      <source>
        <context value="src"/>
        <element value="addr"/>
        <variable value="srcAddr"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Address"/>
        </parameter>
      </target>
      <dependent>
        <name value="ADAddress"/>
        <variable value="srcAddr"/>
        <variable value="address"/>
      </dependent>
    </rule>
  </group>
  <group>
    <name value="ClinicalDocumentPatientRole"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="PatientRole"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="id"/>
      <source>
        <context value="src"/>
        <element value="id"/>
        <variable value="id"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="identifier"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Identifier"/>
        </parameter>
      </target>
      <dependent>
        <name value="setFrPatientIdentifier"/>
        <variable value="id"/>
        <variable value="identifier"/>
      </dependent>
    </rule>
    <rule>
      <name value="addr"/>
      <source>
        <context value="src"/>
        <element value="addr"/>
        <variable value="srcAddr"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="address"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Address"/>
        </parameter>
      </target>
      <dependent>
        <name value="ADAddress"/>
        <variable value="srcAddr"/>
        <variable value="address"/>
      </dependent>
    </rule>
    <rule>
      <name value="telecom"/>
      <source>
        <context value="src"/>
        <element value="telecom"/>
        <variable value="srcTelecom"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="telecom"/>
        <variable value="contactPoint"/>
        <transform value="create"/>
        <parameter>
          <valueString value="ContactPoint"/>
        </parameter>
      </target>
      <dependent>
        <name value="TELContactPoint"/>
        <variable value="srcTelecom"/>
        <variable value="contactPoint"/>
      </dependent>
    </rule>
    <rule>
      <name value="patientrole"/>
      <source>
        <context value="src"/>
        <element value="patient"/>
        <variable value="patient"/>
      </source>
      <rule>
        <name value="name"/>
        <source>
          <context value="patient"/>
          <element value="name"/>
          <variable value="patientName"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="name"/>
          <variable value="humanName"/>
          <transform value="create"/>
          <parameter>
            <valueString value="HumanName"/>
          </parameter>
        </target>
        <dependent>
          <name value="ENHumanName"/>
          <variable value="patientName"/>
          <variable value="humanName"/>
        </dependent>
      </rule>
      <rule>
        <name value="gender"/>
        <source>
          <context value="patient"/>
          <element value="administrativeGenderCode"/>
          <variable value="gender"/>
        </source>
        <rule>
          <name value="gender"/>
          <source>
            <context value="gender"/>
            <element value="code"/>
            <variable value="v"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="gender"/>
            <transform value="translate"/>
            <parameter>
              <valueId value="v"/>
            </parameter>
            <parameter>
              <valueString
                           value="https://interop.esante.gouv.fr/ig/fhir/mappingcdafhir/ConceptMap/cm-v3-administrative-gender"/>
            </parameter>
            <parameter>
              <valueString value="code"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="birthDate"/>
        <source>
          <context value="patient"/>
          <element value="birthTime"/>
          <variable value="birthTime"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="birthDate"/>
          <variable value="date"/>
          <transform value="create"/>
          <parameter>
            <valueString value="date"/>
          </parameter>
        </target>
        <dependent>
          <name value="TSDate"/>
          <variable value="birthTime"/>
          <variable value="date"/>
        </dependent>
      </rule>
      <rule>
        <name value="deceasedBL"/>
        <source>
          <context value="patient"/>
          <element value="deceasedInd"/>
          <variable value="indicator"/>
          <condition value="patient.deceasedTime.empty()"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="deceased"/>
          <variable value="bool"/>
          <transform value="create"/>
          <parameter>
            <valueString value="boolean"/>
          </parameter>
        </target>
        <dependent>
          <name value="boolean"/>
          <variable value="indicator"/>
          <variable value="bool"/>
        </dependent>
      </rule>
      <rule>
        <name value="deceasedTime"/>
        <source>
          <context value="patient"/>
          <element value="deceasedTime"/>
          <variable value="dTime"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="deceased"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="dTime"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="maritalStatus"/>
        <source>
          <context value="patient"/>
          <element value="maritalStatusCode"/>
          <variable value="mStatus"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="maritalStatus"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="mStatus"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="language"/>
        <source>
          <context value="patient"/>
          <element value="languageCommunication"/>
          <variable value="language"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="communication"/>
          <variable value="communication"/>
        </target>
        <rule>
          <name value="communication"/>
          <source>
            <context value="language"/>
            <element value="languageCode"/>
            <variable value="lCode"/>
          </source>
          <target>
            <context value="communication"/>
            <contextType value="variable"/>
            <element value="language"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="lCode"/>
            </parameter>
          </target>
          <documentation
                         value="preference: for language.preferenceInd make communication.preferred"/>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="organization"/>
      <source>
        <context value="src"/>
        <element value="providerOrganization"/>
        <variable value="org"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="organization"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Organization"/>
        </parameter>
      </target>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid3"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid3"/>
        </parameter>
      </target>
      <rule>
        <name value="reference"/>
        <source>
          <context value="org"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="managingOrganization"/>
          <variable value="reference"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Reference"/>
          </parameter>
        </target>
        <target>
          <context value="reference"/>
          <contextType value="variable"/>
          <element value="reference"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="'urn:uuid:' + %organization.id"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="id"/>
        <source>
          <context value="org"/>
          <element value="id"/>
          <variable value="orgId"/>
        </source>
        <target>
          <context value="organization"/>
          <contextType value="variable"/>
          <element value="identifier"/>
          <variable value="identifier"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Identifier"/>
          </parameter>
        </target>
        <dependent>
          <name value="II"/>
          <variable value="orgId"/>
          <variable value="identifier"/>
        </dependent>
      </rule>
      <rule>
        <name value="name"/>
        <source>
          <context value="org"/>
          <element value="name"/>
          <variable value="v"/>
        </source>
        <target>
          <context value="organization"/>
          <contextType value="variable"/>
          <element value="name"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="v.other"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="telecom"/>
        <source>
          <context value="org"/>
          <element value="telecom"/>
          <variable value="orgTel"/>
        </source>
        <target>
          <context value="organization"/>
          <contextType value="variable"/>
          <element value="telecom"/>
          <variable value="contactPoint"/>
          <transform value="create"/>
          <parameter>
            <valueString value="ContactPoint"/>
          </parameter>
        </target>
        <dependent>
          <name value="TELContactPoint"/>
          <variable value="orgTel"/>
          <variable value="contactPoint"/>
        </dependent>
      </rule>
      <rule>
        <name value="addr"/>
        <source>
          <context value="org"/>
          <element value="addr"/>
          <variable value="orgAddr"/>
        </source>
        <target>
          <context value="organization"/>
          <contextType value="variable"/>
          <element value="address"/>
          <variable value="address"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Address"/>
          </parameter>
        </target>
        <dependent>
          <name value="ADAddress"/>
          <variable value="orgAddr"/>
          <variable value="address"/>
        </dependent>
      </rule>
    </rule>
  </group>
  <group>
    <name value="setFrPatientIdentifier"/>
    <typeMode value="none"/>
    <input>
      <name value="id"/>
      <type value="II"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="identifier"/>
      <type value="Identifier"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="identifierType"/>
      <source>
        <context value="id"/>
      </source>
      <target>
        <context value="identifier"/>
        <contextType value="variable"/>
      </target>
      <target>
        <context value="identifier"/>
        <contextType value="variable"/>
        <element value="type"/>
        <variable value="type"/>
      </target>
      <target>
        <context value="type"/>
        <contextType value="variable"/>
        <element value="coding"/>
        <variable value="coding"/>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="system"/>
        <variable value="system"/>
      </target>
      <target>
        <context value="coding"/>
        <contextType value="variable"/>
        <element value="code"/>
        <variable value="code"/>
      </target>
      <rule>
        <name value="system"/>
        <source>
          <context value="id"/>
          <condition value="(id.root = '1.2.250.1.213.1.4.8')"/>
        </source>
        <target>
          <context value="system"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="copy"/>
          <parameter>
            <valueString
                         value="https://hl7.fr/ig/fhir/core/CodeSystem/fr-core-cs-v2-0203"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="code"/>
        <source>
          <context value="id"/>
          <condition value="(id.root = '1.2.250.1.213.1.4.8')"/>
        </source>
        <target>
          <context value="code"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="INS-NIR"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="system"/>
        <source>
          <context value="id"/>
          <condition value="(id.root = '1.2.3.4.5.6.7.8.9.10')"/>
        </source>
        <target>
          <context value="system"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="copy"/>
          <parameter>
            <valueString
                         value="http://terminology.hl7.org/CodeSystem/v2-0203"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="code"/>
        <source>
          <context value="id"/>
          <condition value="(id.root = '1.2.3.4.5.6.7.8.9.10')"/>
        </source>
        <target>
          <context value="code"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="PI"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="extension"/>
      <source>
        <context value="id"/>
        <element value="extension"/>
        <variable value="extension"/>
      </source>
      <target>
        <context value="identifier"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="value"/>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="extension"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="root"/>
      <source>
        <context value="id"/>
        <element value="root"/>
        <variable value="root"/>
      </source>
      <target>
        <context value="identifier"/>
        <contextType value="variable"/>
        <element value="system"/>
        <variable value="system"/>
      </target>
      <target>
        <context value="system"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:oid:"/>
        </parameter>
        <parameter>
          <valueId value="root"/>
        </parameter>
      </target>
    </rule>
  </group>
  <group>
    <name value="ClinicalDocumentEncounter"/>
    <typeMode value="none"/>
    <documentation
                   value="Fin modification NR
Etat initial
src -&gt; tgt.identifier as identifier then {
src.id as id -&gt; identifier.type as type, type.coding as coding, coding.system as system, coding.code as code then {
src -&gt; system.value = 'http://terminology.hl7.org/CodeSystem/v2-0203' &quot;system&quot;;
src -&gt; code.value = 'MR' &quot;code&quot;;
id.extension as extension -&gt; identifier.value as value, value.value = extension &quot;extension&quot;;
id.root as root -&gt; identifier.system as system, system.value = append('urn:oid:', root) &quot;root&quot;;
} &quot;id&quot;;
} &quot;identifier&quot;;
Fin état initial"/>
    <input>
      <name value="src"/>
      <type value="EncompassingEncounter"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="Encounter"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="id"/>
      <source>
        <context value="src"/>
        <element value="id"/>
        <variable value="Id"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="identifier"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Identifier"/>
        </parameter>
      </target>
      <dependent>
        <name value="II"/>
        <variable value="Id"/>
        <variable value="identifier"/>
      </dependent>
    </rule>
    <rule>
      <name value="status"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="finished"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="class"/>
      <source>
        <context value="src"/>
        <element value="code"/>
        <variable value="srcCode"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="class"/>
        <variable value="coding"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Coding"/>
        </parameter>
      </target>
      <rule>
        <name value="code"/>
        <source>
          <context value="srcCode"/>
          <element value="code"/>
          <variable value="code"/>
        </source>
        <target>
          <context value="coding"/>
          <contextType value="variable"/>
          <element value="code"/>
          <transform value="cast"/>
          <parameter>
            <valueId value="code"/>
          </parameter>
          <parameter>
            <valueString value="string"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="codeSystem"/>
        <source>
          <context value="srcCode"/>
          <element value="codeSystem"/>
          <variable value="system"/>
        </source>
        <target>
          <context value="coding"/>
          <contextType value="variable"/>
          <element value="system"/>
          <transform value="translate"/>
          <parameter>
            <valueId value="system"/>
          </parameter>
          <parameter>
            <valueString
                         value="http://hl7.org/fhir/ConceptMap/special-oid2uri"/>
          </parameter>
          <parameter>
            <valueString value="uri"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="displayName"/>
        <source>
          <context value="srcCode"/>
          <element value="displayName"/>
          <variable value="display"/>
        </source>
        <target>
          <context value="coding"/>
          <contextType value="variable"/>
          <element value="display"/>
          <transform value="cast"/>
          <parameter>
            <valueId value="display"/>
          </parameter>
          <parameter>
            <valueString value="string"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="code"/>
      <source>
        <context value="src"/>
        <element value="code"/>
        <variable value="srcCode"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="type"/>
        <variable value="cc"/>
        <transform value="create"/>
        <parameter>
          <valueString value="CodeableConcept"/>
        </parameter>
      </target>
      <dependent>
        <name value="CDCodeableConcept"/>
        <variable value="srcCode"/>
        <variable value="cc"/>
      </dependent>
    </rule>
    <rule>
      <name value="effectiveTime"/>
      <source>
        <context value="src"/>
        <element value="effectiveTime"/>
        <variable value="effTime"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="period"/>
        <variable value="period"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Period"/>
        </parameter>
      </target>
      <dependent>
        <name value="IVLTSPeriod"/>
        <variable value="effTime"/>
        <variable value="period"/>
      </dependent>
    </rule>
    <rule>
      <name value="hospitalization"/>
      <source>
        <context value="src"/>
        <condition
                   value="admissionReferralSourceCode.exists() or dischargeDispositionCode.exists()"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="hospitalization"/>
        <variable value="hosp"/>
      </target>
      <rule>
        <name value="adminReferral"/>
        <source>
          <context value="src"/>
          <element value="admissionReferralSourceCode"/>
          <variable value="admRef"/>
        </source>
        <target>
          <context value="hosp"/>
          <contextType value="variable"/>
          <element value="admitSource"/>
          <variable value="cc"/>
          <transform value="create"/>
          <parameter>
            <valueString value="CodeableConcept"/>
          </parameter>
        </target>
        <dependent>
          <name value="CDCodeableConcept"/>
          <variable value="admRef"/>
          <variable value="cc"/>
        </dependent>
      </rule>
      <rule>
        <name value="discDisposition"/>
        <source>
          <context value="src"/>
          <element value="dischargeDispositionCode"/>
          <variable value="discDispo"/>
        </source>
        <target>
          <context value="hosp"/>
          <contextType value="variable"/>
          <element value="dischargeDisposition"/>
          <variable value="cc"/>
          <transform value="create"/>
          <parameter>
            <valueString value="CodeableConcept"/>
          </parameter>
        </target>
        <dependent>
          <name value="CDCodeableConcept"/>
          <variable value="discDispo"/>
          <variable value="cc"/>
        </dependent>
      </rule>
    </rule>
    <rule>
      <name value="participant"/>
      <source>
        <context value="src"/>
        <element value="encounterParticipant"/>
        <variable value="srcPart"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="participant"/>
        <variable value="tgtPart"/>
      </target>
      <rule>
        <name value="typeCode"/>
        <source>
          <context value="srcPart"/>
          <element value="typeCode"/>
          <variable value="code"/>
        </source>
        <target>
          <context value="tgtPart"/>
          <contextType value="variable"/>
          <element value="type"/>
          <transform value="cc"/>
          <parameter>
            <valueString
                         value="http://terminology.hl7.org/CodeSystem/v3-ParticipationType"/>
          </parameter>
          <parameter>
            <valueId value="code"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="time"/>
        <source>
          <context value="srcPart"/>
          <element value="time"/>
          <variable value="srcTime"/>
        </source>
        <target>
          <context value="tgtPart"/>
          <contextType value="variable"/>
          <element value="period"/>
          <variable value="period"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Period"/>
          </parameter>
        </target>
        <dependent>
          <name value="IVLTSPeriod"/>
          <variable value="srcTime"/>
          <variable value="period"/>
        </dependent>
      </rule>
      <rule>
        <name value="entity"/>
        <source>
          <context value="srcPart"/>
          <element value="assignedEntity"/>
          <variable value="entity"/>
        </source>
        <target>
          <context value="bundle"/>
          <contextType value="variable"/>
          <element value="entry"/>
          <variable value="e"/>
        </target>
        <target>
          <context value="e"/>
          <contextType value="variable"/>
          <element value="resource"/>
          <variable value="practitioner"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Practitioner"/>
          </parameter>
        </target>
        <target>
          <context value="practitioner"/>
          <contextType value="variable"/>
          <element value="id"/>
          <variable value="uuid2"/>
          <transform value="uuid"/>
        </target>
        <target>
          <context value="e"/>
          <contextType value="variable"/>
          <element value="fullUrl"/>
          <transform value="append"/>
          <parameter>
            <valueString value="urn:uuid:"/>
          </parameter>
          <parameter>
            <valueId value="uuid2"/>
          </parameter>
        </target>
        <rule>
          <name value="entry"/>
          <source>
            <context value="entity"/>
          </source>
          <target>
            <context value="tgtPart"/>
            <contextType value="variable"/>
            <element value="individual"/>
            <variable value="reference"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Reference"/>
            </parameter>
          </target>
          <target>
            <context value="reference"/>
            <contextType value="variable"/>
            <element value="reference"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="'urn:uuid:' + %practitioner.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="ClinicalDocumentEntityPractitioner"/>
            <variable value="entity"/>
            <variable value="practitioner"/>
          </dependent>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="location"/>
      <source>
        <context value="src"/>
        <element value="location"/>
        <variable value="srcLocation"/>
      </source>
      <rule>
        <name value="facility"/>
        <source>
          <context value="srcLocation"/>
          <element value="healthCareFacility"/>
          <variable value="facility"/>
        </source>
        <target>
          <context value="bundle"/>
          <contextType value="variable"/>
          <element value="entry"/>
          <variable value="e"/>
        </target>
        <target>
          <context value="e"/>
          <contextType value="variable"/>
          <element value="resource"/>
          <variable value="location"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Location"/>
          </parameter>
        </target>
        <target>
          <context value="location"/>
          <contextType value="variable"/>
          <element value="id"/>
          <variable value="uuid2"/>
          <transform value="uuid"/>
        </target>
        <target>
          <context value="e"/>
          <contextType value="variable"/>
          <element value="fullUrl"/>
          <transform value="append"/>
          <parameter>
            <valueString value="urn:uuid:"/>
          </parameter>
          <parameter>
            <valueId value="uuid2"/>
          </parameter>
        </target>
        <rule>
          <name value="facLocation"/>
          <source>
            <context value="facility"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="location"/>
            <variable value="tgtLocation"/>
          </target>
          <target>
            <context value="tgtLocation"/>
            <contextType value="variable"/>
            <element value="location"/>
            <variable value="reference"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Reference"/>
            </parameter>
          </target>
          <target>
            <context value="reference"/>
            <contextType value="variable"/>
            <element value="reference"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="'urn:uuid:' + %location.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="ClinicalDocumentLocation"/>
            <variable value="facility"/>
            <variable value="bundle"/>
            <variable value="location"/>
          </dependent>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="ClinicalDocumentLocation"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="HealthCareFacility"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="Location"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="id"/>
      <source>
        <context value="src"/>
        <element value="id"/>
        <variable value="srcIdentifier"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="identifier"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Identifier"/>
        </parameter>
      </target>
      <dependent>
        <name value="II"/>
        <variable value="srcIdentifier"/>
        <variable value="identifier"/>
      </dependent>
    </rule>
    <rule>
      <name value="locationType"/>
      <source>
        <context value="src"/>
        <element value="code"/>
        <variable value="srcCode"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="type"/>
        <variable value="cc"/>
        <transform value="create"/>
        <parameter>
          <valueString value="CodeableConcept"/>
        </parameter>
      </target>
      <rule>
        <name value="coding"/>
        <source>
          <context value="srcCode"/>
          <element value="code"/>
          <variable value="code"/>
        </source>
        <target>
          <context value="cc"/>
          <contextType value="variable"/>
          <element value="coding"/>
          <variable value="coding"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Coding"/>
          </parameter>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="code"/>
          </source>
          <target>
            <context value="coding"/>
            <contextType value="variable"/>
            <element value="code"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="code"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="system"/>
          <source>
            <context value="code"/>
          </source>
          <target>
            <context value="coding"/>
            <contextType value="variable"/>
            <element value="system"/>
            <transform value="copy"/>
            <parameter>
              <valueString
                           value="https://mos.esante.gouv.fr/NOS/TRE_R02-SecteurActivite/FHIR/TRE-R02-SecteurActivite"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="display"/>
          <source>
            <context value="srcCode"/>
            <element value="displayName"/>
            <variable value="display"/>
          </source>
          <target>
            <context value="coding"/>
            <contextType value="variable"/>
            <element value="display"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="display"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="location"/>
      <source>
        <context value="src"/>
        <element value="location"/>
        <variable value="location"/>
      </source>
      <rule>
        <name value="addr"/>
        <source>
          <context value="location"/>
          <element value="addr"/>
          <variable value="locAddr"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="address"/>
          <variable value="address"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Address"/>
          </parameter>
        </target>
        <dependent>
          <name value="ADAddress"/>
          <variable value="locAddr"/>
          <variable value="address"/>
        </dependent>
      </rule>
      <rule>
        <name value="org"/>
        <source>
          <context value="location"/>
          <element value="serviceProviderOrganization"/>
          <variable value="srcOrg"/>
        </source>
        <target>
          <context value="bundle"/>
          <contextType value="variable"/>
          <element value="entry"/>
          <variable value="e"/>
        </target>
        <target>
          <context value="e"/>
          <contextType value="variable"/>
          <element value="resource"/>
          <variable value="organization"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Organization"/>
          </parameter>
        </target>
        <target>
          <context value="organization"/>
          <contextType value="variable"/>
          <element value="id"/>
          <variable value="uuid3"/>
          <transform value="uuid"/>
        </target>
        <target>
          <context value="e"/>
          <contextType value="variable"/>
          <element value="fullUrl"/>
          <transform value="append"/>
          <parameter>
            <valueString value="urn:uuid:"/>
          </parameter>
          <parameter>
            <valueId value="uuid3"/>
          </parameter>
        </target>
        <rule>
          <name value="organization"/>
          <source>
            <context value="srcOrg"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="managingOrganization"/>
            <variable value="reference"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Reference"/>
            </parameter>
          </target>
          <target>
            <context value="reference"/>
            <contextType value="variable"/>
            <element value="reference"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="'urn:uuid:' + %organization.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="ClinicalDocumentOrganization"/>
            <variable value="srcOrg"/>
            <variable value="organization"/>
          </dependent>
        </rule>
      </rule>
      <documentation value="place names are usually stored with no parts"/>
    </rule>
  </group>
  <group>
    <name value="NarrativeLink"/>
    <typeMode value="none"/>
    <documentation
                   value="_________________________ Template Type not specified  ___________________"/>
    <input>
      <name value="url"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="ext"/>
      <type value="Extension"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="url"/>
      <source>
        <context value="url"/>
      </source>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://hl7.org/fhir/StructureDefinition/narrativeLink"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="value"/>
      <source>
        <context value="url"/>
      </source>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="value"/>
        <transform value="create"/>
        <parameter>
          <valueString value="url"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="url"/>
        </parameter>
      </target>
    </rule>
  </group>
</StructureMap>