Data Management with FHIR
0.1.0 - ci-build

Data Management with FHIR - Local Development build (v0.1.0) built by the FHIR (HL7® FHIR® Standard) Build Tools. See the Directory of published versions

## : Transforms EHR logical model data to FHIR Semantic Layer resources using Bundle as container - TTL Representation

Draft as of 2025-10-23

Raw ttl | Download

    @prefix fhir: <http://hl7.org/fhir/> .
    @prefix owl: <http://www.w3.org/2002/07/owl#> .
    @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
    @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
    @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

    # - resource -------------------------------------------------------------------

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