Data Management with FHIR 0.1.0 - ci-build

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

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

Draft as of 2026-04-16

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://interop.aphp.fr/ig/fhir/dm/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://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMPatient'</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://interop.aphp.fr/ig/fhir/dm/StructureDefinition/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><b> then</b><span style=\"color: navy\"> {\r\n</span>          ans.valueInteger<b> as </b><span style=\"color: maroon\">valueInteger</span><span style=\"color: navy\"><b> -&gt; </b></span>patient.multipleBirth = <span style=\"color: maroon\">valueInteger</span> <i>&quot;setmultiplebirth&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;navigatevalue&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.valueCoding<b> as </b><span style=\"color: maroon\">valueCoding</span><span style=\"color: navy\"><b> -&gt; </b></span>patient.gender = <b>translate</b><span style=\"color: navy\">(</span><span style=\"color: maroon\">valueCoding</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'https://interop.aphp.fr/ig/fhir/dm/ConceptMap/dpi-gender-2-hl7-gender'</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'code'</span><span style=\"color: navy\">)</span> <i>&quot;setgender&quot;</i><span style=\"color: navy\">;</span>\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://interop.aphp.fr/ig/fhir/dm/StructureDefinition/pmsi-code-geo'</span> <i>&quot;codegeourl&quot;</i><span style=\"color: navy\">;</span>\r\n            ans<span style=\"color: navy\"><b> -&gt; </b></span>ext.value = <span style=\"color: navy\">(</span>ans.valueCoding<span style=\"color: navy\">)</span> <i>&quot;codegeovalue&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;setcodegeoext&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://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMLocation'</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://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMLocation'</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://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMEncounter'</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\">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') <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') <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://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMCondition'</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 = <span style=\"color: navy\">(</span>ans.valueCoding<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://interop.aphp.fr/ig/fhir/dm/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.valueCoding.code<span style=\"color: navy\">)</span> <i>&quot;diagtypecode&quot;</i><span style=\"color: navy\">;</span>\r\n            ans<span style=\"color: navy\"><b> -&gt; </b></span>coding.display = <span style=\"color: navy\">(</span>ans.valueCoding.display<span style=\"color: navy\">)</span> <i>&quot;diagtypedisplay&quot;</i><span style=\"color: navy\">;</span>\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> <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://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMProcedure'</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\">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 = <span style=\"color: navy\">(</span>ans.valueCoding<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> <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        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://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMMedicationRequest'</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\">Create Medication resource and reference</span>\r\n        prescribedGroup<span style=\"color: navy\"><b> -&gt; </b></span>bundle.entry<b> as </b><span style=\"color: maroon\">medEntry</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          prescribedGroup<span style=\"color: navy\"><b> -&gt; </b></span>medEntry.resource = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Medication'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">medication</span><b> then</b><span style=\"color: navy\"> {\r\n</span>            prescribedGroup<span style=\"color: navy\"><b> -&gt; </b></span>medication.id = <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span> <i>&quot;medid&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">// </span><span style=\"color: green\">ATC code from nested items</span>\r\n            prescribedGroup.item<b> as </b><span style=\"color: maroon\">atcItem</span><b> where </b>(linkId.contains('ATC'))<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>medication.code = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'CodeableConcept'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">code</span><b> then</b><span style=\"color: navy\"> {\r\n</span>                ans<span style=\"color: navy\"><b> -&gt; </b></span>code.coding = <span style=\"color: navy\">(</span>ans.valueCoding<span style=\"color: navy\">)</span> <i>&quot;setatccoding&quot;</i><span style=\"color: navy\">;</span>\r\n              <span style=\"color: navy\">}</span> <i>&quot;setmedcode&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">}</span> <i>&quot;extractatc&quot;</i><span style=\"color: navy\">;</span>\r\n            prescribedGroup<span style=\"color: navy\"><b> -&gt; </b></span> medication.id<b> as </b><span style=\"color: maroon\">medId</span><span style=\"color: navy\">, </span> medEntry.fullUrl = <b>append</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'urn:uuid:'</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">medId</span><span style=\"color: navy\">)</span> <i>&quot;setfullUrl&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">// </span><span style=\"color: green\">Link MedicationRequest to Medication</span>\r\n            prescribedGroup<span style=\"color: navy\"><b> -&gt; </b></span> medication.id<b> as </b><span style=\"color: maroon\">medId</span><span style=\"color: navy\">, </span> medReq.medication = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Reference'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">ref</span><span style=\"color: navy\">, </span> ref.reference = <b>append</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Medication/'</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">medId</span><span style=\"color: navy\">)</span> <i>&quot;setmedicationreference&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;createmedication&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;medicationentry&quot;</i><span style=\"color: navy\">;</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.item<b> as </b><span style=\"color: maroon\">routeItem</span><b> where </b>(linkId.contains('voie'))<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 = <span style=\"color: navy\">(</span>ans.valueCoding<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;extractroute&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">// </span><span style=\"color: green\">Timing</span>\r\n          prescribedGroup.item<b> as </b><span style=\"color: maroon\">timingItem</span><b> where </b>(linkId.contains('timing') or linkId.contains('fréquence'))<b> then</b><span style=\"color: navy\"> {\r\n</span>            timingItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>dosage.timing = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Timing'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">timing</span><b> then</b><span style=\"color: navy\"> {\r\n</span>              ans<span style=\"color: navy\"><b> -&gt; </b></span>timing.repeat = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'TimingRepeat'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">repeat</span> <i>&quot;settiming&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">}</span> <i>&quot;settimingstructure&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;extracttiming&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        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://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMMedicationAdministration'</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\">Create Medication resource and reference</span>\r\n        adminGroup<span style=\"color: navy\"><b> -&gt; </b></span>bundle.entry<b> as </b><span style=\"color: maroon\">medEntry</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          adminGroup<span style=\"color: navy\"><b> -&gt; </b></span>medEntry.resource = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Medication'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">medication</span><b> then</b><span style=\"color: navy\"> {\r\n</span>            adminGroup<span style=\"color: navy\"><b> -&gt; </b></span>medication.id = <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span> <i>&quot;medid&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">// </span><span style=\"color: green\">ATC code from nested items</span>\r\n            adminGroup.item<b> as </b><span style=\"color: maroon\">atcItem</span><b> where </b>(linkId.contains('ATC'))<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>medication.code = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'CodeableConcept'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">code</span><b> then</b><span style=\"color: navy\"> {\r\n</span>                ans<span style=\"color: navy\"><b> -&gt; </b></span>code.coding = <span style=\"color: navy\">(</span>ans.valueCoding<span style=\"color: navy\">)</span> <i>&quot;setatccoding&quot;</i><span style=\"color: navy\">;</span>\r\n              <span style=\"color: navy\">}</span> <i>&quot;setmedcode&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">}</span> <i>&quot;extractatc&quot;</i><span style=\"color: navy\">;</span>\r\n            adminGroup<span style=\"color: navy\"><b> -&gt; </b></span> medication.id<b> as </b><span style=\"color: maroon\">medId</span><span style=\"color: navy\">, </span> medEntry.fullUrl = <b>append</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Medication/'</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">medId</span><span style=\"color: navy\">)</span> <i>&quot;setfullUrl&quot;</i><span style=\"color: navy\">;</span>\r\n            <span style=\"color: navy\">// </span><span style=\"color: green\">Link MedicationAdministration to Medication</span>\r\n            adminGroup<span style=\"color: navy\"><b> -&gt; </b></span> medication.id<b> as </b><span style=\"color: maroon\">medId</span><span style=\"color: navy\">, </span> medAdmin.medication = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Reference'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">ref</span><span style=\"color: navy\">, </span> ref.reference = <b>append</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'urn:uuid:'</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">medId</span><span style=\"color: navy\">)</span> <i>&quot;setmedicationreference&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;createmedication&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;medicationentry&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">// </span><span style=\"color: green\">Effective period</span>\r\n        adminGroup<span style=\"color: navy\"><b> -&gt; </b></span>medAdmin.effective = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Period'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">period</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          adminGroup.item<b> as </b><span style=\"color: maroon\">startItem</span><b> where </b>(linkId.contains('début'))<b> then</b><span style=\"color: navy\"> {\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.valueDateTime<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          adminGroup.item<b> as </b><span style=\"color: maroon\">endItem</span><b> where </b>(linkId.contains('fin'))<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.valueDateTime<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;seteffective&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">// </span><span style=\"color: green\">Dosage</span>\r\n        adminGroup<span style=\"color: navy\"><b> -&gt; </b></span>medAdmin.dosage = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Dosage'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">dosage</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          <span style=\"color: navy\">// </span><span style=\"color: green\">Route</span>\r\n          adminGroup.item<b> as </b><span style=\"color: maroon\">routeItem</span><b> where </b>(linkId.contains('voie'))<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 = <span style=\"color: navy\">(</span>ans.valueCoding<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;extractroute&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">// </span><span style=\"color: green\">Dose</span>\r\n          adminGroup.item<b> as </b><span style=\"color: maroon\">doseItem</span><b> where </b>(linkId.contains('dose'))<b> then</b><span style=\"color: navy\"> {\r\n</span>            doseItem.answer<b> as </b><span style=\"color: maroon\">ans</span><span style=\"color: navy\"><b> -&gt; </b></span>dosage.dose = <span style=\"color: navy\">(</span>ans.valueQuantity<span style=\"color: navy\">)</span> <i>&quot;setdose&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;extractdose&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://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMObservationBodyHeight'</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> <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            heightItem.item<b> as </b><span style=\"color: maroon\">dateItem</span><b> where </b>(linkId.contains('Date'))<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.valueDate<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: 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://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMObservationBodyWeight'</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> <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            weightItem.item<b> as </b><span style=\"color: maroon\">dateItem</span><b> where </b>(linkId.contains('Date'))<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.valueDate<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: 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://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMObservationBloodPressure'</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>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Observation'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">sysComp</span><b> then</b><span style=\"color: navy\"> {\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> <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>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Observation'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">diaComp</span><b> then</b><span style=\"color: navy\"> {\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> <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                sysItem.item<b> as </b><span style=\"color: maroon\">dateItem</span><b> where </b>(linkId.contains('Date'))<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.valueDate<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: 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 5687959006070)</span>\r\n      hemoGroup.item<b> as </b><span style=\"color: maroon\">hematItem</span><b> where </b>(linkId = '5687959006070')<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 8697447896867)</span>\r\n      hemoGroup.item<b> as </b><span style=\"color: maroon\">eryItem</span><b> where </b>(linkId = '8697447896867')<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 5584978899134)</span>\r\n      hemoGroup.item<b> as </b><span style=\"color: maroon\">vgmItem</span><b> where </b>(linkId = '5584978899134')<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 2881119993430)</span>\r\n      hemoGroup.item<b> as </b><span style=\"color: maroon\">platItem</span><b> where </b>(linkId = '2881119993430')<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 7408951746270)</span>\r\n      hemoGroup.item<b> as </b><span style=\"color: maroon\">neutItem</span><b> where </b>(linkId = '7408951746270')<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 809808816195)</span>\r\n      hemoGroup.item<b> as </b><span style=\"color: maroon\">lymphItem</span><b> where </b>(linkId = '809808816195')<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 6451887990893)</span>\r\n      hemoGroup.item<b> as </b><span style=\"color: maroon\">eosiItem</span><b> where </b>(linkId = '6451887990893')<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 7935935816936)</span>\r\n      hemoGroup.item<b> as </b><span style=\"color: maroon\">monoItem</span><b> where </b>(linkId = '7935935816936')<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 2055949655770)</span>\r\n      hemoGroup.item<b> as </b><span style=\"color: maroon\">tpItem</span><b> where </b>(linkId = '2055949655770')<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 2527095476817)</span>\r\n      hemoGroup.item<b> as </b><span style=\"color: maroon\">tcaItem</span><b> where </b>(linkId = '2527095476817')<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 3893612773040)</span>\r\n    bioGroup.item<b> as </b><span style=\"color: maroon\">liverGroup</span><b> where </b>(linkId = '3893612773040')<b> then</b><span style=\"color: navy\"> {\r\n</span>      <span style=\"color: navy\">// </span><span style=\"color: green\">ASAT (linkId 3028330976100)</span>\r\n      liverGroup.item<b> as </b><span style=\"color: maroon\">asatItem</span><b> where </b>(linkId = '3028330976100')<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 8486813893880)</span>\r\n      liverGroup.item<b> as </b><span style=\"color: maroon\">alatItem</span><b> where </b>(linkId = '8486813893880')<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 3663296044037)</span>\r\n      liverGroup.item<b> as </b><span style=\"color: maroon\">ggtItem</span><b> where </b>(linkId = '3663296044037')<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 2690026606933)</span>\r\n      liverGroup.item<b> as </b><span style=\"color: maroon\">palItem</span><b> where </b>(linkId = '2690026606933')<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 9068831071023)</span>\r\n      liverGroup.item<b> as </b><span style=\"color: maroon\">bilTotItem</span><b> where </b>(linkId = '9068831071023')<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 8893717988787)</span>\r\n      liverGroup.item<b> as </b><span style=\"color: maroon\">bilConjItem</span><b> where </b>(linkId = '8893717988787')<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 8929068894076)</span>\r\n    bioGroup.item<b> as </b><span style=\"color: maroon\">glucoseGroup</span><b> where </b>(linkId = '8929068894076')<b> then</b><span style=\"color: navy\"> {\r\n</span>      <span style=\"color: navy\">// </span><span style=\"color: green\">Glycémie à jeun (linkId 8193929027997)</span>\r\n      glucoseGroup.item<b> as </b><span style=\"color: maroon\">glycItem</span><b> where </b>(linkId = '8193929027997')<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 7063892830923)</span>\r\n      glucoseGroup.item<b> as </b><span style=\"color: maroon\">hba1cItem</span><b> where </b>(linkId = '7063892830923')<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://interop.aphp.fr/ig/fhir/dm/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> <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      parentItem.item<b> as </b><span style=\"color: maroon\">loincItem</span><b> where </b>(linkId.contains('code loinc'))<b> then</b><span style=\"color: navy\"> {\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>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>          loincAns<span style=\"color: navy\"><b> -&gt; </b></span>code.coding = <span style=\"color: navy\">(</span>loincAns.valueCoding<span style=\"color: navy\">)</span> <i>&quot;setloinccoding&quot;</i><span style=\"color: navy\">;</span>\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;extractloinc&quot;</i><span style=\"color: navy\">;</span>\r\n      parentItem.item<b> as </b><span style=\"color: maroon\">dateItem</span><b> where </b>(linkId.contains('Date et heure du prélèvement'))<b> then</b><span style=\"color: navy\"> {\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: 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://interop.aphp.fr/ig/fhir/dm/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-04-16T14:35:38+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" : "FR"
            }
          ]
        }
      ],
      "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://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMPatient"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "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://interop.aphp.fr/ig/fhir/dm/StructureDefinition/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" : "navigatevalue",
                          "source" : [
                            {
                              "context" : "multipleItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "setmultiplebirth",
                              "source" : [
                                {
                                  "context" : "ans",
                                  "element" : "valueInteger",
                                  "variable" : "valueInteger"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "patient",
                                  "contextType" : "variable",
                                  "element" : "multipleBirth",
                                  "transform" : "copy",
                                  "parameter" : [
                                    {
                                      "valueId" : "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" : "setgender",
                              "source" : [
                                {
                                  "context" : "ans",
                                  "element" : "valueCoding",
                                  "variable" : "valueCoding"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "patient",
                                  "contextType" : "variable",
                                  "element" : "gender",
                                  "transform" : "translate",
                                  "parameter" : [
                                    {
                                      "valueId" : "valueCoding"
                                    },
                                    {
                                      "valueString" : "https://interop.aphp.fr/ig/fhir/dm/ConceptMap/dpi-gender-2-hl7-gender"
                                    },
                                    {
                                      "valueString" : "code"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "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://interop.aphp.fr/ig/fhir/dm/StructureDefinition/pmsi-code-geo"
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "codegeovalue",
                                  "source" : [
                                    {
                                      "context" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "ext",
                                      "contextType" : "variable",
                                      "element" : "value",
                                      "transform" : "evaluate",
                                      "parameter" : [
                                        {
                                          "valueString" : "ans.valueCoding"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "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://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMLocation"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "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://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMLocation"
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "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://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMEncounter"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "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')"
                        }
                      ]
                    },
                    {
                      "name" : "extractmodeout",
                      "source" : [
                        {
                          "context" : "pmsiItem",
                          "element" : "item",
                          "variable" : "modeOutItem",
                          "condition" : "(linkId = '3354867075704')"
                        }
                      ]
                    },
                    {
                      "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://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMCondition"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "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",
                                  "transform" : "evaluate",
                                  "parameter" : [
                                    {
                                      "valueString" : "ans.valueCoding"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "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://interop.aphp.fr/ig/fhir/dm/CodeSystem/pmsi-mco-diag-type"
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "diagtypecode",
                                  "source" : [
                                    {
                                      "context" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "coding",
                                      "contextType" : "variable",
                                      "element" : "code",
                                      "transform" : "evaluate",
                                      "parameter" : [
                                        {
                                          "valueString" : "ans.valueCoding.code"
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "diagtypedisplay",
                                  "source" : [
                                    {
                                      "context" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "coding",
                                      "contextType" : "variable",
                                      "element" : "display",
                                      "transform" : "evaluate",
                                      "parameter" : [
                                        {
                                          "valueString" : "ans.valueCoding.display"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "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" : "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://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMProcedure"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "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",
                                  "transform" : "evaluate",
                                  "parameter" : [
                                    {
                                      "valueString" : "ans.valueCoding"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "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" : "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" : "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://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMMedicationRequest"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "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" : "medicationentry",
                          "source" : [
                            {
                              "context" : "prescribedGroup"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable",
                              "element" : "entry",
                              "variable" : "medEntry"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "createmedication",
                              "source" : [
                                {
                                  "context" : "prescribedGroup"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "medEntry",
                                  "contextType" : "variable",
                                  "element" : "resource",
                                  "variable" : "medication",
                                  "transform" : "create",
                                  "parameter" : [
                                    {
                                      "valueString" : "Medication"
                                    }
                                  ]
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "medid",
                                  "source" : [
                                    {
                                      "context" : "prescribedGroup"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "medication",
                                      "contextType" : "variable",
                                      "element" : "id",
                                      "transform" : "uuid"
                                    }
                                  ]
                                },
                                {
                                  "name" : "extractatc",
                                  "source" : [
                                    {
                                      "context" : "prescribedGroup",
                                      "element" : "item",
                                      "variable" : "atcItem",
                                      "condition" : "(linkId.contains('ATC'))"
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "setmedcode",
                                      "source" : [
                                        {
                                          "context" : "atcItem",
                                          "element" : "answer",
                                          "variable" : "ans"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "medication",
                                          "contextType" : "variable",
                                          "element" : "code",
                                          "variable" : "code",
                                          "transform" : "create",
                                          "parameter" : [
                                            {
                                              "valueString" : "CodeableConcept"
                                            }
                                          ]
                                        }
                                      ],
                                      "rule" : [
                                        {
                                          "name" : "setatccoding",
                                          "source" : [
                                            {
                                              "context" : "ans"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "code",
                                              "contextType" : "variable",
                                              "element" : "coding",
                                              "transform" : "evaluate",
                                              "parameter" : [
                                                {
                                                  "valueString" : "ans.valueCoding"
                                                }
                                              ]
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "setfullUrl",
                                  "source" : [
                                    {
                                      "context" : "prescribedGroup"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "medication",
                                      "contextType" : "variable",
                                      "element" : "id",
                                      "variable" : "medId"
                                    },
                                    {
                                      "context" : "medEntry",
                                      "contextType" : "variable",
                                      "element" : "fullUrl",
                                      "transform" : "append",
                                      "parameter" : [
                                        {
                                          "valueString" : "urn:uuid:"
                                        },
                                        {
                                          "valueId" : "medId"
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "setmedicationreference",
                                  "source" : [
                                    {
                                      "context" : "prescribedGroup"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "medication",
                                      "contextType" : "variable",
                                      "element" : "id",
                                      "variable" : "medId"
                                    },
                                    {
                                      "context" : "medReq",
                                      "contextType" : "variable",
                                      "element" : "medication",
                                      "variable" : "ref",
                                      "transform" : "create",
                                      "parameter" : [
                                        {
                                          "valueString" : "Reference"
                                        }
                                      ]
                                    },
                                    {
                                      "context" : "ref",
                                      "contextType" : "variable",
                                      "element" : "reference",
                                      "transform" : "append",
                                      "parameter" : [
                                        {
                                          "valueString" : "Medication/"
                                        },
                                        {
                                          "valueId" : "medId"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "setdosage",
                          "source" : [
                            {
                              "context" : "prescribedGroup"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "medReq",
                              "contextType" : "variable",
                              "element" : "dosageInstruction",
                              "variable" : "dosage",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Dosage"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "extractroute",
                              "source" : [
                                {
                                  "context" : "prescribedGroup",
                                  "element" : "item",
                                  "variable" : "routeItem",
                                  "condition" : "(linkId.contains('voie'))"
                                }
                              ],
                              "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",
                                          "transform" : "evaluate",
                                          "parameter" : [
                                            {
                                              "valueString" : "ans.valueCoding"
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "extracttiming",
                              "source" : [
                                {
                                  "context" : "prescribedGroup",
                                  "element" : "item",
                                  "variable" : "timingItem",
                                  "condition" : "(linkId.contains('timing') or linkId.contains('fréquence'))"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "settimingstructure",
                                  "source" : [
                                    {
                                      "context" : "timingItem",
                                      "element" : "answer",
                                      "variable" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "dosage",
                                      "contextType" : "variable",
                                      "element" : "timing",
                                      "variable" : "timing",
                                      "transform" : "create",
                                      "parameter" : [
                                        {
                                          "valueString" : "Timing"
                                        }
                                      ]
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "settiming",
                                      "source" : [
                                        {
                                          "context" : "ans"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "timing",
                                          "contextType" : "variable",
                                          "element" : "repeat",
                                          "variable" : "repeat",
                                          "transform" : "create",
                                          "parameter" : [
                                            {
                                              "valueString" : "TimingRepeat"
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "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" : "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://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMMedicationAdministration"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "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" : "medicationentry",
                          "source" : [
                            {
                              "context" : "adminGroup"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable",
                              "element" : "entry",
                              "variable" : "medEntry"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "createmedication",
                              "source" : [
                                {
                                  "context" : "adminGroup"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "medEntry",
                                  "contextType" : "variable",
                                  "element" : "resource",
                                  "variable" : "medication",
                                  "transform" : "create",
                                  "parameter" : [
                                    {
                                      "valueString" : "Medication"
                                    }
                                  ]
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "medid",
                                  "source" : [
                                    {
                                      "context" : "adminGroup"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "medication",
                                      "contextType" : "variable",
                                      "element" : "id",
                                      "transform" : "uuid"
                                    }
                                  ]
                                },
                                {
                                  "name" : "extractatc",
                                  "source" : [
                                    {
                                      "context" : "adminGroup",
                                      "element" : "item",
                                      "variable" : "atcItem",
                                      "condition" : "(linkId.contains('ATC'))"
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "setmedcode",
                                      "source" : [
                                        {
                                          "context" : "atcItem",
                                          "element" : "answer",
                                          "variable" : "ans"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "medication",
                                          "contextType" : "variable",
                                          "element" : "code",
                                          "variable" : "code",
                                          "transform" : "create",
                                          "parameter" : [
                                            {
                                              "valueString" : "CodeableConcept"
                                            }
                                          ]
                                        }
                                      ],
                                      "rule" : [
                                        {
                                          "name" : "setatccoding",
                                          "source" : [
                                            {
                                              "context" : "ans"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "code",
                                              "contextType" : "variable",
                                              "element" : "coding",
                                              "transform" : "evaluate",
                                              "parameter" : [
                                                {
                                                  "valueString" : "ans.valueCoding"
                                                }
                                              ]
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "setfullUrl",
                                  "source" : [
                                    {
                                      "context" : "adminGroup"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "medication",
                                      "contextType" : "variable",
                                      "element" : "id",
                                      "variable" : "medId"
                                    },
                                    {
                                      "context" : "medEntry",
                                      "contextType" : "variable",
                                      "element" : "fullUrl",
                                      "transform" : "append",
                                      "parameter" : [
                                        {
                                          "valueString" : "Medication/"
                                        },
                                        {
                                          "valueId" : "medId"
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "setmedicationreference",
                                  "source" : [
                                    {
                                      "context" : "adminGroup"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "medication",
                                      "contextType" : "variable",
                                      "element" : "id",
                                      "variable" : "medId"
                                    },
                                    {
                                      "context" : "medAdmin",
                                      "contextType" : "variable",
                                      "element" : "medication",
                                      "variable" : "ref",
                                      "transform" : "create",
                                      "parameter" : [
                                        {
                                          "valueString" : "Reference"
                                        }
                                      ]
                                    },
                                    {
                                      "context" : "ref",
                                      "contextType" : "variable",
                                      "element" : "reference",
                                      "transform" : "append",
                                      "parameter" : [
                                        {
                                          "valueString" : "urn:uuid:"
                                        },
                                        {
                                          "valueId" : "medId"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "seteffective",
                          "source" : [
                            {
                              "context" : "adminGroup"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "medAdmin",
                              "contextType" : "variable",
                              "element" : "effective",
                              "variable" : "period",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Period"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "extractstart",
                              "source" : [
                                {
                                  "context" : "adminGroup",
                                  "element" : "item",
                                  "variable" : "startItem",
                                  "condition" : "(linkId.contains('début'))"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "setstart",
                                  "source" : [
                                    {
                                      "context" : "startItem",
                                      "element" : "answer",
                                      "variable" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "period",
                                      "contextType" : "variable",
                                      "element" : "start",
                                      "transform" : "evaluate",
                                      "parameter" : [
                                        {
                                          "valueString" : "ans.valueDateTime"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "extractend",
                              "source" : [
                                {
                                  "context" : "adminGroup",
                                  "element" : "item",
                                  "variable" : "endItem",
                                  "condition" : "(linkId.contains('fin'))"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "setend",
                                  "source" : [
                                    {
                                      "context" : "endItem",
                                      "element" : "answer",
                                      "variable" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "period",
                                      "contextType" : "variable",
                                      "element" : "end",
                                      "transform" : "evaluate",
                                      "parameter" : [
                                        {
                                          "valueString" : "ans.valueDateTime"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "setdosage",
                          "source" : [
                            {
                              "context" : "adminGroup"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "medAdmin",
                              "contextType" : "variable",
                              "element" : "dosage",
                              "variable" : "dosage",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Dosage"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "extractroute",
                              "source" : [
                                {
                                  "context" : "adminGroup",
                                  "element" : "item",
                                  "variable" : "routeItem",
                                  "condition" : "(linkId.contains('voie'))"
                                }
                              ],
                              "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",
                                          "transform" : "evaluate",
                                          "parameter" : [
                                            {
                                              "valueString" : "ans.valueCoding"
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "extractdose",
                              "source" : [
                                {
                                  "context" : "adminGroup",
                                  "element" : "item",
                                  "variable" : "doseItem",
                                  "condition" : "(linkId.contains('dose'))"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "setdose",
                                  "source" : [
                                    {
                                      "context" : "doseItem",
                                      "element" : "answer",
                                      "variable" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "dosage",
                                      "contextType" : "variable",
                                      "element" : "dose",
                                      "transform" : "evaluate",
                                      "parameter" : [
                                        {
                                          "valueString" : "ans.valueQuantity"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "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://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMObservationBodyHeight"
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "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",
                                      "transform" : "evaluate",
                                      "parameter" : [
                                        {
                                          "valueString" : "ans.valueQuantity"
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "extracteffective",
                                  "source" : [
                                    {
                                      "context" : "heightItem",
                                      "element" : "item",
                                      "variable" : "dateItem",
                                      "condition" : "(linkId.contains('Date'))"
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "seteffective",
                                      "source" : [
                                        {
                                          "context" : "dateItem",
                                          "element" : "answer",
                                          "variable" : "dateAns"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "obs",
                                          "contextType" : "variable",
                                          "element" : "effective",
                                          "transform" : "evaluate",
                                          "parameter" : [
                                            {
                                              "valueString" : "dateAns.valueDate"
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "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://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMObservationBodyWeight"
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "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",
                                      "transform" : "evaluate",
                                      "parameter" : [
                                        {
                                          "valueString" : "ans.valueQuantity"
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "extracteffective",
                                  "source" : [
                                    {
                                      "context" : "weightItem",
                                      "element" : "item",
                                      "variable" : "dateItem",
                                      "condition" : "(linkId.contains('Date'))"
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "seteffective",
                                      "source" : [
                                        {
                                          "context" : "dateItem",
                                          "element" : "answer",
                                          "variable" : "dateAns"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "obs",
                                          "contextType" : "variable",
                                          "element" : "effective",
                                          "transform" : "evaluate",
                                          "parameter" : [
                                            {
                                              "valueString" : "dateAns.valueDate"
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "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://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMObservationBloodPressure"
                                                    }
                                                  ]
                                                }
                                              ]
                                            }
                                          ]
                                        },
                                        {
                                          "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",
                                              "transform" : "create",
                                              "parameter" : [
                                                {
                                                  "valueString" : "Observation"
                                                }
                                              ]
                                            }
                                          ],
                                          "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",
                                                  "transform" : "evaluate",
                                                  "parameter" : [
                                                    {
                                                      "valueString" : "sysAns.valueQuantity"
                                                    }
                                                  ]
                                                }
                                              ]
                                            }
                                          ]
                                        },
                                        {
                                          "name" : "setdiastolic",
                                          "source" : [
                                            {
                                              "context" : "diaAns"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "obs",
                                              "contextType" : "variable",
                                              "element" : "component",
                                              "variable" : "diaComp",
                                              "transform" : "create",
                                              "parameter" : [
                                                {
                                                  "valueString" : "Observation"
                                                }
                                              ]
                                            }
                                          ],
                                          "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",
                                                  "transform" : "evaluate",
                                                  "parameter" : [
                                                    {
                                                      "valueString" : "diaAns.valueQuantity"
                                                    }
                                                  ]
                                                }
                                              ]
                                            }
                                          ]
                                        },
                                        {
                                          "name" : "extracteffective",
                                          "source" : [
                                            {
                                              "context" : "sysItem",
                                              "element" : "item",
                                              "variable" : "dateItem",
                                              "condition" : "(linkId.contains('Date'))"
                                            }
                                          ],
                                          "rule" : [
                                            {
                                              "name" : "seteffective",
                                              "source" : [
                                                {
                                                  "context" : "dateItem",
                                                  "element" : "answer",
                                                  "variable" : "dateAns"
                                                }
                                              ],
                                              "target" : [
                                                {
                                                  "context" : "obs",
                                                  "contextType" : "variable",
                                                  "element" : "effective",
                                                  "transform" : "evaluate",
                                                  "parameter" : [
                                                    {
                                                      "valueString" : "dateAns.valueDate"
                                                    }
                                                  ]
                                                }
                                              ]
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "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 = '5687959006070')"
                        }
                      ],
                      "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 = '8697447896867')"
                        }
                      ],
                      "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 = '5584978899134')"
                        }
                      ],
                      "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 = '2881119993430')"
                        }
                      ],
                      "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 = '7408951746270')"
                        }
                      ],
                      "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 = '809808816195')"
                        }
                      ],
                      "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 = '6451887990893')"
                        }
                      ],
                      "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 = '7935935816936')"
                        }
                      ],
                      "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 = '2055949655770')"
                        }
                      ],
                      "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 = '2527095476817')"
                        }
                      ],
                      "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 = '3893612773040')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "extractasat",
                      "source" : [
                        {
                          "context" : "liverGroup",
                          "element" : "item",
                          "variable" : "asatItem",
                          "condition" : "(linkId = '3028330976100')"
                        }
                      ],
                      "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 = '8486813893880')"
                        }
                      ],
                      "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 = '3663296044037')"
                        }
                      ],
                      "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 = '2690026606933')"
                        }
                      ],
                      "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 = '9068831071023')"
                        }
                      ],
                      "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 = '8893717988787')"
                        }
                      ],
                      "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 = '8929068894076')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "extractglyc",
                      "source" : [
                        {
                          "context" : "glucoseGroup",
                          "element" : "item",
                          "variable" : "glycItem",
                          "condition" : "(linkId = '8193929027997')"
                        }
                      ],
                      "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 = '7063892830923')"
                        }
                      ],
                      "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://interop.aphp.fr/ig/fhir/dm/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",
                          "transform" : "evaluate",
                          "parameter" : [
                            {
                              "valueString" : "ans.valueQuantity"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractloinc",
                      "source" : [
                        {
                          "context" : "parentItem",
                          "element" : "item",
                          "variable" : "loincItem",
                          "condition" : "(linkId.contains('code loinc'))"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "setcode",
                          "source" : [
                            {
                              "context" : "loincItem",
                              "element" : "answer",
                              "variable" : "loincAns"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "obs",
                              "contextType" : "variable",
                              "element" : "code",
                              "variable" : "code",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "CodeableConcept"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "setloinccoding",
                              "source" : [
                                {
                                  "context" : "loincAns"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "code",
                                  "contextType" : "variable",
                                  "element" : "coding",
                                  "transform" : "evaluate",
                                  "parameter" : [
                                    {
                                      "valueString" : "loincAns.valueCoding"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extracteffective",
                      "source" : [
                        {
                          "context" : "parentItem",
                          "element" : "item",
                          "variable" : "dateItem",
                          "condition" : "(linkId.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"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }