POC - Mapping CDA to FHIR
0.1.0 - ci-build

POC - Mapping CDA to FHIR - version de développement local (intégration continue v0.1.0) construite par les outils de publication FHIR (HL7® FHIR® Standard). Voir le répertoire des versions publiées

## : Mapping CSE-MDE vers FHIR Bundle - Contexte Français - XML Representation

Draft as of 2026-02-09

Raw xml | Download

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

    </span><span style="color: navy">// </span><span style="color: green">Mapping CSE-MDE vers FHIR Bundle - Contexte Français</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/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/observation.html" title="Observation">http://hl7.org/fhir/StructureDefinition/Observation</a><span style="color: navy">&quot; </span><b>alias </b>Observation <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><b>imports</b><span style="color: navy"> &quot;</span><a href="StructureMap-CdaToBundle.html" title="Mapping de CDA vers FHIR Bundle (A partir des sources de Oliver Egger)">https://interop.esante.gouv.fr/ig/fhir/mappingcdafhir/StructureMap/CdaToBundle</a><span style="color: navy">&quot;
    </span><b>imports</b><span style="color: navy"> &quot;</span><a href="StructureMap-CdaFrToBundle.html" title="Mapping de CDAFr vers FHIR Bundle (A partir des sources de Oliver Egger)">https://interop.esante.gouv.fr/ig/fhir/mappingcdafhir/StructureMap/CdaFrToBundle</a><span style="color: navy">&quot;
    </span>
    <span style="color: navy">// </span><span style="color: green">Entry point</span>
    <b>group </b>CdaFrMDEToBundle<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>CdaFrMDEMapping<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;main&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}

    </span><span style="color: navy">// </span><span style="color: green">Main mapping group</span>
    <b>group </b>CdaFrMDEMapping<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>  <span style="color: navy">// </span><span style="color: green">Bundle metadata</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;bundleId&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;bundleIdentifier&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;bundleType&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;bundleTimestamp&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">// </span><span style="color: green">Composition using CdaToBundle function (includes patient mapping)</span>
      cda<span style="color: navy"><b> -&gt; </b></span>composition<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>
      <span style="color: navy">// </span><span style="color: green">Add gender mapping after ClinicalDocumentComposition (which calls ClinicalDocumentPatientRole)</span>
      cda.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">patientRole</span><b> then</b><span style="color: navy"> {
    </span>      patientRole.patient<b> as </b><span style="color: maroon">cdaPatient</span><b> then</b><span style="color: navy"> {
    </span>        cdaPatient.administrativeGenderCode<b> as </b><span style="color: maroon">gender</span><b> then </b>MapGender<span style="color: navy">(</span><span style="color: maroon">gender</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">)</span> <i>&quot;patientGender&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;cdaPatient&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;recordTargetGender&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">// </span><span style="color: green">Process sections with observations</span>
      cda.component<b> as </b><span style="color: maroon">cdaComp</span><b> then</b><span style="color: navy"> {
    </span>    cdaComp.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">bodyComp</span><b> then</b><span style="color: navy"> {
    </span>        bodyComp.section<b> as </b><span style="color: maroon">section</span><b> then</b><span style="color: navy"> {
    </span>          <span style="color: navy">// </span><span style="color: green">Create composition section</span>
              section<span style="color: navy"><b> -&gt; </b></span>composition.section<b> as </b><span style="color: maroon">compSection</span><b> then</b><span style="color: navy"> {
    </span>            section.title<b> as </b><span style="color: maroon">sectionTitle</span><span style="color: navy"><b> -&gt; </b></span>compSection.title = <span style="color: navy">(</span>sectionTitle.xmlText<span style="color: navy">)</span> <i>&quot;sectionTitle&quot;</i><span style="color: navy">;</span>
                section.code<b> as </b><span style="color: maroon">sectionCode</span><span style="color: navy"><b> -&gt; </b></span>compSection.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">sectionCode</span><span style="color: navy">, </span><span style="color: maroon">cc</span><span style="color: navy">)</span> <i>&quot;sectionCode&quot;</i><span style="color: navy">;</span>
                section.text<b> as </b><span style="color: maroon">sectionText</span><span style="color: navy"><b> -&gt; </b></span>compSection.text = <span style="color: maroon">sectionText</span> <i>&quot;sectionText&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">// </span><span style="color: green">Process observations in organizers</span>
                section.entry<b> as </b><span style="color: maroon">entry</span><b> then</b><span style="color: navy"> {
    </span>              entry.organizer<b> as </b><span style="color: maroon">organizer</span><b> then</b><span style="color: navy"> {
    </span>                organizer.component<b> as </b><span style="color: maroon">orgComp</span><b> then</b><span style="color: navy"> {
    </span>                  orgComp.observation<b> as </b><span style="color: maroon">obs</span><b> then</b><span style="color: navy"> {
    </span>                    obs<span style="color: navy"><b> -&gt; </b></span> bundle.entry<b> as </b><span style="color: maroon">obsEntry</span><span style="color: navy">, </span> obsEntry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Observation'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">observation</span><span style="color: navy">, </span> observation.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">obsUuid</span><span style="color: navy">, </span> obsEntry.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">obsUuid</span><span style="color: navy">)</span><span style="color: navy">, </span> compSection.entry = <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">obsRef</span><span style="color: navy">, </span> obsRef.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">obsUuid</span><span style="color: navy">)</span><b> then </b>ProcessObservation<span style="color: navy">(</span><span style="color: maroon">cda</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">observation</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> <i>&quot;processObs&quot;</i><span style="color: navy">;</span>
                      <span style="color: navy">}</span><span style="color: navy">;</span>
                    <span style="color: navy">}</span> <i>&quot;orgComponent&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>
              <span style="color: navy">}</span> <i>&quot;compSection&quot;</i><span style="color: navy">;</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><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">Process individual observation using CdaToFHIRTypes functions</span>
    <b>group </b>ProcessObservation<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">obs</span>, <b>target</b> <span style="color: maroon">observation</span><span style="color: navy"> : </span>Observation, <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<span style="color: navy">)</span><span style="color: navy"> {
    </span>  <span style="color: navy">// </span><span style="color: green">Meta profile - ANS profiles based on LOINC code</span>
      obs.code<b> as </b><span style="color: maroon">obsCode</span><b> where </b>code = '29463-7'<span style="color: navy"><b> -&gt; </b></span>observation.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>    obsCode<span style="color: navy"><b> -&gt; </b></span>meta.profile = <span style="color: blue">'https://interop.esante.gouv.fr/ig/fhir/mesures/StructureDefinition/mesures-fr-observation-body-weight'</span> <i>&quot;profileWeight&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;metaWeight&quot;</i><span style="color: navy">;</span>
      obs.code<b> as </b><span style="color: maroon">obsCode</span><b> where </b>code = '8302-2'<span style="color: navy"><b> -&gt; </b></span>observation.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>    obsCode<span style="color: navy"><b> -&gt; </b></span>meta.profile = <span style="color: blue">'https://interop.esante.gouv.fr/ig/fhir/mesures/StructureDefinition/mesures-fr-observation-bodyheight'</span> <i>&quot;profileHeight&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;metaHeight&quot;</i><span style="color: navy">;</span>
      obs.code<b> as </b><span style="color: maroon">obsCode</span><b> where </b>code = '8287-5'<span style="color: navy"><b> -&gt; </b></span>observation.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>    obsCode<span style="color: navy"><b> -&gt; </b></span>meta.profile = <span style="color: blue">'https://interop.esante.gouv.fr/ig/fhir/mesures/StructureDefinition/mesures-observation-head-circumference'</span> <i>&quot;profileHeadCirc&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;metaHeadCirc&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">// </span><span style="color: green">Status - map CDA &quot;completed&quot; to FHIR &quot;final&quot;</span>
      obs.statusCode<b> as </b><span style="color: maroon">statusCode</span><b> where </b>code = 'completed'<span style="color: navy"><b> -&gt; </b></span>observation.status = <span style="color: blue">'final'</span> <i>&quot;statusCompleted&quot;</i><span style="color: navy">;</span>
      obs.statusCode<b> as </b><span style="color: maroon">statusCode</span><b> where </b>code != 'completed'<span style="color: navy"><b> -&gt; </b></span>observation.status = <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">status</span><b> then </b>CSCode<span style="color: navy">(</span><span style="color: maroon">statusCode</span><span style="color: navy">, </span><span style="color: maroon">status</span><span style="color: navy">)</span> <i>&quot;statusOther&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">// </span><span style="color: green">Category - vital-signs for all observations in CSE-MDE</span>
      obs<span style="color: navy"><b> -&gt; </b></span>observation.category = <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">category</span><b> then</b><span style="color: navy"> {
    </span>    obs<span style="color: navy"><b> -&gt; </b></span>category.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>      obs<span style="color: navy"><b> -&gt; </b></span>coding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;system&quot;</i><span style="color: navy">;</span>
          obs<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'vital-signs'</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;category&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">// </span><span style="color: green">Code using CDCodeableConcept from CdaToFHIRTypes</span>
      obs.code<b> as </b><span style="color: maroon">code</span><span style="color: navy"><b> -&gt; </b></span>observation.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">code</span><span style="color: navy">, </span><span style="color: maroon">cc</span><span style="color: navy">)</span> <i>&quot;obsCode&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">// </span><span style="color: green">EffectiveDateTime - use effectiveTime from observation</span>
      obs.effectiveTime<b> as </b><span style="color: maroon">effectiveTime</span><span style="color: navy"><b> -&gt; </b></span>observation.effective = <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">effectiveTime</span><span style="color: navy">, </span><span style="color: maroon">dt</span><span style="color: navy">)</span> <i>&quot;effectiveDateTime&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">// </span><span style="color: green">Value as Quantity using PQQuantity from CdaToFHIRTypes</span>
      obs.value<b> as </b><span style="color: maroon">value</span><span style="color: navy"><b> -&gt; </b></span>observation.value = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Quantity'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">qty</span><b> then </b>PQQuantity<span style="color: navy">(</span><span style="color: maroon">value</span><span style="color: navy">, </span><span style="color: maroon">qty</span><span style="color: navy">)</span> <i>&quot;obsValue&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">// </span><span style="color: green">Subject reference</span>
      obs<span style="color: navy"><b> -&gt; </b></span> observation.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">ref</span><span style="color: navy">, </span> ref.reference = <span style="color: navy">(</span>'urn:uuid:' + %patient.id<span style="color: navy">)</span> <i>&quot;obsSubject&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}

    </span><span style="color: navy">// </span><span style="color: green">Map CDA v3 administrative gender to FHIR gender</span>
    <b>group </b>MapGender<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span>, <b>target</b> <span style="color: maroon">patient</span><span style="color: navy"> : </span>Patient<span style="color: navy">)</span><span style="color: navy"> {
    </span>  src<b> where </b>code = 'M'<span style="color: navy"><b> -&gt; </b></span>patient.gender = <span style="color: blue">'male'</span> <i>&quot;genderMale&quot;</i><span style="color: navy">;</span>
      src<b> where </b>code = 'F'<span style="color: navy"><b> -&gt; </b></span>patient.gender = <span style="color: blue">'female'</span> <i>&quot;genderFemale&quot;</i><span style="color: navy">;</span>
      src<b> where </b>code = 'UN'<span style="color: navy"><b> -&gt; </b></span>patient.gender = <span style="color: blue">'other'</span> <i>&quot;genderOther&quot;</i><span style="color: navy">;</span>
      src<b> where </b>code = 'UNK'<span style="color: navy"><b> -&gt; </b></span>patient.gender = <span style="color: blue">'unknown'</span> <i>&quot;genderUnknown&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/CdaFrMDEToBundle"/>
      <version value="0.1.0"/>
      <name value="CdaFrMDEToBundle"/>
      <title value="Mapping CSE-MDE vers FHIR Bundle - Contexte Français"/>
      <status value="draft"/>
      <date value="2026-02-09T11:09:38+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 CSE-MDE vers FHIR Bundle - Contexte Français"/>
      <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/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/Observation"/>
        <mode value="target"/>
        <alias value="Observation"/>
      </structure>
      <import
              value="https://interop.esante.gouv.fr/ig/fhir/mappingcdafhir/StructureMap/CdaToFHIRTypes"/>
      <import
              value="https://interop.esante.gouv.fr/ig/fhir/mappingcdafhir/StructureMap/CdaToBundle"/>
      <import
              value="https://interop.esante.gouv.fr/ig/fhir/mappingcdafhir/StructureMap/CdaFrToBundle"/>
      <group>
        <name value="CdaFrMDEToBundle"/>
        <typeMode value="none"/>
        <documentation value="Entry point"/>
        <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="main"/>
          <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>
          <dependent>
            <name value="CdaFrMDEMapping"/>
            <variable value="cda"/>
            <variable value="patient"/>
            <variable value="composition"/>
            <variable value="bundle"/>
          </dependent>
        </rule>
      </group>
      <group>
        <name value="CdaFrMDEMapping"/>
        <typeMode value="none"/>
        <documentation value="Main mapping group"/>
        <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="bundleId"/>
          <source>
            <context value="cda"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="id"/>
            <transform value="uuid"/>
          </target>
        </rule>
        <rule>
          <name value="bundleIdentifier"/>
          <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="bundleType"/>
          <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="bundleTimestamp"/>
          <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>
          <target>
            <context value="composition"/>
            <contextType value="variable"/>
          </target>
          <dependent>
            <name value="ClinicalDocumentComposition"/>
            <variable value="cda"/>
            <variable value="composition"/>
            <variable value="patient"/>
            <variable value="bundle"/>
          </dependent>
        </rule>
        <rule>
          <name value="recordTargetGender"/>
          <source>
            <context value="cda"/>
            <element value="recordTarget"/>
            <variable value="recordTarget"/>
          </source>
          <rule>
            <name value="patientRole"/>
            <source>
              <context value="recordTarget"/>
              <element value="patientRole"/>
              <variable value="patientRole"/>
            </source>
            <rule>
              <name value="cdaPatient"/>
              <source>
                <context value="patientRole"/>
                <element value="patient"/>
                <variable value="cdaPatient"/>
              </source>
              <rule>
                <name value="patientGender"/>
                <source>
                  <context value="cdaPatient"/>
                  <element value="administrativeGenderCode"/>
                  <variable value="gender"/>
                </source>
                <dependent>
                  <name value="MapGender"/>
                  <variable value="gender"/>
                  <variable value="patient"/>
                </dependent>
              </rule>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="cdaComponent"/>
          <source>
            <context value="cda"/>
            <element value="component"/>
            <variable value="cdaComp"/>
          </source>
          <rule>
            <name value="structuredBody"/>
            <source>
              <context value="cdaComp"/>
              <element value="structuredBody"/>
              <variable value="body"/>
            </source>
            <rule>
              <name value="bodyComponent"/>
              <source>
                <context value="body"/>
                <element value="component"/>
                <variable value="bodyComp"/>
              </source>
              <rule>
                <name value="section"/>
                <source>
                  <context value="bodyComp"/>
                  <element value="section"/>
                  <variable value="section"/>
                </source>
                <rule>
                  <name value="compSection"/>
                  <source>
                    <context value="section"/>
                  </source>
                  <target>
                    <context value="composition"/>
                    <contextType value="variable"/>
                    <element value="section"/>
                    <variable value="compSection"/>
                  </target>
                  <rule>
                    <name value="sectionTitle"/>
                    <source>
                      <context value="section"/>
                      <element value="title"/>
                      <variable value="sectionTitle"/>
                    </source>
                    <target>
                      <context value="compSection"/>
                      <contextType value="variable"/>
                      <element value="title"/>
                      <transform value="evaluate"/>
                      <parameter>
                        <valueString value="sectionTitle.xmlText"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="sectionCode"/>
                    <source>
                      <context value="section"/>
                      <element value="code"/>
                      <variable value="sectionCode"/>
                    </source>
                    <target>
                      <context value="compSection"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <variable value="cc"/>
                      <transform value="create"/>
                      <parameter>
                        <valueString value="CodeableConcept"/>
                      </parameter>
                    </target>
                    <dependent>
                      <name value="CDCodeableConcept"/>
                      <variable value="sectionCode"/>
                      <variable value="cc"/>
                    </dependent>
                  </rule>
                  <rule>
                    <name value="sectionText"/>
                    <source>
                      <context value="section"/>
                      <element value="text"/>
                      <variable value="sectionText"/>
                    </source>
                    <target>
                      <context value="compSection"/>
                      <contextType value="variable"/>
                      <element value="text"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueId value="sectionText"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="entry"/>
                    <source>
                      <context value="section"/>
                      <element value="entry"/>
                      <variable value="entry"/>
                    </source>
                    <rule>
                      <name value="organizer"/>
                      <source>
                        <context value="entry"/>
                        <element value="organizer"/>
                        <variable value="organizer"/>
                      </source>
                      <rule>
                        <name value="orgComponent"/>
                        <source>
                          <context value="organizer"/>
                          <element value="component"/>
                          <variable value="orgComp"/>
                        </source>
                        <rule>
                          <name value="observation"/>
                          <source>
                            <context value="orgComp"/>
                            <element value="observation"/>
                            <variable value="obs"/>
                          </source>
                          <rule>
                            <name value="processObs"/>
                            <source>
                              <context value="obs"/>
                            </source>
                            <target>
                              <context value="bundle"/>
                              <contextType value="variable"/>
                              <element value="entry"/>
                              <variable value="obsEntry"/>
                            </target>
                            <target>
                              <context value="obsEntry"/>
                              <contextType value="variable"/>
                              <element value="resource"/>
                              <variable value="observation"/>
                              <transform value="create"/>
                              <parameter>
                                <valueString value="Observation"/>
                              </parameter>
                            </target>
                            <target>
                              <context value="observation"/>
                              <contextType value="variable"/>
                              <element value="id"/>
                              <variable value="obsUuid"/>
                              <transform value="uuid"/>
                            </target>
                            <target>
                              <context value="obsEntry"/>
                              <contextType value="variable"/>
                              <element value="fullUrl"/>
                              <transform value="append"/>
                              <parameter>
                                <valueString value="urn:uuid:"/>
                              </parameter>
                              <parameter>
                                <valueId value="obsUuid"/>
                              </parameter>
                            </target>
                            <target>
                              <context value="compSection"/>
                              <contextType value="variable"/>
                              <element value="entry"/>
                              <variable value="obsRef"/>
                              <transform value="create"/>
                              <parameter>
                                <valueString value="Reference"/>
                              </parameter>
                            </target>
                            <target>
                              <context value="obsRef"/>
                              <contextType value="variable"/>
                              <element value="reference"/>
                              <transform value="append"/>
                              <parameter>
                                <valueString value="urn:uuid:"/>
                              </parameter>
                              <parameter>
                                <valueId value="obsUuid"/>
                              </parameter>
                            </target>
                            <dependent>
                              <name value="ProcessObservation"/>
                              <variable value="cda"/>
                              <variable value="obs"/>
                              <variable value="observation"/>
                              <variable value="patient"/>
                              <variable value="composition"/>
                            </dependent>
                          </rule>
                        </rule>
                      </rule>
                    </rule>
                  </rule>
                </rule>
              </rule>
            </rule>
          </rule>
        </rule>
      </group>
      <group>
        <name value="ProcessObservation"/>
        <typeMode value="none"/>
        <documentation
                       value="Process individual observation using CdaToFHIRTypes functions"/>
        <input>
          <name value="cda"/>
          <type value="ClinicalDocument"/>
          <mode value="source"/>
        </input>
        <input>
          <name value="obs"/>
          <mode value="source"/>
        </input>
        <input>
          <name value="observation"/>
          <type value="Observation"/>
          <mode value="target"/>
        </input>
        <input>
          <name value="patient"/>
          <type value="Patient"/>
          <mode value="target"/>
        </input>
        <input>
          <name value="composition"/>
          <type value="Composition"/>
          <mode value="target"/>
        </input>
        <rule>
          <name value="metaWeight"/>
          <source>
            <context value="obs"/>
            <element value="code"/>
            <variable value="obsCode"/>
            <condition value="code = '29463-7'"/>
          </source>
          <target>
            <context value="observation"/>
            <contextType value="variable"/>
            <element value="meta"/>
            <variable value="meta"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Meta"/>
            </parameter>
          </target>
          <rule>
            <name value="profileWeight"/>
            <source>
              <context value="obsCode"/>
            </source>
            <target>
              <context value="meta"/>
              <contextType value="variable"/>
              <element value="profile"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="https://interop.esante.gouv.fr/ig/fhir/mesures/StructureDefinition/mesures-fr-observation-body-weight"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="metaHeight"/>
          <source>
            <context value="obs"/>
            <element value="code"/>
            <variable value="obsCode"/>
            <condition value="code = '8302-2'"/>
          </source>
          <target>
            <context value="observation"/>
            <contextType value="variable"/>
            <element value="meta"/>
            <variable value="meta"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Meta"/>
            </parameter>
          </target>
          <rule>
            <name value="profileHeight"/>
            <source>
              <context value="obsCode"/>
            </source>
            <target>
              <context value="meta"/>
              <contextType value="variable"/>
              <element value="profile"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="https://interop.esante.gouv.fr/ig/fhir/mesures/StructureDefinition/mesures-fr-observation-bodyheight"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="metaHeadCirc"/>
          <source>
            <context value="obs"/>
            <element value="code"/>
            <variable value="obsCode"/>
            <condition value="code = '8287-5'"/>
          </source>
          <target>
            <context value="observation"/>
            <contextType value="variable"/>
            <element value="meta"/>
            <variable value="meta"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Meta"/>
            </parameter>
          </target>
          <rule>
            <name value="profileHeadCirc"/>
            <source>
              <context value="obsCode"/>
            </source>
            <target>
              <context value="meta"/>
              <contextType value="variable"/>
              <element value="profile"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="https://interop.esante.gouv.fr/ig/fhir/mesures/StructureDefinition/mesures-observation-head-circumference"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="statusCompleted"/>
          <source>
            <context value="obs"/>
            <element value="statusCode"/>
            <variable value="statusCode"/>
            <condition value="code = 'completed'"/>
          </source>
          <target>
            <context value="observation"/>
            <contextType value="variable"/>
            <element value="status"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="final"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="statusOther"/>
          <source>
            <context value="obs"/>
            <element value="statusCode"/>
            <variable value="statusCode"/>
            <condition value="code != 'completed'"/>
          </source>
          <target>
            <context value="observation"/>
            <contextType value="variable"/>
            <element value="status"/>
            <variable value="status"/>
            <transform value="create"/>
            <parameter>
              <valueString value="code"/>
            </parameter>
          </target>
          <dependent>
            <name value="CSCode"/>
            <variable value="statusCode"/>
            <variable value="status"/>
          </dependent>
        </rule>
        <rule>
          <name value="category"/>
          <source>
            <context value="obs"/>
          </source>
          <target>
            <context value="observation"/>
            <contextType value="variable"/>
            <element value="category"/>
            <variable value="category"/>
            <transform value="create"/>
            <parameter>
              <valueString value="CodeableConcept"/>
            </parameter>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="obs"/>
            </source>
            <target>
              <context value="category"/>
              <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="obs"/>
              </source>
              <target>
                <context value="coding"/>
                <contextType value="variable"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="http://terminology.hl7.org/CodeSystem/observation-category"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="code"/>
              <source>
                <context value="obs"/>
              </source>
              <target>
                <context value="coding"/>
                <contextType value="variable"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="vital-signs"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="obsCode"/>
          <source>
            <context value="obs"/>
            <element value="code"/>
            <variable value="code"/>
          </source>
          <target>
            <context value="observation"/>
            <contextType value="variable"/>
            <element value="code"/>
            <variable value="cc"/>
            <transform value="create"/>
            <parameter>
              <valueString value="CodeableConcept"/>
            </parameter>
          </target>
          <dependent>
            <name value="CDCodeableConcept"/>
            <variable value="code"/>
            <variable value="cc"/>
          </dependent>
        </rule>
        <rule>
          <name value="effectiveDateTime"/>
          <source>
            <context value="obs"/>
            <element value="effectiveTime"/>
            <variable value="effectiveTime"/>
          </source>
          <target>
            <context value="observation"/>
            <contextType value="variable"/>
            <element value="effective"/>
            <variable value="dt"/>
            <transform value="create"/>
            <parameter>
              <valueString value="dateTime"/>
            </parameter>
          </target>
          <dependent>
            <name value="TSDateTime"/>
            <variable value="effectiveTime"/>
            <variable value="dt"/>
          </dependent>
        </rule>
        <rule>
          <name value="obsValue"/>
          <source>
            <context value="obs"/>
            <element value="value"/>
            <variable value="value"/>
          </source>
          <target>
            <context value="observation"/>
            <contextType value="variable"/>
            <element value="value"/>
            <variable value="qty"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Quantity"/>
            </parameter>
          </target>
          <dependent>
            <name value="PQQuantity"/>
            <variable value="value"/>
            <variable value="qty"/>
          </dependent>
        </rule>
        <rule>
          <name value="obsSubject"/>
          <source>
            <context value="obs"/>
          </source>
          <target>
            <context value="observation"/>
            <contextType value="variable"/>
            <element value="subject"/>
            <variable value="ref"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Reference"/>
            </parameter>
          </target>
          <target>
            <context value="ref"/>
            <contextType value="variable"/>
            <element value="reference"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="'urn:uuid:' + %patient.id"/>
            </parameter>
          </target>
        </rule>
      </group>
      <group>
        <name value="MapGender"/>
        <typeMode value="none"/>
        <documentation value="Map CDA v3 administrative gender to FHIR gender"/>
        <input>
          <name value="src"/>
          <mode value="source"/>
        </input>
        <input>
          <name value="patient"/>
          <type value="Patient"/>
          <mode value="target"/>
        </input>
        <rule>
          <name value="genderMale"/>
          <source>
            <context value="src"/>
            <condition value="code = 'M'"/>
          </source>
          <target>
            <context value="patient"/>
            <contextType value="variable"/>
            <element value="gender"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="male"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="genderFemale"/>
          <source>
            <context value="src"/>
            <condition value="code = 'F'"/>
          </source>
          <target>
            <context value="patient"/>
            <contextType value="variable"/>
            <element value="gender"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="female"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="genderOther"/>
          <source>
            <context value="src"/>
            <condition value="code = 'UN'"/>
          </source>
          <target>
            <context value="patient"/>
            <contextType value="variable"/>
            <element value="gender"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="other"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="genderUnknown"/>
          <source>
            <context value="src"/>
            <condition value="code = 'UNK'"/>
          </source>
          <target>
            <context value="patient"/>
            <contextType value="variable"/>
            <element value="gender"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="unknown"/>
            </parameter>
          </target>
        </rule>
      </group>
    </StructureMap>