Données socles des Entrepôts de Données de Santé Hospitalier
0.1.0 - ci-build France (la) flag

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

: Questionnaire to FHIR Semantic Layer - XML Representation

Draft as of 2026-08-27

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.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 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.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><span style="color: navy">(</span>linkId = '4647259356106'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    socioDemo.item<b> as </b><span style="color: maroon">identity</span><b> where </b><span style="color: navy">(</span>linkId = '2958000860428'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      <span style="color: navy">// </span><span style="color: green">Patient id (saisi manuellement dans le champ &quot;Identifiant&quot;, linkId 236790258446)</span>
      identity.item<b> as </b><span style="color: maroon">patIdItem</span><b> where </b><span style="color: navy">(</span>linkId = '236790258446'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>        patIdItem.answer<b> as </b><span style="color: maroon">patIdAns</span><span style="color: navy"><b> -&gt; </b></span>patient.id = <span style="color: navy">(</span>%patIdAns.value.ofType(string)<span style="color: navy">)</span> <i>&quot;setpatientid&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;extractpatientid&quot;</i><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><span style="color: navy">(</span>linkId = '8605698058770'<span style="color: navy">)</span><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.value.ofType(string)<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><span style="color: navy">(</span>linkId = '6214879623503'<span style="color: navy">)</span><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.value.ofType(string)<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><span style="color: navy">(</span>linkId = '5711960356160'<span style="color: navy">)</span><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.value.ofType(string)<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><span style="color: navy">(</span>linkId = '3764723550987'<span style="color: navy">)</span><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.value.ofType(string)<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><span style="color: navy">(</span>linkId = '5036133558154'<span style="color: navy">)</span><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.value.ofType(date)<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><span style="color: navy">(</span>linkId = '5633552097315'<span style="color: navy">)</span><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.value.ofType(date)<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><span style="color: navy">(</span>linkId = '9098810065693'<span style="color: navy">)</span><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.value.ofType(Coding)<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><span style="color: navy">(</span>linkId = '6931296968515'<span style="color: navy">)</span><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.value.ofType(integer)<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><span style="color: navy">(</span>linkId = '2825244231605'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      pmsiGroup.item<b> as </b><span style="color: maroon">sexItem</span><b> where </b><span style="color: navy">(</span>linkId = '3894630481120'<span style="color: navy">)</span><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><span style="color: navy">(</span>$this = 'f'<span style="color: navy">)</span><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><span style="color: navy">(</span>$this = 'm'<span style="color: navy">)</span><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><span style="color: navy">(</span>linkId = '2446369196222'<span style="color: navy">)</span><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><span style="color: navy">(</span>linkId = '5491974639955'<span style="color: navy">)</span><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><span style="color: navy">(</span>linkId = '3816475533472'<span style="color: navy">)</span><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><span style="color: navy">(</span>linkId = '3709843054556'<span style="color: navy">)</span><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.value.ofType(decimal)<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><span style="color: navy">(</span>linkId = '7651448032665'<span style="color: navy">)</span><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.value.ofType(decimal)<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><span style="color: navy">(</span>linkId = '7621032273792'<span style="color: navy">)</span><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.value.ofType(string)<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 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>  src.item<b> as </b><span style="color: maroon">pmsiItem</span><b> where </b><span style="color: navy">(</span>linkId = '2825244231605'<span style="color: navy">)</span><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>      src<span style="color: navy"><b> -&gt; </b></span> patient.id<b> as </b><span style="color: maroon">patIdForEnc</span><span style="color: navy">, </span> encounter.id = <span style="color: navy">(</span>%patIdForEnc.replace('-pat-', '-sej-')<span style="color: navy">)</span> <i>&quot;setencounterid&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>
      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>
      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>
      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>
      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><span style="color: navy">(</span>linkId = '5991443718282'<span style="color: navy">)</span><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.value.ofType(date)<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><span style="color: navy">(</span>linkId = '6114780320846'<span style="color: navy">)</span><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.value.ofType(date)<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>
      pmsiItem.item<b> as </b><span style="color: maroon">modeInItem</span><b> where </b><span style="color: navy">(</span>linkId = '6172398101212'<span style="color: navy">)</span><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>
      pmsiItem.item<b> as </b><span style="color: maroon">modeOutItem</span><b> where </b><span style="color: navy">(</span>linkId = '3354867075704'<span style="color: navy">)</span><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>
      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><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>  pmsiItem.item<b> as </b><span style="color: maroon">diagGroup</span><b> where </b><span style="color: navy">(</span>linkId = '9391816419630'<span style="color: navy">)</span><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.item<b> as </b><span style="color: maroon">condIdItem</span><b> where </b><span style="color: navy">(</span>linkId = '123759733087'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>        condIdItem.answer<b> as </b><span style="color: maroon">condIdAns</span><span style="color: navy"><b> -&gt; </b></span>condition.id = <span style="color: navy">(</span>%condIdAns.value.ofType(string)<span style="color: navy">)</span> <i>&quot;setconditionid&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;extractconditionid&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>
      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>
      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>
      diagGroup.item<b> as </b><span style="color: maroon">diagCodeItem</span><b> where </b><span style="color: navy">(</span>linkId = '5505101189372'<span style="color: navy">)</span><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.value.ofType(string)<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>
      diagGroup.item<b> as </b><span style="color: maroon">diagTypeItem</span><b> where </b><span style="color: navy">(</span>linkId = '6427586743735'<span style="color: navy">)</span><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.value.ofType(string)<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>
      diagGroup.item<b> as </b><span style="color: maroon">dateItem</span><b> where </b><span style="color: navy">(</span>linkId = '7114466839467'<span style="color: navy">)</span><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.value.ofType(date)<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>
      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><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>  pmsiItem.item<b> as </b><span style="color: maroon">acteGroup</span><b> where </b><span style="color: navy">(</span>linkId = '591926901726'<span style="color: navy">)</span><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.item<b> as </b><span style="color: maroon">procIdItem</span><b> where </b><span style="color: navy">(</span>linkId = '151762387793'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>        procIdItem.answer<b> as </b><span style="color: maroon">procIdAns</span><span style="color: navy"><b> -&gt; </b></span>procedure.id = <span style="color: navy">(</span>%procIdAns.value.ofType(string)<span style="color: navy">)</span> <i>&quot;setprocedureid&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;extractprocedureid&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>
      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>
      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>
      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>
      acteGroup.item<b> as </b><span style="color: maroon">acteCodeItem</span><b> where </b><span style="color: navy">(</span>linkId = '7758110033600'<span style="color: navy">)</span><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.value.ofType(string)<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>
      acteGroup.item<b> as </b><span style="color: maroon">dateItem</span><b> where </b><span style="color: navy">(</span>linkId = '5066866286682'<span style="color: navy">)</span><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.value.ofType(dateTime)<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>
      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><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>  src.item<b> as </b><span style="color: maroon">medExpoGroup</span><b> where </b><span style="color: navy">(</span>linkId = '817801935685'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    medExpoGroup.item<b> as </b><span style="color: maroon">prescribedGroup</span><b> where </b><span style="color: navy">(</span>linkId = '156631794800'<span style="color: navy">)</span><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.answer<b> as </b><span style="color: maroon">prescribedMedForId</span><b> then</b><span style="color: navy"> {
</span>          prescribedMedForId.item<b> as </b><span style="color: maroon">medReqIdItem</span><b> where </b><span style="color: navy">(</span>linkId = '145920953908'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>            medReqIdItem.answer<b> as </b><span style="color: maroon">medReqIdAns</span><span style="color: navy"><b> -&gt; </b></span>medReq.id = <span style="color: navy">(</span>%medReqIdAns.value.ofType(string)<span style="color: navy">)</span> <i>&quot;setmedreqid&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractmedreqid&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;navPrescribedMedForId&quot;</i><span style="color: navy">;</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>
        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>
        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>
        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><span style="color: navy">(</span>linkId = '1923143398283'<span style="color: navy">)</span><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.value.ofType(string)<span style="color: navy">)</span><span style="color: navy">, </span> medReqC.display = <span style="color: navy">(</span>%prescribedMedication.value.ofType(string)<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>
        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>          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><span style="color: navy">(</span>linkId = '387026794874'<span style="color: navy">)</span><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.value.ofType(string)<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>
          medExpoGroup.item<b> as </b><span style="color: maroon">posoGroup</span><b> where </b><span style="color: navy">(</span>linkId = '6348237104421'<span style="color: navy">)</span><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.bounds = <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">timingPeriod</span><b> then</b><span style="color: navy"> {
</span>            posoGroup.item<b> as </b><span style="color: maroon">DateDebItem</span><b> where </b><span style="color: navy">(</span>linkId = '316347573327'<span style="color: navy">)</span><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.value.ofType(date)<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><span style="color: navy">(</span>linkId = '429570775935'<span style="color: navy">)</span><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.value.ofType(date)<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><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>  src.item<b> as </b><span style="color: maroon">medExpoGroup</span><b> where </b><span style="color: navy">(</span>linkId = '817801935685'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    medExpoGroup.item<b> as </b><span style="color: maroon">adminGroup</span><b> where </b><span style="color: navy">(</span>linkId = '266852453304'<span style="color: navy">)</span><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.answer<b> as </b><span style="color: maroon">administeredMedForId</span><b> then</b><span style="color: navy"> {
</span>          administeredMedForId.item<b> as </b><span style="color: maroon">medAdminIdItem</span><b> where </b><span style="color: navy">(</span>linkId = '870029232684'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>            medAdminIdItem.answer<b> as </b><span style="color: maroon">medAdminIdAns</span><span style="color: navy"><b> -&gt; </b></span>medAdmin.id = <span style="color: navy">(</span>%medAdminIdAns.value.ofType(string)<span style="color: navy">)</span> <i>&quot;setmedadminid&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;extractmedadminid&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;navAdministeredMedForId&quot;</i><span style="color: navy">;</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>
        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>
        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>
        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><span style="color: navy">(</span>linkId = '631972144976'<span style="color: navy">)</span><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.value.ofType(string)<span style="color: navy">)</span><span style="color: navy">, </span> medAdminC.display = <span style="color: navy">(</span>%administeredMedication.value.ofType(string)<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>
        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>          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><span style="color: navy">(</span>linkId = '811931484859'<span style="color: navy">)</span><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.value.ofType(string)<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>
          medExpoGroup.item<b> as </b><span style="color: maroon">doseGroup</span><b> where </b><span style="color: navy">(</span>linkId = '5720103839343'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>            doseGroup.item<b> as </b><span style="color: maroon">quantityItem</span><b> where </b><span style="color: navy">(</span>linkId = '4765772671997'<span style="color: navy">)</span><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.value.ofType(Quantity)<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>
            doseGroup.item<b> as </b><span style="color: maroon">startItem</span><b> where </b><span style="color: navy">(</span>linkId = '1443558617577'<span style="color: navy">)</span><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><span style="color: navy">(</span>linkId = '780829110731'<span style="color: navy">)</span><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.effective = <b>create</b><span style="color: navy">(</span><span style="color: blue">'Period'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">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><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>  src.item<b> as </b><span style="color: maroon">examGroup</span><b> where </b><span style="color: navy">(</span>linkId = '214880328197'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    examGroup.item<b> as </b><span style="color: maroon">dossierGroup</span><b> where </b><span style="color: navy">(</span>linkId = '305831246173'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      dossierGroup.item<b> as </b><span style="color: maroon">heightItem</span><b> where </b><span style="color: navy">(</span>linkId = '4846902346416'<span style="color: navy">)</span><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.item<b> as </b><span style="color: maroon">heightIdItem</span><b> where </b><span style="color: navy">(</span>linkId = '854021250495'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>              heightIdItem.answer<b> as </b><span style="color: maroon">heightIdAns</span><span style="color: navy"><b> -&gt; </b></span>obs.id = <span style="color: navy">(</span>%heightIdAns.value.ofType(string)<span style="color: navy">)</span> <i>&quot;setobsid&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;extractheightid&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>
            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>
            ans<span style="color: navy"><b> -&gt; </b></span> obs.value = <span style="color: navy">(</span>%ans.value.ofType(Quantity)<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.value.ofType(Quantity).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>
            ans.item<b> as </b><span style="color: maroon">dateItem</span><b> where </b><span style="color: navy">(</span>linkId = '941821315470'<span style="color: navy">)</span><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>
      dossierGroup.item<b> as </b><span style="color: maroon">weightItem</span><b> where </b><span style="color: navy">(</span>linkId = '451513217936'<span style="color: navy">)</span><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.item<b> as </b><span style="color: maroon">weightIdItem</span><b> where </b><span style="color: navy">(</span>linkId = '199208534521'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>              weightIdItem.answer<b> as </b><span style="color: maroon">weightIdAns</span><span style="color: navy"><b> -&gt; </b></span>obs.id = <span style="color: navy">(</span>%weightIdAns.value.ofType(string)<span style="color: navy">)</span> <i>&quot;setobsid&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;extractweightid&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>
            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>
            ans<span style="color: navy"><b> -&gt; </b></span> obs.value = <span style="color: navy">(</span>%ans.value.ofType(Quantity)<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.value.ofType(Quantity).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>
            ans.item<b> as </b><span style="color: maroon">dateItem</span><b> where </b><span style="color: navy">(</span>linkId = '151269044052'<span style="color: navy">)</span><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>
      dossierGroup.item<b> as </b><span style="color: maroon">sysItem</span><b> where </b><span style="color: navy">(</span>linkId = '4160905247955'<span style="color: navy">)</span><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><span style="color: navy">(</span>linkId = '848797127998'<span style="color: navy">)</span><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.item<b> as </b><span style="color: maroon">sysIdItem</span><b> where </b><span style="color: navy">(</span>linkId = '734815456784'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>                  sysIdItem.answer<b> as </b><span style="color: maroon">sysIdAns</span><b> then</b><span style="color: navy"> {
</span>                    diaAns.item<b> as </b><span style="color: maroon">diaIdItem</span><b> where </b><span style="color: navy">(</span>linkId = '926430936118'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>                      diaIdItem.answer<b> as </b><span style="color: maroon">diaIdAns</span><span style="color: navy"><b> -&gt; </b></span>obs.id = <span style="color: navy">(</span>%sysIdAns.value.ofType(string) + '-' + %diaIdAns.value.ofType(string)<span style="color: navy">)</span> <i>&quot;setobsid&quot;</i><span style="color: navy">;</span>
                    <span style="color: navy">}</span> <i>&quot;extractdiaid&quot;</i><span style="color: navy">;</span>
                  <span style="color: navy">}</span> <i>&quot;navSysIdAns&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;extractsysid&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>
                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>
                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.value.ofType(Quantity)<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.value.ofType(Quantity).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>
                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.value.ofType(Quantity)<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.value.ofType(Quantity).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>
                sysAns.item<b> as </b><span style="color: maroon">sysDateItem</span><b> where </b><span style="color: navy">(</span>linkId = '987654638442'<span style="color: navy">)</span><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><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>  src.item<b> as </b><span style="color: maroon">bioGroup</span><b> where </b><span style="color: navy">(</span>linkId = '7702944131447'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    bioGroup.item<b> as </b><span style="color: maroon">renalGroup</span><b> where </b><span style="color: navy">(</span>linkId = '5241323453538'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      renalGroup.item<b> as </b><span style="color: maroon">ureaItem</span><b> where </b><span style="color: navy">(</span>linkId = '7169026818760'<span style="color: navy">)</span><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.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<b> then </b>CreateLabObservationCommon<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">obsEntry</span><span style="color: navy">)</span> <i>&quot;createcommon&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-laboratory-uremie'</span> <i>&quot;setprofile&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setmeta&quot;</i><span style="color: navy">;</span>
            ans<span style="color: navy"><b> -&gt; </b></span>obs.code = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span>              ans<span style="color: navy"><b> -&gt; </b></span>code.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://loinc.org'</span> <i>&quot;setcodesystem&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'22664-7'</span> <i>&quot;setcodevalue&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Urée [Moles/Volume] Sérum/Plasma ; Numérique'</span> <i>&quot;setcodedisplay&quot;</i><span style="color: navy">;</span>
              <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>
            ans<span style="color: navy"><b> -&gt; </b></span> obs.value = <span style="color: navy">(</span>%ans.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">val</span><span style="color: navy">, </span> val.code = <span style="color: blue">'mmol/L'</span><span style="color: navy">, </span> val.unit = <span style="color: blue">'mmol/L'</span><span style="color: navy">, </span> val.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setvalue&quot;</i><span style="color: navy">;</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><span style="color: navy">(</span>text.contains('Borne inférieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtLow</span><span style="color: navy">, </span> tgtLow.code = <span style="color: blue">'mmol/L'</span><span style="color: navy">, </span> tgtLow.unit = <span style="color: blue">'mmol/L'</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><span style="color: navy">(</span>text.contains('Borne supérieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtHigh</span><span style="color: navy">, </span> tgtHigh.code = <span style="color: blue">'mmol/L'</span><span style="color: navy">, </span> tgtHigh.unit = <span style="color: blue">'mmol/L'</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> <i>&quot;extracturea&quot;</i><span style="color: navy">;</span>
      renalGroup.item<b> as </b><span style="color: maroon">creatItem</span><b> where </b><span style="color: navy">(</span>linkId = '500408205043'<span style="color: navy">)</span><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.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<b> then </b>CreateLabObservationCommon<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">obsEntry</span><span style="color: navy">)</span> <i>&quot;createcommon&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-laboratory-creat'</span> <i>&quot;setprofile&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setmeta&quot;</i><span style="color: navy">;</span>
            ans<span style="color: navy"><b> -&gt; </b></span>obs.code = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span>              ans<span style="color: navy"><b> -&gt; </b></span>code.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://loinc.org'</span> <i>&quot;setcodesystem&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'14682-9'</span> <i>&quot;setcodevalue&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Créatinine [Moles/Volume] Sérum/Plasma ; Numérique'</span> <i>&quot;setcodedisplay&quot;</i><span style="color: navy">;</span>
              <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>
            ans<span style="color: navy"><b> -&gt; </b></span> obs.value = <span style="color: navy">(</span>%ans.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">val</span><span style="color: navy">, </span> val.code = <span style="color: blue">'umol/L'</span><span style="color: navy">, </span> val.unit = <span style="color: blue">'umol/L'</span><span style="color: navy">, </span> val.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setvalue&quot;</i><span style="color: navy">;</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><span style="color: navy">(</span>linkId = '488869963230'<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtLow</span><span style="color: navy">, </span> tgtLow.code = <span style="color: blue">'umol/L'</span><span style="color: navy">, </span> tgtLow.unit = <span style="color: blue">'umol/L'</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><span style="color: navy">(</span>linkId = '984480974142'<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtHigh</span><span style="color: navy">, </span> tgtHigh.code = <span style="color: blue">'umol/L'</span><span style="color: navy">, </span> tgtHigh.unit = <span style="color: blue">'umol/L'</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> <i>&quot;extractcreat&quot;</i><span style="color: navy">;</span>
      renalGroup.item<b> as </b><span style="color: maroon">dfgItem</span><b> where </b><span style="color: navy">(</span>linkId = '786621340679'<span style="color: navy">)</span><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.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<b> then </b>CreateLabObservationCommon<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">obsEntry</span><span style="color: navy">)</span> <i>&quot;createcommon&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-laboratory-dfg'</span> <i>&quot;setprofile&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setmeta&quot;</i><span style="color: navy">;</span>
            ans.item<b> as </b><span style="color: maroon">loincItem</span><b> where </b><span style="color: navy">(</span>linkId = '974417569313'<span style="color: navy">)</span><span style="color: navy"><b> -&gt; </b></span>obs.code = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span>              loincItem.answer<b> as </b><span style="color: maroon">loincAns</span><span style="color: navy"><b> -&gt; </b></span>code.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>                loincAns<span style="color: navy"><b> -&gt; </b></span>coding.system = <span style="color: blue">'http://loinc.org'</span> <i>&quot;setcodesystem&quot;</i><span style="color: navy">;</span>
                loincAns.value<b> as </b><span style="color: maroon">loincValue</span><span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: maroon">loincValue</span> <i>&quot;setcodevalue&quot;</i><span style="color: navy">;</span>
              <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>
            ans<span style="color: navy"><b> -&gt; </b></span> obs.value = <span style="color: navy">(</span>%ans.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">val</span><span style="color: navy">, </span> val.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setvalue&quot;</i><span style="color: navy">;</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><span style="color: navy">(</span>linkId = '809916645548'<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtLow</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><span style="color: navy">(</span>linkId = '323493215684'<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtHigh</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> <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>
    bioGroup.item<b> as </b><span style="color: maroon">hemoGroup</span><b> where </b><span style="color: navy">(</span>linkId = '419282985970'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      hemoGroup.item<b> as </b><span style="color: maroon">leukoItem</span><b> where </b><span style="color: navy">(</span>linkId = '210077225604'<span style="color: navy">)</span><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.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<b> then </b>CreateLabObservationCommon<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">obsEntry</span><span style="color: navy">)</span> <i>&quot;createcommon&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-laboratory-leucocytes'</span> <i>&quot;setprofile&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setmeta&quot;</i><span style="color: navy">;</span>
            ans<span style="color: navy"><b> -&gt; </b></span>obs.code = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span>              ans<span style="color: navy"><b> -&gt; </b></span>code.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://loinc.org'</span> <i>&quot;setcodesystem&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'6690-2'</span> <i>&quot;setcodevalue&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Leucocytes [Nombre/Volume] Sang ; Numérique ; Comptage automate'</span> <i>&quot;setcodedisplay&quot;</i><span style="color: navy">;</span>
              <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>
            ans<span style="color: navy"><b> -&gt; </b></span> obs.value = <span style="color: navy">(</span>%ans.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">val</span><span style="color: navy">, </span> val.code = <span style="color: blue">'10*3/uL'</span><span style="color: navy">, </span> val.unit = <span style="color: blue">'10*3/uL'</span><span style="color: navy">, </span> val.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setvalue&quot;</i><span style="color: navy">;</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><span style="color: navy">(</span>text.contains('Borne inférieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtLow</span><span style="color: navy">, </span> tgtLow.code = <span style="color: blue">'10*3/uL'</span><span style="color: navy">, </span> tgtLow.unit = <span style="color: blue">'10*3/uL'</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><span style="color: navy">(</span>text.contains('Borne supérieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtHigh</span><span style="color: navy">, </span> tgtHigh.code = <span style="color: blue">'10*3/uL'</span><span style="color: navy">, </span> tgtHigh.unit = <span style="color: blue">'10*3/uL'</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> <i>&quot;extractleuko&quot;</i><span style="color: navy">;</span>
      hemoGroup.item<b> as </b><span style="color: maroon">hemoItem</span><b> where </b><span style="color: navy">(</span>linkId = '304159088493'<span style="color: navy">)</span><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.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<b> then </b>CreateLabObservationCommon<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">obsEntry</span><span style="color: navy">)</span> <i>&quot;createcommon&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-laboratory-hemoglobine'</span> <i>&quot;setprofile&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setmeta&quot;</i><span style="color: navy">;</span>
            ans<span style="color: navy"><b> -&gt; </b></span>obs.code = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span>              ans<span style="color: navy"><b> -&gt; </b></span>code.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://loinc.org'</span> <i>&quot;setcodesystem&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'718-7'</span> <i>&quot;setcodevalue&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Hémoglobine [Masse/Volume] Sang ; Numérique'</span> <i>&quot;setcodedisplay&quot;</i><span style="color: navy">;</span>
              <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>
            ans<span style="color: navy"><b> -&gt; </b></span> obs.value = <span style="color: navy">(</span>%ans.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">val</span><span style="color: navy">, </span> val.code = <span style="color: blue">'g/dL'</span><span style="color: navy">, </span> val.unit = <span style="color: blue">'g/dL'</span><span style="color: navy">, </span> val.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setvalue&quot;</i><span style="color: navy">;</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><span style="color: navy">(</span>text.contains('Borne inférieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtLow</span><span style="color: navy">, </span> tgtLow.code = <span style="color: blue">'g/dL'</span><span style="color: navy">, </span> tgtLow.unit = <span style="color: blue">'g/dL'</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><span style="color: navy">(</span>text.contains('Borne supérieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtHigh</span><span style="color: navy">, </span> tgtHigh.code = <span style="color: blue">'g/dL'</span><span style="color: navy">, </span> tgtHigh.unit = <span style="color: blue">'g/dL'</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> <i>&quot;extracthemo&quot;</i><span style="color: navy">;</span>
      hemoGroup.item<b> as </b><span style="color: maroon">hematItem</span><b> where </b><span style="color: navy">(</span>linkId = '813863316705'<span style="color: navy">)</span><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.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<b> then </b>CreateLabObservationCommon<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">obsEntry</span><span style="color: navy">)</span> <i>&quot;createcommon&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-laboratory-hematocrite'</span> <i>&quot;setprofile&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setmeta&quot;</i><span style="color: navy">;</span>
            ans<span style="color: navy"><b> -&gt; </b></span>obs.code = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span>              ans<span style="color: navy"><b> -&gt; </b></span>code.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://loinc.org'</span> <i>&quot;setcodesystem&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'4544-3'</span> <i>&quot;setcodevalue&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Hématocrite [Fraction volumique] Sang ; Numérique ; Comptage automate'</span> <i>&quot;setcodedisplay&quot;</i><span style="color: navy">;</span>
              <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>
            ans<span style="color: navy"><b> -&gt; </b></span> obs.value = <span style="color: navy">(</span>%ans.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">val</span><span style="color: navy">, </span> val.code = <span style="color: blue">'%'</span><span style="color: navy">, </span> val.unit = <span style="color: blue">'%'</span><span style="color: navy">, </span> val.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setvalue&quot;</i><span style="color: navy">;</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><span style="color: navy">(</span>text.contains('Borne inférieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtLow</span><span style="color: navy">, </span> tgtLow.code = <span style="color: blue">'%'</span><span style="color: navy">, </span> tgtLow.unit = <span style="color: blue">'%'</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><span style="color: navy">(</span>text.contains('Borne supérieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtHigh</span><span style="color: navy">, </span> tgtHigh.code = <span style="color: blue">'%'</span><span style="color: navy">, </span> tgtHigh.unit = <span style="color: blue">'%'</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> <i>&quot;extracthemat&quot;</i><span style="color: navy">;</span>
      hemoGroup.item<b> as </b><span style="color: maroon">eryItem</span><b> where </b><span style="color: navy">(</span>linkId = '459731866614'<span style="color: navy">)</span><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.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<b> then </b>CreateLabObservationCommon<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">obsEntry</span><span style="color: navy">)</span> <i>&quot;createcommon&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-laboratory-erythrocytes'</span> <i>&quot;setprofile&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setmeta&quot;</i><span style="color: navy">;</span>
            ans<span style="color: navy"><b> -&gt; </b></span>obs.code = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span>              ans<span style="color: navy"><b> -&gt; </b></span>code.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://loinc.org'</span> <i>&quot;setcodesystem&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'789-8'</span> <i>&quot;setcodevalue&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Érythrocytes [Nombre/Volume] Sang ; Numérique ; Comptage automate'</span> <i>&quot;setcodedisplay&quot;</i><span style="color: navy">;</span>
              <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>
            ans<span style="color: navy"><b> -&gt; </b></span> obs.value = <span style="color: navy">(</span>%ans.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">val</span><span style="color: navy">, </span> val.code = <span style="color: blue">'10*6/uL'</span><span style="color: navy">, </span> val.unit = <span style="color: blue">'10*6/uL'</span><span style="color: navy">, </span> val.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setvalue&quot;</i><span style="color: navy">;</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><span style="color: navy">(</span>text.contains('Borne inférieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtLow</span><span style="color: navy">, </span> tgtLow.code = <span style="color: blue">'10*6/uL'</span><span style="color: navy">, </span> tgtLow.unit = <span style="color: blue">'10*6/uL'</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><span style="color: navy">(</span>text.contains('Borne supérieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtHigh</span><span style="color: navy">, </span> tgtHigh.code = <span style="color: blue">'10*6/uL'</span><span style="color: navy">, </span> tgtHigh.unit = <span style="color: blue">'10*6/uL'</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> <i>&quot;extractery&quot;</i><span style="color: navy">;</span>
      hemoGroup.item<b> as </b><span style="color: maroon">vgmItem</span><b> where </b><span style="color: navy">(</span>linkId = '163624088831'<span style="color: navy">)</span><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.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<b> then </b>CreateLabObservationCommon<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">obsEntry</span><span style="color: navy">)</span> <i>&quot;createcommon&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-laboratory-vgm'</span> <i>&quot;setprofile&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setmeta&quot;</i><span style="color: navy">;</span>
            ans<span style="color: navy"><b> -&gt; </b></span>obs.code = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span>              ans<span style="color: navy"><b> -&gt; </b></span>code.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://loinc.org'</span> <i>&quot;setcodesystem&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'30428-7'</span> <i>&quot;setcodevalue&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Volume globulaire moyen [Volume d\'entité] Érythrocytes ; Numérique'</span> <i>&quot;setcodedisplay&quot;</i><span style="color: navy">;</span>
              <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>
            ans<span style="color: navy"><b> -&gt; </b></span> obs.value = <span style="color: navy">(</span>%ans.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">val</span><span style="color: navy">, </span> val.code = <span style="color: blue">'fL'</span><span style="color: navy">, </span> val.unit = <span style="color: blue">'fL'</span><span style="color: navy">, </span> val.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setvalue&quot;</i><span style="color: navy">;</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><span style="color: navy">(</span>text.contains('Borne inférieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtLow</span><span style="color: navy">, </span> tgtLow.code = <span style="color: blue">'fL'</span><span style="color: navy">, </span> tgtLow.unit = <span style="color: blue">'fL'</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><span style="color: navy">(</span>text.contains('Borne supérieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtHigh</span><span style="color: navy">, </span> tgtHigh.code = <span style="color: blue">'fL'</span><span style="color: navy">, </span> tgtHigh.unit = <span style="color: blue">'fL'</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> <i>&quot;extractvgm&quot;</i><span style="color: navy">;</span>
      hemoGroup.item<b> as </b><span style="color: maroon">platItem</span><b> where </b><span style="color: navy">(</span>linkId = '794156787471'<span style="color: navy">)</span><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.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<b> then </b>CreateLabObservationCommon<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">obsEntry</span><span style="color: navy">)</span> <i>&quot;createcommon&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-laboratory-plaquettes'</span> <i>&quot;setprofile&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setmeta&quot;</i><span style="color: navy">;</span>
            ans<span style="color: navy"><b> -&gt; </b></span>obs.code = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span>              ans<span style="color: navy"><b> -&gt; </b></span>code.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://loinc.org'</span> <i>&quot;setcodesystem&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'777-3'</span> <i>&quot;setcodevalue&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Plaquettes [Nombre/Volume] Sang ; Numérique ; Comptage automate'</span> <i>&quot;setcodedisplay&quot;</i><span style="color: navy">;</span>
              <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>
            ans<span style="color: navy"><b> -&gt; </b></span> obs.value = <span style="color: navy">(</span>%ans.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">val</span><span style="color: navy">, </span> val.code = <span style="color: blue">'10*3/uL'</span><span style="color: navy">, </span> val.unit = <span style="color: blue">'10*3/uL'</span><span style="color: navy">, </span> val.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setvalue&quot;</i><span style="color: navy">;</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><span style="color: navy">(</span>text.contains('Borne inférieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtLow</span><span style="color: navy">, </span> tgtLow.code = <span style="color: blue">'10*3/uL'</span><span style="color: navy">, </span> tgtLow.unit = <span style="color: blue">'10*3/uL'</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><span style="color: navy">(</span>text.contains('Borne supérieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtHigh</span><span style="color: navy">, </span> tgtHigh.code = <span style="color: blue">'10*3/uL'</span><span style="color: navy">, </span> tgtHigh.unit = <span style="color: blue">'10*3/uL'</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> <i>&quot;extractplat&quot;</i><span style="color: navy">;</span>
      hemoGroup.item<b> as </b><span style="color: maroon">neutItem</span><b> where </b><span style="color: navy">(</span>linkId = '961905168477'<span style="color: navy">)</span><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.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<b> then </b>CreateLabObservationCommon<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">obsEntry</span><span style="color: navy">)</span> <i>&quot;createcommon&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-laboratory-neutrophiles'</span> <i>&quot;setprofile&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setmeta&quot;</i><span style="color: navy">;</span>
            ans<span style="color: navy"><b> -&gt; </b></span>obs.code = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span>              ans<span style="color: navy"><b> -&gt; </b></span>code.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://loinc.org'</span> <i>&quot;setcodesystem&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'26499-4'</span> <i>&quot;setcodevalue&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Polynucléaires neutrophiles [Nombre/Volume] Sang ; Numérique'</span> <i>&quot;setcodedisplay&quot;</i><span style="color: navy">;</span>
              <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>
            ans<span style="color: navy"><b> -&gt; </b></span> obs.value = <span style="color: navy">(</span>%ans.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">val</span><span style="color: navy">, </span> val.code = <span style="color: blue">'10*3/uL'</span><span style="color: navy">, </span> val.unit = <span style="color: blue">'10*3/uL'</span><span style="color: navy">, </span> val.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setvalue&quot;</i><span style="color: navy">;</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><span style="color: navy">(</span>text.contains('Borne inférieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtLow</span><span style="color: navy">, </span> tgtLow.code = <span style="color: blue">'10*3/uL'</span><span style="color: navy">, </span> tgtLow.unit = <span style="color: blue">'10*3/uL'</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><span style="color: navy">(</span>text.contains('Borne supérieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtHigh</span><span style="color: navy">, </span> tgtHigh.code = <span style="color: blue">'10*3/uL'</span><span style="color: navy">, </span> tgtHigh.unit = <span style="color: blue">'10*3/uL'</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> <i>&quot;extractneut&quot;</i><span style="color: navy">;</span>
      hemoGroup.item<b> as </b><span style="color: maroon">lymphItem</span><b> where </b><span style="color: navy">(</span>linkId = '695150914696'<span style="color: navy">)</span><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.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<b> then </b>CreateLabObservationCommon<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">obsEntry</span><span style="color: navy">)</span> <i>&quot;createcommon&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-laboratory-lymphocytes'</span> <i>&quot;setprofile&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setmeta&quot;</i><span style="color: navy">;</span>
            ans<span style="color: navy"><b> -&gt; </b></span>obs.code = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span>              ans<span style="color: navy"><b> -&gt; </b></span>code.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://loinc.org'</span> <i>&quot;setcodesystem&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'26474-7'</span> <i>&quot;setcodevalue&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Lymphocytes totaux [Nombre/Volume] Sang ; Numérique'</span> <i>&quot;setcodedisplay&quot;</i><span style="color: navy">;</span>
              <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>
            ans<span style="color: navy"><b> -&gt; </b></span> obs.value = <span style="color: navy">(</span>%ans.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">val</span><span style="color: navy">, </span> val.code = <span style="color: blue">'10*3/uL'</span><span style="color: navy">, </span> val.unit = <span style="color: blue">'10*3/uL'</span><span style="color: navy">, </span> val.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setvalue&quot;</i><span style="color: navy">;</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><span style="color: navy">(</span>text.contains('Borne inférieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtLow</span><span style="color: navy">, </span> tgtLow.code = <span style="color: blue">'10*3/uL'</span><span style="color: navy">, </span> tgtLow.unit = <span style="color: blue">'10*3/uL'</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><span style="color: navy">(</span>text.contains('Borne supérieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtHigh</span><span style="color: navy">, </span> tgtHigh.code = <span style="color: blue">'10*3/uL'</span><span style="color: navy">, </span> tgtHigh.unit = <span style="color: blue">'10*3/uL'</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> <i>&quot;extractlymph&quot;</i><span style="color: navy">;</span>
      hemoGroup.item<b> as </b><span style="color: maroon">eosiItem</span><b> where </b><span style="color: navy">(</span>linkId = '700490326748'<span style="color: navy">)</span><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.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<b> then </b>CreateLabObservationCommon<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">obsEntry</span><span style="color: navy">)</span> <i>&quot;createcommon&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-laboratory-eosinophiles'</span> <i>&quot;setprofile&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setmeta&quot;</i><span style="color: navy">;</span>
            ans<span style="color: navy"><b> -&gt; </b></span>obs.code = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span>              ans<span style="color: navy"><b> -&gt; </b></span>code.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://loinc.org'</span> <i>&quot;setcodesystem&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'26449-9'</span> <i>&quot;setcodevalue&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Polynucléaires éosinophiles [Nombre/Volume] Sang ; Numérique'</span> <i>&quot;setcodedisplay&quot;</i><span style="color: navy">;</span>
              <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>
            ans<span style="color: navy"><b> -&gt; </b></span> obs.value = <span style="color: navy">(</span>%ans.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">val</span><span style="color: navy">, </span> val.code = <span style="color: blue">'10*3/uL'</span><span style="color: navy">, </span> val.unit = <span style="color: blue">'10*3/uL'</span><span style="color: navy">, </span> val.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setvalue&quot;</i><span style="color: navy">;</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><span style="color: navy">(</span>text.contains('Borne inférieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtLow</span><span style="color: navy">, </span> tgtLow.code = <span style="color: blue">'10*3/uL'</span><span style="color: navy">, </span> tgtLow.unit = <span style="color: blue">'10*3/uL'</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><span style="color: navy">(</span>text.contains('Borne supérieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtHigh</span><span style="color: navy">, </span> tgtHigh.code = <span style="color: blue">'10*3/uL'</span><span style="color: navy">, </span> tgtHigh.unit = <span style="color: blue">'10*3/uL'</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> <i>&quot;extracteosi&quot;</i><span style="color: navy">;</span>
      hemoGroup.item<b> as </b><span style="color: maroon">monoItem</span><b> where </b><span style="color: navy">(</span>linkId = '168661900522'<span style="color: navy">)</span><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.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<b> then </b>CreateLabObservationCommon<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">obsEntry</span><span style="color: navy">)</span> <i>&quot;createcommon&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-laboratory-monocytes'</span> <i>&quot;setprofile&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setmeta&quot;</i><span style="color: navy">;</span>
            ans<span style="color: navy"><b> -&gt; </b></span>obs.code = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span>              ans<span style="color: navy"><b> -&gt; </b></span>code.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://loinc.org'</span> <i>&quot;setcodesystem&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'26484-6'</span> <i>&quot;setcodevalue&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Monocytes [Nombre/Volume] Sang ; Numérique'</span> <i>&quot;setcodedisplay&quot;</i><span style="color: navy">;</span>
              <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>
            ans<span style="color: navy"><b> -&gt; </b></span> obs.value = <span style="color: navy">(</span>%ans.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">val</span><span style="color: navy">, </span> val.code = <span style="color: blue">'10*3/uL'</span><span style="color: navy">, </span> val.unit = <span style="color: blue">'10*3/uL'</span><span style="color: navy">, </span> val.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setvalue&quot;</i><span style="color: navy">;</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><span style="color: navy">(</span>text.contains('Borne inférieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtLow</span><span style="color: navy">, </span> tgtLow.code = <span style="color: blue">'10*3/uL'</span><span style="color: navy">, </span> tgtLow.unit = <span style="color: blue">'10*3/uL'</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><span style="color: navy">(</span>text.contains('Borne supérieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtHigh</span><span style="color: navy">, </span> tgtHigh.code = <span style="color: blue">'10*3/uL'</span><span style="color: navy">, </span> tgtHigh.unit = <span style="color: blue">'10*3/uL'</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> <i>&quot;extractmono&quot;</i><span style="color: navy">;</span>
      hemoGroup.item<b> as </b><span style="color: maroon">tpItem</span><b> where </b><span style="color: navy">(</span>linkId = '658898841893'<span style="color: navy">)</span><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.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<b> then </b>CreateLabObservationCommon<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">obsEntry</span><span style="color: navy">)</span> <i>&quot;createcommon&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-laboratory-tp'</span> <i>&quot;setprofile&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setmeta&quot;</i><span style="color: navy">;</span>
            ans<span style="color: navy"><b> -&gt; </b></span>obs.code = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span>              ans<span style="color: navy"><b> -&gt; </b></span>code.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://loinc.org'</span> <i>&quot;setcodesystem&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'5894-1'</span> <i>&quot;setcodevalue&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Temps de quick Patient (%) [Temps relatif] Plasma pauvre en plaquettes ; Numérique ; Coagulation'</span> <i>&quot;setcodedisplay&quot;</i><span style="color: navy">;</span>
              <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>
            ans<span style="color: navy"><b> -&gt; </b></span> obs.value = <span style="color: navy">(</span>%ans.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">val</span><span style="color: navy">, </span> val.code = <span style="color: blue">'%'</span><span style="color: navy">, </span> val.unit = <span style="color: blue">'%'</span><span style="color: navy">, </span> val.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setvalue&quot;</i><span style="color: navy">;</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><span style="color: navy">(</span>text.contains('Borne inférieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtLow</span><span style="color: navy">, </span> tgtLow.code = <span style="color: blue">'%'</span><span style="color: navy">, </span> tgtLow.unit = <span style="color: blue">'%'</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><span style="color: navy">(</span>text.contains('Borne supérieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtHigh</span><span style="color: navy">, </span> tgtHigh.code = <span style="color: blue">'%'</span><span style="color: navy">, </span> tgtHigh.unit = <span style="color: blue">'%'</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> <i>&quot;extracttp&quot;</i><span style="color: navy">;</span>
      hemoGroup.item<b> as </b><span style="color: maroon">tcaItem</span><b> where </b><span style="color: navy">(</span>linkId = '795145096241'<span style="color: navy">)</span><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.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<b> then </b>CreateLabObservationCommon<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">obsEntry</span><span style="color: navy">)</span> <i>&quot;createcommon&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-laboratory-generic'</span> <i>&quot;setprofile&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setmeta&quot;</i><span style="color: navy">;</span>
            ans.item<b> as </b><span style="color: maroon">loincItem</span><b> where </b><span style="color: navy">(</span>text.contains('code loinc')<span style="color: navy">)</span><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.value.ofType(string)<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>
            ans<span style="color: navy"><b> -&gt; </b></span> obs.value = <span style="color: navy">(</span>%ans.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">val</span><span style="color: navy">, </span> val.code = <span style="color: navy">(</span>%ans.value.ofType(Quantity).unit<span style="color: navy">)</span><span style="color: navy">, </span> val.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setvalue&quot;</i><span style="color: navy">;</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><span style="color: navy">(</span>text.contains('Borne inférieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<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.value.ofType(Quantity).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><span style="color: navy">(</span>text.contains('Borne supérieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<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.value.ofType(Quantity).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> <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>
    bioGroup.item<b> as </b><span style="color: maroon">liverGroup</span><b> where </b><span style="color: navy">(</span>linkId = '796308115381'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      liverGroup.item<b> as </b><span style="color: maroon">asatItem</span><b> where </b><span style="color: navy">(</span>linkId = '715226319725'<span style="color: navy">)</span><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.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<b> then </b>CreateLabObservationCommon<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">obsEntry</span><span style="color: navy">)</span> <i>&quot;createcommon&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-laboratory-asat'</span> <i>&quot;setprofile&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setmeta&quot;</i><span style="color: navy">;</span>
            ans<span style="color: navy"><b> -&gt; </b></span>obs.code = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span>              ans<span style="color: navy"><b> -&gt; </b></span>code.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://loinc.org'</span> <i>&quot;setcodesystem&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'30239-8'</span> <i>&quot;setcodevalue&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Aspartate aminotransférase [Catalytique/Volume] Sérum/Plasma ; Numérique ; Avec phosphate de pyridoxal'</span> <i>&quot;setcodedisplay&quot;</i><span style="color: navy">;</span>
              <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>
            ans<span style="color: navy"><b> -&gt; </b></span> obs.value = <span style="color: navy">(</span>%ans.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">val</span><span style="color: navy">, </span> val.code = <span style="color: blue">'[IU]/L'</span><span style="color: navy">, </span> val.unit = <span style="color: blue">'[IU]/L'</span><span style="color: navy">, </span> val.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setvalue&quot;</i><span style="color: navy">;</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><span style="color: navy">(</span>text.contains('Borne inférieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtLow</span><span style="color: navy">, </span> tgtLow.code = <span style="color: blue">'[IU]/L'</span><span style="color: navy">, </span> tgtLow.unit = <span style="color: blue">'[IU]/L'</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><span style="color: navy">(</span>text.contains('Borne supérieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtHigh</span><span style="color: navy">, </span> tgtHigh.code = <span style="color: blue">'[IU]/L'</span><span style="color: navy">, </span> tgtHigh.unit = <span style="color: blue">'[IU]/L'</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> <i>&quot;extractasat&quot;</i><span style="color: navy">;</span>
      liverGroup.item<b> as </b><span style="color: maroon">alatItem</span><b> where </b><span style="color: navy">(</span>linkId = '876439410327'<span style="color: navy">)</span><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.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<b> then </b>CreateLabObservationCommon<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">obsEntry</span><span style="color: navy">)</span> <i>&quot;createcommon&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-laboratory-alat'</span> <i>&quot;setprofile&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setmeta&quot;</i><span style="color: navy">;</span>
            ans<span style="color: navy"><b> -&gt; </b></span>obs.code = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span>              ans<span style="color: navy"><b> -&gt; </b></span>code.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://loinc.org'</span> <i>&quot;setcodesystem&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'1743-4'</span> <i>&quot;setcodevalue&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Alanine aminotransférase [Catalytique/Volume] Sérum/Plasma ; Numérique ; Avec phosphate de pyridoxal'</span> <i>&quot;setcodedisplay&quot;</i><span style="color: navy">;</span>
              <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>
            ans<span style="color: navy"><b> -&gt; </b></span> obs.value = <span style="color: navy">(</span>%ans.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">val</span><span style="color: navy">, </span> val.code = <span style="color: blue">'[IU]/L'</span><span style="color: navy">, </span> val.unit = <span style="color: blue">'[IU]/L'</span><span style="color: navy">, </span> val.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setvalue&quot;</i><span style="color: navy">;</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><span style="color: navy">(</span>text.contains('Borne inférieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtLow</span><span style="color: navy">, </span> tgtLow.code = <span style="color: blue">'[IU]/L'</span><span style="color: navy">, </span> tgtLow.unit = <span style="color: blue">'[IU]/L'</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><span style="color: navy">(</span>text.contains('Borne supérieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtHigh</span><span style="color: navy">, </span> tgtHigh.code = <span style="color: blue">'[IU]/L'</span><span style="color: navy">, </span> tgtHigh.unit = <span style="color: blue">'[IU]/L'</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> <i>&quot;extractalat&quot;</i><span style="color: navy">;</span>
      liverGroup.item<b> as </b><span style="color: maroon">ggtItem</span><b> where </b><span style="color: navy">(</span>linkId = '287545455976'<span style="color: navy">)</span><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.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<b> then </b>CreateLabObservationCommon<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">obsEntry</span><span style="color: navy">)</span> <i>&quot;createcommon&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-laboratory-ggt'</span> <i>&quot;setprofile&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setmeta&quot;</i><span style="color: navy">;</span>
            ans<span style="color: navy"><b> -&gt; </b></span>obs.code = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span>              ans<span style="color: navy"><b> -&gt; </b></span>code.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://loinc.org'</span> <i>&quot;setcodesystem&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'2324-2'</span> <i>&quot;setcodevalue&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Gamma glutamyltransférase [Catalytique/Volume] Sérum/Plasma ; Numérique'</span> <i>&quot;setcodedisplay&quot;</i><span style="color: navy">;</span>
              <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>
            ans<span style="color: navy"><b> -&gt; </b></span> obs.value = <span style="color: navy">(</span>%ans.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">val</span><span style="color: navy">, </span> val.code = <span style="color: blue">'U/L'</span><span style="color: navy">, </span> val.unit = <span style="color: blue">'U/L'</span><span style="color: navy">, </span> val.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setvalue&quot;</i><span style="color: navy">;</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><span style="color: navy">(</span>text.contains('Borne inférieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtLow</span><span style="color: navy">, </span> tgtLow.code = <span style="color: blue">'U/L'</span><span style="color: navy">, </span> tgtLow.unit = <span style="color: blue">'U/L'</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><span style="color: navy">(</span>text.contains('Borne supérieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtHigh</span><span style="color: navy">, </span> tgtHigh.code = <span style="color: blue">'U/L'</span><span style="color: navy">, </span> tgtHigh.unit = <span style="color: blue">'U/L'</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> <i>&quot;extractggt&quot;</i><span style="color: navy">;</span>
      liverGroup.item<b> as </b><span style="color: maroon">palItem</span><b> where </b><span style="color: navy">(</span>linkId = '508269571594'<span style="color: navy">)</span><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.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<b> then </b>CreateLabObservationCommon<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">obsEntry</span><span style="color: navy">)</span> <i>&quot;createcommon&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-laboratory-pal'</span> <i>&quot;setprofile&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setmeta&quot;</i><span style="color: navy">;</span>
            ans<span style="color: navy"><b> -&gt; </b></span>obs.code = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span>              ans<span style="color: navy"><b> -&gt; </b></span>code.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://loinc.org'</span> <i>&quot;setcodesystem&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'6768-6'</span> <i>&quot;setcodevalue&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Phosphatases alcalines [Catalytique/Volume] Sérum/Plasma ; Numérique'</span> <i>&quot;setcodedisplay&quot;</i><span style="color: navy">;</span>
              <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>
            ans<span style="color: navy"><b> -&gt; </b></span> obs.value = <span style="color: navy">(</span>%ans.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">val</span><span style="color: navy">, </span> val.code = <span style="color: blue">'U/L'</span><span style="color: navy">, </span> val.unit = <span style="color: blue">'U/L'</span><span style="color: navy">, </span> val.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setvalue&quot;</i><span style="color: navy">;</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><span style="color: navy">(</span>text.contains('Borne inférieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtLow</span><span style="color: navy">, </span> tgtLow.code = <span style="color: blue">'U/L'</span><span style="color: navy">, </span> tgtLow.unit = <span style="color: blue">'U/L'</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><span style="color: navy">(</span>text.contains('Borne supérieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtHigh</span><span style="color: navy">, </span> tgtHigh.code = <span style="color: blue">'U/L'</span><span style="color: navy">, </span> tgtHigh.unit = <span style="color: blue">'U/L'</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> <i>&quot;extractpal&quot;</i><span style="color: navy">;</span>
      liverGroup.item<b> as </b><span style="color: maroon">bilTotItem</span><b> where </b><span style="color: navy">(</span>linkId = '927344090061'<span style="color: navy">)</span><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.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<b> then </b>CreateLabObservationCommon<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">obsEntry</span><span style="color: navy">)</span> <i>&quot;createcommon&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-laboratory-bilirubine-totale'</span> <i>&quot;setprofile&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setmeta&quot;</i><span style="color: navy">;</span>
            ans<span style="color: navy"><b> -&gt; </b></span>obs.code = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span>              ans<span style="color: navy"><b> -&gt; </b></span>code.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://loinc.org'</span> <i>&quot;setcodesystem&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'14631-6'</span> <i>&quot;setcodevalue&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Bilirubine [Moles/Volume] Sérum/Plasma ; Numérique'</span> <i>&quot;setcodedisplay&quot;</i><span style="color: navy">;</span>
              <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>
            ans<span style="color: navy"><b> -&gt; </b></span> obs.value = <span style="color: navy">(</span>%ans.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">val</span><span style="color: navy">, </span> val.code = <span style="color: blue">'umol/L'</span><span style="color: navy">, </span> val.unit = <span style="color: blue">'umol/L'</span><span style="color: navy">, </span> val.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setvalue&quot;</i><span style="color: navy">;</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><span style="color: navy">(</span>text.contains('Borne inférieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtLow</span><span style="color: navy">, </span> tgtLow.code = <span style="color: blue">'umol/L'</span><span style="color: navy">, </span> tgtLow.unit = <span style="color: blue">'umol/L'</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><span style="color: navy">(</span>text.contains('Borne supérieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtHigh</span><span style="color: navy">, </span> tgtHigh.code = <span style="color: blue">'umol/L'</span><span style="color: navy">, </span> tgtHigh.unit = <span style="color: blue">'umol/L'</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> <i>&quot;extractbiltot&quot;</i><span style="color: navy">;</span>
      liverGroup.item<b> as </b><span style="color: maroon">bilConjItem</span><b> where </b><span style="color: navy">(</span>linkId = '208196328453'<span style="color: navy">)</span><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.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<b> then </b>CreateLabObservationCommon<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">obsEntry</span><span style="color: navy">)</span> <i>&quot;createcommon&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-laboratory-bilirubine-conjuguee'</span> <i>&quot;setprofile&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setmeta&quot;</i><span style="color: navy">;</span>
            ans<span style="color: navy"><b> -&gt; </b></span>obs.code = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span>              ans<span style="color: navy"><b> -&gt; </b></span>code.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://loinc.org'</span> <i>&quot;setcodesystem&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'29760-6'</span> <i>&quot;setcodevalue&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Bilirubine conjuguée [Moles/Volume] Sérum/Plasma ; Numérique'</span> <i>&quot;setcodedisplay&quot;</i><span style="color: navy">;</span>
              <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>
            ans<span style="color: navy"><b> -&gt; </b></span> obs.value = <span style="color: navy">(</span>%ans.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">val</span><span style="color: navy">, </span> val.code = <span style="color: blue">'umol/L'</span><span style="color: navy">, </span> val.unit = <span style="color: blue">'umol/L'</span><span style="color: navy">, </span> val.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setvalue&quot;</i><span style="color: navy">;</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><span style="color: navy">(</span>text.contains('Borne inférieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtLow</span><span style="color: navy">, </span> tgtLow.code = <span style="color: blue">'umol/L'</span><span style="color: navy">, </span> tgtLow.unit = <span style="color: blue">'umol/L'</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><span style="color: navy">(</span>text.contains('Borne supérieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtHigh</span><span style="color: navy">, </span> tgtHigh.code = <span style="color: blue">'umol/L'</span><span style="color: navy">, </span> tgtHigh.unit = <span style="color: blue">'umol/L'</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> <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>
    bioGroup.item<b> as </b><span style="color: maroon">glucoseGroup</span><b> where </b><span style="color: navy">(</span>linkId = '334039497382'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>      glucoseGroup.item<b> as </b><span style="color: maroon">glycItem</span><b> where </b><span style="color: navy">(</span>linkId = '273778921448'<span style="color: navy">)</span><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.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<b> then </b>CreateLabObservationCommon<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">obsEntry</span><span style="color: navy">)</span> <i>&quot;createcommon&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-laboratory-glycemie-a-jeun'</span> <i>&quot;setprofile&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setmeta&quot;</i><span style="color: navy">;</span>
            ans<span style="color: navy"><b> -&gt; </b></span>obs.code = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span>              ans<span style="color: navy"><b> -&gt; </b></span>code.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://loinc.org'</span> <i>&quot;setcodesystem&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'14749-6'</span> <i>&quot;setcodevalue&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Glucose [Moles/Volume] Sérum/Plasma ; Numérique'</span> <i>&quot;setcodedisplay&quot;</i><span style="color: navy">;</span>
              <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>
            ans<span style="color: navy"><b> -&gt; </b></span> obs.value = <span style="color: navy">(</span>%ans.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">val</span><span style="color: navy">, </span> val.code = <span style="color: blue">'mmol/L'</span><span style="color: navy">, </span> val.unit = <span style="color: blue">'mmol/L'</span><span style="color: navy">, </span> val.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setvalue&quot;</i><span style="color: navy">;</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><span style="color: navy">(</span>text.contains('Borne inférieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtLow</span><span style="color: navy">, </span> tgtLow.code = <span style="color: blue">'mmol/L'</span><span style="color: navy">, </span> tgtLow.unit = <span style="color: blue">'mmol/L'</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><span style="color: navy">(</span>text.contains('Borne supérieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtHigh</span><span style="color: navy">, </span> tgtHigh.code = <span style="color: blue">'mmol/L'</span><span style="color: navy">, </span> tgtHigh.unit = <span style="color: blue">'mmol/L'</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> <i>&quot;extractglyc&quot;</i><span style="color: navy">;</span>
      glucoseGroup.item<b> as </b><span style="color: maroon">hba1cItem</span><b> where </b><span style="color: navy">(</span>linkId = '632894677152'<span style="color: navy">)</span><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.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<b> then </b>CreateLabObservationCommon<span style="color: navy">(</span><span style="color: maroon">ans</span><span style="color: navy">, </span><span style="color: maroon">patient</span><span style="color: navy">, </span><span style="color: maroon">obs</span><span style="color: navy">, </span><span style="color: maroon">obsEntry</span><span style="color: navy">)</span> <i>&quot;createcommon&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-laboratory-hba1c'</span> <i>&quot;setprofile&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;setmeta&quot;</i><span style="color: navy">;</span>
            ans<span style="color: navy"><b> -&gt; </b></span>obs.code = <b>create</b><span style="color: navy">(</span><span style="color: blue">'CodeableConcept'</span><span style="color: navy">)</span><b> as </b><span style="color: maroon">code</span><b> then</b><span style="color: navy"> {
</span>              ans<span style="color: navy"><b> -&gt; </b></span>code.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://loinc.org'</span> <i>&quot;setcodesystem&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.code = <span style="color: blue">'4548-4'</span> <i>&quot;setcodevalue&quot;</i><span style="color: navy">;</span>
                ans<span style="color: navy"><b> -&gt; </b></span>coding.display = <span style="color: blue">'Hémoglobine A1c/hémoglobine totale [Fraction massique] Sang ; Numérique'</span> <i>&quot;setcodedisplay&quot;</i><span style="color: navy">;</span>
              <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>
            ans<span style="color: navy"><b> -&gt; </b></span> obs.value = <span style="color: navy">(</span>%ans.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">val</span><span style="color: navy">, </span> val.code = <span style="color: blue">'%'</span><span style="color: navy">, </span> val.unit = <span style="color: blue">'%'</span><span style="color: navy">, </span> val.system = <span style="color: blue">'http://unitsofmeasure.org'</span> <i>&quot;setvalue&quot;</i><span style="color: navy">;</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><span style="color: navy">(</span>text.contains('Borne inférieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtLow</span><span style="color: navy">, </span> tgtLow.code = <span style="color: blue">'%'</span><span style="color: navy">, </span> tgtLow.unit = <span style="color: blue">'%'</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><span style="color: navy">(</span>text.contains('Borne supérieure')<span style="color: navy">)</span><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.value.ofType(Quantity)<span style="color: navy">)</span><b> as </b><span style="color: maroon">tgtHigh</span><span style="color: navy">, </span> tgtHigh.code = <span style="color: blue">'%'</span><span style="color: navy">, </span> tgtHigh.unit = <span style="color: blue">'%'</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> <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: fields common to every simple lab Observation (id/fullUrl, status, category, subject,</span>
<span style="color: navy">// </span><span style="color: green">value, effective, referenceRange). meta.profile and code are call-site responsibilities --</span>
<span style="color: navy">// </span><span style="color: green">a literal `source` group parameter is rejected by Matchbox even when unused (see issue #10),</span>
<span style="color: navy">// </span><span style="color: green">so each call site sets those two fields itself via trailing rules against the `obs`/`obsEntry`</span>
<span style="color: navy">// </span><span style="color: green">target parameters this group is handed, rather than passing them in as data.</span>
<b>group </b>CreateLabObservationCommon<span style="color: navy">(</span><b>source</b> <span style="color: maroon">ans</span>, <b>target</b> <span style="color: maroon">patient</span><span style="color: navy"> : </span>Patient, <b>target</b> <span style="color: maroon">obs</span><span style="color: navy"> : </span>Observation, <b>target</b> <span style="color: maroon">obsEntry</span><span style="color: navy">)</span><span style="color: navy"> {
</span>  ans.item<b> as </b><span style="color: maroon">labIdItem</span><b> where </b><span style="color: navy">(</span>text = 'Identifiant'<span style="color: navy">)</span><b> then</b><span style="color: navy"> {
</span>    labIdItem.answer<b> as </b><span style="color: maroon">labIdAns</span><span style="color: navy"><b> -&gt; </b></span>obs.id = <span style="color: navy">(</span>%labIdAns.value.ofType(string)<span style="color: navy">)</span> <i>&quot;setobsid&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;extractobsid&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.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>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>
  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>
  ans.item<b> as </b><span style="color: maroon">dateItem</span><b> where </b><span style="color: navy">(</span>text.contains('Date et heure du prélèvement')<span style="color: navy">)</span><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.value.ofType(dateTime)<span style="color: navy">)</span> <i>&quot;seteffective&quot;</i><span style="color: navy">;</span>
  <span style="color: navy">}</span> <i>&quot;extracteffective&quot;</i><span style="color: navy">;</span>
<span style="color: navy">}

</span></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="Questionnaire to FHIR Semantic Layer"/>
  <status value="draft"/>
  <date value="2026-08-27T14:35:15+00:00"/>
  <publisher value="AP-HP"/>
  <contact>
    <name value="AP-HP"/>
    <telecom>
      <system value="url"/>
      <value value="https://aphp.fr"/>
    </telecom>
  </contact>
  <description
               value="Transforms QuestionnaireResponse based on Questionnaire Usage Variables socles into FHIR resources conforming to DM profiles"/>
  <jurisdiction>
    <coding>
      <system value="urn:iso:std:iso:3166"/>
      <code value="FR"/>
    </coding>
  </jurisdiction>
  <structure>
    <url
         value="http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse"/>
    <mode value="source"/>
    <alias value="QuestionnaireResponse"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Bundle"/>
    <mode value="target"/>
    <alias value="Bundle"/>
  </structure>
  <group>
    <name value="QuestionnaireResponseToBundle"/>
    <typeMode value="none"/>
    <documentation
                   value="Main entry point: Transform QuestionnaireResponse to Bundle"/>
    <input>
      <name value="src"/>
      <type value="QuestionnaireResponse"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="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>
      <documentation value="Initialize Bundle"/>
    </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>
          <documentation value="Create Encounters from PMSI data"/>
        </rule>
        <rule>
          <name value="createlabobservations"/>
          <source>
            <context value="src"/>
          </source>
          <dependent>
            <name value="CreateLaboratoryObservations"/>
            <variable value="src"/>
            <variable value="patient"/>
            <variable value="bundle"/>
          </dependent>
          <documentation value="Create Laboratory Observations"/>
        </rule>
        <rule>
          <name value="createmedicationrequests"/>
          <source>
            <context value="src"/>
          </source>
          <dependent>
            <name value="CreateMedicationRequests"/>
            <variable value="src"/>
            <variable value="patient"/>
            <variable value="bundle"/>
          </dependent>
          <documentation value="Create Medication Requests"/>
        </rule>
        <rule>
          <name value="createmedicationadministrations"/>
          <source>
            <context value="src"/>
          </source>
          <dependent>
            <name value="CreateMedicationAdministrations"/>
            <variable value="src"/>
            <variable value="patient"/>
            <variable value="bundle"/>
          </dependent>
          <documentation value="Create Medication Administrations"/>
        </rule>
        <rule>
          <name value="createvitalsigns"/>
          <source>
            <context value="src"/>
          </source>
          <dependent>
            <name value="CreateVitalSignObservations"/>
            <variable value="src"/>
            <variable value="patient"/>
            <variable value="bundle"/>
          </dependent>
          <documentation value="Create Vital Sign Observations"/>
        </rule>
      </rule>
      <documentation value="Create Patient resource"/>
    </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="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="extractpatientid"/>
          <source>
            <context value="identity"/>
            <element value="item"/>
            <variable value="patIdItem"/>
            <condition value="linkId = '236790258446'"/>
          </source>
          <rule>
            <name value="setpatientid"/>
            <source>
              <context value="patIdItem"/>
              <element value="answer"/>
              <variable value="patIdAns"/>
            </source>
            <target>
              <context value="patient"/>
              <contextType value="variable"/>
              <element value="id"/>
              <transform value="evaluate"/>
              <parameter>
                <valueString value="%patIdAns.value.ofType(string)"/>
              </parameter>
            </target>
          </rule>
          <documentation
                         value="Patient id (saisi manuellement dans le champ &quot;Identifiant&quot;, linkId 236790258446)"/>
        </rule>
        <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.value.ofType(string)"/>
                </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.value.ofType(string)"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <documentation
                         value="Patient name (linkId 8605698058770 = family, 6214879623503 = given)"/>
        </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.value.ofType(string)"/>
                </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>
          <documentation value="NIR identifier (linkId 5711960356160)"/>
        </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.value.ofType(string)"/>
                </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>
          <documentation value="INS identifier (linkId 3764723550987)"/>
        </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.value.ofType(date)"/>
              </parameter>
            </target>
          </rule>
          <documentation value="Birth date (linkId 5036133558154)"/>
        </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.value.ofType(date)"/>
              </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.value.ofType(Coding)"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <documentation value="Death source (linkId 9098810065693)"/>
          </rule>
          <documentation value="Death date (linkId 5633552097315)"/>
        </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.value.ofType(integer)"/>
              </parameter>
            </target>
          </rule>
          <documentation value="Multiple birth rank (linkId 6931296968515)"/>
        </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.value.ofType(decimal)"/>
                      </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.value.ofType(decimal)"/>
                          </parameter>
                        </target>
                      </rule>
                    </rule>
                  </rule>
                </rule>
                <documentation value="geolocation"/>
              </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.value.ofType(string)"/>
                    </parameter>
                  </target>
                </rule>
                <documentation value="IRIS"/>
              </rule>
              <documentation value="Environnement"/>
            </rule>
          </rule>
          <documentation
                         value="Address from code géographique (linkId 2446369196222)"/>
        </rule>
        <documentation
                       value="Gender from PMSI data (linkId 3894630481120 within 2825244231605)"/>
      </rule>
      <documentation
                     value="Extract patient identity data from linkId 4647259356106 &gt; 2958000860428"/>
    </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="setencounterid"/>
          <source>
            <context value="src"/>
          </source>
          <target>
            <context value="patient"/>
            <contextType value="variable"/>
            <element value="id"/>
            <variable value="patIdForEnc"/>
          </target>
          <target>
            <context value="encounter"/>
            <contextType value="variable"/>
            <element value="id"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="%patIdForEnc.replace('-pat-', '-sej-')"/>
            </parameter>
          </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.value.ofType(date)"/>
                </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.value.ofType(date)"/>
                </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"/>
    <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="extractconditionid"/>
          <source>
            <context value="diagGroup"/>
            <element value="item"/>
            <variable value="condIdItem"/>
            <condition value="linkId = '123759733087'"/>
          </source>
          <rule>
            <name value="setconditionid"/>
            <source>
              <context value="condIdItem"/>
              <element value="answer"/>
              <variable value="condIdAns"/>
            </source>
            <target>
              <context value="condition"/>
              <contextType value="variable"/>
              <element value="id"/>
              <transform value="evaluate"/>
              <parameter>
                <valueString value="%condIdAns.value.ofType(string)"/>
              </parameter>
            </target>
          </rule>
        </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.value.ofType(string)"/>
                </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.value.ofType(string)"/>
                  </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.value.ofType(date)"/>
              </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"/>
    <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="extractprocedureid"/>
          <source>
            <context value="acteGroup"/>
            <element value="item"/>
            <variable value="procIdItem"/>
            <condition value="linkId = '151762387793'"/>
          </source>
          <rule>
            <name value="setprocedureid"/>
            <source>
              <context value="procIdItem"/>
              <element value="answer"/>
              <variable value="procIdAns"/>
            </source>
            <target>
              <context value="procedure"/>
              <contextType value="variable"/>
              <element value="id"/>
              <transform value="evaluate"/>
              <parameter>
                <valueString value="%procIdAns.value.ofType(string)"/>
              </parameter>
            </target>
          </rule>
        </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.value.ofType(string)"/>
                </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.value.ofType(dateTime)"/>
              </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"/>
    <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="navPrescribedMedForId"/>
            <source>
              <context value="prescribedGroup"/>
              <element value="answer"/>
              <variable value="prescribedMedForId"/>
            </source>
            <rule>
              <name value="extractmedreqid"/>
              <source>
                <context value="prescribedMedForId"/>
                <element value="item"/>
                <variable value="medReqIdItem"/>
                <condition value="linkId = '145920953908'"/>
              </source>
              <rule>
                <name value="setmedreqid"/>
                <source>
                  <context value="medReqIdItem"/>
                  <element value="answer"/>
                  <variable value="medReqIdAns"/>
                </source>
                <target>
                  <context value="medReq"/>
                  <contextType value="variable"/>
                  <element value="id"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%medReqIdAns.value.ofType(string)"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </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.value.ofType(string)"/>
                  </parameter>
                </target>
                <target>
                  <context value="medReqC"/>
                  <contextType value="variable"/>
                  <element value="display"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString
                                 value="%prescribedMedication.value.ofType(string)"/>
                  </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.value.ofType(string)"/>
                      </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="bounds"/>
                <variable value="timingPeriod"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Period"/>
                </parameter>
              </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.value.ofType(date)"/>
                    </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.value.ofType(date)"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="CreateMedicationAdministrations"/>
    <typeMode value="none"/>
    <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="navAdministeredMedForId"/>
            <source>
              <context value="adminGroup"/>
              <element value="answer"/>
              <variable value="administeredMedForId"/>
            </source>
            <rule>
              <name value="extractmedadminid"/>
              <source>
                <context value="administeredMedForId"/>
                <element value="item"/>
                <variable value="medAdminIdItem"/>
                <condition value="linkId = '870029232684'"/>
              </source>
              <rule>
                <name value="setmedadminid"/>
                <source>
                  <context value="medAdminIdItem"/>
                  <element value="answer"/>
                  <variable value="medAdminIdAns"/>
                </source>
                <target>
                  <context value="medAdmin"/>
                  <contextType value="variable"/>
                  <element value="id"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%medAdminIdAns.value.ofType(string)"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </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.value.ofType(string)"/>
                  </parameter>
                </target>
                <target>
                  <context value="medAdminC"/>
                  <contextType value="variable"/>
                  <element value="display"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString
                                 value="%administeredMedication.value.ofType(string)"/>
                  </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.value.ofType(string)"/>
                      </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.value.ofType(Quantity)"/>
                    </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="effective"/>
                        <variable value="adminPeriod"/>
                        <transform value="create"/>
                        <parameter>
                          <valueString value="Period"/>
                        </parameter>
                      </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"/>
    <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="extractheightid"/>
                <source>
                  <context value="ans"/>
                  <element value="item"/>
                  <variable value="heightIdItem"/>
                  <condition value="linkId = '854021250495'"/>
                </source>
                <rule>
                  <name value="setobsid"/>
                  <source>
                    <context value="heightIdItem"/>
                    <element value="answer"/>
                    <variable value="heightIdAns"/>
                  </source>
                  <target>
                    <context value="obs"/>
                    <contextType value="variable"/>
                    <element value="id"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="%heightIdAns.value.ofType(string)"/>
                    </parameter>
                  </target>
                </rule>
              </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.value.ofType(Quantity)"/>
                  </parameter>
                </target>
                <target>
                  <context value="tgtObsVal"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%ans.value.ofType(Quantity).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="extractweightid"/>
                <source>
                  <context value="ans"/>
                  <element value="item"/>
                  <variable value="weightIdItem"/>
                  <condition value="linkId = '199208534521'"/>
                </source>
                <rule>
                  <name value="setobsid"/>
                  <source>
                    <context value="weightIdItem"/>
                    <element value="answer"/>
                    <variable value="weightIdAns"/>
                  </source>
                  <target>
                    <context value="obs"/>
                    <contextType value="variable"/>
                    <element value="id"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="%weightIdAns.value.ofType(string)"/>
                    </parameter>
                  </target>
                </rule>
              </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.value.ofType(Quantity)"/>
                  </parameter>
                </target>
                <target>
                  <context value="tgtObsVal"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%ans.value.ofType(Quantity).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="extractsysid"/>
                    <source>
                      <context value="sysAns"/>
                      <element value="item"/>
                      <variable value="sysIdItem"/>
                      <condition value="linkId = '734815456784'"/>
                    </source>
                    <rule>
                      <name value="navSysIdAns"/>
                      <source>
                        <context value="sysIdItem"/>
                        <element value="answer"/>
                        <variable value="sysIdAns"/>
                      </source>
                      <rule>
                        <name value="extractdiaid"/>
                        <source>
                          <context value="diaAns"/>
                          <element value="item"/>
                          <variable value="diaIdItem"/>
                          <condition value="linkId = '926430936118'"/>
                        </source>
                        <rule>
                          <name value="setobsid"/>
                          <source>
                            <context value="diaIdItem"/>
                            <element value="answer"/>
                            <variable value="diaIdAns"/>
                          </source>
                          <target>
                            <context value="obs"/>
                            <contextType value="variable"/>
                            <element value="id"/>
                            <transform value="evaluate"/>
                            <parameter>
                              <valueString
                                           value="%sysIdAns.value.ofType(string) + '-' + %diaIdAns.value.ofType(string)"/>
                            </parameter>
                          </target>
                        </rule>
                      </rule>
                    </rule>
                  </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.value.ofType(Quantity)"/>
                        </parameter>
                      </target>
                      <target>
                        <context value="sysVal"/>
                        <contextType value="variable"/>
                        <element value="code"/>
                        <transform value="evaluate"/>
                        <parameter>
                          <valueString
                                       value="%sysAns.value.ofType(Quantity).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.value.ofType(Quantity)"/>
                        </parameter>
                      </target>
                      <target>
                        <context value="diaVal"/>
                        <contextType value="variable"/>
                        <element value="code"/>
                        <transform value="evaluate"/>
                        <parameter>
                          <valueString
                                       value="%diaAns.value.ofType(Quantity).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"/>
    <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="obsentry"/>
            <source>
              <context value="ureaItem"/>
              <element value="answer"/>
              <variable 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="createcommon"/>
                <source>
                  <context value="ans"/>
                </source>
                <dependent>
                  <name value="CreateLabObservationCommon"/>
                  <variable value="ans"/>
                  <variable value="patient"/>
                  <variable value="obs"/>
                  <variable value="obsEntry"/>
                </dependent>
              </rule>
              <rule>
                <name value="setmeta"/>
                <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="setprofile"/>
                  <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-laboratory-uremie"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="setcode"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <variable value="code"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="CodeableConcept"/>
                  </parameter>
                </target>
                <rule>
                  <name value="setcoding"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="code"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <variable value="coding"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Coding"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="setcodesystem"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="http://loinc.org"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodevalue"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="22664-7"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodedisplay"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="display"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString
                                     value="Urée [Moles/Volume] Sérum/Plasma ; Numérique"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
              <rule>
                <name value="setvalue"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="value"/>
                  <variable value="val"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%ans.value.ofType(Quantity)"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="mmol/L"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="unit"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="mmol/L"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://unitsofmeasure.org"/>
                  </parameter>
                </target>
              </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="mmol/L"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="mmol/L"/>
                      </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="mmol/L"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="mmol/L"/>
                      </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>
        </rule>
        <rule>
          <name value="extractcreat"/>
          <source>
            <context value="renalGroup"/>
            <element value="item"/>
            <variable value="creatItem"/>
            <condition value="linkId = '500408205043'"/>
          </source>
          <rule>
            <name value="obsentry"/>
            <source>
              <context value="creatItem"/>
              <element value="answer"/>
              <variable 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="createcommon"/>
                <source>
                  <context value="ans"/>
                </source>
                <dependent>
                  <name value="CreateLabObservationCommon"/>
                  <variable value="ans"/>
                  <variable value="patient"/>
                  <variable value="obs"/>
                  <variable value="obsEntry"/>
                </dependent>
              </rule>
              <rule>
                <name value="setmeta"/>
                <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="setprofile"/>
                  <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-laboratory-creat"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="setcode"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <variable value="code"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="CodeableConcept"/>
                  </parameter>
                </target>
                <rule>
                  <name value="setcoding"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="code"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <variable value="coding"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Coding"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="setcodesystem"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="http://loinc.org"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodevalue"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="14682-9"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodedisplay"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="display"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString
                                     value="Créatinine [Moles/Volume] Sérum/Plasma ; Numérique"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
              <rule>
                <name value="setvalue"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="value"/>
                  <variable value="val"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%ans.value.ofType(Quantity)"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="umol/L"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="unit"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="umol/L"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://unitsofmeasure.org"/>
                  </parameter>
                </target>
              </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="linkId = '488869963230'"/>
                  </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="umol/L"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="umol/L"/>
                      </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="linkId = '984480974142'"/>
                  </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="umol/L"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="umol/L"/>
                      </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>
        </rule>
        <rule>
          <name value="extractdfg"/>
          <source>
            <context value="renalGroup"/>
            <element value="item"/>
            <variable value="dfgItem"/>
            <condition value="linkId = '786621340679'"/>
          </source>
          <rule>
            <name value="obsentry"/>
            <source>
              <context value="dfgItem"/>
              <element value="answer"/>
              <variable 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="createcommon"/>
                <source>
                  <context value="ans"/>
                </source>
                <dependent>
                  <name value="CreateLabObservationCommon"/>
                  <variable value="ans"/>
                  <variable value="patient"/>
                  <variable value="obs"/>
                  <variable value="obsEntry"/>
                </dependent>
              </rule>
              <rule>
                <name value="setmeta"/>
                <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="setprofile"/>
                  <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-laboratory-dfg"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="setcode"/>
                <source>
                  <context value="ans"/>
                  <element value="item"/>
                  <variable value="loincItem"/>
                  <condition value="linkId = '974417569313'"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <variable value="code"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="CodeableConcept"/>
                  </parameter>
                </target>
                <rule>
                  <name value="setcoding"/>
                  <source>
                    <context value="loincItem"/>
                    <element value="answer"/>
                    <variable value="loincAns"/>
                  </source>
                  <target>
                    <context value="code"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <variable value="coding"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Coding"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="setcodesystem"/>
                    <source>
                      <context value="loincAns"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="http://loinc.org"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodevalue"/>
                    <source>
                      <context value="loincAns"/>
                      <element value="value"/>
                      <variable value="loincValue"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueId value="loincValue"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
              <rule>
                <name value="setvalue"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="value"/>
                  <variable value="val"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%ans.value.ofType(Quantity)"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://unitsofmeasure.org"/>
                  </parameter>
                </target>
              </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="linkId = '809916645548'"/>
                  </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.value.ofType(Quantity)"/>
                      </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="linkId = '323493215684'"/>
                  </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.value.ofType(Quantity)"/>
                      </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>
        </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="obsentry"/>
            <source>
              <context value="leukoItem"/>
              <element value="answer"/>
              <variable 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="createcommon"/>
                <source>
                  <context value="ans"/>
                </source>
                <dependent>
                  <name value="CreateLabObservationCommon"/>
                  <variable value="ans"/>
                  <variable value="patient"/>
                  <variable value="obs"/>
                  <variable value="obsEntry"/>
                </dependent>
              </rule>
              <rule>
                <name value="setmeta"/>
                <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="setprofile"/>
                  <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-laboratory-leucocytes"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="setcode"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <variable value="code"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="CodeableConcept"/>
                  </parameter>
                </target>
                <rule>
                  <name value="setcoding"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="code"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <variable value="coding"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Coding"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="setcodesystem"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="http://loinc.org"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodevalue"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="6690-2"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodedisplay"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="display"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString
                                     value="Leucocytes [Nombre/Volume] Sang ; Numérique ; Comptage automate"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
              <rule>
                <name value="setvalue"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="value"/>
                  <variable value="val"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%ans.value.ofType(Quantity)"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="10*3/uL"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="unit"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="10*3/uL"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://unitsofmeasure.org"/>
                  </parameter>
                </target>
              </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="10*3/uL"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="10*3/uL"/>
                      </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="10*3/uL"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="10*3/uL"/>
                      </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>
        </rule>
        <rule>
          <name value="extracthemo"/>
          <source>
            <context value="hemoGroup"/>
            <element value="item"/>
            <variable value="hemoItem"/>
            <condition value="linkId = '304159088493'"/>
          </source>
          <rule>
            <name value="obsentry"/>
            <source>
              <context value="hemoItem"/>
              <element value="answer"/>
              <variable 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="createcommon"/>
                <source>
                  <context value="ans"/>
                </source>
                <dependent>
                  <name value="CreateLabObservationCommon"/>
                  <variable value="ans"/>
                  <variable value="patient"/>
                  <variable value="obs"/>
                  <variable value="obsEntry"/>
                </dependent>
              </rule>
              <rule>
                <name value="setmeta"/>
                <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="setprofile"/>
                  <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-laboratory-hemoglobine"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="setcode"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <variable value="code"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="CodeableConcept"/>
                  </parameter>
                </target>
                <rule>
                  <name value="setcoding"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="code"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <variable value="coding"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Coding"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="setcodesystem"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="http://loinc.org"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodevalue"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="718-7"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodedisplay"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="display"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString
                                     value="Hémoglobine [Masse/Volume] Sang ; Numérique"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
              <rule>
                <name value="setvalue"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="value"/>
                  <variable value="val"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%ans.value.ofType(Quantity)"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="g/dL"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="unit"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="g/dL"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://unitsofmeasure.org"/>
                  </parameter>
                </target>
              </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="g/dL"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="g/dL"/>
                      </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="g/dL"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="g/dL"/>
                      </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>
        </rule>
        <rule>
          <name value="extracthemat"/>
          <source>
            <context value="hemoGroup"/>
            <element value="item"/>
            <variable value="hematItem"/>
            <condition value="linkId = '813863316705'"/>
          </source>
          <rule>
            <name value="obsentry"/>
            <source>
              <context value="hematItem"/>
              <element value="answer"/>
              <variable 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="createcommon"/>
                <source>
                  <context value="ans"/>
                </source>
                <dependent>
                  <name value="CreateLabObservationCommon"/>
                  <variable value="ans"/>
                  <variable value="patient"/>
                  <variable value="obs"/>
                  <variable value="obsEntry"/>
                </dependent>
              </rule>
              <rule>
                <name value="setmeta"/>
                <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="setprofile"/>
                  <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-laboratory-hematocrite"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="setcode"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <variable value="code"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="CodeableConcept"/>
                  </parameter>
                </target>
                <rule>
                  <name value="setcoding"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="code"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <variable value="coding"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Coding"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="setcodesystem"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="http://loinc.org"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodevalue"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="4544-3"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodedisplay"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="display"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString
                                     value="Hématocrite [Fraction volumique] Sang ; Numérique ; Comptage automate"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
              <rule>
                <name value="setvalue"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="value"/>
                  <variable value="val"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%ans.value.ofType(Quantity)"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="%"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="unit"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="%"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://unitsofmeasure.org"/>
                  </parameter>
                </target>
              </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="%"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="%"/>
                      </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="%"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="%"/>
                      </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>
        </rule>
        <rule>
          <name value="extractery"/>
          <source>
            <context value="hemoGroup"/>
            <element value="item"/>
            <variable value="eryItem"/>
            <condition value="linkId = '459731866614'"/>
          </source>
          <rule>
            <name value="obsentry"/>
            <source>
              <context value="eryItem"/>
              <element value="answer"/>
              <variable 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="createcommon"/>
                <source>
                  <context value="ans"/>
                </source>
                <dependent>
                  <name value="CreateLabObservationCommon"/>
                  <variable value="ans"/>
                  <variable value="patient"/>
                  <variable value="obs"/>
                  <variable value="obsEntry"/>
                </dependent>
              </rule>
              <rule>
                <name value="setmeta"/>
                <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="setprofile"/>
                  <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-laboratory-erythrocytes"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="setcode"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <variable value="code"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="CodeableConcept"/>
                  </parameter>
                </target>
                <rule>
                  <name value="setcoding"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="code"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <variable value="coding"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Coding"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="setcodesystem"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="http://loinc.org"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodevalue"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="789-8"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodedisplay"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="display"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString
                                     value="Érythrocytes [Nombre/Volume] Sang ; Numérique ; Comptage automate"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
              <rule>
                <name value="setvalue"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="value"/>
                  <variable value="val"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%ans.value.ofType(Quantity)"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="10*6/uL"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="unit"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="10*6/uL"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://unitsofmeasure.org"/>
                  </parameter>
                </target>
              </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="10*6/uL"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="10*6/uL"/>
                      </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="10*6/uL"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="10*6/uL"/>
                      </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>
        </rule>
        <rule>
          <name value="extractvgm"/>
          <source>
            <context value="hemoGroup"/>
            <element value="item"/>
            <variable value="vgmItem"/>
            <condition value="linkId = '163624088831'"/>
          </source>
          <rule>
            <name value="obsentry"/>
            <source>
              <context value="vgmItem"/>
              <element value="answer"/>
              <variable 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="createcommon"/>
                <source>
                  <context value="ans"/>
                </source>
                <dependent>
                  <name value="CreateLabObservationCommon"/>
                  <variable value="ans"/>
                  <variable value="patient"/>
                  <variable value="obs"/>
                  <variable value="obsEntry"/>
                </dependent>
              </rule>
              <rule>
                <name value="setmeta"/>
                <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="setprofile"/>
                  <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-laboratory-vgm"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="setcode"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <variable value="code"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="CodeableConcept"/>
                  </parameter>
                </target>
                <rule>
                  <name value="setcoding"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="code"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <variable value="coding"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Coding"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="setcodesystem"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="http://loinc.org"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodevalue"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="30428-7"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodedisplay"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="display"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString
                                     value="Volume globulaire moyen [Volume d'entité] Érythrocytes ; Numérique"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
              <rule>
                <name value="setvalue"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="value"/>
                  <variable value="val"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%ans.value.ofType(Quantity)"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="fL"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="unit"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="fL"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://unitsofmeasure.org"/>
                  </parameter>
                </target>
              </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="fL"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="fL"/>
                      </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="fL"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="fL"/>
                      </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>
        </rule>
        <rule>
          <name value="extractplat"/>
          <source>
            <context value="hemoGroup"/>
            <element value="item"/>
            <variable value="platItem"/>
            <condition value="linkId = '794156787471'"/>
          </source>
          <rule>
            <name value="obsentry"/>
            <source>
              <context value="platItem"/>
              <element value="answer"/>
              <variable 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="createcommon"/>
                <source>
                  <context value="ans"/>
                </source>
                <dependent>
                  <name value="CreateLabObservationCommon"/>
                  <variable value="ans"/>
                  <variable value="patient"/>
                  <variable value="obs"/>
                  <variable value="obsEntry"/>
                </dependent>
              </rule>
              <rule>
                <name value="setmeta"/>
                <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="setprofile"/>
                  <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-laboratory-plaquettes"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="setcode"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <variable value="code"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="CodeableConcept"/>
                  </parameter>
                </target>
                <rule>
                  <name value="setcoding"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="code"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <variable value="coding"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Coding"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="setcodesystem"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="http://loinc.org"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodevalue"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="777-3"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodedisplay"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="display"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString
                                     value="Plaquettes [Nombre/Volume] Sang ; Numérique ; Comptage automate"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
              <rule>
                <name value="setvalue"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="value"/>
                  <variable value="val"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%ans.value.ofType(Quantity)"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="10*3/uL"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="unit"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="10*3/uL"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://unitsofmeasure.org"/>
                  </parameter>
                </target>
              </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="10*3/uL"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="10*3/uL"/>
                      </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="10*3/uL"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="10*3/uL"/>
                      </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>
        </rule>
        <rule>
          <name value="extractneut"/>
          <source>
            <context value="hemoGroup"/>
            <element value="item"/>
            <variable value="neutItem"/>
            <condition value="linkId = '961905168477'"/>
          </source>
          <rule>
            <name value="obsentry"/>
            <source>
              <context value="neutItem"/>
              <element value="answer"/>
              <variable 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="createcommon"/>
                <source>
                  <context value="ans"/>
                </source>
                <dependent>
                  <name value="CreateLabObservationCommon"/>
                  <variable value="ans"/>
                  <variable value="patient"/>
                  <variable value="obs"/>
                  <variable value="obsEntry"/>
                </dependent>
              </rule>
              <rule>
                <name value="setmeta"/>
                <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="setprofile"/>
                  <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-laboratory-neutrophiles"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="setcode"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <variable value="code"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="CodeableConcept"/>
                  </parameter>
                </target>
                <rule>
                  <name value="setcoding"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="code"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <variable value="coding"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Coding"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="setcodesystem"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="http://loinc.org"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodevalue"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="26499-4"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodedisplay"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="display"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString
                                     value="Polynucléaires neutrophiles [Nombre/Volume] Sang ; Numérique"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
              <rule>
                <name value="setvalue"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="value"/>
                  <variable value="val"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%ans.value.ofType(Quantity)"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="10*3/uL"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="unit"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="10*3/uL"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://unitsofmeasure.org"/>
                  </parameter>
                </target>
              </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="10*3/uL"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="10*3/uL"/>
                      </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="10*3/uL"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="10*3/uL"/>
                      </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>
        </rule>
        <rule>
          <name value="extractlymph"/>
          <source>
            <context value="hemoGroup"/>
            <element value="item"/>
            <variable value="lymphItem"/>
            <condition value="linkId = '695150914696'"/>
          </source>
          <rule>
            <name value="obsentry"/>
            <source>
              <context value="lymphItem"/>
              <element value="answer"/>
              <variable 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="createcommon"/>
                <source>
                  <context value="ans"/>
                </source>
                <dependent>
                  <name value="CreateLabObservationCommon"/>
                  <variable value="ans"/>
                  <variable value="patient"/>
                  <variable value="obs"/>
                  <variable value="obsEntry"/>
                </dependent>
              </rule>
              <rule>
                <name value="setmeta"/>
                <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="setprofile"/>
                  <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-laboratory-lymphocytes"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="setcode"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <variable value="code"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="CodeableConcept"/>
                  </parameter>
                </target>
                <rule>
                  <name value="setcoding"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="code"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <variable value="coding"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Coding"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="setcodesystem"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="http://loinc.org"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodevalue"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="26474-7"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodedisplay"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="display"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString
                                     value="Lymphocytes totaux [Nombre/Volume] Sang ; Numérique"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
              <rule>
                <name value="setvalue"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="value"/>
                  <variable value="val"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%ans.value.ofType(Quantity)"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="10*3/uL"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="unit"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="10*3/uL"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://unitsofmeasure.org"/>
                  </parameter>
                </target>
              </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="10*3/uL"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="10*3/uL"/>
                      </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="10*3/uL"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="10*3/uL"/>
                      </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>
        </rule>
        <rule>
          <name value="extracteosi"/>
          <source>
            <context value="hemoGroup"/>
            <element value="item"/>
            <variable value="eosiItem"/>
            <condition value="linkId = '700490326748'"/>
          </source>
          <rule>
            <name value="obsentry"/>
            <source>
              <context value="eosiItem"/>
              <element value="answer"/>
              <variable 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="createcommon"/>
                <source>
                  <context value="ans"/>
                </source>
                <dependent>
                  <name value="CreateLabObservationCommon"/>
                  <variable value="ans"/>
                  <variable value="patient"/>
                  <variable value="obs"/>
                  <variable value="obsEntry"/>
                </dependent>
              </rule>
              <rule>
                <name value="setmeta"/>
                <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="setprofile"/>
                  <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-laboratory-eosinophiles"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="setcode"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <variable value="code"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="CodeableConcept"/>
                  </parameter>
                </target>
                <rule>
                  <name value="setcoding"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="code"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <variable value="coding"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Coding"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="setcodesystem"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="http://loinc.org"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodevalue"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="26449-9"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodedisplay"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="display"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString
                                     value="Polynucléaires éosinophiles [Nombre/Volume] Sang ; Numérique"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
              <rule>
                <name value="setvalue"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="value"/>
                  <variable value="val"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%ans.value.ofType(Quantity)"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="10*3/uL"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="unit"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="10*3/uL"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://unitsofmeasure.org"/>
                  </parameter>
                </target>
              </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="10*3/uL"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="10*3/uL"/>
                      </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="10*3/uL"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="10*3/uL"/>
                      </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>
        </rule>
        <rule>
          <name value="extractmono"/>
          <source>
            <context value="hemoGroup"/>
            <element value="item"/>
            <variable value="monoItem"/>
            <condition value="linkId = '168661900522'"/>
          </source>
          <rule>
            <name value="obsentry"/>
            <source>
              <context value="monoItem"/>
              <element value="answer"/>
              <variable 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="createcommon"/>
                <source>
                  <context value="ans"/>
                </source>
                <dependent>
                  <name value="CreateLabObservationCommon"/>
                  <variable value="ans"/>
                  <variable value="patient"/>
                  <variable value="obs"/>
                  <variable value="obsEntry"/>
                </dependent>
              </rule>
              <rule>
                <name value="setmeta"/>
                <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="setprofile"/>
                  <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-laboratory-monocytes"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="setcode"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <variable value="code"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="CodeableConcept"/>
                  </parameter>
                </target>
                <rule>
                  <name value="setcoding"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="code"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <variable value="coding"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Coding"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="setcodesystem"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="http://loinc.org"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodevalue"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="26484-6"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodedisplay"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="display"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString
                                     value="Monocytes [Nombre/Volume] Sang ; Numérique"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
              <rule>
                <name value="setvalue"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="value"/>
                  <variable value="val"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%ans.value.ofType(Quantity)"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="10*3/uL"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="unit"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="10*3/uL"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://unitsofmeasure.org"/>
                  </parameter>
                </target>
              </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="10*3/uL"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="10*3/uL"/>
                      </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="10*3/uL"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="10*3/uL"/>
                      </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>
        </rule>
        <rule>
          <name value="extracttp"/>
          <source>
            <context value="hemoGroup"/>
            <element value="item"/>
            <variable value="tpItem"/>
            <condition value="linkId = '658898841893'"/>
          </source>
          <rule>
            <name value="obsentry"/>
            <source>
              <context value="tpItem"/>
              <element value="answer"/>
              <variable 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="createcommon"/>
                <source>
                  <context value="ans"/>
                </source>
                <dependent>
                  <name value="CreateLabObservationCommon"/>
                  <variable value="ans"/>
                  <variable value="patient"/>
                  <variable value="obs"/>
                  <variable value="obsEntry"/>
                </dependent>
              </rule>
              <rule>
                <name value="setmeta"/>
                <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="setprofile"/>
                  <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-laboratory-tp"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="setcode"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <variable value="code"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="CodeableConcept"/>
                  </parameter>
                </target>
                <rule>
                  <name value="setcoding"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="code"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <variable value="coding"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Coding"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="setcodesystem"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="http://loinc.org"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodevalue"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="5894-1"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodedisplay"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="display"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString
                                     value="Temps de quick Patient (%) [Temps relatif] Plasma pauvre en plaquettes ; Numérique ; Coagulation"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
              <rule>
                <name value="setvalue"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="value"/>
                  <variable value="val"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%ans.value.ofType(Quantity)"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="%"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="unit"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="%"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://unitsofmeasure.org"/>
                  </parameter>
                </target>
              </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="%"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="%"/>
                      </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="%"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="%"/>
                      </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>
        </rule>
        <rule>
          <name value="extracttca"/>
          <source>
            <context value="hemoGroup"/>
            <element value="item"/>
            <variable value="tcaItem"/>
            <condition value="linkId = '795145096241'"/>
          </source>
          <rule>
            <name value="obsentry"/>
            <source>
              <context value="tcaItem"/>
              <element value="answer"/>
              <variable 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="createcommon"/>
                <source>
                  <context value="ans"/>
                </source>
                <dependent>
                  <name value="CreateLabObservationCommon"/>
                  <variable value="ans"/>
                  <variable value="patient"/>
                  <variable value="obs"/>
                  <variable value="obsEntry"/>
                </dependent>
              </rule>
              <rule>
                <name value="setmeta"/>
                <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="setprofile"/>
                  <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-laboratory-generic"/>
                    </parameter>
                  </target>
                </rule>
              </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.value.ofType(string)"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="setvalue"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="value"/>
                  <variable value="val"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%ans.value.ofType(Quantity)"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%ans.value.ofType(Quantity).unit"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://unitsofmeasure.org"/>
                  </parameter>
                </target>
              </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="evaluate"/>
                      <parameter>
                        <valueString
                                     value="%ans.value.ofType(Quantity).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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="evaluate"/>
                      <parameter>
                        <valueString
                                     value="%ans.value.ofType(Quantity).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>
        </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="obsentry"/>
            <source>
              <context value="asatItem"/>
              <element value="answer"/>
              <variable 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="createcommon"/>
                <source>
                  <context value="ans"/>
                </source>
                <dependent>
                  <name value="CreateLabObservationCommon"/>
                  <variable value="ans"/>
                  <variable value="patient"/>
                  <variable value="obs"/>
                  <variable value="obsEntry"/>
                </dependent>
              </rule>
              <rule>
                <name value="setmeta"/>
                <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="setprofile"/>
                  <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-laboratory-asat"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="setcode"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <variable value="code"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="CodeableConcept"/>
                  </parameter>
                </target>
                <rule>
                  <name value="setcoding"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="code"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <variable value="coding"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Coding"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="setcodesystem"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="http://loinc.org"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodevalue"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="30239-8"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodedisplay"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="display"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString
                                     value="Aspartate aminotransférase [Catalytique/Volume] Sérum/Plasma ; Numérique ; Avec phosphate de pyridoxal"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
              <rule>
                <name value="setvalue"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="value"/>
                  <variable value="val"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%ans.value.ofType(Quantity)"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="[IU]/L"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="unit"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="[IU]/L"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://unitsofmeasure.org"/>
                  </parameter>
                </target>
              </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="[IU]/L"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="[IU]/L"/>
                      </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="[IU]/L"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="[IU]/L"/>
                      </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>
        </rule>
        <rule>
          <name value="extractalat"/>
          <source>
            <context value="liverGroup"/>
            <element value="item"/>
            <variable value="alatItem"/>
            <condition value="linkId = '876439410327'"/>
          </source>
          <rule>
            <name value="obsentry"/>
            <source>
              <context value="alatItem"/>
              <element value="answer"/>
              <variable 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="createcommon"/>
                <source>
                  <context value="ans"/>
                </source>
                <dependent>
                  <name value="CreateLabObservationCommon"/>
                  <variable value="ans"/>
                  <variable value="patient"/>
                  <variable value="obs"/>
                  <variable value="obsEntry"/>
                </dependent>
              </rule>
              <rule>
                <name value="setmeta"/>
                <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="setprofile"/>
                  <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-laboratory-alat"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="setcode"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <variable value="code"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="CodeableConcept"/>
                  </parameter>
                </target>
                <rule>
                  <name value="setcoding"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="code"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <variable value="coding"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Coding"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="setcodesystem"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="http://loinc.org"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodevalue"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="1743-4"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodedisplay"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="display"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString
                                     value="Alanine aminotransférase [Catalytique/Volume] Sérum/Plasma ; Numérique ; Avec phosphate de pyridoxal"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
              <rule>
                <name value="setvalue"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="value"/>
                  <variable value="val"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%ans.value.ofType(Quantity)"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="[IU]/L"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="unit"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="[IU]/L"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://unitsofmeasure.org"/>
                  </parameter>
                </target>
              </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="[IU]/L"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="[IU]/L"/>
                      </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="[IU]/L"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="[IU]/L"/>
                      </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>
        </rule>
        <rule>
          <name value="extractggt"/>
          <source>
            <context value="liverGroup"/>
            <element value="item"/>
            <variable value="ggtItem"/>
            <condition value="linkId = '287545455976'"/>
          </source>
          <rule>
            <name value="obsentry"/>
            <source>
              <context value="ggtItem"/>
              <element value="answer"/>
              <variable 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="createcommon"/>
                <source>
                  <context value="ans"/>
                </source>
                <dependent>
                  <name value="CreateLabObservationCommon"/>
                  <variable value="ans"/>
                  <variable value="patient"/>
                  <variable value="obs"/>
                  <variable value="obsEntry"/>
                </dependent>
              </rule>
              <rule>
                <name value="setmeta"/>
                <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="setprofile"/>
                  <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-laboratory-ggt"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="setcode"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <variable value="code"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="CodeableConcept"/>
                  </parameter>
                </target>
                <rule>
                  <name value="setcoding"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="code"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <variable value="coding"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Coding"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="setcodesystem"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="http://loinc.org"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodevalue"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="2324-2"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodedisplay"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="display"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString
                                     value="Gamma glutamyltransférase [Catalytique/Volume] Sérum/Plasma ; Numérique"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
              <rule>
                <name value="setvalue"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="value"/>
                  <variable value="val"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%ans.value.ofType(Quantity)"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="U/L"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="unit"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="U/L"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://unitsofmeasure.org"/>
                  </parameter>
                </target>
              </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="U/L"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="U/L"/>
                      </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="U/L"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="U/L"/>
                      </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>
        </rule>
        <rule>
          <name value="extractpal"/>
          <source>
            <context value="liverGroup"/>
            <element value="item"/>
            <variable value="palItem"/>
            <condition value="linkId = '508269571594'"/>
          </source>
          <rule>
            <name value="obsentry"/>
            <source>
              <context value="palItem"/>
              <element value="answer"/>
              <variable 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="createcommon"/>
                <source>
                  <context value="ans"/>
                </source>
                <dependent>
                  <name value="CreateLabObservationCommon"/>
                  <variable value="ans"/>
                  <variable value="patient"/>
                  <variable value="obs"/>
                  <variable value="obsEntry"/>
                </dependent>
              </rule>
              <rule>
                <name value="setmeta"/>
                <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="setprofile"/>
                  <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-laboratory-pal"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="setcode"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <variable value="code"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="CodeableConcept"/>
                  </parameter>
                </target>
                <rule>
                  <name value="setcoding"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="code"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <variable value="coding"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Coding"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="setcodesystem"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="http://loinc.org"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodevalue"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="6768-6"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodedisplay"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="display"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString
                                     value="Phosphatases alcalines [Catalytique/Volume] Sérum/Plasma ; Numérique"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
              <rule>
                <name value="setvalue"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="value"/>
                  <variable value="val"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%ans.value.ofType(Quantity)"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="U/L"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="unit"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="U/L"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://unitsofmeasure.org"/>
                  </parameter>
                </target>
              </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="U/L"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="U/L"/>
                      </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="U/L"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="U/L"/>
                      </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>
        </rule>
        <rule>
          <name value="extractbiltot"/>
          <source>
            <context value="liverGroup"/>
            <element value="item"/>
            <variable value="bilTotItem"/>
            <condition value="linkId = '927344090061'"/>
          </source>
          <rule>
            <name value="obsentry"/>
            <source>
              <context value="bilTotItem"/>
              <element value="answer"/>
              <variable 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="createcommon"/>
                <source>
                  <context value="ans"/>
                </source>
                <dependent>
                  <name value="CreateLabObservationCommon"/>
                  <variable value="ans"/>
                  <variable value="patient"/>
                  <variable value="obs"/>
                  <variable value="obsEntry"/>
                </dependent>
              </rule>
              <rule>
                <name value="setmeta"/>
                <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="setprofile"/>
                  <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-laboratory-bilirubine-totale"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="setcode"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <variable value="code"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="CodeableConcept"/>
                  </parameter>
                </target>
                <rule>
                  <name value="setcoding"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="code"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <variable value="coding"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Coding"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="setcodesystem"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="http://loinc.org"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodevalue"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="14631-6"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodedisplay"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="display"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString
                                     value="Bilirubine [Moles/Volume] Sérum/Plasma ; Numérique"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
              <rule>
                <name value="setvalue"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="value"/>
                  <variable value="val"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%ans.value.ofType(Quantity)"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="umol/L"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="unit"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="umol/L"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://unitsofmeasure.org"/>
                  </parameter>
                </target>
              </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="umol/L"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="umol/L"/>
                      </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="umol/L"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="umol/L"/>
                      </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>
        </rule>
        <rule>
          <name value="extractbilconj"/>
          <source>
            <context value="liverGroup"/>
            <element value="item"/>
            <variable value="bilConjItem"/>
            <condition value="linkId = '208196328453'"/>
          </source>
          <rule>
            <name value="obsentry"/>
            <source>
              <context value="bilConjItem"/>
              <element value="answer"/>
              <variable 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="createcommon"/>
                <source>
                  <context value="ans"/>
                </source>
                <dependent>
                  <name value="CreateLabObservationCommon"/>
                  <variable value="ans"/>
                  <variable value="patient"/>
                  <variable value="obs"/>
                  <variable value="obsEntry"/>
                </dependent>
              </rule>
              <rule>
                <name value="setmeta"/>
                <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="setprofile"/>
                  <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-laboratory-bilirubine-conjuguee"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="setcode"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <variable value="code"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="CodeableConcept"/>
                  </parameter>
                </target>
                <rule>
                  <name value="setcoding"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="code"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <variable value="coding"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Coding"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="setcodesystem"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="http://loinc.org"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodevalue"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="29760-6"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodedisplay"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="display"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString
                                     value="Bilirubine conjuguée [Moles/Volume] Sérum/Plasma ; Numérique"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
              <rule>
                <name value="setvalue"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="value"/>
                  <variable value="val"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%ans.value.ofType(Quantity)"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="umol/L"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="unit"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="umol/L"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://unitsofmeasure.org"/>
                  </parameter>
                </target>
              </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="umol/L"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="umol/L"/>
                      </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="umol/L"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="umol/L"/>
                      </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>
        </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="obsentry"/>
            <source>
              <context value="glycItem"/>
              <element value="answer"/>
              <variable 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="createcommon"/>
                <source>
                  <context value="ans"/>
                </source>
                <dependent>
                  <name value="CreateLabObservationCommon"/>
                  <variable value="ans"/>
                  <variable value="patient"/>
                  <variable value="obs"/>
                  <variable value="obsEntry"/>
                </dependent>
              </rule>
              <rule>
                <name value="setmeta"/>
                <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="setprofile"/>
                  <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-laboratory-glycemie-a-jeun"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="setcode"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <variable value="code"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="CodeableConcept"/>
                  </parameter>
                </target>
                <rule>
                  <name value="setcoding"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="code"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <variable value="coding"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Coding"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="setcodesystem"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="http://loinc.org"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodevalue"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="14749-6"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodedisplay"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="display"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString
                                     value="Glucose [Moles/Volume] Sérum/Plasma ; Numérique"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
              <rule>
                <name value="setvalue"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="value"/>
                  <variable value="val"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%ans.value.ofType(Quantity)"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="mmol/L"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="unit"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="mmol/L"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://unitsofmeasure.org"/>
                  </parameter>
                </target>
              </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="mmol/L"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="mmol/L"/>
                      </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="mmol/L"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="mmol/L"/>
                      </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>
        </rule>
        <rule>
          <name value="extracthba1c"/>
          <source>
            <context value="glucoseGroup"/>
            <element value="item"/>
            <variable value="hba1cItem"/>
            <condition value="linkId = '632894677152'"/>
          </source>
          <rule>
            <name value="obsentry"/>
            <source>
              <context value="hba1cItem"/>
              <element value="answer"/>
              <variable 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="createcommon"/>
                <source>
                  <context value="ans"/>
                </source>
                <dependent>
                  <name value="CreateLabObservationCommon"/>
                  <variable value="ans"/>
                  <variable value="patient"/>
                  <variable value="obs"/>
                  <variable value="obsEntry"/>
                </dependent>
              </rule>
              <rule>
                <name value="setmeta"/>
                <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="setprofile"/>
                  <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-laboratory-hba1c"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="setcode"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <variable value="code"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="CodeableConcept"/>
                  </parameter>
                </target>
                <rule>
                  <name value="setcoding"/>
                  <source>
                    <context value="ans"/>
                  </source>
                  <target>
                    <context value="code"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <variable value="coding"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Coding"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="setcodesystem"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="http://loinc.org"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodevalue"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="4548-4"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="setcodedisplay"/>
                    <source>
                      <context value="ans"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="display"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString
                                     value="Hémoglobine A1c/hémoglobine totale [Fraction massique] Sang ; Numérique"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
              <rule>
                <name value="setvalue"/>
                <source>
                  <context value="ans"/>
                </source>
                <target>
                  <context value="obs"/>
                  <contextType value="variable"/>
                  <element value="value"/>
                  <variable value="val"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="%ans.value.ofType(Quantity)"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="%"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="unit"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="%"/>
                  </parameter>
                </target>
                <target>
                  <context value="val"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://unitsofmeasure.org"/>
                  </parameter>
                </target>
              </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="%"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtLow"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="%"/>
                      </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.value.ofType(Quantity)"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="%"/>
                      </parameter>
                    </target>
                    <target>
                      <context value="tgtHigh"/>
                      <contextType value="variable"/>
                      <element value="unit"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="%"/>
                      </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>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="CreateLabObservationCommon"/>
    <typeMode value="none"/>
    <documentation
                   value="Helper: fields common to every simple lab Observation (id/fullUrl, status, category, subject,
value, effective, referenceRange). meta.profile and code are call-site responsibilities --
a literal `source` group parameter is rejected by Matchbox even when unused (see issue #10),
so each call site sets those two fields itself via trailing rules against the `obs`/`obsEntry`
target parameters this group is handed, rather than passing them in as data."/>
    <input>
      <name value="ans"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="obs"/>
      <type value="Observation"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="obsEntry"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="extractobsid"/>
      <source>
        <context value="ans"/>
        <element value="item"/>
        <variable value="labIdItem"/>
        <condition value="text = 'Identifiant'"/>
      </source>
      <rule>
        <name value="setobsid"/>
        <source>
          <context value="labIdItem"/>
          <element value="answer"/>
          <variable value="labIdAns"/>
        </source>
        <target>
          <context value="obs"/>
          <contextType value="variable"/>
          <element value="id"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="%labIdAns.value.ofType(string)"/>
          </parameter>
        </target>
      </rule>
    </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="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="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.value.ofType(dateTime)"/>
          </parameter>
        </target>
      </rule>
    </rule>
  </group>
</StructureMap>