Data Management with FHIR 0.1.0 - ci-build

Data Management with 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

## : Transforms QuestionnaireResponse based on Questionnaire Usage Variables socles into FHIR resources conforming to DM profiles - XML Representation

Draft as of 2026-04-16

Raw xml | Download

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

    </span><span style="color: navy">// </span><span style="color: green">Transforms QuestionnaireResponse based on Questionnaire Usage Variables socles into FHIR resources conforming to DM profiles</span>

    <b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/questionnaireresponse.html" title="QuestionnaireResponse">http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse</a><span style="color: navy">&quot; </span><b>alias </b>QuestionnaireResponse <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>

    <span style="color: navy">// </span><span style="color: green">Main entry point: Transform QuestionnaireResponse to Bundle</span>
    <b>group </b>QuestionnaireResponseToBundle<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>QuestionnaireResponse, <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">Initialize Bundle</span>
      src<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>
      src<span style="color: navy"><b> -&gt; </b></span>bundle.type = <span style="color: blue">'collection'</span> <i>&quot;bundletype&quot;</i><span style="color: navy">;</span>
      src<span style="color: navy"><b> -&gt; </b></span>bundle.timestamp = <span style="color: navy">(</span>now()<span style="color: navy">)</span> <i>&quot;setTimestamp&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">// </span><span style="color: green">Create Patient resource</span>
      src<span style="color: navy"><b> -&gt; </b></span>bundle.entry<b> as </b><span style="color: maroon">patientEntry</span><b> then</b><span style="color: navy"> {
    </span>    src<span style="color: navy"><b> -&gt; </b></span>patientEntry.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><b> then</b><span style="color: navy"> {
    </span>      src<b> then </b>CreatePatient<span style="color: navy">(</span><span style="color: maroon">src</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">)</span> <i>&quot;createpatient&quot;</i><span style="color: navy">;</span>
          src<span style="color: navy"><b> -&gt; </b></span> patient.id<b> as </b><span style="color: maroon">patientId</span><span style="color: navy">, </span> patientEntry.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">patientId</span><span style="color: navy">)</span> <i>&quot;setfullUrl&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Create Locations from geocoding data</span>
          <span style="color: navy">// </span><span style="color: green">src then CreateLocations(src, patient, bundle) &quot;create-locations&quot;;</span>
          <span style="color: navy">// </span><span style="color: green">Create Encounters from PMSI data</span>
          src<b> then </b>CreateEncounters<span style="color: navy">(</span><span style="color: maroon">src</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;createencounters&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Create Laboratory Observations</span>
          src<b> then </b>CreateLaboratoryObservations<span style="color: navy">(</span><span style="color: maroon">src</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;createlabobservations&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Create Medication Requests</span>
          src<b> then </b>CreateMedicationRequests<span style="color: navy">(</span><span style="color: maroon">src</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;createmedicationrequests&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Create Medication Administrations</span>
          src<b> then </b>CreateMedicationAdministrations<span style="color: navy">(</span><span style="color: maroon">src</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;createmedicationadministrations&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Create Vital Sign Observations</span>
          src<b> then </b>CreateVitalSignObservations<span style="color: navy">(</span><span style="color: maroon">src</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;createvitalsigns&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;createpatientresource&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;patiententry&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}

    </span><span style="color: navy">// </span><span style="color: green">Group: Create Patient from QuestionnaireResponse</span>
    <b>group </b>CreatePatient<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>QuestionnaireResponse, <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<span style="color: navy"><b> -&gt; </b></span>patient.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span> <i>&quot;patientid&quot;</i><span style="color: navy">;</span>
      src<span style="color: navy"><b> -&gt; </b></span>patient.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.aphp.fr/ig/fhir/dm/StructureDefinition/DMPatient'</span> <i>&quot;patientprofile&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;patientmeta&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">// </span><span style="color: green">Extract patient identity data from linkId 4647259356106 &gt; 2958000860428</span>
      src.item<b> as </b><span style="color: maroon">socioDemo</span><b> where </b>(linkId = '4647259356106')<b> then</b><span style="color: navy"> {
    </span>    socioDemo.item<b> as </b><span style="color: maroon">identity</span><b> where </b>(linkId = '2958000860428')<b> then</b><span style="color: navy"> {
    </span>      <span style="color: navy">// </span><span style="color: green">Patient name (linkId 8605698058770 = family, 6214879623503 = given)</span>
          identity<span style="color: navy"><b> -&gt; </b></span>patient.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">name</span><b> then</b><span style="color: navy"> {
    </span>        identity.item<b> as </b><span style="color: maroon">familyItem</span><b> where </b>(linkId = '8605698058770')<b> then</b><span style="color: navy"> {
    </span>          familyItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>name.family = <span style="color: navy">(</span>ans.valueString<span style="color: navy">)</span> <i>&quot;setfamily&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;extractfamily&quot;</i><span style="color: navy">;</span>
            identity.item<b> as </b><span style="color: maroon">givenItem</span><b> where </b>(linkId = '6214879623503')<b> then</b><span style="color: navy"> {
    </span>          givenItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>name.given = <span style="color: navy">(</span>ans.valueString<span style="color: navy">)</span> <i>&quot;setgiven&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;extractgiven&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;setname&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">NIR identifier (linkId 5711960356160)</span>
          identity.item<b> as </b><span style="color: maroon">nirItem</span><b> where </b>(linkId = '5711960356160')<b> then</b><span style="color: navy"> {
    </span>        nirItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>patient.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">nir</span><b> then</b><span style="color: navy"> {
    </span>          ans<span style="color: navy"><b> -&gt; </b></span>nir.system = <span style="color: blue">'urn:oid:1.2.250.1.213.1.4.8'</span> <i>&quot;nirsystem&quot;</i><span style="color: navy">;</span>
              ans<span style="color: navy"><b> -&gt; </b></span>nir.value = <span style="color: navy">(</span>ans.valueString<span style="color: navy">)</span> <i>&quot;nirvalue&quot;</i><span style="color: navy">;</span>
              ans<span style="color: navy"><b> -&gt; </b></span>nir.type = <b>cc</b><span style="color: navy">(</span><span style="color: blue">'http://interopsante.org/fhir/CodeSystem/fr-v2-0203'</span><span style="color: navy">, </span><span style="color: blue">'NIR'</span><span style="color: navy">)</span> <i>&quot;nirtype&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setnir&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractnir&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">INS identifier (linkId 3764723550987)</span>
          identity.item<b> as </b><span style="color: maroon">insItem</span><b> where </b>(linkId = '3764723550987')<b> then</b><span style="color: navy"> {
    </span>        insItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>patient.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">ins</span><b> then</b><span style="color: navy"> {
    </span>          ans<span style="color: navy"><b> -&gt; </b></span>ins.system = <span style="color: blue">'urn:oid:1.2.250.1.213.1.4.10'</span> <i>&quot;inssystem&quot;</i><span style="color: navy">;</span>
              ans<span style="color: navy"><b> -&gt; </b></span>ins.value = <span style="color: navy">(</span>ans.valueString<span style="color: navy">)</span> <i>&quot;insvalue&quot;</i><span style="color: navy">;</span>
              ans<span style="color: navy"><b> -&gt; </b></span>ins.type = <b>cc</b><span style="color: navy">(</span><span style="color: blue">'http://interopsante.org/fhir/CodeSystem/fr-v2-0203'</span><span style="color: navy">, </span><span style="color: blue">'INS-C'</span><span style="color: navy">)</span> <i>&quot;instype&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setins&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractins&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Birth date (linkId 5036133558154)</span>
          identity.item<b> as </b><span style="color: maroon">birthItem</span><b> where </b>(linkId = '5036133558154')<b> then</b><span style="color: navy"> {
    </span>        birthItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>patient.birthDate = <span style="color: navy">(</span>ans.valueDate<span style="color: navy">)</span> <i>&quot;setbirthdate&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractbirthdate&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Death date (linkId 5633552097315)</span>
          identity.item<b> as </b><span style="color: maroon">deathItem</span><b> where </b>(linkId = '5633552097315')<b> then</b><span style="color: navy"> {
    </span>        deathItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>patient.deceased = <span style="color: navy">(</span>ans.valueDate<span style="color: navy">)</span> <i>&quot;setdeceaseddate&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">// </span><span style="color: green">Death source (linkId 9098810065693)</span>
            deathItem.item<b> as </b><span style="color: maroon">deathSource</span><b> where </b>(linkId = '9098810065693')<b> then</b><span style="color: navy"> {
    </span>          deathSource.answer<b> as </b><span style="color: maroon">sourceAns</span><span style="color: navy"><b> -&gt; </b></span>patient.extension = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Extension'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">ext</span><b> then</b><span style="color: navy"> {
    </span>            sourceAns<span style="color: navy"><b> -&gt; </b></span>ext.url = <span style="color: blue">'https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/death-source'</span> <i>&quot;deathsourceurl&quot;</i><span style="color: navy">;</span>
                sourceAns<span style="color: navy"><b> -&gt; </b></span>ext.value = <span style="color: navy">(</span>sourceAns.valueCoding<span style="color: navy">)</span> <i>&quot;deathsourcevalue&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;setdeathsourceext&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;extractdeathsource&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractdeath&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Multiple birth rank (linkId 6931296968515)</span>
          identity.item<b> as </b><span style="color: maroon">multipleItem</span><b> where </b>(linkId = '6931296968515')<b> then</b><span style="color: navy"> {
    </span>        multipleItem.answer<b> as </b><span style="color: maroon">ans</span><b> then</b><span style="color: navy"> {
    </span>          ans.valueInteger<b> as </b><span style="color: maroon">valueInteger</span><span style="color: navy"><b> -&gt; </b></span>patient.multipleBirth = <span style="color: maroon">valueInteger</span> <i>&quot;setmultiplebirth&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;navigatevalue&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractmultiplebirth&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;processidentity&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">Gender from PMSI data (linkId 3894630481120 within 2825244231605)</span>
        src.item<b> as </b><span style="color: maroon">pmsiGroup</span><b> where </b>(linkId = '2825244231605')<b> then</b><span style="color: navy"> {
    </span>      pmsiGroup.item<b> as </b><span style="color: maroon">sexItem</span><b> where </b>(linkId = '3894630481120')<b> then</b><span style="color: navy"> {
    </span>        sexItem.answer<b> as </b><span style="color: maroon">ans</span><b> then</b><span style="color: navy"> {
    </span>          ans.valueCoding<b> as </b><span style="color: maroon">valueCoding</span><span style="color: navy"><b> -&gt; </b></span>patient.gender = <b>translate</b><span style="color: navy">(</span><span style="color: maroon">valueCoding</span><span style="color: navy">, </span><span style="color: blue">'https://interop.aphp.fr/ig/fhir/dm/ConceptMap/dpi-gender-2-hl7-gender'</span><span style="color: navy">, </span><span style="color: blue">'code'</span><span style="color: navy">)</span> <i>&quot;setgender&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;valueCoding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractgender&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Address from code géographique (linkId 2446369196222)</span>
          pmsiGroup.item<b> as </b><span style="color: maroon">codeGeoItem</span><b> where </b>(linkId = '2446369196222')<b> then</b><span style="color: navy"> {
    </span>        codeGeoItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>patient.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">addr</span><b> then</b><span style="color: navy"> {
    </span>          ans<span style="color: navy"><b> -&gt; </b></span>addr.extension = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Extension'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">ext</span><b> then</b><span style="color: navy"> {
    </span>            ans<span style="color: navy"><b> -&gt; </b></span>ext.url = <span style="color: blue">'https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/pmsi-code-geo'</span> <i>&quot;codegeourl&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>ext.value = <span style="color: navy">(</span>ans.valueCoding<span style="color: navy">)</span> <i>&quot;codegeovalue&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;setcodegeoext&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setaddress&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractcodegeo&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;extractpmsidemographics&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;processsociodemographics&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}

    </span><span style="color: navy">// </span><span style="color: green">Group: Create Locations from geocoding and IRIS data</span>
    <b>group </b>CreateLocations<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>QuestionnaireResponse, <b>target</b> <span style="color: maroon">patient</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: navy">// </span><span style="color: green">Extract geocoding data from linkId 4647259356106 &gt; 5491974639955 &gt; 3816475533472</span>
      src.item<b> as </b><span style="color: maroon">socioDemo</span><b> where </b>(linkId = '4647259356106')<b> then</b><span style="color: navy"> {
    </span>    socioDemo.item<b> as </b><span style="color: maroon">environment</span><b> where </b>(linkId = '5491974639955')<b> then</b><span style="color: navy"> {
    </span>      <span style="color: navy">// </span><span style="color: green">Geocoding locations (repeating group 3816475533472)</span>
          environment.item<b> as </b><span style="color: maroon">geocodingItem</span><b> where </b>(linkId = '3816475533472')<span style="color: navy"><b> -&gt; </b></span>bundle.entry<b> as </b><span style="color: maroon">locationEntry</span><b> then</b><span style="color: navy"> {
    </span>        geocodingItem<span style="color: navy"><b> -&gt; </b></span>locationEntry.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><b> then</b><span style="color: navy"> {
    </span>          geocodingItem<span style="color: navy"><b> -&gt; </b></span>location.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span> <i>&quot;locationid&quot;</i><span style="color: navy">;</span>
              geocodingItem<span style="color: navy"><b> -&gt; </b></span>location.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>            geocodingItem<span style="color: navy"><b> -&gt; </b></span>meta.profile = <span style="color: blue">'https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMLocation'</span> <i>&quot;locationprofile&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;locationmeta&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">// </span><span style="color: green">Position with latitude and longitude</span>
              geocodingItem<span style="color: navy"><b> -&gt; </b></span>location.position = <b>create</b><span style="color: navy">(</span><span style="color: blue">'LocationPosition'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">pos</span><b> then</b><span style="color: navy"> {
    </span>            <span style="color: navy">// </span><span style="color: green">Latitude (linkId 3709843054556)</span>
                geocodingItem.item<b> as </b><span style="color: maroon">latItem</span><b> where </b>(linkId = '3709843054556')<b> then</b><span style="color: navy"> {
    </span>              latItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>pos.latitude = <span style="color: navy">(</span>ans.valueDecimal<span style="color: navy">)</span> <i>&quot;setlatitude&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;extractlatitude&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">// </span><span style="color: green">Longitude (linkId 7651448032665)</span>
                geocodingItem.item<b> as </b><span style="color: maroon">longItem</span><b> where </b>(linkId = '7651448032665')<b> then</b><span style="color: navy"> {
    </span>              longItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>pos.longitude = <span style="color: navy">(</span>ans.valueDecimal<span style="color: navy">)</span> <i>&quot;setlongitude&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;extractlongitude&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;setposition&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">// </span><span style="color: green">Extension for collection date (linkId 1185653257776)</span>
              <span style="color: navy">// </span><span style="color: green">geocodingItem.item as dateItem where (linkId = '1185653257776') then {             dateItem.answer as ans -&gt; location.extension = create('Extension') as ext then {               ans -&gt; ext.url = 'http://hl7.org/fhir/StructureDefinition/data-collection-date' &quot;date-url&quot;;               ans -&gt; ext.value = (ans.valueDate) &quot;date-value&quot;;             } &quot;set-collection-date&quot;;           } &quot;extract-collection-date&quot;;</span>
              location<span style="color: navy"><b> -&gt; </b></span>locationEntry.request<b> as </b><span style="color: maroon">request</span><b> then</b><span style="color: navy"> {
    </span>            location<span style="color: navy"><b> -&gt; </b></span>request.method = <span style="color: blue">'POST'</span> <i>&quot;setmethod&quot;</i><span style="color: navy">;</span>
                location<span style="color: navy"><b> -&gt; </b></span>request.url = <span style="color: blue">'Location'</span> <i>&quot;seturl&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;setrequest&quot;</i><span style="color: navy">;</span>
              location.id<b> as </b><span style="color: maroon">locId</span><span style="color: navy"><b> -&gt; </b></span>locationEntry.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">locId</span><span style="color: navy">)</span> <i>&quot;setfullUrl&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;createlocation&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;geocodinglocationentry&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">IRIS locations (repeating item 7621032273792)</span>
          environment.item<b> as </b><span style="color: maroon">irisItem</span><b> where </b>(linkId = '7621032273792')<b> then</b><span style="color: navy"> {
    </span>        irisItem.answer<b> as </b><span style="color: maroon">irisAnswer</span><span style="color: navy"><b> -&gt; </b></span>bundle.entry<b> as </b><span style="color: maroon">locationEntry</span><b> then</b><span style="color: navy"> {
    </span>          irisAnswer<span style="color: navy"><b> -&gt; </b></span>locationEntry.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><b> then</b><span style="color: navy"> {
    </span>            irisAnswer<span style="color: navy"><b> -&gt; </b></span>location.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span> <i>&quot;locationid&quot;</i><span style="color: navy">;</span>
                irisAnswer<span style="color: navy"><b> -&gt; </b></span>location.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>              irisAnswer<span style="color: navy"><b> -&gt; </b></span>meta.profile = <span style="color: blue">'https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMLocation'</span> <i>&quot;locationprofile&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;locationmeta&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">// </span><span style="color: green">IRIS code as identifier</span>
                irisAnswer<span style="color: navy"><b> -&gt; </b></span>location.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>              irisAnswer<span style="color: navy"><b> -&gt; </b></span>identifier.system = <span style="color: blue">'urn:oid:2.16.840.1.113883.2.8.1.5.5'</span> <i>&quot;irissystem&quot;</i><span style="color: navy">;</span>
                  irisAnswer<span style="color: navy"><b> -&gt; </b></span>identifier.value = <span style="color: navy">(</span>irisAnswer.valueCoding.code<span style="color: navy">)</span> <i>&quot;irisvalue&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;setirisidentifier&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">// </span><span style="color: green">Collection date from nested item (linkId 4999580038872)</span>
                <span style="color: navy">// </span><span style="color: green">irisAnswer.item as dateItem where (linkId = '4999580038872') then {               dateItem.answer as ans -&gt; location.extension = create('Extension') as ext then {                 ans -&gt; ext.url = 'http://hl7.org/fhir/StructureDefinition/data-collection-date' &quot;date-url&quot;;                 ans -&gt; ext.value = (ans.valueDate) &quot;date-value&quot;;               } &quot;set-collection-date&quot;;             } &quot;extract-iris-date&quot;;</span>
                location<span style="color: navy"><b> -&gt; </b></span>locationEntry.request<b> as </b><span style="color: maroon">request</span><b> then</b><span style="color: navy"> {
    </span>              location<span style="color: navy"><b> -&gt; </b></span>request.method = <span style="color: blue">'POST'</span> <i>&quot;setmethod&quot;</i><span style="color: navy">;</span>
                  location<span style="color: navy"><b> -&gt; </b></span>request.url = <span style="color: blue">'Location'</span> <i>&quot;seturl&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;setrequest&quot;</i><span style="color: navy">;</span>
                location.id<b> as </b><span style="color: maroon">locId</span><span style="color: navy"><b> -&gt; </b></span>locationEntry.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">locId</span><span style="color: navy">)</span> <i>&quot;setfullUrl&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;createirislocation&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;irislocationentry&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;processiris&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;processenvironment&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;processsociodemographicslocation&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}

    </span><span style="color: navy">// </span><span style="color: green">Group: Create Encounters from PMSI data</span>
    <b>group </b>CreateEncounters<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>QuestionnaireResponse, <b>target</b> <span style="color: maroon">patient</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: navy">// </span><span style="color: green">PMSI data group (linkId 2825244231605) - Note: This can repeat in the structure</span>
      src.item<b> as </b><span style="color: maroon">pmsiItem</span><b> where </b>(linkId = '2825244231605')<span style="color: navy"><b> -&gt; </b></span>bundle.entry<b> as </b><span style="color: maroon">encounterEntry</span><b> then</b><span style="color: navy"> {
    </span>    pmsiItem<span style="color: navy"><b> -&gt; </b></span>encounterEntry.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><b> then</b><span style="color: navy"> {
    </span>      pmsiItem<span style="color: navy"><b> -&gt; </b></span>encounter.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span> <i>&quot;encounterid&quot;</i><span style="color: navy">;</span>
          pmsiItem<span style="color: navy"><b> -&gt; </b></span>encounter.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>        pmsiItem<span style="color: navy"><b> -&gt; </b></span>meta.profile = <span style="color: blue">'https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMEncounter'</span> <i>&quot;encounterprofile&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;encountermeta&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Link to patient</span>
          src<span style="color: navy"><b> -&gt; </b></span> encounter.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> patient.id<b> as </b><span style="color: maroon">patId</span><span style="color: navy">, </span> ref.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'Patient/'</span><span style="color: navy">, </span><span style="color: maroon">patId</span><span style="color: navy">)</span> <i>&quot;setsubject&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Encounter period (start: 5991443718282, end: 6114780320846)</span>
          pmsiItem<span style="color: navy"><b> -&gt; </b></span>encounter.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><span style="color: navy"> {
    </span>        pmsiItem.item<b> as </b><span style="color: maroon">startItem</span><b> where </b>(linkId = '5991443718282')<b> then</b><span style="color: navy"> {
    </span>          startItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>period.start = <span style="color: navy">(</span>ans.valueDate<span style="color: navy">)</span> <i>&quot;setstart&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;extractstart&quot;</i><span style="color: navy">;</span>
            pmsiItem.item<b> as </b><span style="color: maroon">endItem</span><b> where </b>(linkId = '6114780320846')<b> then</b><span style="color: navy"> {
    </span>          endItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>period.end = <span style="color: navy">(</span>ans.valueDate<span style="color: navy">)</span> <i>&quot;setend&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;extractend&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;setperiod&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Mode d'entrée (linkId 6172398101212)</span>
          pmsiItem.item<b> as </b><span style="color: maroon">modeInItem</span><b> where </b>(linkId = '6172398101212') <i>&quot;extractmodein&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Mode de sortie (linkId 3354867075704)</span>
          pmsiItem.item<b> as </b><span style="color: maroon">modeOutItem</span><b> where </b>(linkId = '3354867075704') <i>&quot;extractmodeout&quot;</i><span style="color: navy">;</span>
          src<span style="color: navy"><b> -&gt; </b></span> encounter.id<b> as </b><span style="color: maroon">encId</span><span style="color: navy">, </span> encounterEntry.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">encId</span><span style="color: navy">)</span> <i>&quot;setfullUrl&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Create nested Conditions and Procedures</span>
          pmsiItem<b> then </b>CreateConditions<span style="color: navy">(</span><span style="color: maroon">pmsiItem</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">encounter</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">)</span> <i>&quot;createconditions&quot;</i><span style="color: navy">;</span>
          pmsiItem<b> then </b>CreateProcedures<span style="color: navy">(</span><span style="color: maroon">pmsiItem</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">encounter</span><span style="color: navy">, </span><span style="color: maroon">bundle</span><span style="color: navy">)</span> <i>&quot;createprocedures&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;createencounter&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;encounterentry&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}

    </span><span style="color: navy">// </span><span style="color: green">Group: Create Conditions from nested diagnostics</span>
    <b>group </b>CreateConditions<span style="color: navy">(</span><b>source</b> <span style="color: maroon">pmsiItem</span>, <b>target</b> <span style="color: maroon">patient</span><span style="color: navy"> : </span>Patient, <b>target</b> <span style="color: maroon">encounter</span><span style="color: navy"> : </span>Encounter, <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">Diagnostics group (linkId 9391816419630) - can repeat</span>
      pmsiItem.item<b> as </b><span style="color: maroon">diagGroup</span><b> where </b>(linkId = '9391816419630')<span style="color: navy"><b> -&gt; </b></span>bundle.entry<b> as </b><span style="color: maroon">conditionEntry</span><b> then</b><span style="color: navy"> {
    </span>    diagGroup<span style="color: navy"><b> -&gt; </b></span>conditionEntry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Condition'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">condition</span><b> then</b><span style="color: navy"> {
    </span>      diagGroup<span style="color: navy"><b> -&gt; </b></span>condition.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span> <i>&quot;conditionid&quot;</i><span style="color: navy">;</span>
          diagGroup<span style="color: navy"><b> -&gt; </b></span>condition.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>        diagGroup<span style="color: navy"><b> -&gt; </b></span>meta.profile = <span style="color: blue">'https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMCondition'</span> <i>&quot;conditionprofile&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;conditionmeta&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Link to patient</span>
          diagGroup<span style="color: navy"><b> -&gt; </b></span> condition.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> patient.id<b> as </b><span style="color: maroon">patId</span><span style="color: navy">, </span> ref.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'Patient/'</span><span style="color: navy">, </span><span style="color: maroon">patId</span><span style="color: navy">)</span> <i>&quot;setsubject&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Link to encounter</span>
          diagGroup<span style="color: navy"><b> -&gt; </b></span> encounter.id<b> as </b><span style="color: maroon">encId</span><span style="color: navy">, </span> condition.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">ref</span><span style="color: navy">, </span> ref.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'Encounter/'</span><span style="color: navy">, </span><span style="color: maroon">encId</span><span style="color: navy">)</span> <i>&quot;setencounter&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Diagnostic code (linkId 5505101189372) - CIM-10</span>
          diagGroup.item<b> as </b><span style="color: maroon">diagCodeItem</span><b> where </b>(linkId = '5505101189372')<b> then</b><span style="color: navy"> {
    </span>        diagCodeItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>condition.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">code</span><b> then</b><span style="color: navy"> {
    </span>          ans<span style="color: navy"><b> -&gt; </b></span>code.coding = <span style="color: navy">(</span>ans.valueCoding<span style="color: navy">)</span> <i>&quot;setcoding&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setcode&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractdiagcode&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Type de diagnostic (linkId 6427586743735) - DP/DAS/DR</span>
          diagGroup.item<b> as </b><span style="color: maroon">diagTypeItem</span><b> where </b>(linkId = '6427586743735')<b> then</b><span style="color: navy"> {
    </span>        diagTypeItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>condition.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>          ans<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>            ans<span style="color: navy"><b> -&gt; </b></span>coding.system = <span style="color: blue">'https://interop.aphp.fr/ig/fhir/dm/CodeSystem/pmsi-mco-diag-type'</span> <i>&quot;diagtypesystem&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: navy">(</span>ans.valueCoding.code<span style="color: navy">)</span> <i>&quot;diagtypecode&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: navy">(</span>ans.valueCoding.display<span style="color: navy">)</span> <i>&quot;diagtypedisplay&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;setcategorycoding&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setcategory&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractdiagtype&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Recorded date (linkId 7114466839467)</span>
          diagGroup.item<b> as </b><span style="color: maroon">dateItem</span><b> where </b>(linkId = '7114466839467')<b> then</b><span style="color: navy"> {
    </span>        dateItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>condition.recordedDate = <span style="color: navy">(</span>ans.valueDate<span style="color: navy">)</span> <i>&quot;setrecordeddate&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractrecordeddate&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;createcondition&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;conditionentry&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}

    </span><span style="color: navy">// </span><span style="color: green">Group: Create Procedures from nested actes</span>
    <b>group </b>CreateProcedures<span style="color: navy">(</span><b>source</b> <span style="color: maroon">pmsiItem</span>, <b>target</b> <span style="color: maroon">patient</span><span style="color: navy"> : </span>Patient, <b>target</b> <span style="color: maroon">encounter</span><span style="color: navy"> : </span>Encounter, <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">Actes group (linkId 591926901726) - can repeat</span>
      pmsiItem.item<b> as </b><span style="color: maroon">acteGroup</span><b> where </b>(linkId = '591926901726')<span style="color: navy"><b> -&gt; </b></span>bundle.entry<b> as </b><span style="color: maroon">procedureEntry</span><b> then</b><span style="color: navy"> {
    </span>    acteGroup<span style="color: navy"><b> -&gt; </b></span>procedureEntry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Procedure'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">procedure</span><b> then</b><span style="color: navy"> {
    </span>      acteGroup<span style="color: navy"><b> -&gt; </b></span>procedure.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span> <i>&quot;procedureid&quot;</i><span style="color: navy">;</span>
          acteGroup<span style="color: navy"><b> -&gt; </b></span>procedure.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>        acteGroup<span style="color: navy"><b> -&gt; </b></span>meta.profile = <span style="color: blue">'https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMProcedure'</span> <i>&quot;procedureprofile&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;proceduremeta&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Link to patient</span>
          acteGroup<span style="color: navy"><b> -&gt; </b></span> procedure.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> patient.id<b> as </b><span style="color: maroon">patId</span><span style="color: navy">, </span> ref.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'Patient/'</span><span style="color: navy">, </span><span style="color: maroon">patId</span><span style="color: navy">)</span> <i>&quot;setsubject&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Link to encounter</span>
          acteGroup<span style="color: navy"><b> -&gt; </b></span> encounter.id<b> as </b><span style="color: maroon">encId</span><span style="color: navy">, </span> procedure.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">ref</span><span style="color: navy">, </span> ref.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'Encounter/'</span><span style="color: navy">, </span><span style="color: maroon">encId</span><span style="color: navy">)</span> <i>&quot;setencounter&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Acte code (linkId 7758110033600) - CCAM</span>
          acteGroup.item<b> as </b><span style="color: maroon">acteCodeItem</span><b> where </b>(linkId = '7758110033600')<b> then</b><span style="color: navy"> {
    </span>        acteCodeItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>procedure.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">code</span><b> then</b><span style="color: navy"> {
    </span>          ans<span style="color: navy"><b> -&gt; </b></span>code.coding = <span style="color: navy">(</span>ans.valueCoding<span style="color: navy">)</span> <i>&quot;setcoding&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setcode&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractactecode&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Date de l'acte (linkId 5066866286682)</span>
          acteGroup.item<b> as </b><span style="color: maroon">dateItem</span><b> where </b>(linkId = '5066866286682')<b> then</b><span style="color: navy"> {
    </span>        dateItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>procedure.performed = <span style="color: navy">(</span>ans.valueDateTime<span style="color: navy">)</span> <i>&quot;setperformed&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractperformeddate&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;createprocedure&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;procedureentry&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}

    </span><span style="color: navy">// </span><span style="color: green">Group: Create Medication Requests</span>
    <b>group </b>CreateMedicationRequests<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>QuestionnaireResponse, <b>target</b> <span style="color: maroon">patient</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: navy">// </span><span style="color: green">Exposition médicamenteuse (linkId 817801935685)</span>
      src.item<b> as </b><span style="color: maroon">medExpoGroup</span><b> where </b>(linkId = '817801935685')<b> then</b><span style="color: navy"> {
    </span>    <span style="color: navy">// </span><span style="color: green">Médicament prescrit (linkId 156631794800) - repeating</span>
        medExpoGroup.item<b> as </b><span style="color: maroon">prescribedGroup</span><b> where </b>(linkId = '156631794800')<span style="color: navy"><b> -&gt; </b></span>bundle.entry<b> as </b><span style="color: maroon">medReqEntry</span><b> then</b><span style="color: navy"> {
    </span>      prescribedGroup<span style="color: navy"><b> -&gt; </b></span>medReqEntry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'MedicationRequest'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">medReq</span><b> then</b><span style="color: navy"> {
    </span>        prescribedGroup<span style="color: navy"><b> -&gt; </b></span>medReq.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span> <i>&quot;medreqid&quot;</i><span style="color: navy">;</span>
            prescribedGroup<span style="color: navy"><b> -&gt; </b></span>medReq.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>          prescribedGroup<span style="color: navy"><b> -&gt; </b></span>meta.profile = <span style="color: blue">'https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMMedicationRequest'</span> <i>&quot;medreqprofile&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;medreqmeta&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">// </span><span style="color: green">Link to patient</span>
            prescribedGroup<span style="color: navy"><b> -&gt; </b></span> medReq.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> patient.id<b> as </b><span style="color: maroon">patId</span><span style="color: navy">, </span> ref.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'Patient/'</span><span style="color: navy">, </span><span style="color: maroon">patId</span><span style="color: navy">)</span> <i>&quot;setsubject&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">// </span><span style="color: green">Status and intent</span>
            prescribedGroup<span style="color: navy"><b> -&gt; </b></span>medReq.status = <span style="color: blue">'active'</span> <i>&quot;setstatus&quot;</i><span style="color: navy">;</span>
            prescribedGroup<span style="color: navy"><b> -&gt; </b></span>medReq.intent = <span style="color: blue">'order'</span> <i>&quot;setintent&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">// </span><span style="color: green">Create Medication resource and reference</span>
            prescribedGroup<span style="color: navy"><b> -&gt; </b></span>bundle.entry<b> as </b><span style="color: maroon">medEntry</span><b> then</b><span style="color: navy"> {
    </span>          prescribedGroup<span style="color: navy"><b> -&gt; </b></span>medEntry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Medication'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">medication</span><b> then</b><span style="color: navy"> {
    </span>            prescribedGroup<span style="color: navy"><b> -&gt; </b></span>medication.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span> <i>&quot;medid&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">// </span><span style="color: green">ATC code from nested items</span>
                prescribedGroup.item<b> as </b><span style="color: maroon">atcItem</span><b> where </b>(linkId.contains('ATC'))<b> then</b><span style="color: navy"> {
    </span>              atcItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>medication.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">code</span><b> then</b><span style="color: navy"> {
    </span>                ans<span style="color: navy"><b> -&gt; </b></span>code.coding = <span style="color: navy">(</span>ans.valueCoding<span style="color: navy">)</span> <i>&quot;setatccoding&quot;</i><span style="color: navy">;</span>
                  <span style="color: navy">}</span> <i>&quot;setmedcode&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;extractatc&quot;</i><span style="color: navy">;</span>
                prescribedGroup<span style="color: navy"><b> -&gt; </b></span> medication.id<b> as </b><span style="color: maroon">medId</span><span style="color: navy">, </span> medEntry.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">medId</span><span style="color: navy">)</span> <i>&quot;setfullUrl&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">// </span><span style="color: green">Link MedicationRequest to Medication</span>
                prescribedGroup<span style="color: navy"><b> -&gt; </b></span> medication.id<b> as </b><span style="color: maroon">medId</span><span style="color: navy">, </span> medReq.medication = <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 = <b>append</b><span style="color: navy">(</span><span style="color: blue">'Medication/'</span><span style="color: navy">, </span><span style="color: maroon">medId</span><span style="color: navy">)</span> <i>&quot;setmedicationreference&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;createmedication&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;medicationentry&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">// </span><span style="color: green">Dosage instructions</span>
            prescribedGroup<span style="color: navy"><b> -&gt; </b></span>medReq.dosageInstruction = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Dosage'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">dosage</span><b> then</b><span style="color: navy"> {
    </span>          <span style="color: navy">// </span><span style="color: green">Route</span>
              prescribedGroup.item<b> as </b><span style="color: maroon">routeItem</span><b> where </b>(linkId.contains('voie'))<b> then</b><span style="color: navy"> {
    </span>            routeItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>dosage.route = <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">route</span><b> then</b><span style="color: navy"> {
    </span>              ans<span style="color: navy"><b> -&gt; </b></span>route.coding = <span style="color: navy">(</span>ans.valueCoding<span style="color: navy">)</span> <i>&quot;setroutecoding&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;setroute&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;extractroute&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">// </span><span style="color: green">Timing</span>
              prescribedGroup.item<b> as </b><span style="color: maroon">timingItem</span><b> where </b>(linkId.contains('timing') or linkId.contains('fréquence'))<b> then</b><span style="color: navy"> {
    </span>            timingItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>dosage.timing = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Timing'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">timing</span><b> then</b><span style="color: navy"> {
    </span>              ans<span style="color: navy"><b> -&gt; </b></span>timing.repeat = <b>create</b><span style="color: navy">(</span><span style="color: blue">'TimingRepeat'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">repeat</span> <i>&quot;settiming&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;settimingstructure&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;extracttiming&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setdosage&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;createmedreq&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;medreqentry&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;processmedexpo&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}

    </span><span style="color: navy">// </span><span style="color: green">Group: Create Medication Administrations</span>
    <b>group </b>CreateMedicationAdministrations<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>QuestionnaireResponse, <b>target</b> <span style="color: maroon">patient</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: navy">// </span><span style="color: green">Exposition médicamenteuse (linkId 817801935685)</span>
      src.item<b> as </b><span style="color: maroon">medExpoGroup</span><b> where </b>(linkId = '817801935685')<b> then</b><span style="color: navy"> {
    </span>    <span style="color: navy">// </span><span style="color: green">Médicament administré (linkId 266852453304) - repeating</span>
        medExpoGroup.item<b> as </b><span style="color: maroon">adminGroup</span><b> where </b>(linkId = '266852453304')<span style="color: navy"><b> -&gt; </b></span>bundle.entry<b> as </b><span style="color: maroon">medAdminEntry</span><b> then</b><span style="color: navy"> {
    </span>      adminGroup<span style="color: navy"><b> -&gt; </b></span>medAdminEntry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'MedicationAdministration'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">medAdmin</span><b> then</b><span style="color: navy"> {
    </span>        adminGroup<span style="color: navy"><b> -&gt; </b></span>medAdmin.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span> <i>&quot;medadminid&quot;</i><span style="color: navy">;</span>
            adminGroup<span style="color: navy"><b> -&gt; </b></span>medAdmin.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>          adminGroup<span style="color: navy"><b> -&gt; </b></span>meta.profile = <span style="color: blue">'https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMMedicationAdministration'</span> <i>&quot;medadminprofile&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;medadminmeta&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">// </span><span style="color: green">Link to patient</span>
            adminGroup<span style="color: navy"><b> -&gt; </b></span> medAdmin.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> patient.id<b> as </b><span style="color: maroon">patId</span><span style="color: navy">, </span> ref.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'Patient/'</span><span style="color: navy">, </span><span style="color: maroon">patId</span><span style="color: navy">)</span> <i>&quot;setsubject&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">// </span><span style="color: green">Status</span>
            adminGroup<span style="color: navy"><b> -&gt; </b></span>medAdmin.status = <span style="color: blue">'completed'</span> <i>&quot;setstatus&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">// </span><span style="color: green">Create Medication resource and reference</span>
            adminGroup<span style="color: navy"><b> -&gt; </b></span>bundle.entry<b> as </b><span style="color: maroon">medEntry</span><b> then</b><span style="color: navy"> {
    </span>          adminGroup<span style="color: navy"><b> -&gt; </b></span>medEntry.resource = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Medication'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">medication</span><b> then</b><span style="color: navy"> {
    </span>            adminGroup<span style="color: navy"><b> -&gt; </b></span>medication.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span> <i>&quot;medid&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">// </span><span style="color: green">ATC code from nested items</span>
                adminGroup.item<b> as </b><span style="color: maroon">atcItem</span><b> where </b>(linkId.contains('ATC'))<b> then</b><span style="color: navy"> {
    </span>              atcItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>medication.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">code</span><b> then</b><span style="color: navy"> {
    </span>                ans<span style="color: navy"><b> -&gt; </b></span>code.coding = <span style="color: navy">(</span>ans.valueCoding<span style="color: navy">)</span> <i>&quot;setatccoding&quot;</i><span style="color: navy">;</span>
                  <span style="color: navy">}</span> <i>&quot;setmedcode&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;extractatc&quot;</i><span style="color: navy">;</span>
                adminGroup<span style="color: navy"><b> -&gt; </b></span> medication.id<b> as </b><span style="color: maroon">medId</span><span style="color: navy">, </span> medEntry.fullUrl = <b>append</b><span style="color: navy">(</span><span style="color: blue">'Medication/'</span><span style="color: navy">, </span><span style="color: maroon">medId</span><span style="color: navy">)</span> <i>&quot;setfullUrl&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">// </span><span style="color: green">Link MedicationAdministration to Medication</span>
                adminGroup<span style="color: navy"><b> -&gt; </b></span> medication.id<b> as </b><span style="color: maroon">medId</span><span style="color: navy">, </span> medAdmin.medication = <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 = <b>append</b><span style="color: navy">(</span><span style="color: blue">'urn:uuid:'</span><span style="color: navy">, </span><span style="color: maroon">medId</span><span style="color: navy">)</span> <i>&quot;setmedicationreference&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;createmedication&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;medicationentry&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">// </span><span style="color: green">Effective period</span>
            adminGroup<span style="color: navy"><b> -&gt; </b></span>medAdmin.effective = <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><span style="color: navy"> {
    </span>          adminGroup.item<b> as </b><span style="color: maroon">startItem</span><b> where </b>(linkId.contains('début'))<b> then</b><span style="color: navy"> {
    </span>            startItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>period.start = <span style="color: navy">(</span>ans.valueDateTime<span style="color: navy">)</span> <i>&quot;setstart&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;extractstart&quot;</i><span style="color: navy">;</span>
              adminGroup.item<b> as </b><span style="color: maroon">endItem</span><b> where </b>(linkId.contains('fin'))<b> then</b><span style="color: navy"> {
    </span>            endItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>period.end = <span style="color: navy">(</span>ans.valueDateTime<span style="color: navy">)</span> <i>&quot;setend&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;extractend&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;seteffective&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">// </span><span style="color: green">Dosage</span>
            adminGroup<span style="color: navy"><b> -&gt; </b></span>medAdmin.dosage = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Dosage'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">dosage</span><b> then</b><span style="color: navy"> {
    </span>          <span style="color: navy">// </span><span style="color: green">Route</span>
              adminGroup.item<b> as </b><span style="color: maroon">routeItem</span><b> where </b>(linkId.contains('voie'))<b> then</b><span style="color: navy"> {
    </span>            routeItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>dosage.route = <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">route</span><b> then</b><span style="color: navy"> {
    </span>              ans<span style="color: navy"><b> -&gt; </b></span>route.coding = <span style="color: navy">(</span>ans.valueCoding<span style="color: navy">)</span> <i>&quot;setroutecoding&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;setroute&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;extractroute&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">// </span><span style="color: green">Dose</span>
              adminGroup.item<b> as </b><span style="color: maroon">doseItem</span><b> where </b>(linkId.contains('dose'))<b> then</b><span style="color: navy"> {
    </span>            doseItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>dosage.dose = <span style="color: navy">(</span>ans.valueQuantity<span style="color: navy">)</span> <i>&quot;setdose&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;extractdose&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setdosage&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;createmedadmin&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;medadminentry&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;processmedexpoadmin&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}

    </span><span style="color: navy">// </span><span style="color: green">Group: Create Vital Sign Observations</span>
    <b>group </b>CreateVitalSignObservations<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>QuestionnaireResponse, <b>target</b> <span style="color: maroon">patient</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: navy">// </span><span style="color: green">Examen clinique (linkId 214880328197)</span>
      src.item<b> as </b><span style="color: maroon">examGroup</span><b> where </b>(linkId = '214880328197')<b> then</b><span style="color: navy"> {
    </span>    <span style="color: navy">// </span><span style="color: green">Dossier de soins (linkId 305831246173) - repeating</span>
        examGroup.item<b> as </b><span style="color: maroon">dossierGroup</span><b> where </b>(linkId = '305831246173')<b> then</b><span style="color: navy"> {
    </span>      <span style="color: navy">// </span><span style="color: green">Height (linkId 4846902346416)</span>
          dossierGroup.item<b> as </b><span style="color: maroon">heightItem</span><b> where </b>(linkId = '4846902346416')<b> then</b><span style="color: navy"> {
    </span>        heightItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>bundle.entry<b> as </b><span style="color: maroon">obsEntry</span><b> then</b><span style="color: navy"> {
    </span>          ans<span style="color: navy"><b> -&gt; </b></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">obs</span><b> then</b><span style="color: navy"> {
    </span>            ans<span style="color: navy"><b> -&gt; </b></span>obs.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span> <i>&quot;obsid&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span> obs.id<b> as </b><span style="color: maroon">obsId</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">obsId</span><span style="color: navy">)</span> <i>&quot;setfullUrl&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>obs.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>              ans<span style="color: navy"><b> -&gt; </b></span>meta.profile = <span style="color: blue">'https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMObservationBodyHeight'</span> <i>&quot;obsprofile&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;obsmeta&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>obs.status = <span style="color: blue">'final'</span> <i>&quot;obsstatus&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>obs.category = <b>cc</b><span style="color: navy">(</span><span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span><span style="color: navy">, </span><span style="color: blue">'vital-signs'</span><span style="color: navy">)</span> <i>&quot;obscategory&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>obs.code = <b>cc</b><span style="color: navy">(</span><span style="color: blue">'http://loinc.org'</span><span style="color: navy">, </span><span style="color: blue">'8302-2'</span><span style="color: navy">, </span><span style="color: blue">'Body height'</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">Link to patient</span>
                ans<span style="color: navy"><b> -&gt; </b></span> obs.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> patient.id<b> as </b><span style="color: maroon">patId</span><span style="color: navy">, </span> ref.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'Patient/'</span><span style="color: navy">, </span><span style="color: maroon">patId</span><span style="color: navy">)</span> <i>&quot;setsubject&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">// </span><span style="color: green">Value</span>
                ans<span style="color: navy"><b> -&gt; </b></span>obs.value = <span style="color: navy">(</span>ans.valueQuantity<span style="color: navy">)</span> <i>&quot;setvalue&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">// </span><span style="color: green">Effective date from nested item</span>
                heightItem.item<b> as </b><span style="color: maroon">dateItem</span><b> where </b>(linkId.contains('Date'))<b> then</b><span style="color: navy"> {
    </span>              dateItem.answer<b> as </b><span style="color: maroon">dateAns</span><span style="color: navy"><b> -&gt; </b></span>obs.effective = <span style="color: navy">(</span>dateAns.valueDate<span style="color: navy">)</span> <i>&quot;seteffective&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;extracteffective&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;createheightobs&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;heightobsentry&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractheight&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Weight (linkId 451513217936)</span>
          dossierGroup.item<b> as </b><span style="color: maroon">weightItem</span><b> where </b>(linkId = '451513217936')<b> then</b><span style="color: navy"> {
    </span>        weightItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>bundle.entry<b> as </b><span style="color: maroon">obsEntry</span><b> then</b><span style="color: navy"> {
    </span>          ans<span style="color: navy"><b> -&gt; </b></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">obs</span><b> then</b><span style="color: navy"> {
    </span>            ans<span style="color: navy"><b> -&gt; </b></span>obs.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span> <i>&quot;obsid&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span> obs.id<b> as </b><span style="color: maroon">obsId</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">obsId</span><span style="color: navy">)</span> <i>&quot;setfullUrl&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>obs.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>              ans<span style="color: navy"><b> -&gt; </b></span>meta.profile = <span style="color: blue">'https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMObservationBodyWeight'</span> <i>&quot;obsprofile&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;obsmeta&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>obs.status = <span style="color: blue">'final'</span> <i>&quot;obsstatus&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>obs.category = <b>cc</b><span style="color: navy">(</span><span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span><span style="color: navy">, </span><span style="color: blue">'vital-signs'</span><span style="color: navy">)</span> <i>&quot;obscategory&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>obs.code = <b>cc</b><span style="color: navy">(</span><span style="color: blue">'http://loinc.org'</span><span style="color: navy">, </span><span style="color: blue">'29463-7'</span><span style="color: navy">, </span><span style="color: blue">'Body weight'</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">Link to patient</span>
                ans<span style="color: navy"><b> -&gt; </b></span> obs.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> patient.id<b> as </b><span style="color: maroon">patId</span><span style="color: navy">, </span> ref.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'Patient/'</span><span style="color: navy">, </span><span style="color: maroon">patId</span><span style="color: navy">)</span> <i>&quot;setsubject&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">// </span><span style="color: green">Value</span>
                ans<span style="color: navy"><b> -&gt; </b></span>obs.value = <span style="color: navy">(</span>ans.valueQuantity<span style="color: navy">)</span> <i>&quot;setvalue&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">// </span><span style="color: green">Effective date from nested item</span>
                weightItem.item<b> as </b><span style="color: maroon">dateItem</span><b> where </b>(linkId.contains('Date'))<b> then</b><span style="color: navy"> {
    </span>              dateItem.answer<b> as </b><span style="color: maroon">dateAns</span><span style="color: navy"><b> -&gt; </b></span>obs.effective = <span style="color: navy">(</span>dateAns.valueDate<span style="color: navy">)</span> <i>&quot;seteffective&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;extracteffective&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;createweightobs&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;weightobsentry&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractweight&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Blood Pressure - need both systolic and diastolic</span>
          dossierGroup.item<b> as </b><span style="color: maroon">sysItem</span><b> where </b>(linkId = '4160905247955')<b> then</b><span style="color: navy"> {
    </span>        sysItem.answer<b> as </b><span style="color: maroon">sysAns</span><b> then</b><span style="color: navy"> {
    </span>          dossierGroup.item<b> as </b><span style="color: maroon">diaItem</span><b> where </b>(linkId = '848797127998')<b> then</b><span style="color: navy"> {
    </span>            diaItem.answer<b> as </b><span style="color: maroon">diaAns</span><span style="color: navy"><b> -&gt; </b></span>bundle.entry<b> as </b><span style="color: maroon">obsEntry</span><b> then</b><span style="color: navy"> {
    </span>              sysAns<span style="color: navy"><b> -&gt; </b></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">obs</span><b> then</b><span style="color: navy"> {
    </span>                sysAns<span style="color: navy"><b> -&gt; </b></span>obs.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span> <i>&quot;obsid&quot;</i><span style="color: navy">;</span>
                    sysAns<span style="color: navy"><b> -&gt; </b></span> obs.id<b> as </b><span style="color: maroon">obsId</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">obsId</span><span style="color: navy">)</span> <i>&quot;setfullUrl&quot;</i><span style="color: navy">;</span>
                    sysAns<span style="color: navy"><b> -&gt; </b></span>obs.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>                  sysAns<span style="color: navy"><b> -&gt; </b></span>meta.profile = <span style="color: blue">'https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMObservationBloodPressure'</span> <i>&quot;obsprofile&quot;</i><span style="color: navy">;</span>
                    <span style="color: navy">}</span> <i>&quot;obsmeta&quot;</i><span style="color: navy">;</span>
                    sysAns<span style="color: navy"><b> -&gt; </b></span>obs.status = <span style="color: blue">'final'</span> <i>&quot;obsstatus&quot;</i><span style="color: navy">;</span>
                    sysAns<span style="color: navy"><b> -&gt; </b></span>obs.category = <b>cc</b><span style="color: navy">(</span><span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span><span style="color: navy">, </span><span style="color: blue">'vital-signs'</span><span style="color: navy">)</span> <i>&quot;obscategory&quot;</i><span style="color: navy">;</span>
                    sysAns<span style="color: navy"><b> -&gt; </b></span>obs.code = <b>cc</b><span style="color: navy">(</span><span style="color: blue">'http://loinc.org'</span><span style="color: navy">, </span><span style="color: blue">'85354-9'</span><span style="color: navy">, </span><span style="color: blue">'Blood pressure panel'</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">Link to patient</span>
                    sysAns<span style="color: navy"><b> -&gt; </b></span> obs.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> patient.id<b> as </b><span style="color: maroon">patId</span><span style="color: navy">, </span> ref.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'Patient/'</span><span style="color: navy">, </span><span style="color: maroon">patId</span><span style="color: navy">)</span> <i>&quot;setsubject&quot;</i><span style="color: navy">;</span>
                    <span style="color: navy">// </span><span style="color: green">Systolic component</span>
                    sysAns<span style="color: navy"><b> -&gt; </b></span>obs.component = <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">sysComp</span><b> then</b><span style="color: navy"> {
    </span>                  sysAns<span style="color: navy"><b> -&gt; </b></span>sysComp.code = <b>cc</b><span style="color: navy">(</span><span style="color: blue">'http://loinc.org'</span><span style="color: navy">, </span><span style="color: blue">'8480-6'</span><span style="color: navy">, </span><span style="color: blue">'Systolic blood pressure'</span><span style="color: navy">)</span> <i>&quot;syscode&quot;</i><span style="color: navy">;</span>
                      sysAns<span style="color: navy"><b> -&gt; </b></span>sysComp.value = <span style="color: navy">(</span>sysAns.valueQuantity<span style="color: navy">)</span> <i>&quot;sysvalue&quot;</i><span style="color: navy">;</span>
                    <span style="color: navy">}</span> <i>&quot;setsystolic&quot;</i><span style="color: navy">;</span>
                    <span style="color: navy">// </span><span style="color: green">Diastolic component</span>
                    diaAns<span style="color: navy"><b> -&gt; </b></span>obs.component = <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">diaComp</span><b> then</b><span style="color: navy"> {
    </span>                  diaAns<span style="color: navy"><b> -&gt; </b></span>diaComp.code = <b>cc</b><span style="color: navy">(</span><span style="color: blue">'http://loinc.org'</span><span style="color: navy">, </span><span style="color: blue">'8462-4'</span><span style="color: navy">, </span><span style="color: blue">'Diastolic blood pressure'</span><span style="color: navy">)</span> <i>&quot;diacode&quot;</i><span style="color: navy">;</span>
                      diaAns<span style="color: navy"><b> -&gt; </b></span>diaComp.value = <span style="color: navy">(</span>diaAns.valueQuantity<span style="color: navy">)</span> <i>&quot;diavalue&quot;</i><span style="color: navy">;</span>
                    <span style="color: navy">}</span> <i>&quot;setdiastolic&quot;</i><span style="color: navy">;</span>
                    <span style="color: navy">// </span><span style="color: green">Effective date from nested item</span>
                    sysItem.item<b> as </b><span style="color: maroon">dateItem</span><b> where </b>(linkId.contains('Date'))<b> then</b><span style="color: navy"> {
    </span>                  dateItem.answer<b> as </b><span style="color: maroon">dateAns</span><span style="color: navy"><b> -&gt; </b></span>obs.effective = <span style="color: navy">(</span>dateAns.valueDate<span style="color: navy">)</span> <i>&quot;seteffective&quot;</i><span style="color: navy">;</span>
                    <span style="color: navy">}</span> <i>&quot;extracteffective&quot;</i><span style="color: navy">;</span>
                  <span style="color: navy">}</span> <i>&quot;createbpobs&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;bpobsentr&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;extractdiastolic&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;processsystolic&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractbloodpressure&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;processdossier&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;processexam&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}

    </span><span style="color: navy">// </span><span style="color: green">Group: Create Laboratory Observations</span>
    <b>group </b>CreateLaboratoryObservations<span style="color: navy">(</span><b>source</b> <span style="color: maroon">src</span><span style="color: navy"> : </span>QuestionnaireResponse, <b>target</b> <span style="color: maroon">patient</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: navy">// </span><span style="color: green">Biologie group (linkId 7702944131447)</span>
      src.item<b> as </b><span style="color: maroon">bioGroup</span><b> where </b>(linkId = '7702944131447')<b> then</b><span style="color: navy"> {
    </span>    <span style="color: navy">// </span><span style="color: green">Fonction rénale (linkId 5241323453538)</span>
        bioGroup.item<b> as </b><span style="color: maroon">renalGroup</span><b> where </b>(linkId = '5241323453538')<b> then</b><span style="color: navy"> {
    </span>      <span style="color: navy">// </span><span style="color: green">Urée (linkId 7169026818760)</span>
          renalGroup.item<b> as </b><span style="color: maroon">ureaItem</span><b> where </b>(linkId = '7169026818760')<b> then</b><span style="color: navy"> {
    </span>        ureaItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">ureaItem</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;createureaobs&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extracturea&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Créatininémie (linkId 500408205043)</span>
          renalGroup.item<b> as </b><span style="color: maroon">creatItem</span><b> where </b>(linkId = '500408205043')<b> then</b><span style="color: navy"> {
    </span>        creatItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">creatItem</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;createcreatobs&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractcreat&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">DFG (linkId 786621340679)</span>
          renalGroup.item<b> as </b><span style="color: maroon">dfgItem</span><b> where </b>(linkId = '786621340679')<b> then</b><span style="color: navy"> {
    </span>        dfgItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">dfgItem</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;createdfgobs&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractdfg&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;processrenal&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">Hémogramme (linkId 419282985970)</span>
        bioGroup.item<b> as </b><span style="color: maroon">hemoGroup</span><b> where </b>(linkId = '419282985970')<b> then</b><span style="color: navy"> {
    </span>      <span style="color: navy">// </span><span style="color: green">Leucocytes (linkId 210077225604)</span>
          hemoGroup.item<b> as </b><span style="color: maroon">leukoItem</span><b> where </b>(linkId = '210077225604')<b> then</b><span style="color: navy"> {
    </span>        leukoItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">leukoItem</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;createleukoobs&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractleuko&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Hémoglobine (linkId 304159088493)</span>
          hemoGroup.item<b> as </b><span style="color: maroon">hemoItem</span><b> where </b>(linkId = '304159088493')<b> then</b><span style="color: navy"> {
    </span>        hemoItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">hemoItem</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;createhemoobs&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extracthemo&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Hématocrite (linkId 5687959006070)</span>
          hemoGroup.item<b> as </b><span style="color: maroon">hematItem</span><b> where </b>(linkId = '5687959006070')<b> then</b><span style="color: navy"> {
    </span>        hematItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">hematItem</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;createhematobs&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extracthemat&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Erythrocytes (linkId 8697447896867)</span>
          hemoGroup.item<b> as </b><span style="color: maroon">eryItem</span><b> where </b>(linkId = '8697447896867')<b> then</b><span style="color: navy"> {
    </span>        eryItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">eryItem</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;createeryobs&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractery&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">VGM (linkId 5584978899134)</span>
          hemoGroup.item<b> as </b><span style="color: maroon">vgmItem</span><b> where </b>(linkId = '5584978899134')<b> then</b><span style="color: navy"> {
    </span>        vgmItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">vgmItem</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;createvgmobs&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractvgm&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Plaquettes (linkId 2881119993430)</span>
          hemoGroup.item<b> as </b><span style="color: maroon">platItem</span><b> where </b>(linkId = '2881119993430')<b> then</b><span style="color: navy"> {
    </span>        platItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">platItem</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;createplatobs&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractplat&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Neutrophiles (linkId 7408951746270)</span>
          hemoGroup.item<b> as </b><span style="color: maroon">neutItem</span><b> where </b>(linkId = '7408951746270')<b> then</b><span style="color: navy"> {
    </span>        neutItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">neutItem</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;createneutobs&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractneut&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Lymphocytes (linkId 809808816195)</span>
          hemoGroup.item<b> as </b><span style="color: maroon">lymphItem</span><b> where </b>(linkId = '809808816195')<b> then</b><span style="color: navy"> {
    </span>        lymphItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">lymphItem</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;createlymphobs&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractlymph&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Eosinophiles (linkId 6451887990893)</span>
          hemoGroup.item<b> as </b><span style="color: maroon">eosiItem</span><b> where </b>(linkId = '6451887990893')<b> then</b><span style="color: navy"> {
    </span>        eosiItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">eosiItem</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;createeosiobs&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extracteosi&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Monocytes (linkId 7935935816936)</span>
          hemoGroup.item<b> as </b><span style="color: maroon">monoItem</span><b> where </b>(linkId = '7935935816936')<b> then</b><span style="color: navy"> {
    </span>        monoItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">monoItem</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;createmonoobs&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractmono&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">TP (linkId 2055949655770)</span>
          hemoGroup.item<b> as </b><span style="color: maroon">tpItem</span><b> where </b>(linkId = '2055949655770')<b> then</b><span style="color: navy"> {
    </span>        tpItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">tpItem</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;createtpobs&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extracttp&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">TCA (linkId 2527095476817)</span>
          hemoGroup.item<b> as </b><span style="color: maroon">tcaItem</span><b> where </b>(linkId = '2527095476817')<b> then</b><span style="color: navy"> {
    </span>        tcaItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">tcaItem</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;createtcaobs&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extracttca&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;processhemo&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">Bilan hépatique (linkId 3893612773040)</span>
        bioGroup.item<b> as </b><span style="color: maroon">liverGroup</span><b> where </b>(linkId = '3893612773040')<b> then</b><span style="color: navy"> {
    </span>      <span style="color: navy">// </span><span style="color: green">ASAT (linkId 3028330976100)</span>
          liverGroup.item<b> as </b><span style="color: maroon">asatItem</span><b> where </b>(linkId = '3028330976100')<b> then</b><span style="color: navy"> {
    </span>        asatItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">asatItem</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;createasatobs&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractasat&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">ALAT (linkId 8486813893880)</span>
          liverGroup.item<b> as </b><span style="color: maroon">alatItem</span><b> where </b>(linkId = '8486813893880')<b> then</b><span style="color: navy"> {
    </span>        alatItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">alatItem</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;createalatobs&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractalat&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">GGT (linkId 3663296044037)</span>
          liverGroup.item<b> as </b><span style="color: maroon">ggtItem</span><b> where </b>(linkId = '3663296044037')<b> then</b><span style="color: navy"> {
    </span>        ggtItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">ggtItem</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;createggtobs&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractggt&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">PAL (linkId 2690026606933)</span>
          liverGroup.item<b> as </b><span style="color: maroon">palItem</span><b> where </b>(linkId = '2690026606933')<b> then</b><span style="color: navy"> {
    </span>        palItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">palItem</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;createpalobs&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractpal&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Bilirubine totale (linkId 9068831071023)</span>
          liverGroup.item<b> as </b><span style="color: maroon">bilTotItem</span><b> where </b>(linkId = '9068831071023')<b> then</b><span style="color: navy"> {
    </span>        bilTotItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">bilTotItem</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;createbiltotobs&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractbiltot&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Bilirubine conjuguée (linkId 8893717988787)</span>
          liverGroup.item<b> as </b><span style="color: maroon">bilConjItem</span><b> where </b>(linkId = '8893717988787')<b> then</b><span style="color: navy"> {
    </span>        bilConjItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">bilConjItem</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;createbilconjobs&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractbilconj&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;processliver&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">// </span><span style="color: green">Métabolisme glucidique (linkId 8929068894076)</span>
        bioGroup.item<b> as </b><span style="color: maroon">glucoseGroup</span><b> where </b>(linkId = '8929068894076')<b> then</b><span style="color: navy"> {
    </span>      <span style="color: navy">// </span><span style="color: green">Glycémie à jeun (linkId 8193929027997)</span>
          glucoseGroup.item<b> as </b><span style="color: maroon">glycItem</span><b> where </b>(linkId = '8193929027997')<b> then</b><span style="color: navy"> {
    </span>        glycItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">glycItem</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;createglycobs&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractglyc&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">HbA1c (linkId 7063892830923)</span>
          glucoseGroup.item<b> as </b><span style="color: maroon">hba1cItem</span><b> where </b>(linkId = '7063892830923')<b> then</b><span style="color: navy"> {
    </span>        hba1cItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">hba1cItem</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;createhba1cobs&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extracthba1c&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;processglucose&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;processbiology&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}

    </span><span style="color: navy">// </span><span style="color: green">Helper: Create a single Laboratory Observation</span>
    <b>group </b>CreateLabObservation<span style="color: navy">(</span><b>source</b> <span style="color: maroon">ans</span>, <b>source</b> <span style="color: maroon">parentItem</span>, <b>target</b> <span style="color: maroon">patient</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>  ans<span style="color: navy"><b> -&gt; </b></span>bundle.entry<b> as </b><span style="color: maroon">obsEntry</span><b> then</b><span style="color: navy"> {
    </span>    ans<span style="color: navy"><b> -&gt; </b></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">obs</span><b> then</b><span style="color: navy"> {
    </span>      ans<span style="color: navy"><b> -&gt; </b></span>obs.id = <b>uuid</b><span style="color: navy">(</span><span style="color: navy">)</span> <i>&quot;obsid&quot;</i><span style="color: navy">;</span>
          ans<span style="color: navy"><b> -&gt; </b></span> obs.id<b> as </b><span style="color: maroon">obsId</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">obsId</span><span style="color: navy">)</span> <i>&quot;setfullUrl&quot;</i><span style="color: navy">;</span>
          ans<span style="color: navy"><b> -&gt; </b></span>obs.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>        ans<span style="color: navy"><b> -&gt; </b></span>meta.profile = <span style="color: blue">'https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/dm-observation-laboratory-generic'</span> <i>&quot;obsprofile&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;obsmeta&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Status</span>
          ans<span style="color: navy"><b> -&gt; </b></span>obs.status = <span style="color: blue">'final'</span> <i>&quot;obsstatus&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Category</span>
          ans<span style="color: navy"><b> -&gt; </b></span>obs.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">cat</span><b> then</b><span style="color: navy"> {
    </span>        ans<span style="color: navy"><b> -&gt; </b></span>cat.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>          ans<span style="color: navy"><b> -&gt; </b></span>coding.system = <span style="color: blue">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;catsystem&quot;</i><span style="color: navy">;</span>
              ans<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'laboratory'</span> <i>&quot;catcode&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setcategorycoding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;setcategory&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Link to patient</span>
          ans<span style="color: navy"><b> -&gt; </b></span> obs.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> patient.id<b> as </b><span style="color: maroon">patId</span><span style="color: navy">, </span> ref.reference = <b>append</b><span style="color: navy">(</span><span style="color: blue">'Patient/'</span><span style="color: navy">, </span><span style="color: maroon">patId</span><span style="color: navy">)</span> <i>&quot;setsubject&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Value as Quantity</span>
          ans<span style="color: navy"><b> -&gt; </b></span>obs.value = <span style="color: navy">(</span>ans.valueQuantity<span style="color: navy">)</span> <i>&quot;setvalue&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">Extract nested items - LOINC code, effective date, status, reference ranges</span>
          parentItem.item<b> as </b><span style="color: maroon">loincItem</span><b> where </b>(linkId.contains('code loinc'))<b> then</b><span style="color: navy"> {
    </span>        loincItem.answer<b> as </b><span style="color: maroon">loincAns</span><span style="color: navy"><b> -&gt; </b></span>obs.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">code</span><b> then</b><span style="color: navy"> {
    </span>          loincAns<span style="color: navy"><b> -&gt; </b></span>code.coding = <span style="color: navy">(</span>loincAns.valueCoding<span style="color: navy">)</span> <i>&quot;setloinccoding&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setcode&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractloinc&quot;</i><span style="color: navy">;</span>
          parentItem.item<b> as </b><span style="color: maroon">dateItem</span><b> where </b>(linkId.contains('Date et heure du prélèvement'))<b> then</b><span style="color: navy"> {
    </span>        dateItem.answer<b> as </b><span style="color: maroon">dateAns</span><span style="color: navy"><b> -&gt; </b></span>obs.effective = <span style="color: navy">(</span>dateAns.valueDateTime<span style="color: navy">)</span> <i>&quot;seteffective&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extracteffective&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;createobs&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;obsentry&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}

    </span></pre></div>
      </text>
      <url value="https://interop.aphp.fr/ig/fhir/dm/StructureMap/Q2FSL"/>
      <version value="0.1.0"/>
      <name value="Q2FSL"/>
      <title
             value="Transforms QuestionnaireResponse based on Questionnaire Usage Variables socles into FHIR resources conforming to DM profiles"/>
      <status value="draft"/>
      <date value="2026-04-16T14:35:38+00:00"/>
      <publisher value="AP-HP"/>
      <contact>
        <name value="AP-HP"/>
        <telecom>
          <system value="url"/>
          <value value="https://aphp.fr"/>
        </telecom>
      </contact>
      <description
                   value="Transforms QuestionnaireResponse based on Questionnaire Usage Variables socles into FHIR resources conforming to DM profiles"/>
      <jurisdiction>
        <coding>
          <system value="urn:iso:std:iso:3166"/>
          <code value="FR"/>
        </coding>
      </jurisdiction>
      <structure>
        <url
             value="http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse"/>
        <mode value="source"/>
        <alias value="QuestionnaireResponse"/>
      </structure>
      <structure>
        <url value="http://hl7.org/fhir/StructureDefinition/Bundle"/>
        <mode value="target"/>
        <alias value="Bundle"/>
      </structure>
      <group>
        <name value="QuestionnaireResponseToBundle"/>
        <typeMode value="none"/>
        <documentation
                       value="Main entry point: Transform QuestionnaireResponse to Bundle"/>
        <input>
          <name value="src"/>
          <type value="QuestionnaireResponse"/>
          <mode value="source"/>
        </input>
        <input>
          <name value="bundle"/>
          <type value="Bundle"/>
          <mode value="target"/>
        </input>
        <rule>
          <name value="bundleid"/>
          <source>
            <context value="src"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="id"/>
            <transform value="uuid"/>
          </target>
        </rule>
        <rule>
          <name value="bundletype"/>
          <source>
            <context value="src"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="type"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="collection"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="setTimestamp"/>
          <source>
            <context value="src"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="timestamp"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="now()"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="patiententry"/>
          <source>
            <context value="src"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="patientEntry"/>
          </target>
          <rule>
            <name value="createpatientresource"/>
            <source>
              <context value="src"/>
            </source>
            <target>
              <context value="patientEntry"/>
              <contextType value="variable"/>
              <element value="resource"/>
              <variable value="patient"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Patient"/>
              </parameter>
            </target>
            <rule>
              <name value="createpatient"/>
              <source>
                <context value="src"/>
              </source>
              <dependent>
                <name value="CreatePatient"/>
                <variable value="src"/>
                <variable value="patient"/>
              </dependent>
            </rule>
            <rule>
              <name value="setfullUrl"/>
              <source>
                <context value="src"/>
              </source>
              <target>
                <context value="patient"/>
                <contextType value="variable"/>
                <element value="id"/>
                <variable value="patientId"/>
              </target>
              <target>
                <context value="patientEntry"/>
                <contextType value="variable"/>
                <element value="fullUrl"/>
                <transform value="append"/>
                <parameter>
                  <valueString value="urn:uuid:"/>
                </parameter>
                <parameter>
                  <valueId value="patientId"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="createencounters"/>
              <source>
                <context value="src"/>
              </source>
              <dependent>
                <name value="CreateEncounters"/>
                <variable value="src"/>
                <variable value="patient"/>
                <variable value="bundle"/>
              </dependent>
            </rule>
            <rule>
              <name value="createlabobservations"/>
              <source>
                <context value="src"/>
              </source>
              <dependent>
                <name value="CreateLaboratoryObservations"/>
                <variable value="src"/>
                <variable value="patient"/>
                <variable value="bundle"/>
              </dependent>
            </rule>
            <rule>
              <name value="createmedicationrequests"/>
              <source>
                <context value="src"/>
              </source>
              <dependent>
                <name value="CreateMedicationRequests"/>
                <variable value="src"/>
                <variable value="patient"/>
                <variable value="bundle"/>
              </dependent>
            </rule>
            <rule>
              <name value="createmedicationadministrations"/>
              <source>
                <context value="src"/>
              </source>
              <dependent>
                <name value="CreateMedicationAdministrations"/>
                <variable value="src"/>
                <variable value="patient"/>
                <variable value="bundle"/>
              </dependent>
            </rule>
            <rule>
              <name value="createvitalsigns"/>
              <source>
                <context value="src"/>
              </source>
              <dependent>
                <name value="CreateVitalSignObservations"/>
                <variable value="src"/>
                <variable value="patient"/>
                <variable value="bundle"/>
              </dependent>
            </rule>
          </rule>
        </rule>
      </group>
      <group>
        <name value="CreatePatient"/>
        <typeMode value="none"/>
        <documentation value="Group: Create Patient from QuestionnaireResponse"/>
        <input>
          <name value="src"/>
          <type value="QuestionnaireResponse"/>
          <mode value="source"/>
        </input>
        <input>
          <name value="patient"/>
          <type value="Patient"/>
          <mode value="target"/>
        </input>
        <rule>
          <name value="patientid"/>
          <source>
            <context value="src"/>
          </source>
          <target>
            <context value="patient"/>
            <contextType value="variable"/>
            <element value="id"/>
            <transform value="uuid"/>
          </target>
        </rule>
        <rule>
          <name value="patientmeta"/>
          <source>
            <context value="src"/>
          </source>
          <target>
            <context value="patient"/>
            <contextType value="variable"/>
            <element value="meta"/>
            <variable value="meta"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Meta"/>
            </parameter>
          </target>
          <rule>
            <name value="patientprofile"/>
            <source>
              <context value="src"/>
            </source>
            <target>
              <context value="meta"/>
              <contextType value="variable"/>
              <element value="profile"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMPatient"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="processsociodemographics"/>
          <source>
            <context value="src"/>
            <element value="item"/>
            <variable value="socioDemo"/>
            <condition value="(linkId = '4647259356106')"/>
          </source>
          <rule>
            <name value="processidentity"/>
            <source>
              <context value="socioDemo"/>
              <element value="item"/>
              <variable value="identity"/>
              <condition value="(linkId = '2958000860428')"/>
            </source>
            <rule>
              <name value="setname"/>
              <source>
                <context value="identity"/>
              </source>
              <target>
                <context value="patient"/>
                <contextType value="variable"/>
                <element value="name"/>
                <variable value="name"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="HumanName"/>
                </parameter>
              </target>
              <rule>
                <name value="extractfamily"/>
                <source>
                  <context value="identity"/>
                  <element value="item"/>
                  <variable value="familyItem"/>
                  <condition value="(linkId = '8605698058770')"/>
                </source>
                <rule>
                  <name value="setfamily"/>
                  <source>
                    <context value="familyItem"/>
                    <element value="answer"/>
                    <variable value="ans"/>
                  </source>
                  <target>
                    <context value="name"/>
                    <contextType value="variable"/>
                    <element value="family"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="ans.valueString"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="extractgiven"/>
                <source>
                  <context value="identity"/>
                  <element value="item"/>
                  <variable value="givenItem"/>
                  <condition value="(linkId = '6214879623503')"/>
                </source>
                <rule>
                  <name value="setgiven"/>
                  <source>
                    <context value="givenItem"/>
                    <element value="answer"/>
                    <variable value="ans"/>
                  </source>
                  <target>
                    <context value="name"/>
                    <contextType value="variable"/>
                    <element value="given"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="ans.valueString"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="extractnir"/>
              <source>
                <context value="identity"/>
                <element value="item"/>
                <variable value="nirItem"/>
                <condition value="(linkId = '5711960356160')"/>
              </source>
              <rule>
                <name value="setnir"/>
                <source>
                  <context value="nirItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="patient"/>
                  <contextType value="variable"/>
                  <element value="identifier"/>
                  <variable value="nir"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="Identifier"/>
                  </parameter>
                </target>
                <rule>
                  <name value="nirsystem"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="nir"/>
                    <contextType value="variable"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="urn:oid:1.2.250.1.213.1.4.8"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="nirvalue"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="nir"/>
                    <contextType value="variable"/>
                    <element value="value"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="ans.valueString"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="nirtype"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="nir"/>
                    <contextType value="variable"/>
                    <element value="type"/>
                    <transform value="cc"/>
                    <parameter>
                      <valueString
                                   value="http://interopsante.org/fhir/CodeSystem/fr-v2-0203"/>
                    </parameter>
                    <parameter>
                      <valueString value="NIR"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="extractins"/>
              <source>
                <context value="identity"/>
                <element value="item"/>
                <variable value="insItem"/>
                <condition value="(linkId = '3764723550987')"/>
              </source>
              <rule>
                <name value="setins"/>
                <source>
                  <context value="insItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="patient"/>
                  <contextType value="variable"/>
                  <element value="identifier"/>
                  <variable value="ins"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="Identifier"/>
                  </parameter>
                </target>
                <rule>
                  <name value="inssystem"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="ins"/>
                    <contextType value="variable"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="urn:oid:1.2.250.1.213.1.4.10"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="insvalue"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="ins"/>
                    <contextType value="variable"/>
                    <element value="value"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="ans.valueString"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="instype"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="ins"/>
                    <contextType value="variable"/>
                    <element value="type"/>
                    <transform value="cc"/>
                    <parameter>
                      <valueString
                                   value="http://interopsante.org/fhir/CodeSystem/fr-v2-0203"/>
                    </parameter>
                    <parameter>
                      <valueString value="INS-C"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="extractbirthdate"/>
              <source>
                <context value="identity"/>
                <element value="item"/>
                <variable value="birthItem"/>
                <condition value="(linkId = '5036133558154')"/>
              </source>
              <rule>
                <name value="setbirthdate"/>
                <source>
                  <context value="birthItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="patient"/>
                  <contextType value="variable"/>
                  <element value="birthDate"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="ans.valueDate"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="extractdeath"/>
              <source>
                <context value="identity"/>
                <element value="item"/>
                <variable value="deathItem"/>
                <condition value="(linkId = '5633552097315')"/>
              </source>
              <rule>
                <name value="setdeceaseddate"/>
                <source>
                  <context value="deathItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="patient"/>
                  <contextType value="variable"/>
                  <element value="deceased"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="ans.valueDate"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="extractdeathsource"/>
                <source>
                  <context value="deathItem"/>
                  <element value="item"/>
                  <variable value="deathSource"/>
                  <condition value="(linkId = '9098810065693')"/>
                </source>
                <rule>
                  <name value="setdeathsourceext"/>
                  <source>
                    <context value="deathSource"/>
                    <element value="answer"/>
                    <variable value="sourceAns"/>
                  </source>
                  <target>
                    <context value="patient"/>
                    <contextType value="variable"/>
                    <element value="extension"/>
                    <variable value="ext"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Extension"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="deathsourceurl"/>
                    <source>
                      <context value="sourceAns"/>
                    </source>
                    <target>
                      <context value="ext"/>
                      <contextType value="variable"/>
                      <element value="url"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString
                                     value="https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/death-source"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="deathsourcevalue"/>
                    <source>
                      <context value="sourceAns"/>
                    </source>
                    <target>
                      <context value="ext"/>
                      <contextType value="variable"/>
                      <element value="value"/>
                      <transform value="evaluate"/>
                      <parameter>
                        <valueString value="sourceAns.valueCoding"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="extractmultiplebirth"/>
              <source>
                <context value="identity"/>
                <element value="item"/>
                <variable value="multipleItem"/>
                <condition value="(linkId = '6931296968515')"/>
              </source>
              <rule>
                <name value="navigatevalue"/>
                <source>
                  <context value="multipleItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <rule>
                  <name value="setmultiplebirth"/>
                  <source>
                    <context value="ans"/>
                    <element value="valueInteger"/>
                    <variable value="valueInteger"/>
                  </source>
                  <target>
                    <context value="patient"/>
                    <contextType value="variable"/>
                    <element value="multipleBirth"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueId value="valueInteger"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="extractpmsidemographics"/>
            <source>
              <context value="src"/>
              <element value="item"/>
              <variable value="pmsiGroup"/>
              <condition value="(linkId = '2825244231605')"/>
            </source>
            <rule>
              <name value="extractgender"/>
              <source>
                <context value="pmsiGroup"/>
                <element value="item"/>
                <variable value="sexItem"/>
                <condition value="(linkId = '3894630481120')"/>
              </source>
              <rule>
                <name value="valueCoding"/>
                <source>
                  <context value="sexItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <rule>
                  <name value="setgender"/>
                  <source>
                    <context value="ans"/>
                    <element value="valueCoding"/>
                    <variable value="valueCoding"/>
                  </source>
                  <target>
                    <context value="patient"/>
                    <contextType value="variable"/>
                    <element value="gender"/>
                    <transform value="translate"/>
                    <parameter>
                      <valueId value="valueCoding"/>
                    </parameter>
                    <parameter>
                      <valueString
                                   value="https://interop.aphp.fr/ig/fhir/dm/ConceptMap/dpi-gender-2-hl7-gender"/>
                    </parameter>
                    <parameter>
                      <valueString value="code"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="extractcodegeo"/>
              <source>
                <context value="pmsiGroup"/>
                <element value="item"/>
                <variable value="codeGeoItem"/>
                <condition value="(linkId = '2446369196222')"/>
              </source>
              <rule>
                <name value="setaddress"/>
                <source>
                  <context value="codeGeoItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="patient"/>
                  <contextType value="variable"/>
                  <element value="address"/>
                  <variable value="addr"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="Address"/>
                  </parameter>
                </target>
                <rule>
                  <name value="setcodegeoext"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="addr"/>
                    <contextType value="variable"/>
                    <element value="extension"/>
                    <variable value="ext"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Extension"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="codegeourl"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="ext"/>
                      <contextType value="variable"/>
                      <element value="url"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString
                                     value="https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/pmsi-code-geo"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="codegeovalue"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="ext"/>
                      <contextType value="variable"/>
                      <element value="value"/>
                      <transform value="evaluate"/>
                      <parameter>
                        <valueString value="ans.valueCoding"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
            </rule>
          </rule>
        </rule>
      </group>
      <group>
        <name value="CreateLocations"/>
        <typeMode value="none"/>
        <documentation
                       value="Group: Create Locations from geocoding and IRIS data"/>
        <input>
          <name value="src"/>
          <type value="QuestionnaireResponse"/>
          <mode value="source"/>
        </input>
        <input>
          <name value="patient"/>
          <type value="Patient"/>
          <mode value="target"/>
        </input>
        <input>
          <name value="bundle"/>
          <type value="Bundle"/>
          <mode value="target"/>
        </input>
        <rule>
          <name value="processsociodemographicslocation"/>
          <source>
            <context value="src"/>
            <element value="item"/>
            <variable value="socioDemo"/>
            <condition value="(linkId = '4647259356106')"/>
          </source>
          <rule>
            <name value="processenvironment"/>
            <source>
              <context value="socioDemo"/>
              <element value="item"/>
              <variable value="environment"/>
              <condition value="(linkId = '5491974639955')"/>
            </source>
            <rule>
              <name value="geocodinglocationentry"/>
              <source>
                <context value="environment"/>
                <element value="item"/>
                <variable value="geocodingItem"/>
                <condition value="(linkId = '3816475533472')"/>
              </source>
              <target>
                <context value="bundle"/>
                <contextType value="variable"/>
                <element value="entry"/>
                <variable value="locationEntry"/>
              </target>
              <rule>
                <name value="createlocation"/>
                <source>
                  <context value="geocodingItem"/>
                </source>
                <target>
                  <context value="locationEntry"/>
                  <contextType value="variable"/>
                  <element value="resource"/>
                  <variable value="location"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="Location"/>
                  </parameter>
                </target>
                <rule>
                  <name value="locationid"/>
                  <source>
                    <context value="geocodingItem"/>
                  </source>
                  <target>
                    <context value="location"/>
                    <contextType value="variable"/>
                    <element value="id"/>
                    <transform value="uuid"/>
                  </target>
                </rule>
                <rule>
                  <name value="locationmeta"/>
                  <source>
                    <context value="geocodingItem"/>
                  </source>
                  <target>
                    <context value="location"/>
                    <contextType value="variable"/>
                    <element value="meta"/>
                    <variable value="meta"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Meta"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="locationprofile"/>
                    <source>
                      <context value="geocodingItem"/>
                    </source>
                    <target>
                      <context value="meta"/>
                      <contextType value="variable"/>
                      <element value="profile"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString
                                     value="https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMLocation"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
                <rule>
                  <name value="setposition"/>
                  <source>
                    <context value="geocodingItem"/>
                  </source>
                  <target>
                    <context value="location"/>
                    <contextType value="variable"/>
                    <element value="position"/>
                    <variable value="pos"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="LocationPosition"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="extractlatitude"/>
                    <source>
                      <context value="geocodingItem"/>
                      <element value="item"/>
                      <variable value="latItem"/>
                      <condition value="(linkId = '3709843054556')"/>
                    </source>
                    <rule>
                      <name value="setlatitude"/>
                      <source>
                        <context value="latItem"/>
                        <element value="answer"/>
                        <variable value="ans"/>
                      </source>
                      <target>
                        <context value="pos"/>
                        <contextType value="variable"/>
                        <element value="latitude"/>
                        <transform value="evaluate"/>
                        <parameter>
                          <valueString value="ans.valueDecimal"/>
                        </parameter>
                      </target>
                    </rule>
                  </rule>
                  <rule>
                    <name value="extractlongitude"/>
                    <source>
                      <context value="geocodingItem"/>
                      <element value="item"/>
                      <variable value="longItem"/>
                      <condition value="(linkId = '7651448032665')"/>
                    </source>
                    <rule>
                      <name value="setlongitude"/>
                      <source>
                        <context value="longItem"/>
                        <element value="answer"/>
                        <variable value="ans"/>
                      </source>
                      <target>
                        <context value="pos"/>
                        <contextType value="variable"/>
                        <element value="longitude"/>
                        <transform value="evaluate"/>
                        <parameter>
                          <valueString value="ans.valueDecimal"/>
                        </parameter>
                      </target>
                    </rule>
                  </rule>
                </rule>
                <rule>
                  <name value="setrequest"/>
                  <source>
                    <context value="location"/>
                  </source>
                  <target>
                    <context value="locationEntry"/>
                    <contextType value="variable"/>
                    <element value="request"/>
                    <variable value="request"/>
                  </target>
                  <rule>
                    <name value="setmethod"/>
                    <source>
                      <context value="location"/>
                    </source>
                    <target>
                      <context value="request"/>
                      <contextType value="variable"/>
                      <element value="method"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="POST"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="seturl"/>
                    <source>
                      <context value="location"/>
                    </source>
                    <target>
                      <context value="request"/>
                      <contextType value="variable"/>
                      <element value="url"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="Location"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
                <rule>
                  <name value="setfullUrl"/>
                  <source>
                    <context value="location"/>
                    <element value="id"/>
                    <variable value="locId"/>
                  </source>
                  <target>
                    <context value="locationEntry"/>
                    <contextType value="variable"/>
                    <element value="fullUrl"/>
                    <transform value="append"/>
                    <parameter>
                      <valueString value="urn:uuid:"/>
                    </parameter>
                    <parameter>
                      <valueId value="locId"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="processiris"/>
              <source>
                <context value="environment"/>
                <element value="item"/>
                <variable value="irisItem"/>
                <condition value="(linkId = '7621032273792')"/>
              </source>
              <rule>
                <name value="irislocationentry"/>
                <source>
                  <context value="irisItem"/>
                  <element value="answer"/>
                  <variable value="irisAnswer"/>
                </source>
                <target>
                  <context value="bundle"/>
                  <contextType value="variable"/>
                  <element value="entry"/>
                  <variable value="locationEntry"/>
                </target>
                <rule>
                  <name value="createirislocation"/>
                  <source>
                    <context value="irisAnswer"/>
                  </source>
                  <target>
                    <context value="locationEntry"/>
                    <contextType value="variable"/>
                    <element value="resource"/>
                    <variable value="location"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Location"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="locationid"/>
                    <source>
                      <context value="irisAnswer"/>
                    </source>
                    <target>
                      <context value="location"/>
                      <contextType value="variable"/>
                      <element value="id"/>
                      <transform value="uuid"/>
                    </target>
                  </rule>
                  <rule>
                    <name value="locationmeta"/>
                    <source>
                      <context value="irisAnswer"/>
                    </source>
                    <target>
                      <context value="location"/>
                      <contextType value="variable"/>
                      <element value="meta"/>
                      <variable value="meta"/>
                      <transform value="create"/>
                      <parameter>
                        <valueString value="Meta"/>
                      </parameter>
                    </target>
                    <rule>
                      <name value="locationprofile"/>
                      <source>
                        <context value="irisAnswer"/>
                      </source>
                      <target>
                        <context value="meta"/>
                        <contextType value="variable"/>
                        <element value="profile"/>
                        <transform value="copy"/>
                        <parameter>
                          <valueString
                                       value="https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMLocation"/>
                        </parameter>
                      </target>
                    </rule>
                  </rule>
                  <rule>
                    <name value="setirisidentifier"/>
                    <source>
                      <context value="irisAnswer"/>
                    </source>
                    <target>
                      <context value="location"/>
                      <contextType value="variable"/>
                      <element value="identifier"/>
                      <variable value="identifier"/>
                      <transform value="create"/>
                      <parameter>
                        <valueString value="Identifier"/>
                      </parameter>
                    </target>
                    <rule>
                      <name value="irissystem"/>
                      <source>
                        <context value="irisAnswer"/>
                      </source>
                      <target>
                        <context value="identifier"/>
                        <contextType value="variable"/>
                        <element value="system"/>
                        <transform value="copy"/>
                        <parameter>
                          <valueString
                                       value="urn:oid:2.16.840.1.113883.2.8.1.5.5"/>
                        </parameter>
                      </target>
                    </rule>
                    <rule>
                      <name value="irisvalue"/>
                      <source>
                        <context value="irisAnswer"/>
                      </source>
                      <target>
                        <context value="identifier"/>
                        <contextType value="variable"/>
                        <element value="value"/>
                        <transform value="evaluate"/>
                        <parameter>
                          <valueString value="irisAnswer.valueCoding.code"/>
                        </parameter>
                      </target>
                    </rule>
                  </rule>
                  <rule>
                    <name value="setrequest"/>
                    <source>
                      <context value="location"/>
                    </source>
                    <target>
                      <context value="locationEntry"/>
                      <contextType value="variable"/>
                      <element value="request"/>
                      <variable value="request"/>
                    </target>
                    <rule>
                      <name value="setmethod"/>
                      <source>
                        <context value="location"/>
                      </source>
                      <target>
                        <context value="request"/>
                        <contextType value="variable"/>
                        <element value="method"/>
                        <transform value="copy"/>
                        <parameter>
                          <valueString value="POST"/>
                        </parameter>
                      </target>
                    </rule>
                    <rule>
                      <name value="seturl"/>
                      <source>
                        <context value="location"/>
                      </source>
                      <target>
                        <context value="request"/>
                        <contextType value="variable"/>
                        <element value="url"/>
                        <transform value="copy"/>
                        <parameter>
                          <valueString value="Location"/>
                        </parameter>
                      </target>
                    </rule>
                  </rule>
                  <rule>
                    <name value="setfullUrl"/>
                    <source>
                      <context value="location"/>
                      <element value="id"/>
                      <variable value="locId"/>
                    </source>
                    <target>
                      <context value="locationEntry"/>
                      <contextType value="variable"/>
                      <element value="fullUrl"/>
                      <transform value="append"/>
                      <parameter>
                        <valueString value="urn:uuid:"/>
                      </parameter>
                      <parameter>
                        <valueId value="locId"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
            </rule>
          </rule>
        </rule>
      </group>
      <group>
        <name value="CreateEncounters"/>
        <typeMode value="none"/>
        <documentation value="Group: Create Encounters from PMSI data"/>
        <input>
          <name value="src"/>
          <type value="QuestionnaireResponse"/>
          <mode value="source"/>
        </input>
        <input>
          <name value="patient"/>
          <type value="Patient"/>
          <mode value="target"/>
        </input>
        <input>
          <name value="bundle"/>
          <type value="Bundle"/>
          <mode value="target"/>
        </input>
        <rule>
          <name value="encounterentry"/>
          <source>
            <context value="src"/>
            <element value="item"/>
            <variable value="pmsiItem"/>
            <condition value="(linkId = '2825244231605')"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="encounterEntry"/>
          </target>
          <rule>
            <name value="createencounter"/>
            <source>
              <context value="pmsiItem"/>
            </source>
            <target>
              <context value="encounterEntry"/>
              <contextType value="variable"/>
              <element value="resource"/>
              <variable value="encounter"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Encounter"/>
              </parameter>
            </target>
            <rule>
              <name value="encounterid"/>
              <source>
                <context value="pmsiItem"/>
              </source>
              <target>
                <context value="encounter"/>
                <contextType value="variable"/>
                <element value="id"/>
                <transform value="uuid"/>
              </target>
            </rule>
            <rule>
              <name value="encountermeta"/>
              <source>
                <context value="pmsiItem"/>
              </source>
              <target>
                <context value="encounter"/>
                <contextType value="variable"/>
                <element value="meta"/>
                <variable value="meta"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Meta"/>
                </parameter>
              </target>
              <rule>
                <name value="encounterprofile"/>
                <source>
                  <context value="pmsiItem"/>
                </source>
                <target>
                  <context value="meta"/>
                  <contextType value="variable"/>
                  <element value="profile"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMEncounter"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="setsubject"/>
              <source>
                <context value="src"/>
              </source>
              <target>
                <context value="encounter"/>
                <contextType value="variable"/>
                <element value="subject"/>
                <variable value="ref"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Reference"/>
                </parameter>
              </target>
              <target>
                <context value="patient"/>
                <contextType value="variable"/>
                <element value="id"/>
                <variable value="patId"/>
              </target>
              <target>
                <context value="ref"/>
                <contextType value="variable"/>
                <element value="reference"/>
                <transform value="append"/>
                <parameter>
                  <valueString value="Patient/"/>
                </parameter>
                <parameter>
                  <valueId value="patId"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setperiod"/>
              <source>
                <context value="pmsiItem"/>
              </source>
              <target>
                <context value="encounter"/>
                <contextType value="variable"/>
                <element value="period"/>
                <variable value="period"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Period"/>
                </parameter>
              </target>
              <rule>
                <name value="extractstart"/>
                <source>
                  <context value="pmsiItem"/>
                  <element value="item"/>
                  <variable value="startItem"/>
                  <condition value="(linkId = '5991443718282')"/>
                </source>
                <rule>
                  <name value="setstart"/>
                  <source>
                    <context value="startItem"/>
                    <element value="answer"/>
                    <variable value="ans"/>
                  </source>
                  <target>
                    <context value="period"/>
                    <contextType value="variable"/>
                    <element value="start"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="ans.valueDate"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="extractend"/>
                <source>
                  <context value="pmsiItem"/>
                  <element value="item"/>
                  <variable value="endItem"/>
                  <condition value="(linkId = '6114780320846')"/>
                </source>
                <rule>
                  <name value="setend"/>
                  <source>
                    <context value="endItem"/>
                    <element value="answer"/>
                    <variable value="ans"/>
                  </source>
                  <target>
                    <context value="period"/>
                    <contextType value="variable"/>
                    <element value="end"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="ans.valueDate"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="extractmodein"/>
              <source>
                <context value="pmsiItem"/>
                <element value="item"/>
                <variable value="modeInItem"/>
                <condition value="(linkId = '6172398101212')"/>
              </source>
            </rule>
            <rule>
              <name value="extractmodeout"/>
              <source>
                <context value="pmsiItem"/>
                <element value="item"/>
                <variable value="modeOutItem"/>
                <condition value="(linkId = '3354867075704')"/>
              </source>
            </rule>
            <rule>
              <name value="setfullUrl"/>
              <source>
                <context value="src"/>
              </source>
              <target>
                <context value="encounter"/>
                <contextType value="variable"/>
                <element value="id"/>
                <variable value="encId"/>
              </target>
              <target>
                <context value="encounterEntry"/>
                <contextType value="variable"/>
                <element value="fullUrl"/>
                <transform value="append"/>
                <parameter>
                  <valueString value="urn:uuid:"/>
                </parameter>
                <parameter>
                  <valueId value="encId"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="createconditions"/>
              <source>
                <context value="pmsiItem"/>
              </source>
              <dependent>
                <name value="CreateConditions"/>
                <variable value="pmsiItem"/>
                <variable value="patient"/>
                <variable value="encounter"/>
                <variable value="bundle"/>
              </dependent>
            </rule>
            <rule>
              <name value="createprocedures"/>
              <source>
                <context value="pmsiItem"/>
              </source>
              <dependent>
                <name value="CreateProcedures"/>
                <variable value="pmsiItem"/>
                <variable value="patient"/>
                <variable value="encounter"/>
                <variable value="bundle"/>
              </dependent>
            </rule>
          </rule>
        </rule>
      </group>
      <group>
        <name value="CreateConditions"/>
        <typeMode value="none"/>
        <documentation value="Group: Create Conditions from nested diagnostics"/>
        <input>
          <name value="pmsiItem"/>
          <mode value="source"/>
        </input>
        <input>
          <name value="patient"/>
          <type value="Patient"/>
          <mode value="target"/>
        </input>
        <input>
          <name value="encounter"/>
          <type value="Encounter"/>
          <mode value="target"/>
        </input>
        <input>
          <name value="bundle"/>
          <type value="Bundle"/>
          <mode value="target"/>
        </input>
        <rule>
          <name value="conditionentry"/>
          <source>
            <context value="pmsiItem"/>
            <element value="item"/>
            <variable value="diagGroup"/>
            <condition value="(linkId = '9391816419630')"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="conditionEntry"/>
          </target>
          <rule>
            <name value="createcondition"/>
            <source>
              <context value="diagGroup"/>
            </source>
            <target>
              <context value="conditionEntry"/>
              <contextType value="variable"/>
              <element value="resource"/>
              <variable value="condition"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Condition"/>
              </parameter>
            </target>
            <rule>
              <name value="conditionid"/>
              <source>
                <context value="diagGroup"/>
              </source>
              <target>
                <context value="condition"/>
                <contextType value="variable"/>
                <element value="id"/>
                <transform value="uuid"/>
              </target>
            </rule>
            <rule>
              <name value="conditionmeta"/>
              <source>
                <context value="diagGroup"/>
              </source>
              <target>
                <context value="condition"/>
                <contextType value="variable"/>
                <element value="meta"/>
                <variable value="meta"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Meta"/>
                </parameter>
              </target>
              <rule>
                <name value="conditionprofile"/>
                <source>
                  <context value="diagGroup"/>
                </source>
                <target>
                  <context value="meta"/>
                  <contextType value="variable"/>
                  <element value="profile"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMCondition"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="setsubject"/>
              <source>
                <context value="diagGroup"/>
              </source>
              <target>
                <context value="condition"/>
                <contextType value="variable"/>
                <element value="subject"/>
                <variable value="ref"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Reference"/>
                </parameter>
              </target>
              <target>
                <context value="patient"/>
                <contextType value="variable"/>
                <element value="id"/>
                <variable value="patId"/>
              </target>
              <target>
                <context value="ref"/>
                <contextType value="variable"/>
                <element value="reference"/>
                <transform value="append"/>
                <parameter>
                  <valueString value="Patient/"/>
                </parameter>
                <parameter>
                  <valueId value="patId"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setencounter"/>
              <source>
                <context value="diagGroup"/>
              </source>
              <target>
                <context value="encounter"/>
                <contextType value="variable"/>
                <element value="id"/>
                <variable value="encId"/>
              </target>
              <target>
                <context value="condition"/>
                <contextType value="variable"/>
                <element value="encounter"/>
                <variable value="ref"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Reference"/>
                </parameter>
              </target>
              <target>
                <context value="ref"/>
                <contextType value="variable"/>
                <element value="reference"/>
                <transform value="append"/>
                <parameter>
                  <valueString value="Encounter/"/>
                </parameter>
                <parameter>
                  <valueId value="encId"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="extractdiagcode"/>
              <source>
                <context value="diagGroup"/>
                <element value="item"/>
                <variable value="diagCodeItem"/>
                <condition value="(linkId = '5505101189372')"/>
              </source>
              <rule>
                <name value="setcode"/>
                <source>
                  <context value="diagCodeItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="condition"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <variable value="code"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="CodeableConcept"/>
                  </parameter>
                </target>
                <rule>
                  <name value="setcoding"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="code"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="ans.valueCoding"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="extractdiagtype"/>
              <source>
                <context value="diagGroup"/>
                <element value="item"/>
                <variable value="diagTypeItem"/>
                <condition value="(linkId = '6427586743735')"/>
              </source>
              <rule>
                <name value="setcategory"/>
                <source>
                  <context value="diagTypeItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="condition"/>
                  <contextType value="variable"/>
                  <element value="category"/>
                  <variable value="category"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="CodeableConcept"/>
                  </parameter>
                </target>
                <rule>
                  <name value="setcategorycoding"/>
                  <source>
                    <context value="ans"/>
                  </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="diagtypesystem"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString
                                     value="https://interop.aphp.fr/ig/fhir/dm/CodeSystem/pmsi-mco-diag-type"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="diagtypecode"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="evaluate"/>
                      <parameter>
                        <valueString value="ans.valueCoding.code"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="diagtypedisplay"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="display"/>
                      <transform value="evaluate"/>
                      <parameter>
                        <valueString value="ans.valueCoding.display"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="extractrecordeddate"/>
              <source>
                <context value="diagGroup"/>
                <element value="item"/>
                <variable value="dateItem"/>
                <condition value="(linkId = '7114466839467')"/>
              </source>
              <rule>
                <name value="setrecordeddate"/>
                <source>
                  <context value="dateItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="condition"/>
                  <contextType value="variable"/>
                  <element value="recordedDate"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="ans.valueDate"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </group>
      <group>
        <name value="CreateProcedures"/>
        <typeMode value="none"/>
        <documentation value="Group: Create Procedures from nested actes"/>
        <input>
          <name value="pmsiItem"/>
          <mode value="source"/>
        </input>
        <input>
          <name value="patient"/>
          <type value="Patient"/>
          <mode value="target"/>
        </input>
        <input>
          <name value="encounter"/>
          <type value="Encounter"/>
          <mode value="target"/>
        </input>
        <input>
          <name value="bundle"/>
          <type value="Bundle"/>
          <mode value="target"/>
        </input>
        <rule>
          <name value="procedureentry"/>
          <source>
            <context value="pmsiItem"/>
            <element value="item"/>
            <variable value="acteGroup"/>
            <condition value="(linkId = '591926901726')"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="procedureEntry"/>
          </target>
          <rule>
            <name value="createprocedure"/>
            <source>
              <context value="acteGroup"/>
            </source>
            <target>
              <context value="procedureEntry"/>
              <contextType value="variable"/>
              <element value="resource"/>
              <variable value="procedure"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Procedure"/>
              </parameter>
            </target>
            <rule>
              <name value="procedureid"/>
              <source>
                <context value="acteGroup"/>
              </source>
              <target>
                <context value="procedure"/>
                <contextType value="variable"/>
                <element value="id"/>
                <transform value="uuid"/>
              </target>
            </rule>
            <rule>
              <name value="proceduremeta"/>
              <source>
                <context value="acteGroup"/>
              </source>
              <target>
                <context value="procedure"/>
                <contextType value="variable"/>
                <element value="meta"/>
                <variable value="meta"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Meta"/>
                </parameter>
              </target>
              <rule>
                <name value="procedureprofile"/>
                <source>
                  <context value="acteGroup"/>
                </source>
                <target>
                  <context value="meta"/>
                  <contextType value="variable"/>
                  <element value="profile"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMProcedure"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="setsubject"/>
              <source>
                <context value="acteGroup"/>
              </source>
              <target>
                <context value="procedure"/>
                <contextType value="variable"/>
                <element value="subject"/>
                <variable value="ref"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Reference"/>
                </parameter>
              </target>
              <target>
                <context value="patient"/>
                <contextType value="variable"/>
                <element value="id"/>
                <variable value="patId"/>
              </target>
              <target>
                <context value="ref"/>
                <contextType value="variable"/>
                <element value="reference"/>
                <transform value="append"/>
                <parameter>
                  <valueString value="Patient/"/>
                </parameter>
                <parameter>
                  <valueId value="patId"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setencounter"/>
              <source>
                <context value="acteGroup"/>
              </source>
              <target>
                <context value="encounter"/>
                <contextType value="variable"/>
                <element value="id"/>
                <variable value="encId"/>
              </target>
              <target>
                <context value="procedure"/>
                <contextType value="variable"/>
                <element value="encounter"/>
                <variable value="ref"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Reference"/>
                </parameter>
              </target>
              <target>
                <context value="ref"/>
                <contextType value="variable"/>
                <element value="reference"/>
                <transform value="append"/>
                <parameter>
                  <valueString value="Encounter/"/>
                </parameter>
                <parameter>
                  <valueId value="encId"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="extractactecode"/>
              <source>
                <context value="acteGroup"/>
                <element value="item"/>
                <variable value="acteCodeItem"/>
                <condition value="(linkId = '7758110033600')"/>
              </source>
              <rule>
                <name value="setcode"/>
                <source>
                  <context value="acteCodeItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="procedure"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <variable value="code"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="CodeableConcept"/>
                  </parameter>
                </target>
                <rule>
                  <name value="setcoding"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="code"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="ans.valueCoding"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="extractperformeddate"/>
              <source>
                <context value="acteGroup"/>
                <element value="item"/>
                <variable value="dateItem"/>
                <condition value="(linkId = '5066866286682')"/>
              </source>
              <rule>
                <name value="setperformed"/>
                <source>
                  <context value="dateItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="procedure"/>
                  <contextType value="variable"/>
                  <element value="performed"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="ans.valueDateTime"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </group>
      <group>
        <name value="CreateMedicationRequests"/>
        <typeMode value="none"/>
        <documentation value="Group: Create Medication Requests"/>
        <input>
          <name value="src"/>
          <type value="QuestionnaireResponse"/>
          <mode value="source"/>
        </input>
        <input>
          <name value="patient"/>
          <type value="Patient"/>
          <mode value="target"/>
        </input>
        <input>
          <name value="bundle"/>
          <type value="Bundle"/>
          <mode value="target"/>
        </input>
        <rule>
          <name value="processmedexpo"/>
          <source>
            <context value="src"/>
            <element value="item"/>
            <variable value="medExpoGroup"/>
            <condition value="(linkId = '817801935685')"/>
          </source>
          <rule>
            <name value="medreqentry"/>
            <source>
              <context value="medExpoGroup"/>
              <element value="item"/>
              <variable value="prescribedGroup"/>
              <condition value="(linkId = '156631794800')"/>
            </source>
            <target>
              <context value="bundle"/>
              <contextType value="variable"/>
              <element value="entry"/>
              <variable value="medReqEntry"/>
            </target>
            <rule>
              <name value="createmedreq"/>
              <source>
                <context value="prescribedGroup"/>
              </source>
              <target>
                <context value="medReqEntry"/>
                <contextType value="variable"/>
                <element value="resource"/>
                <variable value="medReq"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="MedicationRequest"/>
                </parameter>
              </target>
              <rule>
                <name value="medreqid"/>
                <source>
                  <context value="prescribedGroup"/>
                </source>
                <target>
                  <context value="medReq"/>
                  <contextType value="variable"/>
                  <element value="id"/>
                  <transform value="uuid"/>
                </target>
              </rule>
              <rule>
                <name value="medreqmeta"/>
                <source>
                  <context value="prescribedGroup"/>
                </source>
                <target>
                  <context value="medReq"/>
                  <contextType value="variable"/>
                  <element value="meta"/>
                  <variable value="meta"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="Meta"/>
                  </parameter>
                </target>
                <rule>
                  <name value="medreqprofile"/>
                  <source>
                    <context value="prescribedGroup"/>
                  </source>
                  <target>
                    <context value="meta"/>
                    <contextType value="variable"/>
                    <element value="profile"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMMedicationRequest"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="setsubject"/>
                <source>
                  <context value="prescribedGroup"/>
                </source>
                <target>
                  <context value="medReq"/>
                  <contextType value="variable"/>
                  <element value="subject"/>
                  <variable value="ref"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="Reference"/>
                  </parameter>
                </target>
                <target>
                  <context value="patient"/>
                  <contextType value="variable"/>
                  <element value="id"/>
                  <variable value="patId"/>
                </target>
                <target>
                  <context value="ref"/>
                  <contextType value="variable"/>
                  <element value="reference"/>
                  <transform value="append"/>
                  <parameter>
                    <valueString value="Patient/"/>
                  </parameter>
                  <parameter>
                    <valueId value="patId"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="setstatus"/>
                <source>
                  <context value="prescribedGroup"/>
                </source>
                <target>
                  <context value="medReq"/>
                  <contextType value="variable"/>
                  <element value="status"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="active"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="setintent"/>
                <source>
                  <context value="prescribedGroup"/>
                </source>
                <target>
                  <context value="medReq"/>
                  <contextType value="variable"/>
                  <element value="intent"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="order"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="medicationentry"/>
                <source>
                  <context value="prescribedGroup"/>
                </source>
                <target>
                  <context value="bundle"/>
                  <contextType value="variable"/>
                  <element value="entry"/>
                  <variable value="medEntry"/>
                </target>
                <rule>
                  <name value="createmedication"/>
                  <source>
                    <context value="prescribedGroup"/>
                  </source>
                  <target>
                    <context value="medEntry"/>
                    <contextType value="variable"/>
                    <element value="resource"/>
                    <variable value="medication"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Medication"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="medid"/>
                    <source>
                      <context value="prescribedGroup"/>
                    </source>
                    <target>
                      <context value="medication"/>
                      <contextType value="variable"/>
                      <element value="id"/>
                      <transform value="uuid"/>
                    </target>
                  </rule>
                  <rule>
                    <name value="extractatc"/>
                    <source>
                      <context value="prescribedGroup"/>
                      <element value="item"/>
                      <variable value="atcItem"/>
                      <condition value="(linkId.contains('ATC'))"/>
                    </source>
                    <rule>
                      <name value="setmedcode"/>
                      <source>
                        <context value="atcItem"/>
                        <element value="answer"/>
                        <variable value="ans"/>
                      </source>
                      <target>
                        <context value="medication"/>
                        <contextType value="variable"/>
                        <element value="code"/>
                        <variable value="code"/>
                        <transform value="create"/>
                        <parameter>
                          <valueString value="CodeableConcept"/>
                        </parameter>
                      </target>
                      <rule>
                        <name value="setatccoding"/>
                        <source>
                          <context value="ans"/>
                        </source>
                        <target>
                          <context value="code"/>
                          <contextType value="variable"/>
                          <element value="coding"/>
                          <transform value="evaluate"/>
                          <parameter>
                            <valueString value="ans.valueCoding"/>
                          </parameter>
                        </target>
                      </rule>
                    </rule>
                  </rule>
                  <rule>
                    <name value="setfullUrl"/>
                    <source>
                      <context value="prescribedGroup"/>
                    </source>
                    <target>
                      <context value="medication"/>
                      <contextType value="variable"/>
                      <element value="id"/>
                      <variable value="medId"/>
                    </target>
                    <target>
                      <context value="medEntry"/>
                      <contextType value="variable"/>
                      <element value="fullUrl"/>
                      <transform value="append"/>
                      <parameter>
                        <valueString value="urn:uuid:"/>
                      </parameter>
                      <parameter>
                        <valueId value="medId"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setmedicationreference"/>
                    <source>
                      <context value="prescribedGroup"/>
                    </source>
                    <target>
                      <context value="medication"/>
                      <contextType value="variable"/>
                      <element value="id"/>
                      <variable value="medId"/>
                    </target>
                    <target>
                      <context value="medReq"/>
                      <contextType value="variable"/>
                      <element value="medication"/>
                      <variable value="ref"/>
                      <transform value="create"/>
                      <parameter>
                        <valueString value="Reference"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="ref"/>
                      <contextType value="variable"/>
                      <element value="reference"/>
                      <transform value="append"/>
                      <parameter>
                        <valueString value="Medication/"/>
                      </parameter>
                      <parameter>
                        <valueId value="medId"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
              <rule>
                <name value="setdosage"/>
                <source>
                  <context value="prescribedGroup"/>
                </source>
                <target>
                  <context value="medReq"/>
                  <contextType value="variable"/>
                  <element value="dosageInstruction"/>
                  <variable value="dosage"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="Dosage"/>
                  </parameter>
                </target>
                <rule>
                  <name value="extractroute"/>
                  <source>
                    <context value="prescribedGroup"/>
                    <element value="item"/>
                    <variable value="routeItem"/>
                    <condition value="(linkId.contains('voie'))"/>
                  </source>
                  <rule>
                    <name value="setroute"/>
                    <source>
                      <context value="routeItem"/>
                      <element value="answer"/>
                      <variable value="ans"/>
                    </source>
                    <target>
                      <context value="dosage"/>
                      <contextType value="variable"/>
                      <element value="route"/>
                      <variable value="route"/>
                      <transform value="create"/>
                      <parameter>
                        <valueString value="CodeableConcept"/>
                      </parameter>
                    </target>
                    <rule>
                      <name value="setroutecoding"/>
                      <source>
                        <context value="ans"/>
                      </source>
                      <target>
                        <context value="route"/>
                        <contextType value="variable"/>
                        <element value="coding"/>
                        <transform value="evaluate"/>
                        <parameter>
                          <valueString value="ans.valueCoding"/>
                        </parameter>
                      </target>
                    </rule>
                  </rule>
                </rule>
                <rule>
                  <name value="extracttiming"/>
                  <source>
                    <context value="prescribedGroup"/>
                    <element value="item"/>
                    <variable value="timingItem"/>
                    <condition
                               value="(linkId.contains('timing') or linkId.contains('fréquence'))"/>
                  </source>
                  <rule>
                    <name value="settimingstructure"/>
                    <source>
                      <context value="timingItem"/>
                      <element value="answer"/>
                      <variable value="ans"/>
                    </source>
                    <target>
                      <context value="dosage"/>
                      <contextType value="variable"/>
                      <element value="timing"/>
                      <variable value="timing"/>
                      <transform value="create"/>
                      <parameter>
                        <valueString value="Timing"/>
                      </parameter>
                    </target>
                    <rule>
                      <name value="settiming"/>
                      <source>
                        <context value="ans"/>
                      </source>
                      <target>
                        <context value="timing"/>
                        <contextType value="variable"/>
                        <element value="repeat"/>
                        <variable value="repeat"/>
                        <transform value="create"/>
                        <parameter>
                          <valueString value="TimingRepeat"/>
                        </parameter>
                      </target>
                    </rule>
                  </rule>
                </rule>
              </rule>
            </rule>
          </rule>
        </rule>
      </group>
      <group>
        <name value="CreateMedicationAdministrations"/>
        <typeMode value="none"/>
        <documentation value="Group: Create Medication Administrations"/>
        <input>
          <name value="src"/>
          <type value="QuestionnaireResponse"/>
          <mode value="source"/>
        </input>
        <input>
          <name value="patient"/>
          <type value="Patient"/>
          <mode value="target"/>
        </input>
        <input>
          <name value="bundle"/>
          <type value="Bundle"/>
          <mode value="target"/>
        </input>
        <rule>
          <name value="processmedexpoadmin"/>
          <source>
            <context value="src"/>
            <element value="item"/>
            <variable value="medExpoGroup"/>
            <condition value="(linkId = '817801935685')"/>
          </source>
          <rule>
            <name value="medadminentry"/>
            <source>
              <context value="medExpoGroup"/>
              <element value="item"/>
              <variable value="adminGroup"/>
              <condition value="(linkId = '266852453304')"/>
            </source>
            <target>
              <context value="bundle"/>
              <contextType value="variable"/>
              <element value="entry"/>
              <variable value="medAdminEntry"/>
            </target>
            <rule>
              <name value="createmedadmin"/>
              <source>
                <context value="adminGroup"/>
              </source>
              <target>
                <context value="medAdminEntry"/>
                <contextType value="variable"/>
                <element value="resource"/>
                <variable value="medAdmin"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="MedicationAdministration"/>
                </parameter>
              </target>
              <rule>
                <name value="medadminid"/>
                <source>
                  <context value="adminGroup"/>
                </source>
                <target>
                  <context value="medAdmin"/>
                  <contextType value="variable"/>
                  <element value="id"/>
                  <transform value="uuid"/>
                </target>
              </rule>
              <rule>
                <name value="medadminmeta"/>
                <source>
                  <context value="adminGroup"/>
                </source>
                <target>
                  <context value="medAdmin"/>
                  <contextType value="variable"/>
                  <element value="meta"/>
                  <variable value="meta"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="Meta"/>
                  </parameter>
                </target>
                <rule>
                  <name value="medadminprofile"/>
                  <source>
                    <context value="adminGroup"/>
                  </source>
                  <target>
                    <context value="meta"/>
                    <contextType value="variable"/>
                    <element value="profile"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString
                                   value="https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMMedicationAdministration"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="setsubject"/>
                <source>
                  <context value="adminGroup"/>
                </source>
                <target>
                  <context value="medAdmin"/>
                  <contextType value="variable"/>
                  <element value="subject"/>
                  <variable value="ref"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="Reference"/>
                  </parameter>
                </target>
                <target>
                  <context value="patient"/>
                  <contextType value="variable"/>
                  <element value="id"/>
                  <variable value="patId"/>
                </target>
                <target>
                  <context value="ref"/>
                  <contextType value="variable"/>
                  <element value="reference"/>
                  <transform value="append"/>
                  <parameter>
                    <valueString value="Patient/"/>
                  </parameter>
                  <parameter>
                    <valueId value="patId"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="setstatus"/>
                <source>
                  <context value="adminGroup"/>
                </source>
                <target>
                  <context value="medAdmin"/>
                  <contextType value="variable"/>
                  <element value="status"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="completed"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="medicationentry"/>
                <source>
                  <context value="adminGroup"/>
                </source>
                <target>
                  <context value="bundle"/>
                  <contextType value="variable"/>
                  <element value="entry"/>
                  <variable value="medEntry"/>
                </target>
                <rule>
                  <name value="createmedication"/>
                  <source>
                    <context value="adminGroup"/>
                  </source>
                  <target>
                    <context value="medEntry"/>
                    <contextType value="variable"/>
                    <element value="resource"/>
                    <variable value="medication"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Medication"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="medid"/>
                    <source>
                      <context value="adminGroup"/>
                    </source>
                    <target>
                      <context value="medication"/>
                      <contextType value="variable"/>
                      <element value="id"/>
                      <transform value="uuid"/>
                    </target>
                  </rule>
                  <rule>
                    <name value="extractatc"/>
                    <source>
                      <context value="adminGroup"/>
                      <element value="item"/>
                      <variable value="atcItem"/>
                      <condition value="(linkId.contains('ATC'))"/>
                    </source>
                    <rule>
                      <name value="setmedcode"/>
                      <source>
                        <context value="atcItem"/>
                        <element value="answer"/>
                        <variable value="ans"/>
                      </source>
                      <target>
                        <context value="medication"/>
                        <contextType value="variable"/>
                        <element value="code"/>
                        <variable value="code"/>
                        <transform value="create"/>
                        <parameter>
                          <valueString value="CodeableConcept"/>
                        </parameter>
                      </target>
                      <rule>
                        <name value="setatccoding"/>
                        <source>
                          <context value="ans"/>
                        </source>
                        <target>
                          <context value="code"/>
                          <contextType value="variable"/>
                          <element value="coding"/>
                          <transform value="evaluate"/>
                          <parameter>
                            <valueString value="ans.valueCoding"/>
                          </parameter>
                        </target>
                      </rule>
                    </rule>
                  </rule>
                  <rule>
                    <name value="setfullUrl"/>
                    <source>
                      <context value="adminGroup"/>
                    </source>
                    <target>
                      <context value="medication"/>
                      <contextType value="variable"/>
                      <element value="id"/>
                      <variable value="medId"/>
                    </target>
                    <target>
                      <context value="medEntry"/>
                      <contextType value="variable"/>
                      <element value="fullUrl"/>
                      <transform value="append"/>
                      <parameter>
                        <valueString value="Medication/"/>
                      </parameter>
                      <parameter>
                        <valueId value="medId"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setmedicationreference"/>
                    <source>
                      <context value="adminGroup"/>
                    </source>
                    <target>
                      <context value="medication"/>
                      <contextType value="variable"/>
                      <element value="id"/>
                      <variable value="medId"/>
                    </target>
                    <target>
                      <context value="medAdmin"/>
                      <contextType value="variable"/>
                      <element value="medication"/>
                      <variable value="ref"/>
                      <transform value="create"/>
                      <parameter>
                        <valueString value="Reference"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="ref"/>
                      <contextType value="variable"/>
                      <element value="reference"/>
                      <transform value="append"/>
                      <parameter>
                        <valueString value="urn:uuid:"/>
                      </parameter>
                      <parameter>
                        <valueId value="medId"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
              <rule>
                <name value="seteffective"/>
                <source>
                  <context value="adminGroup"/>
                </source>
                <target>
                  <context value="medAdmin"/>
                  <contextType value="variable"/>
                  <element value="effective"/>
                  <variable value="period"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="Period"/>
                  </parameter>
                </target>
                <rule>
                  <name value="extractstart"/>
                  <source>
                    <context value="adminGroup"/>
                    <element value="item"/>
                    <variable value="startItem"/>
                    <condition value="(linkId.contains('début'))"/>
                  </source>
                  <rule>
                    <name value="setstart"/>
                    <source>
                      <context value="startItem"/>
                      <element value="answer"/>
                      <variable value="ans"/>
                    </source>
                    <target>
                      <context value="period"/>
                      <contextType value="variable"/>
                      <element value="start"/>
                      <transform value="evaluate"/>
                      <parameter>
                        <valueString value="ans.valueDateTime"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
                <rule>
                  <name value="extractend"/>
                  <source>
                    <context value="adminGroup"/>
                    <element value="item"/>
                    <variable value="endItem"/>
                    <condition value="(linkId.contains('fin'))"/>
                  </source>
                  <rule>
                    <name value="setend"/>
                    <source>
                      <context value="endItem"/>
                      <element value="answer"/>
                      <variable value="ans"/>
                    </source>
                    <target>
                      <context value="period"/>
                      <contextType value="variable"/>
                      <element value="end"/>
                      <transform value="evaluate"/>
                      <parameter>
                        <valueString value="ans.valueDateTime"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
              <rule>
                <name value="setdosage"/>
                <source>
                  <context value="adminGroup"/>
                </source>
                <target>
                  <context value="medAdmin"/>
                  <contextType value="variable"/>
                  <element value="dosage"/>
                  <variable value="dosage"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="Dosage"/>
                  </parameter>
                </target>
                <rule>
                  <name value="extractroute"/>
                  <source>
                    <context value="adminGroup"/>
                    <element value="item"/>
                    <variable value="routeItem"/>
                    <condition value="(linkId.contains('voie'))"/>
                  </source>
                  <rule>
                    <name value="setroute"/>
                    <source>
                      <context value="routeItem"/>
                      <element value="answer"/>
                      <variable value="ans"/>
                    </source>
                    <target>
                      <context value="dosage"/>
                      <contextType value="variable"/>
                      <element value="route"/>
                      <variable value="route"/>
                      <transform value="create"/>
                      <parameter>
                        <valueString value="CodeableConcept"/>
                      </parameter>
                    </target>
                    <rule>
                      <name value="setroutecoding"/>
                      <source>
                        <context value="ans"/>
                      </source>
                      <target>
                        <context value="route"/>
                        <contextType value="variable"/>
                        <element value="coding"/>
                        <transform value="evaluate"/>
                        <parameter>
                          <valueString value="ans.valueCoding"/>
                        </parameter>
                      </target>
                    </rule>
                  </rule>
                </rule>
                <rule>
                  <name value="extractdose"/>
                  <source>
                    <context value="adminGroup"/>
                    <element value="item"/>
                    <variable value="doseItem"/>
                    <condition value="(linkId.contains('dose'))"/>
                  </source>
                  <rule>
                    <name value="setdose"/>
                    <source>
                      <context value="doseItem"/>
                      <element value="answer"/>
                      <variable value="ans"/>
                    </source>
                    <target>
                      <context value="dosage"/>
                      <contextType value="variable"/>
                      <element value="dose"/>
                      <transform value="evaluate"/>
                      <parameter>
                        <valueString value="ans.valueQuantity"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
            </rule>
          </rule>
        </rule>
      </group>
      <group>
        <name value="CreateVitalSignObservations"/>
        <typeMode value="none"/>
        <documentation value="Group: Create Vital Sign Observations"/>
        <input>
          <name value="src"/>
          <type value="QuestionnaireResponse"/>
          <mode value="source"/>
        </input>
        <input>
          <name value="patient"/>
          <type value="Patient"/>
          <mode value="target"/>
        </input>
        <input>
          <name value="bundle"/>
          <type value="Bundle"/>
          <mode value="target"/>
        </input>
        <rule>
          <name value="processexam"/>
          <source>
            <context value="src"/>
            <element value="item"/>
            <variable value="examGroup"/>
            <condition value="(linkId = '214880328197')"/>
          </source>
          <rule>
            <name value="processdossier"/>
            <source>
              <context value="examGroup"/>
              <element value="item"/>
              <variable value="dossierGroup"/>
              <condition value="(linkId = '305831246173')"/>
            </source>
            <rule>
              <name value="extractheight"/>
              <source>
                <context value="dossierGroup"/>
                <element value="item"/>
                <variable value="heightItem"/>
                <condition value="(linkId = '4846902346416')"/>
              </source>
              <rule>
                <name value="heightobsentry"/>
                <source>
                  <context value="heightItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="bundle"/>
                  <contextType value="variable"/>
                  <element value="entry"/>
                  <variable value="obsEntry"/>
                </target>
                <rule>
                  <name value="createheightobs"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="obsEntry"/>
                    <contextType value="variable"/>
                    <element value="resource"/>
                    <variable value="obs"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Observation"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="obsid"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="obs"/>
                      <contextType value="variable"/>
                      <element value="id"/>
                      <transform value="uuid"/>
                    </target>
                  </rule>
                  <rule>
                    <name value="setfullUrl"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="obs"/>
                      <contextType value="variable"/>
                      <element value="id"/>
                      <variable value="obsId"/>
                    </target>
                    <target>
                      <context value="obsEntry"/>
                      <contextType value="variable"/>
                      <element value="fullUrl"/>
                      <transform value="append"/>
                      <parameter>
                        <valueString value="urn:uuid:"/>
                      </parameter>
                      <parameter>
                        <valueId value="obsId"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="obsmeta"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="obs"/>
                      <contextType value="variable"/>
                      <element value="meta"/>
                      <variable value="meta"/>
                      <transform value="create"/>
                      <parameter>
                        <valueString value="Meta"/>
                      </parameter>
                    </target>
                    <rule>
                      <name value="obsprofile"/>
                      <source>
                        <context value="ans"/>
                      </source>
                      <target>
                        <context value="meta"/>
                        <contextType value="variable"/>
                        <element value="profile"/>
                        <transform value="copy"/>
                        <parameter>
                          <valueString
                                       value="https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMObservationBodyHeight"/>
                        </parameter>
                      </target>
                    </rule>
                  </rule>
                  <rule>
                    <name value="obsstatus"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="obs"/>
                      <contextType value="variable"/>
                      <element value="status"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="final"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="obscategory"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="obs"/>
                      <contextType value="variable"/>
                      <element value="category"/>
                      <transform value="cc"/>
                      <parameter>
                        <valueString
                                     value="http://terminology.hl7.org/CodeSystem/observation-category"/>
                      </parameter>
                      <parameter>
                        <valueString value="vital-signs"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="obscode"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="obs"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="cc"/>
                      <parameter>
                        <valueString value="http://loinc.org"/>
                      </parameter>
                      <parameter>
                        <valueString value="8302-2"/>
                      </parameter>
                      <parameter>
                        <valueString value="Body height"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setsubject"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="obs"/>
                      <contextType value="variable"/>
                      <element value="subject"/>
                      <variable value="ref"/>
                      <transform value="create"/>
                      <parameter>
                        <valueString value="Reference"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="patient"/>
                      <contextType value="variable"/>
                      <element value="id"/>
                      <variable value="patId"/>
                    </target>
                    <target>
                      <context value="ref"/>
                      <contextType value="variable"/>
                      <element value="reference"/>
                      <transform value="append"/>
                      <parameter>
                        <valueString value="Patient/"/>
                      </parameter>
                      <parameter>
                        <valueId value="patId"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setvalue"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="obs"/>
                      <contextType value="variable"/>
                      <element value="value"/>
                      <transform value="evaluate"/>
                      <parameter>
                        <valueString value="ans.valueQuantity"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="extracteffective"/>
                    <source>
                      <context value="heightItem"/>
                      <element value="item"/>
                      <variable value="dateItem"/>
                      <condition value="(linkId.contains('Date'))"/>
                    </source>
                    <rule>
                      <name value="seteffective"/>
                      <source>
                        <context value="dateItem"/>
                        <element value="answer"/>
                        <variable value="dateAns"/>
                      </source>
                      <target>
                        <context value="obs"/>
                        <contextType value="variable"/>
                        <element value="effective"/>
                        <transform value="evaluate"/>
                        <parameter>
                          <valueString value="dateAns.valueDate"/>
                        </parameter>
                      </target>
                    </rule>
                  </rule>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="extractweight"/>
              <source>
                <context value="dossierGroup"/>
                <element value="item"/>
                <variable value="weightItem"/>
                <condition value="(linkId = '451513217936')"/>
              </source>
              <rule>
                <name value="weightobsentry"/>
                <source>
                  <context value="weightItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="bundle"/>
                  <contextType value="variable"/>
                  <element value="entry"/>
                  <variable value="obsEntry"/>
                </target>
                <rule>
                  <name value="createweightobs"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="obsEntry"/>
                    <contextType value="variable"/>
                    <element value="resource"/>
                    <variable value="obs"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Observation"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="obsid"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="obs"/>
                      <contextType value="variable"/>
                      <element value="id"/>
                      <transform value="uuid"/>
                    </target>
                  </rule>
                  <rule>
                    <name value="setfullUrl"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="obs"/>
                      <contextType value="variable"/>
                      <element value="id"/>
                      <variable value="obsId"/>
                    </target>
                    <target>
                      <context value="obsEntry"/>
                      <contextType value="variable"/>
                      <element value="fullUrl"/>
                      <transform value="append"/>
                      <parameter>
                        <valueString value="urn:uuid:"/>
                      </parameter>
                      <parameter>
                        <valueId value="obsId"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="obsmeta"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="obs"/>
                      <contextType value="variable"/>
                      <element value="meta"/>
                      <variable value="meta"/>
                      <transform value="create"/>
                      <parameter>
                        <valueString value="Meta"/>
                      </parameter>
                    </target>
                    <rule>
                      <name value="obsprofile"/>
                      <source>
                        <context value="ans"/>
                      </source>
                      <target>
                        <context value="meta"/>
                        <contextType value="variable"/>
                        <element value="profile"/>
                        <transform value="copy"/>
                        <parameter>
                          <valueString
                                       value="https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMObservationBodyWeight"/>
                        </parameter>
                      </target>
                    </rule>
                  </rule>
                  <rule>
                    <name value="obsstatus"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="obs"/>
                      <contextType value="variable"/>
                      <element value="status"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="final"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="obscategory"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="obs"/>
                      <contextType value="variable"/>
                      <element value="category"/>
                      <transform value="cc"/>
                      <parameter>
                        <valueString
                                     value="http://terminology.hl7.org/CodeSystem/observation-category"/>
                      </parameter>
                      <parameter>
                        <valueString value="vital-signs"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="obscode"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="obs"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="cc"/>
                      <parameter>
                        <valueString value="http://loinc.org"/>
                      </parameter>
                      <parameter>
                        <valueString value="29463-7"/>
                      </parameter>
                      <parameter>
                        <valueString value="Body weight"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setsubject"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="obs"/>
                      <contextType value="variable"/>
                      <element value="subject"/>
                      <variable value="ref"/>
                      <transform value="create"/>
                      <parameter>
                        <valueString value="Reference"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="patient"/>
                      <contextType value="variable"/>
                      <element value="id"/>
                      <variable value="patId"/>
                    </target>
                    <target>
                      <context value="ref"/>
                      <contextType value="variable"/>
                      <element value="reference"/>
                      <transform value="append"/>
                      <parameter>
                        <valueString value="Patient/"/>
                      </parameter>
                      <parameter>
                        <valueId value="patId"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setvalue"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="obs"/>
                      <contextType value="variable"/>
                      <element value="value"/>
                      <transform value="evaluate"/>
                      <parameter>
                        <valueString value="ans.valueQuantity"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="extracteffective"/>
                    <source>
                      <context value="weightItem"/>
                      <element value="item"/>
                      <variable value="dateItem"/>
                      <condition value="(linkId.contains('Date'))"/>
                    </source>
                    <rule>
                      <name value="seteffective"/>
                      <source>
                        <context value="dateItem"/>
                        <element value="answer"/>
                        <variable value="dateAns"/>
                      </source>
                      <target>
                        <context value="obs"/>
                        <contextType value="variable"/>
                        <element value="effective"/>
                        <transform value="evaluate"/>
                        <parameter>
                          <valueString value="dateAns.valueDate"/>
                        </parameter>
                      </target>
                    </rule>
                  </rule>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="extractbloodpressure"/>
              <source>
                <context value="dossierGroup"/>
                <element value="item"/>
                <variable value="sysItem"/>
                <condition value="(linkId = '4160905247955')"/>
              </source>
              <rule>
                <name value="processsystolic"/>
                <source>
                  <context value="sysItem"/>
                  <element value="answer"/>
                  <variable value="sysAns"/>
                </source>
                <rule>
                  <name value="extractdiastolic"/>
                  <source>
                    <context value="dossierGroup"/>
                    <element value="item"/>
                    <variable value="diaItem"/>
                    <condition value="(linkId = '848797127998')"/>
                  </source>
                  <rule>
                    <name value="bpobsentr"/>
                    <source>
                      <context value="diaItem"/>
                      <element value="answer"/>
                      <variable value="diaAns"/>
                    </source>
                    <target>
                      <context value="bundle"/>
                      <contextType value="variable"/>
                      <element value="entry"/>
                      <variable value="obsEntry"/>
                    </target>
                    <rule>
                      <name value="createbpobs"/>
                      <source>
                        <context value="sysAns"/>
                      </source>
                      <target>
                        <context value="obsEntry"/>
                        <contextType value="variable"/>
                        <element value="resource"/>
                        <variable value="obs"/>
                        <transform value="create"/>
                        <parameter>
                          <valueString value="Observation"/>
                        </parameter>
                      </target>
                      <rule>
                        <name value="obsid"/>
                        <source>
                          <context value="sysAns"/>
                        </source>
                        <target>
                          <context value="obs"/>
                          <contextType value="variable"/>
                          <element value="id"/>
                          <transform value="uuid"/>
                        </target>
                      </rule>
                      <rule>
                        <name value="setfullUrl"/>
                        <source>
                          <context value="sysAns"/>
                        </source>
                        <target>
                          <context value="obs"/>
                          <contextType value="variable"/>
                          <element value="id"/>
                          <variable value="obsId"/>
                        </target>
                        <target>
                          <context value="obsEntry"/>
                          <contextType value="variable"/>
                          <element value="fullUrl"/>
                          <transform value="append"/>
                          <parameter>
                            <valueString value="urn:uuid:"/>
                          </parameter>
                          <parameter>
                            <valueId value="obsId"/>
                          </parameter>
                        </target>
                      </rule>
                      <rule>
                        <name value="obsmeta"/>
                        <source>
                          <context value="sysAns"/>
                        </source>
                        <target>
                          <context value="obs"/>
                          <contextType value="variable"/>
                          <element value="meta"/>
                          <variable value="meta"/>
                          <transform value="create"/>
                          <parameter>
                            <valueString value="Meta"/>
                          </parameter>
                        </target>
                        <rule>
                          <name value="obsprofile"/>
                          <source>
                            <context value="sysAns"/>
                          </source>
                          <target>
                            <context value="meta"/>
                            <contextType value="variable"/>
                            <element value="profile"/>
                            <transform value="copy"/>
                            <parameter>
                              <valueString
                                           value="https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMObservationBloodPressure"/>
                            </parameter>
                          </target>
                        </rule>
                      </rule>
                      <rule>
                        <name value="obsstatus"/>
                        <source>
                          <context value="sysAns"/>
                        </source>
                        <target>
                          <context value="obs"/>
                          <contextType value="variable"/>
                          <element value="status"/>
                          <transform value="copy"/>
                          <parameter>
                            <valueString value="final"/>
                          </parameter>
                        </target>
                      </rule>
                      <rule>
                        <name value="obscategory"/>
                        <source>
                          <context value="sysAns"/>
                        </source>
                        <target>
                          <context value="obs"/>
                          <contextType value="variable"/>
                          <element value="category"/>
                          <transform value="cc"/>
                          <parameter>
                            <valueString
                                         value="http://terminology.hl7.org/CodeSystem/observation-category"/>
                          </parameter>
                          <parameter>
                            <valueString value="vital-signs"/>
                          </parameter>
                        </target>
                      </rule>
                      <rule>
                        <name value="obscode"/>
                        <source>
                          <context value="sysAns"/>
                        </source>
                        <target>
                          <context value="obs"/>
                          <contextType value="variable"/>
                          <element value="code"/>
                          <transform value="cc"/>
                          <parameter>
                            <valueString value="http://loinc.org"/>
                          </parameter>
                          <parameter>
                            <valueString value="85354-9"/>
                          </parameter>
                          <parameter>
                            <valueString value="Blood pressure panel"/>
                          </parameter>
                        </target>
                      </rule>
                      <rule>
                        <name value="setsubject"/>
                        <source>
                          <context value="sysAns"/>
                        </source>
                        <target>
                          <context value="obs"/>
                          <contextType value="variable"/>
                          <element value="subject"/>
                          <variable value="ref"/>
                          <transform value="create"/>
                          <parameter>
                            <valueString value="Reference"/>
                          </parameter>
                        </target>
                        <target>
                          <context value="patient"/>
                          <contextType value="variable"/>
                          <element value="id"/>
                          <variable value="patId"/>
                        </target>
                        <target>
                          <context value="ref"/>
                          <contextType value="variable"/>
                          <element value="reference"/>
                          <transform value="append"/>
                          <parameter>
                            <valueString value="Patient/"/>
                          </parameter>
                          <parameter>
                            <valueId value="patId"/>
                          </parameter>
                        </target>
                      </rule>
                      <rule>
                        <name value="setsystolic"/>
                        <source>
                          <context value="sysAns"/>
                        </source>
                        <target>
                          <context value="obs"/>
                          <contextType value="variable"/>
                          <element value="component"/>
                          <variable value="sysComp"/>
                          <transform value="create"/>
                          <parameter>
                            <valueString value="Observation"/>
                          </parameter>
                        </target>
                        <rule>
                          <name value="syscode"/>
                          <source>
                            <context value="sysAns"/>
                          </source>
                          <target>
                            <context value="sysComp"/>
                            <contextType value="variable"/>
                            <element value="code"/>
                            <transform value="cc"/>
                            <parameter>
                              <valueString value="http://loinc.org"/>
                            </parameter>
                            <parameter>
                              <valueString value="8480-6"/>
                            </parameter>
                            <parameter>
                              <valueString value="Systolic blood pressure"/>
                            </parameter>
                          </target>
                        </rule>
                        <rule>
                          <name value="sysvalue"/>
                          <source>
                            <context value="sysAns"/>
                          </source>
                          <target>
                            <context value="sysComp"/>
                            <contextType value="variable"/>
                            <element value="value"/>
                            <transform value="evaluate"/>
                            <parameter>
                              <valueString value="sysAns.valueQuantity"/>
                            </parameter>
                          </target>
                        </rule>
                      </rule>
                      <rule>
                        <name value="setdiastolic"/>
                        <source>
                          <context value="diaAns"/>
                        </source>
                        <target>
                          <context value="obs"/>
                          <contextType value="variable"/>
                          <element value="component"/>
                          <variable value="diaComp"/>
                          <transform value="create"/>
                          <parameter>
                            <valueString value="Observation"/>
                          </parameter>
                        </target>
                        <rule>
                          <name value="diacode"/>
                          <source>
                            <context value="diaAns"/>
                          </source>
                          <target>
                            <context value="diaComp"/>
                            <contextType value="variable"/>
                            <element value="code"/>
                            <transform value="cc"/>
                            <parameter>
                              <valueString value="http://loinc.org"/>
                            </parameter>
                            <parameter>
                              <valueString value="8462-4"/>
                            </parameter>
                            <parameter>
                              <valueString value="Diastolic blood pressure"/>
                            </parameter>
                          </target>
                        </rule>
                        <rule>
                          <name value="diavalue"/>
                          <source>
                            <context value="diaAns"/>
                          </source>
                          <target>
                            <context value="diaComp"/>
                            <contextType value="variable"/>
                            <element value="value"/>
                            <transform value="evaluate"/>
                            <parameter>
                              <valueString value="diaAns.valueQuantity"/>
                            </parameter>
                          </target>
                        </rule>
                      </rule>
                      <rule>
                        <name value="extracteffective"/>
                        <source>
                          <context value="sysItem"/>
                          <element value="item"/>
                          <variable value="dateItem"/>
                          <condition value="(linkId.contains('Date'))"/>
                        </source>
                        <rule>
                          <name value="seteffective"/>
                          <source>
                            <context value="dateItem"/>
                            <element value="answer"/>
                            <variable value="dateAns"/>
                          </source>
                          <target>
                            <context value="obs"/>
                            <contextType value="variable"/>
                            <element value="effective"/>
                            <transform value="evaluate"/>
                            <parameter>
                              <valueString value="dateAns.valueDate"/>
                            </parameter>
                          </target>
                        </rule>
                      </rule>
                    </rule>
                  </rule>
                </rule>
              </rule>
            </rule>
          </rule>
        </rule>
      </group>
      <group>
        <name value="CreateLaboratoryObservations"/>
        <typeMode value="none"/>
        <documentation value="Group: Create Laboratory Observations"/>
        <input>
          <name value="src"/>
          <type value="QuestionnaireResponse"/>
          <mode value="source"/>
        </input>
        <input>
          <name value="patient"/>
          <type value="Patient"/>
          <mode value="target"/>
        </input>
        <input>
          <name value="bundle"/>
          <type value="Bundle"/>
          <mode value="target"/>
        </input>
        <rule>
          <name value="processbiology"/>
          <source>
            <context value="src"/>
            <element value="item"/>
            <variable value="bioGroup"/>
            <condition value="(linkId = '7702944131447')"/>
          </source>
          <rule>
            <name value="processrenal"/>
            <source>
              <context value="bioGroup"/>
              <element value="item"/>
              <variable value="renalGroup"/>
              <condition value="(linkId = '5241323453538')"/>
            </source>
            <rule>
              <name value="extracturea"/>
              <source>
                <context value="renalGroup"/>
                <element value="item"/>
                <variable value="ureaItem"/>
                <condition value="(linkId = '7169026818760')"/>
              </source>
              <rule>
                <name value="createureaobs"/>
                <source>
                  <context value="ureaItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="bundle"/>
                  <contextType value="variable"/>
                </target>
                <dependent>
                  <name value="CreateLabObservation"/>
                  <variable value="ans"/>
                  <variable value="ureaItem"/>
                  <variable value="patient"/>
                  <variable value="bundle"/>
                </dependent>
              </rule>
            </rule>
            <rule>
              <name value="extractcreat"/>
              <source>
                <context value="renalGroup"/>
                <element value="item"/>
                <variable value="creatItem"/>
                <condition value="(linkId = '500408205043')"/>
              </source>
              <rule>
                <name value="createcreatobs"/>
                <source>
                  <context value="creatItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="bundle"/>
                  <contextType value="variable"/>
                </target>
                <dependent>
                  <name value="CreateLabObservation"/>
                  <variable value="ans"/>
                  <variable value="creatItem"/>
                  <variable value="patient"/>
                  <variable value="bundle"/>
                </dependent>
              </rule>
            </rule>
            <rule>
              <name value="extractdfg"/>
              <source>
                <context value="renalGroup"/>
                <element value="item"/>
                <variable value="dfgItem"/>
                <condition value="(linkId = '786621340679')"/>
              </source>
              <rule>
                <name value="createdfgobs"/>
                <source>
                  <context value="dfgItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="bundle"/>
                  <contextType value="variable"/>
                </target>
                <dependent>
                  <name value="CreateLabObservation"/>
                  <variable value="ans"/>
                  <variable value="dfgItem"/>
                  <variable value="patient"/>
                  <variable value="bundle"/>
                </dependent>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="processhemo"/>
            <source>
              <context value="bioGroup"/>
              <element value="item"/>
              <variable value="hemoGroup"/>
              <condition value="(linkId = '419282985970')"/>
            </source>
            <rule>
              <name value="extractleuko"/>
              <source>
                <context value="hemoGroup"/>
                <element value="item"/>
                <variable value="leukoItem"/>
                <condition value="(linkId = '210077225604')"/>
              </source>
              <rule>
                <name value="createleukoobs"/>
                <source>
                  <context value="leukoItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="bundle"/>
                  <contextType value="variable"/>
                </target>
                <dependent>
                  <name value="CreateLabObservation"/>
                  <variable value="ans"/>
                  <variable value="leukoItem"/>
                  <variable value="patient"/>
                  <variable value="bundle"/>
                </dependent>
              </rule>
            </rule>
            <rule>
              <name value="extracthemo"/>
              <source>
                <context value="hemoGroup"/>
                <element value="item"/>
                <variable value="hemoItem"/>
                <condition value="(linkId = '304159088493')"/>
              </source>
              <rule>
                <name value="createhemoobs"/>
                <source>
                  <context value="hemoItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="bundle"/>
                  <contextType value="variable"/>
                </target>
                <dependent>
                  <name value="CreateLabObservation"/>
                  <variable value="ans"/>
                  <variable value="hemoItem"/>
                  <variable value="patient"/>
                  <variable value="bundle"/>
                </dependent>
              </rule>
            </rule>
            <rule>
              <name value="extracthemat"/>
              <source>
                <context value="hemoGroup"/>
                <element value="item"/>
                <variable value="hematItem"/>
                <condition value="(linkId = '5687959006070')"/>
              </source>
              <rule>
                <name value="createhematobs"/>
                <source>
                  <context value="hematItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="bundle"/>
                  <contextType value="variable"/>
                </target>
                <dependent>
                  <name value="CreateLabObservation"/>
                  <variable value="ans"/>
                  <variable value="hematItem"/>
                  <variable value="patient"/>
                  <variable value="bundle"/>
                </dependent>
              </rule>
            </rule>
            <rule>
              <name value="extractery"/>
              <source>
                <context value="hemoGroup"/>
                <element value="item"/>
                <variable value="eryItem"/>
                <condition value="(linkId = '8697447896867')"/>
              </source>
              <rule>
                <name value="createeryobs"/>
                <source>
                  <context value="eryItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="bundle"/>
                  <contextType value="variable"/>
                </target>
                <dependent>
                  <name value="CreateLabObservation"/>
                  <variable value="ans"/>
                  <variable value="eryItem"/>
                  <variable value="patient"/>
                  <variable value="bundle"/>
                </dependent>
              </rule>
            </rule>
            <rule>
              <name value="extractvgm"/>
              <source>
                <context value="hemoGroup"/>
                <element value="item"/>
                <variable value="vgmItem"/>
                <condition value="(linkId = '5584978899134')"/>
              </source>
              <rule>
                <name value="createvgmobs"/>
                <source>
                  <context value="vgmItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="bundle"/>
                  <contextType value="variable"/>
                </target>
                <dependent>
                  <name value="CreateLabObservation"/>
                  <variable value="ans"/>
                  <variable value="vgmItem"/>
                  <variable value="patient"/>
                  <variable value="bundle"/>
                </dependent>
              </rule>
            </rule>
            <rule>
              <name value="extractplat"/>
              <source>
                <context value="hemoGroup"/>
                <element value="item"/>
                <variable value="platItem"/>
                <condition value="(linkId = '2881119993430')"/>
              </source>
              <rule>
                <name value="createplatobs"/>
                <source>
                  <context value="platItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="bundle"/>
                  <contextType value="variable"/>
                </target>
                <dependent>
                  <name value="CreateLabObservation"/>
                  <variable value="ans"/>
                  <variable value="platItem"/>
                  <variable value="patient"/>
                  <variable value="bundle"/>
                </dependent>
              </rule>
            </rule>
            <rule>
              <name value="extractneut"/>
              <source>
                <context value="hemoGroup"/>
                <element value="item"/>
                <variable value="neutItem"/>
                <condition value="(linkId = '7408951746270')"/>
              </source>
              <rule>
                <name value="createneutobs"/>
                <source>
                  <context value="neutItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="bundle"/>
                  <contextType value="variable"/>
                </target>
                <dependent>
                  <name value="CreateLabObservation"/>
                  <variable value="ans"/>
                  <variable value="neutItem"/>
                  <variable value="patient"/>
                  <variable value="bundle"/>
                </dependent>
              </rule>
            </rule>
            <rule>
              <name value="extractlymph"/>
              <source>
                <context value="hemoGroup"/>
                <element value="item"/>
                <variable value="lymphItem"/>
                <condition value="(linkId = '809808816195')"/>
              </source>
              <rule>
                <name value="createlymphobs"/>
                <source>
                  <context value="lymphItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="bundle"/>
                  <contextType value="variable"/>
                </target>
                <dependent>
                  <name value="CreateLabObservation"/>
                  <variable value="ans"/>
                  <variable value="lymphItem"/>
                  <variable value="patient"/>
                  <variable value="bundle"/>
                </dependent>
              </rule>
            </rule>
            <rule>
              <name value="extracteosi"/>
              <source>
                <context value="hemoGroup"/>
                <element value="item"/>
                <variable value="eosiItem"/>
                <condition value="(linkId = '6451887990893')"/>
              </source>
              <rule>
                <name value="createeosiobs"/>
                <source>
                  <context value="eosiItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="bundle"/>
                  <contextType value="variable"/>
                </target>
                <dependent>
                  <name value="CreateLabObservation"/>
                  <variable value="ans"/>
                  <variable value="eosiItem"/>
                  <variable value="patient"/>
                  <variable value="bundle"/>
                </dependent>
              </rule>
            </rule>
            <rule>
              <name value="extractmono"/>
              <source>
                <context value="hemoGroup"/>
                <element value="item"/>
                <variable value="monoItem"/>
                <condition value="(linkId = '7935935816936')"/>
              </source>
              <rule>
                <name value="createmonoobs"/>
                <source>
                  <context value="monoItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="bundle"/>
                  <contextType value="variable"/>
                </target>
                <dependent>
                  <name value="CreateLabObservation"/>
                  <variable value="ans"/>
                  <variable value="monoItem"/>
                  <variable value="patient"/>
                  <variable value="bundle"/>
                </dependent>
              </rule>
            </rule>
            <rule>
              <name value="extracttp"/>
              <source>
                <context value="hemoGroup"/>
                <element value="item"/>
                <variable value="tpItem"/>
                <condition value="(linkId = '2055949655770')"/>
              </source>
              <rule>
                <name value="createtpobs"/>
                <source>
                  <context value="tpItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="bundle"/>
                  <contextType value="variable"/>
                </target>
                <dependent>
                  <name value="CreateLabObservation"/>
                  <variable value="ans"/>
                  <variable value="tpItem"/>
                  <variable value="patient"/>
                  <variable value="bundle"/>
                </dependent>
              </rule>
            </rule>
            <rule>
              <name value="extracttca"/>
              <source>
                <context value="hemoGroup"/>
                <element value="item"/>
                <variable value="tcaItem"/>
                <condition value="(linkId = '2527095476817')"/>
              </source>
              <rule>
                <name value="createtcaobs"/>
                <source>
                  <context value="tcaItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="bundle"/>
                  <contextType value="variable"/>
                </target>
                <dependent>
                  <name value="CreateLabObservation"/>
                  <variable value="ans"/>
                  <variable value="tcaItem"/>
                  <variable value="patient"/>
                  <variable value="bundle"/>
                </dependent>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="processliver"/>
            <source>
              <context value="bioGroup"/>
              <element value="item"/>
              <variable value="liverGroup"/>
              <condition value="(linkId = '3893612773040')"/>
            </source>
            <rule>
              <name value="extractasat"/>
              <source>
                <context value="liverGroup"/>
                <element value="item"/>
                <variable value="asatItem"/>
                <condition value="(linkId = '3028330976100')"/>
              </source>
              <rule>
                <name value="createasatobs"/>
                <source>
                  <context value="asatItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="bundle"/>
                  <contextType value="variable"/>
                </target>
                <dependent>
                  <name value="CreateLabObservation"/>
                  <variable value="ans"/>
                  <variable value="asatItem"/>
                  <variable value="patient"/>
                  <variable value="bundle"/>
                </dependent>
              </rule>
            </rule>
            <rule>
              <name value="extractalat"/>
              <source>
                <context value="liverGroup"/>
                <element value="item"/>
                <variable value="alatItem"/>
                <condition value="(linkId = '8486813893880')"/>
              </source>
              <rule>
                <name value="createalatobs"/>
                <source>
                  <context value="alatItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="bundle"/>
                  <contextType value="variable"/>
                </target>
                <dependent>
                  <name value="CreateLabObservation"/>
                  <variable value="ans"/>
                  <variable value="alatItem"/>
                  <variable value="patient"/>
                  <variable value="bundle"/>
                </dependent>
              </rule>
            </rule>
            <rule>
              <name value="extractggt"/>
              <source>
                <context value="liverGroup"/>
                <element value="item"/>
                <variable value="ggtItem"/>
                <condition value="(linkId = '3663296044037')"/>
              </source>
              <rule>
                <name value="createggtobs"/>
                <source>
                  <context value="ggtItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="bundle"/>
                  <contextType value="variable"/>
                </target>
                <dependent>
                  <name value="CreateLabObservation"/>
                  <variable value="ans"/>
                  <variable value="ggtItem"/>
                  <variable value="patient"/>
                  <variable value="bundle"/>
                </dependent>
              </rule>
            </rule>
            <rule>
              <name value="extractpal"/>
              <source>
                <context value="liverGroup"/>
                <element value="item"/>
                <variable value="palItem"/>
                <condition value="(linkId = '2690026606933')"/>
              </source>
              <rule>
                <name value="createpalobs"/>
                <source>
                  <context value="palItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="bundle"/>
                  <contextType value="variable"/>
                </target>
                <dependent>
                  <name value="CreateLabObservation"/>
                  <variable value="ans"/>
                  <variable value="palItem"/>
                  <variable value="patient"/>
                  <variable value="bundle"/>
                </dependent>
              </rule>
            </rule>
            <rule>
              <name value="extractbiltot"/>
              <source>
                <context value="liverGroup"/>
                <element value="item"/>
                <variable value="bilTotItem"/>
                <condition value="(linkId = '9068831071023')"/>
              </source>
              <rule>
                <name value="createbiltotobs"/>
                <source>
                  <context value="bilTotItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="bundle"/>
                  <contextType value="variable"/>
                </target>
                <dependent>
                  <name value="CreateLabObservation"/>
                  <variable value="ans"/>
                  <variable value="bilTotItem"/>
                  <variable value="patient"/>
                  <variable value="bundle"/>
                </dependent>
              </rule>
            </rule>
            <rule>
              <name value="extractbilconj"/>
              <source>
                <context value="liverGroup"/>
                <element value="item"/>
                <variable value="bilConjItem"/>
                <condition value="(linkId = '8893717988787')"/>
              </source>
              <rule>
                <name value="createbilconjobs"/>
                <source>
                  <context value="bilConjItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="bundle"/>
                  <contextType value="variable"/>
                </target>
                <dependent>
                  <name value="CreateLabObservation"/>
                  <variable value="ans"/>
                  <variable value="bilConjItem"/>
                  <variable value="patient"/>
                  <variable value="bundle"/>
                </dependent>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="processglucose"/>
            <source>
              <context value="bioGroup"/>
              <element value="item"/>
              <variable value="glucoseGroup"/>
              <condition value="(linkId = '8929068894076')"/>
            </source>
            <rule>
              <name value="extractglyc"/>
              <source>
                <context value="glucoseGroup"/>
                <element value="item"/>
                <variable value="glycItem"/>
                <condition value="(linkId = '8193929027997')"/>
              </source>
              <rule>
                <name value="createglycobs"/>
                <source>
                  <context value="glycItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="bundle"/>
                  <contextType value="variable"/>
                </target>
                <dependent>
                  <name value="CreateLabObservation"/>
                  <variable value="ans"/>
                  <variable value="glycItem"/>
                  <variable value="patient"/>
                  <variable value="bundle"/>
                </dependent>
              </rule>
            </rule>
            <rule>
              <name value="extracthba1c"/>
              <source>
                <context value="glucoseGroup"/>
                <element value="item"/>
                <variable value="hba1cItem"/>
                <condition value="(linkId = '7063892830923')"/>
              </source>
              <rule>
                <name value="createhba1cobs"/>
                <source>
                  <context value="hba1cItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="bundle"/>
                  <contextType value="variable"/>
                </target>
                <dependent>
                  <name value="CreateLabObservation"/>
                  <variable value="ans"/>
                  <variable value="hba1cItem"/>
                  <variable value="patient"/>
                  <variable value="bundle"/>
                </dependent>
              </rule>
            </rule>
          </rule>
        </rule>
      </group>
      <group>
        <name value="CreateLabObservation"/>
        <typeMode value="none"/>
        <documentation value="Helper: Create a single Laboratory Observation"/>
        <input>
          <name value="ans"/>
          <mode value="source"/>
        </input>
        <input>
          <name value="parentItem"/>
          <mode value="source"/>
        </input>
        <input>
          <name value="patient"/>
          <type value="Patient"/>
          <mode value="target"/>
        </input>
        <input>
          <name value="bundle"/>
          <type value="Bundle"/>
          <mode value="target"/>
        </input>
        <rule>
          <name value="obsentry"/>
          <source>
            <context value="ans"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="obsEntry"/>
          </target>
          <rule>
            <name value="createobs"/>
            <source>
              <context value="ans"/>
            </source>
            <target>
              <context value="obsEntry"/>
              <contextType value="variable"/>
              <element value="resource"/>
              <variable value="obs"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Observation"/>
              </parameter>
            </target>
            <rule>
              <name value="obsid"/>
              <source>
                <context value="ans"/>
              </source>
              <target>
                <context value="obs"/>
                <contextType value="variable"/>
                <element value="id"/>
                <transform value="uuid"/>
              </target>
            </rule>
            <rule>
              <name value="setfullUrl"/>
              <source>
                <context value="ans"/>
              </source>
              <target>
                <context value="obs"/>
                <contextType value="variable"/>
                <element value="id"/>
                <variable value="obsId"/>
              </target>
              <target>
                <context value="obsEntry"/>
                <contextType value="variable"/>
                <element value="fullUrl"/>
                <transform value="append"/>
                <parameter>
                  <valueString value="urn:uuid:"/>
                </parameter>
                <parameter>
                  <valueId value="obsId"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="obsmeta"/>
              <source>
                <context value="ans"/>
              </source>
              <target>
                <context value="obs"/>
                <contextType value="variable"/>
                <element value="meta"/>
                <variable value="meta"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Meta"/>
                </parameter>
              </target>
              <rule>
                <name value="obsprofile"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="meta"/>
                  <contextType value="variable"/>
                  <element value="profile"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/dm-observation-laboratory-generic"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="obsstatus"/>
              <source>
                <context value="ans"/>
              </source>
              <target>
                <context value="obs"/>
                <contextType value="variable"/>
                <element value="status"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="final"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setcategory"/>
              <source>
                <context value="ans"/>
              </source>
              <target>
                <context value="obs"/>
                <contextType value="variable"/>
                <element value="category"/>
                <variable value="cat"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="CodeableConcept"/>
                </parameter>
              </target>
              <rule>
                <name value="setcategorycoding"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="cat"/>
                  <contextType value="variable"/>
                  <element value="coding"/>
                  <variable value="coding"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="Coding"/>
                  </parameter>
                </target>
                <rule>
                  <name value="catsystem"/>
                  <source>
                    <context value="ans"/>
                  </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="catcode"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="coding"/>
                    <contextType value="variable"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="laboratory"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="setsubject"/>
              <source>
                <context value="ans"/>
              </source>
              <target>
                <context value="obs"/>
                <contextType value="variable"/>
                <element value="subject"/>
                <variable value="ref"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Reference"/>
                </parameter>
              </target>
              <target>
                <context value="patient"/>
                <contextType value="variable"/>
                <element value="id"/>
                <variable value="patId"/>
              </target>
              <target>
                <context value="ref"/>
                <contextType value="variable"/>
                <element value="reference"/>
                <transform value="append"/>
                <parameter>
                  <valueString value="Patient/"/>
                </parameter>
                <parameter>
                  <valueId value="patId"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setvalue"/>
              <source>
                <context value="ans"/>
              </source>
              <target>
                <context value="obs"/>
                <contextType value="variable"/>
                <element value="value"/>
                <transform value="evaluate"/>
                <parameter>
                  <valueString value="ans.valueQuantity"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="extractloinc"/>
              <source>
                <context value="parentItem"/>
                <element value="item"/>
                <variable value="loincItem"/>
                <condition value="(linkId.contains('code loinc'))"/>
              </source>
              <rule>
                <name value="setcode"/>
                <source>
                  <context value="loincItem"/>
                  <element value="answer"/>
                  <variable value="loincAns"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <variable value="code"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="CodeableConcept"/>
                  </parameter>
                </target>
                <rule>
                  <name value="setloinccoding"/>
                  <source>
                    <context value="loincAns"/>
                  </source>
                  <target>
                    <context value="code"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="loincAns.valueCoding"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="extracteffective"/>
              <source>
                <context value="parentItem"/>
                <element value="item"/>
                <variable value="dateItem"/>
                <condition
                           value="(linkId.contains('Date et heure du prélèvement'))"/>
              </source>
              <rule>
                <name value="seteffective"/>
                <source>
                  <context value="dateItem"/>
                  <element value="answer"/>
                  <variable value="dateAns"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="effective"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="dateAns.valueDateTime"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </group>
    </StructureMap>