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

Données socles des Entrepôts de Données de Santé Hospitalier - version de développement local (intégration continue v0.1.0) construite par les outils de publication FHIR (HL7® FHIR® Standard). Voir le répertoire des versions publiées

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

Draft as of 2026-05-28

Raw json | Download

    {
      "resourceType" : "StructureMap",
      "id" : "Q2FSL",
      "text" : {
        "status" : "generated",
        "div" : "<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\">\r\n<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;\r\n\r\n</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>\r\n\r\n<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>\r\n<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>\r\n\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">Main entry point: Transform QuestionnaireResponse to Bundle</span>\r\n<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\"> {\r\n</span>  <span style=\"color: navy\">// </span><span style=\"color: green\">Initialize Bundle</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>bundle.id = <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span> <i>&quot;bundleid&quot;</i><span style=\"color: navy\">;</span>\r\n  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>\r\n  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>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Create Patient resource</span>\r\n  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\"> {\r\n</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\"> {\r\n</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>\r\n      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>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Create Locations from geocoding data</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">src then CreateLocations(src, patient, bundle) &quot;create-locations&quot;;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Create Encounters from PMSI data</span>\r\n      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>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Create Laboratory Observations</span>\r\n      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>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Create Medication Requests</span>\r\n      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>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Create Medication Administrations</span>\r\n      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>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Create Vital Sign Observations</span>\r\n      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>\r\n    <span style=\"color: navy\">}</span> <i>&quot;createpatientresource&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;patiententry&quot;</i><span style=\"color: navy\">;</span>\r\n<span style=\"color: navy\">}\r\n\r\n</span><span style=\"color: navy\">// </span><span style=\"color: green\">Group: Create Patient from QuestionnaireResponse</span>\r\n<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\"> {\r\n</span>  src<span style=\"color: navy\"><b> -&gt; </b></span>patient.id = <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span> <i>&quot;patientid&quot;</i><span style=\"color: navy\">;</span>\r\n  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\"> {\r\n</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>\r\n  <span style=\"color: navy\">}</span> <i>&quot;patientmeta&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Extract patient identity data from linkId 4647259356106 &gt; 2958000860428</span>\r\n  src.item<b> as </b><span style=\"color: maroon\">socioDemo</span><b> where </b>(linkId = '4647259356106')<b> then</b><span style=\"color: navy\"> {\r\n</span>    socioDemo.item<b> as </b><span style=\"color: maroon\">identity</span><b> where </b>(linkId = '2958000860428')<b> then</b><span style=\"color: navy\"> {\r\n</span>      <span style=\"color: navy\">// </span><span style=\"color: green\">Patient name (linkId 8605698058770 = family, 6214879623503 = given)</span>\r\n      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\"> {\r\n</span>        identity.item<b> as </b><span style=\"color: maroon\">familyItem</span><b> where </b>(linkId = '8605698058770')<b> then</b><span style=\"color: navy\"> {\r\n</span>          familyItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>name.family = <span style=\"color: navy\">(</span>%ans.valueString<span style=\"color: navy\">)</span> <i>&quot;setfamily&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;extractfamily&quot;</i><span style=\"color: navy\">;</span>\r\n        identity.item<b> as </b><span style=\"color: maroon\">givenItem</span><b> where </b>(linkId = '6214879623503')<b> then</b><span style=\"color: navy\"> {\r\n</span>          givenItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>name.given = <span style=\"color: navy\">(</span>%ans.valueString<span style=\"color: navy\">)</span> <i>&quot;setgiven&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;extractgiven&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;setname&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">NIR identifier (linkId 5711960356160)</span>\r\n      identity.item<b> as </b><span style=\"color: maroon\">nirItem</span><b> where </b>(linkId = '5711960356160')<b> then</b><span style=\"color: navy\"> {\r\n</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\"> {\r\n</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>\r\n          ans<span style=\"color: navy\"><b> -&gt; </b></span>nir.value = <span style=\"color: navy\">(</span>%ans.valueString<span style=\"color: navy\">)</span> <i>&quot;nirvalue&quot;</i><span style=\"color: navy\">;</span>\r\n          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>\r\n        <span style=\"color: navy\">}</span> <i>&quot;setnir&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractnir&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">INS identifier (linkId 3764723550987)</span>\r\n      identity.item<b> as </b><span style=\"color: maroon\">insItem</span><b> where </b>(linkId = '3764723550987')<b> then</b><span style=\"color: navy\"> {\r\n</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\"> {\r\n</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>\r\n          ans<span style=\"color: navy\"><b> -&gt; </b></span>ins.value = <span style=\"color: navy\">(</span>%ans.valueString<span style=\"color: navy\">)</span> <i>&quot;insvalue&quot;</i><span style=\"color: navy\">;</span>\r\n          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>\r\n        <span style=\"color: navy\">}</span> <i>&quot;setins&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractins&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Birth date (linkId 5036133558154)</span>\r\n      identity.item<b> as </b><span style=\"color: maroon\">birthItem</span><b> where </b>(linkId = '5036133558154')<b> then</b><span style=\"color: navy\"> {\r\n</span>        birthItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>patient.birthDate = <span style=\"color: navy\">(</span>%ans.valueDate<span style=\"color: navy\">)</span> <i>&quot;setbirthdate&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractbirthdate&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Death date (linkId 5633552097315)</span>\r\n      identity.item<b> as </b><span style=\"color: maroon\">deathItem</span><b> where </b>(linkId = '5633552097315')<b> then</b><span style=\"color: navy\"> {\r\n</span>        deathItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>patient.deceased = <span style=\"color: navy\">(</span>%ans.valueDate<span style=\"color: navy\">)</span> <i>&quot;setdeceaseddate&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">// </span><span style=\"color: green\">Death source (linkId 9098810065693)</span>\r\n        deathItem.item<b> as </b><span style=\"color: maroon\">deathSource</span><b> where </b>(linkId = '9098810065693')<b> then</b><span style=\"color: navy\"> {\r\n</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\"> {\r\n</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>\r\n            sourceAns<span style=\"color: navy\"><b> -&gt; </b></span>ext.value = <span style=\"color: navy\">(</span>%sourceAns.valueCoding<span style=\"color: navy\">)</span> <i>&quot;deathsourcevalue&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;setdeathsourceext&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;extractdeathsource&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractdeath&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Multiple birth rank (linkId 6931296968515)</span>\r\n      identity.item<b> as </b><span style=\"color: maroon\">multipleItem</span><b> where </b>(linkId = '6931296968515')<b> then</b><span style=\"color: navy\"> {\r\n</span>        multipleItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>patient.multipleBirth = <span style=\"color: navy\">(</span>%ans.valueInteger<span style=\"color: navy\">)</span> <i>&quot;setmultiplebirth&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractmultiplebirth&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;processidentity&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">// </span><span style=\"color: green\">Gender from PMSI data (linkId 3894630481120 within 2825244231605)</span>\r\n    src.item<b> as </b><span style=\"color: maroon\">pmsiGroup</span><b> where </b>(linkId = '2825244231605')<b> then</b><span style=\"color: navy\"> {\r\n</span>      pmsiGroup.item<b> as </b><span style=\"color: maroon\">sexItem</span><b> where </b>(linkId = '3894630481120')<b> then</b><span style=\"color: navy\"> {\r\n</span>        sexItem.answer<b> as </b><span style=\"color: maroon\">ans</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          ans.valueString<b> as </b><span style=\"color: maroon\">female</span><b> where </b>($this = 'f')<span style=\"color: navy\"><b> -&gt; </b></span>patient.gender = <span style=\"color: blue\">'female'</span> <i>&quot;setGenderF&quot;</i><span style=\"color: navy\">;</span>\r\n          ans.valueString<b> as </b><span style=\"color: maroon\">female</span><b> where </b>($this = 'm')<span style=\"color: navy\"><b> -&gt; </b></span>patient.gender = <span style=\"color: blue\">'male'</span> <i>&quot;setGenderM&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;valueCoding&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractgender&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Address from code géographique (linkId 2446369196222)</span>\r\n      pmsiGroup.item<b> as </b><span style=\"color: maroon\">codeGeoItem</span><b> where </b>(linkId = '2446369196222')<b> then</b><span style=\"color: navy\"> {\r\n</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\"> {\r\n</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\"> {\r\n</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>\r\n            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>\r\n          <span style=\"color: navy\">}</span> <i>&quot;setcodegeoext&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">// </span><span style=\"color: green\">Environnement</span>\r\n          socioDemo.item<b> as </b><span style=\"color: maroon\">environnementItem</span><b> where </b>(linkId = '5491974639955')<b> then</b><span style=\"color: navy\"> {\r\n</span>            <span style=\"color: navy\">// </span><span style=\"color: green\">geolocation</span>\r\n            environnementItem.item<b> as </b><span style=\"color: maroon\">geocodageItem</span><b> where </b>(linkId = '3816475533472')<span style=\"color: navy\"><b> -&gt; </b></span>addr.extension = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Extension'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">geolocationExt</span><b> then</b><span style=\"color: navy\"> {\r\n</span>              geocodageItem.item<b> as </b><span style=\"color: maroon\">latItem</span><b> where </b>(linkId = '3709843054556')<span style=\"color: navy\"><b> -&gt; </b></span> geolocationExt.url = <span style=\"color: blue\">'http://hl7.org/fhir/StructureDefinition/geolocation'</span><span style=\"color: navy\">, </span> geolocationExt.extension = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Extension'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">latExt</span><b> then</b><span style=\"color: navy\"> {\r\n</span>                latItem.answer<b> as </b><span style=\"color: maroon\">lat</span><span style=\"color: navy\"><b> -&gt; </b></span> latExt.url = <span style=\"color: blue\">'latitude'</span><span style=\"color: navy\">, </span> latExt.value = <span style=\"color: navy\">(</span>%lat.valueDecimal<span style=\"color: navy\">)</span><b> then</b><span style=\"color: navy\"> {\r\n</span>                  geocodageItem.item<b> as </b><span style=\"color: maroon\">longItem</span><b> where </b>(linkId = '7651448032665')<span style=\"color: navy\"><b> -&gt; </b></span>geolocationExt.extension = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Extension'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">longExt</span><b> then</b><span style=\"color: navy\"> {\r\n</span>                    longItem.answer<b> as </b><span style=\"color: maroon\">long</span><span style=\"color: navy\"><b> -&gt; </b></span> longExt.url = <span style=\"color: blue\">'longitude'</span><span style=\"color: navy\">, </span> longExt.value = <span style=\"color: navy\">(</span>%long.valueDecimal<span style=\"color: navy\">)</span> <i>&quot;setLong&quot;</i><span style=\"color: navy\">;</span>\r\n                  <span style=\"color: navy\">}</span> <i>&quot;createLongExt&quot;</i><span style=\"color: navy\">;</span>\r\n                <span style=\"color: navy\">}</span> <i>&quot;setLat&quot;</i><span style=\"color: navy\">;</span>\r\n              <span style=\"color: navy\">}</span> <i>&quot;createLatExt&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">}</span> <i>&quot;createGeolocExt&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">// </span><span style=\"color: green\">IRIS</span>\r\n            environnementItem.item<b> as </b><span style=\"color: maroon\">irisItem</span><b> where </b>(linkId = '7621032273792')<span style=\"color: navy\"><b> -&gt; </b></span> addr.line<b> as </b><span style=\"color: maroon\">addrLine</span><span style=\"color: navy\">, </span> addrLine.extension = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Extension'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">irisExt</span><b> then</b><span style=\"color: navy\"> {\r\n</span>              irisItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span> irisExt.url = <span style=\"color: blue\">'http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-censusTract'</span><span style=\"color: navy\">, </span> irisExt.valueString = <span style=\"color: navy\">(</span>%ans.valueString<span style=\"color: navy\">)</span> <i>&quot;setIrisExt&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">}</span> <i>&quot;navIrisItem&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;navEnv&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;setaddress&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractcodegeo&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;extractpmsidemographics&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;processsociodemographics&quot;</i><span style=\"color: navy\">;</span>\r\n<span style=\"color: navy\">}\r\n\r\n</span><span style=\"color: navy\">// </span><span style=\"color: green\">Group: Create Locations from geocoding and IRIS data</span>\r\n<b>group </b>CreateLocations<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">src</span><span style=\"color: navy\"> : </span>QuestionnaireResponse, <b>target</b> <span style=\"color: maroon\">patient</span><span style=\"color: navy\"> : </span>Patient, <b>target</b> <span style=\"color: maroon\">bundle</span><span style=\"color: navy\"> : </span>Bundle<span style=\"color: navy\">)</span><span style=\"color: navy\"> {\r\n</span>  <span style=\"color: navy\">// </span><span style=\"color: green\">Extract geocoding data from linkId 4647259356106 &gt; 5491974639955 &gt; 3816475533472</span>\r\n  src.item<b> as </b><span style=\"color: maroon\">socioDemo</span><b> where </b>(linkId = '4647259356106')<b> then</b><span style=\"color: navy\"> {\r\n</span>    socioDemo.item<b> as </b><span style=\"color: maroon\">environment</span><b> where </b>(linkId = '5491974639955')<b> then</b><span style=\"color: navy\"> {\r\n</span>      <span style=\"color: navy\">// </span><span style=\"color: green\">Geocoding locations (repeating group 3816475533472)</span>\r\n      environment.item<b> as </b><span style=\"color: maroon\">geocodingItem</span><b> where </b>(linkId = '3816475533472')<span style=\"color: navy\"><b> -&gt; </b></span>bundle.entry<b> as </b><span style=\"color: maroon\">locationEntry</span><b> then</b><span style=\"color: navy\"> {\r\n</span>        geocodingItem<span style=\"color: navy\"><b> -&gt; </b></span>locationEntry.resource = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Location'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">location</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          geocodingItem<span style=\"color: navy\"><b> -&gt; </b></span>location.id = <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span> <i>&quot;locationid&quot;</i><span style=\"color: navy\">;</span>\r\n          geocodingItem<span style=\"color: navy\"><b> -&gt; </b></span>location.meta = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Meta'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">meta</span><b> then</b><span style=\"color: navy\"> {\r\n</span>            geocodingItem<span style=\"color: navy\"><b> -&gt; </b></span>meta.profile = <span style=\"color: blue\">'https://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-location'</span> <i>&quot;locationprofile&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;locationmeta&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">// </span><span style=\"color: green\">Position with latitude and longitude</span>\r\n          geocodingItem<span style=\"color: navy\"><b> -&gt; </b></span>location.position = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'LocationPosition'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">pos</span><b> then</b><span style=\"color: navy\"> {\r\n</span>            <span style=\"color: navy\">// </span><span style=\"color: green\">Latitude (linkId 3709843054556)</span>\r\n            geocodingItem.item<b> as </b><span style=\"color: maroon\">latItem</span><b> where </b>(linkId = '3709843054556')<b> then</b><span style=\"color: navy\"> {\r\n</span>              latItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>pos.latitude = <span style=\"color: navy\">(</span>%ans.valueDecimal<span style=\"color: navy\">)</span> <i>&quot;setlatitude&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">}</span> <i>&quot;extractlatitude&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">// </span><span style=\"color: green\">Longitude (linkId 7651448032665)</span>\r\n            geocodingItem.item<b> as </b><span style=\"color: maroon\">longItem</span><b> where </b>(linkId = '7651448032665')<b> then</b><span style=\"color: navy\"> {\r\n</span>              longItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>pos.longitude = <span style=\"color: navy\">(</span>%ans.valueDecimal<span style=\"color: navy\">)</span> <i>&quot;setlongitude&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">}</span> <i>&quot;extractlongitude&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;setposition&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">// </span><span style=\"color: green\">Extension for collection date (linkId 1185653257776)</span>\r\n          <span style=\"color: navy\">// </span><span style=\"color: green\">geocodingItem.item as dateItem where (linkId = '1185653257776') then {             dateItem.answer as ans -&gt; location.extension = create('Extension') as ext then {               ans -&gt; ext.url = 'http://hl7.org/fhir/StructureDefinition/data-collection-date' &quot;date-url&quot;;               ans -&gt; ext.value = (%ans.valueDate) &quot;date-value&quot;;             } &quot;set-collection-date&quot;;           } &quot;extract-collection-date&quot;;</span>\r\n          location<span style=\"color: navy\"><b> -&gt; </b></span>locationEntry.request<b> as </b><span style=\"color: maroon\">request</span><b> then</b><span style=\"color: navy\"> {\r\n</span>            location<span style=\"color: navy\"><b> -&gt; </b></span>request.method = <span style=\"color: blue\">'POST'</span> <i>&quot;setmethod&quot;</i><span style=\"color: navy\">;</span>\r\n            location<span style=\"color: navy\"><b> -&gt; </b></span>request.url = <span style=\"color: blue\">'Location'</span> <i>&quot;seturl&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;setrequest&quot;</i><span style=\"color: navy\">;</span>\r\n          location.id<b> as </b><span style=\"color: maroon\">locId</span><span style=\"color: navy\"><b> -&gt; </b></span>locationEntry.fullUrl = <b>append</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'urn:uuid:'</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">locId</span><span style=\"color: navy\">)</span> <i>&quot;setfullUrl&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;createlocation&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;geocodinglocationentry&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">IRIS locations (repeating item 7621032273792)</span>\r\n      environment.item<b> as </b><span style=\"color: maroon\">irisItem</span><b> where </b>(linkId = '7621032273792')<b> then</b><span style=\"color: navy\"> {\r\n</span>        irisItem.answer<b> as </b><span style=\"color: maroon\">irisAnswer</span><span style=\"color: navy\"><b> -&gt; </b></span>bundle.entry<b> as </b><span style=\"color: maroon\">locationEntry</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          irisAnswer<span style=\"color: navy\"><b> -&gt; </b></span>locationEntry.resource = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Location'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">location</span><b> then</b><span style=\"color: navy\"> {\r\n</span>            irisAnswer<span style=\"color: navy\"><b> -&gt; </b></span>location.id = <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span> <i>&quot;locationid&quot;</i><span style=\"color: navy\">;</span>\r\n            irisAnswer<span style=\"color: navy\"><b> -&gt; </b></span>location.meta = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Meta'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">meta</span><b> then</b><span style=\"color: navy\"> {\r\n</span>              irisAnswer<span style=\"color: navy\"><b> -&gt; </b></span>meta.profile = <span style=\"color: blue\">'https://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-location'</span> <i>&quot;locationprofile&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">}</span> <i>&quot;locationmeta&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">// </span><span style=\"color: green\">IRIS code as identifier</span>\r\n            irisAnswer<span style=\"color: navy\"><b> -&gt; </b></span>location.identifier = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Identifier'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">identifier</span><b> then</b><span style=\"color: navy\"> {\r\n</span>              irisAnswer<span style=\"color: navy\"><b> -&gt; </b></span>identifier.system = <span style=\"color: blue\">'urn:oid:2.16.840.1.113883.2.8.1.5.5'</span> <i>&quot;irissystem&quot;</i><span style=\"color: navy\">;</span>\r\n              irisAnswer<span style=\"color: navy\"><b> -&gt; </b></span>identifier.value = <span style=\"color: navy\">(</span>%irisAnswer.valueCoding.code<span style=\"color: navy\">)</span> <i>&quot;irisvalue&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">}</span> <i>&quot;setirisidentifier&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">// </span><span style=\"color: green\">Collection date from nested item (linkId 4999580038872)</span>\r\n            <span style=\"color: navy\">// </span><span style=\"color: green\">irisAnswer.item as dateItem where (linkId = '4999580038872') then {               dateItem.answer as ans -&gt; location.extension = create('Extension') as ext then {                 ans -&gt; ext.url = 'http://hl7.org/fhir/StructureDefinition/data-collection-date' &quot;date-url&quot;;                 ans -&gt; ext.value = (%ans.valueDate) &quot;date-value&quot;;               } &quot;set-collection-date&quot;;             } &quot;extract-iris-date&quot;;</span>\r\n            location<span style=\"color: navy\"><b> -&gt; </b></span>locationEntry.request<b> as </b><span style=\"color: maroon\">request</span><b> then</b><span style=\"color: navy\"> {\r\n</span>              location<span style=\"color: navy\"><b> -&gt; </b></span>request.method = <span style=\"color: blue\">'POST'</span> <i>&quot;setmethod&quot;</i><span style=\"color: navy\">;</span>\r\n              location<span style=\"color: navy\"><b> -&gt; </b></span>request.url = <span style=\"color: blue\">'Location'</span> <i>&quot;seturl&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">}</span> <i>&quot;setrequest&quot;</i><span style=\"color: navy\">;</span>\r\n            location.id<b> as </b><span style=\"color: maroon\">locId</span><span style=\"color: navy\"><b> -&gt; </b></span>locationEntry.fullUrl = <b>append</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'urn:uuid:'</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">locId</span><span style=\"color: navy\">)</span> <i>&quot;setfullUrl&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;createirislocation&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;irislocationentry&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;processiris&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;processenvironment&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;processsociodemographicslocation&quot;</i><span style=\"color: navy\">;</span>\r\n<span style=\"color: navy\">}\r\n\r\n</span><span style=\"color: navy\">// </span><span style=\"color: green\">Group: Create Encounters from PMSI data</span>\r\n<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\"> {\r\n</span>  <span style=\"color: navy\">// </span><span style=\"color: green\">PMSI data group (linkId 2825244231605) - Note: This can repeat in the structure</span>\r\n  src.item<b> as </b><span style=\"color: maroon\">pmsiItem</span><b> where </b>(linkId = '2825244231605')<span style=\"color: navy\"><b> -&gt; </b></span>bundle.entry<b> as </b><span style=\"color: maroon\">encounterEntry</span><b> then</b><span style=\"color: navy\"> {\r\n</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\"> {\r\n</span>      pmsiItem<span style=\"color: navy\"><b> -&gt; </b></span>encounter.id = <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span> <i>&quot;encounterid&quot;</i><span style=\"color: navy\">;</span>\r\n      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\"> {\r\n</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>\r\n      <span style=\"color: navy\">}</span> <i>&quot;encountermeta&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">status</span>\r\n      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>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">class</span>\r\n      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>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Link to patient</span>\r\n      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>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Encounter period (start: 5991443718282, end: 6114780320846)</span>\r\n      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\"> {\r\n</span>        pmsiItem.item<b> as </b><span style=\"color: maroon\">startItem</span><b> where </b>(linkId = '5991443718282')<b> then</b><span style=\"color: navy\"> {\r\n</span>          startItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>period.start = <span style=\"color: navy\">(</span>%ans.valueDate<span style=\"color: navy\">)</span> <i>&quot;setstart&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;extractstart&quot;</i><span style=\"color: navy\">;</span>\r\n        pmsiItem.item<b> as </b><span style=\"color: maroon\">endItem</span><b> where </b>(linkId = '6114780320846')<b> then</b><span style=\"color: navy\"> {\r\n</span>          endItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>period.end = <span style=\"color: navy\">(</span>%ans.valueDate<span style=\"color: navy\">)</span> <i>&quot;setend&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;extractend&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;setperiod&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Mode d'entrée (linkId 6172398101212)</span>\r\n      pmsiItem.item<b> as </b><span style=\"color: maroon\">modeInItem</span><b> where </b>(linkId = '6172398101212')<b> then</b><span style=\"color: navy\"> {\r\n</span>        modeInItem.answer<b> as </b><span style=\"color: maroon\">ans</span><b> then</b><span style=\"color: navy\"> {\r\n</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>\r\n        <span style=\"color: navy\">}</span> <i>&quot;navValue&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractmodein&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Mode de sortie (linkId 3354867075704)</span>\r\n      pmsiItem.item<b> as </b><span style=\"color: maroon\">modeOutItem</span><b> where </b>(linkId = '3354867075704')<b> then</b><span style=\"color: navy\"> {\r\n</span>        modeOutItem.answer<b> as </b><span style=\"color: maroon\">ans</span><b> then</b><span style=\"color: navy\"> {\r\n</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>\r\n        <span style=\"color: navy\">}</span> <i>&quot;navValue&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractmodeout&quot;</i><span style=\"color: navy\">;</span>\r\n      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>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Create nested Conditions and Procedures</span>\r\n      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>\r\n      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>\r\n    <span style=\"color: navy\">}</span> <i>&quot;createencounter&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;encounterentry&quot;</i><span style=\"color: navy\">;</span>\r\n<span style=\"color: navy\">}\r\n\r\n</span><span style=\"color: navy\">// </span><span style=\"color: green\">Group: Create Conditions from nested diagnostics</span>\r\n<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\"> {\r\n</span>  <span style=\"color: navy\">// </span><span style=\"color: green\">Diagnostics group (linkId 9391816419630) - can repeat</span>\r\n  pmsiItem.item<b> as </b><span style=\"color: maroon\">diagGroup</span><b> where </b>(linkId = '9391816419630')<span style=\"color: navy\"><b> -&gt; </b></span>bundle.entry<b> as </b><span style=\"color: maroon\">conditionEntry</span><b> then</b><span style=\"color: navy\"> {\r\n</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\"> {\r\n</span>      diagGroup<span style=\"color: navy\"><b> -&gt; </b></span>condition.id = <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span> <i>&quot;conditionid&quot;</i><span style=\"color: navy\">;</span>\r\n      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\"> {\r\n</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>\r\n      <span style=\"color: navy\">}</span> <i>&quot;conditionmeta&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Link to patient</span>\r\n      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>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Link to encounter</span>\r\n      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>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Diagnostic code (linkId 5505101189372) - CIM-10</span>\r\n      diagGroup.item<b> as </b><span style=\"color: maroon\">diagCodeItem</span><b> where </b>(linkId = '5505101189372')<b> then</b><span style=\"color: navy\"> {\r\n</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\"> {\r\n</span>          ans<span style=\"color: navy\"><b> -&gt; </b></span> code.coding<b> as </b><span style=\"color: maroon\">coding</span><span style=\"color: navy\">, </span> coding.code = <span style=\"color: navy\">(</span>%ans.valueString<span style=\"color: navy\">)</span> <i>&quot;setcoding&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;setcode&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractdiagcode&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Type de diagnostic (linkId 6427586743735) - DP/DAS/DR</span>\r\n      diagGroup.item<b> as </b><span style=\"color: maroon\">diagTypeItem</span><b> where </b>(linkId = '6427586743735')<b> then</b><span style=\"color: navy\"> {\r\n</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\"> {\r\n</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\"> {\r\n</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>\r\n            ans<span style=\"color: navy\"><b> -&gt; </b></span>coding.code = <span style=\"color: navy\">(</span>%ans.valueString<span style=\"color: navy\">)</span> <i>&quot;diagtypecode&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;setcategorycoding&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;setcategory&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractdiagtype&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Recorded date (linkId 7114466839467)</span>\r\n      diagGroup.item<b> as </b><span style=\"color: maroon\">dateItem</span><b> where </b>(linkId = '7114466839467')<b> then</b><span style=\"color: navy\"> {\r\n</span>        dateItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>condition.recordedDate = <span style=\"color: navy\">(</span>%ans.valueDate<span style=\"color: navy\">)</span> <i>&quot;setrecordeddate&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractrecordeddate&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">fullurl</span>\r\n      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>\r\n    <span style=\"color: navy\">}</span> <i>&quot;createcondition&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;conditionentry&quot;</i><span style=\"color: navy\">;</span>\r\n<span style=\"color: navy\">}\r\n\r\n</span><span style=\"color: navy\">// </span><span style=\"color: green\">Group: Create Procedures from nested actes</span>\r\n<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\"> {\r\n</span>  <span style=\"color: navy\">// </span><span style=\"color: green\">Actes group (linkId 591926901726) - can repeat</span>\r\n  pmsiItem.item<b> as </b><span style=\"color: maroon\">acteGroup</span><b> where </b>(linkId = '591926901726')<span style=\"color: navy\"><b> -&gt; </b></span>bundle.entry<b> as </b><span style=\"color: maroon\">procedureEntry</span><b> then</b><span style=\"color: navy\"> {\r\n</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\"> {\r\n</span>      acteGroup<span style=\"color: navy\"><b> -&gt; </b></span>procedure.id = <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span> <i>&quot;procedureid&quot;</i><span style=\"color: navy\">;</span>\r\n      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\"> {\r\n</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>\r\n      <span style=\"color: navy\">}</span> <i>&quot;proceduremeta&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">status</span>\r\n      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>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Link to patient</span>\r\n      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>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Link to encounter</span>\r\n      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>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Acte code (linkId 7758110033600) - CCAM</span>\r\n      acteGroup.item<b> as </b><span style=\"color: maroon\">acteCodeItem</span><b> where </b>(linkId = '7758110033600')<b> then</b><span style=\"color: navy\"> {\r\n</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\"> {\r\n</span>          ans<span style=\"color: navy\"><b> -&gt; </b></span> code.coding<b> as </b><span style=\"color: maroon\">coding</span><span style=\"color: navy\">, </span> coding.code = <span style=\"color: navy\">(</span>%ans.valueString<span style=\"color: navy\">)</span> <i>&quot;setcoding&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;setcode&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractactecode&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Date de l'acte (linkId 5066866286682)</span>\r\n      acteGroup.item<b> as </b><span style=\"color: maroon\">dateItem</span><b> where </b>(linkId = '5066866286682')<b> then</b><span style=\"color: navy\"> {\r\n</span>        dateItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>procedure.performed = <span style=\"color: navy\">(</span>%ans.valueDateTime<span style=\"color: navy\">)</span> <i>&quot;setperformed&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractperformeddate&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">fullurl</span>\r\n      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>\r\n    <span style=\"color: navy\">}</span> <i>&quot;createprocedure&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;procedureentry&quot;</i><span style=\"color: navy\">;</span>\r\n<span style=\"color: navy\">}\r\n\r\n</span><span style=\"color: navy\">// </span><span style=\"color: green\">Group: Create Medication Requests</span>\r\n<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\"> {\r\n</span>  <span style=\"color: navy\">// </span><span style=\"color: green\">Exposition médicamenteuse (linkId 817801935685)</span>\r\n  src.item<b> as </b><span style=\"color: maroon\">medExpoGroup</span><b> where </b>(linkId = '817801935685')<b> then</b><span style=\"color: navy\"> {\r\n</span>    <span style=\"color: navy\">// </span><span style=\"color: green\">Médicament prescrit (linkId 156631794800) - repeating</span>\r\n    medExpoGroup.item<b> as </b><span style=\"color: maroon\">prescribedGroup</span><b> where </b>(linkId = '156631794800')<span style=\"color: navy\"><b> -&gt; </b></span>bundle.entry<b> as </b><span style=\"color: maroon\">medReqEntry</span><b> then</b><span style=\"color: navy\"> {\r\n</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\"> {\r\n</span>        prescribedGroup<span style=\"color: navy\"><b> -&gt; </b></span>medReq.id = <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span> <i>&quot;medreqid&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">// </span><span style=\"color: green\">fullurl</span>\r\n        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>\r\n        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\"> {\r\n</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>\r\n        <span style=\"color: navy\">}</span> <i>&quot;medreqmeta&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">// </span><span style=\"color: green\">Link to patient</span>\r\n        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>\r\n        <span style=\"color: navy\">// </span><span style=\"color: green\">Status and intent</span>\r\n        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>\r\n        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>\r\n        <span style=\"color: navy\">// </span><span style=\"color: green\">MedicationCodeableConcept</span>\r\n        prescribedGroup.answer<b> as </b><span style=\"color: maroon\">prescribedMedication</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          prescribedMedication.item<b> as </b><span style=\"color: maroon\">atcItem</span><b> where </b>(linkId = '1923143398283')<b> then</b><span style=\"color: navy\"> {\r\n</span>            atcItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span> medReq.medication = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'CodeableConcept'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">medReqCC</span><span style=\"color: navy\">, </span> medReqCC.coding<b> as </b><span style=\"color: maroon\">medReqC</span><span style=\"color: navy\">, </span> medReqC.code = <span style=\"color: navy\">(</span>%ans.valueString<span style=\"color: navy\">)</span><span style=\"color: navy\">, </span> medReqC.display = <span style=\"color: navy\">(</span>%prescribedMedication.valueString<span style=\"color: navy\">)</span> <i>&quot;setAtcCoding&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;navAtcItem&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;navPrescribedMedication&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">// </span><span style=\"color: green\">Create Medication resource and reference</span>\r\n        <span style=\"color: navy\">// </span><span style=\"color: green\">prescribedGroup -&gt; bundle.entry as medEntry then {           prescribedGroup -&gt; medEntry.resource = create('Medication') as medication then {             prescribedGroup -&gt; medication.id = uuid() &quot;med-id&quot;;              // ATC code from nested items             prescribedGroup.item as atcItem where (linkId.contains('ATC')) then {               atcItem.answer as ans -&gt; medication.code = create('CodeableConcept') as code then {                 ans -&gt; code.coding = (%ans.valueCoding) &quot;set-atc-coding&quot;;               } &quot;set-med-code&quot;;             } &quot;extract-atc&quot;;              prescribedGroup -&gt; medication.id as medId, medEntry.fullUrl = append('urn:uuid:', medId) &quot;set-fullUrl&quot;;              // Link MedicationRequest to Medication             prescribedGroup -&gt; medication.id as medId, medReq.medication = create('Reference') as ref, ref.reference = append('Medication/', medId) &quot;set-medication-reference&quot;;            } &quot;create-medication&quot;;         } &quot;medication-entry&quot;;</span>\r\n        <span style=\"color: navy\">// </span><span style=\"color: green\">Dosage instructions</span>\r\n        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\"> {\r\n</span>          <span style=\"color: navy\">// </span><span style=\"color: green\">Route</span>\r\n          prescribedGroup.answer<b> as </b><span style=\"color: maroon\">prescribedMedication</span><b> then</b><span style=\"color: navy\"> {\r\n</span>            prescribedMedication.item<b> as </b><span style=\"color: maroon\">routeItem</span><b> where </b>(linkId = '387026794874')<b> then</b><span style=\"color: navy\"> {\r\n</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\"> {\r\n</span>                ans<span style=\"color: navy\"><b> -&gt; </b></span> route.coding<b> as </b><span style=\"color: maroon\">routeCoding</span><span style=\"color: navy\">, </span> routeCoding.code = <span style=\"color: navy\">(</span>%ans.valueString<span style=\"color: navy\">)</span> <i>&quot;setroutecoding&quot;</i><span style=\"color: navy\">;</span>\r\n              <span style=\"color: navy\">}</span> <i>&quot;setroute&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">}</span> <i>&quot;navRouteItem&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;navPrescribedMedication&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">// </span><span style=\"color: green\">Timing</span>\r\n          medExpoGroup.item<b> as </b><span style=\"color: maroon\">posoGroup</span><b> where </b>(linkId = '6348237104421')<span style=\"color: navy\"><b> -&gt; </b></span> dosage.timing<b> as </b><span style=\"color: maroon\">timing</span><span style=\"color: navy\">, </span> timing.repeat<b> as </b><span style=\"color: maroon\">timingRepeat</span><span style=\"color: navy\">, </span> timingRepeat.boundsPeriod<b> as </b><span style=\"color: maroon\">timingPeriod</span><b> then</b><span style=\"color: navy\"> {\r\n</span>            posoGroup.item<b> as </b><span style=\"color: maroon\">DateDebItem</span><b> where </b>(linkId = '316347573327')<b> then</b><span style=\"color: navy\"> {\r\n</span>              DateDebItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>timingPeriod.start = <span style=\"color: navy\">(</span>%ans.valueDate<span style=\"color: navy\">)</span> <i>&quot;setDateDeb&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">}</span> <i>&quot;navDateDeb&quot;</i><span style=\"color: navy\">;</span>\r\n            posoGroup.item<b> as </b><span style=\"color: maroon\">DateFinItem</span><b> where </b>(linkId = '429570775935')<b> then</b><span style=\"color: navy\"> {\r\n</span>              DateFinItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>timingPeriod.end = <span style=\"color: navy\">(</span>%ans.valueDate<span style=\"color: navy\">)</span> <i>&quot;setDateFin&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">}</span> <i>&quot;navDateFin&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;navPoso&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;setdosage&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;createmedreq&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;medreqentry&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;processmedexpo&quot;</i><span style=\"color: navy\">;</span>\r\n<span style=\"color: navy\">}\r\n\r\n</span><span style=\"color: navy\">// </span><span style=\"color: green\">Group: Create Medication Administrations</span>\r\n<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\"> {\r\n</span>  <span style=\"color: navy\">// </span><span style=\"color: green\">Exposition médicamenteuse (linkId 817801935685)</span>\r\n  src.item<b> as </b><span style=\"color: maroon\">medExpoGroup</span><b> where </b>(linkId = '817801935685')<b> then</b><span style=\"color: navy\"> {\r\n</span>    <span style=\"color: navy\">// </span><span style=\"color: green\">Médicament administré (linkId 266852453304) - repeating</span>\r\n    medExpoGroup.item<b> as </b><span style=\"color: maroon\">adminGroup</span><b> where </b>(linkId = '266852453304')<span style=\"color: navy\"><b> -&gt; </b></span>bundle.entry<b> as </b><span style=\"color: maroon\">medAdminEntry</span><b> then</b><span style=\"color: navy\"> {\r\n</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\"> {\r\n</span>        adminGroup<span style=\"color: navy\"><b> -&gt; </b></span>medAdmin.id = <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span> <i>&quot;medadminid&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">// </span><span style=\"color: green\">fullurl</span>\r\n        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>\r\n        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\"> {\r\n</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>\r\n        <span style=\"color: navy\">}</span> <i>&quot;medadminmeta&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">// </span><span style=\"color: green\">Link to patient</span>\r\n        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>\r\n        <span style=\"color: navy\">// </span><span style=\"color: green\">Status</span>\r\n        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>\r\n        <span style=\"color: navy\">// </span><span style=\"color: green\">MedicationCodeableConcept</span>\r\n        adminGroup.answer<b> as </b><span style=\"color: maroon\">administeredMedication</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          administeredMedication.item<b> as </b><span style=\"color: maroon\">atcItem</span><b> where </b>(linkId = '631972144976')<b> then</b><span style=\"color: navy\"> {\r\n</span>            atcItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span> medAdmin.medication = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'CodeableConcept'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">medAdminCC</span><span style=\"color: navy\">, </span> medAdminCC.coding<b> as </b><span style=\"color: maroon\">medAdminC</span><span style=\"color: navy\">, </span> medAdminC.code = <span style=\"color: navy\">(</span>%ans.valueString<span style=\"color: navy\">)</span><span style=\"color: navy\">, </span> medAdminC.display = <span style=\"color: navy\">(</span>%administeredMedication.valueString<span style=\"color: navy\">)</span> <i>&quot;setAtcCoding&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;navAtcItem&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;navadministeredMedication&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">// </span><span style=\"color: green\">Create Medication resource and reference</span>\r\n        <span style=\"color: navy\">// </span><span style=\"color: green\">adminGroup -&gt; bundle.entry as medEntry then {           adminGroup -&gt; medEntry.resource = create('Medication') as medication then {             adminGroup -&gt; medication.id = uuid() &quot;med-id&quot;;              // ATC code from nested items             adminGroup.item as atcItem where (linkId.contains('ATC')) then {               atcItem.answer as ans -&gt; medication.code = create('CodeableConcept') as code then {                 ans -&gt; code.coding = (%ans.valueCoding) &quot;set-atc-coding&quot;;               } &quot;set-med-code&quot;;             } &quot;extract-atc&quot;;              adminGroup -&gt; medication.id as medId, medEntry.fullUrl = append('Medication/', medId) &quot;set-fullUrl&quot;;              // Link MedicationAdministration to Medication             adminGroup -&gt; medication.id as medId, medAdmin.medication = create('Reference') as ref, ref.reference = append('urn:uuid:', medId) &quot;set-medication-reference&quot;;            } &quot;create-medication&quot;;         } &quot;medication-entry&quot;;</span>\r\n        <span style=\"color: navy\">// </span><span style=\"color: green\">Dosage (FHIR)</span>\r\n        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\"> {\r\n</span>          <span style=\"color: navy\">// </span><span style=\"color: green\">Route</span>\r\n          adminGroup.answer<b> as </b><span style=\"color: maroon\">administeredMedication</span><b> then</b><span style=\"color: navy\"> {\r\n</span>            administeredMedication.item<b> as </b><span style=\"color: maroon\">routeItem</span><b> where </b>(linkId = '811931484859')<b> then</b><span style=\"color: navy\"> {\r\n</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\"> {\r\n</span>                ans<span style=\"color: navy\"><b> -&gt; </b></span> route.coding<b> as </b><span style=\"color: maroon\">routeCoding</span><span style=\"color: navy\">, </span> routeCoding.code = <span style=\"color: navy\">(</span>%ans.valueString<span style=\"color: navy\">)</span> <i>&quot;setroutecoding&quot;</i><span style=\"color: navy\">;</span>\r\n              <span style=\"color: navy\">}</span> <i>&quot;setroute&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">}</span> <i>&quot;navRoute&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;navadministeredMedication&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">// </span><span style=\"color: green\">Dosage (QR)</span>\r\n          medExpoGroup.item<b> as </b><span style=\"color: maroon\">doseGroup</span><b> where </b>(linkId = '5720103839343')<b> then</b><span style=\"color: navy\"> {\r\n</span>            <span style=\"color: navy\">// </span><span style=\"color: green\">Dose</span>\r\n            doseGroup.item<b> as </b><span style=\"color: maroon\">quantityItem</span><b> where </b>(linkId = '4765772671997')<b> then</b><span style=\"color: navy\"> {\r\n</span>              quantityItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>dosage.dose = <span style=\"color: navy\">(</span>%ans.valueQuantity<span style=\"color: navy\">)</span> <i>&quot;setDose&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">}</span> <i>&quot;navquantity&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">// </span><span style=\"color: green\">Effective period</span>\r\n            doseGroup.item<b> as </b><span style=\"color: maroon\">startItem</span><b> where </b>(linkId = '1443558617577')<b> then</b><span style=\"color: navy\"> {\r\n</span>              startItem.answer<b> as </b><span style=\"color: maroon\">startAns</span><b> then</b><span style=\"color: navy\"> {\r\n</span>                doseGroup.item<b> as </b><span style=\"color: maroon\">endItem</span><b> where </b>(linkId = '780829110731')<b> then</b><span style=\"color: navy\"> {\r\n</span>                  endItem.answer<b> as </b><span style=\"color: maroon\">endAns</span><span style=\"color: navy\"><b> -&gt; </b></span> medAdmin.effectivePeriod<b> as </b><span style=\"color: maroon\">adminPeriod</span><span style=\"color: navy\">, </span> adminPeriod.start = <span style=\"color: navy\">(</span>%startAns.value<span style=\"color: navy\">)</span><span style=\"color: navy\">, </span> adminPeriod.end = <span style=\"color: navy\">(</span>%endAns.value<span style=\"color: navy\">)</span> <i>&quot;setAdminPeriod&quot;</i><span style=\"color: navy\">;</span>\r\n                <span style=\"color: navy\">}</span> <i>&quot;navEnd&quot;</i><span style=\"color: navy\">;</span>\r\n              <span style=\"color: navy\">}</span> <i>&quot;navStartAns&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">}</span> <i>&quot;navStart&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;navDosage&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;setdosage&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;createmedadmin&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;medadminentry&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;processmedexpoadmin&quot;</i><span style=\"color: navy\">;</span>\r\n<span style=\"color: navy\">}\r\n\r\n</span><span style=\"color: navy\">// </span><span style=\"color: green\">Group: Create Vital Sign Observations</span>\r\n<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\"> {\r\n</span>  <span style=\"color: navy\">// </span><span style=\"color: green\">Examen clinique (linkId 214880328197)</span>\r\n  src.item<b> as </b><span style=\"color: maroon\">examGroup</span><b> where </b>(linkId = '214880328197')<b> then</b><span style=\"color: navy\"> {\r\n</span>    <span style=\"color: navy\">// </span><span style=\"color: green\">Dossier de soins (linkId 305831246173) - repeating</span>\r\n    examGroup.item<b> as </b><span style=\"color: maroon\">dossierGroup</span><b> where </b>(linkId = '305831246173')<b> then</b><span style=\"color: navy\"> {\r\n</span>      <span style=\"color: navy\">// </span><span style=\"color: green\">Height (linkId 4846902346416)</span>\r\n      dossierGroup.item<b> as </b><span style=\"color: maroon\">heightItem</span><b> where </b>(linkId = '4846902346416')<b> then</b><span style=\"color: navy\"> {\r\n</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\"> {\r\n</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\"> {\r\n</span>            ans<span style=\"color: navy\"><b> -&gt; </b></span>obs.id = <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span> <i>&quot;obsid&quot;</i><span style=\"color: navy\">;</span>\r\n            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>\r\n            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\"> {\r\n</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>\r\n            <span style=\"color: navy\">}</span> <i>&quot;obsmeta&quot;</i><span style=\"color: navy\">;</span>\r\n            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>\r\n            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>\r\n            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>\r\n            <span style=\"color: navy\">// </span><span style=\"color: green\">Link to patient</span>\r\n            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>\r\n            <span style=\"color: navy\">// </span><span style=\"color: green\">Value</span>\r\n            ans<span style=\"color: navy\"><b> -&gt; </b></span> obs.value = <span style=\"color: navy\">(</span>%ans.valueQuantity<span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">tgtObsVal</span><span style=\"color: navy\">, </span> tgtObsVal.code = <span style=\"color: navy\">(</span>%ans.valueQuantity.unit<span style=\"color: navy\">)</span><span style=\"color: navy\">, </span> tgtObsVal.system = <span style=\"color: blue\">'http://unitsofmeasure.org'</span> <i>&quot;setvalue&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">// </span><span style=\"color: green\">Effective date from nested item</span>\r\n            ans.item<b> as </b><span style=\"color: maroon\">dateItem</span><b> where </b>(linkId = '941821315470')<b> then</b><span style=\"color: navy\"> {\r\n</span>              dateItem.answer<b> as </b><span style=\"color: maroon\">dateAns</span><b> then</b><span style=\"color: navy\"> {\r\n</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>\r\n              <span style=\"color: navy\">}</span> <i>&quot;navDateAns&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">}</span> <i>&quot;extracteffective&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;createheightobs&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;heightobsentry&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractheight&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Weight (linkId 451513217936)</span>\r\n      dossierGroup.item<b> as </b><span style=\"color: maroon\">weightItem</span><b> where </b>(linkId = '451513217936')<b> then</b><span style=\"color: navy\"> {\r\n</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\"> {\r\n</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\"> {\r\n</span>            ans<span style=\"color: navy\"><b> -&gt; </b></span>obs.id = <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span> <i>&quot;obsid&quot;</i><span style=\"color: navy\">;</span>\r\n            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>\r\n            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\"> {\r\n</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>\r\n            <span style=\"color: navy\">}</span> <i>&quot;obsmeta&quot;</i><span style=\"color: navy\">;</span>\r\n            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>\r\n            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>\r\n            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>\r\n            <span style=\"color: navy\">// </span><span style=\"color: green\">Link to patient</span>\r\n            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>\r\n            <span style=\"color: navy\">// </span><span style=\"color: green\">Value</span>\r\n            ans<span style=\"color: navy\"><b> -&gt; </b></span> obs.value = <span style=\"color: navy\">(</span>%ans.valueQuantity<span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">tgtObsVal</span><span style=\"color: navy\">, </span> tgtObsVal.code = <span style=\"color: navy\">(</span>%ans.valueQuantity.unit<span style=\"color: navy\">)</span><span style=\"color: navy\">, </span> tgtObsVal.system = <span style=\"color: blue\">'http://unitsofmeasure.org'</span> <i>&quot;setvalue&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">// </span><span style=\"color: green\">Effective date from nested item</span>\r\n            ans.item<b> as </b><span style=\"color: maroon\">dateItem</span><b> where </b>(linkId = '151269044052')<b> then</b><span style=\"color: navy\"> {\r\n</span>              dateItem.answer<b> as </b><span style=\"color: maroon\">dateAns</span><b> then</b><span style=\"color: navy\"> {\r\n</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>\r\n              <span style=\"color: navy\">}</span> <i>&quot;navDateAns&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">}</span> <i>&quot;extracteffective&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;createweightobs&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;weightobsentry&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractweight&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Blood Pressure - need both systolic and diastolic</span>\r\n      dossierGroup.item<b> as </b><span style=\"color: maroon\">sysItem</span><b> where </b>(linkId = '4160905247955')<b> then</b><span style=\"color: navy\"> {\r\n</span>        sysItem.answer<b> as </b><span style=\"color: maroon\">sysAns</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          dossierGroup.item<b> as </b><span style=\"color: maroon\">diaItem</span><b> where </b>(linkId = '848797127998')<b> then</b><span style=\"color: navy\"> {\r\n</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\"> {\r\n</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\"> {\r\n</span>                sysAns<span style=\"color: navy\"><b> -&gt; </b></span>obs.id = <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span> <i>&quot;obsid&quot;</i><span style=\"color: navy\">;</span>\r\n                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>\r\n                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\"> {\r\n</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>\r\n                <span style=\"color: navy\">}</span> <i>&quot;obsmeta&quot;</i><span style=\"color: navy\">;</span>\r\n                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>\r\n                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>\r\n                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>\r\n                <span style=\"color: navy\">// </span><span style=\"color: green\">Link to patient</span>\r\n                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>\r\n                <span style=\"color: navy\">// </span><span style=\"color: green\">Systolic component</span>\r\n                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\"> {\r\n</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>\r\n                  sysAns<span style=\"color: navy\"><b> -&gt; </b></span> sysComp.value = <span style=\"color: navy\">(</span>%sysAns.valueQuantity<span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">sysVal</span><span style=\"color: navy\">, </span> sysVal.code = <span style=\"color: navy\">(</span>%sysAns.valueQuantity.unit<span style=\"color: navy\">)</span><span style=\"color: navy\">, </span> sysVal.system = <span style=\"color: blue\">'http://unitsofmeasure.org'</span> <i>&quot;sysvalue&quot;</i><span style=\"color: navy\">;</span>\r\n                <span style=\"color: navy\">}</span> <i>&quot;setsystolic&quot;</i><span style=\"color: navy\">;</span>\r\n                <span style=\"color: navy\">// </span><span style=\"color: green\">Diastolic component</span>\r\n                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\"> {\r\n</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>\r\n                  diaAns<span style=\"color: navy\"><b> -&gt; </b></span> diaComp.value = <span style=\"color: navy\">(</span>%diaAns.valueQuantity<span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">diaVal</span><span style=\"color: navy\">, </span> diaVal.code = <span style=\"color: navy\">(</span>%diaAns.valueQuantity.unit<span style=\"color: navy\">)</span><span style=\"color: navy\">, </span> diaVal.system = <span style=\"color: blue\">'http://unitsofmeasure.org'</span> <i>&quot;diavalue&quot;</i><span style=\"color: navy\">;</span>\r\n                <span style=\"color: navy\">}</span> <i>&quot;setdiastolic&quot;</i><span style=\"color: navy\">;</span>\r\n                <span style=\"color: navy\">// </span><span style=\"color: green\">Effective date from nested item</span>\r\n                sysAns.item<b> as </b><span style=\"color: maroon\">sysDateItem</span><b> where </b>(linkId = '987654638442')<b> then</b><span style=\"color: navy\"> {\r\n</span>                  sysDateItem.answer<b> as </b><span style=\"color: maroon\">dateAns</span><b> then</b><span style=\"color: navy\"> {\r\n</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>\r\n                  <span style=\"color: navy\">}</span> <i>&quot;navDateAns&quot;</i><span style=\"color: navy\">;</span>\r\n                <span style=\"color: navy\">}</span> <i>&quot;navDate&quot;</i><span style=\"color: navy\">;</span>\r\n              <span style=\"color: navy\">}</span> <i>&quot;createbpobs&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">}</span> <i>&quot;bpobsentr&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;extractdiastolic&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;processsystolic&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractbloodpressure&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;processdossier&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;processexam&quot;</i><span style=\"color: navy\">;</span>\r\n<span style=\"color: navy\">}\r\n\r\n</span><span style=\"color: navy\">// </span><span style=\"color: green\">Group: Create Laboratory Observations</span>\r\n<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\"> {\r\n</span>  <span style=\"color: navy\">// </span><span style=\"color: green\">Biologie group (linkId 7702944131447)</span>\r\n  src.item<b> as </b><span style=\"color: maroon\">bioGroup</span><b> where </b>(linkId = '7702944131447')<b> then</b><span style=\"color: navy\"> {\r\n</span>    <span style=\"color: navy\">// </span><span style=\"color: green\">Fonction rénale (linkId 5241323453538)</span>\r\n    bioGroup.item<b> as </b><span style=\"color: maroon\">renalGroup</span><b> where </b>(linkId = '5241323453538')<b> then</b><span style=\"color: navy\"> {\r\n</span>      <span style=\"color: navy\">// </span><span style=\"color: green\">Urée (linkId 7169026818760)</span>\r\n      renalGroup.item<b> as </b><span style=\"color: maroon\">ureaItem</span><b> where </b>(linkId = '7169026818760')<b> then</b><span style=\"color: navy\"> {\r\n</span>        ureaItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style=\"color: navy\">(</span><span style=\"color: maroon\">ans</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">ureaItem</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">patient</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">bundle</span><span style=\"color: navy\">)</span> <i>&quot;createureaobs&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extracturea&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Créatininémie (linkId 500408205043)</span>\r\n      renalGroup.item<b> as </b><span style=\"color: maroon\">creatItem</span><b> where </b>(linkId = '500408205043')<b> then</b><span style=\"color: navy\"> {\r\n</span>        creatItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style=\"color: navy\">(</span><span style=\"color: maroon\">ans</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">creatItem</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">patient</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">bundle</span><span style=\"color: navy\">)</span> <i>&quot;createcreatobs&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractcreat&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">DFG (linkId 786621340679)</span>\r\n      renalGroup.item<b> as </b><span style=\"color: maroon\">dfgItem</span><b> where </b>(linkId = '786621340679')<b> then</b><span style=\"color: navy\"> {\r\n</span>        dfgItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style=\"color: navy\">(</span><span style=\"color: maroon\">ans</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">dfgItem</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">patient</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">bundle</span><span style=\"color: navy\">)</span> <i>&quot;createdfgobs&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractdfg&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;processrenal&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">// </span><span style=\"color: green\">Hémogramme (linkId 419282985970)</span>\r\n    bioGroup.item<b> as </b><span style=\"color: maroon\">hemoGroup</span><b> where </b>(linkId = '419282985970')<b> then</b><span style=\"color: navy\"> {\r\n</span>      <span style=\"color: navy\">// </span><span style=\"color: green\">Leucocytes (linkId 210077225604)</span>\r\n      hemoGroup.item<b> as </b><span style=\"color: maroon\">leukoItem</span><b> where </b>(linkId = '210077225604')<b> then</b><span style=\"color: navy\"> {\r\n</span>        leukoItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style=\"color: navy\">(</span><span style=\"color: maroon\">ans</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">leukoItem</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">patient</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">bundle</span><span style=\"color: navy\">)</span> <i>&quot;createleukoobs&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractleuko&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Hémoglobine (linkId 304159088493)</span>\r\n      hemoGroup.item<b> as </b><span style=\"color: maroon\">hemoItem</span><b> where </b>(linkId = '304159088493')<b> then</b><span style=\"color: navy\"> {\r\n</span>        hemoItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style=\"color: navy\">(</span><span style=\"color: maroon\">ans</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">hemoItem</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">patient</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">bundle</span><span style=\"color: navy\">)</span> <i>&quot;createhemoobs&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extracthemo&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Hématocrite (linkId 813863316705)</span>\r\n      hemoGroup.item<b> as </b><span style=\"color: maroon\">hematItem</span><b> where </b>(linkId = '813863316705')<b> then</b><span style=\"color: navy\"> {\r\n</span>        hematItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style=\"color: navy\">(</span><span style=\"color: maroon\">ans</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">hematItem</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">patient</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">bundle</span><span style=\"color: navy\">)</span> <i>&quot;createhematobs&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extracthemat&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Erythrocytes (linkId 459731866614)</span>\r\n      hemoGroup.item<b> as </b><span style=\"color: maroon\">eryItem</span><b> where </b>(linkId = '459731866614')<b> then</b><span style=\"color: navy\"> {\r\n</span>        eryItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style=\"color: navy\">(</span><span style=\"color: maroon\">ans</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">eryItem</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">patient</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">bundle</span><span style=\"color: navy\">)</span> <i>&quot;createeryobs&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractery&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">VGM (linkId 163624088831)</span>\r\n      hemoGroup.item<b> as </b><span style=\"color: maroon\">vgmItem</span><b> where </b>(linkId = '163624088831')<b> then</b><span style=\"color: navy\"> {\r\n</span>        vgmItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style=\"color: navy\">(</span><span style=\"color: maroon\">ans</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">vgmItem</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">patient</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">bundle</span><span style=\"color: navy\">)</span> <i>&quot;createvgmobs&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractvgm&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Plaquettes (linkId 794156787471)</span>\r\n      hemoGroup.item<b> as </b><span style=\"color: maroon\">platItem</span><b> where </b>(linkId = '794156787471')<b> then</b><span style=\"color: navy\"> {\r\n</span>        platItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style=\"color: navy\">(</span><span style=\"color: maroon\">ans</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">platItem</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">patient</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">bundle</span><span style=\"color: navy\">)</span> <i>&quot;createplatobs&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractplat&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Neutrophiles (linkId 961905168477)</span>\r\n      hemoGroup.item<b> as </b><span style=\"color: maroon\">neutItem</span><b> where </b>(linkId = '961905168477')<b> then</b><span style=\"color: navy\"> {\r\n</span>        neutItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style=\"color: navy\">(</span><span style=\"color: maroon\">ans</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">neutItem</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">patient</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">bundle</span><span style=\"color: navy\">)</span> <i>&quot;createneutobs&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractneut&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Lymphocytes (linkId 695150914696)</span>\r\n      hemoGroup.item<b> as </b><span style=\"color: maroon\">lymphItem</span><b> where </b>(linkId = '695150914696')<b> then</b><span style=\"color: navy\"> {\r\n</span>        lymphItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style=\"color: navy\">(</span><span style=\"color: maroon\">ans</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">lymphItem</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">patient</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">bundle</span><span style=\"color: navy\">)</span> <i>&quot;createlymphobs&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractlymph&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Eosinophiles (linkId 700490326748)</span>\r\n      hemoGroup.item<b> as </b><span style=\"color: maroon\">eosiItem</span><b> where </b>(linkId = '700490326748')<b> then</b><span style=\"color: navy\"> {\r\n</span>        eosiItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style=\"color: navy\">(</span><span style=\"color: maroon\">ans</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">eosiItem</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">patient</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">bundle</span><span style=\"color: navy\">)</span> <i>&quot;createeosiobs&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extracteosi&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Monocytes (linkId 168661900522)</span>\r\n      hemoGroup.item<b> as </b><span style=\"color: maroon\">monoItem</span><b> where </b>(linkId = '168661900522')<b> then</b><span style=\"color: navy\"> {\r\n</span>        monoItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style=\"color: navy\">(</span><span style=\"color: maroon\">ans</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">monoItem</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">patient</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">bundle</span><span style=\"color: navy\">)</span> <i>&quot;createmonoobs&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractmono&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">TP (linkId 658898841893)</span>\r\n      hemoGroup.item<b> as </b><span style=\"color: maroon\">tpItem</span><b> where </b>(linkId = '658898841893')<b> then</b><span style=\"color: navy\"> {\r\n</span>        tpItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style=\"color: navy\">(</span><span style=\"color: maroon\">ans</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">tpItem</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">patient</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">bundle</span><span style=\"color: navy\">)</span> <i>&quot;createtpobs&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extracttp&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">TCA (linkId 795145096241)</span>\r\n      hemoGroup.item<b> as </b><span style=\"color: maroon\">tcaItem</span><b> where </b>(linkId = '795145096241')<b> then</b><span style=\"color: navy\"> {\r\n</span>        tcaItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style=\"color: navy\">(</span><span style=\"color: maroon\">ans</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">tcaItem</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">patient</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">bundle</span><span style=\"color: navy\">)</span> <i>&quot;createtcaobs&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extracttca&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;processhemo&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">// </span><span style=\"color: green\">Bilan hépatique (linkId 796308115381)</span>\r\n    bioGroup.item<b> as </b><span style=\"color: maroon\">liverGroup</span><b> where </b>(linkId = '796308115381')<b> then</b><span style=\"color: navy\"> {\r\n</span>      <span style=\"color: navy\">// </span><span style=\"color: green\">ASAT (linkId 715226319725)</span>\r\n      liverGroup.item<b> as </b><span style=\"color: maroon\">asatItem</span><b> where </b>(linkId = '715226319725')<b> then</b><span style=\"color: navy\"> {\r\n</span>        asatItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style=\"color: navy\">(</span><span style=\"color: maroon\">ans</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">asatItem</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">patient</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">bundle</span><span style=\"color: navy\">)</span> <i>&quot;createasatobs&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractasat&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">ALAT (linkId 876439410327)</span>\r\n      liverGroup.item<b> as </b><span style=\"color: maroon\">alatItem</span><b> where </b>(linkId = '876439410327')<b> then</b><span style=\"color: navy\"> {\r\n</span>        alatItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style=\"color: navy\">(</span><span style=\"color: maroon\">ans</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">alatItem</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">patient</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">bundle</span><span style=\"color: navy\">)</span> <i>&quot;createalatobs&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractalat&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">GGT (linkId 287545455976)</span>\r\n      liverGroup.item<b> as </b><span style=\"color: maroon\">ggtItem</span><b> where </b>(linkId = '287545455976')<b> then</b><span style=\"color: navy\"> {\r\n</span>        ggtItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style=\"color: navy\">(</span><span style=\"color: maroon\">ans</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">ggtItem</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">patient</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">bundle</span><span style=\"color: navy\">)</span> <i>&quot;createggtobs&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractggt&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">PAL (linkId 508269571594)</span>\r\n      liverGroup.item<b> as </b><span style=\"color: maroon\">palItem</span><b> where </b>(linkId = '508269571594')<b> then</b><span style=\"color: navy\"> {\r\n</span>        palItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style=\"color: navy\">(</span><span style=\"color: maroon\">ans</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">palItem</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">patient</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">bundle</span><span style=\"color: navy\">)</span> <i>&quot;createpalobs&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractpal&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Bilirubine totale (linkId 927344090061)</span>\r\n      liverGroup.item<b> as </b><span style=\"color: maroon\">bilTotItem</span><b> where </b>(linkId = '927344090061')<b> then</b><span style=\"color: navy\"> {\r\n</span>        bilTotItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style=\"color: navy\">(</span><span style=\"color: maroon\">ans</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">bilTotItem</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">patient</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">bundle</span><span style=\"color: navy\">)</span> <i>&quot;createbiltotobs&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractbiltot&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Bilirubine conjuguée (linkId 208196328453)</span>\r\n      liverGroup.item<b> as </b><span style=\"color: maroon\">bilConjItem</span><b> where </b>(linkId = '208196328453')<b> then</b><span style=\"color: navy\"> {\r\n</span>        bilConjItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style=\"color: navy\">(</span><span style=\"color: maroon\">ans</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">bilConjItem</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">patient</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">bundle</span><span style=\"color: navy\">)</span> <i>&quot;createbilconjobs&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractbilconj&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;processliver&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">// </span><span style=\"color: green\">Métabolisme glucidique (linkId 334039497382)</span>\r\n    bioGroup.item<b> as </b><span style=\"color: maroon\">glucoseGroup</span><b> where </b>(linkId = '334039497382')<b> then</b><span style=\"color: navy\"> {\r\n</span>      <span style=\"color: navy\">// </span><span style=\"color: green\">Glycémie à jeun (linkId 273778921448)</span>\r\n      glucoseGroup.item<b> as </b><span style=\"color: maroon\">glycItem</span><b> where </b>(linkId = '273778921448')<b> then</b><span style=\"color: navy\"> {\r\n</span>        glycItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style=\"color: navy\">(</span><span style=\"color: maroon\">ans</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">glycItem</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">patient</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">bundle</span><span style=\"color: navy\">)</span> <i>&quot;createglycobs&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractglyc&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">HbA1c (linkId 632894677152)</span>\r\n      glucoseGroup.item<b> as </b><span style=\"color: maroon\">hba1cItem</span><b> where </b>(linkId = '632894677152')<b> then</b><span style=\"color: navy\"> {\r\n</span>        hba1cItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>bundle<b> then </b>CreateLabObservation<span style=\"color: navy\">(</span><span style=\"color: maroon\">ans</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">hba1cItem</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">patient</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">bundle</span><span style=\"color: navy\">)</span> <i>&quot;createhba1cobs&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extracthba1c&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;processglucose&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;processbiology&quot;</i><span style=\"color: navy\">;</span>\r\n<span style=\"color: navy\">}\r\n\r\n</span><span style=\"color: navy\">// </span><span style=\"color: green\">Helper: Create a single Laboratory Observation</span>\r\n<b>group </b>CreateLabObservation<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">ans</span>, <b>source</b> <span style=\"color: maroon\">parentItem</span>, <b>target</b> <span style=\"color: maroon\">patient</span><span style=\"color: navy\"> : </span>Patient, <b>target</b> <span style=\"color: maroon\">bundle</span><span style=\"color: navy\"> : </span>Bundle<span style=\"color: navy\">)</span><span style=\"color: navy\"> {\r\n</span>  ans<span style=\"color: navy\"><b> -&gt; </b></span>bundle.entry<b> as </b><span style=\"color: maroon\">obsEntry</span><b> then</b><span style=\"color: navy\"> {\r\n</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\"> {\r\n</span>      ans<span style=\"color: navy\"><b> -&gt; </b></span>obs.id = <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span> <i>&quot;obsid&quot;</i><span style=\"color: navy\">;</span>\r\n      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>\r\n      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\"> {\r\n</span>        ans<span style=\"color: navy\"><b> -&gt; </b></span>meta.profile = <span style=\"color: blue\">'https://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/dm-observation-laboratory-generic'</span> <i>&quot;obsprofile&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;obsmeta&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Status</span>\r\n      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>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Category</span>\r\n      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\"> {\r\n</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\"> {\r\n</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>\r\n          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>\r\n        <span style=\"color: navy\">}</span> <i>&quot;setcategorycoding&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;setcategory&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Link to patient</span>\r\n      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>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Value as Quantity</span>\r\n      ans<span style=\"color: navy\"><b> -&gt; </b></span> obs.value = <span style=\"color: navy\">(</span>%ans.valueQuantity<span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">tgtObsVal</span><span style=\"color: navy\">, </span> tgtObsVal.code = <span style=\"color: navy\">(</span>%ans.valueQuantity.unit<span style=\"color: navy\">)</span><span style=\"color: navy\">, </span> tgtObsVal.system = <span style=\"color: blue\">'http://unitsofmeasure.org'</span> <i>&quot;setvalue&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Extract nested items - LOINC code, effective date, status, reference ranges</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">LOINC code</span>\r\n      ans.item<b> as </b><span style=\"color: maroon\">loincItem</span><b> where </b>(text.contains('code loinc'))<b> then</b><span style=\"color: navy\"> {\r\n</span>        loincItem.answer<b> as </b><span style=\"color: maroon\">loincAns</span><span style=\"color: navy\"><b> -&gt; </b></span> obs.code<b> as </b><span style=\"color: maroon\">code</span><span style=\"color: navy\">, </span> code.coding<b> as </b><span style=\"color: maroon\">coding</span><span style=\"color: navy\">, </span> coding.code = <span style=\"color: navy\">(</span>%loincAns.valueString<span style=\"color: navy\">)</span> <i>&quot;setloinccoding&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extractloinc&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">effectiveDateTime</span>\r\n      ans.item<b> as </b><span style=\"color: maroon\">dateItem</span><b> where </b>(text.contains('Date et heure du prélèvement'))<b> then</b><span style=\"color: navy\"> {\r\n</span>        dateItem.answer<b> as </b><span style=\"color: maroon\">dateAns</span><span style=\"color: navy\"><b> -&gt; </b></span>obs.effective = <span style=\"color: navy\">(</span>%dateAns.valueDateTime<span style=\"color: navy\">)</span> <i>&quot;seteffective&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;extracteffective&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: #b36b00\" title=\"Cet élément n'était pas défini avant R5\">// parentItem.item as statusItem where (linkId.contains('Statut de validation')) then {         statusItem.answer as statusAns -&gt; obs.extension = create('Extension') as ext then {           statusAns -&gt; ext.url = 'http://hl7.org/fhir/StructureDefinition/observation-status' &quot;status-url&quot;;           statusAns -&gt; ext.value = (%statusAns.valueString) &quot;status-value&quot;;         } &quot;set-status-ext&quot;;       } &quot;extract-validation-status&quot;;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Reference ranges (low and high)</span>\r\n      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\"> {\r\n</span>        ans.item<b> as </b><span style=\"color: maroon\">lowItem</span><b> where </b>(text.contains('Borne inférieure'))<b> then</b><span style=\"color: navy\"> {\r\n</span>          lowItem.answer<b> as </b><span style=\"color: maroon\">lowAns</span><span style=\"color: navy\"><b> -&gt; </b></span> refRange.low = <span style=\"color: navy\">(</span>%lowAns.valueQuantity<span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">tgtLow</span><span style=\"color: navy\">, </span> tgtLow.code = <span style=\"color: navy\">(</span>%ans.valueQuantity.unit<span style=\"color: navy\">)</span><span style=\"color: navy\">, </span> tgtLow.system = <span style=\"color: blue\">'http://unitsofmeasure.org'</span> <i>&quot;setlow&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;extractlow&quot;</i><span style=\"color: navy\">;</span>\r\n        ans.item<b> as </b><span style=\"color: maroon\">highItem</span><b> where </b>(text.contains('Borne supérieure'))<b> then</b><span style=\"color: navy\"> {\r\n</span>          highItem.answer<b> as </b><span style=\"color: maroon\">highAns</span><span style=\"color: navy\"><b> -&gt; </b></span> refRange.high = <span style=\"color: navy\">(</span>%highAns.valueQuantity<span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">tgtHigh</span><span style=\"color: navy\">, </span> tgtHigh.code = <span style=\"color: navy\">(</span>%ans.valueQuantity.unit<span style=\"color: navy\">)</span><span style=\"color: navy\">, </span> tgtHigh.system = <span style=\"color: blue\">'http://unitsofmeasure.org'</span> <i>&quot;sethigh&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;extracthigh&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;setrefrange&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;createobs&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;obsentry&quot;</i><span style=\"color: navy\">;</span>\r\n<span style=\"color: navy\">}\r\n\r\n</span></pre></div>"
      },
      "url" : "https://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureMap/Q2FSL",
      "version" : "0.1.0",
      "name" : "Q2FSL",
      "title" : "Transforms QuestionnaireResponse based on Questionnaire Usage Variables socles into FHIR resources conforming to DM profiles",
      "status" : "draft",
      "date" : "2026-05-28T20:54:01+00:00",
      "publisher" : "AP-HP",
      "contact" : [
        {
          "name" : "AP-HP",
          "telecom" : [
            {
              "system" : "url",
              "value" : "https://aphp.fr"
            }
          ]
        }
      ],
      "description" : "Transforms QuestionnaireResponse based on Questionnaire Usage Variables socles into FHIR resources conforming to DM profiles",
      "jurisdiction" : [
        {
          "coding" : [
            {
              "system" : "urn:iso:std:iso:3166",
              "code" : "FRA"
            }
          ]
        }
      ],
      "structure" : [
        {
          "url" : "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse",
          "mode" : "source",
          "alias" : "QuestionnaireResponse"
        },
        {
          "url" : "http://hl7.org/fhir/StructureDefinition/Bundle",
          "mode" : "target",
          "alias" : "Bundle"
        }
      ],
      "group" : [
        {
          "name" : "QuestionnaireResponseToBundle",
          "typeMode" : "none",
          "documentation" : "Main entry point: Transform QuestionnaireResponse to Bundle",
          "input" : [
            {
              "name" : "src",
              "type" : "QuestionnaireResponse",
              "mode" : "source"
            },
            {
              "name" : "bundle",
              "type" : "Bundle",
              "mode" : "target"
            }
          ],
          "rule" : [
            {
              "name" : "bundleid",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "bundle",
                  "contextType" : "variable",
                  "element" : "id",
                  "transform" : "uuid"
                }
              ]
            },
            {
              "name" : "bundletype",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "bundle",
                  "contextType" : "variable",
                  "element" : "type",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "collection"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "setTimestamp",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "bundle",
                  "contextType" : "variable",
                  "element" : "timestamp",
                  "transform" : "evaluate",
                  "parameter" : [
                    {
                      "valueString" : "now()"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "patiententry",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "bundle",
                  "contextType" : "variable",
                  "element" : "entry",
                  "variable" : "patientEntry"
                }
              ],
              "rule" : [
                {
                  "name" : "createpatientresource",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "patientEntry",
                      "contextType" : "variable",
                      "element" : "resource",
                      "variable" : "patient",
                      "transform" : "create",
                      "parameter" : [
                        {
                          "valueString" : "Patient"
                        }
                      ]
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "createpatient",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreatePatient",
                          "variable" : [
                            "src",
                            "patient"
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "setfullUrl",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "patient",
                          "contextType" : "variable",
                          "element" : "id",
                          "variable" : "patientId"
                        },
                        {
                          "context" : "patientEntry",
                          "contextType" : "variable",
                          "element" : "fullUrl",
                          "transform" : "append",
                          "parameter" : [
                            {
                              "valueString" : "urn:uuid:"
                            },
                            {
                              "valueId" : "patientId"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "createencounters",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateEncounters",
                          "variable" : [
                            "src",
                            "patient",
                            "bundle"
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "createlabobservations",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateLaboratoryObservations",
                          "variable" : [
                            "src",
                            "patient",
                            "bundle"
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "createmedicationrequests",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateMedicationRequests",
                          "variable" : [
                            "src",
                            "patient",
                            "bundle"
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "createmedicationadministrations",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateMedicationAdministrations",
                          "variable" : [
                            "src",
                            "patient",
                            "bundle"
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "createvitalsigns",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateVitalSignObservations",
                          "variable" : [
                            "src",
                            "patient",
                            "bundle"
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "CreatePatient",
          "typeMode" : "none",
          "documentation" : "Group: Create Patient from QuestionnaireResponse",
          "input" : [
            {
              "name" : "src",
              "type" : "QuestionnaireResponse",
              "mode" : "source"
            },
            {
              "name" : "patient",
              "type" : "Patient",
              "mode" : "target"
            }
          ],
          "rule" : [
            {
              "name" : "patientid",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "patient",
                  "contextType" : "variable",
                  "element" : "id",
                  "transform" : "uuid"
                }
              ]
            },
            {
              "name" : "patientmeta",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "patient",
                  "contextType" : "variable",
                  "element" : "meta",
                  "variable" : "meta",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Meta"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "patientprofile",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "meta",
                      "contextType" : "variable",
                      "element" : "profile",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "https://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-patient"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "processsociodemographics",
              "source" : [
                {
                  "context" : "src",
                  "element" : "item",
                  "variable" : "socioDemo",
                  "condition" : "(linkId = '4647259356106')"
                }
              ],
              "rule" : [
                {
                  "name" : "processidentity",
                  "source" : [
                    {
                      "context" : "socioDemo",
                      "element" : "item",
                      "variable" : "identity",
                      "condition" : "(linkId = '2958000860428')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "setname",
                      "source" : [
                        {
                          "context" : "identity"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "patient",
                          "contextType" : "variable",
                          "element" : "name",
                          "variable" : "name",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "HumanName"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "extractfamily",
                          "source" : [
                            {
                              "context" : "identity",
                              "element" : "item",
                              "variable" : "familyItem",
                              "condition" : "(linkId = '8605698058770')"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "setfamily",
                              "source" : [
                                {
                                  "context" : "familyItem",
                                  "element" : "answer",
                                  "variable" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "name",
                                  "contextType" : "variable",
                                  "element" : "family",
                                  "transform" : "evaluate",
                                  "parameter" : [
                                    {
                                      "valueString" : "%ans.valueString"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "extractgiven",
                          "source" : [
                            {
                              "context" : "identity",
                              "element" : "item",
                              "variable" : "givenItem",
                              "condition" : "(linkId = '6214879623503')"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "setgiven",
                              "source" : [
                                {
                                  "context" : "givenItem",
                                  "element" : "answer",
                                  "variable" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "name",
                                  "contextType" : "variable",
                                  "element" : "given",
                                  "transform" : "evaluate",
                                  "parameter" : [
                                    {
                                      "valueString" : "%ans.valueString"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractnir",
                      "source" : [
                        {
                          "context" : "identity",
                          "element" : "item",
                          "variable" : "nirItem",
                          "condition" : "(linkId = '5711960356160')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "setnir",
                          "source" : [
                            {
                              "context" : "nirItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "patient",
                              "contextType" : "variable",
                              "element" : "identifier",
                              "variable" : "nir",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Identifier"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "nirsystem",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "nir",
                                  "contextType" : "variable",
                                  "element" : "system",
                                  "transform" : "copy",
                                  "parameter" : [
                                    {
                                      "valueString" : "urn:oid:1.2.250.1.213.1.4.8"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "nirvalue",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "nir",
                                  "contextType" : "variable",
                                  "element" : "value",
                                  "transform" : "evaluate",
                                  "parameter" : [
                                    {
                                      "valueString" : "%ans.valueString"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "nirtype",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "nir",
                                  "contextType" : "variable",
                                  "element" : "type",
                                  "transform" : "cc",
                                  "parameter" : [
                                    {
                                      "valueString" : "http://interopsante.org/fhir/CodeSystem/fr-v2-0203"
                                    },
                                    {
                                      "valueString" : "NIR"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractins",
                      "source" : [
                        {
                          "context" : "identity",
                          "element" : "item",
                          "variable" : "insItem",
                          "condition" : "(linkId = '3764723550987')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "setins",
                          "source" : [
                            {
                              "context" : "insItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "patient",
                              "contextType" : "variable",
                              "element" : "identifier",
                              "variable" : "ins",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Identifier"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "inssystem",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "ins",
                                  "contextType" : "variable",
                                  "element" : "system",
                                  "transform" : "copy",
                                  "parameter" : [
                                    {
                                      "valueString" : "urn:oid:1.2.250.1.213.1.4.10"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "insvalue",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "ins",
                                  "contextType" : "variable",
                                  "element" : "value",
                                  "transform" : "evaluate",
                                  "parameter" : [
                                    {
                                      "valueString" : "%ans.valueString"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "instype",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "ins",
                                  "contextType" : "variable",
                                  "element" : "type",
                                  "transform" : "cc",
                                  "parameter" : [
                                    {
                                      "valueString" : "http://interopsante.org/fhir/CodeSystem/fr-v2-0203"
                                    },
                                    {
                                      "valueString" : "INS-C"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractbirthdate",
                      "source" : [
                        {
                          "context" : "identity",
                          "element" : "item",
                          "variable" : "birthItem",
                          "condition" : "(linkId = '5036133558154')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "setbirthdate",
                          "source" : [
                            {
                              "context" : "birthItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "patient",
                              "contextType" : "variable",
                              "element" : "birthDate",
                              "transform" : "evaluate",
                              "parameter" : [
                                {
                                  "valueString" : "%ans.valueDate"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractdeath",
                      "source" : [
                        {
                          "context" : "identity",
                          "element" : "item",
                          "variable" : "deathItem",
                          "condition" : "(linkId = '5633552097315')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "setdeceaseddate",
                          "source" : [
                            {
                              "context" : "deathItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "patient",
                              "contextType" : "variable",
                              "element" : "deceased",
                              "transform" : "evaluate",
                              "parameter" : [
                                {
                                  "valueString" : "%ans.valueDate"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "extractdeathsource",
                          "source" : [
                            {
                              "context" : "deathItem",
                              "element" : "item",
                              "variable" : "deathSource",
                              "condition" : "(linkId = '9098810065693')"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "setdeathsourceext",
                              "source" : [
                                {
                                  "context" : "deathSource",
                                  "element" : "answer",
                                  "variable" : "sourceAns"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "patient",
                                  "contextType" : "variable",
                                  "element" : "extension",
                                  "variable" : "ext",
                                  "transform" : "create",
                                  "parameter" : [
                                    {
                                      "valueString" : "Extension"
                                    }
                                  ]
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "deathsourceurl",
                                  "source" : [
                                    {
                                      "context" : "sourceAns"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "ext",
                                      "contextType" : "variable",
                                      "element" : "url",
                                      "transform" : "copy",
                                      "parameter" : [
                                        {
                                          "valueString" : "https://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-death-source"
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "deathsourcevalue",
                                  "source" : [
                                    {
                                      "context" : "sourceAns"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "ext",
                                      "contextType" : "variable",
                                      "element" : "value",
                                      "transform" : "evaluate",
                                      "parameter" : [
                                        {
                                          "valueString" : "%sourceAns.valueCoding"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractmultiplebirth",
                      "source" : [
                        {
                          "context" : "identity",
                          "element" : "item",
                          "variable" : "multipleItem",
                          "condition" : "(linkId = '6931296968515')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "setmultiplebirth",
                          "source" : [
                            {
                              "context" : "multipleItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "patient",
                              "contextType" : "variable",
                              "element" : "multipleBirth",
                              "transform" : "evaluate",
                              "parameter" : [
                                {
                                  "valueString" : "%ans.valueInteger"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extractpmsidemographics",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "item",
                      "variable" : "pmsiGroup",
                      "condition" : "(linkId = '2825244231605')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "extractgender",
                      "source" : [
                        {
                          "context" : "pmsiGroup",
                          "element" : "item",
                          "variable" : "sexItem",
                          "condition" : "(linkId = '3894630481120')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "valueCoding",
                          "source" : [
                            {
                              "context" : "sexItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "setGenderF",
                              "source" : [
                                {
                                  "context" : "ans",
                                  "element" : "valueString",
                                  "variable" : "female",
                                  "condition" : "($this = 'f')"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "patient",
                                  "contextType" : "variable",
                                  "element" : "gender",
                                  "transform" : "copy",
                                  "parameter" : [
                                    {
                                      "valueString" : "female"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "setGenderM",
                              "source" : [
                                {
                                  "context" : "ans",
                                  "element" : "valueString",
                                  "variable" : "female",
                                  "condition" : "($this = 'm')"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "patient",
                                  "contextType" : "variable",
                                  "element" : "gender",
                                  "transform" : "copy",
                                  "parameter" : [
                                    {
                                      "valueString" : "male"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractcodegeo",
                      "source" : [
                        {
                          "context" : "pmsiGroup",
                          "element" : "item",
                          "variable" : "codeGeoItem",
                          "condition" : "(linkId = '2446369196222')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "setaddress",
                          "source" : [
                            {
                              "context" : "codeGeoItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "patient",
                              "contextType" : "variable",
                              "element" : "address",
                              "variable" : "addr",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Address"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "setcodegeoext",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "addr",
                                  "contextType" : "variable",
                                  "element" : "extension",
                                  "variable" : "ext",
                                  "transform" : "create",
                                  "parameter" : [
                                    {
                                      "valueString" : "Extension"
                                    }
                                  ]
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "codegeourl",
                                  "source" : [
                                    {
                                      "context" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "ext",
                                      "contextType" : "variable",
                                      "element" : "url",
                                      "transform" : "copy",
                                      "parameter" : [
                                        {
                                          "valueString" : "https://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-pmsi-code-geo"
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "codegeovalue",
                                  "source" : [
                                    {
                                      "context" : "ans",
                                      "element" : "value",
                                      "variable" : "val"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "ext",
                                      "contextType" : "variable",
                                      "element" : "value",
                                      "transform" : "cast",
                                      "parameter" : [
                                        {
                                          "valueId" : "val"
                                        },
                                        {
                                          "valueString" : "code"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "navEnv",
                              "source" : [
                                {
                                  "context" : "socioDemo",
                                  "element" : "item",
                                  "variable" : "environnementItem",
                                  "condition" : "(linkId = '5491974639955')"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "createGeolocExt",
                                  "source" : [
                                    {
                                      "context" : "environnementItem",
                                      "element" : "item",
                                      "variable" : "geocodageItem",
                                      "condition" : "(linkId = '3816475533472')"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "addr",
                                      "contextType" : "variable",
                                      "element" : "extension",
                                      "variable" : "geolocationExt",
                                      "transform" : "create",
                                      "parameter" : [
                                        {
                                          "valueString" : "Extension"
                                        }
                                      ]
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "createLatExt",
                                      "source" : [
                                        {
                                          "context" : "geocodageItem",
                                          "element" : "item",
                                          "variable" : "latItem",
                                          "condition" : "(linkId = '3709843054556')"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "geolocationExt",
                                          "contextType" : "variable",
                                          "element" : "url",
                                          "transform" : "copy",
                                          "parameter" : [
                                            {
                                              "valueString" : "http://hl7.org/fhir/StructureDefinition/geolocation"
                                            }
                                          ]
                                        },
                                        {
                                          "context" : "geolocationExt",
                                          "contextType" : "variable",
                                          "element" : "extension",
                                          "variable" : "latExt",
                                          "transform" : "create",
                                          "parameter" : [
                                            {
                                              "valueString" : "Extension"
                                            }
                                          ]
                                        }
                                      ],
                                      "rule" : [
                                        {
                                          "name" : "setLat",
                                          "source" : [
                                            {
                                              "context" : "latItem",
                                              "element" : "answer",
                                              "variable" : "lat"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "latExt",
                                              "contextType" : "variable",
                                              "element" : "url",
                                              "transform" : "copy",
                                              "parameter" : [
                                                {
                                                  "valueString" : "latitude"
                                                }
                                              ]
                                            },
                                            {
                                              "context" : "latExt",
                                              "contextType" : "variable",
                                              "element" : "value",
                                              "transform" : "evaluate",
                                              "parameter" : [
                                                {
                                                  "valueString" : "%lat.valueDecimal"
                                                }
                                              ]
                                            }
                                          ],
                                          "rule" : [
                                            {
                                              "name" : "createLongExt",
                                              "source" : [
                                                {
                                                  "context" : "geocodageItem",
                                                  "element" : "item",
                                                  "variable" : "longItem",
                                                  "condition" : "(linkId = '7651448032665')"
                                                }
                                              ],
                                              "target" : [
                                                {
                                                  "context" : "geolocationExt",
                                                  "contextType" : "variable",
                                                  "element" : "extension",
                                                  "variable" : "longExt",
                                                  "transform" : "create",
                                                  "parameter" : [
                                                    {
                                                      "valueString" : "Extension"
                                                    }
                                                  ]
                                                }
                                              ],
                                              "rule" : [
                                                {
                                                  "name" : "setLong",
                                                  "source" : [
                                                    {
                                                      "context" : "longItem",
                                                      "element" : "answer",
                                                      "variable" : "long"
                                                    }
                                                  ],
                                                  "target" : [
                                                    {
                                                      "context" : "longExt",
                                                      "contextType" : "variable",
                                                      "element" : "url",
                                                      "transform" : "copy",
                                                      "parameter" : [
                                                        {
                                                          "valueString" : "longitude"
                                                        }
                                                      ]
                                                    },
                                                    {
                                                      "context" : "longExt",
                                                      "contextType" : "variable",
                                                      "element" : "value",
                                                      "transform" : "evaluate",
                                                      "parameter" : [
                                                        {
                                                          "valueString" : "%long.valueDecimal"
                                                        }
                                                      ]
                                                    }
                                                  ]
                                                }
                                              ]
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "navIrisItem",
                                  "source" : [
                                    {
                                      "context" : "environnementItem",
                                      "element" : "item",
                                      "variable" : "irisItem",
                                      "condition" : "(linkId = '7621032273792')"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "addr",
                                      "contextType" : "variable",
                                      "element" : "line",
                                      "variable" : "addrLine"
                                    },
                                    {
                                      "context" : "addrLine",
                                      "contextType" : "variable",
                                      "element" : "extension",
                                      "variable" : "irisExt",
                                      "transform" : "create",
                                      "parameter" : [
                                        {
                                          "valueString" : "Extension"
                                        }
                                      ]
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "setIrisExt",
                                      "source" : [
                                        {
                                          "context" : "irisItem",
                                          "element" : "answer",
                                          "variable" : "ans"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "irisExt",
                                          "contextType" : "variable",
                                          "element" : "url",
                                          "transform" : "copy",
                                          "parameter" : [
                                            {
                                              "valueString" : "http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-censusTract"
                                            }
                                          ]
                                        },
                                        {
                                          "context" : "irisExt",
                                          "contextType" : "variable",
                                          "element" : "valueString",
                                          "transform" : "evaluate",
                                          "parameter" : [
                                            {
                                              "valueString" : "%ans.valueString"
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "CreateLocations",
          "typeMode" : "none",
          "documentation" : "Group: Create Locations from geocoding and IRIS data",
          "input" : [
            {
              "name" : "src",
              "type" : "QuestionnaireResponse",
              "mode" : "source"
            },
            {
              "name" : "patient",
              "type" : "Patient",
              "mode" : "target"
            },
            {
              "name" : "bundle",
              "type" : "Bundle",
              "mode" : "target"
            }
          ],
          "rule" : [
            {
              "name" : "processsociodemographicslocation",
              "source" : [
                {
                  "context" : "src",
                  "element" : "item",
                  "variable" : "socioDemo",
                  "condition" : "(linkId = '4647259356106')"
                }
              ],
              "rule" : [
                {
                  "name" : "processenvironment",
                  "source" : [
                    {
                      "context" : "socioDemo",
                      "element" : "item",
                      "variable" : "environment",
                      "condition" : "(linkId = '5491974639955')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "geocodinglocationentry",
                      "source" : [
                        {
                          "context" : "environment",
                          "element" : "item",
                          "variable" : "geocodingItem",
                          "condition" : "(linkId = '3816475533472')"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable",
                          "element" : "entry",
                          "variable" : "locationEntry"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createlocation",
                          "source" : [
                            {
                              "context" : "geocodingItem"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "locationEntry",
                              "contextType" : "variable",
                              "element" : "resource",
                              "variable" : "location",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Location"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "locationid",
                              "source" : [
                                {
                                  "context" : "geocodingItem"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "location",
                                  "contextType" : "variable",
                                  "element" : "id",
                                  "transform" : "uuid"
                                }
                              ]
                            },
                            {
                              "name" : "locationmeta",
                              "source" : [
                                {
                                  "context" : "geocodingItem"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "location",
                                  "contextType" : "variable",
                                  "element" : "meta",
                                  "variable" : "meta",
                                  "transform" : "create",
                                  "parameter" : [
                                    {
                                      "valueString" : "Meta"
                                    }
                                  ]
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "locationprofile",
                                  "source" : [
                                    {
                                      "context" : "geocodingItem"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "meta",
                                      "contextType" : "variable",
                                      "element" : "profile",
                                      "transform" : "copy",
                                      "parameter" : [
                                        {
                                          "valueString" : "https://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-location"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "setposition",
                              "source" : [
                                {
                                  "context" : "geocodingItem"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "location",
                                  "contextType" : "variable",
                                  "element" : "position",
                                  "variable" : "pos",
                                  "transform" : "create",
                                  "parameter" : [
                                    {
                                      "valueString" : "LocationPosition"
                                    }
                                  ]
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "extractlatitude",
                                  "source" : [
                                    {
                                      "context" : "geocodingItem",
                                      "element" : "item",
                                      "variable" : "latItem",
                                      "condition" : "(linkId = '3709843054556')"
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "setlatitude",
                                      "source" : [
                                        {
                                          "context" : "latItem",
                                          "element" : "answer",
                                          "variable" : "ans"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "pos",
                                          "contextType" : "variable",
                                          "element" : "latitude",
                                          "transform" : "evaluate",
                                          "parameter" : [
                                            {
                                              "valueString" : "%ans.valueDecimal"
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "extractlongitude",
                                  "source" : [
                                    {
                                      "context" : "geocodingItem",
                                      "element" : "item",
                                      "variable" : "longItem",
                                      "condition" : "(linkId = '7651448032665')"
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "setlongitude",
                                      "source" : [
                                        {
                                          "context" : "longItem",
                                          "element" : "answer",
                                          "variable" : "ans"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "pos",
                                          "contextType" : "variable",
                                          "element" : "longitude",
                                          "transform" : "evaluate",
                                          "parameter" : [
                                            {
                                              "valueString" : "%ans.valueDecimal"
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "setrequest",
                              "source" : [
                                {
                                  "context" : "location"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "locationEntry",
                                  "contextType" : "variable",
                                  "element" : "request",
                                  "variable" : "request"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "setmethod",
                                  "source" : [
                                    {
                                      "context" : "location"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "request",
                                      "contextType" : "variable",
                                      "element" : "method",
                                      "transform" : "copy",
                                      "parameter" : [
                                        {
                                          "valueString" : "POST"
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "seturl",
                                  "source" : [
                                    {
                                      "context" : "location"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "request",
                                      "contextType" : "variable",
                                      "element" : "url",
                                      "transform" : "copy",
                                      "parameter" : [
                                        {
                                          "valueString" : "Location"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "setfullUrl",
                              "source" : [
                                {
                                  "context" : "location",
                                  "element" : "id",
                                  "variable" : "locId"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "locationEntry",
                                  "contextType" : "variable",
                                  "element" : "fullUrl",
                                  "transform" : "append",
                                  "parameter" : [
                                    {
                                      "valueString" : "urn:uuid:"
                                    },
                                    {
                                      "valueId" : "locId"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "processiris",
                      "source" : [
                        {
                          "context" : "environment",
                          "element" : "item",
                          "variable" : "irisItem",
                          "condition" : "(linkId = '7621032273792')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "irislocationentry",
                          "source" : [
                            {
                              "context" : "irisItem",
                              "element" : "answer",
                              "variable" : "irisAnswer"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable",
                              "element" : "entry",
                              "variable" : "locationEntry"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "createirislocation",
                              "source" : [
                                {
                                  "context" : "irisAnswer"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "locationEntry",
                                  "contextType" : "variable",
                                  "element" : "resource",
                                  "variable" : "location",
                                  "transform" : "create",
                                  "parameter" : [
                                    {
                                      "valueString" : "Location"
                                    }
                                  ]
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "locationid",
                                  "source" : [
                                    {
                                      "context" : "irisAnswer"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "location",
                                      "contextType" : "variable",
                                      "element" : "id",
                                      "transform" : "uuid"
                                    }
                                  ]
                                },
                                {
                                  "name" : "locationmeta",
                                  "source" : [
                                    {
                                      "context" : "irisAnswer"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "location",
                                      "contextType" : "variable",
                                      "element" : "meta",
                                      "variable" : "meta",
                                      "transform" : "create",
                                      "parameter" : [
                                        {
                                          "valueString" : "Meta"
                                        }
                                      ]
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "locationprofile",
                                      "source" : [
                                        {
                                          "context" : "irisAnswer"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "meta",
                                          "contextType" : "variable",
                                          "element" : "profile",
                                          "transform" : "copy",
                                          "parameter" : [
                                            {
                                              "valueString" : "https://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-location"
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "setirisidentifier",
                                  "source" : [
                                    {
                                      "context" : "irisAnswer"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "location",
                                      "contextType" : "variable",
                                      "element" : "identifier",
                                      "variable" : "identifier",
                                      "transform" : "create",
                                      "parameter" : [
                                        {
                                          "valueString" : "Identifier"
                                        }
                                      ]
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "irissystem",
                                      "source" : [
                                        {
                                          "context" : "irisAnswer"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "identifier",
                                          "contextType" : "variable",
                                          "element" : "system",
                                          "transform" : "copy",
                                          "parameter" : [
                                            {
                                              "valueString" : "urn:oid:2.16.840.1.113883.2.8.1.5.5"
                                            }
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "name" : "irisvalue",
                                      "source" : [
                                        {
                                          "context" : "irisAnswer"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "identifier",
                                          "contextType" : "variable",
                                          "element" : "value",
                                          "transform" : "evaluate",
                                          "parameter" : [
                                            {
                                              "valueString" : "%irisAnswer.valueCoding.code"
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "setrequest",
                                  "source" : [
                                    {
                                      "context" : "location"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "locationEntry",
                                      "contextType" : "variable",
                                      "element" : "request",
                                      "variable" : "request"
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "setmethod",
                                      "source" : [
                                        {
                                          "context" : "location"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "request",
                                          "contextType" : "variable",
                                          "element" : "method",
                                          "transform" : "copy",
                                          "parameter" : [
                                            {
                                              "valueString" : "POST"
                                            }
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "name" : "seturl",
                                      "source" : [
                                        {
                                          "context" : "location"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "request",
                                          "contextType" : "variable",
                                          "element" : "url",
                                          "transform" : "copy",
                                          "parameter" : [
                                            {
                                              "valueString" : "Location"
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "setfullUrl",
                                  "source" : [
                                    {
                                      "context" : "location",
                                      "element" : "id",
                                      "variable" : "locId"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "locationEntry",
                                      "contextType" : "variable",
                                      "element" : "fullUrl",
                                      "transform" : "append",
                                      "parameter" : [
                                        {
                                          "valueString" : "urn:uuid:"
                                        },
                                        {
                                          "valueId" : "locId"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "CreateEncounters",
          "typeMode" : "none",
          "documentation" : "Group: Create Encounters from PMSI data",
          "input" : [
            {
              "name" : "src",
              "type" : "QuestionnaireResponse",
              "mode" : "source"
            },
            {
              "name" : "patient",
              "type" : "Patient",
              "mode" : "target"
            },
            {
              "name" : "bundle",
              "type" : "Bundle",
              "mode" : "target"
            }
          ],
          "rule" : [
            {
              "name" : "encounterentry",
              "source" : [
                {
                  "context" : "src",
                  "element" : "item",
                  "variable" : "pmsiItem",
                  "condition" : "(linkId = '2825244231605')"
                }
              ],
              "target" : [
                {
                  "context" : "bundle",
                  "contextType" : "variable",
                  "element" : "entry",
                  "variable" : "encounterEntry"
                }
              ],
              "rule" : [
                {
                  "name" : "createencounter",
                  "source" : [
                    {
                      "context" : "pmsiItem"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "encounterEntry",
                      "contextType" : "variable",
                      "element" : "resource",
                      "variable" : "encounter",
                      "transform" : "create",
                      "parameter" : [
                        {
                          "valueString" : "Encounter"
                        }
                      ]
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "encounterid",
                      "source" : [
                        {
                          "context" : "pmsiItem"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "encounter",
                          "contextType" : "variable",
                          "element" : "id",
                          "transform" : "uuid"
                        }
                      ]
                    },
                    {
                      "name" : "encountermeta",
                      "source" : [
                        {
                          "context" : "pmsiItem"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "encounter",
                          "contextType" : "variable",
                          "element" : "meta",
                          "variable" : "meta",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Meta"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "encounterprofile",
                          "source" : [
                            {
                              "context" : "pmsiItem"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "meta",
                              "contextType" : "variable",
                              "element" : "profile",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueString" : "https://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-encounter"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "setStatus",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "encounter",
                          "contextType" : "variable",
                          "element" : "status",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "finished"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "setClass",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "encounter",
                          "contextType" : "variable",
                          "element" : "class",
                          "transform" : "c",
                          "parameter" : [
                            {
                              "valueString" : "http://terminology.hl7.org/CodeSystem/v3-ActCode"
                            },
                            {
                              "valueString" : "IMP"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "setsubject",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "encounter",
                          "contextType" : "variable",
                          "element" : "subject",
                          "variable" : "ref",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Reference"
                            }
                          ]
                        },
                        {
                          "context" : "patient",
                          "contextType" : "variable",
                          "element" : "id",
                          "variable" : "patId"
                        },
                        {
                          "context" : "ref",
                          "contextType" : "variable",
                          "element" : "reference",
                          "transform" : "append",
                          "parameter" : [
                            {
                              "valueString" : "Patient/"
                            },
                            {
                              "valueId" : "patId"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "setperiod",
                      "source" : [
                        {
                          "context" : "pmsiItem"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "encounter",
                          "contextType" : "variable",
                          "element" : "period",
                          "variable" : "period",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Period"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "extractstart",
                          "source" : [
                            {
                              "context" : "pmsiItem",
                              "element" : "item",
                              "variable" : "startItem",
                              "condition" : "(linkId = '5991443718282')"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "setstart",
                              "source" : [
                                {
                                  "context" : "startItem",
                                  "element" : "answer",
                                  "variable" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "period",
                                  "contextType" : "variable",
                                  "element" : "start",
                                  "transform" : "evaluate",
                                  "parameter" : [
                                    {
                                      "valueString" : "%ans.valueDate"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "extractend",
                          "source" : [
                            {
                              "context" : "pmsiItem",
                              "element" : "item",
                              "variable" : "endItem",
                              "condition" : "(linkId = '6114780320846')"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "setend",
                              "source" : [
                                {
                                  "context" : "endItem",
                                  "element" : "answer",
                                  "variable" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "period",
                                  "contextType" : "variable",
                                  "element" : "end",
                                  "transform" : "evaluate",
                                  "parameter" : [
                                    {
                                      "valueString" : "%ans.valueDate"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractmodein",
                      "source" : [
                        {
                          "context" : "pmsiItem",
                          "element" : "item",
                          "variable" : "modeInItem",
                          "condition" : "(linkId = '6172398101212')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "navValue",
                          "source" : [
                            {
                              "context" : "modeInItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "setadmitsource",
                              "source" : [
                                {
                                  "context" : "ans",
                                  "element" : "valueString",
                                  "variable" : "valueString"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "encounter",
                                  "contextType" : "variable",
                                  "element" : "hospitalization",
                                  "variable" : "hosp"
                                },
                                {
                                  "context" : "hosp",
                                  "contextType" : "variable",
                                  "element" : "admitSource",
                                  "variable" : "admitSource"
                                },
                                {
                                  "context" : "admitSource",
                                  "contextType" : "variable",
                                  "element" : "coding",
                                  "variable" : "admitSourceCoding"
                                },
                                {
                                  "context" : "admitSourceCoding",
                                  "contextType" : "variable",
                                  "element" : "code",
                                  "transform" : "copy",
                                  "parameter" : [
                                    {
                                      "valueId" : "valueString"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractmodeout",
                      "source" : [
                        {
                          "context" : "pmsiItem",
                          "element" : "item",
                          "variable" : "modeOutItem",
                          "condition" : "(linkId = '3354867075704')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "navValue",
                          "source" : [
                            {
                              "context" : "modeOutItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "setdischargedisposition",
                              "source" : [
                                {
                                  "context" : "ans",
                                  "element" : "valueString",
                                  "variable" : "valueString"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "encounter",
                                  "contextType" : "variable",
                                  "element" : "hospitalization",
                                  "variable" : "hosp"
                                },
                                {
                                  "context" : "hosp",
                                  "contextType" : "variable",
                                  "element" : "dischargeDisposition",
                                  "variable" : "dischargeDisposition"
                                },
                                {
                                  "context" : "dischargeDisposition",
                                  "contextType" : "variable",
                                  "element" : "coding",
                                  "variable" : "dischargeDispositionCoding"
                                },
                                {
                                  "context" : "dischargeDispositionCoding",
                                  "contextType" : "variable",
                                  "element" : "code",
                                  "transform" : "copy",
                                  "parameter" : [
                                    {
                                      "valueId" : "valueString"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "setfullUrl",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "encounter",
                          "contextType" : "variable",
                          "element" : "id",
                          "variable" : "encId"
                        },
                        {
                          "context" : "encounterEntry",
                          "contextType" : "variable",
                          "element" : "fullUrl",
                          "transform" : "append",
                          "parameter" : [
                            {
                              "valueString" : "urn:uuid:"
                            },
                            {
                              "valueId" : "encId"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "createconditions",
                      "source" : [
                        {
                          "context" : "pmsiItem"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateConditions",
                          "variable" : [
                            "pmsiItem",
                            "patient",
                            "encounter",
                            "bundle"
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "createprocedures",
                      "source" : [
                        {
                          "context" : "pmsiItem"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateProcedures",
                          "variable" : [
                            "pmsiItem",
                            "patient",
                            "encounter",
                            "bundle"
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "CreateConditions",
          "typeMode" : "none",
          "documentation" : "Group: Create Conditions from nested diagnostics",
          "input" : [
            {
              "name" : "pmsiItem",
              "mode" : "source"
            },
            {
              "name" : "patient",
              "type" : "Patient",
              "mode" : "target"
            },
            {
              "name" : "encounter",
              "type" : "Encounter",
              "mode" : "target"
            },
            {
              "name" : "bundle",
              "type" : "Bundle",
              "mode" : "target"
            }
          ],
          "rule" : [
            {
              "name" : "conditionentry",
              "source" : [
                {
                  "context" : "pmsiItem",
                  "element" : "item",
                  "variable" : "diagGroup",
                  "condition" : "(linkId = '9391816419630')"
                }
              ],
              "target" : [
                {
                  "context" : "bundle",
                  "contextType" : "variable",
                  "element" : "entry",
                  "variable" : "conditionEntry"
                }
              ],
              "rule" : [
                {
                  "name" : "createcondition",
                  "source" : [
                    {
                      "context" : "diagGroup"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "conditionEntry",
                      "contextType" : "variable",
                      "element" : "resource",
                      "variable" : "condition",
                      "transform" : "create",
                      "parameter" : [
                        {
                          "valueString" : "Condition"
                        }
                      ]
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "conditionid",
                      "source" : [
                        {
                          "context" : "diagGroup"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "condition",
                          "contextType" : "variable",
                          "element" : "id",
                          "transform" : "uuid"
                        }
                      ]
                    },
                    {
                      "name" : "conditionmeta",
                      "source" : [
                        {
                          "context" : "diagGroup"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "condition",
                          "contextType" : "variable",
                          "element" : "meta",
                          "variable" : "meta",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Meta"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "conditionprofile",
                          "source" : [
                            {
                              "context" : "diagGroup"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "meta",
                              "contextType" : "variable",
                              "element" : "profile",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueString" : "https://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-condition"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "setsubject",
                      "source" : [
                        {
                          "context" : "diagGroup"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "condition",
                          "contextType" : "variable",
                          "element" : "subject",
                          "variable" : "ref",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Reference"
                            }
                          ]
                        },
                        {
                          "context" : "patient",
                          "contextType" : "variable",
                          "element" : "id",
                          "variable" : "patId"
                        },
                        {
                          "context" : "ref",
                          "contextType" : "variable",
                          "element" : "reference",
                          "transform" : "append",
                          "parameter" : [
                            {
                              "valueString" : "Patient/"
                            },
                            {
                              "valueId" : "patId"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "setencounter",
                      "source" : [
                        {
                          "context" : "diagGroup"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "encounter",
                          "contextType" : "variable",
                          "element" : "id",
                          "variable" : "encId"
                        },
                        {
                          "context" : "condition",
                          "contextType" : "variable",
                          "element" : "encounter",
                          "variable" : "ref",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Reference"
                            }
                          ]
                        },
                        {
                          "context" : "ref",
                          "contextType" : "variable",
                          "element" : "reference",
                          "transform" : "append",
                          "parameter" : [
                            {
                              "valueString" : "Encounter/"
                            },
                            {
                              "valueId" : "encId"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractdiagcode",
                      "source" : [
                        {
                          "context" : "diagGroup",
                          "element" : "item",
                          "variable" : "diagCodeItem",
                          "condition" : "(linkId = '5505101189372')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "setcode",
                          "source" : [
                            {
                              "context" : "diagCodeItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "condition",
                              "contextType" : "variable",
                              "element" : "code",
                              "variable" : "code",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "CodeableConcept"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "setcoding",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "code",
                                  "contextType" : "variable",
                                  "element" : "coding",
                                  "variable" : "coding"
                                },
                                {
                                  "context" : "coding",
                                  "contextType" : "variable",
                                  "element" : "code",
                                  "transform" : "evaluate",
                                  "parameter" : [
                                    {
                                      "valueString" : "%ans.valueString"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractdiagtype",
                      "source" : [
                        {
                          "context" : "diagGroup",
                          "element" : "item",
                          "variable" : "diagTypeItem",
                          "condition" : "(linkId = '6427586743735')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "setcategory",
                          "source" : [
                            {
                              "context" : "diagTypeItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "condition",
                              "contextType" : "variable",
                              "element" : "category",
                              "variable" : "category",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "CodeableConcept"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "setcategorycoding",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "category",
                                  "contextType" : "variable",
                                  "element" : "coding",
                                  "variable" : "coding",
                                  "transform" : "create",
                                  "parameter" : [
                                    {
                                      "valueString" : "Coding"
                                    }
                                  ]
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "diagtypesystem",
                                  "source" : [
                                    {
                                      "context" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "coding",
                                      "contextType" : "variable",
                                      "element" : "system",
                                      "transform" : "copy",
                                      "parameter" : [
                                        {
                                          "valueString" : "https://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/CodeSystem/pmsi-mco-diag-type"
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "diagtypecode",
                                  "source" : [
                                    {
                                      "context" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "coding",
                                      "contextType" : "variable",
                                      "element" : "code",
                                      "transform" : "evaluate",
                                      "parameter" : [
                                        {
                                          "valueString" : "%ans.valueString"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractrecordeddate",
                      "source" : [
                        {
                          "context" : "diagGroup",
                          "element" : "item",
                          "variable" : "dateItem",
                          "condition" : "(linkId = '7114466839467')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "setrecordeddate",
                          "source" : [
                            {
                              "context" : "dateItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "condition",
                              "contextType" : "variable",
                              "element" : "recordedDate",
                              "transform" : "evaluate",
                              "parameter" : [
                                {
                                  "valueString" : "%ans.valueDate"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "setfullUrl",
                      "source" : [
                        {
                          "context" : "pmsiItem"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "condition",
                          "contextType" : "variable",
                          "element" : "id",
                          "variable" : "condId"
                        },
                        {
                          "context" : "conditionEntry",
                          "contextType" : "variable",
                          "element" : "fullUrl",
                          "transform" : "append",
                          "parameter" : [
                            {
                              "valueString" : "urn:uuid:"
                            },
                            {
                              "valueId" : "condId"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "CreateProcedures",
          "typeMode" : "none",
          "documentation" : "Group: Create Procedures from nested actes",
          "input" : [
            {
              "name" : "pmsiItem",
              "mode" : "source"
            },
            {
              "name" : "patient",
              "type" : "Patient",
              "mode" : "target"
            },
            {
              "name" : "encounter",
              "type" : "Encounter",
              "mode" : "target"
            },
            {
              "name" : "bundle",
              "type" : "Bundle",
              "mode" : "target"
            }
          ],
          "rule" : [
            {
              "name" : "procedureentry",
              "source" : [
                {
                  "context" : "pmsiItem",
                  "element" : "item",
                  "variable" : "acteGroup",
                  "condition" : "(linkId = '591926901726')"
                }
              ],
              "target" : [
                {
                  "context" : "bundle",
                  "contextType" : "variable",
                  "element" : "entry",
                  "variable" : "procedureEntry"
                }
              ],
              "rule" : [
                {
                  "name" : "createprocedure",
                  "source" : [
                    {
                      "context" : "acteGroup"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "procedureEntry",
                      "contextType" : "variable",
                      "element" : "resource",
                      "variable" : "procedure",
                      "transform" : "create",
                      "parameter" : [
                        {
                          "valueString" : "Procedure"
                        }
                      ]
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "procedureid",
                      "source" : [
                        {
                          "context" : "acteGroup"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "procedure",
                          "contextType" : "variable",
                          "element" : "id",
                          "transform" : "uuid"
                        }
                      ]
                    },
                    {
                      "name" : "proceduremeta",
                      "source" : [
                        {
                          "context" : "acteGroup"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "procedure",
                          "contextType" : "variable",
                          "element" : "meta",
                          "variable" : "meta",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Meta"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "procedureprofile",
                          "source" : [
                            {
                              "context" : "acteGroup"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "meta",
                              "contextType" : "variable",
                              "element" : "profile",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueString" : "https://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-procedure"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "setStatus",
                      "source" : [
                        {
                          "context" : "acteGroup"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "procedure",
                          "contextType" : "variable",
                          "element" : "status",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "completed"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "setsubject",
                      "source" : [
                        {
                          "context" : "acteGroup"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "procedure",
                          "contextType" : "variable",
                          "element" : "subject",
                          "variable" : "ref",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Reference"
                            }
                          ]
                        },
                        {
                          "context" : "patient",
                          "contextType" : "variable",
                          "element" : "id",
                          "variable" : "patId"
                        },
                        {
                          "context" : "ref",
                          "contextType" : "variable",
                          "element" : "reference",
                          "transform" : "append",
                          "parameter" : [
                            {
                              "valueString" : "Patient/"
                            },
                            {
                              "valueId" : "patId"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "setencounter",
                      "source" : [
                        {
                          "context" : "acteGroup"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "encounter",
                          "contextType" : "variable",
                          "element" : "id",
                          "variable" : "encId"
                        },
                        {
                          "context" : "procedure",
                          "contextType" : "variable",
                          "element" : "encounter",
                          "variable" : "ref",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Reference"
                            }
                          ]
                        },
                        {
                          "context" : "ref",
                          "contextType" : "variable",
                          "element" : "reference",
                          "transform" : "append",
                          "parameter" : [
                            {
                              "valueString" : "Encounter/"
                            },
                            {
                              "valueId" : "encId"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractactecode",
                      "source" : [
                        {
                          "context" : "acteGroup",
                          "element" : "item",
                          "variable" : "acteCodeItem",
                          "condition" : "(linkId = '7758110033600')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "setcode",
                          "source" : [
                            {
                              "context" : "acteCodeItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "procedure",
                              "contextType" : "variable",
                              "element" : "code",
                              "variable" : "code",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "CodeableConcept"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "setcoding",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "code",
                                  "contextType" : "variable",
                                  "element" : "coding",
                                  "variable" : "coding"
                                },
                                {
                                  "context" : "coding",
                                  "contextType" : "variable",
                                  "element" : "code",
                                  "transform" : "evaluate",
                                  "parameter" : [
                                    {
                                      "valueString" : "%ans.valueString"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractperformeddate",
                      "source" : [
                        {
                          "context" : "acteGroup",
                          "element" : "item",
                          "variable" : "dateItem",
                          "condition" : "(linkId = '5066866286682')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "setperformed",
                          "source" : [
                            {
                              "context" : "dateItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "procedure",
                              "contextType" : "variable",
                              "element" : "performed",
                              "transform" : "evaluate",
                              "parameter" : [
                                {
                                  "valueString" : "%ans.valueDateTime"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "setfullUrl",
                      "source" : [
                        {
                          "context" : "pmsiItem"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "procedure",
                          "contextType" : "variable",
                          "element" : "id",
                          "variable" : "procId"
                        },
                        {
                          "context" : "procedureEntry",
                          "contextType" : "variable",
                          "element" : "fullUrl",
                          "transform" : "append",
                          "parameter" : [
                            {
                              "valueString" : "urn:uuid:"
                            },
                            {
                              "valueId" : "procId"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "CreateMedicationRequests",
          "typeMode" : "none",
          "documentation" : "Group: Create Medication Requests",
          "input" : [
            {
              "name" : "src",
              "type" : "QuestionnaireResponse",
              "mode" : "source"
            },
            {
              "name" : "patient",
              "type" : "Patient",
              "mode" : "target"
            },
            {
              "name" : "bundle",
              "type" : "Bundle",
              "mode" : "target"
            }
          ],
          "rule" : [
            {
              "name" : "processmedexpo",
              "source" : [
                {
                  "context" : "src",
                  "element" : "item",
                  "variable" : "medExpoGroup",
                  "condition" : "(linkId = '817801935685')"
                }
              ],
              "rule" : [
                {
                  "name" : "medreqentry",
                  "source" : [
                    {
                      "context" : "medExpoGroup",
                      "element" : "item",
                      "variable" : "prescribedGroup",
                      "condition" : "(linkId = '156631794800')"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "bundle",
                      "contextType" : "variable",
                      "element" : "entry",
                      "variable" : "medReqEntry"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "createmedreq",
                      "source" : [
                        {
                          "context" : "prescribedGroup"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "medReqEntry",
                          "contextType" : "variable",
                          "element" : "resource",
                          "variable" : "medReq",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "MedicationRequest"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "medreqid",
                          "source" : [
                            {
                              "context" : "prescribedGroup"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "medReq",
                              "contextType" : "variable",
                              "element" : "id",
                              "transform" : "uuid"
                            }
                          ]
                        },
                        {
                          "name" : "setfullUrl",
                          "source" : [
                            {
                              "context" : "src"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "medReq",
                              "contextType" : "variable",
                              "element" : "id",
                              "variable" : "medReqId"
                            },
                            {
                              "context" : "medReqEntry",
                              "contextType" : "variable",
                              "element" : "fullUrl",
                              "transform" : "append",
                              "parameter" : [
                                {
                                  "valueString" : "urn:uuid:"
                                },
                                {
                                  "valueId" : "medReqId"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "medreqmeta",
                          "source" : [
                            {
                              "context" : "prescribedGroup"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "medReq",
                              "contextType" : "variable",
                              "element" : "meta",
                              "variable" : "meta",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Meta"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "medreqprofile",
                              "source" : [
                                {
                                  "context" : "prescribedGroup"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "meta",
                                  "contextType" : "variable",
                                  "element" : "profile",
                                  "transform" : "copy",
                                  "parameter" : [
                                    {
                                      "valueString" : "https://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-medication-request"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "setsubject",
                          "source" : [
                            {
                              "context" : "prescribedGroup"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "medReq",
                              "contextType" : "variable",
                              "element" : "subject",
                              "variable" : "ref",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Reference"
                                }
                              ]
                            },
                            {
                              "context" : "patient",
                              "contextType" : "variable",
                              "element" : "id",
                              "variable" : "patId"
                            },
                            {
                              "context" : "ref",
                              "contextType" : "variable",
                              "element" : "reference",
                              "transform" : "append",
                              "parameter" : [
                                {
                                  "valueString" : "Patient/"
                                },
                                {
                                  "valueId" : "patId"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "setstatus",
                          "source" : [
                            {
                              "context" : "prescribedGroup"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "medReq",
                              "contextType" : "variable",
                              "element" : "status",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueString" : "active"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "setintent",
                          "source" : [
                            {
                              "context" : "prescribedGroup"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "medReq",
                              "contextType" : "variable",
                              "element" : "intent",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueString" : "order"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "navPrescribedMedication",
                          "source" : [
                            {
                              "context" : "prescribedGroup",
                              "element" : "answer",
                              "variable" : "prescribedMedication"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "navAtcItem",
                              "source" : [
                                {
                                  "context" : "prescribedMedication",
                                  "element" : "item",
                                  "variable" : "atcItem",
                                  "condition" : "(linkId = '1923143398283')"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "setAtcCoding",
                                  "source" : [
                                    {
                                      "context" : "atcItem",
                                      "element" : "answer",
                                      "variable" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "medReq",
                                      "contextType" : "variable",
                                      "element" : "medication",
                                      "variable" : "medReqCC",
                                      "transform" : "create",
                                      "parameter" : [
                                        {
                                          "valueString" : "CodeableConcept"
                                        }
                                      ]
                                    },
                                    {
                                      "context" : "medReqCC",
                                      "contextType" : "variable",
                                      "element" : "coding",
                                      "variable" : "medReqC"
                                    },
                                    {
                                      "context" : "medReqC",
                                      "contextType" : "variable",
                                      "element" : "code",
                                      "transform" : "evaluate",
                                      "parameter" : [
                                        {
                                          "valueString" : "%ans.valueString"
                                        }
                                      ]
                                    },
                                    {
                                      "context" : "medReqC",
                                      "contextType" : "variable",
                                      "element" : "display",
                                      "transform" : "evaluate",
                                      "parameter" : [
                                        {
                                          "valueString" : "%prescribedMedication.valueString"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "setdosage",
                          "source" : [
                            {
                              "context" : "prescribedGroup"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "medReq",
                              "contextType" : "variable",
                              "element" : "dosageInstruction",
                              "variable" : "dosage",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Dosage"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "navPrescribedMedication",
                              "source" : [
                                {
                                  "context" : "prescribedGroup",
                                  "element" : "answer",
                                  "variable" : "prescribedMedication"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "navRouteItem",
                                  "source" : [
                                    {
                                      "context" : "prescribedMedication",
                                      "element" : "item",
                                      "variable" : "routeItem",
                                      "condition" : "(linkId = '387026794874')"
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "setroute",
                                      "source" : [
                                        {
                                          "context" : "routeItem",
                                          "element" : "answer",
                                          "variable" : "ans"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "dosage",
                                          "contextType" : "variable",
                                          "element" : "route",
                                          "variable" : "route"
                                        }
                                      ],
                                      "rule" : [
                                        {
                                          "name" : "setroutecoding",
                                          "source" : [
                                            {
                                              "context" : "ans"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "route",
                                              "contextType" : "variable",
                                              "element" : "coding",
                                              "variable" : "routeCoding"
                                            },
                                            {
                                              "context" : "routeCoding",
                                              "contextType" : "variable",
                                              "element" : "code",
                                              "transform" : "evaluate",
                                              "parameter" : [
                                                {
                                                  "valueString" : "%ans.valueString"
                                                }
                                              ]
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "navPoso",
                              "source" : [
                                {
                                  "context" : "medExpoGroup",
                                  "element" : "item",
                                  "variable" : "posoGroup",
                                  "condition" : "(linkId = '6348237104421')"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "dosage",
                                  "contextType" : "variable",
                                  "element" : "timing",
                                  "variable" : "timing"
                                },
                                {
                                  "context" : "timing",
                                  "contextType" : "variable",
                                  "element" : "repeat",
                                  "variable" : "timingRepeat"
                                },
                                {
                                  "context" : "timingRepeat",
                                  "contextType" : "variable",
                                  "element" : "boundsPeriod",
                                  "variable" : "timingPeriod"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "navDateDeb",
                                  "source" : [
                                    {
                                      "context" : "posoGroup",
                                      "element" : "item",
                                      "variable" : "DateDebItem",
                                      "condition" : "(linkId = '316347573327')"
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "setDateDeb",
                                      "source" : [
                                        {
                                          "context" : "DateDebItem",
                                          "element" : "answer",
                                          "variable" : "ans"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "timingPeriod",
                                          "contextType" : "variable",
                                          "element" : "start",
                                          "transform" : "evaluate",
                                          "parameter" : [
                                            {
                                              "valueString" : "%ans.valueDate"
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "navDateFin",
                                  "source" : [
                                    {
                                      "context" : "posoGroup",
                                      "element" : "item",
                                      "variable" : "DateFinItem",
                                      "condition" : "(linkId = '429570775935')"
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "setDateFin",
                                      "source" : [
                                        {
                                          "context" : "DateFinItem",
                                          "element" : "answer",
                                          "variable" : "ans"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "timingPeriod",
                                          "contextType" : "variable",
                                          "element" : "end",
                                          "transform" : "evaluate",
                                          "parameter" : [
                                            {
                                              "valueString" : "%ans.valueDate"
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "CreateMedicationAdministrations",
          "typeMode" : "none",
          "documentation" : "Group: Create Medication Administrations",
          "input" : [
            {
              "name" : "src",
              "type" : "QuestionnaireResponse",
              "mode" : "source"
            },
            {
              "name" : "patient",
              "type" : "Patient",
              "mode" : "target"
            },
            {
              "name" : "bundle",
              "type" : "Bundle",
              "mode" : "target"
            }
          ],
          "rule" : [
            {
              "name" : "processmedexpoadmin",
              "source" : [
                {
                  "context" : "src",
                  "element" : "item",
                  "variable" : "medExpoGroup",
                  "condition" : "(linkId = '817801935685')"
                }
              ],
              "rule" : [
                {
                  "name" : "medadminentry",
                  "source" : [
                    {
                      "context" : "medExpoGroup",
                      "element" : "item",
                      "variable" : "adminGroup",
                      "condition" : "(linkId = '266852453304')"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "bundle",
                      "contextType" : "variable",
                      "element" : "entry",
                      "variable" : "medAdminEntry"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "createmedadmin",
                      "source" : [
                        {
                          "context" : "adminGroup"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "medAdminEntry",
                          "contextType" : "variable",
                          "element" : "resource",
                          "variable" : "medAdmin",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "MedicationAdministration"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "medadminid",
                          "source" : [
                            {
                              "context" : "adminGroup"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "medAdmin",
                              "contextType" : "variable",
                              "element" : "id",
                              "transform" : "uuid"
                            }
                          ]
                        },
                        {
                          "name" : "setfullUrl",
                          "source" : [
                            {
                              "context" : "src"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "medAdmin",
                              "contextType" : "variable",
                              "element" : "id",
                              "variable" : "medAdminId"
                            },
                            {
                              "context" : "medAdminEntry",
                              "contextType" : "variable",
                              "element" : "fullUrl",
                              "transform" : "append",
                              "parameter" : [
                                {
                                  "valueString" : "urn:uuid:"
                                },
                                {
                                  "valueId" : "medAdminId"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "medadminmeta",
                          "source" : [
                            {
                              "context" : "adminGroup"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "medAdmin",
                              "contextType" : "variable",
                              "element" : "meta",
                              "variable" : "meta",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Meta"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "medadminprofile",
                              "source" : [
                                {
                                  "context" : "adminGroup"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "meta",
                                  "contextType" : "variable",
                                  "element" : "profile",
                                  "transform" : "copy",
                                  "parameter" : [
                                    {
                                      "valueString" : "https://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-medication-administration"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "setsubject",
                          "source" : [
                            {
                              "context" : "adminGroup"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "medAdmin",
                              "contextType" : "variable",
                              "element" : "subject",
                              "variable" : "ref",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Reference"
                                }
                              ]
                            },
                            {
                              "context" : "patient",
                              "contextType" : "variable",
                              "element" : "id",
                              "variable" : "patId"
                            },
                            {
                              "context" : "ref",
                              "contextType" : "variable",
                              "element" : "reference",
                              "transform" : "append",
                              "parameter" : [
                                {
                                  "valueString" : "Patient/"
                                },
                                {
                                  "valueId" : "patId"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "setstatus",
                          "source" : [
                            {
                              "context" : "adminGroup"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "medAdmin",
                              "contextType" : "variable",
                              "element" : "status",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueString" : "completed"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "navadministeredMedication",
                          "source" : [
                            {
                              "context" : "adminGroup",
                              "element" : "answer",
                              "variable" : "administeredMedication"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "navAtcItem",
                              "source" : [
                                {
                                  "context" : "administeredMedication",
                                  "element" : "item",
                                  "variable" : "atcItem",
                                  "condition" : "(linkId = '631972144976')"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "setAtcCoding",
                                  "source" : [
                                    {
                                      "context" : "atcItem",
                                      "element" : "answer",
                                      "variable" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "medAdmin",
                                      "contextType" : "variable",
                                      "element" : "medication",
                                      "variable" : "medAdminCC",
                                      "transform" : "create",
                                      "parameter" : [
                                        {
                                          "valueString" : "CodeableConcept"
                                        }
                                      ]
                                    },
                                    {
                                      "context" : "medAdminCC",
                                      "contextType" : "variable",
                                      "element" : "coding",
                                      "variable" : "medAdminC"
                                    },
                                    {
                                      "context" : "medAdminC",
                                      "contextType" : "variable",
                                      "element" : "code",
                                      "transform" : "evaluate",
                                      "parameter" : [
                                        {
                                          "valueString" : "%ans.valueString"
                                        }
                                      ]
                                    },
                                    {
                                      "context" : "medAdminC",
                                      "contextType" : "variable",
                                      "element" : "display",
                                      "transform" : "evaluate",
                                      "parameter" : [
                                        {
                                          "valueString" : "%administeredMedication.valueString"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "setdosage",
                          "source" : [
                            {
                              "context" : "adminGroup"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "medAdmin",
                              "contextType" : "variable",
                              "element" : "dosage",
                              "variable" : "dosage"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "navadministeredMedication",
                              "source" : [
                                {
                                  "context" : "adminGroup",
                                  "element" : "answer",
                                  "variable" : "administeredMedication"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "navRoute",
                                  "source" : [
                                    {
                                      "context" : "administeredMedication",
                                      "element" : "item",
                                      "variable" : "routeItem",
                                      "condition" : "(linkId = '811931484859')"
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "setroute",
                                      "source" : [
                                        {
                                          "context" : "routeItem",
                                          "element" : "answer",
                                          "variable" : "ans"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "dosage",
                                          "contextType" : "variable",
                                          "element" : "route",
                                          "variable" : "route",
                                          "transform" : "create",
                                          "parameter" : [
                                            {
                                              "valueString" : "CodeableConcept"
                                            }
                                          ]
                                        }
                                      ],
                                      "rule" : [
                                        {
                                          "name" : "setroutecoding",
                                          "source" : [
                                            {
                                              "context" : "ans"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "route",
                                              "contextType" : "variable",
                                              "element" : "coding",
                                              "variable" : "routeCoding"
                                            },
                                            {
                                              "context" : "routeCoding",
                                              "contextType" : "variable",
                                              "element" : "code",
                                              "transform" : "evaluate",
                                              "parameter" : [
                                                {
                                                  "valueString" : "%ans.valueString"
                                                }
                                              ]
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "navDosage",
                              "source" : [
                                {
                                  "context" : "medExpoGroup",
                                  "element" : "item",
                                  "variable" : "doseGroup",
                                  "condition" : "(linkId = '5720103839343')"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "navquantity",
                                  "source" : [
                                    {
                                      "context" : "doseGroup",
                                      "element" : "item",
                                      "variable" : "quantityItem",
                                      "condition" : "(linkId = '4765772671997')"
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "setDose",
                                      "source" : [
                                        {
                                          "context" : "quantityItem",
                                          "element" : "answer",
                                          "variable" : "ans"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "dosage",
                                          "contextType" : "variable",
                                          "element" : "dose",
                                          "transform" : "evaluate",
                                          "parameter" : [
                                            {
                                              "valueString" : "%ans.valueQuantity"
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "navStart",
                                  "source" : [
                                    {
                                      "context" : "doseGroup",
                                      "element" : "item",
                                      "variable" : "startItem",
                                      "condition" : "(linkId = '1443558617577')"
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "navStartAns",
                                      "source" : [
                                        {
                                          "context" : "startItem",
                                          "element" : "answer",
                                          "variable" : "startAns"
                                        }
                                      ],
                                      "rule" : [
                                        {
                                          "name" : "navEnd",
                                          "source" : [
                                            {
                                              "context" : "doseGroup",
                                              "element" : "item",
                                              "variable" : "endItem",
                                              "condition" : "(linkId = '780829110731')"
                                            }
                                          ],
                                          "rule" : [
                                            {
                                              "name" : "setAdminPeriod",
                                              "source" : [
                                                {
                                                  "context" : "endItem",
                                                  "element" : "answer",
                                                  "variable" : "endAns"
                                                }
                                              ],
                                              "target" : [
                                                {
                                                  "context" : "medAdmin",
                                                  "contextType" : "variable",
                                                  "element" : "effectivePeriod",
                                                  "variable" : "adminPeriod"
                                                },
                                                {
                                                  "context" : "adminPeriod",
                                                  "contextType" : "variable",
                                                  "element" : "start",
                                                  "transform" : "evaluate",
                                                  "parameter" : [
                                                    {
                                                      "valueString" : "%startAns.value"
                                                    }
                                                  ]
                                                },
                                                {
                                                  "context" : "adminPeriod",
                                                  "contextType" : "variable",
                                                  "element" : "end",
                                                  "transform" : "evaluate",
                                                  "parameter" : [
                                                    {
                                                      "valueString" : "%endAns.value"
                                                    }
                                                  ]
                                                }
                                              ]
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "CreateVitalSignObservations",
          "typeMode" : "none",
          "documentation" : "Group: Create Vital Sign Observations",
          "input" : [
            {
              "name" : "src",
              "type" : "QuestionnaireResponse",
              "mode" : "source"
            },
            {
              "name" : "patient",
              "type" : "Patient",
              "mode" : "target"
            },
            {
              "name" : "bundle",
              "type" : "Bundle",
              "mode" : "target"
            }
          ],
          "rule" : [
            {
              "name" : "processexam",
              "source" : [
                {
                  "context" : "src",
                  "element" : "item",
                  "variable" : "examGroup",
                  "condition" : "(linkId = '214880328197')"
                }
              ],
              "rule" : [
                {
                  "name" : "processdossier",
                  "source" : [
                    {
                      "context" : "examGroup",
                      "element" : "item",
                      "variable" : "dossierGroup",
                      "condition" : "(linkId = '305831246173')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "extractheight",
                      "source" : [
                        {
                          "context" : "dossierGroup",
                          "element" : "item",
                          "variable" : "heightItem",
                          "condition" : "(linkId = '4846902346416')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "heightobsentry",
                          "source" : [
                            {
                              "context" : "heightItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable",
                              "element" : "entry",
                              "variable" : "obsEntry"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "createheightobs",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "obsEntry",
                                  "contextType" : "variable",
                                  "element" : "resource",
                                  "variable" : "obs",
                                  "transform" : "create",
                                  "parameter" : [
                                    {
                                      "valueString" : "Observation"
                                    }
                                  ]
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "obsid",
                                  "source" : [
                                    {
                                      "context" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "obs",
                                      "contextType" : "variable",
                                      "element" : "id",
                                      "transform" : "uuid"
                                    }
                                  ]
                                },
                                {
                                  "name" : "setfullUrl",
                                  "source" : [
                                    {
                                      "context" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "obs",
                                      "contextType" : "variable",
                                      "element" : "id",
                                      "variable" : "obsId"
                                    },
                                    {
                                      "context" : "obsEntry",
                                      "contextType" : "variable",
                                      "element" : "fullUrl",
                                      "transform" : "append",
                                      "parameter" : [
                                        {
                                          "valueString" : "urn:uuid:"
                                        },
                                        {
                                          "valueId" : "obsId"
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "obsmeta",
                                  "source" : [
                                    {
                                      "context" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "obs",
                                      "contextType" : "variable",
                                      "element" : "meta",
                                      "variable" : "meta",
                                      "transform" : "create",
                                      "parameter" : [
                                        {
                                          "valueString" : "Meta"
                                        }
                                      ]
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "obsprofile",
                                      "source" : [
                                        {
                                          "context" : "ans"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "meta",
                                          "contextType" : "variable",
                                          "element" : "profile",
                                          "transform" : "copy",
                                          "parameter" : [
                                            {
                                              "valueString" : "https://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-observation-body-height"
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "obsstatus",
                                  "source" : [
                                    {
                                      "context" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "obs",
                                      "contextType" : "variable",
                                      "element" : "status",
                                      "transform" : "copy",
                                      "parameter" : [
                                        {
                                          "valueString" : "final"
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "obscategory",
                                  "source" : [
                                    {
                                      "context" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "obs",
                                      "contextType" : "variable",
                                      "element" : "category",
                                      "transform" : "cc",
                                      "parameter" : [
                                        {
                                          "valueString" : "http://terminology.hl7.org/CodeSystem/observation-category"
                                        },
                                        {
                                          "valueString" : "vital-signs"
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "obscode",
                                  "source" : [
                                    {
                                      "context" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "obs",
                                      "contextType" : "variable",
                                      "element" : "code",
                                      "transform" : "cc",
                                      "parameter" : [
                                        {
                                          "valueString" : "http://loinc.org"
                                        },
                                        {
                                          "valueString" : "8302-2"
                                        },
                                        {
                                          "valueString" : "Body height"
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "setsubject",
                                  "source" : [
                                    {
                                      "context" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "obs",
                                      "contextType" : "variable",
                                      "element" : "subject",
                                      "variable" : "ref",
                                      "transform" : "create",
                                      "parameter" : [
                                        {
                                          "valueString" : "Reference"
                                        }
                                      ]
                                    },
                                    {
                                      "context" : "patient",
                                      "contextType" : "variable",
                                      "element" : "id",
                                      "variable" : "patId"
                                    },
                                    {
                                      "context" : "ref",
                                      "contextType" : "variable",
                                      "element" : "reference",
                                      "transform" : "append",
                                      "parameter" : [
                                        {
                                          "valueString" : "Patient/"
                                        },
                                        {
                                          "valueId" : "patId"
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "setvalue",
                                  "source" : [
                                    {
                                      "context" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "obs",
                                      "contextType" : "variable",
                                      "element" : "value",
                                      "variable" : "tgtObsVal",
                                      "transform" : "evaluate",
                                      "parameter" : [
                                        {
                                          "valueString" : "%ans.valueQuantity"
                                        }
                                      ]
                                    },
                                    {
                                      "context" : "tgtObsVal",
                                      "contextType" : "variable",
                                      "element" : "code",
                                      "transform" : "evaluate",
                                      "parameter" : [
                                        {
                                          "valueString" : "%ans.valueQuantity.unit"
                                        }
                                      ]
                                    },
                                    {
                                      "context" : "tgtObsVal",
                                      "contextType" : "variable",
                                      "element" : "system",
                                      "transform" : "copy",
                                      "parameter" : [
                                        {
                                          "valueString" : "http://unitsofmeasure.org"
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "extracteffective",
                                  "source" : [
                                    {
                                      "context" : "ans",
                                      "element" : "item",
                                      "variable" : "dateItem",
                                      "condition" : "(linkId = '941821315470')"
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "navDateAns",
                                      "source" : [
                                        {
                                          "context" : "dateItem",
                                          "element" : "answer",
                                          "variable" : "dateAns"
                                        }
                                      ],
                                      "rule" : [
                                        {
                                          "name" : "seteffective",
                                          "source" : [
                                            {
                                              "context" : "dateAns",
                                              "element" : "value",
                                              "variable" : "val"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "obs",
                                              "contextType" : "variable",
                                              "element" : "effective",
                                              "transform" : "cast",
                                              "parameter" : [
                                                {
                                                  "valueId" : "val"
                                                },
                                                {
                                                  "valueString" : "dateTime"
                                                }
                                              ]
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractweight",
                      "source" : [
                        {
                          "context" : "dossierGroup",
                          "element" : "item",
                          "variable" : "weightItem",
                          "condition" : "(linkId = '451513217936')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "weightobsentry",
                          "source" : [
                            {
                              "context" : "weightItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable",
                              "element" : "entry",
                              "variable" : "obsEntry"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "createweightobs",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "obsEntry",
                                  "contextType" : "variable",
                                  "element" : "resource",
                                  "variable" : "obs",
                                  "transform" : "create",
                                  "parameter" : [
                                    {
                                      "valueString" : "Observation"
                                    }
                                  ]
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "obsid",
                                  "source" : [
                                    {
                                      "context" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "obs",
                                      "contextType" : "variable",
                                      "element" : "id",
                                      "transform" : "uuid"
                                    }
                                  ]
                                },
                                {
                                  "name" : "setfullUrl",
                                  "source" : [
                                    {
                                      "context" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "obs",
                                      "contextType" : "variable",
                                      "element" : "id",
                                      "variable" : "obsId"
                                    },
                                    {
                                      "context" : "obsEntry",
                                      "contextType" : "variable",
                                      "element" : "fullUrl",
                                      "transform" : "append",
                                      "parameter" : [
                                        {
                                          "valueString" : "urn:uuid:"
                                        },
                                        {
                                          "valueId" : "obsId"
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "obsmeta",
                                  "source" : [
                                    {
                                      "context" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "obs",
                                      "contextType" : "variable",
                                      "element" : "meta",
                                      "variable" : "meta",
                                      "transform" : "create",
                                      "parameter" : [
                                        {
                                          "valueString" : "Meta"
                                        }
                                      ]
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "obsprofile",
                                      "source" : [
                                        {
                                          "context" : "ans"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "meta",
                                          "contextType" : "variable",
                                          "element" : "profile",
                                          "transform" : "copy",
                                          "parameter" : [
                                            {
                                              "valueString" : "https://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-observation-body-weight"
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "obsstatus",
                                  "source" : [
                                    {
                                      "context" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "obs",
                                      "contextType" : "variable",
                                      "element" : "status",
                                      "transform" : "copy",
                                      "parameter" : [
                                        {
                                          "valueString" : "final"
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "obscategory",
                                  "source" : [
                                    {
                                      "context" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "obs",
                                      "contextType" : "variable",
                                      "element" : "category",
                                      "transform" : "cc",
                                      "parameter" : [
                                        {
                                          "valueString" : "http://terminology.hl7.org/CodeSystem/observation-category"
                                        },
                                        {
                                          "valueString" : "vital-signs"
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "obscode",
                                  "source" : [
                                    {
                                      "context" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "obs",
                                      "contextType" : "variable",
                                      "element" : "code",
                                      "transform" : "cc",
                                      "parameter" : [
                                        {
                                          "valueString" : "http://loinc.org"
                                        },
                                        {
                                          "valueString" : "29463-7"
                                        },
                                        {
                                          "valueString" : "Body weight"
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "setsubject",
                                  "source" : [
                                    {
                                      "context" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "obs",
                                      "contextType" : "variable",
                                      "element" : "subject",
                                      "variable" : "ref",
                                      "transform" : "create",
                                      "parameter" : [
                                        {
                                          "valueString" : "Reference"
                                        }
                                      ]
                                    },
                                    {
                                      "context" : "patient",
                                      "contextType" : "variable",
                                      "element" : "id",
                                      "variable" : "patId"
                                    },
                                    {
                                      "context" : "ref",
                                      "contextType" : "variable",
                                      "element" : "reference",
                                      "transform" : "append",
                                      "parameter" : [
                                        {
                                          "valueString" : "Patient/"
                                        },
                                        {
                                          "valueId" : "patId"
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "setvalue",
                                  "source" : [
                                    {
                                      "context" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "obs",
                                      "contextType" : "variable",
                                      "element" : "value",
                                      "variable" : "tgtObsVal",
                                      "transform" : "evaluate",
                                      "parameter" : [
                                        {
                                          "valueString" : "%ans.valueQuantity"
                                        }
                                      ]
                                    },
                                    {
                                      "context" : "tgtObsVal",
                                      "contextType" : "variable",
                                      "element" : "code",
                                      "transform" : "evaluate",
                                      "parameter" : [
                                        {
                                          "valueString" : "%ans.valueQuantity.unit"
                                        }
                                      ]
                                    },
                                    {
                                      "context" : "tgtObsVal",
                                      "contextType" : "variable",
                                      "element" : "system",
                                      "transform" : "copy",
                                      "parameter" : [
                                        {
                                          "valueString" : "http://unitsofmeasure.org"
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "extracteffective",
                                  "source" : [
                                    {
                                      "context" : "ans",
                                      "element" : "item",
                                      "variable" : "dateItem",
                                      "condition" : "(linkId = '151269044052')"
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "navDateAns",
                                      "source" : [
                                        {
                                          "context" : "dateItem",
                                          "element" : "answer",
                                          "variable" : "dateAns"
                                        }
                                      ],
                                      "rule" : [
                                        {
                                          "name" : "seteffective",
                                          "source" : [
                                            {
                                              "context" : "dateAns",
                                              "element" : "value",
                                              "variable" : "val"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "obs",
                                              "contextType" : "variable",
                                              "element" : "effective",
                                              "transform" : "cast",
                                              "parameter" : [
                                                {
                                                  "valueId" : "val"
                                                },
                                                {
                                                  "valueString" : "dateTime"
                                                }
                                              ]
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractbloodpressure",
                      "source" : [
                        {
                          "context" : "dossierGroup",
                          "element" : "item",
                          "variable" : "sysItem",
                          "condition" : "(linkId = '4160905247955')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "processsystolic",
                          "source" : [
                            {
                              "context" : "sysItem",
                              "element" : "answer",
                              "variable" : "sysAns"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "extractdiastolic",
                              "source" : [
                                {
                                  "context" : "dossierGroup",
                                  "element" : "item",
                                  "variable" : "diaItem",
                                  "condition" : "(linkId = '848797127998')"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "bpobsentr",
                                  "source" : [
                                    {
                                      "context" : "diaItem",
                                      "element" : "answer",
                                      "variable" : "diaAns"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "bundle",
                                      "contextType" : "variable",
                                      "element" : "entry",
                                      "variable" : "obsEntry"
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "createbpobs",
                                      "source" : [
                                        {
                                          "context" : "sysAns"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "obsEntry",
                                          "contextType" : "variable",
                                          "element" : "resource",
                                          "variable" : "obs",
                                          "transform" : "create",
                                          "parameter" : [
                                            {
                                              "valueString" : "Observation"
                                            }
                                          ]
                                        }
                                      ],
                                      "rule" : [
                                        {
                                          "name" : "obsid",
                                          "source" : [
                                            {
                                              "context" : "sysAns"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "obs",
                                              "contextType" : "variable",
                                              "element" : "id",
                                              "transform" : "uuid"
                                            }
                                          ]
                                        },
                                        {
                                          "name" : "setfullUrl",
                                          "source" : [
                                            {
                                              "context" : "sysAns"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "obs",
                                              "contextType" : "variable",
                                              "element" : "id",
                                              "variable" : "obsId"
                                            },
                                            {
                                              "context" : "obsEntry",
                                              "contextType" : "variable",
                                              "element" : "fullUrl",
                                              "transform" : "append",
                                              "parameter" : [
                                                {
                                                  "valueString" : "urn:uuid:"
                                                },
                                                {
                                                  "valueId" : "obsId"
                                                }
                                              ]
                                            }
                                          ]
                                        },
                                        {
                                          "name" : "obsmeta",
                                          "source" : [
                                            {
                                              "context" : "sysAns"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "obs",
                                              "contextType" : "variable",
                                              "element" : "meta",
                                              "variable" : "meta",
                                              "transform" : "create",
                                              "parameter" : [
                                                {
                                                  "valueString" : "Meta"
                                                }
                                              ]
                                            }
                                          ],
                                          "rule" : [
                                            {
                                              "name" : "obsprofile",
                                              "source" : [
                                                {
                                                  "context" : "sysAns"
                                                }
                                              ],
                                              "target" : [
                                                {
                                                  "context" : "meta",
                                                  "contextType" : "variable",
                                                  "element" : "profile",
                                                  "transform" : "copy",
                                                  "parameter" : [
                                                    {
                                                      "valueString" : "https://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-observation-blood-pressure"
                                                    }
                                                  ]
                                                }
                                              ]
                                            }
                                          ]
                                        },
                                        {
                                          "name" : "obsstatus",
                                          "source" : [
                                            {
                                              "context" : "sysAns"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "obs",
                                              "contextType" : "variable",
                                              "element" : "status",
                                              "transform" : "copy",
                                              "parameter" : [
                                                {
                                                  "valueString" : "final"
                                                }
                                              ]
                                            }
                                          ]
                                        },
                                        {
                                          "name" : "obscategory",
                                          "source" : [
                                            {
                                              "context" : "sysAns"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "obs",
                                              "contextType" : "variable",
                                              "element" : "category",
                                              "transform" : "cc",
                                              "parameter" : [
                                                {
                                                  "valueString" : "http://terminology.hl7.org/CodeSystem/observation-category"
                                                },
                                                {
                                                  "valueString" : "vital-signs"
                                                }
                                              ]
                                            }
                                          ]
                                        },
                                        {
                                          "name" : "obscode",
                                          "source" : [
                                            {
                                              "context" : "sysAns"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "obs",
                                              "contextType" : "variable",
                                              "element" : "code",
                                              "transform" : "cc",
                                              "parameter" : [
                                                {
                                                  "valueString" : "http://loinc.org"
                                                },
                                                {
                                                  "valueString" : "85354-9"
                                                },
                                                {
                                                  "valueString" : "Blood pressure panel"
                                                }
                                              ]
                                            }
                                          ]
                                        },
                                        {
                                          "name" : "setsubject",
                                          "source" : [
                                            {
                                              "context" : "sysAns"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "obs",
                                              "contextType" : "variable",
                                              "element" : "subject",
                                              "variable" : "ref",
                                              "transform" : "create",
                                              "parameter" : [
                                                {
                                                  "valueString" : "Reference"
                                                }
                                              ]
                                            },
                                            {
                                              "context" : "patient",
                                              "contextType" : "variable",
                                              "element" : "id",
                                              "variable" : "patId"
                                            },
                                            {
                                              "context" : "ref",
                                              "contextType" : "variable",
                                              "element" : "reference",
                                              "transform" : "append",
                                              "parameter" : [
                                                {
                                                  "valueString" : "Patient/"
                                                },
                                                {
                                                  "valueId" : "patId"
                                                }
                                              ]
                                            }
                                          ]
                                        },
                                        {
                                          "name" : "setsystolic",
                                          "source" : [
                                            {
                                              "context" : "sysAns"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "obs",
                                              "contextType" : "variable",
                                              "element" : "component",
                                              "variable" : "sysComp"
                                            }
                                          ],
                                          "rule" : [
                                            {
                                              "name" : "syscode",
                                              "source" : [
                                                {
                                                  "context" : "sysAns"
                                                }
                                              ],
                                              "target" : [
                                                {
                                                  "context" : "sysComp",
                                                  "contextType" : "variable",
                                                  "element" : "code",
                                                  "transform" : "cc",
                                                  "parameter" : [
                                                    {
                                                      "valueString" : "http://loinc.org"
                                                    },
                                                    {
                                                      "valueString" : "8480-6"
                                                    },
                                                    {
                                                      "valueString" : "Systolic blood pressure"
                                                    }
                                                  ]
                                                }
                                              ]
                                            },
                                            {
                                              "name" : "sysvalue",
                                              "source" : [
                                                {
                                                  "context" : "sysAns"
                                                }
                                              ],
                                              "target" : [
                                                {
                                                  "context" : "sysComp",
                                                  "contextType" : "variable",
                                                  "element" : "value",
                                                  "variable" : "sysVal",
                                                  "transform" : "evaluate",
                                                  "parameter" : [
                                                    {
                                                      "valueString" : "%sysAns.valueQuantity"
                                                    }
                                                  ]
                                                },
                                                {
                                                  "context" : "sysVal",
                                                  "contextType" : "variable",
                                                  "element" : "code",
                                                  "transform" : "evaluate",
                                                  "parameter" : [
                                                    {
                                                      "valueString" : "%sysAns.valueQuantity.unit"
                                                    }
                                                  ]
                                                },
                                                {
                                                  "context" : "sysVal",
                                                  "contextType" : "variable",
                                                  "element" : "system",
                                                  "transform" : "copy",
                                                  "parameter" : [
                                                    {
                                                      "valueString" : "http://unitsofmeasure.org"
                                                    }
                                                  ]
                                                }
                                              ]
                                            }
                                          ]
                                        },
                                        {
                                          "name" : "setdiastolic",
                                          "source" : [
                                            {
                                              "context" : "diaAns"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "obs",
                                              "contextType" : "variable",
                                              "element" : "component",
                                              "variable" : "diaComp"
                                            }
                                          ],
                                          "rule" : [
                                            {
                                              "name" : "diacode",
                                              "source" : [
                                                {
                                                  "context" : "diaAns"
                                                }
                                              ],
                                              "target" : [
                                                {
                                                  "context" : "diaComp",
                                                  "contextType" : "variable",
                                                  "element" : "code",
                                                  "transform" : "cc",
                                                  "parameter" : [
                                                    {
                                                      "valueString" : "http://loinc.org"
                                                    },
                                                    {
                                                      "valueString" : "8462-4"
                                                    },
                                                    {
                                                      "valueString" : "Diastolic blood pressure"
                                                    }
                                                  ]
                                                }
                                              ]
                                            },
                                            {
                                              "name" : "diavalue",
                                              "source" : [
                                                {
                                                  "context" : "diaAns"
                                                }
                                              ],
                                              "target" : [
                                                {
                                                  "context" : "diaComp",
                                                  "contextType" : "variable",
                                                  "element" : "value",
                                                  "variable" : "diaVal",
                                                  "transform" : "evaluate",
                                                  "parameter" : [
                                                    {
                                                      "valueString" : "%diaAns.valueQuantity"
                                                    }
                                                  ]
                                                },
                                                {
                                                  "context" : "diaVal",
                                                  "contextType" : "variable",
                                                  "element" : "code",
                                                  "transform" : "evaluate",
                                                  "parameter" : [
                                                    {
                                                      "valueString" : "%diaAns.valueQuantity.unit"
                                                    }
                                                  ]
                                                },
                                                {
                                                  "context" : "diaVal",
                                                  "contextType" : "variable",
                                                  "element" : "system",
                                                  "transform" : "copy",
                                                  "parameter" : [
                                                    {
                                                      "valueString" : "http://unitsofmeasure.org"
                                                    }
                                                  ]
                                                }
                                              ]
                                            }
                                          ]
                                        },
                                        {
                                          "name" : "navDate",
                                          "source" : [
                                            {
                                              "context" : "sysAns",
                                              "element" : "item",
                                              "variable" : "sysDateItem",
                                              "condition" : "(linkId = '987654638442')"
                                            }
                                          ],
                                          "rule" : [
                                            {
                                              "name" : "navDateAns",
                                              "source" : [
                                                {
                                                  "context" : "sysDateItem",
                                                  "element" : "answer",
                                                  "variable" : "dateAns"
                                                }
                                              ],
                                              "rule" : [
                                                {
                                                  "name" : "seteffective",
                                                  "source" : [
                                                    {
                                                      "context" : "dateAns",
                                                      "element" : "value",
                                                      "variable" : "val"
                                                    }
                                                  ],
                                                  "target" : [
                                                    {
                                                      "context" : "obs",
                                                      "contextType" : "variable",
                                                      "element" : "effective",
                                                      "transform" : "cast",
                                                      "parameter" : [
                                                        {
                                                          "valueId" : "val"
                                                        },
                                                        {
                                                          "valueString" : "dateTime"
                                                        }
                                                      ]
                                                    }
                                                  ]
                                                }
                                              ]
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "CreateLaboratoryObservations",
          "typeMode" : "none",
          "documentation" : "Group: Create Laboratory Observations",
          "input" : [
            {
              "name" : "src",
              "type" : "QuestionnaireResponse",
              "mode" : "source"
            },
            {
              "name" : "patient",
              "type" : "Patient",
              "mode" : "target"
            },
            {
              "name" : "bundle",
              "type" : "Bundle",
              "mode" : "target"
            }
          ],
          "rule" : [
            {
              "name" : "processbiology",
              "source" : [
                {
                  "context" : "src",
                  "element" : "item",
                  "variable" : "bioGroup",
                  "condition" : "(linkId = '7702944131447')"
                }
              ],
              "rule" : [
                {
                  "name" : "processrenal",
                  "source" : [
                    {
                      "context" : "bioGroup",
                      "element" : "item",
                      "variable" : "renalGroup",
                      "condition" : "(linkId = '5241323453538')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "extracturea",
                      "source" : [
                        {
                          "context" : "renalGroup",
                          "element" : "item",
                          "variable" : "ureaItem",
                          "condition" : "(linkId = '7169026818760')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createureaobs",
                          "source" : [
                            {
                              "context" : "ureaItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable"
                            }
                          ],
                          "dependent" : [
                            {
                              "name" : "CreateLabObservation",
                              "variable" : [
                                "ans",
                                "ureaItem",
                                "patient",
                                "bundle"
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractcreat",
                      "source" : [
                        {
                          "context" : "renalGroup",
                          "element" : "item",
                          "variable" : "creatItem",
                          "condition" : "(linkId = '500408205043')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createcreatobs",
                          "source" : [
                            {
                              "context" : "creatItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable"
                            }
                          ],
                          "dependent" : [
                            {
                              "name" : "CreateLabObservation",
                              "variable" : [
                                "ans",
                                "creatItem",
                                "patient",
                                "bundle"
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractdfg",
                      "source" : [
                        {
                          "context" : "renalGroup",
                          "element" : "item",
                          "variable" : "dfgItem",
                          "condition" : "(linkId = '786621340679')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createdfgobs",
                          "source" : [
                            {
                              "context" : "dfgItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable"
                            }
                          ],
                          "dependent" : [
                            {
                              "name" : "CreateLabObservation",
                              "variable" : [
                                "ans",
                                "dfgItem",
                                "patient",
                                "bundle"
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "processhemo",
                  "source" : [
                    {
                      "context" : "bioGroup",
                      "element" : "item",
                      "variable" : "hemoGroup",
                      "condition" : "(linkId = '419282985970')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "extractleuko",
                      "source" : [
                        {
                          "context" : "hemoGroup",
                          "element" : "item",
                          "variable" : "leukoItem",
                          "condition" : "(linkId = '210077225604')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createleukoobs",
                          "source" : [
                            {
                              "context" : "leukoItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable"
                            }
                          ],
                          "dependent" : [
                            {
                              "name" : "CreateLabObservation",
                              "variable" : [
                                "ans",
                                "leukoItem",
                                "patient",
                                "bundle"
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extracthemo",
                      "source" : [
                        {
                          "context" : "hemoGroup",
                          "element" : "item",
                          "variable" : "hemoItem",
                          "condition" : "(linkId = '304159088493')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createhemoobs",
                          "source" : [
                            {
                              "context" : "hemoItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable"
                            }
                          ],
                          "dependent" : [
                            {
                              "name" : "CreateLabObservation",
                              "variable" : [
                                "ans",
                                "hemoItem",
                                "patient",
                                "bundle"
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extracthemat",
                      "source" : [
                        {
                          "context" : "hemoGroup",
                          "element" : "item",
                          "variable" : "hematItem",
                          "condition" : "(linkId = '813863316705')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createhematobs",
                          "source" : [
                            {
                              "context" : "hematItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable"
                            }
                          ],
                          "dependent" : [
                            {
                              "name" : "CreateLabObservation",
                              "variable" : [
                                "ans",
                                "hematItem",
                                "patient",
                                "bundle"
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractery",
                      "source" : [
                        {
                          "context" : "hemoGroup",
                          "element" : "item",
                          "variable" : "eryItem",
                          "condition" : "(linkId = '459731866614')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createeryobs",
                          "source" : [
                            {
                              "context" : "eryItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable"
                            }
                          ],
                          "dependent" : [
                            {
                              "name" : "CreateLabObservation",
                              "variable" : [
                                "ans",
                                "eryItem",
                                "patient",
                                "bundle"
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractvgm",
                      "source" : [
                        {
                          "context" : "hemoGroup",
                          "element" : "item",
                          "variable" : "vgmItem",
                          "condition" : "(linkId = '163624088831')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createvgmobs",
                          "source" : [
                            {
                              "context" : "vgmItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable"
                            }
                          ],
                          "dependent" : [
                            {
                              "name" : "CreateLabObservation",
                              "variable" : [
                                "ans",
                                "vgmItem",
                                "patient",
                                "bundle"
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractplat",
                      "source" : [
                        {
                          "context" : "hemoGroup",
                          "element" : "item",
                          "variable" : "platItem",
                          "condition" : "(linkId = '794156787471')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createplatobs",
                          "source" : [
                            {
                              "context" : "platItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable"
                            }
                          ],
                          "dependent" : [
                            {
                              "name" : "CreateLabObservation",
                              "variable" : [
                                "ans",
                                "platItem",
                                "patient",
                                "bundle"
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractneut",
                      "source" : [
                        {
                          "context" : "hemoGroup",
                          "element" : "item",
                          "variable" : "neutItem",
                          "condition" : "(linkId = '961905168477')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createneutobs",
                          "source" : [
                            {
                              "context" : "neutItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable"
                            }
                          ],
                          "dependent" : [
                            {
                              "name" : "CreateLabObservation",
                              "variable" : [
                                "ans",
                                "neutItem",
                                "patient",
                                "bundle"
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractlymph",
                      "source" : [
                        {
                          "context" : "hemoGroup",
                          "element" : "item",
                          "variable" : "lymphItem",
                          "condition" : "(linkId = '695150914696')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createlymphobs",
                          "source" : [
                            {
                              "context" : "lymphItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable"
                            }
                          ],
                          "dependent" : [
                            {
                              "name" : "CreateLabObservation",
                              "variable" : [
                                "ans",
                                "lymphItem",
                                "patient",
                                "bundle"
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extracteosi",
                      "source" : [
                        {
                          "context" : "hemoGroup",
                          "element" : "item",
                          "variable" : "eosiItem",
                          "condition" : "(linkId = '700490326748')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createeosiobs",
                          "source" : [
                            {
                              "context" : "eosiItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable"
                            }
                          ],
                          "dependent" : [
                            {
                              "name" : "CreateLabObservation",
                              "variable" : [
                                "ans",
                                "eosiItem",
                                "patient",
                                "bundle"
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractmono",
                      "source" : [
                        {
                          "context" : "hemoGroup",
                          "element" : "item",
                          "variable" : "monoItem",
                          "condition" : "(linkId = '168661900522')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createmonoobs",
                          "source" : [
                            {
                              "context" : "monoItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable"
                            }
                          ],
                          "dependent" : [
                            {
                              "name" : "CreateLabObservation",
                              "variable" : [
                                "ans",
                                "monoItem",
                                "patient",
                                "bundle"
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extracttp",
                      "source" : [
                        {
                          "context" : "hemoGroup",
                          "element" : "item",
                          "variable" : "tpItem",
                          "condition" : "(linkId = '658898841893')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createtpobs",
                          "source" : [
                            {
                              "context" : "tpItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable"
                            }
                          ],
                          "dependent" : [
                            {
                              "name" : "CreateLabObservation",
                              "variable" : [
                                "ans",
                                "tpItem",
                                "patient",
                                "bundle"
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extracttca",
                      "source" : [
                        {
                          "context" : "hemoGroup",
                          "element" : "item",
                          "variable" : "tcaItem",
                          "condition" : "(linkId = '795145096241')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createtcaobs",
                          "source" : [
                            {
                              "context" : "tcaItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable"
                            }
                          ],
                          "dependent" : [
                            {
                              "name" : "CreateLabObservation",
                              "variable" : [
                                "ans",
                                "tcaItem",
                                "patient",
                                "bundle"
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "processliver",
                  "source" : [
                    {
                      "context" : "bioGroup",
                      "element" : "item",
                      "variable" : "liverGroup",
                      "condition" : "(linkId = '796308115381')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "extractasat",
                      "source" : [
                        {
                          "context" : "liverGroup",
                          "element" : "item",
                          "variable" : "asatItem",
                          "condition" : "(linkId = '715226319725')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createasatobs",
                          "source" : [
                            {
                              "context" : "asatItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable"
                            }
                          ],
                          "dependent" : [
                            {
                              "name" : "CreateLabObservation",
                              "variable" : [
                                "ans",
                                "asatItem",
                                "patient",
                                "bundle"
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractalat",
                      "source" : [
                        {
                          "context" : "liverGroup",
                          "element" : "item",
                          "variable" : "alatItem",
                          "condition" : "(linkId = '876439410327')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createalatobs",
                          "source" : [
                            {
                              "context" : "alatItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable"
                            }
                          ],
                          "dependent" : [
                            {
                              "name" : "CreateLabObservation",
                              "variable" : [
                                "ans",
                                "alatItem",
                                "patient",
                                "bundle"
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractggt",
                      "source" : [
                        {
                          "context" : "liverGroup",
                          "element" : "item",
                          "variable" : "ggtItem",
                          "condition" : "(linkId = '287545455976')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createggtobs",
                          "source" : [
                            {
                              "context" : "ggtItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable"
                            }
                          ],
                          "dependent" : [
                            {
                              "name" : "CreateLabObservation",
                              "variable" : [
                                "ans",
                                "ggtItem",
                                "patient",
                                "bundle"
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractpal",
                      "source" : [
                        {
                          "context" : "liverGroup",
                          "element" : "item",
                          "variable" : "palItem",
                          "condition" : "(linkId = '508269571594')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createpalobs",
                          "source" : [
                            {
                              "context" : "palItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable"
                            }
                          ],
                          "dependent" : [
                            {
                              "name" : "CreateLabObservation",
                              "variable" : [
                                "ans",
                                "palItem",
                                "patient",
                                "bundle"
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractbiltot",
                      "source" : [
                        {
                          "context" : "liverGroup",
                          "element" : "item",
                          "variable" : "bilTotItem",
                          "condition" : "(linkId = '927344090061')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createbiltotobs",
                          "source" : [
                            {
                              "context" : "bilTotItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable"
                            }
                          ],
                          "dependent" : [
                            {
                              "name" : "CreateLabObservation",
                              "variable" : [
                                "ans",
                                "bilTotItem",
                                "patient",
                                "bundle"
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractbilconj",
                      "source" : [
                        {
                          "context" : "liverGroup",
                          "element" : "item",
                          "variable" : "bilConjItem",
                          "condition" : "(linkId = '208196328453')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createbilconjobs",
                          "source" : [
                            {
                              "context" : "bilConjItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable"
                            }
                          ],
                          "dependent" : [
                            {
                              "name" : "CreateLabObservation",
                              "variable" : [
                                "ans",
                                "bilConjItem",
                                "patient",
                                "bundle"
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "processglucose",
                  "source" : [
                    {
                      "context" : "bioGroup",
                      "element" : "item",
                      "variable" : "glucoseGroup",
                      "condition" : "(linkId = '334039497382')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "extractglyc",
                      "source" : [
                        {
                          "context" : "glucoseGroup",
                          "element" : "item",
                          "variable" : "glycItem",
                          "condition" : "(linkId = '273778921448')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createglycobs",
                          "source" : [
                            {
                              "context" : "glycItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable"
                            }
                          ],
                          "dependent" : [
                            {
                              "name" : "CreateLabObservation",
                              "variable" : [
                                "ans",
                                "glycItem",
                                "patient",
                                "bundle"
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extracthba1c",
                      "source" : [
                        {
                          "context" : "glucoseGroup",
                          "element" : "item",
                          "variable" : "hba1cItem",
                          "condition" : "(linkId = '632894677152')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createhba1cobs",
                          "source" : [
                            {
                              "context" : "hba1cItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable"
                            }
                          ],
                          "dependent" : [
                            {
                              "name" : "CreateLabObservation",
                              "variable" : [
                                "ans",
                                "hba1cItem",
                                "patient",
                                "bundle"
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "CreateLabObservation",
          "typeMode" : "none",
          "documentation" : "Helper: Create a single Laboratory Observation",
          "input" : [
            {
              "name" : "ans",
              "mode" : "source"
            },
            {
              "name" : "parentItem",
              "mode" : "source"
            },
            {
              "name" : "patient",
              "type" : "Patient",
              "mode" : "target"
            },
            {
              "name" : "bundle",
              "type" : "Bundle",
              "mode" : "target"
            }
          ],
          "rule" : [
            {
              "name" : "obsentry",
              "source" : [
                {
                  "context" : "ans"
                }
              ],
              "target" : [
                {
                  "context" : "bundle",
                  "contextType" : "variable",
                  "element" : "entry",
                  "variable" : "obsEntry"
                }
              ],
              "rule" : [
                {
                  "name" : "createobs",
                  "source" : [
                    {
                      "context" : "ans"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "obsEntry",
                      "contextType" : "variable",
                      "element" : "resource",
                      "variable" : "obs",
                      "transform" : "create",
                      "parameter" : [
                        {
                          "valueString" : "Observation"
                        }
                      ]
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "obsid",
                      "source" : [
                        {
                          "context" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "obs",
                          "contextType" : "variable",
                          "element" : "id",
                          "transform" : "uuid"
                        }
                      ]
                    },
                    {
                      "name" : "setfullUrl",
                      "source" : [
                        {
                          "context" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "obs",
                          "contextType" : "variable",
                          "element" : "id",
                          "variable" : "obsId"
                        },
                        {
                          "context" : "obsEntry",
                          "contextType" : "variable",
                          "element" : "fullUrl",
                          "transform" : "append",
                          "parameter" : [
                            {
                              "valueString" : "urn:uuid:"
                            },
                            {
                              "valueId" : "obsId"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "obsmeta",
                      "source" : [
                        {
                          "context" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "obs",
                          "contextType" : "variable",
                          "element" : "meta",
                          "variable" : "meta",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Meta"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "obsprofile",
                          "source" : [
                            {
                              "context" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "meta",
                              "contextType" : "variable",
                              "element" : "profile",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueString" : "https://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/dm-observation-laboratory-generic"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "obsstatus",
                      "source" : [
                        {
                          "context" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "obs",
                          "contextType" : "variable",
                          "element" : "status",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "final"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "setcategory",
                      "source" : [
                        {
                          "context" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "obs",
                          "contextType" : "variable",
                          "element" : "category",
                          "variable" : "cat",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "CodeableConcept"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "setcategorycoding",
                          "source" : [
                            {
                              "context" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "cat",
                              "contextType" : "variable",
                              "element" : "coding",
                              "variable" : "coding",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Coding"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "catsystem",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "coding",
                                  "contextType" : "variable",
                                  "element" : "system",
                                  "transform" : "copy",
                                  "parameter" : [
                                    {
                                      "valueString" : "http://terminology.hl7.org/CodeSystem/observation-category"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "catcode",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "coding",
                                  "contextType" : "variable",
                                  "element" : "code",
                                  "transform" : "copy",
                                  "parameter" : [
                                    {
                                      "valueString" : "laboratory"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "setsubject",
                      "source" : [
                        {
                          "context" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "obs",
                          "contextType" : "variable",
                          "element" : "subject",
                          "variable" : "ref",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Reference"
                            }
                          ]
                        },
                        {
                          "context" : "patient",
                          "contextType" : "variable",
                          "element" : "id",
                          "variable" : "patId"
                        },
                        {
                          "context" : "ref",
                          "contextType" : "variable",
                          "element" : "reference",
                          "transform" : "append",
                          "parameter" : [
                            {
                              "valueString" : "Patient/"
                            },
                            {
                              "valueId" : "patId"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "setvalue",
                      "source" : [
                        {
                          "context" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "obs",
                          "contextType" : "variable",
                          "element" : "value",
                          "variable" : "tgtObsVal",
                          "transform" : "evaluate",
                          "parameter" : [
                            {
                              "valueString" : "%ans.valueQuantity"
                            }
                          ]
                        },
                        {
                          "context" : "tgtObsVal",
                          "contextType" : "variable",
                          "element" : "code",
                          "transform" : "evaluate",
                          "parameter" : [
                            {
                              "valueString" : "%ans.valueQuantity.unit"
                            }
                          ]
                        },
                        {
                          "context" : "tgtObsVal",
                          "contextType" : "variable",
                          "element" : "system",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "http://unitsofmeasure.org"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractloinc",
                      "source" : [
                        {
                          "context" : "ans",
                          "element" : "item",
                          "variable" : "loincItem",
                          "condition" : "(text.contains('code loinc'))"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "setloinccoding",
                          "source" : [
                            {
                              "context" : "loincItem",
                              "element" : "answer",
                              "variable" : "loincAns"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "obs",
                              "contextType" : "variable",
                              "element" : "code",
                              "variable" : "code"
                            },
                            {
                              "context" : "code",
                              "contextType" : "variable",
                              "element" : "coding",
                              "variable" : "coding"
                            },
                            {
                              "context" : "coding",
                              "contextType" : "variable",
                              "element" : "code",
                              "transform" : "evaluate",
                              "parameter" : [
                                {
                                  "valueString" : "%loincAns.valueString"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extracteffective",
                      "source" : [
                        {
                          "context" : "ans",
                          "element" : "item",
                          "variable" : "dateItem",
                          "condition" : "(text.contains('Date et heure du prélèvement'))"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "seteffective",
                          "source" : [
                            {
                              "context" : "dateItem",
                              "element" : "answer",
                              "variable" : "dateAns"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "obs",
                              "contextType" : "variable",
                              "element" : "effective",
                              "transform" : "evaluate",
                              "parameter" : [
                                {
                                  "valueString" : "%dateAns.valueDateTime"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "setrefrange",
                      "source" : [
                        {
                          "context" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "obs",
                          "contextType" : "variable",
                          "element" : "referenceRange",
                          "variable" : "refRange"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "extractlow",
                          "source" : [
                            {
                              "context" : "ans",
                              "element" : "item",
                              "variable" : "lowItem",
                              "condition" : "(text.contains('Borne inférieure'))"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "setlow",
                              "source" : [
                                {
                                  "context" : "lowItem",
                                  "element" : "answer",
                                  "variable" : "lowAns"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "refRange",
                                  "contextType" : "variable",
                                  "element" : "low",
                                  "variable" : "tgtLow",
                                  "transform" : "evaluate",
                                  "parameter" : [
                                    {
                                      "valueString" : "%lowAns.valueQuantity"
                                    }
                                  ]
                                },
                                {
                                  "context" : "tgtLow",
                                  "contextType" : "variable",
                                  "element" : "code",
                                  "transform" : "evaluate",
                                  "parameter" : [
                                    {
                                      "valueString" : "%ans.valueQuantity.unit"
                                    }
                                  ]
                                },
                                {
                                  "context" : "tgtLow",
                                  "contextType" : "variable",
                                  "element" : "system",
                                  "transform" : "copy",
                                  "parameter" : [
                                    {
                                      "valueString" : "http://unitsofmeasure.org"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "extracthigh",
                          "source" : [
                            {
                              "context" : "ans",
                              "element" : "item",
                              "variable" : "highItem",
                              "condition" : "(text.contains('Borne supérieure'))"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "sethigh",
                              "source" : [
                                {
                                  "context" : "highItem",
                                  "element" : "answer",
                                  "variable" : "highAns"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "refRange",
                                  "contextType" : "variable",
                                  "element" : "high",
                                  "variable" : "tgtHigh",
                                  "transform" : "evaluate",
                                  "parameter" : [
                                    {
                                      "valueString" : "%highAns.valueQuantity"
                                    }
                                  ]
                                },
                                {
                                  "context" : "tgtHigh",
                                  "contextType" : "variable",
                                  "element" : "code",
                                  "transform" : "evaluate",
                                  "parameter" : [
                                    {
                                      "valueString" : "%ans.valueQuantity.unit"
                                    }
                                  ]
                                },
                                {
                                  "context" : "tgtHigh",
                                  "contextType" : "variable",
                                  "element" : "system",
                                  "transform" : "copy",
                                  "parameter" : [
                                    {
                                      "valueString" : "http://unitsofmeasure.org"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }