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 EHR logical model data to FHIR Semantic Layer resources using Bundle as container - JSON Representation

Draft as of 2026-04-16

Raw json | Download

    {
      "resourceType" : "StructureMap",
      "id" : "EHR2FSL",
      "text" : {
        "status" : "generated",
        "div" : "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p class=\"res-header-id\"><b>Narratif généré : StructureMap EHR2FSL</b></p><a name=\"EHR2FSL\"> </a><a name=\"hcEHR2FSL\"> </a><pre class=\"fml\">\r\n<b>map</b><span style=\"color: navy\"> &quot;</span>https://interop.aphp.fr/ig/fhir/dm/StructureMap/EHR2FSL<span style=\"color: navy\">&quot; = &quot;</span>EHR2FSL<span style=\"color: navy\">&quot;\r\n\r\n</span><span style=\"color: navy\">// </span><span style=\"color: green\">Transforms EHR logical model data to FHIR Semantic Layer resources using Bundle as container</span>\r\n\r\n<b>uses</b><span style=\"color: navy\"> &quot;</span>https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/ehr<span style=\"color: navy\">&quot; </span><b>alias </b>EHR <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<b>group </b>EHR2FSL<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">src</span><span style=\"color: navy\"> : </span>EHR, <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><span style=\"color: navy\">(</span>now()<span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">timestamp</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    src<span style=\"color: navy\"><b> -&gt; </b></span>bundle.timestamp = <span style=\"color: maroon\">timestamp</span> <i>&quot;affectTimestamp&quot;</i><span style=\"color: navy\">;</span>\r\n  <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\">Transform Patient</span>\r\n  src.patient<b> as </b><span style=\"color: maroon\">patient</span><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>    patient<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\">dmPatient</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      patient<b> then </b>TransformPatient<span style=\"color: navy\">(</span><span style=\"color: maroon\">patient</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">dmPatient</span><span style=\"color: navy\">)</span> <i>&quot;transformpatient&quot;</i><span style=\"color: navy\">;</span>\r\n      patient<b> then </b>setEntryRequestAndFullUrl<span style=\"color: navy\">(</span><span style=\"color: maroon\">dmPatient</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">patientEntry</span><span style=\"color: navy\">)</span> <i>&quot;setRequestAndFullUrl&quot;</i><span style=\"color: navy\">;</span>\r\n      src.patientAdresse<b> as </b><span style=\"color: maroon\">patientAdresse</span><b> where </b>patientAdresse.patientId = %patient.patientId<b> then </b>setAddress<span style=\"color: navy\">(</span><span style=\"color: maroon\">patientAdresse</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">dmPatient</span><span style=\"color: navy\">)</span> <i>&quot;transformpatientAdresse&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Transform PMSI Encounters</span>\r\n      src.donneesPmsi<b> as </b><span style=\"color: maroon\">pmsi</span><b> where </b>pmsi.patientId = %patient.patientId<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>        pmsi<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\">dmEncounter</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          pmsi<b> then </b>TransformEncounter<span style=\"color: navy\">(</span><span style=\"color: maroon\">pmsi</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">dmEncounter</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">dmPatient</span><span style=\"color: navy\">)</span> <i>&quot;transformencounter&quot;</i><span style=\"color: navy\">;</span>\r\n          pmsi<b> then </b>setEntryRequestAndFullUrl<span style=\"color: navy\">(</span><span style=\"color: maroon\">dmEncounter</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">encounterEntry</span><span style=\"color: navy\">)</span> <i>&quot;setRequestAndFullUrl&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">// </span><span style=\"color: green\">Transform Conditions (Diagnostics)</span>\r\n          src.diagnostics<b> as </b><span style=\"color: maroon\">diag</span><b> where </b>(diag.patientId = %patient.patientId) and (diag.pmsiId = %pmsi.pmsiId)<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>            diag<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\">dmCondition</span><b> then</b><span style=\"color: navy\"> {\r\n</span>              diag<b> then </b>TransformCondition<span style=\"color: navy\">(</span><span style=\"color: maroon\">diag</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">dmCondition</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">dmPatient</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">dmEncounter</span><span style=\"color: navy\">)</span> <i>&quot;transformcondition&quot;</i><span style=\"color: navy\">;</span>\r\n              diag<b> then </b>setEntryRequestAndFullUrl<span style=\"color: navy\">(</span><span style=\"color: maroon\">dmCondition</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">conditionEntry</span><span style=\"color: navy\">)</span> <i>&quot;setRequestAndFullUrl&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;conditionentries&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">// </span><span style=\"color: green\">Transform Procedures (Actes)</span>\r\n          src.actes<b> as </b><span style=\"color: maroon\">acte</span><b> where </b>(acte.patientId = %patient.patientId) and (acte.pmsiId = %pmsi.pmsiId)<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>            acte<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\">dmProcedure</span><b> then</b><span style=\"color: navy\"> {\r\n</span>              acte<b> then </b>TransformProcedure<span style=\"color: navy\">(</span><span style=\"color: maroon\">acte</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">dmProcedure</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">dmPatient</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">dmEncounter</span><span style=\"color: navy\">)</span> <i>&quot;transformprocedure&quot;</i><span style=\"color: navy\">;</span>\r\n              acte<b> then </b>setEntryRequestAndFullUrl<span style=\"color: navy\">(</span><span style=\"color: maroon\">dmProcedure</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">procedureEntry</span><span style=\"color: navy\">)</span> <i>&quot;setRequestAndFullUrl&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;procedureentries&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;encounterentries&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Transform Laboratory Observations</span>\r\n      src.biologie<b> as </b><span style=\"color: maroon\">lab</span><b> where </b>lab.patientId = %patient.patientId<span style=\"color: navy\"><b> -&gt; </b></span>bundle.entry<b> as </b><span style=\"color: maroon\">labEntry</span><b> then</b><span style=\"color: navy\"> {\r\n</span>        lab<span style=\"color: navy\"><b> -&gt; </b></span>labEntry.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\">dmLab</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          lab<b> then </b>TransformLabObservation<span style=\"color: navy\">(</span><span style=\"color: maroon\">lab</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">dmLab</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">dmPatient</span><span style=\"color: navy\">)</span> <i>&quot;transformLabObs&quot;</i><span style=\"color: navy\">;</span>\r\n          lab<b> then </b>setEntryRequestAndFullUrl<span style=\"color: navy\">(</span><span style=\"color: maroon\">dmLab</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">labEntry</span><span style=\"color: navy\">)</span> <i>&quot;setRequestAndFullUrl&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;createlabobs&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;labentries&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Transform Medication Requests</span>\r\n      src.prescription<b> as </b><span style=\"color: maroon\">pres</span><b> where </b>pres.patientId = %patient.patientId<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>        pres<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\">dmMedReq</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          src<b> then </b>TransformMedicationRequest<span style=\"color: navy\">(</span><span style=\"color: maroon\">pres</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">dmMedReq</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">dmPatient</span><span style=\"color: navy\">)</span> <i>&quot;createmedrequest&quot;</i><span style=\"color: navy\">;</span>\r\n          pres<b> then </b>setEntryRequestAndFullUrl<span style=\"color: navy\">(</span><span style=\"color: maroon\">dmMedReq</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">medReqEntry</span><span style=\"color: navy\">)</span> <i>&quot;setRequestAndFullUrl&quot;</i><span style=\"color: navy\">;</span>\r\n          src.posologie<b> as </b><span style=\"color: maroon\">poso</span><b> where </b>%poso.prescriptionId = %pres.prescriptionId<b> then </b>setPoso<span style=\"color: navy\">(</span><span style=\"color: maroon\">poso</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">pres</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">dmMedReq</span><span style=\"color: navy\">)</span> <i>&quot;transformPoso&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">// </span><span style=\"color: green\">Transform Administration (W prescription)</span>\r\n          src.administration<b> as </b><span style=\"color: maroon\">admin</span><b> where </b>(admin.patientId = %patient.patientId) and (admin.prescriptionId = pres.prescriptionId)<span style=\"color: navy\"><b> -&gt; </b></span>bundle.entry<b> as </b><span style=\"color: maroon\">adminEntry</span><b> then</b><span style=\"color: navy\"> {\r\n</span>            admin<span style=\"color: navy\"><b> -&gt; </b></span>adminEntry.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\">dmAdmin</span><b> then</b><span style=\"color: navy\"> {\r\n</span>              admin<b> then </b>TransformMedicationAdministrationWOrder<span style=\"color: navy\">(</span><span style=\"color: maroon\">admin</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">dmAdmin</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">dmPatient</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">dmMedReq</span><span style=\"color: navy\">)</span> <i>&quot;createmedadmin&quot;</i><span style=\"color: navy\">;</span>\r\n              admin<b> then </b>setEntryRequestAndFullUrl<span style=\"color: navy\">(</span><span style=\"color: maroon\">dmAdmin</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">adminEntry</span><span style=\"color: navy\">)</span> <i>&quot;setRequestAndFullUrl&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;administrationentries&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;medicationentries&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Transform Lifestyle Observations - separate observation for each lifestyle element</span>\r\n      src.styleVie<b> as </b><span style=\"color: maroon\">lifestyle</span><b> where </b>lifestyle.patientId = %patient.patientId<b> then</b><span style=\"color: navy\"> {\r\n</span>        <span style=\"color: navy\">// </span><span style=\"color: green\">Tobacco consumption observation</span>\r\n        lifestyle.consommationTabac<b> as </b><span style=\"color: maroon\">tobacco</span><b> where </b>tobacco.exists()<span style=\"color: navy\"><b> -&gt; </b></span>bundle.entry<b> as </b><span style=\"color: maroon\">tobaccoEntry</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          tobacco<span style=\"color: navy\"><b> -&gt; </b></span>tobaccoEntry.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\">tobaccoObs</span><b> then</b><span style=\"color: navy\"> {\r\n</span>            lifestyle<b> then </b>TransformTobaccoObservation<span style=\"color: navy\">(</span><span style=\"color: maroon\">lifestyle</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">tobaccoObs</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">dmPatient</span><span style=\"color: navy\">)</span> <i>&quot;createtobaccoobs&quot;</i><span style=\"color: navy\">;</span>\r\n            lifestyle<b> then </b>setEntryRequestAndFullUrl<span style=\"color: navy\">(</span><span style=\"color: maroon\">tobaccoObs</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">tobaccoEntry</span><span style=\"color: navy\">)</span> <i>&quot;setRequestAndFullUrl&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;createtobaccoobs&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;tobaccoentries&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">// </span><span style=\"color: green\">Alcohol consumption observation</span>\r\n        lifestyle.consommationAlcool<b> as </b><span style=\"color: maroon\">alcohol</span><b> where </b>alcohol.exists()<span style=\"color: navy\"><b> -&gt; </b></span>bundle.entry<b> as </b><span style=\"color: maroon\">alcoholEntry</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          alcohol<span style=\"color: navy\"><b> -&gt; </b></span>alcoholEntry.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\">alcoholObs</span><b> then</b><span style=\"color: navy\"> {\r\n</span>            lifestyle<b> then </b>TransformAlcoholObservation<span style=\"color: navy\">(</span><span style=\"color: maroon\">lifestyle</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">alcoholObs</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">dmPatient</span><span style=\"color: navy\">)</span> <i>&quot;createalcoholobs&quot;</i><span style=\"color: navy\">;</span>\r\n            lifestyle<b> then </b>setEntryRequestAndFullUrl<span style=\"color: navy\">(</span><span style=\"color: maroon\">alcoholObs</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">alcoholEntry</span><span style=\"color: navy\">)</span> <i>&quot;setRequestAndFullUrl&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;createalcoholobs&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;alcoholentries&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">// </span><span style=\"color: green\">Drug consumption observation</span>\r\n        lifestyle.consommationAutresDrogues<b> as </b><span style=\"color: maroon\">drugs</span><b> where </b>drugs.exists()<span style=\"color: navy\"><b> -&gt; </b></span>bundle.entry<b> as </b><span style=\"color: maroon\">drugEntry</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          drugs<span style=\"color: navy\"><b> -&gt; </b></span>drugEntry.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\">drugObs</span><b> then</b><span style=\"color: navy\"> {\r\n</span>            lifestyle<b> then </b>TransformDrugObservation<span style=\"color: navy\">(</span><span style=\"color: maroon\">lifestyle</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">drugObs</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">dmPatient</span><span style=\"color: navy\">)</span> <i>&quot;createdrugobs&quot;</i><span style=\"color: navy\">;</span>\r\n            lifestyle<b> then </b>setEntryRequestAndFullUrl<span style=\"color: navy\">(</span><span style=\"color: maroon\">drugObs</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">drugEntry</span><span style=\"color: navy\">)</span> <i>&quot;setRequestAndFullUrl&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;createdrugobs&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;drugentries&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">// </span><span style=\"color: green\">Physical activity observation</span>\r\n        lifestyle.activitePhysique<b> as </b><span style=\"color: maroon\">physical</span><b> where </b>physical.exists()<span style=\"color: navy\"><b> -&gt; </b></span>bundle.entry<b> as </b><span style=\"color: maroon\">physicalEntry</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          physical<span style=\"color: navy\"><b> -&gt; </b></span>physicalEntry.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\">physicalObs</span><b> then</b><span style=\"color: navy\"> {\r\n</span>            lifestyle<b> then </b>TransformPhysicalActivityObservation<span style=\"color: navy\">(</span><span style=\"color: maroon\">lifestyle</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">physicalObs</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">dmPatient</span><span style=\"color: navy\">)</span> <i>&quot;createphysicalobs&quot;</i><span style=\"color: navy\">;</span>\r\n            lifestyle<b> then </b>setEntryRequestAndFullUrl<span style=\"color: navy\">(</span><span style=\"color: maroon\">physicalObs</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">physicalEntry</span><span style=\"color: navy\">)</span> <i>&quot;setRequestAndFullUrl&quot;</i><span style=\"color: navy\">;</span>\r\n          <span style=\"color: navy\">}</span> <i>&quot;createphysicalobs&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;physicalentries&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;lifestyleentries&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Transform Care Observations (s)</span>\r\n      src.dossierSoins<b> as </b><span style=\"color: maroon\">soin</span><b> where </b>soin.patientId = %patient.patientId<span style=\"color: navy\"><b> -&gt; </b></span>bundle.entry<b> as </b><span style=\"color: maroon\">vitalEntry</span><b> then</b><span style=\"color: navy\"> {\r\n</span>        soin<span style=\"color: navy\"><b> -&gt; </b></span>vitalEntry.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\">dmObs</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          soin<b> then </b>TransformVitalSigns<span style=\"color: navy\">(</span><span style=\"color: maroon\">soin</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">dmObs</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">dmPatient</span><span style=\"color: navy\">)</span> <i>&quot;createmesureobs&quot;</i><span style=\"color: navy\">;</span>\r\n          soin<b> then </b>setEntryRequestAndFullUrl<span style=\"color: navy\">(</span><span style=\"color: maroon\">dmObs</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">vitalEntry</span><span style=\"color: navy\">)</span> <i>&quot;setRequestAndFullUrl&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;createmesureobs&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;vitalentries&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">Transform Administration (WO prescription)</span>\r\n      src.administration<b> as </b><span style=\"color: maroon\">admin</span><b> where </b>(admin.patientId = %patient.patientId) and admin.prescriptionId.empty()<span style=\"color: navy\"><b> -&gt; </b></span>bundle.entry<b> as </b><span style=\"color: maroon\">adminEntry</span><b> then</b><span style=\"color: navy\"> {\r\n</span>        admin<span style=\"color: navy\"><b> -&gt; </b></span>adminEntry.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\">dmAdmin</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          admin<b> then </b>TransformMedicationAdministrationWOOrder<span style=\"color: navy\">(</span><span style=\"color: maroon\">admin</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">dmAdmin</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">dmPatient</span><span style=\"color: navy\">)</span> <i>&quot;createmedadmin&quot;</i><span style=\"color: navy\">;</span>\r\n          admin<b> then </b>setEntryRequestAndFullUrl<span style=\"color: navy\">(</span><span style=\"color: maroon\">dmAdmin</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">adminEntry</span><span style=\"color: navy\">)</span> <i>&quot;setRequestAndFullUrl&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;administrationentries&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;createpatient&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\">---------------------------------------------------------</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">PATIENT TRANSFORMATION</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">---------------------------------------------------------</span>\r\n<b>group </b>TransformPatient<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">src</span>, <b>target</b> <span style=\"color: maroon\">tgt</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>tgt.id = <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span> <i>&quot;setId&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: #b36b00\" title=\"Cet élément n'était pas défini avant R5\">// src.patientId as id -&gt; tgt.id = id &quot;patient-id&quot;;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Identifiers</span>\r\n  src.patientId<b> as </b><span style=\"color: maroon\">pid</span><span style=\"color: navy\"><b> -&gt; </b></span>tgt.identifier<b> as </b><span style=\"color: maroon\">identifier</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    pid<span style=\"color: navy\"><b> -&gt; </b></span>identifier.use = <span style=\"color: blue\">'usual'</span> <i>&quot;iduse&quot;</i><span style=\"color: navy\">;</span>\r\n    pid<span style=\"color: navy\"><b> -&gt; </b></span>identifier.type = <b>cc</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'http://terminology.hl7.org/CodeSystem/v2-0203'</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'PI'</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'Patient Identifier'</span><span style=\"color: navy\">)</span> <i>&quot;idtype&quot;</i><span style=\"color: navy\">;</span>\r\n    pid<span style=\"color: navy\"><b> -&gt; </b></span>identifier.system = <span style=\"color: blue\">'https://hospital.eu/ehr/patient-id'</span> <i>&quot;idsystem&quot;</i><span style=\"color: navy\">;</span>\r\n    pid<span style=\"color: navy\"><b> -&gt; </b></span>identifier.value = <span style=\"color: maroon\">pid</span> <i>&quot;idvalue&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;patientidentifier&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">NIR identifier &lt;- C'est pas terrible côté expression de besoin : qu'est ce qu'ils veulent quand ils disent NIR ? ça peut être le NSS, mais du coup c'est pas un identifier (un NSS peut correspondre à plusieurs ayant droits), et ce serait plutôt une info qui irait côté claim. ça peut aussi être l'ins-nir, mais du coup qu'est ce qu'ils attendent dans l'ins ? Bref, à mon avis, faut discuter cette variable au niveau du GT.</span>\r\n  <span style=\"color: #b36b00\" title=\"Cet élément n'était pas défini avant R5\">// src.nir as nir where nir.exists() -&gt; tgt.identifier as insIdentifier then {     nir -&gt; insIdentifier.use = 'official' &quot;ins-use&quot;;     nir -&gt; insIdentifier.type = cc('http://hl7.fr/fhir/CodeSystem/fr-v2-0203', 'INS-NIR') &quot;ins-type&quot;;     nir -&gt; insIdentifier.system = 'urn:oid:1.2.250.1.213.1.4.8' &quot;ins-system&quot;;     nir -&gt; insIdentifier.value = nir &quot;ins-value&quot;;   } &quot;ins-identifier&quot;;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Alternative INS from ins field</span>\r\n  src.ins<b> as </b><span style=\"color: maroon\">ins</span><b> where </b>ins.exists()<span style=\"color: navy\"><b> -&gt; </b></span>tgt.identifier<b> as </b><span style=\"color: maroon\">insIdentifier</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    ins<span style=\"color: navy\"><b> -&gt; </b></span>insIdentifier.use = <span style=\"color: blue\">'official'</span> <i>&quot;insuse&quot;</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">On part du principe qu'on n'est pas sur un old.</span>\r\n    ins<span style=\"color: navy\"><b> -&gt; </b></span>insIdentifier.type = <b>cc</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'https://hl7.fr/ig/fhir/core/CodeSystem/fr-core-cs-v2-0203'</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'INS-NIR'</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'NIR définitif'</span><span style=\"color: navy\">)</span> <i>&quot;instype&quot;</i><span style=\"color: navy\">;</span>\r\n    ins<span style=\"color: navy\"><b> -&gt; </b></span>insIdentifier.system = <span style=\"color: blue\">'urn:oid:1.2.250.1.213.1.4.8'</span> <i>&quot;inssystem&quot;</i><span style=\"color: navy\">;</span>\r\n    ins<span style=\"color: navy\"><b> -&gt; </b></span>insIdentifier.value = <span style=\"color: maroon\">ins</span> <i>&quot;insvalue&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;insidentifier&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Name</span>\r\n  src<b> where </b>src.nom.exists() or src.prenom.exists()<span style=\"color: navy\"><b> -&gt; </b></span>tgt.name<b> as </b><span style=\"color: maroon\">name</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    src.nom<b> as </b><span style=\"color: maroon\">lastName</span><span style=\"color: navy\"><b> -&gt; </b></span>name.family = <span style=\"color: maroon\">lastName</span> <i>&quot;familyname&quot;</i><span style=\"color: navy\">;</span>\r\n    src.prenom<b> as </b><span style=\"color: maroon\">firstName</span><span style=\"color: navy\"><b> -&gt; </b></span>name.given = <span style=\"color: maroon\">firstName</span> <i>&quot;givenname&quot;</i><span style=\"color: navy\">;</span>\r\n    src<span style=\"color: navy\"><b> -&gt; </b></span>name.use = <span style=\"color: blue\">'official'</span> <i>&quot;nameuse&quot;</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">hypothèse un peu forte.</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;patientname&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Demographics On aurait pu faire plus élégant avec un ConceptMap</span>\r\n  src.dateNaissance<b> as </b><span style=\"color: maroon\">birthDate</span><span style=\"color: navy\"><b> -&gt; </b></span>tgt.birthDate = <span style=\"color: maroon\">birthDate</span> <i>&quot;birthdate&quot;</i><span style=\"color: navy\">;</span>\r\n  src.sexe<b> as </b><span style=\"color: maroon\">gender</span><b> where </b>gender = 'h'<span style=\"color: navy\"><b> -&gt; </b></span>tgt.gender = <span style=\"color: blue\">'male'</span> <i>&quot;gendermale&quot;</i><span style=\"color: navy\">;</span>\r\n  src.sexe<b> as </b><span style=\"color: maroon\">gender</span><b> where </b>gender = 'f'<span style=\"color: navy\"><b> -&gt; </b></span>tgt.gender = <span style=\"color: blue\">'female'</span> <i>&quot;genderfemale&quot;</i><span style=\"color: navy\">;</span>\r\n  src.sexe<b> as </b><span style=\"color: maroon\">gender</span><b> where </b>gender.exists() and (gender != 'h') and (gender != 'f')<span style=\"color: navy\"><b> -&gt; </b></span>tgt.gender = <span style=\"color: blue\">'unknown'</span> <i>&quot;genderunknown&quot;</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">n'a pas grand sens en l'état des contraintes SQL</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Death information</span>\r\n  src.dateDeces<b> as </b><span style=\"color: maroon\">deathDate</span><b> where </b>deathDate.exists()<span style=\"color: navy\"><b> -&gt; </b></span>tgt.deceased = <b>cast</b><span style=\"color: navy\">(</span><span style=\"color: maroon\">deathDate</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'dateTime'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">deceasedDate</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    src.sourceDeces<b> as </b><span style=\"color: maroon\">deathSource</span><b> where </b>deathSource.exists()<span style=\"color: navy\"><b> -&gt; </b></span>deceasedDate.extension<b> as </b><span style=\"color: maroon\">DeathSourceExtension</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      deathSource<span style=\"color: navy\"><b> -&gt; </b></span>DeathSourceExtension.url = <span style=\"color: blue\">'https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DeathSource'</span> <i>&quot;deathSourceUrl&quot;</i><span style=\"color: navy\">;</span>\r\n      deathSource<span style=\"color: navy\"><b> -&gt; </b></span>DeathSourceExtension.value = <b>cast</b><span style=\"color: navy\">(</span><span style=\"color: maroon\">deathSource</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'code'</span><span style=\"color: navy\">)</span> <i>&quot;deathSourceValue&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;deathSource&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;deathDate&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Multiple birth</span>\r\n  src.rangGemellaire<b> as </b><span style=\"color: maroon\">twin</span><b> where </b>twin.exists()<span style=\"color: navy\"><b> -&gt; </b></span>tgt.multipleBirth = <span style=\"color: maroon\">twin</span> <i>&quot;multiplebirth&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\">========================================================================</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">PATIENT_LOCATION TRANSFORMATION</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">========================================================================</span>\r\n<b>group </b>setAddress<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">src</span>, <b>target</b> <span style=\"color: maroon\">tgtPat</span><span style=\"color: navy\"> : </span>Patient<span style=\"color: navy\">)</span><span style=\"color: navy\"> {\r\n</span>  src<b> where </b>src.latitude.exists() or src.longitude.exists() or src.codeIris.exists() or src.libelleIris.exists() or src.codeGeographiqueResidence.exists()<b> then</b><span style=\"color: navy\"> {\r\n</span>    src<span style=\"color: navy\"><b> -&gt; </b></span>tgtPat.address<b> as </b><span style=\"color: maroon\">newAddress</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      src<b> where </b>src.latitude.exists() or src.longitude.exists()<span style=\"color: navy\"><b> -&gt; </b></span> newAddress.extension<b> as </b><span style=\"color: maroon\">geolocationExtension</span><span style=\"color: navy\">, </span> geolocationExtension.url = <span style=\"color: blue\">'http://hl7.org/fhir/StructureDefinition/geolocation'</span><b> then</b><span style=\"color: navy\"> {\r\n</span>        src.latitude<b> as </b><span style=\"color: maroon\">srcLat</span><span style=\"color: navy\"><b> -&gt; </b></span> geolocationExtension.extension<b> as </b><span style=\"color: maroon\">tgtLat</span><span style=\"color: navy\">, </span> tgtLat.url = <span style=\"color: blue\">'latitude'</span><span style=\"color: navy\">, </span> tgtLat.value = <span style=\"color: maroon\">srcLat</span> <i>&quot;setLat&quot;</i><span style=\"color: navy\">;</span>\r\n        src.longitude<b> as </b><span style=\"color: maroon\">srcLong</span><span style=\"color: navy\"><b> -&gt; </b></span> geolocationExtension.extension<b> as </b><span style=\"color: maroon\">tgtLong</span><span style=\"color: navy\">, </span> tgtLong.url = <span style=\"color: blue\">'longitude'</span><span style=\"color: navy\">, </span> tgtLong.value = <span style=\"color: maroon\">srcLong</span> <i>&quot;setLong&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;setCoordinates&quot;</i><span style=\"color: navy\">;</span>\r\n      src<b> where </b>src.codeIris.exists() or src.libelleIris.exists()<span style=\"color: navy\"><b> -&gt; </b></span> newAddress.line = <span style=\"color: navy\">(</span>%src.libelleIris<span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">irisLine</span><span style=\"color: navy\">, </span> irisLine.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\">irisExtension</span><span style=\"color: navy\">, </span> irisExtension.url = <span style=\"color: blue\">'http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-censusTract'</span><span style=\"color: navy\">, </span> irisExtension.value = <span style=\"color: navy\">(</span>%src.codeIris<span style=\"color: navy\">)</span> <i>&quot;setIris&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">src where src.codeIris.exists() or src.libelleIris.exists() -&gt; newAddress.extension as irisExtension,</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">irisExtension.url = 'http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-censusTract',</span>\r\n      <span style=\"color: navy\">// </span><span style=\"color: green\">irisExtension.value = (iif(%src.codeIris.exists() and %src.libelleIris.exists(), %src.codeIris &amp; ' - ' &amp; %src.libelleIris, %src.codeIris &amp; %src.libelleIris)) &quot;setIris&quot;;</span>\r\n      src.codeGeographiqueResidence<b> as </b><span style=\"color: maroon\">srcCodeGeographiqueResidence</span><b> where </b>src.codeGeographiqueResidence.exists()<span style=\"color: navy\"><b> -&gt; </b></span> newAddress.extension<b> as </b><span style=\"color: maroon\">residencePmsiExtension</span><span style=\"color: navy\">, </span> residencePmsiExtension.url = <span style=\"color: blue\">'https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/PmsiCodeGeo'</span><span style=\"color: navy\">, </span> residencePmsiExtension.value = <b>cast</b><span style=\"color: navy\">(</span><span style=\"color: maroon\">srcCodeGeographiqueResidence</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'code'</span><span style=\"color: navy\">)</span> <i>&quot;SetResidencePmsi&quot;</i><span style=\"color: navy\">;</span>\r\n      src.dateRecueil<b> as </b><span style=\"color: maroon\">dateRecueil</span><span style=\"color: navy\"><b> -&gt; </b></span> newAddress.period<b> as </b><span style=\"color: maroon\">newAddressPeriod</span><span style=\"color: navy\">, </span> newAddressPeriod.start = <span style=\"color: maroon\">dateRecueil</span> <i>&quot;setDateRecueil&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;createAddress&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;checkSource&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\">========================================================================</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">ENCOUNTER TRANSFORMATION</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">========================================================================</span>\r\n<b>group </b>TransformEncounter<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">src</span>, <b>target</b> <span style=\"color: maroon\">tgtEnc</span><span style=\"color: navy\"> : </span>Encounter, <b>source</b> <span style=\"color: maroon\">patient</span><span style=\"color: navy\">)</span><span style=\"color: navy\"> {\r\n</span>  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtEnc.id = <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span> <i>&quot;setId&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: #b36b00\" title=\"Cet élément n'était pas défini avant R5\">// src.pmsiId as id -&gt; tgt.id = id &quot;encounter-id&quot;;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Identifier</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtEnc.identifier<b> as </b><span style=\"color: maroon\">identifier</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    src<span style=\"color: navy\"><b> -&gt; </b></span>identifier.type = <b>cc</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'https://hl7.fr/ig/fhir/core/CodeSystem/fr-core-cs-identifier-type'</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'VN'</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'Visit Number'</span><span style=\"color: navy\">)</span> <i>&quot;idtype&quot;</i><span style=\"color: navy\">;</span>\r\n    src<span style=\"color: navy\"><b> -&gt; </b></span>identifier.system = <span style=\"color: blue\">'https://hospital.eu/ehr/pmsi-id'</span> <i>&quot;encounteridsystem&quot;</i><span style=\"color: navy\">;</span>\r\n    src.pmsiId<b> as </b><span style=\"color: maroon\">srcEncoutnerId</span><span style=\"color: navy\"><b> -&gt; </b></span>identifier.value = <span style=\"color: maroon\">srcEncoutnerId</span> <i>&quot;encounteridvalue&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;encounteridentifier&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Status - default to finished for historical data</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtEnc.status = <span style=\"color: blue\">'finished'</span> <i>&quot;encounterstatus&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Class - assume inpatient for PMSI data</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtEnc.class = <b>c</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'http://terminology.hl7.org/CodeSystem/v3-ActCode'</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'IMP'</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'inpatient encounter'</span><span style=\"color: navy\">)</span> <i>&quot;encounterclass&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Reference patient</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtEnc.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><b> then</b><span style=\"color: navy\"> {\r\n</span>    patient.id<b> as </b><span style=\"color: maroon\">patientId</span><span style=\"color: navy\"><b> -&gt; </b></span> ref.reference = <span style=\"color: navy\">(</span>'Patient/' + %patientId<span style=\"color: navy\">)</span><span style=\"color: navy\">, </span> ref.type = <span style=\"color: blue\">'Patient'</span> <i>&quot;subjectreference&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;encountersubject&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Period</span>\r\n  src<b> where </b>src.dateDebutSejour.exists() or src.dateFinSejour.exists()<span style=\"color: navy\"><b> -&gt; </b></span>tgtEnc.period<b> as </b><span style=\"color: maroon\">period</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    src.dateDebutSejour<b> as </b><span style=\"color: maroon\">startDate</span><span style=\"color: navy\"><b> -&gt; </b></span>period.start = <span style=\"color: maroon\">startDate</span> <i>&quot;periodstart&quot;</i><span style=\"color: navy\">;</span>\r\n    src.dateFinSejour<b> as </b><span style=\"color: maroon\">endDate</span><span style=\"color: navy\"><b> -&gt; </b></span>period.end = <span style=\"color: maroon\">endDate</span> <i>&quot;periodend&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;encounterperiod&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Désactivé dans le modèle physique   // Duration   src.dureeSejour as duration -&gt; tgtEnc.length as length then {     duration -&gt; length.value = duration &quot;length-value&quot;;     duration -&gt; length.unit = 'd' &quot;length-unit&quot;;     duration -&gt; length.system = 'http://unitsofmeasure.org' &quot;length-system&quot;;     duration -&gt; length.code = 'd' &quot;length-code&quot;;   } &quot;encounter-length&quot;;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Hospitalization</span>\r\n  src<b> where </b>src.modeEntree.exists() or src.modeSortie.exists()<span style=\"color: navy\"><b> -&gt; </b></span>tgtEnc.hospitalization<b> as </b><span style=\"color: maroon\">hosp</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    src.modeEntree<b> as </b><span style=\"color: maroon\">admitSource</span><span style=\"color: navy\"><b> -&gt; </b></span>hosp.admitSource<b> as </b><span style=\"color: maroon\">admitSrc</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      admitSource<span style=\"color: navy\"><b> -&gt; </b></span>admitSrc.text = <span style=\"color: maroon\">admitSource</span> <i>&quot;admitsourcetext&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;admitsource&quot;</i><span style=\"color: navy\">;</span>\r\n    src.modeSortie<b> as </b><span style=\"color: maroon\">dischargeDisp</span><span style=\"color: navy\"><b> -&gt; </b></span>hosp.dischargeDisposition<b> as </b><span style=\"color: maroon\">dischargeDsp</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      dischargeDisp<span style=\"color: navy\"><b> -&gt; </b></span>dischargeDsp.text = <span style=\"color: maroon\">dischargeDisp</span> <i>&quot;dischargedisptext&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;dischargedisposition&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;encounterhospitalization&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Service Provider</span>\r\n  src<b> where </b>src.uniteFonctionnelle.exists() or src.service.exists() or src.etablissement.exists()<span style=\"color: navy\"><b> -&gt; </b></span>tgtEnc.serviceProvider<b> as </b><span style=\"color: maroon\">provider</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    src<span style=\"color: navy\"><b> -&gt; </b></span>provider.display = <span style=\"color: navy\">(</span>iif(%src.uniteFonctionnelle.exists(), %src.uniteFonctionnelle, iif(%src.service.exists(), %src.service, %src.etablissement))<span style=\"color: navy\">)</span> <i>&quot;providerdisplay&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;provider&quot;</i><span style=\"color: navy\">;</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">// Location - On n'a pas de location à gérer à ce stade (établissement, service et UF, halluciné par l'IA, sont des Organization que j'ai du coup mi dans Provider. )   src.service as service -&gt; tgt.location as location then {     service -&gt; location.location as loc then {       service -&gt; loc.display = service &quot;location-display&quot;;     } &quot;location-ref&quot;;   } &quot;encounter-location&quot;;</span>\r\n<span style=\"color: navy\">}\r\n\r\n</span><span style=\"color: navy\">// </span><span style=\"color: green\">========================================================================</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">CONDITION TRANSFORMATION</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">========================================================================</span>\r\n<b>group </b>TransformCondition<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">src</span>, <b>target</b> <span style=\"color: maroon\">tgtCond</span><span style=\"color: navy\"> : </span>Condition, <b>source</b> <span style=\"color: maroon\">patient</span>, <b>source</b> <span style=\"color: maroon\">encounter</span><span style=\"color: navy\">)</span><span style=\"color: navy\"> {\r\n</span>  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtCond.id = <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span> <i>&quot;setId&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Identifier</span>\r\n  src.diagnosticId<b> as </b><span style=\"color: maroon\">diagId</span><span style=\"color: navy\"><b> -&gt; </b></span>tgtCond.identifier<b> as </b><span style=\"color: maroon\">identifier</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    diagId<span style=\"color: navy\"><b> -&gt; </b></span>identifier.system = <span style=\"color: blue\">'https://hospital.eu/ehr/diagnostic-id'</span> <i>&quot;conditionidsystem&quot;</i><span style=\"color: navy\">;</span>\r\n    diagId<span style=\"color: navy\"><b> -&gt; </b></span>identifier.value = <span style=\"color: maroon\">diagId</span> <i>&quot;conditionidvalue&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;conditionidentifier&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Category</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Représentation des codes diagnostics du PMSI dans condition , plusieurs options :</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">- ce sont des infos de claim, pas de condition</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">- utiliser la catégorie 'encounter-diagnosis'</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">- utiliser les catégories du PMSI : DP, DR, DAS, DAD</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">- mettre les deux précédent &lt;- j'ai fait ça.</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtCond.category = <b>cc</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'http://terminology.hl7.org/CodeSystem/condition-category'</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'encounter-diagnosis'</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'Encounter Diagnosis'</span><span style=\"color: navy\">)</span> <i>&quot;categoryencounterDiag&quot;</i><span style=\"color: navy\">;</span>\r\n  src.typeDiagnostic<b> as </b><span style=\"color: maroon\">diagType</span><span style=\"color: navy\"><b> -&gt; </b></span>tgtCond.category<b> as </b><span style=\"color: maroon\">category</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    diagType<span style=\"color: navy\"><b> -&gt; </b></span>category.text = <span style=\"color: maroon\">diagType</span> <i>&quot;categorytext&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;conditioncategory&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Code (ICD-10)</span>\r\n  src.codeDiagnostic<b> as </b><span style=\"color: maroon\">srcCode</span><span style=\"color: navy\"><b> -&gt; </b></span>tgtCond.code<b> as </b><span style=\"color: maroon\">conditionCode</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    <span style=\"color: navy\">// </span><span style=\"color: green\">la fonction cc ne peuple pas le display...</span>\r\n    src.libelleDiagnostic<b> as </b><span style=\"color: maroon\">label</span><span style=\"color: navy\"><b> -&gt; </b></span> conditionCode.coding<b> as </b><span style=\"color: maroon\">tgtCoding</span><span style=\"color: navy\">, </span> tgtCoding.system = <span style=\"color: blue\">'http://hl7.org/fhir/sid/icd-10'</span><span style=\"color: navy\">, </span> tgtCoding.code = <span style=\"color: maroon\">srcCode</span> <i>&quot;conditioncode&quot;</i><span style=\"color: navy\">;</span>\r\n    src.libelleDiagnostic<b> as </b><span style=\"color: maroon\">text</span><span style=\"color: navy\"><b> -&gt; </b></span>conditionCode.text = <span style=\"color: maroon\">text</span> <i>&quot;codetext&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;varcode&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Subject</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtCond.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><b> then</b><span style=\"color: navy\"> {\r\n</span>    patient.id<b> as </b><span style=\"color: maroon\">patientId</span><span style=\"color: navy\"><b> -&gt; </b></span> ref.reference = <span style=\"color: navy\">(</span>'Patient/' + %patientId<span style=\"color: navy\">)</span><span style=\"color: navy\">, </span> ref.type = <span style=\"color: blue\">'Patient'</span> <i>&quot;subjectref&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;conditionsubject&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Encounter reference</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtCond.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><b> then</b><span style=\"color: navy\"> {\r\n</span>    encounter.id<b> as </b><span style=\"color: maroon\">encounterId</span><span style=\"color: navy\"><b> -&gt; </b></span> ref.reference = <span style=\"color: navy\">(</span>'Encounter/' + %encounterId<span style=\"color: navy\">)</span><span style=\"color: navy\">, </span> ref.type = <span style=\"color: blue\">'Encounter'</span> <i>&quot;encounterref&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;conditionencounter&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Recorded date</span>\r\n  src.dateRecueil<b> as </b><span style=\"color: maroon\">entryDate</span><span style=\"color: navy\"><b> -&gt; </b></span>tgtCond.recordedDate = <span style=\"color: maroon\">entryDate</span> <i>&quot;conditionrecordeddate&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Clinical status - assume active for recorded diagnoses</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtCond.clinicalStatus = <b>cc</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'http://terminology.hl7.org/CodeSystem/condition-clinical'</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'active'</span><span style=\"color: navy\">)</span> <i>&quot;conditionclinicalstatus&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Verification status - assume confirmed for coded diagnoses</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtCond.verificationStatus = <b>cc</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'http://terminology.hl7.org/CodeSystem/condition-ver-status'</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'confirmed'</span><span style=\"color: navy\">)</span> <i>&quot;conditionverificationstatus&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\">========================================================================</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">PROCEDURE TRANSFORMATION</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">========================================================================</span>\r\n<b>group </b>TransformProcedure<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">src</span>, <b>target</b> <span style=\"color: maroon\">tgtProc</span><span style=\"color: navy\"> : </span>Procedure, <b>source</b> <span style=\"color: maroon\">patient</span>, <b>source</b> <span style=\"color: maroon\">encounter</span><span style=\"color: navy\">)</span><span style=\"color: navy\"> {\r\n</span>  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtProc.id = <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span> <i>&quot;setId&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Identifier</span>\r\n  src.acteId<b> as </b><span style=\"color: maroon\">acteId</span><span style=\"color: navy\"><b> -&gt; </b></span>tgtProc.identifier<b> as </b><span style=\"color: maroon\">identifier</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    acteId<span style=\"color: navy\"><b> -&gt; </b></span>identifier.system = <span style=\"color: blue\">'https://hospital.eu/ehr/acte-id'</span> <i>&quot;procedureidsystem&quot;</i><span style=\"color: navy\">;</span>\r\n    acteId<span style=\"color: navy\"><b> -&gt; </b></span>identifier.value = <span style=\"color: maroon\">acteId</span> <i>&quot;procedureidvalue&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;procedureidentifier&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Status - assume completed for historical data</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtProc.status = <span style=\"color: blue\">'completed'</span> <i>&quot;procedurestatus&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Code (CCAM)</span>\r\n  src.codeActe<b> as </b><span style=\"color: maroon\">code</span><span style=\"color: navy\"><b> -&gt; </b></span>tgtProc.code<b> as </b><span style=\"color: maroon\">procedureCode</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    code<span style=\"color: navy\"><b> -&gt; </b></span> procedureCode.coding<b> as </b><span style=\"color: maroon\">coding</span><span style=\"color: navy\">, </span> coding.system = <span style=\"color: blue\">'https://interop.aphp.fr/ig/fhir/dm/CodeSystem/Ccam'</span><span style=\"color: navy\">, </span> coding.code = <span style=\"color: maroon\">code</span> <i>&quot;procedurecoding&quot;</i><span style=\"color: navy\">;</span>\r\n    src.libelleActe<b> as </b><span style=\"color: maroon\">text</span><span style=\"color: navy\"><b> -&gt; </b></span>procedureCode.text = <span style=\"color: maroon\">text</span> <i>&quot;codetext&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;procedurecode&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Subject</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtProc.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><b> then</b><span style=\"color: navy\"> {\r\n</span>    patient.id<b> as </b><span style=\"color: maroon\">patientId</span><span style=\"color: navy\"><b> -&gt; </b></span> ref.reference = <span style=\"color: navy\">(</span>'Patient/' + %patientId<span style=\"color: navy\">)</span><span style=\"color: navy\">, </span> ref.type = <span style=\"color: blue\">'Patient'</span> <i>&quot;subjectref&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;proceduresubject&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Encounter reference</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtProc.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><b> then</b><span style=\"color: navy\"> {\r\n</span>    encounter.id<b> as </b><span style=\"color: maroon\">encounterId</span><span style=\"color: navy\"><b> -&gt; </b></span> ref.reference = <span style=\"color: navy\">(</span>'Encounter/' + %encounterId<span style=\"color: navy\">)</span><span style=\"color: navy\">, </span> ref.type = <span style=\"color: blue\">'Encounter'</span> <i>&quot;encounterref&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;procedureencounter&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Performed date/time</span>\r\n  src.dateActe<b> as </b><span style=\"color: maroon\">performedDate</span><b> where </b>%performedDate.exists()<span style=\"color: navy\"><b> -&gt; </b></span>tgtProc.performed = <span style=\"color: maroon\">performedDate</span> <i>&quot;procedureperformed&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Performer</span>\r\n  src.executant<b> as </b><span style=\"color: maroon\">performer</span><span style=\"color: navy\"><b> -&gt; </b></span>tgtProc.performer<b> as </b><span style=\"color: maroon\">perf</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    performer<span style=\"color: navy\"><b> -&gt; </b></span>perf.actor<b> as </b><span style=\"color: maroon\">actor</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      performer<span style=\"color: navy\"><b> -&gt; </b></span>actor.display = <span style=\"color: maroon\">performer</span> <i>&quot;performerdisplay&quot;</i><span style=\"color: navy\">;</span>\r\n      performer<span style=\"color: navy\"><b> -&gt; </b></span>actor.type = <span style=\"color: blue\">'Practitioner'</span> <i>&quot;performerType&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;performeractor&quot;</i><span style=\"color: navy\">;</span>\r\n    performer<span style=\"color: navy\"><b> -&gt; </b></span> perf.function<b> as </b><span style=\"color: maroon\">function</span><span style=\"color: navy\">, </span> function.text = <span style=\"color: blue\">'Exécutant'</span> <i>&quot;performerFunction&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;procedureperformer&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\">========================================================================</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">LABORATORY OBSERVATION TRANSFORMATION</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">========================================================================</span>\r\n<b>group </b>TransformLabObservation<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">src</span>, <b>target</b> <span style=\"color: maroon\">tgtObs</span><span style=\"color: navy\"> : </span>Observation, <b>source</b> <span style=\"color: maroon\">patient</span><span style=\"color: navy\">)</span><span style=\"color: navy\"> {\r\n</span>  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.id = <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span> <i>&quot;setId&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Identifier</span>\r\n  src.biologieId<b> as </b><span style=\"color: maroon\">bioId</span><span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.identifier<b> as </b><span style=\"color: maroon\">identifier</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    bioId<span style=\"color: navy\"><b> -&gt; </b></span>identifier.system = <span style=\"color: blue\">'https://hospital.eu/ehr/biologie-id'</span> <i>&quot;labidsystem&quot;</i><span style=\"color: navy\">;</span>\r\n    bioId<span style=\"color: navy\"><b> -&gt; </b></span>identifier.value = <span style=\"color: maroon\">bioId</span> <i>&quot;labidvalue&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;labidentifier&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Status - map validation status or default to final</span>\r\n  src.statutValidation<b> as </b><span style=\"color: maroon\">validation</span><b> where </b>validation = 'VALIDE'<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.status = <span style=\"color: blue\">'final'</span> <i>&quot;statusvalidated&quot;</i><span style=\"color: navy\">;</span>\r\n  src<b> where </b>src.statutValidation.exists().not()<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.status = <span style=\"color: blue\">'final'</span> <i>&quot;statusdefault&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Category</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.category<b> as </b><span style=\"color: maroon\">category</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    src<span style=\"color: navy\"><b> -&gt; </b></span>category.coding<b> as </b><span style=\"color: maroon\">coding</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.system = <span style=\"color: blue\">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;categorysystem&quot;</i><span style=\"color: navy\">;</span>\r\n      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.code = <span style=\"color: blue\">'laboratory'</span> <i>&quot;categorycode&quot;</i><span style=\"color: navy\">;</span>\r\n      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.display = <span style=\"color: blue\">'Laboratory'</span> <i>&quot;categorydisplay&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;categorycoding&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;labcategory&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Code (LOINC)</span>\r\n  src.codeLoinc<b> as </b><span style=\"color: maroon\">loinc</span><span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.code<b> as </b><span style=\"color: maroon\">code</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    loinc<span style=\"color: navy\"><b> -&gt; </b></span>code.coding<b> as </b><span style=\"color: maroon\">coding</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      loinc<span style=\"color: navy\"><b> -&gt; </b></span>coding.system = <span style=\"color: blue\">'http://loinc.org'</span> <i>&quot;codesystem&quot;</i><span style=\"color: navy\">;</span>\r\n      loinc<span style=\"color: navy\"><b> -&gt; </b></span>coding.code = <span style=\"color: maroon\">loinc</span> <i>&quot;codevalue&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;labcoding&quot;</i><span style=\"color: navy\">;</span>\r\n    src.libelleTest<b> as </b><span style=\"color: maroon\">text</span><span style=\"color: navy\"><b> -&gt; </b></span>code.text = <span style=\"color: maroon\">text</span> <i>&quot;codetext&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;labcode&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Subject</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.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><b> then</b><span style=\"color: navy\"> {\r\n</span>    patient.id<b> as </b><span style=\"color: maroon\">patientId</span><span style=\"color: navy\"><b> -&gt; </b></span> ref.reference = <span style=\"color: navy\">(</span>'Patient/' + %patientId<span style=\"color: navy\">)</span><span style=\"color: navy\">, </span> ref.type = <span style=\"color: blue\">'Patient'</span> <i>&quot;subjectref&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;labsubject&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Effective date/time</span>\r\n  src.datePrelevement<b> as </b><span style=\"color: maroon\">collectionDate</span><b> where </b>%collectionDate.exists()<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.effective = <b>cast</b><span style=\"color: navy\">(</span><span style=\"color: maroon\">collectionDate</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'dateTime'</span><span style=\"color: navy\">)</span> <i>&quot;labeffective&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Value (numeric or text)</span>\r\n  src.valeur<b> as </b><span style=\"color: maroon\">numValue</span><b> where </b>numValue.exists()<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.value = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Quantity'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">qty</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    numValue<span style=\"color: navy\"><b> -&gt; </b></span>qty.value = <span style=\"color: maroon\">numValue</span> <i>&quot;quantityvalue&quot;</i><span style=\"color: navy\">;</span>\r\n    src.unite<b> as </b><span style=\"color: maroon\">unit</span><span style=\"color: navy\"><b> -&gt; </b></span>qty.unit = <span style=\"color: maroon\">unit</span> <i>&quot;quantityunit&quot;</i><span style=\"color: navy\">;</span>\r\n    src.unite<b> as </b><span style=\"color: maroon\">unit</span><span style=\"color: navy\"><b> -&gt; </b></span>qty.code = <span style=\"color: maroon\">unit</span> <i>&quot;quantitycode&quot;</i><span style=\"color: navy\">;</span>\r\n    src<span style=\"color: navy\"><b> -&gt; </b></span>qty.system = <span style=\"color: blue\">'http://unitsofmeasure.org'</span> <i>&quot;quantitysystem&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;labvaluequantity&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">On n'a pas de résultats textuels de prévu</span>\r\n  <span style=\"color: #b36b00\" title=\"Cet élément n'était pas défini avant R5\">// src.valeurTexte as textValue where textValue.exists() and src.valeur.exists().not() -&gt; tgtObs.value = textValue &quot;lab-value-string&quot;;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Reference range</span>\r\n  src<b> where </b>src.borneInfNormale.exists() or src.borneSupNormale.exists()<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.referenceRange<b> as </b><span style=\"color: maroon\">range</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    src.borneInfNormale<b> as </b><span style=\"color: maroon\">low</span><span style=\"color: navy\"><b> -&gt; </b></span>range.low<b> as </b><span style=\"color: maroon\">lowQty</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      low<span style=\"color: navy\"><b> -&gt; </b></span>lowQty.value = <span style=\"color: maroon\">low</span> <i>&quot;reflowvalue&quot;</i><span style=\"color: navy\">;</span>\r\n      src.unite<b> as </b><span style=\"color: maroon\">unit</span><span style=\"color: navy\"><b> -&gt; </b></span>lowQty.unit = <span style=\"color: maroon\">unit</span> <i>&quot;reflowunit&quot;</i><span style=\"color: navy\">;</span>\r\n      src.unite<b> as </b><span style=\"color: maroon\">unit</span><span style=\"color: navy\"><b> -&gt; </b></span>lowQty.code = <span style=\"color: maroon\">unit</span> <i>&quot;reflowcode&quot;</i><span style=\"color: navy\">;</span>\r\n      src<span style=\"color: navy\"><b> -&gt; </b></span>lowQty.system = <span style=\"color: blue\">'http://unitsofmeasure.org'</span> <i>&quot;reflowsystem&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;referencelow&quot;</i><span style=\"color: navy\">;</span>\r\n    src.borneSupNormale<b> as </b><span style=\"color: maroon\">high</span><span style=\"color: navy\"><b> -&gt; </b></span>range.high<b> as </b><span style=\"color: maroon\">highQty</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      high<span style=\"color: navy\"><b> -&gt; </b></span>highQty.value = <span style=\"color: maroon\">high</span> <i>&quot;refhighvalue&quot;</i><span style=\"color: navy\">;</span>\r\n      src.unite<b> as </b><span style=\"color: maroon\">unit</span><span style=\"color: navy\"><b> -&gt; </b></span>highQty.unit = <span style=\"color: maroon\">unit</span> <i>&quot;refhighunit&quot;</i><span style=\"color: navy\">;</span>\r\n      src.unite<b> as </b><span style=\"color: maroon\">unit</span><span style=\"color: navy\"><b> -&gt; </b></span>highQty.code = <span style=\"color: maroon\">unit</span> <i>&quot;refhighcode&quot;</i><span style=\"color: navy\">;</span>\r\n      src<span style=\"color: navy\"><b> -&gt; </b></span>highQty.system = <span style=\"color: blue\">'http://unitsofmeasure.org'</span> <i>&quot;refhighsystem&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;referencehigh&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;labreferencerange&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Performer</span>\r\n  src.laboratoire<b> as </b><span style=\"color: maroon\">lab</span><span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.performer<b> as </b><span style=\"color: maroon\">performer</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    lab<span style=\"color: navy\"><b> -&gt; </b></span>performer.display = <span style=\"color: maroon\">lab</span> <i>&quot;performerdisplay&quot;</i><span style=\"color: navy\">;</span>\r\n    lab<span style=\"color: navy\"><b> -&gt; </b></span>performer.type = <span style=\"color: blue\">'Organization'</span> <i>&quot;performerType&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;labperformer&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\">========================================================================</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">MEDICATION REQUEST TRANSFORMATION</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">========================================================================</span>\r\n<b>group </b>TransformMedicationRequest<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">src</span>, <b>target</b> <span style=\"color: maroon\">tgtMedReq</span><span style=\"color: navy\"> : </span>MedicationRequest, <b>source</b> <span style=\"color: maroon\">patient</span><span style=\"color: navy\">)</span><span style=\"color: navy\"> {\r\n</span>  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtMedReq.id = <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span> <i>&quot;setId&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Identifier</span>\r\n  src.prescriptionId<b> as </b><span style=\"color: maroon\">presId</span><span style=\"color: navy\"><b> -&gt; </b></span>tgtMedReq.identifier<b> as </b><span style=\"color: maroon\">identifier</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    presId<span style=\"color: navy\"><b> -&gt; </b></span>identifier.system = <span style=\"color: blue\">'https://hospital.eu/ehr/prescription-id'</span> <i>&quot;medrequestidsystem&quot;</i><span style=\"color: navy\">;</span>\r\n    presId<span style=\"color: navy\"><b> -&gt; </b></span>identifier.value = <span style=\"color: maroon\">presId</span> <i>&quot;medrequestidvalue&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;medrequestidentifier&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Status - assume unknown for historical prescriptions</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtMedReq.status = <span style=\"color: blue\">'unknown'</span> <i>&quot;medrequeststatus&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Intent</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtMedReq.intent = <span style=\"color: blue\">'order'</span> <i>&quot;medrequestintent&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Subject</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtMedReq.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><b> then</b><span style=\"color: navy\"> {\r\n</span>    patient.id<b> as </b><span style=\"color: maroon\">patientId</span><span style=\"color: navy\"><b> -&gt; </b></span> ref.reference = <span style=\"color: navy\">(</span>'Patient/' + %patientId<span style=\"color: navy\">)</span><span style=\"color: navy\">, </span> ref.type = <span style=\"color: blue\">'Patient'</span> <i>&quot;subjectref&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;medrequestsubject&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Medication</span>\r\n  src.denomination<b> as </b><span style=\"color: maroon\">denomination</span><span style=\"color: navy\"><b> -&gt; </b></span>tgtMedReq.medication = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'CodeableConcept'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">medication</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    denomination<b> as </b><span style=\"color: maroon\">text</span><span style=\"color: navy\"><b> -&gt; </b></span>medication.text = <span style=\"color: maroon\">text</span> <i>&quot;medicationtext&quot;</i><span style=\"color: navy\">;</span>\r\n    src.codeAtc<b> as </b><span style=\"color: maroon\">atc</span><span style=\"color: navy\"><b> -&gt; </b></span>medication.coding<b> as </b><span style=\"color: maroon\">coding</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      atc<span style=\"color: navy\"><b> -&gt; </b></span>coding.system = <span style=\"color: blue\">'http://www.whocc.no/atc'</span> <i>&quot;atcsystem&quot;</i><span style=\"color: navy\">;</span>\r\n      atc<span style=\"color: navy\"><b> -&gt; </b></span>coding.code = <span style=\"color: maroon\">atc</span> <i>&quot;atccode&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;atccoding&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;medicationdenomination&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Authored date</span>\r\n  src.datePrescription<b> as </b><span style=\"color: maroon\">prescDate</span><span style=\"color: navy\"><b> -&gt; </b></span>tgtMedReq.authoredOn = <span style=\"color: maroon\">prescDate</span> <i>&quot;medauthored&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Requester</span>\r\n  src.prescripteur<b> as </b><span style=\"color: maroon\">prescriber</span><span style=\"color: navy\"><b> -&gt; </b></span>tgtMedReq.requester<b> as </b><span style=\"color: maroon\">requesterRef</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    prescriber<span style=\"color: navy\"><b> -&gt; </b></span>requesterRef.display = <span style=\"color: maroon\">prescriber</span> <i>&quot;requesterdisplay&quot;</i><span style=\"color: navy\">;</span>\r\n    prescriber<span style=\"color: navy\"><b> -&gt; </b></span>requesterRef.type = <span style=\"color: blue\">'Practitioner'</span> <i>&quot;requesterType&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;medrequester&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\">========================================================================</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">POSOLOGIE TRANSFORMATION</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">========================================================================</span>\r\n<b>group </b>setPoso<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">srcPoso</span>, <b>source</b> <span style=\"color: maroon\">srcPres</span>, <b>target</b> <span style=\"color: maroon\">tgtMedReq</span><span style=\"color: navy\">)</span><span style=\"color: navy\"> {\r\n</span>  srcPres<span style=\"color: navy\"><b> -&gt; </b></span>tgtMedReq.dosageInstruction<b> as </b><span style=\"color: maroon\">dosageInstruction</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    <span style=\"color: navy\">// </span><span style=\"color: green\">Human-readable dosage text - construct from available fields</span>\r\n    srcPoso<span style=\"color: navy\"><b> -&gt; </b></span>dosageInstruction.text = <span style=\"color: navy\">(</span>'Prendre' + iif(%srcPoso.quantite.exists(), ' ' + %srcPoso.quantite.toString(), '1') + iif(%srcPoso.uniteQuantite.exists(), ' ' + %srcPoso.uniteQuantite, ' comprimé') + iif(%srcPoso.nombrePrisesParJour.exists(), ' ' + %srcPoso.nombrePrisesParJour.toString() + ' fois par jour', ' selon prescription')<span style=\"color: navy\">)</span> <i>&quot;dosagetext&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">// </span><span style=\"color: green\">Route of administration from prescription</span>\r\n    srcPres.voieAdministration<b> as </b><span style=\"color: maroon\">route</span><span style=\"color: navy\"><b> -&gt; </b></span>dosageInstruction.route<b> as </b><span style=\"color: maroon\">routeCC</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      route<span style=\"color: navy\"><b> -&gt; </b></span>routeCC.coding<b> as </b><span style=\"color: maroon\">routeCoding</span><b> then</b><span style=\"color: navy\"> {\r\n</span>        route<span style=\"color: navy\"><b> -&gt; </b></span>routeCoding.code = <span style=\"color: maroon\">route</span> <i>&quot;routecode&quot;</i><span style=\"color: navy\">;</span>\r\n        route<span style=\"color: navy\"><b> -&gt; </b></span>routeCoding.system = <span style=\"color: blue\">'https://smt.esante.gouv.fr/terminologie-standardterms'</span> <i>&quot;routesystem&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;routecoding&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;dosageroute&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">// </span><span style=\"color: green\">Timing</span>\r\n    srcPoso<span style=\"color: navy\"><b> -&gt; </b></span>dosageInstruction.timing<b> as </b><span style=\"color: maroon\">timing</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      srcPoso<span style=\"color: navy\"><b> -&gt; </b></span>timing.repeat<b> as </b><span style=\"color: maroon\">timingRepeat</span><b> then</b><span style=\"color: navy\"> {\r\n</span>        <span style=\"color: navy\">// </span><span style=\"color: green\">Set prescription period as bounds if available</span>\r\n        srcPres<b> where </b>srcPres.dateDebutPrescription.exists() or srcPres.dateFinPrescription.exists()<span style=\"color: navy\"><b> -&gt; </b></span>timingRepeat.bounds = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Period'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">medReqPeriod</span><b> then</b><span style=\"color: navy\"> {\r\n</span>          srcPres.dateDebutPrescription<b> as </b><span style=\"color: maroon\">startDate</span><span style=\"color: navy\"><b> -&gt; </b></span>medReqPeriod.start = <span style=\"color: maroon\">startDate</span> <i>&quot;periodstart&quot;</i><span style=\"color: navy\">;</span>\r\n          srcPres.dateFinPrescription<b> as </b><span style=\"color: maroon\">endDate</span><span style=\"color: navy\"><b> -&gt; </b></span>medReqPeriod.end = <span style=\"color: maroon\">endDate</span> <i>&quot;periodend&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">}</span> <i>&quot;prescriptionperiod&quot;</i><span style=\"color: navy\">;</span>\r\n        <span style=\"color: navy\">// </span><span style=\"color: green\">Frequency from posology</span>\r\n        srcPoso.nombrePrisesParJour<b> as </b><span style=\"color: maroon\">frequency</span><span style=\"color: navy\"><b> -&gt; </b></span>timingRepeat.frequency = <span style=\"color: maroon\">frequency</span> <i>&quot;timingfrequency&quot;</i><span style=\"color: navy\">;</span>\r\n        srcPoso.nombrePrisesParJour<b> as </b><span style=\"color: maroon\">frequency</span><span style=\"color: navy\"><b> -&gt; </b></span>timingRepeat.period = <span style=\"color: blue\">'1'</span> <i>&quot;timingperiod&quot;</i><span style=\"color: navy\">;</span>\r\n        srcPoso.nombrePrisesParJour<b> as </b><span style=\"color: maroon\">frequency</span><span style=\"color: navy\"><b> -&gt; </b></span>timingRepeat.periodUnit = <span style=\"color: blue\">'d'</span> <i>&quot;timingperiodunit&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;timingrepeat&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;dosagetiming&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">// </span><span style=\"color: green\">Dose and rate</span>\r\n    srcPoso.quantite<b> as </b><span style=\"color: maroon\">quantity</span><span style=\"color: navy\"><b> -&gt; </b></span>dosageInstruction.doseAndRate<b> as </b><span style=\"color: maroon\">doseRate</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      quantity<span style=\"color: navy\"><b> -&gt; </b></span>doseRate.dose = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Quantity'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">doseQuantity</span><b> then</b><span style=\"color: navy\"> {\r\n</span>        quantity<span style=\"color: navy\"><b> -&gt; </b></span>doseQuantity.value = <span style=\"color: maroon\">quantity</span> <i>&quot;dosevalue&quot;</i><span style=\"color: navy\">;</span>\r\n        srcPoso.uniteQuantite<b> as </b><span style=\"color: maroon\">unit</span><span style=\"color: navy\"><b> -&gt; </b></span>doseQuantity.unit = <span style=\"color: maroon\">unit</span> <i>&quot;doseunit&quot;</i><span style=\"color: navy\">;</span>\r\n        srcPoso.uniteQuantite<b> as </b><span style=\"color: maroon\">unit</span><span style=\"color: navy\"><b> -&gt; </b></span>doseQuantity.code = <span style=\"color: maroon\">unit</span> <i>&quot;dosecode&quot;</i><span style=\"color: navy\">;</span>\r\n        srcPoso<span style=\"color: navy\"><b> -&gt; </b></span>doseQuantity.system = <span style=\"color: blue\">'http://unitsofmeasure.org'</span> <i>&quot;dosesystem&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;dosequantity&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;doseandrate&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;dosageinstruction&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\">========================================================================</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">VITAL SIGNS TRANSFORMATION</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">========================================================================</span>\r\n<b>group </b>TransformVitalSigns<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">src</span>, <b>target</b> <span style=\"color: maroon\">tgtObs</span><span style=\"color: navy\"> : </span>Observation, <b>source</b> <span style=\"color: maroon\">patient</span><span style=\"color: navy\">)</span><span style=\"color: navy\"> {\r\n</span>  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.id = <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span> <i>&quot;setId&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Identifier</span>\r\n  src.soinId<b> as </b><span style=\"color: maroon\">soinId</span><span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.identifier<b> as </b><span style=\"color: maroon\">identifier</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    soinId<span style=\"color: navy\"><b> -&gt; </b></span>identifier.system = <span style=\"color: blue\">'https://hospital.eu/ehr/soin-id'</span> <i>&quot;soinidsystem&quot;</i><span style=\"color: navy\">;</span>\r\n    soinId<span style=\"color: navy\"><b> -&gt; </b></span>identifier.value = <span style=\"color: maroon\">soinId</span> <i>&quot;soinidvalue&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;medrequestidentifier&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Status - assume final</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.status = <span style=\"color: blue\">'final'</span> <i>&quot;status&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Category - vital-signs</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.category<b> as </b><span style=\"color: maroon\">category</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    src<span style=\"color: navy\"><b> -&gt; </b></span>category.coding<b> as </b><span style=\"color: maroon\">coding</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.system = <span style=\"color: blue\">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;categorysystem&quot;</i><span style=\"color: navy\">;</span>\r\n      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.code = <span style=\"color: blue\">'vital-signs'</span> <i>&quot;categorycode&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;categorycoding&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;category&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">code (LOINC)</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.code<b> as </b><span style=\"color: maroon\">code</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    src<span style=\"color: navy\"><b> -&gt; </b></span>code.coding<b> as </b><span style=\"color: maroon\">coding</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.system = <span style=\"color: blue\">'http://loinc.org'</span> <i>&quot;codesystem&quot;</i><span style=\"color: navy\">;</span>\r\n      src.codeLoinc<b> as </b><span style=\"color: maroon\">codeLoinc</span><span style=\"color: navy\"><b> -&gt; </b></span>coding.code = <span style=\"color: maroon\">codeLoinc</span> <i>&quot;codevalue&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;coding&quot;</i><span style=\"color: navy\">;</span>\r\n    src.libelleTest<b> as </b><span style=\"color: maroon\">label</span><span style=\"color: navy\"><b> -&gt; </b></span>code.text = <span style=\"color: maroon\">label</span> <i>&quot;codetext&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;code&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Subject</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.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><b> then</b><span style=\"color: navy\"> {\r\n</span>    patient.id<b> as </b><span style=\"color: maroon\">patientId</span><span style=\"color: navy\"><b> -&gt; </b></span> ref.reference = <span style=\"color: navy\">(</span>'Patient/' + %patientId<span style=\"color: navy\">)</span><span style=\"color: navy\">, </span> ref.type = <span style=\"color: blue\">'Patient'</span> <i>&quot;subjectref&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;obssubject&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Date de l'observation</span>\r\n  src.dateMesure<b> as </b><span style=\"color: maroon\">date</span><b> where </b>%date.exists()<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.effective = <b>cast</b><span style=\"color: navy\">(</span><span style=\"color: maroon\">date</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'dateTime'</span><span style=\"color: navy\">)</span> <i>&quot;effective&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Valeur (quantitiative)</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.value = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Quantity'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">qty</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    src.valeur<b> as </b><span style=\"color: maroon\">mesure</span><span style=\"color: navy\"><b> -&gt; </b></span>qty.value = <span style=\"color: maroon\">mesure</span> <i>&quot;value&quot;</i><span style=\"color: navy\">;</span>\r\n    src.unite<b> as </b><span style=\"color: maroon\">unit</span><span style=\"color: navy\"><b> -&gt; </b></span>qty.unit = <span style=\"color: maroon\">unit</span> <i>&quot;unit&quot;</i><span style=\"color: navy\">;</span>\r\n    src.unite<b> as </b><span style=\"color: maroon\">unit</span><span style=\"color: navy\"><b> -&gt; </b></span>qty.code = <span style=\"color: maroon\">unit</span> <i>&quot;code&quot;</i><span style=\"color: navy\">;</span>\r\n    src<span style=\"color: navy\"><b> -&gt; </b></span>qty.system = <span style=\"color: blue\">'http://unitsofmeasure.org'</span> <i>&quot;system&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;quantity&quot;</i><span style=\"color: navy\">;</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">Blood pressure observation - would need separate entry with components</span>\r\n<span style=\"color: navy\">}\r\n\r\n</span><span style=\"color: navy\">// </span><span style=\"color: green\">========================================================================</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">LIFESTYLE TRANSFORMATION - SEPARATE OBSERVATIONS</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">========================================================================</span>\r\n<b>group </b>TransformTobaccoObservation<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">src</span>, <b>target</b> <span style=\"color: maroon\">tgtObs</span><span style=\"color: navy\"> : </span>Observation, <b>source</b> <span style=\"color: maroon\">patient</span><span style=\"color: navy\">)</span><span style=\"color: navy\"> {\r\n</span>  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.id = <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span> <i>&quot;setId&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Identifier</span>\r\n  src.styleVieId<b> as </b><span style=\"color: maroon\">lsId</span><span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.identifier<b> as </b><span style=\"color: maroon\">identifier</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    lsId<span style=\"color: navy\"><b> -&gt; </b></span>identifier.system = <span style=\"color: blue\">'https://hospital.eu/ehr/lifestyle-id'</span> <i>&quot;lifestyleidsystem&quot;</i><span style=\"color: navy\">;</span>\r\n    lsId<span style=\"color: navy\"><b> -&gt; </b></span>identifier.value = <span style=\"color: navy\">(</span>%lsId &amp; '-tobacco'<span style=\"color: navy\">)</span> <i>&quot;lifestyleidvalue&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;lifestyleidentifier&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Status</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.status = <span style=\"color: blue\">'final'</span> <i>&quot;lifestylestatus&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Category - social-history</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.category<b> as </b><span style=\"color: maroon\">category</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    src<span style=\"color: navy\"><b> -&gt; </b></span>category.coding<b> as </b><span style=\"color: maroon\">coding</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.system = <span style=\"color: blue\">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;categorysystem&quot;</i><span style=\"color: navy\">;</span>\r\n      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.code = <span style=\"color: blue\">'social-history'</span> <i>&quot;categorycode&quot;</i><span style=\"color: navy\">;</span>\r\n      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.display = <span style=\"color: blue\">'Social History'</span> <i>&quot;categorydisplay&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;categorycoding&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;lifestylecategory&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Code - tobacco use status</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.code<b> as </b><span style=\"color: maroon\">code</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    src<span style=\"color: navy\"><b> -&gt; </b></span>code.coding<b> as </b><span style=\"color: maroon\">coding</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.system = <span style=\"color: blue\">'http://loinc.org'</span> <i>&quot;codesystem&quot;</i><span style=\"color: navy\">;</span>\r\n      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.code = <span style=\"color: blue\">'72166-2'</span> <i>&quot;codevalue&quot;</i><span style=\"color: navy\">;</span>\r\n      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.display = <span style=\"color: blue\">'Tobacco smoking status'</span> <i>&quot;codedisplay&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;tobaccocoding&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;tobaccocode&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Subject</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.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><b> then</b><span style=\"color: navy\"> {\r\n</span>    patient.id<b> as </b><span style=\"color: maroon\">patientId</span><span style=\"color: navy\"><b> -&gt; </b></span> ref.reference = <span style=\"color: navy\">(</span>'Patient/' + %patientId<span style=\"color: navy\">)</span><span style=\"color: navy\">, </span> ref.type = <span style=\"color: blue\">'Patient'</span> <i>&quot;subjectref&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;lifestylesubject&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Effective date</span>\r\n  src.dateRecueil<b> as </b><span style=\"color: maroon\">collectDate</span><b> where </b>%collectDate.exists()<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.effective = <b>cast</b><span style=\"color: navy\">(</span><span style=\"color: maroon\">collectDate</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'dateTime'</span><span style=\"color: navy\">)</span> <i>&quot;lifestyleeffective&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Value</span>\r\n  src.consommationTabac<b> as </b><span style=\"color: maroon\">tobacco</span><span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.value = <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\">valueCC</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    tobacco<span style=\"color: navy\"><b> -&gt; </b></span>valueCC.text = <span style=\"color: maroon\">tobacco</span> <i>&quot;tobaccovaluetext&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;tobaccovalue&quot;</i><span style=\"color: navy\">;</span>\r\n<span style=\"color: navy\">}\r\n\r\n</span><b>group </b>TransformAlcoholObservation<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">src</span>, <b>target</b> <span style=\"color: maroon\">tgtObs</span><span style=\"color: navy\"> : </span>Observation, <b>source</b> <span style=\"color: maroon\">patient</span><span style=\"color: navy\">)</span><span style=\"color: navy\"> {\r\n</span>  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.id = <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span> <i>&quot;setId&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Identifier</span>\r\n  src.styleVieId<b> as </b><span style=\"color: maroon\">lsId</span><span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.identifier<b> as </b><span style=\"color: maroon\">identifier</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    lsId<span style=\"color: navy\"><b> -&gt; </b></span>identifier.system = <span style=\"color: blue\">'https://hospital.eu/ehr/lifestyle-id'</span> <i>&quot;lifestyleidsystem&quot;</i><span style=\"color: navy\">;</span>\r\n    lsId<span style=\"color: navy\"><b> -&gt; </b></span>identifier.value = <span style=\"color: navy\">(</span>%lsId &amp; '-alcohol'<span style=\"color: navy\">)</span> <i>&quot;lifestyleidvalue&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;lifestyleidentifier&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Status</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.status = <span style=\"color: blue\">'final'</span> <i>&quot;lifestylestatus&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Category - social-history</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.category<b> as </b><span style=\"color: maroon\">category</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    src<span style=\"color: navy\"><b> -&gt; </b></span>category.coding<b> as </b><span style=\"color: maroon\">coding</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.system = <span style=\"color: blue\">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;categorysystem&quot;</i><span style=\"color: navy\">;</span>\r\n      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.code = <span style=\"color: blue\">'social-history'</span> <i>&quot;categorycode&quot;</i><span style=\"color: navy\">;</span>\r\n      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.display = <span style=\"color: blue\">'Social History'</span> <i>&quot;categorydisplay&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;categorycoding&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;lifestylecategory&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Code - alcohol use</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.code<b> as </b><span style=\"color: maroon\">code</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    src<span style=\"color: navy\"><b> -&gt; </b></span>code.coding<b> as </b><span style=\"color: maroon\">coding</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.system = <span style=\"color: blue\">'http://loinc.org'</span> <i>&quot;codesystem&quot;</i><span style=\"color: navy\">;</span>\r\n      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.code = <span style=\"color: blue\">'11331-6'</span> <i>&quot;codevalue&quot;</i><span style=\"color: navy\">;</span>\r\n      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.display = <span style=\"color: blue\">'History of alcohol use'</span> <i>&quot;codedisplay&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;alcoholcoding&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;alcoholcode&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Subject</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.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><b> then</b><span style=\"color: navy\"> {\r\n</span>    patient.id<b> as </b><span style=\"color: maroon\">patientId</span><span style=\"color: navy\"><b> -&gt; </b></span> ref.reference = <span style=\"color: navy\">(</span>'Patient/' + %patientId<span style=\"color: navy\">)</span><span style=\"color: navy\">, </span> ref.type = <span style=\"color: blue\">'Patient'</span> <i>&quot;subjectref&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;lifestylesubject&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Effective date</span>\r\n  src.dateRecueil<b> as </b><span style=\"color: maroon\">collectDate</span><b> where </b>%collectDate.exists()<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.effective = <b>cast</b><span style=\"color: navy\">(</span><span style=\"color: maroon\">collectDate</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'dateTime'</span><span style=\"color: navy\">)</span> <i>&quot;lifestyleeffective&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Value</span>\r\n  src.consommationAlcool<b> as </b><span style=\"color: maroon\">alcohol</span><span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.value = <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\">valueCC</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    alcohol<span style=\"color: navy\"><b> -&gt; </b></span>valueCC.text = <span style=\"color: maroon\">alcohol</span> <i>&quot;alcoholvaluetext&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;alcoholvalue&quot;</i><span style=\"color: navy\">;</span>\r\n<span style=\"color: navy\">}\r\n\r\n</span><b>group </b>TransformDrugObservation<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">src</span>, <b>target</b> <span style=\"color: maroon\">tgtObs</span><span style=\"color: navy\"> : </span>Observation, <b>source</b> <span style=\"color: maroon\">patient</span><span style=\"color: navy\">)</span><span style=\"color: navy\"> {\r\n</span>  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.id = <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span> <i>&quot;setId&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Identifier</span>\r\n  src.styleVieId<b> as </b><span style=\"color: maroon\">lsId</span><span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.identifier<b> as </b><span style=\"color: maroon\">identifier</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    lsId<span style=\"color: navy\"><b> -&gt; </b></span>identifier.system = <span style=\"color: blue\">'https://hospital.eu/ehr/lifestyle-id'</span> <i>&quot;lifestyleidsystem&quot;</i><span style=\"color: navy\">;</span>\r\n    lsId<span style=\"color: navy\"><b> -&gt; </b></span>identifier.value = <span style=\"color: navy\">(</span>%lsId &amp; '-drugs'<span style=\"color: navy\">)</span> <i>&quot;lifestyleidvalue&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;lifestyleidentifier&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Status</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.status = <span style=\"color: blue\">'final'</span> <i>&quot;lifestylestatus&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Category - social-history</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.category<b> as </b><span style=\"color: maroon\">category</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    src<span style=\"color: navy\"><b> -&gt; </b></span>category.coding<b> as </b><span style=\"color: maroon\">coding</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.system = <span style=\"color: blue\">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;categorysystem&quot;</i><span style=\"color: navy\">;</span>\r\n      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.code = <span style=\"color: blue\">'social-history'</span> <i>&quot;categorycode&quot;</i><span style=\"color: navy\">;</span>\r\n      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.display = <span style=\"color: blue\">'Social History'</span> <i>&quot;categorydisplay&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;categorycoding&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;lifestylecategory&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Code - drug use</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.code<b> as </b><span style=\"color: maroon\">code</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    src<span style=\"color: navy\"><b> -&gt; </b></span>code.coding<b> as </b><span style=\"color: maroon\">coding</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.system = <span style=\"color: blue\">'http://loinc.org'</span> <i>&quot;codesystem&quot;</i><span style=\"color: navy\">;</span>\r\n      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.code = <span style=\"color: blue\">'11342-3'</span> <i>&quot;codevalue&quot;</i><span style=\"color: navy\">;</span>\r\n      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.display = <span style=\"color: blue\">'History of drug use'</span> <i>&quot;codedisplay&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;drugcoding&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;drugcode&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Subject</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.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><b> then</b><span style=\"color: navy\"> {\r\n</span>    patient.id<b> as </b><span style=\"color: maroon\">patientId</span><span style=\"color: navy\"><b> -&gt; </b></span> ref.reference = <span style=\"color: navy\">(</span>'Patient/' + %patientId<span style=\"color: navy\">)</span><span style=\"color: navy\">, </span> ref.type = <span style=\"color: blue\">'Patient'</span> <i>&quot;subjectref&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;lifestylesubject&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Effective date</span>\r\n  src.dateRecueil<b> as </b><span style=\"color: maroon\">collectDate</span><b> where </b>%collectDate.exists()<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.effective = <b>cast</b><span style=\"color: navy\">(</span><span style=\"color: maroon\">collectDate</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'dateTime'</span><span style=\"color: navy\">)</span> <i>&quot;lifestyleeffective&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Value</span>\r\n  src.consommationAutresDrogues<b> as </b><span style=\"color: maroon\">drugs</span><span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.value = <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\">valueCC</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    drugs<span style=\"color: navy\"><b> -&gt; </b></span>valueCC.text = <span style=\"color: maroon\">drugs</span> <i>&quot;drugvaluetext&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;drugvalue&quot;</i><span style=\"color: navy\">;</span>\r\n<span style=\"color: navy\">}\r\n\r\n</span><b>group </b>TransformPhysicalActivityObservation<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">src</span>, <b>target</b> <span style=\"color: maroon\">tgtObs</span><span style=\"color: navy\"> : </span>Observation, <b>source</b> <span style=\"color: maroon\">patient</span><span style=\"color: navy\">)</span><span style=\"color: navy\"> {\r\n</span>  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.id = <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span> <i>&quot;setId&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Identifier</span>\r\n  src.styleVieId<b> as </b><span style=\"color: maroon\">lsId</span><span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.identifier<b> as </b><span style=\"color: maroon\">identifier</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    lsId<span style=\"color: navy\"><b> -&gt; </b></span>identifier.system = <span style=\"color: blue\">'https://hospital.eu/ehr/lifestyle-id'</span> <i>&quot;lifestyleidsystem&quot;</i><span style=\"color: navy\">;</span>\r\n    lsId<span style=\"color: navy\"><b> -&gt; </b></span>identifier.value = <span style=\"color: navy\">(</span>%lsId &amp; '-physical'<span style=\"color: navy\">)</span> <i>&quot;lifestyleidvalue&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;lifestyleidentifier&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Status</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.status = <span style=\"color: blue\">'final'</span> <i>&quot;lifestylestatus&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Category - social-history</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.category<b> as </b><span style=\"color: maroon\">category</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    src<span style=\"color: navy\"><b> -&gt; </b></span>category.coding<b> as </b><span style=\"color: maroon\">coding</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.system = <span style=\"color: blue\">'http://terminology.hl7.org/CodeSystem/observation-category'</span> <i>&quot;categorysystem&quot;</i><span style=\"color: navy\">;</span>\r\n      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.code = <span style=\"color: blue\">'social-history'</span> <i>&quot;categorycode&quot;</i><span style=\"color: navy\">;</span>\r\n      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.display = <span style=\"color: blue\">'Social History'</span> <i>&quot;categorydisplay&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;categorycoding&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;lifestylecategory&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Code - physical activity</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.code<b> as </b><span style=\"color: maroon\">code</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    src<span style=\"color: navy\"><b> -&gt; </b></span>code.coding<b> as </b><span style=\"color: maroon\">coding</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.system = <span style=\"color: blue\">'http://loinc.org'</span> <i>&quot;codesystem&quot;</i><span style=\"color: navy\">;</span>\r\n      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.code = <span style=\"color: blue\">'67504-6'</span> <i>&quot;codevalue&quot;</i><span style=\"color: navy\">;</span>\r\n      src<span style=\"color: navy\"><b> -&gt; </b></span>coding.display = <span style=\"color: blue\">'Exercise activity'</span> <i>&quot;codedisplay&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;physicalcoding&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;physicalcode&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Subject</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.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><b> then</b><span style=\"color: navy\"> {\r\n</span>    patient.id<b> as </b><span style=\"color: maroon\">patientId</span><span style=\"color: navy\"><b> -&gt; </b></span> ref.reference = <span style=\"color: navy\">(</span>'Patient/' + %patientId<span style=\"color: navy\">)</span><span style=\"color: navy\">, </span> ref.type = <span style=\"color: blue\">'Patient'</span> <i>&quot;subjectref&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;lifestylesubject&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Effective date</span>\r\n  src.dateRecueil<b> as </b><span style=\"color: maroon\">collectDate</span><b> where </b>%collectDate.exists()<span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.effective = <b>cast</b><span style=\"color: navy\">(</span><span style=\"color: maroon\">collectDate</span><span style=\"color: navy\">, </span><span style=\"color: blue\">'dateTime'</span><span style=\"color: navy\">)</span> <i>&quot;lifestyleeffective&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Value</span>\r\n  src.activitePhysique<b> as </b><span style=\"color: maroon\">physical</span><span style=\"color: navy\"><b> -&gt; </b></span>tgtObs.value = <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\">valueCC</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    physical<span style=\"color: navy\"><b> -&gt; </b></span>valueCC.text = <span style=\"color: maroon\">physical</span> <i>&quot;physicalvaluetext&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;physicalvalue&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\">========================================================================</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">MEDICATION ADMINISTRATION TRANSFORMATION</span>\r\n<span style=\"color: navy\">// </span><span style=\"color: green\">========================================================================</span>\r\n<b>group </b>TransformMedicationAdministrationWOOrder<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">src</span>, <b>target</b> <span style=\"color: maroon\">tgtMedAdmin</span><span style=\"color: navy\"> : </span>MedicationAdministration, <b>source</b> <span style=\"color: maroon\">patient</span><span style=\"color: navy\">)</span><span style=\"color: navy\"> {\r\n</span>  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtMedAdmin.id = <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span> <i>&quot;setId&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Identifier</span>\r\n  src.administrationId<b> as </b><span style=\"color: maroon\">adminId</span><span style=\"color: navy\"><b> -&gt; </b></span>tgtMedAdmin.identifier<b> as </b><span style=\"color: maroon\">identifier</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    adminId<span style=\"color: navy\"><b> -&gt; </b></span>identifier.system = <span style=\"color: blue\">'https://hospital.eu/ehr/administration-id'</span> <i>&quot;adminidsystem&quot;</i><span style=\"color: navy\">;</span>\r\n    adminId<span style=\"color: navy\"><b> -&gt; </b></span>identifier.value = <span style=\"color: maroon\">adminId</span> <i>&quot;adminidvalue&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;adminidentifier&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Status - assume completed</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtMedAdmin.status = <span style=\"color: blue\">'completed'</span> <i>&quot;adminstatus&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Subject</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtMedAdmin.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><b> then</b><span style=\"color: navy\"> {\r\n</span>    patient.id<b> as </b><span style=\"color: maroon\">patientId</span><span style=\"color: navy\"><b> -&gt; </b></span> ref.reference = <span style=\"color: navy\">(</span>'Patient/' + %patientId<span style=\"color: navy\">)</span><span style=\"color: navy\">, </span> ref.type = <span style=\"color: blue\">'Patient'</span> <i>&quot;subjectref&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;adminsubject&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Medication</span>\r\n  src.denomination<b> as </b><span style=\"color: maroon\">denomination</span><span style=\"color: navy\"><b> -&gt; </b></span>tgtMedAdmin.medication = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'CodeableConcept'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">medication</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    denomination<span style=\"color: navy\"><b> -&gt; </b></span>medication.text = <span style=\"color: maroon\">denomination</span> <i>&quot;medicationtext&quot;</i><span style=\"color: navy\">;</span>\r\n    src.codeAtc<b> as </b><span style=\"color: maroon\">atc</span><span style=\"color: navy\"><b> -&gt; </b></span>medication.coding<b> as </b><span style=\"color: maroon\">coding</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      atc<span style=\"color: navy\"><b> -&gt; </b></span>coding.system = <span style=\"color: blue\">'http://www.whocc.no/atc'</span> <i>&quot;atcsystem&quot;</i><span style=\"color: navy\">;</span>\r\n      atc<span style=\"color: navy\"><b> -&gt; </b></span>coding.code = <span style=\"color: maroon\">atc</span> <i>&quot;atccode&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;atccoding&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;adminmedication&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Effective period</span>\r\n  src<b> where </b>src.dateHeureDebut.exists() or src.dateHeureFin.exists()<span style=\"color: navy\"><b> -&gt; </b></span>tgtMedAdmin.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>    src.dateHeureDebut<b> as </b><span style=\"color: maroon\">startDate</span><span style=\"color: navy\"><b> -&gt; </b></span>period.start = <span style=\"color: maroon\">startDate</span> <i>&quot;periodstart&quot;</i><span style=\"color: navy\">;</span>\r\n    src.dateHeureFin<b> as </b><span style=\"color: maroon\">endDate</span><span style=\"color: navy\"><b> -&gt; </b></span>period.end = <span style=\"color: maroon\">endDate</span> <i>&quot;periodend&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;admineffective&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">// </span><span style=\"color: green\">Dosage</span>\r\n  src<b> where </b>src.quantite.exists() or src.voieAdministration.exists()<span style=\"color: navy\"><b> -&gt; </b></span>tgtMedAdmin.dosage<b> as </b><span style=\"color: maroon\">dosage</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    src.quantite<b> as </b><span style=\"color: maroon\">quantity</span><span style=\"color: navy\"><b> -&gt; </b></span>dosage.dose = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Quantity'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">dose</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      quantity<span style=\"color: navy\"><b> -&gt; </b></span>dose.value = <span style=\"color: maroon\">quantity</span> <i>&quot;dosevalue&quot;</i><span style=\"color: navy\">;</span>\r\n      src.uniteQuantite<b> as </b><span style=\"color: maroon\">unit</span><span style=\"color: navy\"><b> -&gt; </b></span>dose.unit = <span style=\"color: maroon\">unit</span> <i>&quot;doseunit&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;admindose&quot;</i><span style=\"color: navy\">;</span>\r\n    src.voieAdministration<b> as </b><span style=\"color: maroon\">route</span><span style=\"color: navy\"><b> -&gt; </b></span>dosage.route<b> as </b><span style=\"color: maroon\">routeCC</span><b> then</b><span style=\"color: navy\"> {\r\n</span>      route<span style=\"color: navy\"><b> -&gt; </b></span>routeCC.coding<b> as </b><span style=\"color: maroon\">routeCoding</span><b> then</b><span style=\"color: navy\"> {\r\n</span>        route<span style=\"color: navy\"><b> -&gt; </b></span>routeCoding.code = <span style=\"color: maroon\">route</span> <i>&quot;routecode&quot;</i><span style=\"color: navy\">;</span>\r\n        route<span style=\"color: navy\"><b> -&gt; </b></span>routeCoding.system = <span style=\"color: blue\">'https://smt.esante.gouv.fr/terminologie-standardterms'</span> <i>&quot;routesystem&quot;</i><span style=\"color: navy\">;</span>\r\n      <span style=\"color: navy\">}</span> <i>&quot;routecoding&quot;</i><span style=\"color: navy\">;</span>\r\n    <span style=\"color: navy\">}</span> <i>&quot;dosageroute&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;admindosage&quot;</i><span style=\"color: navy\">;</span>\r\n<span style=\"color: navy\">}\r\n\r\n</span><b>group </b>TransformMedicationAdministrationWOrder<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">src</span>, <b>target</b> <span style=\"color: maroon\">tgtMedAdmin</span><span style=\"color: navy\"> : </span>MedicationAdministration, <b>source</b> <span style=\"color: maroon\">patient</span>, <b>source</b> <span style=\"color: maroon\">order</span><span style=\"color: navy\">)</span><b> extends </b>TransformMedicationAdministrationWOOrder<span style=\"color: navy\"> {\r\n</span>  <span style=\"color: navy\">// </span><span style=\"color: green\">Context (encounter) reference</span>\r\n  src<span style=\"color: navy\"><b> -&gt; </b></span>tgtMedAdmin.request = <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><b> then</b><span style=\"color: navy\"> {\r\n</span>    order.id<b> as </b><span style=\"color: maroon\">orderId</span><span style=\"color: navy\"><b> -&gt; </b></span> ref.reference = <span style=\"color: navy\">(</span>'MedicationRequest/' + %orderId<span style=\"color: navy\">)</span><span style=\"color: navy\">, </span> ref.type = <span style=\"color: blue\">'MedicationRequest'</span> <i>&quot;encounterref&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;admincontext&quot;</i><span style=\"color: navy\">;</span>\r\n<span style=\"color: navy\">}\r\n\r\n</span><b>group </b>setEntryRequestAndFullUrl<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">newRes</span>, <b>target</b> <span style=\"color: maroon\">tgtEntry</span><span style=\"color: navy\">)</span><span style=\"color: navy\"> {\r\n</span>  newRes.id<b> as </b><span style=\"color: maroon\">newResId</span><b> then</b><span style=\"color: navy\"> {\r\n</span>    newResId<span style=\"color: navy\"><b> -&gt; </b></span>tgtEntry.fullUrl = <span style=\"color: navy\">(</span>'urn:ehr:' + %newRes.type().name + '/' + %newResId<span style=\"color: navy\">)</span> <i>&quot;setFullUrl&quot;</i><span style=\"color: navy\">;</span>\r\n  <span style=\"color: navy\">}</span> <i>&quot;setResourceType&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/EHR2FSL",
      "version" : "0.1.0",
      "name" : "EHR2FSL",
      "title" : "Transforms EHR logical model data to FHIR Semantic Layer resources using Bundle as container",
      "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 EHR logical model data to FHIR Semantic Layer resources using Bundle as container",
      "jurisdiction" : [
        {
          "coding" : [
            {
              "system" : "urn:iso:std:iso:3166",
              "code" : "FR"
            }
          ]
        }
      ],
      "structure" : [
        {
          "url" : "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/ehr",
          "mode" : "source",
          "alias" : "EHR"
        },
        {
          "url" : "http://hl7.org/fhir/StructureDefinition/Bundle",
          "mode" : "target",
          "alias" : "Bundle"
        }
      ],
      "group" : [
        {
          "name" : "EHR2FSL",
          "typeMode" : "none",
          "input" : [
            {
              "name" : "src",
              "type" : "EHR",
              "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" : [
                {
                  "contextType" : "variable",
                  "variable" : "timestamp",
                  "transform" : "evaluate",
                  "parameter" : [
                    {
                      "valueString" : "now()"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "affectTimestamp",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "bundle",
                      "contextType" : "variable",
                      "element" : "timestamp",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "timestamp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "patiententry",
              "source" : [
                {
                  "context" : "src",
                  "element" : "patient",
                  "variable" : "patient"
                }
              ],
              "target" : [
                {
                  "context" : "bundle",
                  "contextType" : "variable",
                  "element" : "entry",
                  "variable" : "patientEntry"
                }
              ],
              "rule" : [
                {
                  "name" : "createpatient",
                  "source" : [
                    {
                      "context" : "patient"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "patientEntry",
                      "contextType" : "variable",
                      "element" : "resource",
                      "variable" : "dmPatient",
                      "transform" : "create",
                      "parameter" : [
                        {
                          "valueString" : "Patient"
                        }
                      ]
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "transformpatient",
                      "source" : [
                        {
                          "context" : "patient"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "TransformPatient",
                          "variable" : [
                            "patient",
                            "dmPatient"
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "setRequestAndFullUrl",
                      "source" : [
                        {
                          "context" : "patient"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "setEntryRequestAndFullUrl",
                          "variable" : [
                            "dmPatient",
                            "patientEntry"
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "transformpatientAdresse",
                      "source" : [
                        {
                          "context" : "src",
                          "element" : "patientAdresse",
                          "variable" : "patientAdresse",
                          "condition" : "patientAdresse.patientId = %patient.patientId"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "setAddress",
                          "variable" : [
                            "patientAdresse",
                            "dmPatient"
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "encounterentries",
                      "source" : [
                        {
                          "context" : "src",
                          "element" : "donneesPmsi",
                          "variable" : "pmsi",
                          "condition" : "pmsi.patientId = %patient.patientId"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable",
                          "element" : "entry",
                          "variable" : "encounterEntry"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createencounter",
                          "source" : [
                            {
                              "context" : "pmsi"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "encounterEntry",
                              "contextType" : "variable",
                              "element" : "resource",
                              "variable" : "dmEncounter",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Encounter"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "transformencounter",
                              "source" : [
                                {
                                  "context" : "pmsi"
                                }
                              ],
                              "dependent" : [
                                {
                                  "name" : "TransformEncounter",
                                  "variable" : [
                                    "pmsi",
                                    "dmEncounter",
                                    "dmPatient"
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "setRequestAndFullUrl",
                              "source" : [
                                {
                                  "context" : "pmsi"
                                }
                              ],
                              "dependent" : [
                                {
                                  "name" : "setEntryRequestAndFullUrl",
                                  "variable" : [
                                    "dmEncounter",
                                    "encounterEntry"
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "conditionentries",
                              "source" : [
                                {
                                  "context" : "src",
                                  "element" : "diagnostics",
                                  "variable" : "diag",
                                  "condition" : "(diag.patientId = %patient.patientId) and (diag.pmsiId = %pmsi.pmsiId)"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "bundle",
                                  "contextType" : "variable",
                                  "element" : "entry",
                                  "variable" : "conditionEntry"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "createcondition",
                                  "source" : [
                                    {
                                      "context" : "diag"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "conditionEntry",
                                      "contextType" : "variable",
                                      "element" : "resource",
                                      "variable" : "dmCondition",
                                      "transform" : "create",
                                      "parameter" : [
                                        {
                                          "valueString" : "Condition"
                                        }
                                      ]
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "transformcondition",
                                      "source" : [
                                        {
                                          "context" : "diag"
                                        }
                                      ],
                                      "dependent" : [
                                        {
                                          "name" : "TransformCondition",
                                          "variable" : [
                                            "diag",
                                            "dmCondition",
                                            "dmPatient",
                                            "dmEncounter"
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "name" : "setRequestAndFullUrl",
                                      "source" : [
                                        {
                                          "context" : "diag"
                                        }
                                      ],
                                      "dependent" : [
                                        {
                                          "name" : "setEntryRequestAndFullUrl",
                                          "variable" : [
                                            "dmCondition",
                                            "conditionEntry"
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "procedureentries",
                              "source" : [
                                {
                                  "context" : "src",
                                  "element" : "actes",
                                  "variable" : "acte",
                                  "condition" : "(acte.patientId = %patient.patientId) and (acte.pmsiId = %pmsi.pmsiId)"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "bundle",
                                  "contextType" : "variable",
                                  "element" : "entry",
                                  "variable" : "procedureEntry"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "createprocedure",
                                  "source" : [
                                    {
                                      "context" : "acte"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "procedureEntry",
                                      "contextType" : "variable",
                                      "element" : "resource",
                                      "variable" : "dmProcedure",
                                      "transform" : "create",
                                      "parameter" : [
                                        {
                                          "valueString" : "Procedure"
                                        }
                                      ]
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "transformprocedure",
                                      "source" : [
                                        {
                                          "context" : "acte"
                                        }
                                      ],
                                      "dependent" : [
                                        {
                                          "name" : "TransformProcedure",
                                          "variable" : [
                                            "acte",
                                            "dmProcedure",
                                            "dmPatient",
                                            "dmEncounter"
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "name" : "setRequestAndFullUrl",
                                      "source" : [
                                        {
                                          "context" : "acte"
                                        }
                                      ],
                                      "dependent" : [
                                        {
                                          "name" : "setEntryRequestAndFullUrl",
                                          "variable" : [
                                            "dmProcedure",
                                            "procedureEntry"
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "labentries",
                      "source" : [
                        {
                          "context" : "src",
                          "element" : "biologie",
                          "variable" : "lab",
                          "condition" : "lab.patientId = %patient.patientId"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable",
                          "element" : "entry",
                          "variable" : "labEntry"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createlabobs",
                          "source" : [
                            {
                              "context" : "lab"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "labEntry",
                              "contextType" : "variable",
                              "element" : "resource",
                              "variable" : "dmLab",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Observation"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "transformLabObs",
                              "source" : [
                                {
                                  "context" : "lab"
                                }
                              ],
                              "dependent" : [
                                {
                                  "name" : "TransformLabObservation",
                                  "variable" : [
                                    "lab",
                                    "dmLab",
                                    "dmPatient"
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "setRequestAndFullUrl",
                              "source" : [
                                {
                                  "context" : "lab"
                                }
                              ],
                              "dependent" : [
                                {
                                  "name" : "setEntryRequestAndFullUrl",
                                  "variable" : [
                                    "dmLab",
                                    "labEntry"
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "medicationentries",
                      "source" : [
                        {
                          "context" : "src",
                          "element" : "prescription",
                          "variable" : "pres",
                          "condition" : "pres.patientId = %patient.patientId"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable",
                          "element" : "entry",
                          "variable" : "medReqEntry"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createmedreq",
                          "source" : [
                            {
                              "context" : "pres"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "medReqEntry",
                              "contextType" : "variable",
                              "element" : "resource",
                              "variable" : "dmMedReq",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "MedicationRequest"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "createmedrequest",
                              "source" : [
                                {
                                  "context" : "src"
                                }
                              ],
                              "dependent" : [
                                {
                                  "name" : "TransformMedicationRequest",
                                  "variable" : [
                                    "pres",
                                    "dmMedReq",
                                    "dmPatient"
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "setRequestAndFullUrl",
                              "source" : [
                                {
                                  "context" : "pres"
                                }
                              ],
                              "dependent" : [
                                {
                                  "name" : "setEntryRequestAndFullUrl",
                                  "variable" : [
                                    "dmMedReq",
                                    "medReqEntry"
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "transformPoso",
                              "source" : [
                                {
                                  "context" : "src",
                                  "element" : "posologie",
                                  "variable" : "poso",
                                  "condition" : "%poso.prescriptionId = %pres.prescriptionId"
                                }
                              ],
                              "dependent" : [
                                {
                                  "name" : "setPoso",
                                  "variable" : [
                                    "poso",
                                    "pres",
                                    "dmMedReq"
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "administrationentries",
                              "source" : [
                                {
                                  "context" : "src",
                                  "element" : "administration",
                                  "variable" : "admin",
                                  "condition" : "(admin.patientId = %patient.patientId) and (admin.prescriptionId = pres.prescriptionId)"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "bundle",
                                  "contextType" : "variable",
                                  "element" : "entry",
                                  "variable" : "adminEntry"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "createmedadmin",
                                  "source" : [
                                    {
                                      "context" : "admin"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "adminEntry",
                                      "contextType" : "variable",
                                      "element" : "resource",
                                      "variable" : "dmAdmin",
                                      "transform" : "create",
                                      "parameter" : [
                                        {
                                          "valueString" : "MedicationAdministration"
                                        }
                                      ]
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "createmedadmin",
                                      "source" : [
                                        {
                                          "context" : "admin"
                                        }
                                      ],
                                      "dependent" : [
                                        {
                                          "name" : "TransformMedicationAdministrationWOrder",
                                          "variable" : [
                                            "admin",
                                            "dmAdmin",
                                            "dmPatient",
                                            "dmMedReq"
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "name" : "setRequestAndFullUrl",
                                      "source" : [
                                        {
                                          "context" : "admin"
                                        }
                                      ],
                                      "dependent" : [
                                        {
                                          "name" : "setEntryRequestAndFullUrl",
                                          "variable" : [
                                            "dmAdmin",
                                            "adminEntry"
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "lifestyleentries",
                      "source" : [
                        {
                          "context" : "src",
                          "element" : "styleVie",
                          "variable" : "lifestyle",
                          "condition" : "lifestyle.patientId = %patient.patientId"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "tobaccoentries",
                          "source" : [
                            {
                              "context" : "lifestyle",
                              "element" : "consommationTabac",
                              "variable" : "tobacco",
                              "condition" : "tobacco.exists()"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable",
                              "element" : "entry",
                              "variable" : "tobaccoEntry"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "createtobaccoobs",
                              "source" : [
                                {
                                  "context" : "tobacco"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "tobaccoEntry",
                                  "contextType" : "variable",
                                  "element" : "resource",
                                  "variable" : "tobaccoObs",
                                  "transform" : "create",
                                  "parameter" : [
                                    {
                                      "valueString" : "Observation"
                                    }
                                  ]
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "createtobaccoobs",
                                  "source" : [
                                    {
                                      "context" : "lifestyle"
                                    }
                                  ],
                                  "dependent" : [
                                    {
                                      "name" : "TransformTobaccoObservation",
                                      "variable" : [
                                        "lifestyle",
                                        "tobaccoObs",
                                        "dmPatient"
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "setRequestAndFullUrl",
                                  "source" : [
                                    {
                                      "context" : "lifestyle"
                                    }
                                  ],
                                  "dependent" : [
                                    {
                                      "name" : "setEntryRequestAndFullUrl",
                                      "variable" : [
                                        "tobaccoObs",
                                        "tobaccoEntry"
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "alcoholentries",
                          "source" : [
                            {
                              "context" : "lifestyle",
                              "element" : "consommationAlcool",
                              "variable" : "alcohol",
                              "condition" : "alcohol.exists()"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable",
                              "element" : "entry",
                              "variable" : "alcoholEntry"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "createalcoholobs",
                              "source" : [
                                {
                                  "context" : "alcohol"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "alcoholEntry",
                                  "contextType" : "variable",
                                  "element" : "resource",
                                  "variable" : "alcoholObs",
                                  "transform" : "create",
                                  "parameter" : [
                                    {
                                      "valueString" : "Observation"
                                    }
                                  ]
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "createalcoholobs",
                                  "source" : [
                                    {
                                      "context" : "lifestyle"
                                    }
                                  ],
                                  "dependent" : [
                                    {
                                      "name" : "TransformAlcoholObservation",
                                      "variable" : [
                                        "lifestyle",
                                        "alcoholObs",
                                        "dmPatient"
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "setRequestAndFullUrl",
                                  "source" : [
                                    {
                                      "context" : "lifestyle"
                                    }
                                  ],
                                  "dependent" : [
                                    {
                                      "name" : "setEntryRequestAndFullUrl",
                                      "variable" : [
                                        "alcoholObs",
                                        "alcoholEntry"
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "drugentries",
                          "source" : [
                            {
                              "context" : "lifestyle",
                              "element" : "consommationAutresDrogues",
                              "variable" : "drugs",
                              "condition" : "drugs.exists()"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable",
                              "element" : "entry",
                              "variable" : "drugEntry"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "createdrugobs",
                              "source" : [
                                {
                                  "context" : "drugs"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "drugEntry",
                                  "contextType" : "variable",
                                  "element" : "resource",
                                  "variable" : "drugObs",
                                  "transform" : "create",
                                  "parameter" : [
                                    {
                                      "valueString" : "Observation"
                                    }
                                  ]
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "createdrugobs",
                                  "source" : [
                                    {
                                      "context" : "lifestyle"
                                    }
                                  ],
                                  "dependent" : [
                                    {
                                      "name" : "TransformDrugObservation",
                                      "variable" : [
                                        "lifestyle",
                                        "drugObs",
                                        "dmPatient"
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "setRequestAndFullUrl",
                                  "source" : [
                                    {
                                      "context" : "lifestyle"
                                    }
                                  ],
                                  "dependent" : [
                                    {
                                      "name" : "setEntryRequestAndFullUrl",
                                      "variable" : [
                                        "drugObs",
                                        "drugEntry"
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "physicalentries",
                          "source" : [
                            {
                              "context" : "lifestyle",
                              "element" : "activitePhysique",
                              "variable" : "physical",
                              "condition" : "physical.exists()"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "bundle",
                              "contextType" : "variable",
                              "element" : "entry",
                              "variable" : "physicalEntry"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "createphysicalobs",
                              "source" : [
                                {
                                  "context" : "physical"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "physicalEntry",
                                  "contextType" : "variable",
                                  "element" : "resource",
                                  "variable" : "physicalObs",
                                  "transform" : "create",
                                  "parameter" : [
                                    {
                                      "valueString" : "Observation"
                                    }
                                  ]
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "createphysicalobs",
                                  "source" : [
                                    {
                                      "context" : "lifestyle"
                                    }
                                  ],
                                  "dependent" : [
                                    {
                                      "name" : "TransformPhysicalActivityObservation",
                                      "variable" : [
                                        "lifestyle",
                                        "physicalObs",
                                        "dmPatient"
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "setRequestAndFullUrl",
                                  "source" : [
                                    {
                                      "context" : "lifestyle"
                                    }
                                  ],
                                  "dependent" : [
                                    {
                                      "name" : "setEntryRequestAndFullUrl",
                                      "variable" : [
                                        "physicalObs",
                                        "physicalEntry"
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "vitalentries",
                      "source" : [
                        {
                          "context" : "src",
                          "element" : "dossierSoins",
                          "variable" : "soin",
                          "condition" : "soin.patientId = %patient.patientId"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable",
                          "element" : "entry",
                          "variable" : "vitalEntry"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createmesureobs",
                          "source" : [
                            {
                              "context" : "soin"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "vitalEntry",
                              "contextType" : "variable",
                              "element" : "resource",
                              "variable" : "dmObs",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Observation"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "createmesureobs",
                              "source" : [
                                {
                                  "context" : "soin"
                                }
                              ],
                              "dependent" : [
                                {
                                  "name" : "TransformVitalSigns",
                                  "variable" : [
                                    "soin",
                                    "dmObs",
                                    "dmPatient"
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "setRequestAndFullUrl",
                              "source" : [
                                {
                                  "context" : "soin"
                                }
                              ],
                              "dependent" : [
                                {
                                  "name" : "setEntryRequestAndFullUrl",
                                  "variable" : [
                                    "dmObs",
                                    "vitalEntry"
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "administrationentries",
                      "source" : [
                        {
                          "context" : "src",
                          "element" : "administration",
                          "variable" : "admin",
                          "condition" : "(admin.patientId = %patient.patientId) and admin.prescriptionId.empty()"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable",
                          "element" : "entry",
                          "variable" : "adminEntry"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createmedadmin",
                          "source" : [
                            {
                              "context" : "admin"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "adminEntry",
                              "contextType" : "variable",
                              "element" : "resource",
                              "variable" : "dmAdmin",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "MedicationAdministration"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "createmedadmin",
                              "source" : [
                                {
                                  "context" : "admin"
                                }
                              ],
                              "dependent" : [
                                {
                                  "name" : "TransformMedicationAdministrationWOOrder",
                                  "variable" : [
                                    "admin",
                                    "dmAdmin",
                                    "dmPatient"
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "setRequestAndFullUrl",
                              "source" : [
                                {
                                  "context" : "admin"
                                }
                              ],
                              "dependent" : [
                                {
                                  "name" : "setEntryRequestAndFullUrl",
                                  "variable" : [
                                    "dmAdmin",
                                    "adminEntry"
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "TransformPatient",
          "typeMode" : "none",
          "documentation" : "---------------------------------------------------------\r\nPATIENT TRANSFORMATION\r\n---------------------------------------------------------",
          "input" : [
            {
              "name" : "src",
              "mode" : "source"
            },
            {
              "name" : "tgt",
              "type" : "Patient",
              "mode" : "target"
            }
          ],
          "rule" : [
            {
              "name" : "setId",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgt",
                  "contextType" : "variable",
                  "element" : "id",
                  "transform" : "uuid"
                }
              ]
            },
            {
              "name" : "patientidentifier",
              "source" : [
                {
                  "context" : "src",
                  "element" : "patientId",
                  "variable" : "pid"
                }
              ],
              "target" : [
                {
                  "context" : "tgt",
                  "contextType" : "variable",
                  "element" : "identifier",
                  "variable" : "identifier"
                }
              ],
              "rule" : [
                {
                  "name" : "iduse",
                  "source" : [
                    {
                      "context" : "pid"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "identifier",
                      "contextType" : "variable",
                      "element" : "use",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "usual"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "idtype",
                  "source" : [
                    {
                      "context" : "pid"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "identifier",
                      "contextType" : "variable",
                      "element" : "type",
                      "transform" : "cc",
                      "parameter" : [
                        {
                          "valueString" : "http://terminology.hl7.org/CodeSystem/v2-0203"
                        },
                        {
                          "valueString" : "PI"
                        },
                        {
                          "valueString" : "Patient Identifier"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "idsystem",
                  "source" : [
                    {
                      "context" : "pid"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "identifier",
                      "contextType" : "variable",
                      "element" : "system",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "https://hospital.eu/ehr/patient-id"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "idvalue",
                  "source" : [
                    {
                      "context" : "pid"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "identifier",
                      "contextType" : "variable",
                      "element" : "value",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "pid"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "insidentifier",
              "source" : [
                {
                  "context" : "src",
                  "element" : "ins",
                  "variable" : "ins",
                  "condition" : "ins.exists()"
                }
              ],
              "target" : [
                {
                  "context" : "tgt",
                  "contextType" : "variable",
                  "element" : "identifier",
                  "variable" : "insIdentifier"
                }
              ],
              "rule" : [
                {
                  "name" : "insuse",
                  "source" : [
                    {
                      "context" : "ins"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "insIdentifier",
                      "contextType" : "variable",
                      "element" : "use",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "official"
                        }
                      ]
                    }
                  ],
                  "documentation" : "On part du principe qu'on n'est pas sur un old."
                },
                {
                  "name" : "instype",
                  "source" : [
                    {
                      "context" : "ins"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "insIdentifier",
                      "contextType" : "variable",
                      "element" : "type",
                      "transform" : "cc",
                      "parameter" : [
                        {
                          "valueString" : "https://hl7.fr/ig/fhir/core/CodeSystem/fr-core-cs-v2-0203"
                        },
                        {
                          "valueString" : "INS-NIR"
                        },
                        {
                          "valueString" : "NIR définitif"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "inssystem",
                  "source" : [
                    {
                      "context" : "ins"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "insIdentifier",
                      "contextType" : "variable",
                      "element" : "system",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "urn:oid:1.2.250.1.213.1.4.8"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "insvalue",
                  "source" : [
                    {
                      "context" : "ins"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "insIdentifier",
                      "contextType" : "variable",
                      "element" : "value",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "ins"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "patientname",
              "source" : [
                {
                  "context" : "src",
                  "condition" : "src.nom.exists() or src.prenom.exists()"
                }
              ],
              "target" : [
                {
                  "context" : "tgt",
                  "contextType" : "variable",
                  "element" : "name",
                  "variable" : "name"
                }
              ],
              "rule" : [
                {
                  "name" : "familyname",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "nom",
                      "variable" : "lastName"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "name",
                      "contextType" : "variable",
                      "element" : "family",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "lastName"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "givenname",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "prenom",
                      "variable" : "firstName"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "name",
                      "contextType" : "variable",
                      "element" : "given",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "firstName"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "nameuse",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "name",
                      "contextType" : "variable",
                      "element" : "use",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "official"
                        }
                      ]
                    }
                  ],
                  "documentation" : "hypothèse un peu forte."
                }
              ]
            },
            {
              "name" : "birthdate",
              "source" : [
                {
                  "context" : "src",
                  "element" : "dateNaissance",
                  "variable" : "birthDate"
                }
              ],
              "target" : [
                {
                  "context" : "tgt",
                  "contextType" : "variable",
                  "element" : "birthDate",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueId" : "birthDate"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "gendermale",
              "source" : [
                {
                  "context" : "src",
                  "element" : "sexe",
                  "variable" : "gender",
                  "condition" : "gender = 'h'"
                }
              ],
              "target" : [
                {
                  "context" : "tgt",
                  "contextType" : "variable",
                  "element" : "gender",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "male"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "genderfemale",
              "source" : [
                {
                  "context" : "src",
                  "element" : "sexe",
                  "variable" : "gender",
                  "condition" : "gender = 'f'"
                }
              ],
              "target" : [
                {
                  "context" : "tgt",
                  "contextType" : "variable",
                  "element" : "gender",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "female"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "genderunknown",
              "source" : [
                {
                  "context" : "src",
                  "element" : "sexe",
                  "variable" : "gender",
                  "condition" : "gender.exists() and (gender != 'h') and (gender != 'f')"
                }
              ],
              "target" : [
                {
                  "context" : "tgt",
                  "contextType" : "variable",
                  "element" : "gender",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "unknown"
                    }
                  ]
                }
              ],
              "documentation" : "n'a pas grand sens en l'état des contraintes SQL"
            },
            {
              "name" : "deathDate",
              "source" : [
                {
                  "context" : "src",
                  "element" : "dateDeces",
                  "variable" : "deathDate",
                  "condition" : "deathDate.exists()"
                }
              ],
              "target" : [
                {
                  "context" : "tgt",
                  "contextType" : "variable",
                  "element" : "deceased",
                  "variable" : "deceasedDate",
                  "transform" : "cast",
                  "parameter" : [
                    {
                      "valueId" : "deathDate"
                    },
                    {
                      "valueString" : "dateTime"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "deathSource",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "sourceDeces",
                      "variable" : "deathSource",
                      "condition" : "deathSource.exists()"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "deceasedDate",
                      "contextType" : "variable",
                      "element" : "extension",
                      "variable" : "DeathSourceExtension"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "deathSourceUrl",
                      "source" : [
                        {
                          "context" : "deathSource"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "DeathSourceExtension",
                          "contextType" : "variable",
                          "element" : "url",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DeathSource"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "deathSourceValue",
                      "source" : [
                        {
                          "context" : "deathSource"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "DeathSourceExtension",
                          "contextType" : "variable",
                          "element" : "value",
                          "transform" : "cast",
                          "parameter" : [
                            {
                              "valueId" : "deathSource"
                            },
                            {
                              "valueString" : "code"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "multiplebirth",
              "source" : [
                {
                  "context" : "src",
                  "element" : "rangGemellaire",
                  "variable" : "twin",
                  "condition" : "twin.exists()"
                }
              ],
              "target" : [
                {
                  "context" : "tgt",
                  "contextType" : "variable",
                  "element" : "multipleBirth",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueId" : "twin"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "setAddress",
          "typeMode" : "none",
          "documentation" : "========================================================================\r\nPATIENT_LOCATION TRANSFORMATION\r\n========================================================================",
          "input" : [
            {
              "name" : "src",
              "mode" : "source"
            },
            {
              "name" : "tgtPat",
              "type" : "Patient",
              "mode" : "target"
            }
          ],
          "rule" : [
            {
              "name" : "checkSource",
              "source" : [
                {
                  "context" : "src",
                  "condition" : "src.latitude.exists() or src.longitude.exists() or src.codeIris.exists() or src.libelleIris.exists() or src.codeGeographiqueResidence.exists()"
                }
              ],
              "rule" : [
                {
                  "name" : "createAddress",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "tgtPat",
                      "contextType" : "variable",
                      "element" : "address",
                      "variable" : "newAddress"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "setCoordinates",
                      "source" : [
                        {
                          "context" : "src",
                          "condition" : "src.latitude.exists() or src.longitude.exists()"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "newAddress",
                          "contextType" : "variable",
                          "element" : "extension",
                          "variable" : "geolocationExtension"
                        },
                        {
                          "context" : "geolocationExtension",
                          "contextType" : "variable",
                          "element" : "url",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "http://hl7.org/fhir/StructureDefinition/geolocation"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "setLat",
                          "source" : [
                            {
                              "context" : "src",
                              "element" : "latitude",
                              "variable" : "srcLat"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "geolocationExtension",
                              "contextType" : "variable",
                              "element" : "extension",
                              "variable" : "tgtLat"
                            },
                            {
                              "context" : "tgtLat",
                              "contextType" : "variable",
                              "element" : "url",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueString" : "latitude"
                                }
                              ]
                            },
                            {
                              "context" : "tgtLat",
                              "contextType" : "variable",
                              "element" : "value",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueId" : "srcLat"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "setLong",
                          "source" : [
                            {
                              "context" : "src",
                              "element" : "longitude",
                              "variable" : "srcLong"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "geolocationExtension",
                              "contextType" : "variable",
                              "element" : "extension",
                              "variable" : "tgtLong"
                            },
                            {
                              "context" : "tgtLong",
                              "contextType" : "variable",
                              "element" : "url",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueString" : "longitude"
                                }
                              ]
                            },
                            {
                              "context" : "tgtLong",
                              "contextType" : "variable",
                              "element" : "value",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueId" : "srcLong"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "setIris",
                      "source" : [
                        {
                          "context" : "src",
                          "condition" : "src.codeIris.exists() or src.libelleIris.exists()"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "newAddress",
                          "contextType" : "variable",
                          "element" : "line",
                          "variable" : "irisLine",
                          "transform" : "evaluate",
                          "parameter" : [
                            {
                              "valueString" : "%src.libelleIris"
                            }
                          ]
                        },
                        {
                          "context" : "irisLine",
                          "contextType" : "variable",
                          "element" : "extension",
                          "variable" : "irisExtension",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Extension"
                            }
                          ]
                        },
                        {
                          "context" : "irisExtension",
                          "contextType" : "variable",
                          "element" : "url",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-censusTract"
                            }
                          ]
                        },
                        {
                          "context" : "irisExtension",
                          "contextType" : "variable",
                          "element" : "value",
                          "transform" : "evaluate",
                          "parameter" : [
                            {
                              "valueString" : "%src.codeIris"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "SetResidencePmsi",
                      "source" : [
                        {
                          "context" : "src",
                          "element" : "codeGeographiqueResidence",
                          "variable" : "srcCodeGeographiqueResidence",
                          "condition" : "src.codeGeographiqueResidence.exists()"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "newAddress",
                          "contextType" : "variable",
                          "element" : "extension",
                          "variable" : "residencePmsiExtension"
                        },
                        {
                          "context" : "residencePmsiExtension",
                          "contextType" : "variable",
                          "element" : "url",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/PmsiCodeGeo"
                            }
                          ]
                        },
                        {
                          "context" : "residencePmsiExtension",
                          "contextType" : "variable",
                          "element" : "value",
                          "transform" : "cast",
                          "parameter" : [
                            {
                              "valueId" : "srcCodeGeographiqueResidence"
                            },
                            {
                              "valueString" : "code"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "setDateRecueil",
                      "source" : [
                        {
                          "context" : "src",
                          "element" : "dateRecueil",
                          "variable" : "dateRecueil"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "newAddress",
                          "contextType" : "variable",
                          "element" : "period",
                          "variable" : "newAddressPeriod"
                        },
                        {
                          "context" : "newAddressPeriod",
                          "contextType" : "variable",
                          "element" : "start",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueId" : "dateRecueil"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "TransformEncounter",
          "typeMode" : "none",
          "documentation" : "========================================================================\r\nENCOUNTER TRANSFORMATION\r\n========================================================================",
          "input" : [
            {
              "name" : "src",
              "mode" : "source"
            },
            {
              "name" : "tgtEnc",
              "type" : "Encounter",
              "mode" : "target"
            },
            {
              "name" : "patient",
              "mode" : "source"
            }
          ],
          "rule" : [
            {
              "name" : "setId",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtEnc",
                  "contextType" : "variable",
                  "element" : "id",
                  "transform" : "uuid"
                }
              ]
            },
            {
              "name" : "encounteridentifier",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtEnc",
                  "contextType" : "variable",
                  "element" : "identifier",
                  "variable" : "identifier"
                }
              ],
              "rule" : [
                {
                  "name" : "idtype",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "identifier",
                      "contextType" : "variable",
                      "element" : "type",
                      "transform" : "cc",
                      "parameter" : [
                        {
                          "valueString" : "https://hl7.fr/ig/fhir/core/CodeSystem/fr-core-cs-identifier-type"
                        },
                        {
                          "valueString" : "VN"
                        },
                        {
                          "valueString" : "Visit Number"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "encounteridsystem",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "identifier",
                      "contextType" : "variable",
                      "element" : "system",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "https://hospital.eu/ehr/pmsi-id"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "encounteridvalue",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "pmsiId",
                      "variable" : "srcEncoutnerId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "identifier",
                      "contextType" : "variable",
                      "element" : "value",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "srcEncoutnerId"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "encounterstatus",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtEnc",
                  "contextType" : "variable",
                  "element" : "status",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "finished"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "encounterclass",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtEnc",
                  "contextType" : "variable",
                  "element" : "class",
                  "transform" : "c",
                  "parameter" : [
                    {
                      "valueString" : "http://terminology.hl7.org/CodeSystem/v3-ActCode"
                    },
                    {
                      "valueString" : "IMP"
                    },
                    {
                      "valueString" : "inpatient encounter"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "encountersubject",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtEnc",
                  "contextType" : "variable",
                  "element" : "subject",
                  "variable" : "ref",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Reference"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "subjectreference",
                  "source" : [
                    {
                      "context" : "patient",
                      "element" : "id",
                      "variable" : "patientId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "reference",
                      "transform" : "evaluate",
                      "parameter" : [
                        {
                          "valueString" : "'Patient/' + %patientId"
                        }
                      ]
                    },
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "type",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "Patient"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "encounterperiod",
              "source" : [
                {
                  "context" : "src",
                  "condition" : "src.dateDebutSejour.exists() or src.dateFinSejour.exists()"
                }
              ],
              "target" : [
                {
                  "context" : "tgtEnc",
                  "contextType" : "variable",
                  "element" : "period",
                  "variable" : "period"
                }
              ],
              "rule" : [
                {
                  "name" : "periodstart",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "dateDebutSejour",
                      "variable" : "startDate"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "period",
                      "contextType" : "variable",
                      "element" : "start",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "startDate"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "periodend",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "dateFinSejour",
                      "variable" : "endDate"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "period",
                      "contextType" : "variable",
                      "element" : "end",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "endDate"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "encounterhospitalization",
              "source" : [
                {
                  "context" : "src",
                  "condition" : "src.modeEntree.exists() or src.modeSortie.exists()"
                }
              ],
              "target" : [
                {
                  "context" : "tgtEnc",
                  "contextType" : "variable",
                  "element" : "hospitalization",
                  "variable" : "hosp"
                }
              ],
              "rule" : [
                {
                  "name" : "admitsource",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "modeEntree",
                      "variable" : "admitSource"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "hosp",
                      "contextType" : "variable",
                      "element" : "admitSource",
                      "variable" : "admitSrc"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "admitsourcetext",
                      "source" : [
                        {
                          "context" : "admitSource"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "admitSrc",
                          "contextType" : "variable",
                          "element" : "text",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueId" : "admitSource"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "dischargedisposition",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "modeSortie",
                      "variable" : "dischargeDisp"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "hosp",
                      "contextType" : "variable",
                      "element" : "dischargeDisposition",
                      "variable" : "dischargeDsp"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "dischargedisptext",
                      "source" : [
                        {
                          "context" : "dischargeDisp"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "dischargeDsp",
                          "contextType" : "variable",
                          "element" : "text",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueId" : "dischargeDisp"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "provider",
              "source" : [
                {
                  "context" : "src",
                  "condition" : "src.uniteFonctionnelle.exists() or src.service.exists() or src.etablissement.exists()"
                }
              ],
              "target" : [
                {
                  "context" : "tgtEnc",
                  "contextType" : "variable",
                  "element" : "serviceProvider",
                  "variable" : "provider"
                }
              ],
              "rule" : [
                {
                  "name" : "providerdisplay",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "provider",
                      "contextType" : "variable",
                      "element" : "display",
                      "transform" : "evaluate",
                      "parameter" : [
                        {
                          "valueString" : "iif(%src.uniteFonctionnelle.exists(), %src.uniteFonctionnelle, iif(%src.service.exists(), %src.service, %src.etablissement))"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "TransformCondition",
          "typeMode" : "none",
          "documentation" : "========================================================================\r\nCONDITION TRANSFORMATION\r\n========================================================================",
          "input" : [
            {
              "name" : "src",
              "mode" : "source"
            },
            {
              "name" : "tgtCond",
              "type" : "Condition",
              "mode" : "target"
            },
            {
              "name" : "patient",
              "mode" : "source"
            },
            {
              "name" : "encounter",
              "mode" : "source"
            }
          ],
          "rule" : [
            {
              "name" : "setId",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtCond",
                  "contextType" : "variable",
                  "element" : "id",
                  "transform" : "uuid"
                }
              ]
            },
            {
              "name" : "conditionidentifier",
              "source" : [
                {
                  "context" : "src",
                  "element" : "diagnosticId",
                  "variable" : "diagId"
                }
              ],
              "target" : [
                {
                  "context" : "tgtCond",
                  "contextType" : "variable",
                  "element" : "identifier",
                  "variable" : "identifier"
                }
              ],
              "rule" : [
                {
                  "name" : "conditionidsystem",
                  "source" : [
                    {
                      "context" : "diagId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "identifier",
                      "contextType" : "variable",
                      "element" : "system",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "https://hospital.eu/ehr/diagnostic-id"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "conditionidvalue",
                  "source" : [
                    {
                      "context" : "diagId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "identifier",
                      "contextType" : "variable",
                      "element" : "value",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "diagId"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "categoryencounterDiag",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtCond",
                  "contextType" : "variable",
                  "element" : "category",
                  "transform" : "cc",
                  "parameter" : [
                    {
                      "valueString" : "http://terminology.hl7.org/CodeSystem/condition-category"
                    },
                    {
                      "valueString" : "encounter-diagnosis"
                    },
                    {
                      "valueString" : "Encounter Diagnosis"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "conditioncategory",
              "source" : [
                {
                  "context" : "src",
                  "element" : "typeDiagnostic",
                  "variable" : "diagType"
                }
              ],
              "target" : [
                {
                  "context" : "tgtCond",
                  "contextType" : "variable",
                  "element" : "category",
                  "variable" : "category"
                }
              ],
              "rule" : [
                {
                  "name" : "categorytext",
                  "source" : [
                    {
                      "context" : "diagType"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "category",
                      "contextType" : "variable",
                      "element" : "text",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "diagType"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "varcode",
              "source" : [
                {
                  "context" : "src",
                  "element" : "codeDiagnostic",
                  "variable" : "srcCode"
                }
              ],
              "target" : [
                {
                  "context" : "tgtCond",
                  "contextType" : "variable",
                  "element" : "code",
                  "variable" : "conditionCode"
                }
              ],
              "rule" : [
                {
                  "name" : "conditioncode",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "libelleDiagnostic",
                      "variable" : "label"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "conditionCode",
                      "contextType" : "variable",
                      "element" : "coding",
                      "variable" : "tgtCoding"
                    },
                    {
                      "context" : "tgtCoding",
                      "contextType" : "variable",
                      "element" : "system",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "http://hl7.org/fhir/sid/icd-10"
                        }
                      ]
                    },
                    {
                      "context" : "tgtCoding",
                      "contextType" : "variable",
                      "element" : "code",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "srcCode"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "codetext",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "libelleDiagnostic",
                      "variable" : "text"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "conditionCode",
                      "contextType" : "variable",
                      "element" : "text",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "text"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "conditionsubject",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtCond",
                  "contextType" : "variable",
                  "element" : "subject",
                  "variable" : "ref",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Reference"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "subjectref",
                  "source" : [
                    {
                      "context" : "patient",
                      "element" : "id",
                      "variable" : "patientId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "reference",
                      "transform" : "evaluate",
                      "parameter" : [
                        {
                          "valueString" : "'Patient/' + %patientId"
                        }
                      ]
                    },
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "type",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "Patient"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "conditionencounter",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtCond",
                  "contextType" : "variable",
                  "element" : "encounter",
                  "variable" : "ref",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Reference"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "encounterref",
                  "source" : [
                    {
                      "context" : "encounter",
                      "element" : "id",
                      "variable" : "encounterId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "reference",
                      "transform" : "evaluate",
                      "parameter" : [
                        {
                          "valueString" : "'Encounter/' + %encounterId"
                        }
                      ]
                    },
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "type",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "Encounter"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "conditionrecordeddate",
              "source" : [
                {
                  "context" : "src",
                  "element" : "dateRecueil",
                  "variable" : "entryDate"
                }
              ],
              "target" : [
                {
                  "context" : "tgtCond",
                  "contextType" : "variable",
                  "element" : "recordedDate",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueId" : "entryDate"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "conditionclinicalstatus",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtCond",
                  "contextType" : "variable",
                  "element" : "clinicalStatus",
                  "transform" : "cc",
                  "parameter" : [
                    {
                      "valueString" : "http://terminology.hl7.org/CodeSystem/condition-clinical"
                    },
                    {
                      "valueString" : "active"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "conditionverificationstatus",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtCond",
                  "contextType" : "variable",
                  "element" : "verificationStatus",
                  "transform" : "cc",
                  "parameter" : [
                    {
                      "valueString" : "http://terminology.hl7.org/CodeSystem/condition-ver-status"
                    },
                    {
                      "valueString" : "confirmed"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "TransformProcedure",
          "typeMode" : "none",
          "documentation" : "========================================================================\r\nPROCEDURE TRANSFORMATION\r\n========================================================================",
          "input" : [
            {
              "name" : "src",
              "mode" : "source"
            },
            {
              "name" : "tgtProc",
              "type" : "Procedure",
              "mode" : "target"
            },
            {
              "name" : "patient",
              "mode" : "source"
            },
            {
              "name" : "encounter",
              "mode" : "source"
            }
          ],
          "rule" : [
            {
              "name" : "setId",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtProc",
                  "contextType" : "variable",
                  "element" : "id",
                  "transform" : "uuid"
                }
              ]
            },
            {
              "name" : "procedureidentifier",
              "source" : [
                {
                  "context" : "src",
                  "element" : "acteId",
                  "variable" : "acteId"
                }
              ],
              "target" : [
                {
                  "context" : "tgtProc",
                  "contextType" : "variable",
                  "element" : "identifier",
                  "variable" : "identifier"
                }
              ],
              "rule" : [
                {
                  "name" : "procedureidsystem",
                  "source" : [
                    {
                      "context" : "acteId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "identifier",
                      "contextType" : "variable",
                      "element" : "system",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "https://hospital.eu/ehr/acte-id"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "procedureidvalue",
                  "source" : [
                    {
                      "context" : "acteId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "identifier",
                      "contextType" : "variable",
                      "element" : "value",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "acteId"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "procedurestatus",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtProc",
                  "contextType" : "variable",
                  "element" : "status",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "completed"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "procedurecode",
              "source" : [
                {
                  "context" : "src",
                  "element" : "codeActe",
                  "variable" : "code"
                }
              ],
              "target" : [
                {
                  "context" : "tgtProc",
                  "contextType" : "variable",
                  "element" : "code",
                  "variable" : "procedureCode"
                }
              ],
              "rule" : [
                {
                  "name" : "procedurecoding",
                  "source" : [
                    {
                      "context" : "code"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "procedureCode",
                      "contextType" : "variable",
                      "element" : "coding",
                      "variable" : "coding"
                    },
                    {
                      "context" : "coding",
                      "contextType" : "variable",
                      "element" : "system",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "https://interop.aphp.fr/ig/fhir/dm/CodeSystem/Ccam"
                        }
                      ]
                    },
                    {
                      "context" : "coding",
                      "contextType" : "variable",
                      "element" : "code",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "code"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "codetext",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "libelleActe",
                      "variable" : "text"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "procedureCode",
                      "contextType" : "variable",
                      "element" : "text",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "text"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "proceduresubject",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtProc",
                  "contextType" : "variable",
                  "element" : "subject",
                  "variable" : "ref",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Reference"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "subjectref",
                  "source" : [
                    {
                      "context" : "patient",
                      "element" : "id",
                      "variable" : "patientId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "reference",
                      "transform" : "evaluate",
                      "parameter" : [
                        {
                          "valueString" : "'Patient/' + %patientId"
                        }
                      ]
                    },
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "type",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "Patient"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "procedureencounter",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtProc",
                  "contextType" : "variable",
                  "element" : "encounter",
                  "variable" : "ref",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Reference"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "encounterref",
                  "source" : [
                    {
                      "context" : "encounter",
                      "element" : "id",
                      "variable" : "encounterId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "reference",
                      "transform" : "evaluate",
                      "parameter" : [
                        {
                          "valueString" : "'Encounter/' + %encounterId"
                        }
                      ]
                    },
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "type",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "Encounter"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "procedureperformed",
              "source" : [
                {
                  "context" : "src",
                  "element" : "dateActe",
                  "variable" : "performedDate",
                  "condition" : "%performedDate.exists()"
                }
              ],
              "target" : [
                {
                  "context" : "tgtProc",
                  "contextType" : "variable",
                  "element" : "performed",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueId" : "performedDate"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "procedureperformer",
              "source" : [
                {
                  "context" : "src",
                  "element" : "executant",
                  "variable" : "performer"
                }
              ],
              "target" : [
                {
                  "context" : "tgtProc",
                  "contextType" : "variable",
                  "element" : "performer",
                  "variable" : "perf"
                }
              ],
              "rule" : [
                {
                  "name" : "performeractor",
                  "source" : [
                    {
                      "context" : "performer"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "perf",
                      "contextType" : "variable",
                      "element" : "actor",
                      "variable" : "actor"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "performerdisplay",
                      "source" : [
                        {
                          "context" : "performer"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "actor",
                          "contextType" : "variable",
                          "element" : "display",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueId" : "performer"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "performerType",
                      "source" : [
                        {
                          "context" : "performer"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "actor",
                          "contextType" : "variable",
                          "element" : "type",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "Practitioner"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "performerFunction",
                  "source" : [
                    {
                      "context" : "performer"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "perf",
                      "contextType" : "variable",
                      "element" : "function",
                      "variable" : "function"
                    },
                    {
                      "context" : "function",
                      "contextType" : "variable",
                      "element" : "text",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "Exécutant"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "TransformLabObservation",
          "typeMode" : "none",
          "documentation" : "========================================================================\r\nLABORATORY OBSERVATION TRANSFORMATION\r\n========================================================================",
          "input" : [
            {
              "name" : "src",
              "mode" : "source"
            },
            {
              "name" : "tgtObs",
              "type" : "Observation",
              "mode" : "target"
            },
            {
              "name" : "patient",
              "mode" : "source"
            }
          ],
          "rule" : [
            {
              "name" : "setId",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "id",
                  "transform" : "uuid"
                }
              ]
            },
            {
              "name" : "labidentifier",
              "source" : [
                {
                  "context" : "src",
                  "element" : "biologieId",
                  "variable" : "bioId"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "identifier",
                  "variable" : "identifier"
                }
              ],
              "rule" : [
                {
                  "name" : "labidsystem",
                  "source" : [
                    {
                      "context" : "bioId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "identifier",
                      "contextType" : "variable",
                      "element" : "system",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "https://hospital.eu/ehr/biologie-id"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "labidvalue",
                  "source" : [
                    {
                      "context" : "bioId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "identifier",
                      "contextType" : "variable",
                      "element" : "value",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "bioId"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "statusvalidated",
              "source" : [
                {
                  "context" : "src",
                  "element" : "statutValidation",
                  "variable" : "validation",
                  "condition" : "validation = 'VALIDE'"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "status",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "final"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "statusdefault",
              "source" : [
                {
                  "context" : "src",
                  "condition" : "src.statutValidation.exists().not()"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "status",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "final"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "labcategory",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "category",
                  "variable" : "category"
                }
              ],
              "rule" : [
                {
                  "name" : "categorycoding",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "category",
                      "contextType" : "variable",
                      "element" : "coding",
                      "variable" : "coding"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "categorysystem",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "system",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "http://terminology.hl7.org/CodeSystem/observation-category"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "categorycode",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "code",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "laboratory"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "categorydisplay",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "display",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "Laboratory"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "labcode",
              "source" : [
                {
                  "context" : "src",
                  "element" : "codeLoinc",
                  "variable" : "loinc"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "code",
                  "variable" : "code"
                }
              ],
              "rule" : [
                {
                  "name" : "labcoding",
                  "source" : [
                    {
                      "context" : "loinc"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "code",
                      "contextType" : "variable",
                      "element" : "coding",
                      "variable" : "coding"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "codesystem",
                      "source" : [
                        {
                          "context" : "loinc"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "system",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "http://loinc.org"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "codevalue",
                      "source" : [
                        {
                          "context" : "loinc"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "code",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueId" : "loinc"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "codetext",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "libelleTest",
                      "variable" : "text"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "code",
                      "contextType" : "variable",
                      "element" : "text",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "text"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "labsubject",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "subject",
                  "variable" : "ref",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Reference"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "subjectref",
                  "source" : [
                    {
                      "context" : "patient",
                      "element" : "id",
                      "variable" : "patientId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "reference",
                      "transform" : "evaluate",
                      "parameter" : [
                        {
                          "valueString" : "'Patient/' + %patientId"
                        }
                      ]
                    },
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "type",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "Patient"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "labeffective",
              "source" : [
                {
                  "context" : "src",
                  "element" : "datePrelevement",
                  "variable" : "collectionDate",
                  "condition" : "%collectionDate.exists()"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "effective",
                  "transform" : "cast",
                  "parameter" : [
                    {
                      "valueId" : "collectionDate"
                    },
                    {
                      "valueString" : "dateTime"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "labvaluequantity",
              "source" : [
                {
                  "context" : "src",
                  "element" : "valeur",
                  "variable" : "numValue",
                  "condition" : "numValue.exists()"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "value",
                  "variable" : "qty",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Quantity"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "quantityvalue",
                  "source" : [
                    {
                      "context" : "numValue"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "qty",
                      "contextType" : "variable",
                      "element" : "value",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "numValue"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "quantityunit",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "unite",
                      "variable" : "unit"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "qty",
                      "contextType" : "variable",
                      "element" : "unit",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "unit"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "quantitycode",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "unite",
                      "variable" : "unit"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "qty",
                      "contextType" : "variable",
                      "element" : "code",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "unit"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "quantitysystem",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "qty",
                      "contextType" : "variable",
                      "element" : "system",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "http://unitsofmeasure.org"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "labreferencerange",
              "source" : [
                {
                  "context" : "src",
                  "condition" : "src.borneInfNormale.exists() or src.borneSupNormale.exists()"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "referenceRange",
                  "variable" : "range"
                }
              ],
              "rule" : [
                {
                  "name" : "referencelow",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "borneInfNormale",
                      "variable" : "low"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "range",
                      "contextType" : "variable",
                      "element" : "low",
                      "variable" : "lowQty"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "reflowvalue",
                      "source" : [
                        {
                          "context" : "low"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "lowQty",
                          "contextType" : "variable",
                          "element" : "value",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueId" : "low"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "reflowunit",
                      "source" : [
                        {
                          "context" : "src",
                          "element" : "unite",
                          "variable" : "unit"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "lowQty",
                          "contextType" : "variable",
                          "element" : "unit",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueId" : "unit"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "reflowcode",
                      "source" : [
                        {
                          "context" : "src",
                          "element" : "unite",
                          "variable" : "unit"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "lowQty",
                          "contextType" : "variable",
                          "element" : "code",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueId" : "unit"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "reflowsystem",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "lowQty",
                          "contextType" : "variable",
                          "element" : "system",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "http://unitsofmeasure.org"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "referencehigh",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "borneSupNormale",
                      "variable" : "high"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "range",
                      "contextType" : "variable",
                      "element" : "high",
                      "variable" : "highQty"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "refhighvalue",
                      "source" : [
                        {
                          "context" : "high"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "highQty",
                          "contextType" : "variable",
                          "element" : "value",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueId" : "high"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "refhighunit",
                      "source" : [
                        {
                          "context" : "src",
                          "element" : "unite",
                          "variable" : "unit"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "highQty",
                          "contextType" : "variable",
                          "element" : "unit",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueId" : "unit"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "refhighcode",
                      "source" : [
                        {
                          "context" : "src",
                          "element" : "unite",
                          "variable" : "unit"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "highQty",
                          "contextType" : "variable",
                          "element" : "code",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueId" : "unit"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "refhighsystem",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "highQty",
                          "contextType" : "variable",
                          "element" : "system",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "http://unitsofmeasure.org"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "labperformer",
              "source" : [
                {
                  "context" : "src",
                  "element" : "laboratoire",
                  "variable" : "lab"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "performer",
                  "variable" : "performer"
                }
              ],
              "rule" : [
                {
                  "name" : "performerdisplay",
                  "source" : [
                    {
                      "context" : "lab"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "performer",
                      "contextType" : "variable",
                      "element" : "display",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "lab"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "performerType",
                  "source" : [
                    {
                      "context" : "lab"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "performer",
                      "contextType" : "variable",
                      "element" : "type",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "Organization"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "TransformMedicationRequest",
          "typeMode" : "none",
          "documentation" : "========================================================================\r\nMEDICATION REQUEST TRANSFORMATION\r\n========================================================================",
          "input" : [
            {
              "name" : "src",
              "mode" : "source"
            },
            {
              "name" : "tgtMedReq",
              "type" : "MedicationRequest",
              "mode" : "target"
            },
            {
              "name" : "patient",
              "mode" : "source"
            }
          ],
          "rule" : [
            {
              "name" : "setId",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtMedReq",
                  "contextType" : "variable",
                  "element" : "id",
                  "transform" : "uuid"
                }
              ]
            },
            {
              "name" : "medrequestidentifier",
              "source" : [
                {
                  "context" : "src",
                  "element" : "prescriptionId",
                  "variable" : "presId"
                }
              ],
              "target" : [
                {
                  "context" : "tgtMedReq",
                  "contextType" : "variable",
                  "element" : "identifier",
                  "variable" : "identifier"
                }
              ],
              "rule" : [
                {
                  "name" : "medrequestidsystem",
                  "source" : [
                    {
                      "context" : "presId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "identifier",
                      "contextType" : "variable",
                      "element" : "system",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "https://hospital.eu/ehr/prescription-id"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "medrequestidvalue",
                  "source" : [
                    {
                      "context" : "presId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "identifier",
                      "contextType" : "variable",
                      "element" : "value",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "presId"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "medrequeststatus",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtMedReq",
                  "contextType" : "variable",
                  "element" : "status",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "unknown"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "medrequestintent",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtMedReq",
                  "contextType" : "variable",
                  "element" : "intent",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "order"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "medrequestsubject",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtMedReq",
                  "contextType" : "variable",
                  "element" : "subject",
                  "variable" : "ref",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Reference"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "subjectref",
                  "source" : [
                    {
                      "context" : "patient",
                      "element" : "id",
                      "variable" : "patientId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "reference",
                      "transform" : "evaluate",
                      "parameter" : [
                        {
                          "valueString" : "'Patient/' + %patientId"
                        }
                      ]
                    },
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "type",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "Patient"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "medicationdenomination",
              "source" : [
                {
                  "context" : "src",
                  "element" : "denomination",
                  "variable" : "denomination"
                }
              ],
              "target" : [
                {
                  "context" : "tgtMedReq",
                  "contextType" : "variable",
                  "element" : "medication",
                  "variable" : "medication",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "CodeableConcept"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "medicationtext",
                  "source" : [
                    {
                      "context" : "denomination",
                      "variable" : "text"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "medication",
                      "contextType" : "variable",
                      "element" : "text",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "text"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "atccoding",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "codeAtc",
                      "variable" : "atc"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "medication",
                      "contextType" : "variable",
                      "element" : "coding",
                      "variable" : "coding"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "atcsystem",
                      "source" : [
                        {
                          "context" : "atc"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "system",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "http://www.whocc.no/atc"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "atccode",
                      "source" : [
                        {
                          "context" : "atc"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "code",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueId" : "atc"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "medauthored",
              "source" : [
                {
                  "context" : "src",
                  "element" : "datePrescription",
                  "variable" : "prescDate"
                }
              ],
              "target" : [
                {
                  "context" : "tgtMedReq",
                  "contextType" : "variable",
                  "element" : "authoredOn",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueId" : "prescDate"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "medrequester",
              "source" : [
                {
                  "context" : "src",
                  "element" : "prescripteur",
                  "variable" : "prescriber"
                }
              ],
              "target" : [
                {
                  "context" : "tgtMedReq",
                  "contextType" : "variable",
                  "element" : "requester",
                  "variable" : "requesterRef"
                }
              ],
              "rule" : [
                {
                  "name" : "requesterdisplay",
                  "source" : [
                    {
                      "context" : "prescriber"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "requesterRef",
                      "contextType" : "variable",
                      "element" : "display",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "prescriber"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "requesterType",
                  "source" : [
                    {
                      "context" : "prescriber"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "requesterRef",
                      "contextType" : "variable",
                      "element" : "type",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "Practitioner"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "setPoso",
          "typeMode" : "none",
          "documentation" : "========================================================================\r\nPOSOLOGIE TRANSFORMATION\r\n========================================================================",
          "input" : [
            {
              "name" : "srcPoso",
              "mode" : "source"
            },
            {
              "name" : "srcPres",
              "mode" : "source"
            },
            {
              "name" : "tgtMedReq",
              "mode" : "target"
            }
          ],
          "rule" : [
            {
              "name" : "dosageinstruction",
              "source" : [
                {
                  "context" : "srcPres"
                }
              ],
              "target" : [
                {
                  "context" : "tgtMedReq",
                  "contextType" : "variable",
                  "element" : "dosageInstruction",
                  "variable" : "dosageInstruction"
                }
              ],
              "rule" : [
                {
                  "name" : "dosagetext",
                  "source" : [
                    {
                      "context" : "srcPoso"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "dosageInstruction",
                      "contextType" : "variable",
                      "element" : "text",
                      "transform" : "evaluate",
                      "parameter" : [
                        {
                          "valueString" : "'Prendre' + iif(%srcPoso.quantite.exists(), ' ' + %srcPoso.quantite.toString(), '1') + iif(%srcPoso.uniteQuantite.exists(), ' ' + %srcPoso.uniteQuantite, ' comprimé') + iif(%srcPoso.nombrePrisesParJour.exists(), ' ' + %srcPoso.nombrePrisesParJour.toString() + ' fois par jour', ' selon prescription')"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "dosageroute",
                  "source" : [
                    {
                      "context" : "srcPres",
                      "element" : "voieAdministration",
                      "variable" : "route"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "dosageInstruction",
                      "contextType" : "variable",
                      "element" : "route",
                      "variable" : "routeCC"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "routecoding",
                      "source" : [
                        {
                          "context" : "route"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "routeCC",
                          "contextType" : "variable",
                          "element" : "coding",
                          "variable" : "routeCoding"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "routecode",
                          "source" : [
                            {
                              "context" : "route"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "routeCoding",
                              "contextType" : "variable",
                              "element" : "code",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueId" : "route"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "routesystem",
                          "source" : [
                            {
                              "context" : "route"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "routeCoding",
                              "contextType" : "variable",
                              "element" : "system",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueString" : "https://smt.esante.gouv.fr/terminologie-standardterms"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "dosagetiming",
                  "source" : [
                    {
                      "context" : "srcPoso"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "dosageInstruction",
                      "contextType" : "variable",
                      "element" : "timing",
                      "variable" : "timing"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "timingrepeat",
                      "source" : [
                        {
                          "context" : "srcPoso"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "timing",
                          "contextType" : "variable",
                          "element" : "repeat",
                          "variable" : "timingRepeat"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "prescriptionperiod",
                          "source" : [
                            {
                              "context" : "srcPres",
                              "condition" : "srcPres.dateDebutPrescription.exists() or srcPres.dateFinPrescription.exists()"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "timingRepeat",
                              "contextType" : "variable",
                              "element" : "bounds",
                              "variable" : "medReqPeriod",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Period"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "periodstart",
                              "source" : [
                                {
                                  "context" : "srcPres",
                                  "element" : "dateDebutPrescription",
                                  "variable" : "startDate"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "medReqPeriod",
                                  "contextType" : "variable",
                                  "element" : "start",
                                  "transform" : "copy",
                                  "parameter" : [
                                    {
                                      "valueId" : "startDate"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "periodend",
                              "source" : [
                                {
                                  "context" : "srcPres",
                                  "element" : "dateFinPrescription",
                                  "variable" : "endDate"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "medReqPeriod",
                                  "contextType" : "variable",
                                  "element" : "end",
                                  "transform" : "copy",
                                  "parameter" : [
                                    {
                                      "valueId" : "endDate"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "timingfrequency",
                          "source" : [
                            {
                              "context" : "srcPoso",
                              "element" : "nombrePrisesParJour",
                              "variable" : "frequency"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "timingRepeat",
                              "contextType" : "variable",
                              "element" : "frequency",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueId" : "frequency"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "timingperiod",
                          "source" : [
                            {
                              "context" : "srcPoso",
                              "element" : "nombrePrisesParJour",
                              "variable" : "frequency"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "timingRepeat",
                              "contextType" : "variable",
                              "element" : "period",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueString" : "1"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "timingperiodunit",
                          "source" : [
                            {
                              "context" : "srcPoso",
                              "element" : "nombrePrisesParJour",
                              "variable" : "frequency"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "timingRepeat",
                              "contextType" : "variable",
                              "element" : "periodUnit",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueString" : "d"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "doseandrate",
                  "source" : [
                    {
                      "context" : "srcPoso",
                      "element" : "quantite",
                      "variable" : "quantity"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "dosageInstruction",
                      "contextType" : "variable",
                      "element" : "doseAndRate",
                      "variable" : "doseRate"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "dosequantity",
                      "source" : [
                        {
                          "context" : "quantity"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "doseRate",
                          "contextType" : "variable",
                          "element" : "dose",
                          "variable" : "doseQuantity",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Quantity"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "dosevalue",
                          "source" : [
                            {
                              "context" : "quantity"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "doseQuantity",
                              "contextType" : "variable",
                              "element" : "value",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueId" : "quantity"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "doseunit",
                          "source" : [
                            {
                              "context" : "srcPoso",
                              "element" : "uniteQuantite",
                              "variable" : "unit"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "doseQuantity",
                              "contextType" : "variable",
                              "element" : "unit",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueId" : "unit"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "dosecode",
                          "source" : [
                            {
                              "context" : "srcPoso",
                              "element" : "uniteQuantite",
                              "variable" : "unit"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "doseQuantity",
                              "contextType" : "variable",
                              "element" : "code",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueId" : "unit"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "dosesystem",
                          "source" : [
                            {
                              "context" : "srcPoso"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "doseQuantity",
                              "contextType" : "variable",
                              "element" : "system",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueString" : "http://unitsofmeasure.org"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "TransformVitalSigns",
          "typeMode" : "none",
          "documentation" : "========================================================================\r\nVITAL SIGNS TRANSFORMATION\r\n========================================================================",
          "input" : [
            {
              "name" : "src",
              "mode" : "source"
            },
            {
              "name" : "tgtObs",
              "type" : "Observation",
              "mode" : "target"
            },
            {
              "name" : "patient",
              "mode" : "source"
            }
          ],
          "rule" : [
            {
              "name" : "setId",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "id",
                  "transform" : "uuid"
                }
              ]
            },
            {
              "name" : "medrequestidentifier",
              "source" : [
                {
                  "context" : "src",
                  "element" : "soinId",
                  "variable" : "soinId"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "identifier",
                  "variable" : "identifier"
                }
              ],
              "rule" : [
                {
                  "name" : "soinidsystem",
                  "source" : [
                    {
                      "context" : "soinId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "identifier",
                      "contextType" : "variable",
                      "element" : "system",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "https://hospital.eu/ehr/soin-id"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "soinidvalue",
                  "source" : [
                    {
                      "context" : "soinId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "identifier",
                      "contextType" : "variable",
                      "element" : "value",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "soinId"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "status",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "status",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "final"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "category",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "category",
                  "variable" : "category"
                }
              ],
              "rule" : [
                {
                  "name" : "categorycoding",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "category",
                      "contextType" : "variable",
                      "element" : "coding",
                      "variable" : "coding"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "categorysystem",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "system",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "http://terminology.hl7.org/CodeSystem/observation-category"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "categorycode",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "code",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "vital-signs"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "code",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "code",
                  "variable" : "code"
                }
              ],
              "rule" : [
                {
                  "name" : "coding",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "code",
                      "contextType" : "variable",
                      "element" : "coding",
                      "variable" : "coding"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "codesystem",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "system",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "http://loinc.org"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "codevalue",
                      "source" : [
                        {
                          "context" : "src",
                          "element" : "codeLoinc",
                          "variable" : "codeLoinc"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "code",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueId" : "codeLoinc"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "codetext",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "libelleTest",
                      "variable" : "label"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "code",
                      "contextType" : "variable",
                      "element" : "text",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "label"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "obssubject",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "subject",
                  "variable" : "ref",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Reference"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "subjectref",
                  "source" : [
                    {
                      "context" : "patient",
                      "element" : "id",
                      "variable" : "patientId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "reference",
                      "transform" : "evaluate",
                      "parameter" : [
                        {
                          "valueString" : "'Patient/' + %patientId"
                        }
                      ]
                    },
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "type",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "Patient"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "effective",
              "source" : [
                {
                  "context" : "src",
                  "element" : "dateMesure",
                  "variable" : "date",
                  "condition" : "%date.exists()"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "effective",
                  "transform" : "cast",
                  "parameter" : [
                    {
                      "valueId" : "date"
                    },
                    {
                      "valueString" : "dateTime"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "quantity",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "value",
                  "variable" : "qty",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Quantity"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "value",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "valeur",
                      "variable" : "mesure"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "qty",
                      "contextType" : "variable",
                      "element" : "value",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "mesure"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "unit",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "unite",
                      "variable" : "unit"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "qty",
                      "contextType" : "variable",
                      "element" : "unit",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "unit"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "code",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "unite",
                      "variable" : "unit"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "qty",
                      "contextType" : "variable",
                      "element" : "code",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "unit"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "system",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "qty",
                      "contextType" : "variable",
                      "element" : "system",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "http://unitsofmeasure.org"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "TransformTobaccoObservation",
          "typeMode" : "none",
          "documentation" : "========================================================================\r\nLIFESTYLE TRANSFORMATION - SEPARATE OBSERVATIONS\r\n========================================================================",
          "input" : [
            {
              "name" : "src",
              "mode" : "source"
            },
            {
              "name" : "tgtObs",
              "type" : "Observation",
              "mode" : "target"
            },
            {
              "name" : "patient",
              "mode" : "source"
            }
          ],
          "rule" : [
            {
              "name" : "setId",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "id",
                  "transform" : "uuid"
                }
              ]
            },
            {
              "name" : "lifestyleidentifier",
              "source" : [
                {
                  "context" : "src",
                  "element" : "styleVieId",
                  "variable" : "lsId"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "identifier",
                  "variable" : "identifier"
                }
              ],
              "rule" : [
                {
                  "name" : "lifestyleidsystem",
                  "source" : [
                    {
                      "context" : "lsId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "identifier",
                      "contextType" : "variable",
                      "element" : "system",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "https://hospital.eu/ehr/lifestyle-id"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "lifestyleidvalue",
                  "source" : [
                    {
                      "context" : "lsId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "identifier",
                      "contextType" : "variable",
                      "element" : "value",
                      "transform" : "evaluate",
                      "parameter" : [
                        {
                          "valueString" : "%lsId & '-tobacco'"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "lifestylestatus",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "status",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "final"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "lifestylecategory",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "category",
                  "variable" : "category"
                }
              ],
              "rule" : [
                {
                  "name" : "categorycoding",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "category",
                      "contextType" : "variable",
                      "element" : "coding",
                      "variable" : "coding"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "categorysystem",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "system",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "http://terminology.hl7.org/CodeSystem/observation-category"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "categorycode",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "code",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "social-history"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "categorydisplay",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "display",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "Social History"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "tobaccocode",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "code",
                  "variable" : "code"
                }
              ],
              "rule" : [
                {
                  "name" : "tobaccocoding",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "code",
                      "contextType" : "variable",
                      "element" : "coding",
                      "variable" : "coding"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "codesystem",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "system",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "http://loinc.org"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "codevalue",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "code",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "72166-2"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "codedisplay",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "display",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "Tobacco smoking status"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "lifestylesubject",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "subject",
                  "variable" : "ref",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Reference"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "subjectref",
                  "source" : [
                    {
                      "context" : "patient",
                      "element" : "id",
                      "variable" : "patientId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "reference",
                      "transform" : "evaluate",
                      "parameter" : [
                        {
                          "valueString" : "'Patient/' + %patientId"
                        }
                      ]
                    },
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "type",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "Patient"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "lifestyleeffective",
              "source" : [
                {
                  "context" : "src",
                  "element" : "dateRecueil",
                  "variable" : "collectDate",
                  "condition" : "%collectDate.exists()"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "effective",
                  "transform" : "cast",
                  "parameter" : [
                    {
                      "valueId" : "collectDate"
                    },
                    {
                      "valueString" : "dateTime"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "tobaccovalue",
              "source" : [
                {
                  "context" : "src",
                  "element" : "consommationTabac",
                  "variable" : "tobacco"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "value",
                  "variable" : "valueCC",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "CodeableConcept"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "tobaccovaluetext",
                  "source" : [
                    {
                      "context" : "tobacco"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "valueCC",
                      "contextType" : "variable",
                      "element" : "text",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "tobacco"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "TransformAlcoholObservation",
          "typeMode" : "none",
          "input" : [
            {
              "name" : "src",
              "mode" : "source"
            },
            {
              "name" : "tgtObs",
              "type" : "Observation",
              "mode" : "target"
            },
            {
              "name" : "patient",
              "mode" : "source"
            }
          ],
          "rule" : [
            {
              "name" : "setId",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "id",
                  "transform" : "uuid"
                }
              ]
            },
            {
              "name" : "lifestyleidentifier",
              "source" : [
                {
                  "context" : "src",
                  "element" : "styleVieId",
                  "variable" : "lsId"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "identifier",
                  "variable" : "identifier"
                }
              ],
              "rule" : [
                {
                  "name" : "lifestyleidsystem",
                  "source" : [
                    {
                      "context" : "lsId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "identifier",
                      "contextType" : "variable",
                      "element" : "system",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "https://hospital.eu/ehr/lifestyle-id"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "lifestyleidvalue",
                  "source" : [
                    {
                      "context" : "lsId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "identifier",
                      "contextType" : "variable",
                      "element" : "value",
                      "transform" : "evaluate",
                      "parameter" : [
                        {
                          "valueString" : "%lsId & '-alcohol'"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "lifestylestatus",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "status",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "final"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "lifestylecategory",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "category",
                  "variable" : "category"
                }
              ],
              "rule" : [
                {
                  "name" : "categorycoding",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "category",
                      "contextType" : "variable",
                      "element" : "coding",
                      "variable" : "coding"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "categorysystem",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "system",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "http://terminology.hl7.org/CodeSystem/observation-category"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "categorycode",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "code",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "social-history"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "categorydisplay",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "display",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "Social History"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "alcoholcode",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "code",
                  "variable" : "code"
                }
              ],
              "rule" : [
                {
                  "name" : "alcoholcoding",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "code",
                      "contextType" : "variable",
                      "element" : "coding",
                      "variable" : "coding"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "codesystem",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "system",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "http://loinc.org"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "codevalue",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "code",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "11331-6"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "codedisplay",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "display",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "History of alcohol use"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "lifestylesubject",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "subject",
                  "variable" : "ref",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Reference"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "subjectref",
                  "source" : [
                    {
                      "context" : "patient",
                      "element" : "id",
                      "variable" : "patientId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "reference",
                      "transform" : "evaluate",
                      "parameter" : [
                        {
                          "valueString" : "'Patient/' + %patientId"
                        }
                      ]
                    },
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "type",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "Patient"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "lifestyleeffective",
              "source" : [
                {
                  "context" : "src",
                  "element" : "dateRecueil",
                  "variable" : "collectDate",
                  "condition" : "%collectDate.exists()"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "effective",
                  "transform" : "cast",
                  "parameter" : [
                    {
                      "valueId" : "collectDate"
                    },
                    {
                      "valueString" : "dateTime"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "alcoholvalue",
              "source" : [
                {
                  "context" : "src",
                  "element" : "consommationAlcool",
                  "variable" : "alcohol"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "value",
                  "variable" : "valueCC",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "CodeableConcept"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "alcoholvaluetext",
                  "source" : [
                    {
                      "context" : "alcohol"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "valueCC",
                      "contextType" : "variable",
                      "element" : "text",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "alcohol"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "TransformDrugObservation",
          "typeMode" : "none",
          "input" : [
            {
              "name" : "src",
              "mode" : "source"
            },
            {
              "name" : "tgtObs",
              "type" : "Observation",
              "mode" : "target"
            },
            {
              "name" : "patient",
              "mode" : "source"
            }
          ],
          "rule" : [
            {
              "name" : "setId",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "id",
                  "transform" : "uuid"
                }
              ]
            },
            {
              "name" : "lifestyleidentifier",
              "source" : [
                {
                  "context" : "src",
                  "element" : "styleVieId",
                  "variable" : "lsId"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "identifier",
                  "variable" : "identifier"
                }
              ],
              "rule" : [
                {
                  "name" : "lifestyleidsystem",
                  "source" : [
                    {
                      "context" : "lsId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "identifier",
                      "contextType" : "variable",
                      "element" : "system",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "https://hospital.eu/ehr/lifestyle-id"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "lifestyleidvalue",
                  "source" : [
                    {
                      "context" : "lsId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "identifier",
                      "contextType" : "variable",
                      "element" : "value",
                      "transform" : "evaluate",
                      "parameter" : [
                        {
                          "valueString" : "%lsId & '-drugs'"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "lifestylestatus",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "status",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "final"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "lifestylecategory",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "category",
                  "variable" : "category"
                }
              ],
              "rule" : [
                {
                  "name" : "categorycoding",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "category",
                      "contextType" : "variable",
                      "element" : "coding",
                      "variable" : "coding"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "categorysystem",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "system",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "http://terminology.hl7.org/CodeSystem/observation-category"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "categorycode",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "code",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "social-history"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "categorydisplay",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "display",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "Social History"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "drugcode",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "code",
                  "variable" : "code"
                }
              ],
              "rule" : [
                {
                  "name" : "drugcoding",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "code",
                      "contextType" : "variable",
                      "element" : "coding",
                      "variable" : "coding"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "codesystem",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "system",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "http://loinc.org"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "codevalue",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "code",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "11342-3"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "codedisplay",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "display",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "History of drug use"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "lifestylesubject",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "subject",
                  "variable" : "ref",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Reference"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "subjectref",
                  "source" : [
                    {
                      "context" : "patient",
                      "element" : "id",
                      "variable" : "patientId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "reference",
                      "transform" : "evaluate",
                      "parameter" : [
                        {
                          "valueString" : "'Patient/' + %patientId"
                        }
                      ]
                    },
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "type",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "Patient"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "lifestyleeffective",
              "source" : [
                {
                  "context" : "src",
                  "element" : "dateRecueil",
                  "variable" : "collectDate",
                  "condition" : "%collectDate.exists()"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "effective",
                  "transform" : "cast",
                  "parameter" : [
                    {
                      "valueId" : "collectDate"
                    },
                    {
                      "valueString" : "dateTime"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "drugvalue",
              "source" : [
                {
                  "context" : "src",
                  "element" : "consommationAutresDrogues",
                  "variable" : "drugs"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "value",
                  "variable" : "valueCC",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "CodeableConcept"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "drugvaluetext",
                  "source" : [
                    {
                      "context" : "drugs"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "valueCC",
                      "contextType" : "variable",
                      "element" : "text",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "drugs"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "TransformPhysicalActivityObservation",
          "typeMode" : "none",
          "input" : [
            {
              "name" : "src",
              "mode" : "source"
            },
            {
              "name" : "tgtObs",
              "type" : "Observation",
              "mode" : "target"
            },
            {
              "name" : "patient",
              "mode" : "source"
            }
          ],
          "rule" : [
            {
              "name" : "setId",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "id",
                  "transform" : "uuid"
                }
              ]
            },
            {
              "name" : "lifestyleidentifier",
              "source" : [
                {
                  "context" : "src",
                  "element" : "styleVieId",
                  "variable" : "lsId"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "identifier",
                  "variable" : "identifier"
                }
              ],
              "rule" : [
                {
                  "name" : "lifestyleidsystem",
                  "source" : [
                    {
                      "context" : "lsId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "identifier",
                      "contextType" : "variable",
                      "element" : "system",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "https://hospital.eu/ehr/lifestyle-id"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "lifestyleidvalue",
                  "source" : [
                    {
                      "context" : "lsId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "identifier",
                      "contextType" : "variable",
                      "element" : "value",
                      "transform" : "evaluate",
                      "parameter" : [
                        {
                          "valueString" : "%lsId & '-physical'"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "lifestylestatus",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "status",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "final"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "lifestylecategory",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "category",
                  "variable" : "category"
                }
              ],
              "rule" : [
                {
                  "name" : "categorycoding",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "category",
                      "contextType" : "variable",
                      "element" : "coding",
                      "variable" : "coding"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "categorysystem",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "system",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "http://terminology.hl7.org/CodeSystem/observation-category"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "categorycode",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "code",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "social-history"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "categorydisplay",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "display",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "Social History"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "physicalcode",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "code",
                  "variable" : "code"
                }
              ],
              "rule" : [
                {
                  "name" : "physicalcoding",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "code",
                      "contextType" : "variable",
                      "element" : "coding",
                      "variable" : "coding"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "codesystem",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "system",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "http://loinc.org"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "codevalue",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "code",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "67504-6"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "codedisplay",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "display",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "Exercise activity"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "lifestylesubject",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "subject",
                  "variable" : "ref",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Reference"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "subjectref",
                  "source" : [
                    {
                      "context" : "patient",
                      "element" : "id",
                      "variable" : "patientId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "reference",
                      "transform" : "evaluate",
                      "parameter" : [
                        {
                          "valueString" : "'Patient/' + %patientId"
                        }
                      ]
                    },
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "type",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "Patient"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "lifestyleeffective",
              "source" : [
                {
                  "context" : "src",
                  "element" : "dateRecueil",
                  "variable" : "collectDate",
                  "condition" : "%collectDate.exists()"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "effective",
                  "transform" : "cast",
                  "parameter" : [
                    {
                      "valueId" : "collectDate"
                    },
                    {
                      "valueString" : "dateTime"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "physicalvalue",
              "source" : [
                {
                  "context" : "src",
                  "element" : "activitePhysique",
                  "variable" : "physical"
                }
              ],
              "target" : [
                {
                  "context" : "tgtObs",
                  "contextType" : "variable",
                  "element" : "value",
                  "variable" : "valueCC",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "CodeableConcept"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "physicalvaluetext",
                  "source" : [
                    {
                      "context" : "physical"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "valueCC",
                      "contextType" : "variable",
                      "element" : "text",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "physical"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "TransformMedicationAdministrationWOOrder",
          "typeMode" : "none",
          "documentation" : "========================================================================\r\nMEDICATION ADMINISTRATION TRANSFORMATION\r\n========================================================================",
          "input" : [
            {
              "name" : "src",
              "mode" : "source"
            },
            {
              "name" : "tgtMedAdmin",
              "type" : "MedicationAdministration",
              "mode" : "target"
            },
            {
              "name" : "patient",
              "mode" : "source"
            }
          ],
          "rule" : [
            {
              "name" : "setId",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtMedAdmin",
                  "contextType" : "variable",
                  "element" : "id",
                  "transform" : "uuid"
                }
              ]
            },
            {
              "name" : "adminidentifier",
              "source" : [
                {
                  "context" : "src",
                  "element" : "administrationId",
                  "variable" : "adminId"
                }
              ],
              "target" : [
                {
                  "context" : "tgtMedAdmin",
                  "contextType" : "variable",
                  "element" : "identifier",
                  "variable" : "identifier"
                }
              ],
              "rule" : [
                {
                  "name" : "adminidsystem",
                  "source" : [
                    {
                      "context" : "adminId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "identifier",
                      "contextType" : "variable",
                      "element" : "system",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "https://hospital.eu/ehr/administration-id"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "adminidvalue",
                  "source" : [
                    {
                      "context" : "adminId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "identifier",
                      "contextType" : "variable",
                      "element" : "value",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "adminId"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "adminstatus",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtMedAdmin",
                  "contextType" : "variable",
                  "element" : "status",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "completed"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "adminsubject",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtMedAdmin",
                  "contextType" : "variable",
                  "element" : "subject",
                  "variable" : "ref",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Reference"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "subjectref",
                  "source" : [
                    {
                      "context" : "patient",
                      "element" : "id",
                      "variable" : "patientId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "reference",
                      "transform" : "evaluate",
                      "parameter" : [
                        {
                          "valueString" : "'Patient/' + %patientId"
                        }
                      ]
                    },
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "type",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "Patient"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "adminmedication",
              "source" : [
                {
                  "context" : "src",
                  "element" : "denomination",
                  "variable" : "denomination"
                }
              ],
              "target" : [
                {
                  "context" : "tgtMedAdmin",
                  "contextType" : "variable",
                  "element" : "medication",
                  "variable" : "medication",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "CodeableConcept"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "medicationtext",
                  "source" : [
                    {
                      "context" : "denomination"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "medication",
                      "contextType" : "variable",
                      "element" : "text",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "denomination"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "atccoding",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "codeAtc",
                      "variable" : "atc"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "medication",
                      "contextType" : "variable",
                      "element" : "coding",
                      "variable" : "coding"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "atcsystem",
                      "source" : [
                        {
                          "context" : "atc"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "system",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "http://www.whocc.no/atc"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "atccode",
                      "source" : [
                        {
                          "context" : "atc"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "code",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueId" : "atc"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "admineffective",
              "source" : [
                {
                  "context" : "src",
                  "condition" : "src.dateHeureDebut.exists() or src.dateHeureFin.exists()"
                }
              ],
              "target" : [
                {
                  "context" : "tgtMedAdmin",
                  "contextType" : "variable",
                  "element" : "effective",
                  "variable" : "period",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Period"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "periodstart",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "dateHeureDebut",
                      "variable" : "startDate"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "period",
                      "contextType" : "variable",
                      "element" : "start",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "startDate"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "periodend",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "dateHeureFin",
                      "variable" : "endDate"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "period",
                      "contextType" : "variable",
                      "element" : "end",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "endDate"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "admindosage",
              "source" : [
                {
                  "context" : "src",
                  "condition" : "src.quantite.exists() or src.voieAdministration.exists()"
                }
              ],
              "target" : [
                {
                  "context" : "tgtMedAdmin",
                  "contextType" : "variable",
                  "element" : "dosage",
                  "variable" : "dosage"
                }
              ],
              "rule" : [
                {
                  "name" : "admindose",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "quantite",
                      "variable" : "quantity"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "dosage",
                      "contextType" : "variable",
                      "element" : "dose",
                      "variable" : "dose",
                      "transform" : "create",
                      "parameter" : [
                        {
                          "valueString" : "Quantity"
                        }
                      ]
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "dosevalue",
                      "source" : [
                        {
                          "context" : "quantity"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "dose",
                          "contextType" : "variable",
                          "element" : "value",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueId" : "quantity"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "doseunit",
                      "source" : [
                        {
                          "context" : "src",
                          "element" : "uniteQuantite",
                          "variable" : "unit"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "dose",
                          "contextType" : "variable",
                          "element" : "unit",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueId" : "unit"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "dosageroute",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "voieAdministration",
                      "variable" : "route"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "dosage",
                      "contextType" : "variable",
                      "element" : "route",
                      "variable" : "routeCC"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "routecoding",
                      "source" : [
                        {
                          "context" : "route"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "routeCC",
                          "contextType" : "variable",
                          "element" : "coding",
                          "variable" : "routeCoding"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "routecode",
                          "source" : [
                            {
                              "context" : "route"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "routeCoding",
                              "contextType" : "variable",
                              "element" : "code",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueId" : "route"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "routesystem",
                          "source" : [
                            {
                              "context" : "route"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "routeCoding",
                              "contextType" : "variable",
                              "element" : "system",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueString" : "https://smt.esante.gouv.fr/terminologie-standardterms"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "TransformMedicationAdministrationWOrder",
          "extends" : "TransformMedicationAdministrationWOOrder",
          "typeMode" : "none",
          "input" : [
            {
              "name" : "src",
              "mode" : "source"
            },
            {
              "name" : "tgtMedAdmin",
              "type" : "MedicationAdministration",
              "mode" : "target"
            },
            {
              "name" : "patient",
              "mode" : "source"
            },
            {
              "name" : "order",
              "mode" : "source"
            }
          ],
          "rule" : [
            {
              "name" : "admincontext",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "tgtMedAdmin",
                  "contextType" : "variable",
                  "element" : "request",
                  "variable" : "ref",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Reference"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "encounterref",
                  "source" : [
                    {
                      "context" : "order",
                      "element" : "id",
                      "variable" : "orderId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "reference",
                      "transform" : "evaluate",
                      "parameter" : [
                        {
                          "valueString" : "'MedicationRequest/' + %orderId"
                        }
                      ]
                    },
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "type",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "MedicationRequest"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "setEntryRequestAndFullUrl",
          "typeMode" : "none",
          "input" : [
            {
              "name" : "newRes",
              "mode" : "source"
            },
            {
              "name" : "tgtEntry",
              "mode" : "target"
            }
          ],
          "rule" : [
            {
              "name" : "setResourceType",
              "source" : [
                {
                  "context" : "newRes",
                  "element" : "id",
                  "variable" : "newResId"
                }
              ],
              "rule" : [
                {
                  "name" : "setFullUrl",
                  "source" : [
                    {
                      "context" : "newResId"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "tgtEntry",
                      "contextType" : "variable",
                      "element" : "fullUrl",
                      "transform" : "evaluate",
                      "parameter" : [
                        {
                          "valueString" : "'urn:ehr:' + %newRes.type().name + '/' + %newResId"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }