Données socles des Entrepôts de Données de Santé Hospitalier
0.1.0 - ci-build FRA

Données socles des Entrepôts de Données de Santé Hospitalier - 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-05-28

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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-patient'</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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-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><span style="color: navy"><b> -&gt; </b></span>patient.multipleBirth = <span style="color: navy">(</span>%ans.valueInteger<span style="color: navy">)</span> <i>&quot;setmultiplebirth&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.valueString<b> as </b><span style="color: maroon">female</span><b> where </b>($this = 'f')<span style="color: navy"><b> -&gt; </b></span>patient.gender = <span style="color: blue">'female'</span> <i>&quot;setGenderF&quot;</i><span style="color: navy">;</span>
              ans.valueString<b> as </b><span style="color: maroon">female</span><b> where </b>($this = 'm')<span style="color: navy"><b> -&gt; </b></span>patient.gender = <span style="color: blue">'male'</span> <i>&quot;setGenderM&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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-pmsi-code-geo'</span> <i>&quot;codegeourl&quot;</i><span style="color: navy">;</span>
                ans.value<b> as </b><span style="color: maroon">val</span><span style="color: navy"><b> -&gt; </b></span>ext.value = <b>cast</b><span style="color: navy">(</span><span style="color: maroon">val</span><span style="color: navy">, </span><span style="color: blue">'code'</span><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><span style="color: green">Environnement</span>
              socioDemo.item<b> as </b><span style="color: maroon">environnementItem</span><b> where </b>(linkId = '5491974639955')<b> then</b><span style="color: navy"> {
    </span>            <span style="color: navy">// </span><span style="color: green">geolocation</span>
                environnementItem.item<b> as </b><span style="color: maroon">geocodageItem</span><b> where </b>(linkId = '3816475533472')<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">geolocationExt</span><b> then</b><span style="color: navy"> {
    </span>              geocodageItem.item<b> as </b><span style="color: maroon">latItem</span><b> where </b>(linkId = '3709843054556')<span style="color: navy"><b> -&gt; </b></span> geolocationExt.url = <span style="color: blue">'http://hl7.org/fhir/StructureDefinition/geolocation'</span><span style="color: navy">, </span> geolocationExt.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">latExt</span><b> then</b><span style="color: navy"> {
    </span>                latItem.answer<b> as </b><span style="color: maroon">lat</span><span style="color: navy"><b> -&gt; </b></span> latExt.url = <span style="color: blue">'latitude'</span><span style="color: navy">, </span> latExt.value = <span style="color: navy">(</span>%lat.valueDecimal<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
    </span>                  geocodageItem.item<b> as </b><span style="color: maroon">longItem</span><b> where </b>(linkId = '7651448032665')<span style="color: navy"><b> -&gt; </b></span>geolocationExt.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">longExt</span><b> then</b><span style="color: navy"> {
    </span>                    longItem.answer<b> as </b><span style="color: maroon">long</span><span style="color: navy"><b> -&gt; </b></span> longExt.url = <span style="color: blue">'longitude'</span><span style="color: navy">, </span> longExt.value = <span style="color: navy">(</span>%long.valueDecimal<span style="color: navy">)</span> <i>&quot;setLong&quot;</i><span style="color: navy">;</span>
                      <span style="color: navy">}</span> <i>&quot;createLongExt&quot;</i><span style="color: navy">;</span>
                    <span style="color: navy">}</span> <i>&quot;setLat&quot;</i><span style="color: navy">;</span>
                  <span style="color: navy">}</span> <i>&quot;createLatExt&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;createGeolocExt&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">// </span><span style="color: green">IRIS</span>
                environnementItem.item<b> as </b><span style="color: maroon">irisItem</span><b> where </b>(linkId = '7621032273792')<span style="color: navy"><b> -&gt; </b></span> addr.line<b> as </b><span style="color: maroon">addrLine</span><span style="color: navy">, </span> addrLine.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">irisExt</span><b> then</b><span style="color: navy"> {
    </span>              irisItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span> irisExt.url = <span style="color: blue">'http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-censusTract'</span><span style="color: navy">, </span> irisExt.valueString = <span style="color: navy">(</span>%ans.valueString<span style="color: navy">)</span> <i>&quot;setIrisExt&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;navIrisItem&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;navEnv&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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-location'</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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-location'</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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-encounter'</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">status</span>
          src<span style="color: navy"><b> -&gt; </b></span>encounter.status = <span style="color: blue">'finished'</span> <i>&quot;setStatus&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">class</span>
          src<span style="color: navy"><b> -&gt; </b></span>encounter.class = <b>c</b><span style="color: navy">(</span><span style="color: blue">'http://terminology.hl7.org/CodeSystem/v3-ActCode'</span><span style="color: navy">, </span><span style="color: blue">'IMP'</span><span style="color: navy">)</span> <i>&quot;setClass&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')<b> then</b><span style="color: navy"> {
    </span>        modeInItem.answer<b> as </b><span style="color: maroon">ans</span><b> then</b><span style="color: navy"> {
    </span>          ans.valueString<b> as </b><span style="color: maroon">valueString</span><span style="color: navy"><b> -&gt; </b></span> encounter.hospitalization<b> as </b><span style="color: maroon">hosp</span><span style="color: navy">, </span> hosp.admitSource<b> as </b><span style="color: maroon">admitSource</span><span style="color: navy">, </span> admitSource.coding<b> as </b><span style="color: maroon">admitSourceCoding</span><span style="color: navy">, </span> admitSourceCoding.code = <span style="color: maroon">valueString</span> <i>&quot;setadmitsource&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;navValue&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <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')<b> then</b><span style="color: navy"> {
    </span>        modeOutItem.answer<b> as </b><span style="color: maroon">ans</span><b> then</b><span style="color: navy"> {
    </span>          ans.valueString<b> as </b><span style="color: maroon">valueString</span><span style="color: navy"><b> -&gt; </b></span> encounter.hospitalization<b> as </b><span style="color: maroon">hosp</span><span style="color: navy">, </span> hosp.dischargeDisposition<b> as </b><span style="color: maroon">dischargeDisposition</span><span style="color: navy">, </span> dischargeDisposition.coding<b> as </b><span style="color: maroon">dischargeDispositionCoding</span><span style="color: navy">, </span> dischargeDispositionCoding.code = <span style="color: maroon">valueString</span> <i>&quot;setdischargedisposition&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;navValue&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-condition'</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<b> as </b><span style="color: maroon">coding</span><span style="color: navy">, </span> coding.code = <span style="color: navy">(</span>%ans.valueString<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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/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.valueString<span style="color: navy">)</span> <i>&quot;diagtypecode&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><span style="color: green">fullurl</span>
          pmsiItem<span style="color: navy"><b> -&gt; </b></span> condition.id<b> as </b><span style="color: maroon">condId</span><span style="color: navy">, </span> conditionEntry.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">condId</span><span style="color: navy">)</span> <i>&quot;setfullUrl&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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-procedure'</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">status</span>
          acteGroup<span style="color: navy"><b> -&gt; </b></span>procedure.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">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<b> as </b><span style="color: maroon">coding</span><span style="color: navy">, </span> coding.code = <span style="color: navy">(</span>%ans.valueString<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><span style="color: green">fullurl</span>
          pmsiItem<span style="color: navy"><b> -&gt; </b></span> procedure.id<b> as </b><span style="color: maroon">procId</span><span style="color: navy">, </span> procedureEntry.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">procId</span><span style="color: navy">)</span> <i>&quot;setfullUrl&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>
            <span style="color: navy">// </span><span style="color: green">fullurl</span>
            src<span style="color: navy"><b> -&gt; </b></span> medReq.id<b> as </b><span style="color: maroon">medReqId</span><span style="color: navy">, </span> medReqEntry.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">medReqId</span><span style="color: navy">)</span> <i>&quot;setfullUrl&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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-medication-request'</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">MedicationCodeableConcept</span>
            prescribedGroup.answer<b> as </b><span style="color: maroon">prescribedMedication</span><b> then</b><span style="color: navy"> {
    </span>          prescribedMedication.item<b> as </b><span style="color: maroon">atcItem</span><b> where </b>(linkId = '1923143398283')<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> medReq.medication = <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">medReqCC</span><span style="color: navy">, </span> medReqCC.coding<b> as </b><span style="color: maroon">medReqC</span><span style="color: navy">, </span> medReqC.code = <span style="color: navy">(</span>%ans.valueString<span style="color: navy">)</span><span style="color: navy">, </span> medReqC.display = <span style="color: navy">(</span>%prescribedMedication.valueString<span style="color: navy">)</span> <i>&quot;setAtcCoding&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;navAtcItem&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;navPrescribedMedication&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">// </span><span style="color: green">Create Medication resource and reference</span>
            <span style="color: navy">// </span><span style="color: green">prescribedGroup -&gt; bundle.entry as medEntry then {           prescribedGroup -&gt; medEntry.resource = create('Medication') as medication then {             prescribedGroup -&gt; medication.id = uuid() &quot;med-id&quot;;              // ATC code from nested items             prescribedGroup.item as atcItem where (linkId.contains('ATC')) then {               atcItem.answer as ans -&gt; medication.code = create('CodeableConcept') as code then {                 ans -&gt; code.coding = (%ans.valueCoding) &quot;set-atc-coding&quot;;               } &quot;set-med-code&quot;;             } &quot;extract-atc&quot;;              prescribedGroup -&gt; medication.id as medId, medEntry.fullUrl = append('urn:uuid:', medId) &quot;set-fullUrl&quot;;              // Link MedicationRequest to Medication             prescribedGroup -&gt; medication.id as medId, medReq.medication = create('Reference') as ref, ref.reference = append('Medication/', medId) &quot;set-medication-reference&quot;;            } &quot;create-medication&quot;;         } &quot;medication-entry&quot;;</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.answer<b> as </b><span style="color: maroon">prescribedMedication</span><b> then</b><span style="color: navy"> {
    </span>            prescribedMedication.item<b> as </b><span style="color: maroon">routeItem</span><b> where </b>(linkId = '387026794874')<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> 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<b> as </b><span style="color: maroon">routeCoding</span><span style="color: navy">, </span> routeCoding.code = <span style="color: navy">(</span>%ans.valueString<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;navRouteItem&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;navPrescribedMedication&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">// </span><span style="color: green">Timing</span>
              medExpoGroup.item<b> as </b><span style="color: maroon">posoGroup</span><b> where </b>(linkId = '6348237104421')<span style="color: navy"><b> -&gt; </b></span> dosage.timing<b> as </b><span style="color: maroon">timing</span><span style="color: navy">, </span> timing.repeat<b> as </b><span style="color: maroon">timingRepeat</span><span style="color: navy">, </span> timingRepeat.boundsPeriod<b> as </b><span style="color: maroon">timingPeriod</span><b> then</b><span style="color: navy"> {
    </span>            posoGroup.item<b> as </b><span style="color: maroon">DateDebItem</span><b> where </b>(linkId = '316347573327')<b> then</b><span style="color: navy"> {
    </span>              DateDebItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>timingPeriod.start = <span style="color: navy">(</span>%ans.valueDate<span style="color: navy">)</span> <i>&quot;setDateDeb&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;navDateDeb&quot;</i><span style="color: navy">;</span>
                posoGroup.item<b> as </b><span style="color: maroon">DateFinItem</span><b> where </b>(linkId = '429570775935')<b> then</b><span style="color: navy"> {
    </span>              DateFinItem.answer<b> as </b><span style="color: maroon">ans</span><span style="color: navy"><b> -&gt; </b></span>timingPeriod.end = <span style="color: navy">(</span>%ans.valueDate<span style="color: navy">)</span> <i>&quot;setDateFin&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;navDateFin&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;navPoso&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>
            <span style="color: navy">// </span><span style="color: green">fullurl</span>
            src<span style="color: navy"><b> -&gt; </b></span> medAdmin.id<b> as </b><span style="color: maroon">medAdminId</span><span style="color: navy">, </span> medAdminEntry.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">medAdminId</span><span style="color: navy">)</span> <i>&quot;setfullUrl&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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-medication-administration'</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">MedicationCodeableConcept</span>
            adminGroup.answer<b> as </b><span style="color: maroon">administeredMedication</span><b> then</b><span style="color: navy"> {
    </span>          administeredMedication.item<b> as </b><span style="color: maroon">atcItem</span><b> where </b>(linkId = '631972144976')<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> medAdmin.medication = <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">medAdminCC</span><span style="color: navy">, </span> medAdminCC.coding<b> as </b><span style="color: maroon">medAdminC</span><span style="color: navy">, </span> medAdminC.code = <span style="color: navy">(</span>%ans.valueString<span style="color: navy">)</span><span style="color: navy">, </span> medAdminC.display = <span style="color: navy">(</span>%administeredMedication.valueString<span style="color: navy">)</span> <i>&quot;setAtcCoding&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;navAtcItem&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;navadministeredMedication&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">// </span><span style="color: green">Create Medication resource and reference</span>
            <span style="color: navy">// </span><span style="color: green">adminGroup -&gt; bundle.entry as medEntry then {           adminGroup -&gt; medEntry.resource = create('Medication') as medication then {             adminGroup -&gt; medication.id = uuid() &quot;med-id&quot;;              // ATC code from nested items             adminGroup.item as atcItem where (linkId.contains('ATC')) then {               atcItem.answer as ans -&gt; medication.code = create('CodeableConcept') as code then {                 ans -&gt; code.coding = (%ans.valueCoding) &quot;set-atc-coding&quot;;               } &quot;set-med-code&quot;;             } &quot;extract-atc&quot;;              adminGroup -&gt; medication.id as medId, medEntry.fullUrl = append('Medication/', medId) &quot;set-fullUrl&quot;;              // Link MedicationAdministration to Medication             adminGroup -&gt; medication.id as medId, medAdmin.medication = create('Reference') as ref, ref.reference = append('urn:uuid:', medId) &quot;set-medication-reference&quot;;            } &quot;create-medication&quot;;         } &quot;medication-entry&quot;;</span>
            <span style="color: navy">// </span><span style="color: green">Dosage (FHIR)</span>
            adminGroup<span style="color: navy"><b> -&gt; </b></span>medAdmin.dosage<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.answer<b> as </b><span style="color: maroon">administeredMedication</span><b> then</b><span style="color: navy"> {
    </span>            administeredMedication.item<b> as </b><span style="color: maroon">routeItem</span><b> where </b>(linkId = '811931484859')<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<b> as </b><span style="color: maroon">routeCoding</span><span style="color: navy">, </span> routeCoding.code = <span style="color: navy">(</span>%ans.valueString<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;navRoute&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;navadministeredMedication&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">// </span><span style="color: green">Dosage (QR)</span>
              medExpoGroup.item<b> as </b><span style="color: maroon">doseGroup</span><b> where </b>(linkId = '5720103839343')<b> then</b><span style="color: navy"> {
    </span>            <span style="color: navy">// </span><span style="color: green">Dose</span>
                doseGroup.item<b> as </b><span style="color: maroon">quantityItem</span><b> where </b>(linkId = '4765772671997')<b> then</b><span style="color: navy"> {
    </span>              quantityItem.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;navquantity&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">// </span><span style="color: green">Effective period</span>
                doseGroup.item<b> as </b><span style="color: maroon">startItem</span><b> where </b>(linkId = '1443558617577')<b> then</b><span style="color: navy"> {
    </span>              startItem.answer<b> as </b><span style="color: maroon">startAns</span><b> then</b><span style="color: navy"> {
    </span>                doseGroup.item<b> as </b><span style="color: maroon">endItem</span><b> where </b>(linkId = '780829110731')<b> then</b><span style="color: navy"> {
    </span>                  endItem.answer<b> as </b><span style="color: maroon">endAns</span><span style="color: navy"><b> -&gt; </b></span> medAdmin.effectivePeriod<b> as </b><span style="color: maroon">adminPeriod</span><span style="color: navy">, </span> adminPeriod.start = <span style="color: navy">(</span>%startAns.value<span style="color: navy">)</span><span style="color: navy">, </span> adminPeriod.end = <span style="color: navy">(</span>%endAns.value<span style="color: navy">)</span> <i>&quot;setAdminPeriod&quot;</i><span style="color: navy">;</span>
                    <span style="color: navy">}</span> <i>&quot;navEnd&quot;</i><span style="color: navy">;</span>
                  <span style="color: navy">}</span> <i>&quot;navStartAns&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;navStart&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;navDosage&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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-observation-body-height'</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><b> as </b><span style="color: maroon">tgtObsVal</span><span style="color: navy">, </span> tgtObsVal.code = <span style="color: navy">(</span>%ans.valueQuantity.unit<span style="color: navy">)</span><span style="color: navy">, </span> tgtObsVal.system = <span style="color: blue">'http://unitsofmeasure.org'</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>
                ans.item<b> as </b><span style="color: maroon">dateItem</span><b> where </b>(linkId = '941821315470')<b> then</b><span style="color: navy"> {
    </span>              dateItem.answer<b> as </b><span style="color: maroon">dateAns</span><b> then</b><span style="color: navy"> {
    </span>                dateAns.value<b> as </b><span style="color: maroon">val</span><span style="color: navy"><b> -&gt; </b></span>obs.effective = <b>cast</b><span style="color: navy">(</span><span style="color: maroon">val</span><span style="color: navy">, </span><span style="color: blue">'dateTime'</span><span style="color: navy">)</span> <i>&quot;seteffective&quot;</i><span style="color: navy">;</span>
                  <span style="color: navy">}</span> <i>&quot;navDateAns&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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-observation-body-weight'</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><b> as </b><span style="color: maroon">tgtObsVal</span><span style="color: navy">, </span> tgtObsVal.code = <span style="color: navy">(</span>%ans.valueQuantity.unit<span style="color: navy">)</span><span style="color: navy">, </span> tgtObsVal.system = <span style="color: blue">'http://unitsofmeasure.org'</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>
                ans.item<b> as </b><span style="color: maroon">dateItem</span><b> where </b>(linkId = '151269044052')<b> then</b><span style="color: navy"> {
    </span>              dateItem.answer<b> as </b><span style="color: maroon">dateAns</span><b> then</b><span style="color: navy"> {
    </span>                dateAns.value<b> as </b><span style="color: maroon">val</span><span style="color: navy"><b> -&gt; </b></span>obs.effective = <b>cast</b><span style="color: navy">(</span><span style="color: maroon">val</span><span style="color: navy">, </span><span style="color: blue">'dateTime'</span><span style="color: navy">)</span> <i>&quot;seteffective&quot;</i><span style="color: navy">;</span>
                  <span style="color: navy">}</span> <i>&quot;navDateAns&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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-observation-blood-pressure'</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> 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><b> as </b><span style="color: maroon">sysVal</span><span style="color: navy">, </span> sysVal.code = <span style="color: navy">(</span>%sysAns.valueQuantity.unit<span style="color: navy">)</span><span style="color: navy">, </span> sysVal.system = <span style="color: blue">'http://unitsofmeasure.org'</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> 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><b> as </b><span style="color: maroon">diaVal</span><span style="color: navy">, </span> diaVal.code = <span style="color: navy">(</span>%diaAns.valueQuantity.unit<span style="color: navy">)</span><span style="color: navy">, </span> diaVal.system = <span style="color: blue">'http://unitsofmeasure.org'</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>
                    sysAns.item<b> as </b><span style="color: maroon">sysDateItem</span><b> where </b>(linkId = '987654638442')<b> then</b><span style="color: navy"> {
    </span>                  sysDateItem.answer<b> as </b><span style="color: maroon">dateAns</span><b> then</b><span style="color: navy"> {
    </span>                    dateAns.value<b> as </b><span style="color: maroon">val</span><span style="color: navy"><b> -&gt; </b></span>obs.effective = <b>cast</b><span style="color: navy">(</span><span style="color: maroon">val</span><span style="color: navy">, </span><span style="color: blue">'dateTime'</span><span style="color: navy">)</span> <i>&quot;seteffective&quot;</i><span style="color: navy">;</span>
                      <span style="color: navy">}</span> <i>&quot;navDateAns&quot;</i><span style="color: navy">;</span>
                    <span style="color: navy">}</span> <i>&quot;navDate&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 813863316705)</span>
          hemoGroup.item<b> as </b><span style="color: maroon">hematItem</span><b> where </b>(linkId = '813863316705')<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 459731866614)</span>
          hemoGroup.item<b> as </b><span style="color: maroon">eryItem</span><b> where </b>(linkId = '459731866614')<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 163624088831)</span>
          hemoGroup.item<b> as </b><span style="color: maroon">vgmItem</span><b> where </b>(linkId = '163624088831')<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 794156787471)</span>
          hemoGroup.item<b> as </b><span style="color: maroon">platItem</span><b> where </b>(linkId = '794156787471')<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 961905168477)</span>
          hemoGroup.item<b> as </b><span style="color: maroon">neutItem</span><b> where </b>(linkId = '961905168477')<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 695150914696)</span>
          hemoGroup.item<b> as </b><span style="color: maroon">lymphItem</span><b> where </b>(linkId = '695150914696')<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 700490326748)</span>
          hemoGroup.item<b> as </b><span style="color: maroon">eosiItem</span><b> where </b>(linkId = '700490326748')<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 168661900522)</span>
          hemoGroup.item<b> as </b><span style="color: maroon">monoItem</span><b> where </b>(linkId = '168661900522')<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 658898841893)</span>
          hemoGroup.item<b> as </b><span style="color: maroon">tpItem</span><b> where </b>(linkId = '658898841893')<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 795145096241)</span>
          hemoGroup.item<b> as </b><span style="color: maroon">tcaItem</span><b> where </b>(linkId = '795145096241')<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 796308115381)</span>
        bioGroup.item<b> as </b><span style="color: maroon">liverGroup</span><b> where </b>(linkId = '796308115381')<b> then</b><span style="color: navy"> {
    </span>      <span style="color: navy">// </span><span style="color: green">ASAT (linkId 715226319725)</span>
          liverGroup.item<b> as </b><span style="color: maroon">asatItem</span><b> where </b>(linkId = '715226319725')<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 876439410327)</span>
          liverGroup.item<b> as </b><span style="color: maroon">alatItem</span><b> where </b>(linkId = '876439410327')<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 287545455976)</span>
          liverGroup.item<b> as </b><span style="color: maroon">ggtItem</span><b> where </b>(linkId = '287545455976')<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 508269571594)</span>
          liverGroup.item<b> as </b><span style="color: maroon">palItem</span><b> where </b>(linkId = '508269571594')<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 927344090061)</span>
          liverGroup.item<b> as </b><span style="color: maroon">bilTotItem</span><b> where </b>(linkId = '927344090061')<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 208196328453)</span>
          liverGroup.item<b> as </b><span style="color: maroon">bilConjItem</span><b> where </b>(linkId = '208196328453')<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 334039497382)</span>
        bioGroup.item<b> as </b><span style="color: maroon">glucoseGroup</span><b> where </b>(linkId = '334039497382')<b> then</b><span style="color: navy"> {
    </span>      <span style="color: navy">// </span><span style="color: green">Glycémie à jeun (linkId 273778921448)</span>
          glucoseGroup.item<b> as </b><span style="color: maroon">glycItem</span><b> where </b>(linkId = '273778921448')<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 632894677152)</span>
          glucoseGroup.item<b> as </b><span style="color: maroon">hba1cItem</span><b> where </b>(linkId = '632894677152')<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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/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><b> as </b><span style="color: maroon">tgtObsVal</span><span style="color: navy">, </span> tgtObsVal.code = <span style="color: navy">(</span>%ans.valueQuantity.unit<span style="color: navy">)</span><span style="color: navy">, </span> tgtObsVal.system = <span style="color: blue">'http://unitsofmeasure.org'</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>
          <span style="color: navy">// </span><span style="color: green">LOINC code</span>
          ans.item<b> as </b><span style="color: maroon">loincItem</span><b> where </b>(text.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> as </b><span style="color: maroon">code</span><span style="color: navy">, </span> code.coding<b> as </b><span style="color: maroon">coding</span><span style="color: navy">, </span> coding.code = <span style="color: navy">(</span>%loincAns.valueString<span style="color: navy">)</span> <i>&quot;setloinccoding&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractloinc&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">// </span><span style="color: green">effectiveDateTime</span>
          ans.item<b> as </b><span style="color: maroon">dateItem</span><b> where </b>(text.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: #b36b00" title="Cet élément n'était pas défini avant R5">// parentItem.item as statusItem where (linkId.contains('Statut de validation')) then {         statusItem.answer as statusAns -&gt; obs.extension = create('Extension') as ext then {           statusAns -&gt; ext.url = 'http://hl7.org/fhir/StructureDefinition/observation-status' &quot;status-url&quot;;           statusAns -&gt; ext.value = (%statusAns.valueString) &quot;status-value&quot;;         } &quot;set-status-ext&quot;;       } &quot;extract-validation-status&quot;;</span>
          <span style="color: navy">// </span><span style="color: green">Reference ranges (low and high)</span>
          ans<span style="color: navy"><b> -&gt; </b></span>obs.referenceRange<b> as </b><span style="color: maroon">refRange</span><b> then</b><span style="color: navy"> {
    </span>        ans.item<b> as </b><span style="color: maroon">lowItem</span><b> where </b>(text.contains('Borne inférieure'))<b> then</b><span style="color: navy"> {
    </span>          lowItem.answer<b> as </b><span style="color: maroon">lowAns</span><span style="color: navy"><b> -&gt; </b></span> refRange.low = <span style="color: navy">(</span>%lowAns.valueQuantity<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtLow</span><span style="color: navy">, </span> tgtLow.code = <span style="color: navy">(</span>%ans.valueQuantity.unit<span style="color: navy">)</span><span style="color: navy">, </span> tgtLow.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setlow&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;extractlow&quot;</i><span style="color: navy">;</span>
            ans.item<b> as </b><span style="color: maroon">highItem</span><b> where </b>(text.contains('Borne supérieure'))<b> then</b><span style="color: navy"> {
    </span>          highItem.answer<b> as </b><span style="color: maroon">highAns</span><span style="color: navy"><b> -&gt; </b></span> refRange.high = <span style="color: navy">(</span>%highAns.valueQuantity<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtHigh</span><span style="color: navy">, </span> tgtHigh.code = <span style="color: navy">(</span>%ans.valueQuantity.unit<span style="color: navy">)</span><span style="color: navy">, </span> tgtHigh.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;sethigh&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;extracthigh&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;setrefrange&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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/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-05-28T20:54:01+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="FRA"/>
        </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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-patient"/>
              </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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-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="setmultiplebirth"/>
                <source>
                  <context value="multipleItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <target>
                  <context value="patient"/>
                  <contextType value="variable"/>
                  <element value="multipleBirth"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%ans.valueInteger"/>
                  </parameter>
                </target>
              </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="setGenderF"/>
                  <source>
                    <context value="ans"/>
                    <element value="valueString"/>
                    <variable value="female"/>
                    <condition value="($this = 'f')"/>
                  </source>
                  <target>
                    <context value="patient"/>
                    <contextType value="variable"/>
                    <element value="gender"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="female"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="setGenderM"/>
                  <source>
                    <context value="ans"/>
                    <element value="valueString"/>
                    <variable value="female"/>
                    <condition value="($this = 'm')"/>
                  </source>
                  <target>
                    <context value="patient"/>
                    <contextType value="variable"/>
                    <element value="gender"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="male"/>
                    </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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-pmsi-code-geo"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="codegeovalue"/>
                    <source>
                      <context value="ans"/>
                      <element value="value"/>
                      <variable value="val"/>
                    </source>
                    <target>
                      <context value="ext"/>
                      <contextType value="variable"/>
                      <element value="value"/>
                      <transform value="cast"/>
                      <parameter>
                        <valueId value="val"/>
                      </parameter>
                      <parameter>
                        <valueString value="code"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
                <rule>
                  <name value="navEnv"/>
                  <source>
                    <context value="socioDemo"/>
                    <element value="item"/>
                    <variable value="environnementItem"/>
                    <condition value="(linkId = '5491974639955')"/>
                  </source>
                  <rule>
                    <name value="createGeolocExt"/>
                    <source>
                      <context value="environnementItem"/>
                      <element value="item"/>
                      <variable value="geocodageItem"/>
                      <condition value="(linkId = '3816475533472')"/>
                    </source>
                    <target>
                      <context value="addr"/>
                      <contextType value="variable"/>
                      <element value="extension"/>
                      <variable value="geolocationExt"/>
                      <transform value="create"/>
                      <parameter>
                        <valueString value="Extension"/>
                      </parameter>
                    </target>
                    <rule>
                      <name value="createLatExt"/>
                      <source>
                        <context value="geocodageItem"/>
                        <element value="item"/>
                        <variable value="latItem"/>
                        <condition value="(linkId = '3709843054556')"/>
                      </source>
                      <target>
                        <context value="geolocationExt"/>
                        <contextType value="variable"/>
                        <element value="url"/>
                        <transform value="copy"/>
                        <parameter>
                          <valueString
                                       value="http://hl7.org/fhir/StructureDefinition/geolocation"/>
                        </parameter>
                      </target>
                      <target>
                        <context value="geolocationExt"/>
                        <contextType value="variable"/>
                        <element value="extension"/>
                        <variable value="latExt"/>
                        <transform value="create"/>
                        <parameter>
                          <valueString value="Extension"/>
                        </parameter>
                      </target>
                      <rule>
                        <name value="setLat"/>
                        <source>
                          <context value="latItem"/>
                          <element value="answer"/>
                          <variable value="lat"/>
                        </source>
                        <target>
                          <context value="latExt"/>
                          <contextType value="variable"/>
                          <element value="url"/>
                          <transform value="copy"/>
                          <parameter>
                            <valueString value="latitude"/>
                          </parameter>
                        </target>
                        <target>
                          <context value="latExt"/>
                          <contextType value="variable"/>
                          <element value="value"/>
                          <transform value="evaluate"/>
                          <parameter>
                            <valueString value="%lat.valueDecimal"/>
                          </parameter>
                        </target>
                        <rule>
                          <name value="createLongExt"/>
                          <source>
                            <context value="geocodageItem"/>
                            <element value="item"/>
                            <variable value="longItem"/>
                            <condition value="(linkId = '7651448032665')"/>
                          </source>
                          <target>
                            <context value="geolocationExt"/>
                            <contextType value="variable"/>
                            <element value="extension"/>
                            <variable value="longExt"/>
                            <transform value="create"/>
                            <parameter>
                              <valueString value="Extension"/>
                            </parameter>
                          </target>
                          <rule>
                            <name value="setLong"/>
                            <source>
                              <context value="longItem"/>
                              <element value="answer"/>
                              <variable value="long"/>
                            </source>
                            <target>
                              <context value="longExt"/>
                              <contextType value="variable"/>
                              <element value="url"/>
                              <transform value="copy"/>
                              <parameter>
                                <valueString value="longitude"/>
                              </parameter>
                            </target>
                            <target>
                              <context value="longExt"/>
                              <contextType value="variable"/>
                              <element value="value"/>
                              <transform value="evaluate"/>
                              <parameter>
                                <valueString value="%long.valueDecimal"/>
                              </parameter>
                            </target>
                          </rule>
                        </rule>
                      </rule>
                    </rule>
                  </rule>
                  <rule>
                    <name value="navIrisItem"/>
                    <source>
                      <context value="environnementItem"/>
                      <element value="item"/>
                      <variable value="irisItem"/>
                      <condition value="(linkId = '7621032273792')"/>
                    </source>
                    <target>
                      <context value="addr"/>
                      <contextType value="variable"/>
                      <element value="line"/>
                      <variable value="addrLine"/>
                    </target>
                    <target>
                      <context value="addrLine"/>
                      <contextType value="variable"/>
                      <element value="extension"/>
                      <variable value="irisExt"/>
                      <transform value="create"/>
                      <parameter>
                        <valueString value="Extension"/>
                      </parameter>
                    </target>
                    <rule>
                      <name value="setIrisExt"/>
                      <source>
                        <context value="irisItem"/>
                        <element value="answer"/>
                        <variable value="ans"/>
                      </source>
                      <target>
                        <context value="irisExt"/>
                        <contextType value="variable"/>
                        <element value="url"/>
                        <transform value="copy"/>
                        <parameter>
                          <valueString
                                       value="http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-censusTract"/>
                        </parameter>
                      </target>
                      <target>
                        <context value="irisExt"/>
                        <contextType value="variable"/>
                        <element value="valueString"/>
                        <transform value="evaluate"/>
                        <parameter>
                          <valueString value="%ans.valueString"/>
                        </parameter>
                      </target>
                    </rule>
                  </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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-location"/>
                      </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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-location"/>
                        </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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-encounter"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="setStatus"/>
              <source>
                <context value="src"/>
              </source>
              <target>
                <context value="encounter"/>
                <contextType value="variable"/>
                <element value="status"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="finished"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="setClass"/>
              <source>
                <context value="src"/>
              </source>
              <target>
                <context value="encounter"/>
                <contextType value="variable"/>
                <element value="class"/>
                <transform value="c"/>
                <parameter>
                  <valueString
                               value="http://terminology.hl7.org/CodeSystem/v3-ActCode"/>
                </parameter>
                <parameter>
                  <valueString value="IMP"/>
                </parameter>
              </target>
            </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>
                <name value="navValue"/>
                <source>
                  <context value="modeInItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <rule>
                  <name value="setadmitsource"/>
                  <source>
                    <context value="ans"/>
                    <element value="valueString"/>
                    <variable value="valueString"/>
                  </source>
                  <target>
                    <context value="encounter"/>
                    <contextType value="variable"/>
                    <element value="hospitalization"/>
                    <variable value="hosp"/>
                  </target>
                  <target>
                    <context value="hosp"/>
                    <contextType value="variable"/>
                    <element value="admitSource"/>
                    <variable value="admitSource"/>
                  </target>
                  <target>
                    <context value="admitSource"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <variable value="admitSourceCoding"/>
                  </target>
                  <target>
                    <context value="admitSourceCoding"/>
                    <contextType value="variable"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueId value="valueString"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="extractmodeout"/>
              <source>
                <context value="pmsiItem"/>
                <element value="item"/>
                <variable value="modeOutItem"/>
                <condition value="(linkId = '3354867075704')"/>
              </source>
              <rule>
                <name value="navValue"/>
                <source>
                  <context value="modeOutItem"/>
                  <element value="answer"/>
                  <variable value="ans"/>
                </source>
                <rule>
                  <name value="setdischargedisposition"/>
                  <source>
                    <context value="ans"/>
                    <element value="valueString"/>
                    <variable value="valueString"/>
                  </source>
                  <target>
                    <context value="encounter"/>
                    <contextType value="variable"/>
                    <element value="hospitalization"/>
                    <variable value="hosp"/>
                  </target>
                  <target>
                    <context value="hosp"/>
                    <contextType value="variable"/>
                    <element value="dischargeDisposition"/>
                    <variable value="dischargeDisposition"/>
                  </target>
                  <target>
                    <context value="dischargeDisposition"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <variable value="dischargeDispositionCoding"/>
                  </target>
                  <target>
                    <context value="dischargeDispositionCoding"/>
                    <contextType value="variable"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueId value="valueString"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-condition"/>
                  </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"/>
                    <variable value="coding"/>
                  </target>
                  <target>
                    <context value="coding"/>
                    <contextType value="variable"/>
                    <element value="code"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="%ans.valueString"/>
                    </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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/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.valueString"/>
                      </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>
              <name value="setfullUrl"/>
              <source>
                <context value="pmsiItem"/>
              </source>
              <target>
                <context value="condition"/>
                <contextType value="variable"/>
                <element value="id"/>
                <variable value="condId"/>
              </target>
              <target>
                <context value="conditionEntry"/>
                <contextType value="variable"/>
                <element value="fullUrl"/>
                <transform value="append"/>
                <parameter>
                  <valueString value="urn:uuid:"/>
                </parameter>
                <parameter>
                  <valueId value="condId"/>
                </parameter>
              </target>
            </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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-procedure"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="setStatus"/>
              <source>
                <context value="acteGroup"/>
              </source>
              <target>
                <context value="procedure"/>
                <contextType value="variable"/>
                <element value="status"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="completed"/>
                </parameter>
              </target>
            </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"/>
                    <variable value="coding"/>
                  </target>
                  <target>
                    <context value="coding"/>
                    <contextType value="variable"/>
                    <element value="code"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="%ans.valueString"/>
                    </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>
              <name value="setfullUrl"/>
              <source>
                <context value="pmsiItem"/>
              </source>
              <target>
                <context value="procedure"/>
                <contextType value="variable"/>
                <element value="id"/>
                <variable value="procId"/>
              </target>
              <target>
                <context value="procedureEntry"/>
                <contextType value="variable"/>
                <element value="fullUrl"/>
                <transform value="append"/>
                <parameter>
                  <valueString value="urn:uuid:"/>
                </parameter>
                <parameter>
                  <valueId value="procId"/>
                </parameter>
              </target>
            </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="setfullUrl"/>
                <source>
                  <context value="src"/>
                </source>
                <target>
                  <context value="medReq"/>
                  <contextType value="variable"/>
                  <element value="id"/>
                  <variable value="medReqId"/>
                </target>
                <target>
                  <context value="medReqEntry"/>
                  <contextType value="variable"/>
                  <element value="fullUrl"/>
                  <transform value="append"/>
                  <parameter>
                    <valueString value="urn:uuid:"/>
                  </parameter>
                  <parameter>
                    <valueId value="medReqId"/>
                  </parameter>
                </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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-medication-request"/>
                    </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="navPrescribedMedication"/>
                <source>
                  <context value="prescribedGroup"/>
                  <element value="answer"/>
                  <variable value="prescribedMedication"/>
                </source>
                <rule>
                  <name value="navAtcItem"/>
                  <source>
                    <context value="prescribedMedication"/>
                    <element value="item"/>
                    <variable value="atcItem"/>
                    <condition value="(linkId = '1923143398283')"/>
                  </source>
                  <rule>
                    <name value="setAtcCoding"/>
                    <source>
                      <context value="atcItem"/>
                      <element value="answer"/>
                      <variable value="ans"/>
                    </source>
                    <target>
                      <context value="medReq"/>
                      <contextType value="variable"/>
                      <element value="medication"/>
                      <variable value="medReqCC"/>
                      <transform value="create"/>
                      <parameter>
                        <valueString value="CodeableConcept"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="medReqCC"/>
                      <contextType value="variable"/>
                      <element value="coding"/>
                      <variable value="medReqC"/>
                    </target>
                    <target>
                      <context value="medReqC"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="evaluate"/>
                      <parameter>
                        <valueString value="%ans.valueString"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="medReqC"/>
                      <contextType value="variable"/>
                      <element value="display"/>
                      <transform value="evaluate"/>
                      <parameter>
                        <valueString value="%prescribedMedication.valueString"/>
                      </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="navPrescribedMedication"/>
                  <source>
                    <context value="prescribedGroup"/>
                    <element value="answer"/>
                    <variable value="prescribedMedication"/>
                  </source>
                  <rule>
                    <name value="navRouteItem"/>
                    <source>
                      <context value="prescribedMedication"/>
                      <element value="item"/>
                      <variable value="routeItem"/>
                      <condition value="(linkId = '387026794874')"/>
                    </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"/>
                      </target>
                      <rule>
                        <name value="setroutecoding"/>
                        <source>
                          <context value="ans"/>
                        </source>
                        <target>
                          <context value="route"/>
                          <contextType value="variable"/>
                          <element value="coding"/>
                          <variable value="routeCoding"/>
                        </target>
                        <target>
                          <context value="routeCoding"/>
                          <contextType value="variable"/>
                          <element value="code"/>
                          <transform value="evaluate"/>
                          <parameter>
                            <valueString value="%ans.valueString"/>
                          </parameter>
                        </target>
                      </rule>
                    </rule>
                  </rule>
                </rule>
                <rule>
                  <name value="navPoso"/>
                  <source>
                    <context value="medExpoGroup"/>
                    <element value="item"/>
                    <variable value="posoGroup"/>
                    <condition value="(linkId = '6348237104421')"/>
                  </source>
                  <target>
                    <context value="dosage"/>
                    <contextType value="variable"/>
                    <element value="timing"/>
                    <variable value="timing"/>
                  </target>
                  <target>
                    <context value="timing"/>
                    <contextType value="variable"/>
                    <element value="repeat"/>
                    <variable value="timingRepeat"/>
                  </target>
                  <target>
                    <context value="timingRepeat"/>
                    <contextType value="variable"/>
                    <element value="boundsPeriod"/>
                    <variable value="timingPeriod"/>
                  </target>
                  <rule>
                    <name value="navDateDeb"/>
                    <source>
                      <context value="posoGroup"/>
                      <element value="item"/>
                      <variable value="DateDebItem"/>
                      <condition value="(linkId = '316347573327')"/>
                    </source>
                    <rule>
                      <name value="setDateDeb"/>
                      <source>
                        <context value="DateDebItem"/>
                        <element value="answer"/>
                        <variable value="ans"/>
                      </source>
                      <target>
                        <context value="timingPeriod"/>
                        <contextType value="variable"/>
                        <element value="start"/>
                        <transform value="evaluate"/>
                        <parameter>
                          <valueString value="%ans.valueDate"/>
                        </parameter>
                      </target>
                    </rule>
                  </rule>
                  <rule>
                    <name value="navDateFin"/>
                    <source>
                      <context value="posoGroup"/>
                      <element value="item"/>
                      <variable value="DateFinItem"/>
                      <condition value="(linkId = '429570775935')"/>
                    </source>
                    <rule>
                      <name value="setDateFin"/>
                      <source>
                        <context value="DateFinItem"/>
                        <element value="answer"/>
                        <variable value="ans"/>
                      </source>
                      <target>
                        <context value="timingPeriod"/>
                        <contextType value="variable"/>
                        <element value="end"/>
                        <transform value="evaluate"/>
                        <parameter>
                          <valueString value="%ans.valueDate"/>
                        </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="setfullUrl"/>
                <source>
                  <context value="src"/>
                </source>
                <target>
                  <context value="medAdmin"/>
                  <contextType value="variable"/>
                  <element value="id"/>
                  <variable value="medAdminId"/>
                </target>
                <target>
                  <context value="medAdminEntry"/>
                  <contextType value="variable"/>
                  <element value="fullUrl"/>
                  <transform value="append"/>
                  <parameter>
                    <valueString value="urn:uuid:"/>
                  </parameter>
                  <parameter>
                    <valueId value="medAdminId"/>
                  </parameter>
                </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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-medication-administration"/>
                    </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="navadministeredMedication"/>
                <source>
                  <context value="adminGroup"/>
                  <element value="answer"/>
                  <variable value="administeredMedication"/>
                </source>
                <rule>
                  <name value="navAtcItem"/>
                  <source>
                    <context value="administeredMedication"/>
                    <element value="item"/>
                    <variable value="atcItem"/>
                    <condition value="(linkId = '631972144976')"/>
                  </source>
                  <rule>
                    <name value="setAtcCoding"/>
                    <source>
                      <context value="atcItem"/>
                      <element value="answer"/>
                      <variable value="ans"/>
                    </source>
                    <target>
                      <context value="medAdmin"/>
                      <contextType value="variable"/>
                      <element value="medication"/>
                      <variable value="medAdminCC"/>
                      <transform value="create"/>
                      <parameter>
                        <valueString value="CodeableConcept"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="medAdminCC"/>
                      <contextType value="variable"/>
                      <element value="coding"/>
                      <variable value="medAdminC"/>
                    </target>
                    <target>
                      <context value="medAdminC"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="evaluate"/>
                      <parameter>
                        <valueString value="%ans.valueString"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="medAdminC"/>
                      <contextType value="variable"/>
                      <element value="display"/>
                      <transform value="evaluate"/>
                      <parameter>
                        <valueString value="%administeredMedication.valueString"/>
                      </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"/>
                </target>
                <rule>
                  <name value="navadministeredMedication"/>
                  <source>
                    <context value="adminGroup"/>
                    <element value="answer"/>
                    <variable value="administeredMedication"/>
                  </source>
                  <rule>
                    <name value="navRoute"/>
                    <source>
                      <context value="administeredMedication"/>
                      <element value="item"/>
                      <variable value="routeItem"/>
                      <condition value="(linkId = '811931484859')"/>
                    </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"/>
                          <variable value="routeCoding"/>
                        </target>
                        <target>
                          <context value="routeCoding"/>
                          <contextType value="variable"/>
                          <element value="code"/>
                          <transform value="evaluate"/>
                          <parameter>
                            <valueString value="%ans.valueString"/>
                          </parameter>
                        </target>
                      </rule>
                    </rule>
                  </rule>
                </rule>
                <rule>
                  <name value="navDosage"/>
                  <source>
                    <context value="medExpoGroup"/>
                    <element value="item"/>
                    <variable value="doseGroup"/>
                    <condition value="(linkId = '5720103839343')"/>
                  </source>
                  <rule>
                    <name value="navquantity"/>
                    <source>
                      <context value="doseGroup"/>
                      <element value="item"/>
                      <variable value="quantityItem"/>
                      <condition value="(linkId = '4765772671997')"/>
                    </source>
                    <rule>
                      <name value="setDose"/>
                      <source>
                        <context value="quantityItem"/>
                        <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>
                    <name value="navStart"/>
                    <source>
                      <context value="doseGroup"/>
                      <element value="item"/>
                      <variable value="startItem"/>
                      <condition value="(linkId = '1443558617577')"/>
                    </source>
                    <rule>
                      <name value="navStartAns"/>
                      <source>
                        <context value="startItem"/>
                        <element value="answer"/>
                        <variable value="startAns"/>
                      </source>
                      <rule>
                        <name value="navEnd"/>
                        <source>
                          <context value="doseGroup"/>
                          <element value="item"/>
                          <variable value="endItem"/>
                          <condition value="(linkId = '780829110731')"/>
                        </source>
                        <rule>
                          <name value="setAdminPeriod"/>
                          <source>
                            <context value="endItem"/>
                            <element value="answer"/>
                            <variable value="endAns"/>
                          </source>
                          <target>
                            <context value="medAdmin"/>
                            <contextType value="variable"/>
                            <element value="effectivePeriod"/>
                            <variable value="adminPeriod"/>
                          </target>
                          <target>
                            <context value="adminPeriod"/>
                            <contextType value="variable"/>
                            <element value="start"/>
                            <transform value="evaluate"/>
                            <parameter>
                              <valueString value="%startAns.value"/>
                            </parameter>
                          </target>
                          <target>
                            <context value="adminPeriod"/>
                            <contextType value="variable"/>
                            <element value="end"/>
                            <transform value="evaluate"/>
                            <parameter>
                              <valueString value="%endAns.value"/>
                            </parameter>
                          </target>
                        </rule>
                      </rule>
                    </rule>
                  </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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-observation-body-height"/>
                        </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"/>
                      <variable value="tgtObsVal"/>
                      <transform value="evaluate"/>
                      <parameter>
                        <valueString value="%ans.valueQuantity"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtObsVal"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="evaluate"/>
                      <parameter>
                        <valueString value="%ans.valueQuantity.unit"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtObsVal"/>
                      <contextType value="variable"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="http://unitsofmeasure.org"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="extracteffective"/>
                    <source>
                      <context value="ans"/>
                      <element value="item"/>
                      <variable value="dateItem"/>
                      <condition value="(linkId = '941821315470')"/>
                    </source>
                    <rule>
                      <name value="navDateAns"/>
                      <source>
                        <context value="dateItem"/>
                        <element value="answer"/>
                        <variable value="dateAns"/>
                      </source>
                      <rule>
                        <name value="seteffective"/>
                        <source>
                          <context value="dateAns"/>
                          <element value="value"/>
                          <variable value="val"/>
                        </source>
                        <target>
                          <context value="obs"/>
                          <contextType value="variable"/>
                          <element value="effective"/>
                          <transform value="cast"/>
                          <parameter>
                            <valueId value="val"/>
                          </parameter>
                          <parameter>
                            <valueString value="dateTime"/>
                          </parameter>
                        </target>
                      </rule>
                    </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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-observation-body-weight"/>
                        </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"/>
                      <variable value="tgtObsVal"/>
                      <transform value="evaluate"/>
                      <parameter>
                        <valueString value="%ans.valueQuantity"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtObsVal"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="evaluate"/>
                      <parameter>
                        <valueString value="%ans.valueQuantity.unit"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtObsVal"/>
                      <contextType value="variable"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="http://unitsofmeasure.org"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="extracteffective"/>
                    <source>
                      <context value="ans"/>
                      <element value="item"/>
                      <variable value="dateItem"/>
                      <condition value="(linkId = '151269044052')"/>
                    </source>
                    <rule>
                      <name value="navDateAns"/>
                      <source>
                        <context value="dateItem"/>
                        <element value="answer"/>
                        <variable value="dateAns"/>
                      </source>
                      <rule>
                        <name value="seteffective"/>
                        <source>
                          <context value="dateAns"/>
                          <element value="value"/>
                          <variable value="val"/>
                        </source>
                        <target>
                          <context value="obs"/>
                          <contextType value="variable"/>
                          <element value="effective"/>
                          <transform value="cast"/>
                          <parameter>
                            <valueId value="val"/>
                          </parameter>
                          <parameter>
                            <valueString value="dateTime"/>
                          </parameter>
                        </target>
                      </rule>
                    </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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-observation-blood-pressure"/>
                            </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"/>
                        </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"/>
                            <variable value="sysVal"/>
                            <transform value="evaluate"/>
                            <parameter>
                              <valueString value="%sysAns.valueQuantity"/>
                            </parameter>
                          </target>
                          <target>
                            <context value="sysVal"/>
                            <contextType value="variable"/>
                            <element value="code"/>
                            <transform value="evaluate"/>
                            <parameter>
                              <valueString value="%sysAns.valueQuantity.unit"/>
                            </parameter>
                          </target>
                          <target>
                            <context value="sysVal"/>
                            <contextType value="variable"/>
                            <element value="system"/>
                            <transform value="copy"/>
                            <parameter>
                              <valueString value="http://unitsofmeasure.org"/>
                            </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"/>
                        </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"/>
                            <variable value="diaVal"/>
                            <transform value="evaluate"/>
                            <parameter>
                              <valueString value="%diaAns.valueQuantity"/>
                            </parameter>
                          </target>
                          <target>
                            <context value="diaVal"/>
                            <contextType value="variable"/>
                            <element value="code"/>
                            <transform value="evaluate"/>
                            <parameter>
                              <valueString value="%diaAns.valueQuantity.unit"/>
                            </parameter>
                          </target>
                          <target>
                            <context value="diaVal"/>
                            <contextType value="variable"/>
                            <element value="system"/>
                            <transform value="copy"/>
                            <parameter>
                              <valueString value="http://unitsofmeasure.org"/>
                            </parameter>
                          </target>
                        </rule>
                      </rule>
                      <rule>
                        <name value="navDate"/>
                        <source>
                          <context value="sysAns"/>
                          <element value="item"/>
                          <variable value="sysDateItem"/>
                          <condition value="(linkId = '987654638442')"/>
                        </source>
                        <rule>
                          <name value="navDateAns"/>
                          <source>
                            <context value="sysDateItem"/>
                            <element value="answer"/>
                            <variable value="dateAns"/>
                          </source>
                          <rule>
                            <name value="seteffective"/>
                            <source>
                              <context value="dateAns"/>
                              <element value="value"/>
                              <variable value="val"/>
                            </source>
                            <target>
                              <context value="obs"/>
                              <contextType value="variable"/>
                              <element value="effective"/>
                              <transform value="cast"/>
                              <parameter>
                                <valueId value="val"/>
                              </parameter>
                              <parameter>
                                <valueString value="dateTime"/>
                              </parameter>
                            </target>
                          </rule>
                        </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 = '813863316705')"/>
              </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 = '459731866614')"/>
              </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 = '163624088831')"/>
              </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 = '794156787471')"/>
              </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 = '961905168477')"/>
              </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 = '695150914696')"/>
              </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 = '700490326748')"/>
              </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 = '168661900522')"/>
              </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 = '658898841893')"/>
              </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 = '795145096241')"/>
              </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 = '796308115381')"/>
            </source>
            <rule>
              <name value="extractasat"/>
              <source>
                <context value="liverGroup"/>
                <element value="item"/>
                <variable value="asatItem"/>
                <condition value="(linkId = '715226319725')"/>
              </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 = '876439410327')"/>
              </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 = '287545455976')"/>
              </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 = '508269571594')"/>
              </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 = '927344090061')"/>
              </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 = '208196328453')"/>
              </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 = '334039497382')"/>
            </source>
            <rule>
              <name value="extractglyc"/>
              <source>
                <context value="glucoseGroup"/>
                <element value="item"/>
                <variable value="glycItem"/>
                <condition value="(linkId = '273778921448')"/>
              </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 = '632894677152')"/>
              </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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/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"/>
                <variable value="tgtObsVal"/>
                <transform value="evaluate"/>
                <parameter>
                  <valueString value="%ans.valueQuantity"/>
                </parameter>
              </target>
              <target>
                <context value="tgtObsVal"/>
                <contextType value="variable"/>
                <element value="code"/>
                <transform value="evaluate"/>
                <parameter>
                  <valueString value="%ans.valueQuantity.unit"/>
                </parameter>
              </target>
              <target>
                <context value="tgtObsVal"/>
                <contextType value="variable"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="http://unitsofmeasure.org"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="extractloinc"/>
              <source>
                <context value="ans"/>
                <element value="item"/>
                <variable value="loincItem"/>
                <condition value="(text.contains('code loinc'))"/>
              </source>
              <rule>
                <name value="setloinccoding"/>
                <source>
                  <context value="loincItem"/>
                  <element value="answer"/>
                  <variable value="loincAns"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <variable value="code"/>
                </target>
                <target>
                  <context value="code"/>
                  <contextType value="variable"/>
                  <element value="coding"/>
                  <variable value="coding"/>
                </target>
                <target>
                  <context value="coding"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%loincAns.valueString"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="extracteffective"/>
              <source>
                <context value="ans"/>
                <element value="item"/>
                <variable value="dateItem"/>
                <condition
                           value="(text.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>
              <name value="setrefrange"/>
              <source>
                <context value="ans"/>
              </source>
              <target>
                <context value="obs"/>
                <contextType value="variable"/>
                <element value="referenceRange"/>
                <variable value="refRange"/>
              </target>
              <rule>
                <name value="extractlow"/>
                <source>
                  <context value="ans"/>
                  <element value="item"/>
                  <variable value="lowItem"/>
                  <condition value="(text.contains('Borne inférieure'))"/>
                </source>
                <rule>
                  <name value="setlow"/>
                  <source>
                    <context value="lowItem"/>
                    <element value="answer"/>
                    <variable value="lowAns"/>
                  </source>
                  <target>
                    <context value="refRange"/>
                    <contextType value="variable"/>
                    <element value="low"/>
                    <variable value="tgtLow"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="%lowAns.valueQuantity"/>
                    </parameter>
                  </target>
                  <target>
                    <context value="tgtLow"/>
                    <contextType value="variable"/>
                    <element value="code"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="%ans.valueQuantity.unit"/>
                    </parameter>
                  </target>
                  <target>
                    <context value="tgtLow"/>
                    <contextType value="variable"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://unitsofmeasure.org"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="extracthigh"/>
                <source>
                  <context value="ans"/>
                  <element value="item"/>
                  <variable value="highItem"/>
                  <condition value="(text.contains('Borne supérieure'))"/>
                </source>
                <rule>
                  <name value="sethigh"/>
                  <source>
                    <context value="highItem"/>
                    <element value="answer"/>
                    <variable value="highAns"/>
                  </source>
                  <target>
                    <context value="refRange"/>
                    <contextType value="variable"/>
                    <element value="high"/>
                    <variable value="tgtHigh"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="%highAns.valueQuantity"/>
                    </parameter>
                  </target>
                  <target>
                    <context value="tgtHigh"/>
                    <contextType value="variable"/>
                    <element value="code"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="%ans.valueQuantity.unit"/>
                    </parameter>
                  </target>
                  <target>
                    <context value="tgtHigh"/>
                    <contextType value="variable"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://unitsofmeasure.org"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
          </rule>
        </rule>
      </group>
    </StructureMap>