# Transforms EHR logical model data to FHIR Semantic Layer resources using Bundle as container - Data Management with FHIR v0.1.0

 ![](assets/images/aphp-logo.png) 

*  [Accueil](index.md) 
*  [Dictionnaire des données](data-dictionary.md) 
*  [Variables du socle commun **** ](#) 
*  [Acquisition des variables](use-core-variables-acquisition.md) 
*  [Formalisation des variables](use-core-variables-formalization.md) 
*  [Standardisation des variables](use-core-variables-standardization.md) 
 
*  [Health Data Platform **** ](#) 
*  [Architecture fonctionnelle](data-platform-functional-architecture.md) 
*  [Raw layer](data-platform-raw-layer.md) 
*  [Transform layer](data-platform-transform-layer.md) 
*  [Semantic layer](data-platform-semantic-layer.md) 
*  [Share layer](data-platform-share-layer.md) 
 
*  [Guide **** ](#) 
*  [Gestion des données](https://interop.aphp.fr/ig/fhir/core/data-management.html) 
*  [Bonnes pratiques](https://interop.aphp.fr/ig/fhir/core/best-practice.html) 
*  [Processus de standardisation des données](https://interop.aphp.fr/ig/fhir/core/standardization-process.html) 
 
*  [Ressources de conformité](artifacts.md) 
*  [Autres **** ](#) 
*  [Aide](help.md) 
*  [Notes de version](changelog.md) 
*  [Glossaire](glossary.md) 
*  [Télécharger spécifications](downloads.md) 
 

* [Accueil](index.md)
* [Dictionnaire des données](data-dictionary.md)
* [Usages](use-case.md)
* [Variables socles pour les EDSH](use-core-variables.md)
* [Standardisation de données au format FHIR](use-core-variables-process.md)
* [Acquisition des variables](use-core-variables-acquisition.md)
* [Formalisation des variables](use-core-variables-formalization.md)
* [Standardisation des variables](use-core-variables-standardization.md)
* [Evaluation](use-core-variables-evaluation.md)
* [Health Data Platform (démo)](data-platform.md)
* [Architecture fonctionnelle](data-platform-functional-architecture.md)
* [Raw layer](data-platform-raw-layer.md)
* [Transform layer](data-platform-transform-layer.md)
* [Semantic layer](data-platform-semantic-layer.md)
* [Share layer](data-platform-share-layer.md)
* [Autre](other.md)
* [Aide](help.md)
* [Notes de version](changelog.md)
* [Glossaire](glossary.md)
* [Télécharger les spécifications](downloads.md)
* [Artifacts Summary](artifacts.md)
* [CareSite OMOP Table](StructureDefinition-OMOPCareSite.md)
* [Concept OMOP Table](StructureDefinition-OMOPConcept.md)
* [Condition Era OMOP Table](StructureDefinition-OMOPConditionEra.md)
* [Condition Occurrence OMOP Table](StructureDefinition-OMOPConditionOccurrence.md)
* [Cost OMOP Table](StructureDefinition-OMOPCost.md)
* [Death OMOP Table](StructureDefinition-OMOPDeath.md)
* [Device Exposure OMOP Table](StructureDefinition-OMOPDeviceExposure.md)
* [Dose Era OMOP Table](StructureDefinition-OMOPDoseEra.md)
* [Drug Era OMOP Table](StructureDefinition-OMOPDrugEra.md)
* [Drug Occurrence OMOP Table](StructureDefinition-OMOPDrugExposure.md)
* [Electronic Health Record Data Model](StructureDefinition-ehr.md)
* [Episode Event OMOP Table](StructureDefinition-OMOPEpisodeEvent.md)
* [Episode OMOP Table](StructureDefinition-OMOPEpisode.md)
* [Fact Relationship OMOP Table](StructureDefinition-OMOPFactRelationship.md)
* [Location OMOP Table](StructureDefinition-OMOPLocation.md)
* [LogicalBundle](StructureDefinition-LogicalBundle.md)
* [Measurement OMOP Table](StructureDefinition-OMOPMeasurement.md)
* [Note NLP OMOP Table](StructureDefinition-OMOPNoteNLP.md)
* [Note OMOP Table](StructureDefinition-OMOPNote.md)
* [Observation OMOP Table](StructureDefinition-OMOPObservation.md)
* [Observation Period OMOP Table](StructureDefinition-OMOPObservationPeriod.md)
* [Payer Plan Period OMOP Table](StructureDefinition-OMOPPayerPlanPeriod.md)
* [Person OMOP Table](StructureDefinition-OMOPPerson.md)
* [Procedure Occurrence OMOP Table](StructureDefinition-OMOPProcedureOccurrence.md)
* [Provider OMOP Table](StructureDefinition-OMOPProvider.md)
* [Specimen OMOP Table](StructureDefinition-OMOPSpecimen.md)
* [Visit Detail OMOP Table](StructureDefinition-OMOPVisitDetail.md)
* [Visit Occurrence OMOP Table](StructureDefinition-OMOPVisitOccurrence.md)
* [Questionnaire usage Variables socles pour les EDSH](Questionnaire-UsageCore.md)
* [Profil de Claim pour le champ MCO du PMSI](StructureDefinition-DMClaimPMSIMCO.md)
* [Profil de Claim pour le PMSI](StructureDefinition-DMClaimPMSI.md)
* [Résultat de laboratoire](StructureDefinition-DMObservationLaboratoryGeneric.md)
* [Activité physique](StructureDefinition-DMObservationExerciceStatus.md)
* [Alanine aminotransférase (ALAT)](StructureDefinition-DMObservationLaboratoryALAT.md)
* [Aspartate aminotransférase (ASAT)](StructureDefinition-DMObservationLaboratoryASAT.md)
* [Bilirubine conjuguée](StructureDefinition-DMObservationLaboratoryBilirubineConjuguee.md)
* [Bilirubine totale](StructureDefinition-DMObservationLaboratoryBilirubineTotale.md)
* [Condition](StructureDefinition-DMCondition.md)
* [Consommation d'alcool](StructureDefinition-DMObservationAlcoholUseStatus.md)
* [Consommation d'autres drogues](StructureDefinition-DMObservationSubstanceUseStatus.md)
* [Consommation de tabac](StructureDefinition-DMObservationSmokingStatus.md)
* [Encounter](StructureDefinition-DMEncounter.md)
* [Eosinophiles](StructureDefinition-DMObservationLaboratoryEosinophiles.md)
* [Episode of care](StructureDefinition-DMEpisodeOfCare.md)
* [Erythrocytes](StructureDefinition-DMObservationLaboratoryErythrocytes.md)
* [Fonction rénale](StructureDefinition-DMObservationLaboratoryFonctionRenale.md)
* [French branded name Medication](StructureDefinition-FrMedicationUcd.md)
* [French compound Medication](StructureDefinition-FrMedicationCompound.md)
* [French non proprietary name Medication](StructureDefinition-FrMedicationNonproprietaryName.md)
* [French Ucd Part Medication](StructureDefinition-FrMedicationUcdPart.md)
* [Gamma-glutamyl transférase (GGT)](StructureDefinition-DMObservationLaboratoryGGT.md)
* [Glycémie à jeun](StructureDefinition-DMObservationLaboratoryGlycemieAJeun.md)
* [Hématocrite](StructureDefinition-DMObservationLaboratoryHematocrite.md)
* [Hémoglobine](StructureDefinition-DMObservationLaboratoryHemoglobine.md)
* [Hémoglobine glyquée](StructureDefinition-DMObservationLaboratoryHbA1c.md)
* [Leucocytes](StructureDefinition-DMObservationLaboratoryLeucocytes.md)
* [Location](StructureDefinition-DMLocation.md)
* [Lymphocytes](StructureDefinition-DMObservationLaboratoryLymphocytes.md)
* [Monocytes](StructureDefinition-DMObservationLaboratoryMonocytes.md)
* [Neutrophiles](StructureDefinition-DMObservationLaboratoryNeutrophiles.md)
* [Organization](StructureDefinition-DMOrganization.md)
* [Patient](StructureDefinition-DMPatient.md)
* [Phosphatases alcaline](StructureDefinition-DMObservationLaboratoryPAL.md)
* [Plaquettes](StructureDefinition-DMObservationLaboratoryPlaquettes.md)
* [Poids du patient](StructureDefinition-DMObservationBodyWeight.md)
* [Practitioner](StructureDefinition-DMPractitioner.md)
* [PractitionerRole](StructureDefinition-DMPractitionerRole.md)
* [Prescription de médicaments](StructureDefinition-DMMedicationRequest.md)
* [Pression artérielle](StructureDefinition-DMObservationBloodPressure.md)
* [Prise de médicaments](StructureDefinition-DMMedicationAdministration.md)
* [Procedure](StructureDefinition-DMProcedure.md)
* [RUM du PMSI MCO](StructureDefinition-DMClaimRUM.md)
* [Taille du patient](StructureDefinition-DMObservationBodyHeight.md)
* [Taux prothrombine (TP)](StructureDefinition-DMObservationLaboratoryTP.md)
* [Temps de céphaline activée (TCA)](StructureDefinition-DMObservationLaboratoryTCA.md)
* [Urée](StructureDefinition-DMObservationLaboratoryUremie.md)
* [Volume globulaire moyen](StructureDefinition-DMObservationLaboratoryVGM.md)
* [Address](StructureDefinition-DMAddress.md)
* [Range with UCUM quantity units](StructureDefinition-FrRangeUcum.md)
* [Ratio with UCUM quantity units](StructureDefinition-FrRatioUcum.md)
* [SimpleQuantity with UCUM quantity unit](StructureDefinition-FrSimpleQuantityUcum.md)
* [Codage géographique du lieu de résidence pour les RSA du PMSI](StructureDefinition-PmsiCodeGeo.md)
* [Groupe Homogène de Malade](StructureDefinition-DRG.md)
* [Ordre des Item dans un claim](StructureDefinition-ItemRank.md)
* [Source ayant fournie l'information de décès](StructureDefinition-DeathSource.md)
* [Actes CCAM pour le PMSI](ValueSet-CcamVS.md)
* [Blood Pressure Measurement Body Location Precoordinated](ValueSet-BloodPressureMeasurementBodyLocationPrecoodinated.md)
* [Blood Pressure Measurement Method](ValueSet-BloodPressureMeasurementMethod.md)
* [Categorisation des items de claim pour le PMSI MCO](ValueSet-FrMCOClaimItemCategory.md)
* [Exercice Status Type](ValueSet-DMExerciceStatusType.md)
* [French Medicinal product Dose form](ValueSet-FrMpDoseForm.md)
* [French Medicinal Product only](ValueSet-FrMedicinalProductOnly.md)
* [French Route of Administration](ValueSet-FrRouteOfAdministration.md)
* [Height Length Measurement Method](ValueSet-HeightLengthMeasurementMethod.md)
* [Liste des analyses biologiques socle des EDS](ValueSet-DMLaboratory.md)
* [Liste des analyses correspondant à l'estimation du DFG - socle des EDS](ValueSet-DMLaboratoryEstimatedDFG.md)
* [Liste des diagnostiques CIM-10 acceptable en DA pour les PMSI MCO et HAD](ValueSet-CIM10PMSIDA.md)
* [Liste des diagnostiques CIM-10 acceptable en DP pour les PMSI MCO et HAD](ValueSet-CIM10PMSIDP.md)
* [Liste des diagnostiques CIM-10 acceptable en DR pour les PMSI MCO et HAD](ValueSet-CIM10PMSIDR.md)
* [Liste des diagnostiques CIM-10 OMS](ValueSet-CIM10.md)
* [Liste des diagnostiques CIM-10 pour le PMSI](ValueSet-CIM10PMSI.md)
* [Liste des GHM pour le PMSI MCO](ValueSet-GHMVS.md)
* [Liste des status pour l'Observation de consommation de tabac](ValueSet-DMObservationSmokingStatusStatus.md)
* [Liste des unités possibles pour une estimation du débit de filtration glomérulaire - socle des EDS](ValueSet-DMLaboratoryEstimatedDFGUnit.md)
* [Mode d'entré du PMSI MCO](ValueSet-PMSIMCOMDEVS.md)
* [Mode de sortie du PMSI MCO](ValueSet-PMSIMCOMDSVS.md)
* [Smoking status comprehensive](ValueSet-DMSmokingStatusComprehensive.md)
* [Smoking Status Pack Years SCT](ValueSet-DMSmokingStatusPackYearsSCT.md)
* [Smoking Status Type](ValueSet-DMSmokingStatusType.md)
* [Smoking Status Type from LOINC](ValueSet-DMSmokingStatusTypeLOINC.md)
* [ValueSet des codes géographiques de résidence du PMSI](ValueSet-PmsiCodeGeoVs.md)
* [ValueSet des modes d'entrée du DPI](ValueSet-DpiModeIn.md)
* [ValueSet des modes de sortie du DPI](ValueSet-DpiModeOut.md)
* [ValueSet des Sexe administratif du DPI](ValueSet-DpiGenderVS.md)
* [ValueSet des sources d'informations fr sur le statut vital](ValueSet-DeathSourcesVs.md)
* [ValueSet des type fr des claims](ValueSet-FrClaimType.md)
* [ValueSet des type fr des claims](ValueSet-FrMCOClaimSubType.md)
* [ValueSet des types de séjour du DPI](ValueSet-DpiEncounterTypeVS.md)
* [ValueSet of gender of OHDSI](ValueSet-OMOPGender.md)
* [Weight Measurement Method](ValueSet-WeightMeasurementMethod.md)
* [Cadre de facturation dans la réglementation française](CodeSystem-FrClaimType.md)
* [Categorie d'information pour les supporting information](CodeSystem-FrClaimSupInfoCategoryPMSIMCO.md)
* [Categorisation des items de claim pour le PMSI MCO](CodeSystem-FrMCOClaimItemCategory.md)
* [CCAM illustrative](CodeSystem-Ccam.md)
* [CIM 10 PMSI](CodeSystem-CIM10.md)
* [Classification des GHM utilisée pour le groupage des séjours dans le PMSI MCO.](CodeSystem-GHM.md)
* [CodeSystem des lieux de résidence géographique au sens du PMSI](CodeSystem-PmsiCodeGeo.md)
* [DPI Gender](CodeSystem-DpiGender.md)
* [Dpi Mode d'entrée](CodeSystem-DpiModeIn.md)
* [Dpi Mode de sortie](CodeSystem-DpiModeOut.md)
* [DPI Type de séjour](CodeSystem-DpiEncounterType.md)
* [Mode d'entré du PMSI MCO](CodeSystem-PMSIMCOMDE.md)
* [Mode de sortie du PMSI MCO](CodeSystem-PMSIMCOMDS.md)
* [mode PMSI](CodeSystem-FrClaimMode.md)
* [Observational Medical Outcomes Partnership (OMOP)](CodeSystem-dm-omop-cdm-v20240229.md)
* [SNOMED CT Solor Extension Temporary](CodeSystem-SolorTemporary.md)
* [Sources susceptibles d'informer sur le statu vital des patients](CodeSystem-DeathSources.md)
* [Specialités médicales au sens de la Fédération des Spécialités Médicales (FSM)](CodeSystem-SpecialitesMedicalesFSM.md)
* [type de diagnostic du PMSI MCO](CodeSystem-PMSIMCODiagType.md)
* [Transforms EHR logical model data to FHIR Semantic Layer resources using Bundle as container](StructureMap-EHR2FSL.md)
* [Transforms QuestionnaireResponse based on Questionnaire Usage Variables socles into FHIR resources conforming to DM profiles](StructureMap-Q2FSL.md)
* [Alignement de l''expression de besoin vers le modèle physique du DPI dans le cadre de l''usage Core](StructureMap-CoreBusiness2Physical.md)
* [Cette ressource présente les spécifications de l''alignement entre les ressources FHIR vers les tables correspodantes du CDM OMOP.](StructureMap-CoreFHIR2OMOP.md)
* [Mapping FHIR Patient resource to OMOP Death](StructureMap-CoreFHIR2OMOPDeath.md)
* [Mapping Patient resource to Location OMOP Domain](StructureMap-CoreFHIR2OMOPLocation.md)
* [Mapping Observation laboratory resources to Measurement OMOP Domain](StructureMap-CoreFHIR2OMOPMeasurement.md)
* [Mapping FHIR Patient resource to OMOP Person](StructureMap-CoreFHIR2OMOPPerson.md)
* [Cette ressource présente les spécifications de l''alignement entre la ressource `Patient` vers les tables correspodantes du CDM OMOP.](StructureMap-CoreFHIRPatient2OMOP.md)
* [Alignement de l''usage Core du modèle physique du DPI vers les ressources FHIR](StructureMap-CorePhysical2FHIR.md)
* [Mapping simple Observation laboratory resources to Measurement OMOP Domain](StructureMap-CoreSimpleObservation2OMOPMeasurement.md)
* [DPI (local) Gender to HL7 Gender](ConceptMap-dpi-gender-2-hl7-gender.md)
* [DPI Encounter type to Semantic layer](ConceptMap-dpi-encounter-type-2-semantic-layer-encounter-class.md)
* [HL7 Gender to OHDSI Gender](ConceptMap-hl7-gender-to-ohdsi-gender.md)
* [Administration d'albumine de Madame Blanc](MedicationAdministration-albumine-j1-cas-9.md)
* [Administration à J1 de furosemide de Madame Blanc](MedicationAdministration-furosemide-j1-cas-9.md)
* [Administration à J1 de spironolactone de Madame Blanc](MedicationAdministration-spironolactone-j1-cas-9.md)
* [Administration à J2 de furosemide de Madame Blanc](MedicationAdministration-furosemide-j2-cas-9.md)
* [Administration à J2 de spironolactone de Madame Blanc](MedicationAdministration-spironolactone-j2-cas-9.md)
* [ALAT de Madame Blanc](Observation-alat-cas-9.md)
* [Albumine](Medication-albumine.md)
* [ASAT de Madame Blanc](Observation-asat-cas-9.md)
* [Ascite de Madame Blanc](Condition-ascite-cas-9.md)
* [Bilirubine totale de Madame Blanc](Observation-bilirubine-totale-cas-9.md)
* [Cirrhose de Madame Blanc](Condition-cirrhose-cas-9.md)
* [Consommation d'alcool de Madame Blanc](Observation-alcool-cas-9.md)
* [de Madame Blanc](Patient-cas-9.md)
* [Exemple complet (FSL)](Bundle-df9c9a9c-854b-46f4-9687-1fbe40c06540.md)
* [Exemple simple](QuestionnaireResponse-test-usage-core.md)
* [Fibroscopie oeso-gastroduodénale de Madame Blanc](Procedure-fogd-cas-9.md)
* [Furosémide](Medication-furosemide.md)
* [GGT de Madame Blanc](Observation-ggt-cas-9.md)
* [Patient 1 - Madame Dupont](QuestionnaireResponse-cas-1-usage-core.md)
* [Patient 10 - Monsieur David](QuestionnaireResponse-cas-10-usage-core.md)
* [Patient 11 - Madame Doré](QuestionnaireResponse-cas-11-usage-core.md)
* [Patient 2 - Monsieur Martin](QuestionnaireResponse-cas-2-usage-core.md)
* [Patient 3 - Madame Leroy](QuestionnaireResponse-cas-3-usage-core.md)
* [Patient 4 - Monsieur Moreau](QuestionnaireResponse-cas-4-usage-core.md)
* [Patient 5 - Madame Simon](QuestionnaireResponse-cas-5-usage-core.md)
* [Patient 6 - Monsieur Petit](QuestionnaireResponse-cas-6-usage-core.md)
* [Patient 7 - Madame Garcia](QuestionnaireResponse-cas-7-usage-core.md)
* [Patient 8 - Monsieur Roux](QuestionnaireResponse-cas-8-usage-core.md)
* [Patient 9 - Madame Blanc](QuestionnaireResponse-cas-9-usage-core.md)
* [Patient test (Bundle)](Bundle-5616f9ad-61b0-4279-9f41-777228d04665.md)
* [Patient test (Ressource)](Patient-8f005d60-b59b-47f7-b04a-f877378f8d68.md)
* [Phosphatases alcalines de Madame Blanc](Observation-phosphatases-alcalines-cas-9.md)
* [Poids de Madame Blanc](Observation-poids-cas-9.md)
* [Ponction évacuatrice de Madame Blanc](Procedure-ponction-cas-9.md)
* [Prescription d'albumine de Madame Blanc](MedicationRequest-albumine-cas-9.md)
* [Prescription de furosémide de Madame Blanc](MedicationRequest-furosemide-cas-9.md)
* [Prescription de furosémide de Madame Blanc](MedicationRequest-spironolactone-cas-9.md)
* [Spironolactone](Medication-spironolactone.md)
* [Séjour de Madame Blanc](Encounter-sejour-cas-9.md)
* [Taux de prothrombine de Madame Blanc](Observation-tp-cas-9.md)
* [Test simple](Bundle-2abf7f4c-bd1f-431f-a4c8-667cfa425baf.md)
* [Exigences des variables socles pour les Entrepôts de Données de Santé Hospitalier (EDSH)](DocumentReference-CoreExigences.md)

Data Management with FHIR
0.1.0 - ci-build

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

| | |
| :--- | :--- |
| *Official URL*:https://interop.aphp.fr/ig/fhir/dm/StructureMap/EHR2FSL | *Version*:0.1.0 |
| Draft as of 2026-04-16 | *Computable Name*:EHR2FSL |

 
Transforms EHR logical model data to FHIR Semantic Layer resources using Bundle as container 



## Resource Content

```json
{
  "resourceType" : "StructureMap",
  "id" : "EHR2FSL",
  "url" : "https://interop.aphp.fr/ig/fhir/dm/StructureMap/EHR2FSL",
  "version" : "0.1.0",
  "name" : "EHR2FSL",
  "title" : "Transforms EHR logical model data to FHIR Semantic Layer resources using Bundle as container",
  "status" : "draft",
  "date" : "2026-04-16T14:35:38+00:00",
  "publisher" : "AP-HP",
  "contact" : [{
    "name" : "AP-HP",
    "telecom" : [{
      "system" : "url",
      "value" : "https://aphp.fr"
    }]
  }],
  "description" : "Transforms EHR logical model data to FHIR Semantic Layer resources using Bundle as container",
  "jurisdiction" : [{
    "coding" : [{
      "system" : "urn:iso:std:iso:3166",
      "code" : "FR"
    }]
  }],
  "structure" : [{
    "url" : "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/ehr",
    "mode" : "source",
    "alias" : "EHR"
  },
  {
    "url" : "http://hl7.org/fhir/StructureDefinition/Bundle",
    "mode" : "target",
    "alias" : "Bundle"
  }],
  "group" : [{
    "name" : "EHR2FSL",
    "typeMode" : "none",
    "input" : [{
      "name" : "src",
      "type" : "EHR",
      "mode" : "source"
    },
    {
      "name" : "bundle",
      "type" : "Bundle",
      "mode" : "target"
    }],
    "rule" : [{
      "name" : "bundleid",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "bundle",
        "contextType" : "variable",
        "element" : "id",
        "transform" : "uuid"
      }]
    },
    {
      "name" : "bundletype",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "bundle",
        "contextType" : "variable",
        "element" : "type",
        "transform" : "copy",
        "parameter" : [{
          "valueString" : "collection"
        }]
      }]
    },
    {
      "name" : "setTimestamp",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "contextType" : "variable",
        "variable" : "timestamp",
        "transform" : "evaluate",
        "parameter" : [{
          "valueString" : "now()"
        }]
      }],
      "rule" : [{
        "name" : "affectTimestamp",
        "source" : [{
          "context" : "src"
        }],
        "target" : [{
          "context" : "bundle",
          "contextType" : "variable",
          "element" : "timestamp",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "timestamp"
          }]
        }]
      }]
    },
    {
      "name" : "patiententry",
      "source" : [{
        "context" : "src",
        "element" : "patient",
        "variable" : "patient"
      }],
      "target" : [{
        "context" : "bundle",
        "contextType" : "variable",
        "element" : "entry",
        "variable" : "patientEntry"
      }],
      "rule" : [{
        "name" : "createpatient",
        "source" : [{
          "context" : "patient"
        }],
        "target" : [{
          "context" : "patientEntry",
          "contextType" : "variable",
          "element" : "resource",
          "variable" : "dmPatient",
          "transform" : "create",
          "parameter" : [{
            "valueString" : "Patient"
          }]
        }],
        "rule" : [{
          "name" : "transformpatient",
          "source" : [{
            "context" : "patient"
          }],
          "dependent" : [{
            "name" : "TransformPatient",
            "variable" : ["patient", "dmPatient"]
          }]
        },
        {
          "name" : "setRequestAndFullUrl",
          "source" : [{
            "context" : "patient"
          }],
          "dependent" : [{
            "name" : "setEntryRequestAndFullUrl",
            "variable" : ["dmPatient", "patientEntry"]
          }]
        },
        {
          "name" : "transformpatientAdresse",
          "source" : [{
            "context" : "src",
            "element" : "patientAdresse",
            "variable" : "patientAdresse",
            "condition" : "patientAdresse.patientId = %patient.patientId"
          }],
          "dependent" : [{
            "name" : "setAddress",
            "variable" : ["patientAdresse", "dmPatient"]
          }]
        },
        {
          "name" : "encounterentries",
          "source" : [{
            "context" : "src",
            "element" : "donneesPmsi",
            "variable" : "pmsi",
            "condition" : "pmsi.patientId = %patient.patientId"
          }],
          "target" : [{
            "context" : "bundle",
            "contextType" : "variable",
            "element" : "entry",
            "variable" : "encounterEntry"
          }],
          "rule" : [{
            "name" : "createencounter",
            "source" : [{
              "context" : "pmsi"
            }],
            "target" : [{
              "context" : "encounterEntry",
              "contextType" : "variable",
              "element" : "resource",
              "variable" : "dmEncounter",
              "transform" : "create",
              "parameter" : [{
                "valueString" : "Encounter"
              }]
            }],
            "rule" : [{
              "name" : "transformencounter",
              "source" : [{
                "context" : "pmsi"
              }],
              "dependent" : [{
                "name" : "TransformEncounter",
                "variable" : ["pmsi", "dmEncounter", "dmPatient"]
              }]
            },
            {
              "name" : "setRequestAndFullUrl",
              "source" : [{
                "context" : "pmsi"
              }],
              "dependent" : [{
                "name" : "setEntryRequestAndFullUrl",
                "variable" : ["dmEncounter", "encounterEntry"]
              }]
            },
            {
              "name" : "conditionentries",
              "source" : [{
                "context" : "src",
                "element" : "diagnostics",
                "variable" : "diag",
                "condition" : "(diag.patientId = %patient.patientId) and (diag.pmsiId = %pmsi.pmsiId)"
              }],
              "target" : [{
                "context" : "bundle",
                "contextType" : "variable",
                "element" : "entry",
                "variable" : "conditionEntry"
              }],
              "rule" : [{
                "name" : "createcondition",
                "source" : [{
                  "context" : "diag"
                }],
                "target" : [{
                  "context" : "conditionEntry",
                  "contextType" : "variable",
                  "element" : "resource",
                  "variable" : "dmCondition",
                  "transform" : "create",
                  "parameter" : [{
                    "valueString" : "Condition"
                  }]
                }],
                "rule" : [{
                  "name" : "transformcondition",
                  "source" : [{
                    "context" : "diag"
                  }],
                  "dependent" : [{
                    "name" : "TransformCondition",
                    "variable" : ["diag", "dmCondition", "dmPatient", "dmEncounter"]
                  }]
                },
                {
                  "name" : "setRequestAndFullUrl",
                  "source" : [{
                    "context" : "diag"
                  }],
                  "dependent" : [{
                    "name" : "setEntryRequestAndFullUrl",
                    "variable" : ["dmCondition", "conditionEntry"]
                  }]
                }]
              }]
            },
            {
              "name" : "procedureentries",
              "source" : [{
                "context" : "src",
                "element" : "actes",
                "variable" : "acte",
                "condition" : "(acte.patientId = %patient.patientId) and (acte.pmsiId = %pmsi.pmsiId)"
              }],
              "target" : [{
                "context" : "bundle",
                "contextType" : "variable",
                "element" : "entry",
                "variable" : "procedureEntry"
              }],
              "rule" : [{
                "name" : "createprocedure",
                "source" : [{
                  "context" : "acte"
                }],
                "target" : [{
                  "context" : "procedureEntry",
                  "contextType" : "variable",
                  "element" : "resource",
                  "variable" : "dmProcedure",
                  "transform" : "create",
                  "parameter" : [{
                    "valueString" : "Procedure"
                  }]
                }],
                "rule" : [{
                  "name" : "transformprocedure",
                  "source" : [{
                    "context" : "acte"
                  }],
                  "dependent" : [{
                    "name" : "TransformProcedure",
                    "variable" : ["acte", "dmProcedure", "dmPatient", "dmEncounter"]
                  }]
                },
                {
                  "name" : "setRequestAndFullUrl",
                  "source" : [{
                    "context" : "acte"
                  }],
                  "dependent" : [{
                    "name" : "setEntryRequestAndFullUrl",
                    "variable" : ["dmProcedure", "procedureEntry"]
                  }]
                }]
              }]
            }]
          }]
        },
        {
          "name" : "labentries",
          "source" : [{
            "context" : "src",
            "element" : "biologie",
            "variable" : "lab",
            "condition" : "lab.patientId = %patient.patientId"
          }],
          "target" : [{
            "context" : "bundle",
            "contextType" : "variable",
            "element" : "entry",
            "variable" : "labEntry"
          }],
          "rule" : [{
            "name" : "createlabobs",
            "source" : [{
              "context" : "lab"
            }],
            "target" : [{
              "context" : "labEntry",
              "contextType" : "variable",
              "element" : "resource",
              "variable" : "dmLab",
              "transform" : "create",
              "parameter" : [{
                "valueString" : "Observation"
              }]
            }],
            "rule" : [{
              "name" : "transformLabObs",
              "source" : [{
                "context" : "lab"
              }],
              "dependent" : [{
                "name" : "TransformLabObservation",
                "variable" : ["lab", "dmLab", "dmPatient"]
              }]
            },
            {
              "name" : "setRequestAndFullUrl",
              "source" : [{
                "context" : "lab"
              }],
              "dependent" : [{
                "name" : "setEntryRequestAndFullUrl",
                "variable" : ["dmLab", "labEntry"]
              }]
            }]
          }]
        },
        {
          "name" : "medicationentries",
          "source" : [{
            "context" : "src",
            "element" : "prescription",
            "variable" : "pres",
            "condition" : "pres.patientId = %patient.patientId"
          }],
          "target" : [{
            "context" : "bundle",
            "contextType" : "variable",
            "element" : "entry",
            "variable" : "medReqEntry"
          }],
          "rule" : [{
            "name" : "createmedreq",
            "source" : [{
              "context" : "pres"
            }],
            "target" : [{
              "context" : "medReqEntry",
              "contextType" : "variable",
              "element" : "resource",
              "variable" : "dmMedReq",
              "transform" : "create",
              "parameter" : [{
                "valueString" : "MedicationRequest"
              }]
            }],
            "rule" : [{
              "name" : "createmedrequest",
              "source" : [{
                "context" : "src"
              }],
              "dependent" : [{
                "name" : "TransformMedicationRequest",
                "variable" : ["pres", "dmMedReq", "dmPatient"]
              }]
            },
            {
              "name" : "setRequestAndFullUrl",
              "source" : [{
                "context" : "pres"
              }],
              "dependent" : [{
                "name" : "setEntryRequestAndFullUrl",
                "variable" : ["dmMedReq", "medReqEntry"]
              }]
            },
            {
              "name" : "transformPoso",
              "source" : [{
                "context" : "src",
                "element" : "posologie",
                "variable" : "poso",
                "condition" : "%poso.prescriptionId = %pres.prescriptionId"
              }],
              "dependent" : [{
                "name" : "setPoso",
                "variable" : ["poso", "pres", "dmMedReq"]
              }]
            },
            {
              "name" : "administrationentries",
              "source" : [{
                "context" : "src",
                "element" : "administration",
                "variable" : "admin",
                "condition" : "(admin.patientId = %patient.patientId) and (admin.prescriptionId = pres.prescriptionId)"
              }],
              "target" : [{
                "context" : "bundle",
                "contextType" : "variable",
                "element" : "entry",
                "variable" : "adminEntry"
              }],
              "rule" : [{
                "name" : "createmedadmin",
                "source" : [{
                  "context" : "admin"
                }],
                "target" : [{
                  "context" : "adminEntry",
                  "contextType" : "variable",
                  "element" : "resource",
                  "variable" : "dmAdmin",
                  "transform" : "create",
                  "parameter" : [{
                    "valueString" : "MedicationAdministration"
                  }]
                }],
                "rule" : [{
                  "name" : "createmedadmin",
                  "source" : [{
                    "context" : "admin"
                  }],
                  "dependent" : [{
                    "name" : "TransformMedicationAdministrationWOrder",
                    "variable" : ["admin", "dmAdmin", "dmPatient", "dmMedReq"]
                  }]
                },
                {
                  "name" : "setRequestAndFullUrl",
                  "source" : [{
                    "context" : "admin"
                  }],
                  "dependent" : [{
                    "name" : "setEntryRequestAndFullUrl",
                    "variable" : ["dmAdmin", "adminEntry"]
                  }]
                }]
              }]
            }]
          }]
        },
        {
          "name" : "lifestyleentries",
          "source" : [{
            "context" : "src",
            "element" : "styleVie",
            "variable" : "lifestyle",
            "condition" : "lifestyle.patientId = %patient.patientId"
          }],
          "rule" : [{
            "name" : "tobaccoentries",
            "source" : [{
              "context" : "lifestyle",
              "element" : "consommationTabac",
              "variable" : "tobacco",
              "condition" : "tobacco.exists()"
            }],
            "target" : [{
              "context" : "bundle",
              "contextType" : "variable",
              "element" : "entry",
              "variable" : "tobaccoEntry"
            }],
            "rule" : [{
              "name" : "createtobaccoobs",
              "source" : [{
                "context" : "tobacco"
              }],
              "target" : [{
                "context" : "tobaccoEntry",
                "contextType" : "variable",
                "element" : "resource",
                "variable" : "tobaccoObs",
                "transform" : "create",
                "parameter" : [{
                  "valueString" : "Observation"
                }]
              }],
              "rule" : [{
                "name" : "createtobaccoobs",
                "source" : [{
                  "context" : "lifestyle"
                }],
                "dependent" : [{
                  "name" : "TransformTobaccoObservation",
                  "variable" : ["lifestyle", "tobaccoObs", "dmPatient"]
                }]
              },
              {
                "name" : "setRequestAndFullUrl",
                "source" : [{
                  "context" : "lifestyle"
                }],
                "dependent" : [{
                  "name" : "setEntryRequestAndFullUrl",
                  "variable" : ["tobaccoObs", "tobaccoEntry"]
                }]
              }]
            }]
          },
          {
            "name" : "alcoholentries",
            "source" : [{
              "context" : "lifestyle",
              "element" : "consommationAlcool",
              "variable" : "alcohol",
              "condition" : "alcohol.exists()"
            }],
            "target" : [{
              "context" : "bundle",
              "contextType" : "variable",
              "element" : "entry",
              "variable" : "alcoholEntry"
            }],
            "rule" : [{
              "name" : "createalcoholobs",
              "source" : [{
                "context" : "alcohol"
              }],
              "target" : [{
                "context" : "alcoholEntry",
                "contextType" : "variable",
                "element" : "resource",
                "variable" : "alcoholObs",
                "transform" : "create",
                "parameter" : [{
                  "valueString" : "Observation"
                }]
              }],
              "rule" : [{
                "name" : "createalcoholobs",
                "source" : [{
                  "context" : "lifestyle"
                }],
                "dependent" : [{
                  "name" : "TransformAlcoholObservation",
                  "variable" : ["lifestyle", "alcoholObs", "dmPatient"]
                }]
              },
              {
                "name" : "setRequestAndFullUrl",
                "source" : [{
                  "context" : "lifestyle"
                }],
                "dependent" : [{
                  "name" : "setEntryRequestAndFullUrl",
                  "variable" : ["alcoholObs", "alcoholEntry"]
                }]
              }]
            }]
          },
          {
            "name" : "drugentries",
            "source" : [{
              "context" : "lifestyle",
              "element" : "consommationAutresDrogues",
              "variable" : "drugs",
              "condition" : "drugs.exists()"
            }],
            "target" : [{
              "context" : "bundle",
              "contextType" : "variable",
              "element" : "entry",
              "variable" : "drugEntry"
            }],
            "rule" : [{
              "name" : "createdrugobs",
              "source" : [{
                "context" : "drugs"
              }],
              "target" : [{
                "context" : "drugEntry",
                "contextType" : "variable",
                "element" : "resource",
                "variable" : "drugObs",
                "transform" : "create",
                "parameter" : [{
                  "valueString" : "Observation"
                }]
              }],
              "rule" : [{
                "name" : "createdrugobs",
                "source" : [{
                  "context" : "lifestyle"
                }],
                "dependent" : [{
                  "name" : "TransformDrugObservation",
                  "variable" : ["lifestyle", "drugObs", "dmPatient"]
                }]
              },
              {
                "name" : "setRequestAndFullUrl",
                "source" : [{
                  "context" : "lifestyle"
                }],
                "dependent" : [{
                  "name" : "setEntryRequestAndFullUrl",
                  "variable" : ["drugObs", "drugEntry"]
                }]
              }]
            }]
          },
          {
            "name" : "physicalentries",
            "source" : [{
              "context" : "lifestyle",
              "element" : "activitePhysique",
              "variable" : "physical",
              "condition" : "physical.exists()"
            }],
            "target" : [{
              "context" : "bundle",
              "contextType" : "variable",
              "element" : "entry",
              "variable" : "physicalEntry"
            }],
            "rule" : [{
              "name" : "createphysicalobs",
              "source" : [{
                "context" : "physical"
              }],
              "target" : [{
                "context" : "physicalEntry",
                "contextType" : "variable",
                "element" : "resource",
                "variable" : "physicalObs",
                "transform" : "create",
                "parameter" : [{
                  "valueString" : "Observation"
                }]
              }],
              "rule" : [{
                "name" : "createphysicalobs",
                "source" : [{
                  "context" : "lifestyle"
                }],
                "dependent" : [{
                  "name" : "TransformPhysicalActivityObservation",
                  "variable" : ["lifestyle", "physicalObs", "dmPatient"]
                }]
              },
              {
                "name" : "setRequestAndFullUrl",
                "source" : [{
                  "context" : "lifestyle"
                }],
                "dependent" : [{
                  "name" : "setEntryRequestAndFullUrl",
                  "variable" : ["physicalObs", "physicalEntry"]
                }]
              }]
            }]
          }]
        },
        {
          "name" : "vitalentries",
          "source" : [{
            "context" : "src",
            "element" : "dossierSoins",
            "variable" : "soin",
            "condition" : "soin.patientId = %patient.patientId"
          }],
          "target" : [{
            "context" : "bundle",
            "contextType" : "variable",
            "element" : "entry",
            "variable" : "vitalEntry"
          }],
          "rule" : [{
            "name" : "createmesureobs",
            "source" : [{
              "context" : "soin"
            }],
            "target" : [{
              "context" : "vitalEntry",
              "contextType" : "variable",
              "element" : "resource",
              "variable" : "dmObs",
              "transform" : "create",
              "parameter" : [{
                "valueString" : "Observation"
              }]
            }],
            "rule" : [{
              "name" : "createmesureobs",
              "source" : [{
                "context" : "soin"
              }],
              "dependent" : [{
                "name" : "TransformVitalSigns",
                "variable" : ["soin", "dmObs", "dmPatient"]
              }]
            },
            {
              "name" : "setRequestAndFullUrl",
              "source" : [{
                "context" : "soin"
              }],
              "dependent" : [{
                "name" : "setEntryRequestAndFullUrl",
                "variable" : ["dmObs", "vitalEntry"]
              }]
            }]
          }]
        },
        {
          "name" : "administrationentries",
          "source" : [{
            "context" : "src",
            "element" : "administration",
            "variable" : "admin",
            "condition" : "(admin.patientId = %patient.patientId) and admin.prescriptionId.empty()"
          }],
          "target" : [{
            "context" : "bundle",
            "contextType" : "variable",
            "element" : "entry",
            "variable" : "adminEntry"
          }],
          "rule" : [{
            "name" : "createmedadmin",
            "source" : [{
              "context" : "admin"
            }],
            "target" : [{
              "context" : "adminEntry",
              "contextType" : "variable",
              "element" : "resource",
              "variable" : "dmAdmin",
              "transform" : "create",
              "parameter" : [{
                "valueString" : "MedicationAdministration"
              }]
            }],
            "rule" : [{
              "name" : "createmedadmin",
              "source" : [{
                "context" : "admin"
              }],
              "dependent" : [{
                "name" : "TransformMedicationAdministrationWOOrder",
                "variable" : ["admin", "dmAdmin", "dmPatient"]
              }]
            },
            {
              "name" : "setRequestAndFullUrl",
              "source" : [{
                "context" : "admin"
              }],
              "dependent" : [{
                "name" : "setEntryRequestAndFullUrl",
                "variable" : ["dmAdmin", "adminEntry"]
              }]
            }]
          }]
        }]
      }]
    }]
  },
  {
    "name" : "TransformPatient",
    "typeMode" : "none",
    "documentation" : "---------------------------------------------------------\r\nPATIENT TRANSFORMATION\r\n---------------------------------------------------------",
    "input" : [{
      "name" : "src",
      "mode" : "source"
    },
    {
      "name" : "tgt",
      "type" : "Patient",
      "mode" : "target"
    }],
    "rule" : [{
      "name" : "setId",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgt",
        "contextType" : "variable",
        "element" : "id",
        "transform" : "uuid"
      }]
    },
    {
      "name" : "patientidentifier",
      "source" : [{
        "context" : "src",
        "element" : "patientId",
        "variable" : "pid"
      }],
      "target" : [{
        "context" : "tgt",
        "contextType" : "variable",
        "element" : "identifier",
        "variable" : "identifier"
      }],
      "rule" : [{
        "name" : "iduse",
        "source" : [{
          "context" : "pid"
        }],
        "target" : [{
          "context" : "identifier",
          "contextType" : "variable",
          "element" : "use",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "usual"
          }]
        }]
      },
      {
        "name" : "idtype",
        "source" : [{
          "context" : "pid"
        }],
        "target" : [{
          "context" : "identifier",
          "contextType" : "variable",
          "element" : "type",
          "transform" : "cc",
          "parameter" : [{
            "valueString" : "http://terminology.hl7.org/CodeSystem/v2-0203"
          },
          {
            "valueString" : "PI"
          },
          {
            "valueString" : "Patient Identifier"
          }]
        }]
      },
      {
        "name" : "idsystem",
        "source" : [{
          "context" : "pid"
        }],
        "target" : [{
          "context" : "identifier",
          "contextType" : "variable",
          "element" : "system",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "https://hospital.eu/ehr/patient-id"
          }]
        }]
      },
      {
        "name" : "idvalue",
        "source" : [{
          "context" : "pid"
        }],
        "target" : [{
          "context" : "identifier",
          "contextType" : "variable",
          "element" : "value",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "pid"
          }]
        }]
      }]
    },
    {
      "name" : "insidentifier",
      "source" : [{
        "context" : "src",
        "element" : "ins",
        "variable" : "ins",
        "condition" : "ins.exists()"
      }],
      "target" : [{
        "context" : "tgt",
        "contextType" : "variable",
        "element" : "identifier",
        "variable" : "insIdentifier"
      }],
      "rule" : [{
        "name" : "insuse",
        "source" : [{
          "context" : "ins"
        }],
        "target" : [{
          "context" : "insIdentifier",
          "contextType" : "variable",
          "element" : "use",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "official"
          }]
        }],
        "documentation" : "On part du principe qu'on n'est pas sur un old."
      },
      {
        "name" : "instype",
        "source" : [{
          "context" : "ins"
        }],
        "target" : [{
          "context" : "insIdentifier",
          "contextType" : "variable",
          "element" : "type",
          "transform" : "cc",
          "parameter" : [{
            "valueString" : "https://hl7.fr/ig/fhir/core/CodeSystem/fr-core-cs-v2-0203"
          },
          {
            "valueString" : "INS-NIR"
          },
          {
            "valueString" : "NIR définitif"
          }]
        }]
      },
      {
        "name" : "inssystem",
        "source" : [{
          "context" : "ins"
        }],
        "target" : [{
          "context" : "insIdentifier",
          "contextType" : "variable",
          "element" : "system",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "urn:oid:1.2.250.1.213.1.4.8"
          }]
        }]
      },
      {
        "name" : "insvalue",
        "source" : [{
          "context" : "ins"
        }],
        "target" : [{
          "context" : "insIdentifier",
          "contextType" : "variable",
          "element" : "value",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "ins"
          }]
        }]
      }]
    },
    {
      "name" : "patientname",
      "source" : [{
        "context" : "src",
        "condition" : "src.nom.exists() or src.prenom.exists()"
      }],
      "target" : [{
        "context" : "tgt",
        "contextType" : "variable",
        "element" : "name",
        "variable" : "name"
      }],
      "rule" : [{
        "name" : "familyname",
        "source" : [{
          "context" : "src",
          "element" : "nom",
          "variable" : "lastName"
        }],
        "target" : [{
          "context" : "name",
          "contextType" : "variable",
          "element" : "family",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "lastName"
          }]
        }]
      },
      {
        "name" : "givenname",
        "source" : [{
          "context" : "src",
          "element" : "prenom",
          "variable" : "firstName"
        }],
        "target" : [{
          "context" : "name",
          "contextType" : "variable",
          "element" : "given",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "firstName"
          }]
        }]
      },
      {
        "name" : "nameuse",
        "source" : [{
          "context" : "src"
        }],
        "target" : [{
          "context" : "name",
          "contextType" : "variable",
          "element" : "use",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "official"
          }]
        }],
        "documentation" : "hypothèse un peu forte."
      }]
    },
    {
      "name" : "birthdate",
      "source" : [{
        "context" : "src",
        "element" : "dateNaissance",
        "variable" : "birthDate"
      }],
      "target" : [{
        "context" : "tgt",
        "contextType" : "variable",
        "element" : "birthDate",
        "transform" : "copy",
        "parameter" : [{
          "valueId" : "birthDate"
        }]
      }]
    },
    {
      "name" : "gendermale",
      "source" : [{
        "context" : "src",
        "element" : "sexe",
        "variable" : "gender",
        "condition" : "gender = 'h'"
      }],
      "target" : [{
        "context" : "tgt",
        "contextType" : "variable",
        "element" : "gender",
        "transform" : "copy",
        "parameter" : [{
          "valueString" : "male"
        }]
      }]
    },
    {
      "name" : "genderfemale",
      "source" : [{
        "context" : "src",
        "element" : "sexe",
        "variable" : "gender",
        "condition" : "gender = 'f'"
      }],
      "target" : [{
        "context" : "tgt",
        "contextType" : "variable",
        "element" : "gender",
        "transform" : "copy",
        "parameter" : [{
          "valueString" : "female"
        }]
      }]
    },
    {
      "name" : "genderunknown",
      "source" : [{
        "context" : "src",
        "element" : "sexe",
        "variable" : "gender",
        "condition" : "gender.exists() and (gender != 'h') and (gender != 'f')"
      }],
      "target" : [{
        "context" : "tgt",
        "contextType" : "variable",
        "element" : "gender",
        "transform" : "copy",
        "parameter" : [{
          "valueString" : "unknown"
        }]
      }],
      "documentation" : "n'a pas grand sens en l'état des contraintes SQL"
    },
    {
      "name" : "deathDate",
      "source" : [{
        "context" : "src",
        "element" : "dateDeces",
        "variable" : "deathDate",
        "condition" : "deathDate.exists()"
      }],
      "target" : [{
        "context" : "tgt",
        "contextType" : "variable",
        "element" : "deceased",
        "variable" : "deceasedDate",
        "transform" : "cast",
        "parameter" : [{
          "valueId" : "deathDate"
        },
        {
          "valueString" : "dateTime"
        }]
      }],
      "rule" : [{
        "name" : "deathSource",
        "source" : [{
          "context" : "src",
          "element" : "sourceDeces",
          "variable" : "deathSource",
          "condition" : "deathSource.exists()"
        }],
        "target" : [{
          "context" : "deceasedDate",
          "contextType" : "variable",
          "element" : "extension",
          "variable" : "DeathSourceExtension"
        }],
        "rule" : [{
          "name" : "deathSourceUrl",
          "source" : [{
            "context" : "deathSource"
          }],
          "target" : [{
            "context" : "DeathSourceExtension",
            "contextType" : "variable",
            "element" : "url",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DeathSource"
            }]
          }]
        },
        {
          "name" : "deathSourceValue",
          "source" : [{
            "context" : "deathSource"
          }],
          "target" : [{
            "context" : "DeathSourceExtension",
            "contextType" : "variable",
            "element" : "value",
            "transform" : "cast",
            "parameter" : [{
              "valueId" : "deathSource"
            },
            {
              "valueString" : "code"
            }]
          }]
        }]
      }]
    },
    {
      "name" : "multiplebirth",
      "source" : [{
        "context" : "src",
        "element" : "rangGemellaire",
        "variable" : "twin",
        "condition" : "twin.exists()"
      }],
      "target" : [{
        "context" : "tgt",
        "contextType" : "variable",
        "element" : "multipleBirth",
        "transform" : "copy",
        "parameter" : [{
          "valueId" : "twin"
        }]
      }]
    }]
  },
  {
    "name" : "setAddress",
    "typeMode" : "none",
    "documentation" : "========================================================================\r\nPATIENT_LOCATION TRANSFORMATION\r\n========================================================================",
    "input" : [{
      "name" : "src",
      "mode" : "source"
    },
    {
      "name" : "tgtPat",
      "type" : "Patient",
      "mode" : "target"
    }],
    "rule" : [{
      "name" : "checkSource",
      "source" : [{
        "context" : "src",
        "condition" : "src.latitude.exists() or src.longitude.exists() or src.codeIris.exists() or src.libelleIris.exists() or src.codeGeographiqueResidence.exists()"
      }],
      "rule" : [{
        "name" : "createAddress",
        "source" : [{
          "context" : "src"
        }],
        "target" : [{
          "context" : "tgtPat",
          "contextType" : "variable",
          "element" : "address",
          "variable" : "newAddress"
        }],
        "rule" : [{
          "name" : "setCoordinates",
          "source" : [{
            "context" : "src",
            "condition" : "src.latitude.exists() or src.longitude.exists()"
          }],
          "target" : [{
            "context" : "newAddress",
            "contextType" : "variable",
            "element" : "extension",
            "variable" : "geolocationExtension"
          },
          {
            "context" : "geolocationExtension",
            "contextType" : "variable",
            "element" : "url",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "http://hl7.org/fhir/StructureDefinition/geolocation"
            }]
          }],
          "rule" : [{
            "name" : "setLat",
            "source" : [{
              "context" : "src",
              "element" : "latitude",
              "variable" : "srcLat"
            }],
            "target" : [{
              "context" : "geolocationExtension",
              "contextType" : "variable",
              "element" : "extension",
              "variable" : "tgtLat"
            },
            {
              "context" : "tgtLat",
              "contextType" : "variable",
              "element" : "url",
              "transform" : "copy",
              "parameter" : [{
                "valueString" : "latitude"
              }]
            },
            {
              "context" : "tgtLat",
              "contextType" : "variable",
              "element" : "value",
              "transform" : "copy",
              "parameter" : [{
                "valueId" : "srcLat"
              }]
            }]
          },
          {
            "name" : "setLong",
            "source" : [{
              "context" : "src",
              "element" : "longitude",
              "variable" : "srcLong"
            }],
            "target" : [{
              "context" : "geolocationExtension",
              "contextType" : "variable",
              "element" : "extension",
              "variable" : "tgtLong"
            },
            {
              "context" : "tgtLong",
              "contextType" : "variable",
              "element" : "url",
              "transform" : "copy",
              "parameter" : [{
                "valueString" : "longitude"
              }]
            },
            {
              "context" : "tgtLong",
              "contextType" : "variable",
              "element" : "value",
              "transform" : "copy",
              "parameter" : [{
                "valueId" : "srcLong"
              }]
            }]
          }]
        },
        {
          "name" : "setIris",
          "source" : [{
            "context" : "src",
            "condition" : "src.codeIris.exists() or src.libelleIris.exists()"
          }],
          "target" : [{
            "context" : "newAddress",
            "contextType" : "variable",
            "element" : "line",
            "variable" : "irisLine",
            "transform" : "evaluate",
            "parameter" : [{
              "valueString" : "%src.libelleIris"
            }]
          },
          {
            "context" : "irisLine",
            "contextType" : "variable",
            "element" : "extension",
            "variable" : "irisExtension",
            "transform" : "create",
            "parameter" : [{
              "valueString" : "Extension"
            }]
          },
          {
            "context" : "irisExtension",
            "contextType" : "variable",
            "element" : "url",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-censusTract"
            }]
          },
          {
            "context" : "irisExtension",
            "contextType" : "variable",
            "element" : "value",
            "transform" : "evaluate",
            "parameter" : [{
              "valueString" : "%src.codeIris"
            }]
          }]
        },
        {
          "name" : "SetResidencePmsi",
          "source" : [{
            "context" : "src",
            "element" : "codeGeographiqueResidence",
            "variable" : "srcCodeGeographiqueResidence",
            "condition" : "src.codeGeographiqueResidence.exists()"
          }],
          "target" : [{
            "context" : "newAddress",
            "contextType" : "variable",
            "element" : "extension",
            "variable" : "residencePmsiExtension"
          },
          {
            "context" : "residencePmsiExtension",
            "contextType" : "variable",
            "element" : "url",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/PmsiCodeGeo"
            }]
          },
          {
            "context" : "residencePmsiExtension",
            "contextType" : "variable",
            "element" : "value",
            "transform" : "cast",
            "parameter" : [{
              "valueId" : "srcCodeGeographiqueResidence"
            },
            {
              "valueString" : "code"
            }]
          }]
        },
        {
          "name" : "setDateRecueil",
          "source" : [{
            "context" : "src",
            "element" : "dateRecueil",
            "variable" : "dateRecueil"
          }],
          "target" : [{
            "context" : "newAddress",
            "contextType" : "variable",
            "element" : "period",
            "variable" : "newAddressPeriod"
          },
          {
            "context" : "newAddressPeriod",
            "contextType" : "variable",
            "element" : "start",
            "transform" : "copy",
            "parameter" : [{
              "valueId" : "dateRecueil"
            }]
          }]
        }]
      }]
    }]
  },
  {
    "name" : "TransformEncounter",
    "typeMode" : "none",
    "documentation" : "========================================================================\r\nENCOUNTER TRANSFORMATION\r\n========================================================================",
    "input" : [{
      "name" : "src",
      "mode" : "source"
    },
    {
      "name" : "tgtEnc",
      "type" : "Encounter",
      "mode" : "target"
    },
    {
      "name" : "patient",
      "mode" : "source"
    }],
    "rule" : [{
      "name" : "setId",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtEnc",
        "contextType" : "variable",
        "element" : "id",
        "transform" : "uuid"
      }]
    },
    {
      "name" : "encounteridentifier",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtEnc",
        "contextType" : "variable",
        "element" : "identifier",
        "variable" : "identifier"
      }],
      "rule" : [{
        "name" : "idtype",
        "source" : [{
          "context" : "src"
        }],
        "target" : [{
          "context" : "identifier",
          "contextType" : "variable",
          "element" : "type",
          "transform" : "cc",
          "parameter" : [{
            "valueString" : "https://hl7.fr/ig/fhir/core/CodeSystem/fr-core-cs-identifier-type"
          },
          {
            "valueString" : "VN"
          },
          {
            "valueString" : "Visit Number"
          }]
        }]
      },
      {
        "name" : "encounteridsystem",
        "source" : [{
          "context" : "src"
        }],
        "target" : [{
          "context" : "identifier",
          "contextType" : "variable",
          "element" : "system",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "https://hospital.eu/ehr/pmsi-id"
          }]
        }]
      },
      {
        "name" : "encounteridvalue",
        "source" : [{
          "context" : "src",
          "element" : "pmsiId",
          "variable" : "srcEncoutnerId"
        }],
        "target" : [{
          "context" : "identifier",
          "contextType" : "variable",
          "element" : "value",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "srcEncoutnerId"
          }]
        }]
      }]
    },
    {
      "name" : "encounterstatus",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtEnc",
        "contextType" : "variable",
        "element" : "status",
        "transform" : "copy",
        "parameter" : [{
          "valueString" : "finished"
        }]
      }]
    },
    {
      "name" : "encounterclass",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtEnc",
        "contextType" : "variable",
        "element" : "class",
        "transform" : "c",
        "parameter" : [{
          "valueString" : "http://terminology.hl7.org/CodeSystem/v3-ActCode"
        },
        {
          "valueString" : "IMP"
        },
        {
          "valueString" : "inpatient encounter"
        }]
      }]
    },
    {
      "name" : "encountersubject",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtEnc",
        "contextType" : "variable",
        "element" : "subject",
        "variable" : "ref",
        "transform" : "create",
        "parameter" : [{
          "valueString" : "Reference"
        }]
      }],
      "rule" : [{
        "name" : "subjectreference",
        "source" : [{
          "context" : "patient",
          "element" : "id",
          "variable" : "patientId"
        }],
        "target" : [{
          "context" : "ref",
          "contextType" : "variable",
          "element" : "reference",
          "transform" : "evaluate",
          "parameter" : [{
            "valueString" : "'Patient/' + %patientId"
          }]
        },
        {
          "context" : "ref",
          "contextType" : "variable",
          "element" : "type",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "Patient"
          }]
        }]
      }]
    },
    {
      "name" : "encounterperiod",
      "source" : [{
        "context" : "src",
        "condition" : "src.dateDebutSejour.exists() or src.dateFinSejour.exists()"
      }],
      "target" : [{
        "context" : "tgtEnc",
        "contextType" : "variable",
        "element" : "period",
        "variable" : "period"
      }],
      "rule" : [{
        "name" : "periodstart",
        "source" : [{
          "context" : "src",
          "element" : "dateDebutSejour",
          "variable" : "startDate"
        }],
        "target" : [{
          "context" : "period",
          "contextType" : "variable",
          "element" : "start",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "startDate"
          }]
        }]
      },
      {
        "name" : "periodend",
        "source" : [{
          "context" : "src",
          "element" : "dateFinSejour",
          "variable" : "endDate"
        }],
        "target" : [{
          "context" : "period",
          "contextType" : "variable",
          "element" : "end",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "endDate"
          }]
        }]
      }]
    },
    {
      "name" : "encounterhospitalization",
      "source" : [{
        "context" : "src",
        "condition" : "src.modeEntree.exists() or src.modeSortie.exists()"
      }],
      "target" : [{
        "context" : "tgtEnc",
        "contextType" : "variable",
        "element" : "hospitalization",
        "variable" : "hosp"
      }],
      "rule" : [{
        "name" : "admitsource",
        "source" : [{
          "context" : "src",
          "element" : "modeEntree",
          "variable" : "admitSource"
        }],
        "target" : [{
          "context" : "hosp",
          "contextType" : "variable",
          "element" : "admitSource",
          "variable" : "admitSrc"
        }],
        "rule" : [{
          "name" : "admitsourcetext",
          "source" : [{
            "context" : "admitSource"
          }],
          "target" : [{
            "context" : "admitSrc",
            "contextType" : "variable",
            "element" : "text",
            "transform" : "copy",
            "parameter" : [{
              "valueId" : "admitSource"
            }]
          }]
        }]
      },
      {
        "name" : "dischargedisposition",
        "source" : [{
          "context" : "src",
          "element" : "modeSortie",
          "variable" : "dischargeDisp"
        }],
        "target" : [{
          "context" : "hosp",
          "contextType" : "variable",
          "element" : "dischargeDisposition",
          "variable" : "dischargeDsp"
        }],
        "rule" : [{
          "name" : "dischargedisptext",
          "source" : [{
            "context" : "dischargeDisp"
          }],
          "target" : [{
            "context" : "dischargeDsp",
            "contextType" : "variable",
            "element" : "text",
            "transform" : "copy",
            "parameter" : [{
              "valueId" : "dischargeDisp"
            }]
          }]
        }]
      }]
    },
    {
      "name" : "provider",
      "source" : [{
        "context" : "src",
        "condition" : "src.uniteFonctionnelle.exists() or src.service.exists() or src.etablissement.exists()"
      }],
      "target" : [{
        "context" : "tgtEnc",
        "contextType" : "variable",
        "element" : "serviceProvider",
        "variable" : "provider"
      }],
      "rule" : [{
        "name" : "providerdisplay",
        "source" : [{
          "context" : "src"
        }],
        "target" : [{
          "context" : "provider",
          "contextType" : "variable",
          "element" : "display",
          "transform" : "evaluate",
          "parameter" : [{
            "valueString" : "iif(%src.uniteFonctionnelle.exists(), %src.uniteFonctionnelle, iif(%src.service.exists(), %src.service, %src.etablissement))"
          }]
        }]
      }]
    }]
  },
  {
    "name" : "TransformCondition",
    "typeMode" : "none",
    "documentation" : "========================================================================\r\nCONDITION TRANSFORMATION\r\n========================================================================",
    "input" : [{
      "name" : "src",
      "mode" : "source"
    },
    {
      "name" : "tgtCond",
      "type" : "Condition",
      "mode" : "target"
    },
    {
      "name" : "patient",
      "mode" : "source"
    },
    {
      "name" : "encounter",
      "mode" : "source"
    }],
    "rule" : [{
      "name" : "setId",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtCond",
        "contextType" : "variable",
        "element" : "id",
        "transform" : "uuid"
      }]
    },
    {
      "name" : "conditionidentifier",
      "source" : [{
        "context" : "src",
        "element" : "diagnosticId",
        "variable" : "diagId"
      }],
      "target" : [{
        "context" : "tgtCond",
        "contextType" : "variable",
        "element" : "identifier",
        "variable" : "identifier"
      }],
      "rule" : [{
        "name" : "conditionidsystem",
        "source" : [{
          "context" : "diagId"
        }],
        "target" : [{
          "context" : "identifier",
          "contextType" : "variable",
          "element" : "system",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "https://hospital.eu/ehr/diagnostic-id"
          }]
        }]
      },
      {
        "name" : "conditionidvalue",
        "source" : [{
          "context" : "diagId"
        }],
        "target" : [{
          "context" : "identifier",
          "contextType" : "variable",
          "element" : "value",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "diagId"
          }]
        }]
      }]
    },
    {
      "name" : "categoryencounterDiag",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtCond",
        "contextType" : "variable",
        "element" : "category",
        "transform" : "cc",
        "parameter" : [{
          "valueString" : "http://terminology.hl7.org/CodeSystem/condition-category"
        },
        {
          "valueString" : "encounter-diagnosis"
        },
        {
          "valueString" : "Encounter Diagnosis"
        }]
      }]
    },
    {
      "name" : "conditioncategory",
      "source" : [{
        "context" : "src",
        "element" : "typeDiagnostic",
        "variable" : "diagType"
      }],
      "target" : [{
        "context" : "tgtCond",
        "contextType" : "variable",
        "element" : "category",
        "variable" : "category"
      }],
      "rule" : [{
        "name" : "categorytext",
        "source" : [{
          "context" : "diagType"
        }],
        "target" : [{
          "context" : "category",
          "contextType" : "variable",
          "element" : "text",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "diagType"
          }]
        }]
      }]
    },
    {
      "name" : "varcode",
      "source" : [{
        "context" : "src",
        "element" : "codeDiagnostic",
        "variable" : "srcCode"
      }],
      "target" : [{
        "context" : "tgtCond",
        "contextType" : "variable",
        "element" : "code",
        "variable" : "conditionCode"
      }],
      "rule" : [{
        "name" : "conditioncode",
        "source" : [{
          "context" : "src",
          "element" : "libelleDiagnostic",
          "variable" : "label"
        }],
        "target" : [{
          "context" : "conditionCode",
          "contextType" : "variable",
          "element" : "coding",
          "variable" : "tgtCoding"
        },
        {
          "context" : "tgtCoding",
          "contextType" : "variable",
          "element" : "system",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "http://hl7.org/fhir/sid/icd-10"
          }]
        },
        {
          "context" : "tgtCoding",
          "contextType" : "variable",
          "element" : "code",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "srcCode"
          }]
        }]
      },
      {
        "name" : "codetext",
        "source" : [{
          "context" : "src",
          "element" : "libelleDiagnostic",
          "variable" : "text"
        }],
        "target" : [{
          "context" : "conditionCode",
          "contextType" : "variable",
          "element" : "text",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "text"
          }]
        }]
      }]
    },
    {
      "name" : "conditionsubject",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtCond",
        "contextType" : "variable",
        "element" : "subject",
        "variable" : "ref",
        "transform" : "create",
        "parameter" : [{
          "valueString" : "Reference"
        }]
      }],
      "rule" : [{
        "name" : "subjectref",
        "source" : [{
          "context" : "patient",
          "element" : "id",
          "variable" : "patientId"
        }],
        "target" : [{
          "context" : "ref",
          "contextType" : "variable",
          "element" : "reference",
          "transform" : "evaluate",
          "parameter" : [{
            "valueString" : "'Patient/' + %patientId"
          }]
        },
        {
          "context" : "ref",
          "contextType" : "variable",
          "element" : "type",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "Patient"
          }]
        }]
      }]
    },
    {
      "name" : "conditionencounter",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtCond",
        "contextType" : "variable",
        "element" : "encounter",
        "variable" : "ref",
        "transform" : "create",
        "parameter" : [{
          "valueString" : "Reference"
        }]
      }],
      "rule" : [{
        "name" : "encounterref",
        "source" : [{
          "context" : "encounter",
          "element" : "id",
          "variable" : "encounterId"
        }],
        "target" : [{
          "context" : "ref",
          "contextType" : "variable",
          "element" : "reference",
          "transform" : "evaluate",
          "parameter" : [{
            "valueString" : "'Encounter/' + %encounterId"
          }]
        },
        {
          "context" : "ref",
          "contextType" : "variable",
          "element" : "type",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "Encounter"
          }]
        }]
      }]
    },
    {
      "name" : "conditionrecordeddate",
      "source" : [{
        "context" : "src",
        "element" : "dateRecueil",
        "variable" : "entryDate"
      }],
      "target" : [{
        "context" : "tgtCond",
        "contextType" : "variable",
        "element" : "recordedDate",
        "transform" : "copy",
        "parameter" : [{
          "valueId" : "entryDate"
        }]
      }]
    },
    {
      "name" : "conditionclinicalstatus",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtCond",
        "contextType" : "variable",
        "element" : "clinicalStatus",
        "transform" : "cc",
        "parameter" : [{
          "valueString" : "http://terminology.hl7.org/CodeSystem/condition-clinical"
        },
        {
          "valueString" : "active"
        }]
      }]
    },
    {
      "name" : "conditionverificationstatus",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtCond",
        "contextType" : "variable",
        "element" : "verificationStatus",
        "transform" : "cc",
        "parameter" : [{
          "valueString" : "http://terminology.hl7.org/CodeSystem/condition-ver-status"
        },
        {
          "valueString" : "confirmed"
        }]
      }]
    }]
  },
  {
    "name" : "TransformProcedure",
    "typeMode" : "none",
    "documentation" : "========================================================================\r\nPROCEDURE TRANSFORMATION\r\n========================================================================",
    "input" : [{
      "name" : "src",
      "mode" : "source"
    },
    {
      "name" : "tgtProc",
      "type" : "Procedure",
      "mode" : "target"
    },
    {
      "name" : "patient",
      "mode" : "source"
    },
    {
      "name" : "encounter",
      "mode" : "source"
    }],
    "rule" : [{
      "name" : "setId",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtProc",
        "contextType" : "variable",
        "element" : "id",
        "transform" : "uuid"
      }]
    },
    {
      "name" : "procedureidentifier",
      "source" : [{
        "context" : "src",
        "element" : "acteId",
        "variable" : "acteId"
      }],
      "target" : [{
        "context" : "tgtProc",
        "contextType" : "variable",
        "element" : "identifier",
        "variable" : "identifier"
      }],
      "rule" : [{
        "name" : "procedureidsystem",
        "source" : [{
          "context" : "acteId"
        }],
        "target" : [{
          "context" : "identifier",
          "contextType" : "variable",
          "element" : "system",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "https://hospital.eu/ehr/acte-id"
          }]
        }]
      },
      {
        "name" : "procedureidvalue",
        "source" : [{
          "context" : "acteId"
        }],
        "target" : [{
          "context" : "identifier",
          "contextType" : "variable",
          "element" : "value",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "acteId"
          }]
        }]
      }]
    },
    {
      "name" : "procedurestatus",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtProc",
        "contextType" : "variable",
        "element" : "status",
        "transform" : "copy",
        "parameter" : [{
          "valueString" : "completed"
        }]
      }]
    },
    {
      "name" : "procedurecode",
      "source" : [{
        "context" : "src",
        "element" : "codeActe",
        "variable" : "code"
      }],
      "target" : [{
        "context" : "tgtProc",
        "contextType" : "variable",
        "element" : "code",
        "variable" : "procedureCode"
      }],
      "rule" : [{
        "name" : "procedurecoding",
        "source" : [{
          "context" : "code"
        }],
        "target" : [{
          "context" : "procedureCode",
          "contextType" : "variable",
          "element" : "coding",
          "variable" : "coding"
        },
        {
          "context" : "coding",
          "contextType" : "variable",
          "element" : "system",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "https://interop.aphp.fr/ig/fhir/dm/CodeSystem/Ccam"
          }]
        },
        {
          "context" : "coding",
          "contextType" : "variable",
          "element" : "code",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "code"
          }]
        }]
      },
      {
        "name" : "codetext",
        "source" : [{
          "context" : "src",
          "element" : "libelleActe",
          "variable" : "text"
        }],
        "target" : [{
          "context" : "procedureCode",
          "contextType" : "variable",
          "element" : "text",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "text"
          }]
        }]
      }]
    },
    {
      "name" : "proceduresubject",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtProc",
        "contextType" : "variable",
        "element" : "subject",
        "variable" : "ref",
        "transform" : "create",
        "parameter" : [{
          "valueString" : "Reference"
        }]
      }],
      "rule" : [{
        "name" : "subjectref",
        "source" : [{
          "context" : "patient",
          "element" : "id",
          "variable" : "patientId"
        }],
        "target" : [{
          "context" : "ref",
          "contextType" : "variable",
          "element" : "reference",
          "transform" : "evaluate",
          "parameter" : [{
            "valueString" : "'Patient/' + %patientId"
          }]
        },
        {
          "context" : "ref",
          "contextType" : "variable",
          "element" : "type",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "Patient"
          }]
        }]
      }]
    },
    {
      "name" : "procedureencounter",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtProc",
        "contextType" : "variable",
        "element" : "encounter",
        "variable" : "ref",
        "transform" : "create",
        "parameter" : [{
          "valueString" : "Reference"
        }]
      }],
      "rule" : [{
        "name" : "encounterref",
        "source" : [{
          "context" : "encounter",
          "element" : "id",
          "variable" : "encounterId"
        }],
        "target" : [{
          "context" : "ref",
          "contextType" : "variable",
          "element" : "reference",
          "transform" : "evaluate",
          "parameter" : [{
            "valueString" : "'Encounter/' + %encounterId"
          }]
        },
        {
          "context" : "ref",
          "contextType" : "variable",
          "element" : "type",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "Encounter"
          }]
        }]
      }]
    },
    {
      "name" : "procedureperformed",
      "source" : [{
        "context" : "src",
        "element" : "dateActe",
        "variable" : "performedDate",
        "condition" : "%performedDate.exists()"
      }],
      "target" : [{
        "context" : "tgtProc",
        "contextType" : "variable",
        "element" : "performed",
        "transform" : "copy",
        "parameter" : [{
          "valueId" : "performedDate"
        }]
      }]
    },
    {
      "name" : "procedureperformer",
      "source" : [{
        "context" : "src",
        "element" : "executant",
        "variable" : "performer"
      }],
      "target" : [{
        "context" : "tgtProc",
        "contextType" : "variable",
        "element" : "performer",
        "variable" : "perf"
      }],
      "rule" : [{
        "name" : "performeractor",
        "source" : [{
          "context" : "performer"
        }],
        "target" : [{
          "context" : "perf",
          "contextType" : "variable",
          "element" : "actor",
          "variable" : "actor"
        }],
        "rule" : [{
          "name" : "performerdisplay",
          "source" : [{
            "context" : "performer"
          }],
          "target" : [{
            "context" : "actor",
            "contextType" : "variable",
            "element" : "display",
            "transform" : "copy",
            "parameter" : [{
              "valueId" : "performer"
            }]
          }]
        },
        {
          "name" : "performerType",
          "source" : [{
            "context" : "performer"
          }],
          "target" : [{
            "context" : "actor",
            "contextType" : "variable",
            "element" : "type",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "Practitioner"
            }]
          }]
        }]
      },
      {
        "name" : "performerFunction",
        "source" : [{
          "context" : "performer"
        }],
        "target" : [{
          "context" : "perf",
          "contextType" : "variable",
          "element" : "function",
          "variable" : "function"
        },
        {
          "context" : "function",
          "contextType" : "variable",
          "element" : "text",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "Exécutant"
          }]
        }]
      }]
    }]
  },
  {
    "name" : "TransformLabObservation",
    "typeMode" : "none",
    "documentation" : "========================================================================\r\nLABORATORY OBSERVATION TRANSFORMATION\r\n========================================================================",
    "input" : [{
      "name" : "src",
      "mode" : "source"
    },
    {
      "name" : "tgtObs",
      "type" : "Observation",
      "mode" : "target"
    },
    {
      "name" : "patient",
      "mode" : "source"
    }],
    "rule" : [{
      "name" : "setId",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "id",
        "transform" : "uuid"
      }]
    },
    {
      "name" : "labidentifier",
      "source" : [{
        "context" : "src",
        "element" : "biologieId",
        "variable" : "bioId"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "identifier",
        "variable" : "identifier"
      }],
      "rule" : [{
        "name" : "labidsystem",
        "source" : [{
          "context" : "bioId"
        }],
        "target" : [{
          "context" : "identifier",
          "contextType" : "variable",
          "element" : "system",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "https://hospital.eu/ehr/biologie-id"
          }]
        }]
      },
      {
        "name" : "labidvalue",
        "source" : [{
          "context" : "bioId"
        }],
        "target" : [{
          "context" : "identifier",
          "contextType" : "variable",
          "element" : "value",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "bioId"
          }]
        }]
      }]
    },
    {
      "name" : "statusvalidated",
      "source" : [{
        "context" : "src",
        "element" : "statutValidation",
        "variable" : "validation",
        "condition" : "validation = 'VALIDE'"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "status",
        "transform" : "copy",
        "parameter" : [{
          "valueString" : "final"
        }]
      }]
    },
    {
      "name" : "statusdefault",
      "source" : [{
        "context" : "src",
        "condition" : "src.statutValidation.exists().not()"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "status",
        "transform" : "copy",
        "parameter" : [{
          "valueString" : "final"
        }]
      }]
    },
    {
      "name" : "labcategory",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "category",
        "variable" : "category"
      }],
      "rule" : [{
        "name" : "categorycoding",
        "source" : [{
          "context" : "src"
        }],
        "target" : [{
          "context" : "category",
          "contextType" : "variable",
          "element" : "coding",
          "variable" : "coding"
        }],
        "rule" : [{
          "name" : "categorysystem",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "system",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "http://terminology.hl7.org/CodeSystem/observation-category"
            }]
          }]
        },
        {
          "name" : "categorycode",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "code",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "laboratory"
            }]
          }]
        },
        {
          "name" : "categorydisplay",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "display",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "Laboratory"
            }]
          }]
        }]
      }]
    },
    {
      "name" : "labcode",
      "source" : [{
        "context" : "src",
        "element" : "codeLoinc",
        "variable" : "loinc"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "code",
        "variable" : "code"
      }],
      "rule" : [{
        "name" : "labcoding",
        "source" : [{
          "context" : "loinc"
        }],
        "target" : [{
          "context" : "code",
          "contextType" : "variable",
          "element" : "coding",
          "variable" : "coding"
        }],
        "rule" : [{
          "name" : "codesystem",
          "source" : [{
            "context" : "loinc"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "system",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "http://loinc.org"
            }]
          }]
        },
        {
          "name" : "codevalue",
          "source" : [{
            "context" : "loinc"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "code",
            "transform" : "copy",
            "parameter" : [{
              "valueId" : "loinc"
            }]
          }]
        }]
      },
      {
        "name" : "codetext",
        "source" : [{
          "context" : "src",
          "element" : "libelleTest",
          "variable" : "text"
        }],
        "target" : [{
          "context" : "code",
          "contextType" : "variable",
          "element" : "text",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "text"
          }]
        }]
      }]
    },
    {
      "name" : "labsubject",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "subject",
        "variable" : "ref",
        "transform" : "create",
        "parameter" : [{
          "valueString" : "Reference"
        }]
      }],
      "rule" : [{
        "name" : "subjectref",
        "source" : [{
          "context" : "patient",
          "element" : "id",
          "variable" : "patientId"
        }],
        "target" : [{
          "context" : "ref",
          "contextType" : "variable",
          "element" : "reference",
          "transform" : "evaluate",
          "parameter" : [{
            "valueString" : "'Patient/' + %patientId"
          }]
        },
        {
          "context" : "ref",
          "contextType" : "variable",
          "element" : "type",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "Patient"
          }]
        }]
      }]
    },
    {
      "name" : "labeffective",
      "source" : [{
        "context" : "src",
        "element" : "datePrelevement",
        "variable" : "collectionDate",
        "condition" : "%collectionDate.exists()"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "effective",
        "transform" : "cast",
        "parameter" : [{
          "valueId" : "collectionDate"
        },
        {
          "valueString" : "dateTime"
        }]
      }]
    },
    {
      "name" : "labvaluequantity",
      "source" : [{
        "context" : "src",
        "element" : "valeur",
        "variable" : "numValue",
        "condition" : "numValue.exists()"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "value",
        "variable" : "qty",
        "transform" : "create",
        "parameter" : [{
          "valueString" : "Quantity"
        }]
      }],
      "rule" : [{
        "name" : "quantityvalue",
        "source" : [{
          "context" : "numValue"
        }],
        "target" : [{
          "context" : "qty",
          "contextType" : "variable",
          "element" : "value",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "numValue"
          }]
        }]
      },
      {
        "name" : "quantityunit",
        "source" : [{
          "context" : "src",
          "element" : "unite",
          "variable" : "unit"
        }],
        "target" : [{
          "context" : "qty",
          "contextType" : "variable",
          "element" : "unit",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "unit"
          }]
        }]
      },
      {
        "name" : "quantitycode",
        "source" : [{
          "context" : "src",
          "element" : "unite",
          "variable" : "unit"
        }],
        "target" : [{
          "context" : "qty",
          "contextType" : "variable",
          "element" : "code",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "unit"
          }]
        }]
      },
      {
        "name" : "quantitysystem",
        "source" : [{
          "context" : "src"
        }],
        "target" : [{
          "context" : "qty",
          "contextType" : "variable",
          "element" : "system",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "http://unitsofmeasure.org"
          }]
        }]
      }]
    },
    {
      "name" : "labreferencerange",
      "source" : [{
        "context" : "src",
        "condition" : "src.borneInfNormale.exists() or src.borneSupNormale.exists()"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "referenceRange",
        "variable" : "range"
      }],
      "rule" : [{
        "name" : "referencelow",
        "source" : [{
          "context" : "src",
          "element" : "borneInfNormale",
          "variable" : "low"
        }],
        "target" : [{
          "context" : "range",
          "contextType" : "variable",
          "element" : "low",
          "variable" : "lowQty"
        }],
        "rule" : [{
          "name" : "reflowvalue",
          "source" : [{
            "context" : "low"
          }],
          "target" : [{
            "context" : "lowQty",
            "contextType" : "variable",
            "element" : "value",
            "transform" : "copy",
            "parameter" : [{
              "valueId" : "low"
            }]
          }]
        },
        {
          "name" : "reflowunit",
          "source" : [{
            "context" : "src",
            "element" : "unite",
            "variable" : "unit"
          }],
          "target" : [{
            "context" : "lowQty",
            "contextType" : "variable",
            "element" : "unit",
            "transform" : "copy",
            "parameter" : [{
              "valueId" : "unit"
            }]
          }]
        },
        {
          "name" : "reflowcode",
          "source" : [{
            "context" : "src",
            "element" : "unite",
            "variable" : "unit"
          }],
          "target" : [{
            "context" : "lowQty",
            "contextType" : "variable",
            "element" : "code",
            "transform" : "copy",
            "parameter" : [{
              "valueId" : "unit"
            }]
          }]
        },
        {
          "name" : "reflowsystem",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "lowQty",
            "contextType" : "variable",
            "element" : "system",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "http://unitsofmeasure.org"
            }]
          }]
        }]
      },
      {
        "name" : "referencehigh",
        "source" : [{
          "context" : "src",
          "element" : "borneSupNormale",
          "variable" : "high"
        }],
        "target" : [{
          "context" : "range",
          "contextType" : "variable",
          "element" : "high",
          "variable" : "highQty"
        }],
        "rule" : [{
          "name" : "refhighvalue",
          "source" : [{
            "context" : "high"
          }],
          "target" : [{
            "context" : "highQty",
            "contextType" : "variable",
            "element" : "value",
            "transform" : "copy",
            "parameter" : [{
              "valueId" : "high"
            }]
          }]
        },
        {
          "name" : "refhighunit",
          "source" : [{
            "context" : "src",
            "element" : "unite",
            "variable" : "unit"
          }],
          "target" : [{
            "context" : "highQty",
            "contextType" : "variable",
            "element" : "unit",
            "transform" : "copy",
            "parameter" : [{
              "valueId" : "unit"
            }]
          }]
        },
        {
          "name" : "refhighcode",
          "source" : [{
            "context" : "src",
            "element" : "unite",
            "variable" : "unit"
          }],
          "target" : [{
            "context" : "highQty",
            "contextType" : "variable",
            "element" : "code",
            "transform" : "copy",
            "parameter" : [{
              "valueId" : "unit"
            }]
          }]
        },
        {
          "name" : "refhighsystem",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "highQty",
            "contextType" : "variable",
            "element" : "system",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "http://unitsofmeasure.org"
            }]
          }]
        }]
      }]
    },
    {
      "name" : "labperformer",
      "source" : [{
        "context" : "src",
        "element" : "laboratoire",
        "variable" : "lab"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "performer",
        "variable" : "performer"
      }],
      "rule" : [{
        "name" : "performerdisplay",
        "source" : [{
          "context" : "lab"
        }],
        "target" : [{
          "context" : "performer",
          "contextType" : "variable",
          "element" : "display",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "lab"
          }]
        }]
      },
      {
        "name" : "performerType",
        "source" : [{
          "context" : "lab"
        }],
        "target" : [{
          "context" : "performer",
          "contextType" : "variable",
          "element" : "type",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "Organization"
          }]
        }]
      }]
    }]
  },
  {
    "name" : "TransformMedicationRequest",
    "typeMode" : "none",
    "documentation" : "========================================================================\r\nMEDICATION REQUEST TRANSFORMATION\r\n========================================================================",
    "input" : [{
      "name" : "src",
      "mode" : "source"
    },
    {
      "name" : "tgtMedReq",
      "type" : "MedicationRequest",
      "mode" : "target"
    },
    {
      "name" : "patient",
      "mode" : "source"
    }],
    "rule" : [{
      "name" : "setId",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtMedReq",
        "contextType" : "variable",
        "element" : "id",
        "transform" : "uuid"
      }]
    },
    {
      "name" : "medrequestidentifier",
      "source" : [{
        "context" : "src",
        "element" : "prescriptionId",
        "variable" : "presId"
      }],
      "target" : [{
        "context" : "tgtMedReq",
        "contextType" : "variable",
        "element" : "identifier",
        "variable" : "identifier"
      }],
      "rule" : [{
        "name" : "medrequestidsystem",
        "source" : [{
          "context" : "presId"
        }],
        "target" : [{
          "context" : "identifier",
          "contextType" : "variable",
          "element" : "system",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "https://hospital.eu/ehr/prescription-id"
          }]
        }]
      },
      {
        "name" : "medrequestidvalue",
        "source" : [{
          "context" : "presId"
        }],
        "target" : [{
          "context" : "identifier",
          "contextType" : "variable",
          "element" : "value",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "presId"
          }]
        }]
      }]
    },
    {
      "name" : "medrequeststatus",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtMedReq",
        "contextType" : "variable",
        "element" : "status",
        "transform" : "copy",
        "parameter" : [{
          "valueString" : "unknown"
        }]
      }]
    },
    {
      "name" : "medrequestintent",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtMedReq",
        "contextType" : "variable",
        "element" : "intent",
        "transform" : "copy",
        "parameter" : [{
          "valueString" : "order"
        }]
      }]
    },
    {
      "name" : "medrequestsubject",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtMedReq",
        "contextType" : "variable",
        "element" : "subject",
        "variable" : "ref",
        "transform" : "create",
        "parameter" : [{
          "valueString" : "Reference"
        }]
      }],
      "rule" : [{
        "name" : "subjectref",
        "source" : [{
          "context" : "patient",
          "element" : "id",
          "variable" : "patientId"
        }],
        "target" : [{
          "context" : "ref",
          "contextType" : "variable",
          "element" : "reference",
          "transform" : "evaluate",
          "parameter" : [{
            "valueString" : "'Patient/' + %patientId"
          }]
        },
        {
          "context" : "ref",
          "contextType" : "variable",
          "element" : "type",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "Patient"
          }]
        }]
      }]
    },
    {
      "name" : "medicationdenomination",
      "source" : [{
        "context" : "src",
        "element" : "denomination",
        "variable" : "denomination"
      }],
      "target" : [{
        "context" : "tgtMedReq",
        "contextType" : "variable",
        "element" : "medication",
        "variable" : "medication",
        "transform" : "create",
        "parameter" : [{
          "valueString" : "CodeableConcept"
        }]
      }],
      "rule" : [{
        "name" : "medicationtext",
        "source" : [{
          "context" : "denomination",
          "variable" : "text"
        }],
        "target" : [{
          "context" : "medication",
          "contextType" : "variable",
          "element" : "text",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "text"
          }]
        }]
      },
      {
        "name" : "atccoding",
        "source" : [{
          "context" : "src",
          "element" : "codeAtc",
          "variable" : "atc"
        }],
        "target" : [{
          "context" : "medication",
          "contextType" : "variable",
          "element" : "coding",
          "variable" : "coding"
        }],
        "rule" : [{
          "name" : "atcsystem",
          "source" : [{
            "context" : "atc"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "system",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "http://www.whocc.no/atc"
            }]
          }]
        },
        {
          "name" : "atccode",
          "source" : [{
            "context" : "atc"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "code",
            "transform" : "copy",
            "parameter" : [{
              "valueId" : "atc"
            }]
          }]
        }]
      }]
    },
    {
      "name" : "medauthored",
      "source" : [{
        "context" : "src",
        "element" : "datePrescription",
        "variable" : "prescDate"
      }],
      "target" : [{
        "context" : "tgtMedReq",
        "contextType" : "variable",
        "element" : "authoredOn",
        "transform" : "copy",
        "parameter" : [{
          "valueId" : "prescDate"
        }]
      }]
    },
    {
      "name" : "medrequester",
      "source" : [{
        "context" : "src",
        "element" : "prescripteur",
        "variable" : "prescriber"
      }],
      "target" : [{
        "context" : "tgtMedReq",
        "contextType" : "variable",
        "element" : "requester",
        "variable" : "requesterRef"
      }],
      "rule" : [{
        "name" : "requesterdisplay",
        "source" : [{
          "context" : "prescriber"
        }],
        "target" : [{
          "context" : "requesterRef",
          "contextType" : "variable",
          "element" : "display",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "prescriber"
          }]
        }]
      },
      {
        "name" : "requesterType",
        "source" : [{
          "context" : "prescriber"
        }],
        "target" : [{
          "context" : "requesterRef",
          "contextType" : "variable",
          "element" : "type",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "Practitioner"
          }]
        }]
      }]
    }]
  },
  {
    "name" : "setPoso",
    "typeMode" : "none",
    "documentation" : "========================================================================\r\nPOSOLOGIE TRANSFORMATION\r\n========================================================================",
    "input" : [{
      "name" : "srcPoso",
      "mode" : "source"
    },
    {
      "name" : "srcPres",
      "mode" : "source"
    },
    {
      "name" : "tgtMedReq",
      "mode" : "target"
    }],
    "rule" : [{
      "name" : "dosageinstruction",
      "source" : [{
        "context" : "srcPres"
      }],
      "target" : [{
        "context" : "tgtMedReq",
        "contextType" : "variable",
        "element" : "dosageInstruction",
        "variable" : "dosageInstruction"
      }],
      "rule" : [{
        "name" : "dosagetext",
        "source" : [{
          "context" : "srcPoso"
        }],
        "target" : [{
          "context" : "dosageInstruction",
          "contextType" : "variable",
          "element" : "text",
          "transform" : "evaluate",
          "parameter" : [{
            "valueString" : "'Prendre' + iif(%srcPoso.quantite.exists(), ' ' + %srcPoso.quantite.toString(), '1') + iif(%srcPoso.uniteQuantite.exists(), ' ' + %srcPoso.uniteQuantite, ' comprimé') + iif(%srcPoso.nombrePrisesParJour.exists(), ' ' + %srcPoso.nombrePrisesParJour.toString() + ' fois par jour', ' selon prescription')"
          }]
        }]
      },
      {
        "name" : "dosageroute",
        "source" : [{
          "context" : "srcPres",
          "element" : "voieAdministration",
          "variable" : "route"
        }],
        "target" : [{
          "context" : "dosageInstruction",
          "contextType" : "variable",
          "element" : "route",
          "variable" : "routeCC"
        }],
        "rule" : [{
          "name" : "routecoding",
          "source" : [{
            "context" : "route"
          }],
          "target" : [{
            "context" : "routeCC",
            "contextType" : "variable",
            "element" : "coding",
            "variable" : "routeCoding"
          }],
          "rule" : [{
            "name" : "routecode",
            "source" : [{
              "context" : "route"
            }],
            "target" : [{
              "context" : "routeCoding",
              "contextType" : "variable",
              "element" : "code",
              "transform" : "copy",
              "parameter" : [{
                "valueId" : "route"
              }]
            }]
          },
          {
            "name" : "routesystem",
            "source" : [{
              "context" : "route"
            }],
            "target" : [{
              "context" : "routeCoding",
              "contextType" : "variable",
              "element" : "system",
              "transform" : "copy",
              "parameter" : [{
                "valueString" : "https://smt.esante.gouv.fr/terminologie-standardterms"
              }]
            }]
          }]
        }]
      },
      {
        "name" : "dosagetiming",
        "source" : [{
          "context" : "srcPoso"
        }],
        "target" : [{
          "context" : "dosageInstruction",
          "contextType" : "variable",
          "element" : "timing",
          "variable" : "timing"
        }],
        "rule" : [{
          "name" : "timingrepeat",
          "source" : [{
            "context" : "srcPoso"
          }],
          "target" : [{
            "context" : "timing",
            "contextType" : "variable",
            "element" : "repeat",
            "variable" : "timingRepeat"
          }],
          "rule" : [{
            "name" : "prescriptionperiod",
            "source" : [{
              "context" : "srcPres",
              "condition" : "srcPres.dateDebutPrescription.exists() or srcPres.dateFinPrescription.exists()"
            }],
            "target" : [{
              "context" : "timingRepeat",
              "contextType" : "variable",
              "element" : "bounds",
              "variable" : "medReqPeriod",
              "transform" : "create",
              "parameter" : [{
                "valueString" : "Period"
              }]
            }],
            "rule" : [{
              "name" : "periodstart",
              "source" : [{
                "context" : "srcPres",
                "element" : "dateDebutPrescription",
                "variable" : "startDate"
              }],
              "target" : [{
                "context" : "medReqPeriod",
                "contextType" : "variable",
                "element" : "start",
                "transform" : "copy",
                "parameter" : [{
                  "valueId" : "startDate"
                }]
              }]
            },
            {
              "name" : "periodend",
              "source" : [{
                "context" : "srcPres",
                "element" : "dateFinPrescription",
                "variable" : "endDate"
              }],
              "target" : [{
                "context" : "medReqPeriod",
                "contextType" : "variable",
                "element" : "end",
                "transform" : "copy",
                "parameter" : [{
                  "valueId" : "endDate"
                }]
              }]
            }]
          },
          {
            "name" : "timingfrequency",
            "source" : [{
              "context" : "srcPoso",
              "element" : "nombrePrisesParJour",
              "variable" : "frequency"
            }],
            "target" : [{
              "context" : "timingRepeat",
              "contextType" : "variable",
              "element" : "frequency",
              "transform" : "copy",
              "parameter" : [{
                "valueId" : "frequency"
              }]
            }]
          },
          {
            "name" : "timingperiod",
            "source" : [{
              "context" : "srcPoso",
              "element" : "nombrePrisesParJour",
              "variable" : "frequency"
            }],
            "target" : [{
              "context" : "timingRepeat",
              "contextType" : "variable",
              "element" : "period",
              "transform" : "copy",
              "parameter" : [{
                "valueString" : "1"
              }]
            }]
          },
          {
            "name" : "timingperiodunit",
            "source" : [{
              "context" : "srcPoso",
              "element" : "nombrePrisesParJour",
              "variable" : "frequency"
            }],
            "target" : [{
              "context" : "timingRepeat",
              "contextType" : "variable",
              "element" : "periodUnit",
              "transform" : "copy",
              "parameter" : [{
                "valueString" : "d"
              }]
            }]
          }]
        }]
      },
      {
        "name" : "doseandrate",
        "source" : [{
          "context" : "srcPoso",
          "element" : "quantite",
          "variable" : "quantity"
        }],
        "target" : [{
          "context" : "dosageInstruction",
          "contextType" : "variable",
          "element" : "doseAndRate",
          "variable" : "doseRate"
        }],
        "rule" : [{
          "name" : "dosequantity",
          "source" : [{
            "context" : "quantity"
          }],
          "target" : [{
            "context" : "doseRate",
            "contextType" : "variable",
            "element" : "dose",
            "variable" : "doseQuantity",
            "transform" : "create",
            "parameter" : [{
              "valueString" : "Quantity"
            }]
          }],
          "rule" : [{
            "name" : "dosevalue",
            "source" : [{
              "context" : "quantity"
            }],
            "target" : [{
              "context" : "doseQuantity",
              "contextType" : "variable",
              "element" : "value",
              "transform" : "copy",
              "parameter" : [{
                "valueId" : "quantity"
              }]
            }]
          },
          {
            "name" : "doseunit",
            "source" : [{
              "context" : "srcPoso",
              "element" : "uniteQuantite",
              "variable" : "unit"
            }],
            "target" : [{
              "context" : "doseQuantity",
              "contextType" : "variable",
              "element" : "unit",
              "transform" : "copy",
              "parameter" : [{
                "valueId" : "unit"
              }]
            }]
          },
          {
            "name" : "dosecode",
            "source" : [{
              "context" : "srcPoso",
              "element" : "uniteQuantite",
              "variable" : "unit"
            }],
            "target" : [{
              "context" : "doseQuantity",
              "contextType" : "variable",
              "element" : "code",
              "transform" : "copy",
              "parameter" : [{
                "valueId" : "unit"
              }]
            }]
          },
          {
            "name" : "dosesystem",
            "source" : [{
              "context" : "srcPoso"
            }],
            "target" : [{
              "context" : "doseQuantity",
              "contextType" : "variable",
              "element" : "system",
              "transform" : "copy",
              "parameter" : [{
                "valueString" : "http://unitsofmeasure.org"
              }]
            }]
          }]
        }]
      }]
    }]
  },
  {
    "name" : "TransformVitalSigns",
    "typeMode" : "none",
    "documentation" : "========================================================================\r\nVITAL SIGNS TRANSFORMATION\r\n========================================================================",
    "input" : [{
      "name" : "src",
      "mode" : "source"
    },
    {
      "name" : "tgtObs",
      "type" : "Observation",
      "mode" : "target"
    },
    {
      "name" : "patient",
      "mode" : "source"
    }],
    "rule" : [{
      "name" : "setId",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "id",
        "transform" : "uuid"
      }]
    },
    {
      "name" : "medrequestidentifier",
      "source" : [{
        "context" : "src",
        "element" : "soinId",
        "variable" : "soinId"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "identifier",
        "variable" : "identifier"
      }],
      "rule" : [{
        "name" : "soinidsystem",
        "source" : [{
          "context" : "soinId"
        }],
        "target" : [{
          "context" : "identifier",
          "contextType" : "variable",
          "element" : "system",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "https://hospital.eu/ehr/soin-id"
          }]
        }]
      },
      {
        "name" : "soinidvalue",
        "source" : [{
          "context" : "soinId"
        }],
        "target" : [{
          "context" : "identifier",
          "contextType" : "variable",
          "element" : "value",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "soinId"
          }]
        }]
      }]
    },
    {
      "name" : "status",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "status",
        "transform" : "copy",
        "parameter" : [{
          "valueString" : "final"
        }]
      }]
    },
    {
      "name" : "category",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "category",
        "variable" : "category"
      }],
      "rule" : [{
        "name" : "categorycoding",
        "source" : [{
          "context" : "src"
        }],
        "target" : [{
          "context" : "category",
          "contextType" : "variable",
          "element" : "coding",
          "variable" : "coding"
        }],
        "rule" : [{
          "name" : "categorysystem",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "system",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "http://terminology.hl7.org/CodeSystem/observation-category"
            }]
          }]
        },
        {
          "name" : "categorycode",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "code",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "vital-signs"
            }]
          }]
        }]
      }]
    },
    {
      "name" : "code",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "code",
        "variable" : "code"
      }],
      "rule" : [{
        "name" : "coding",
        "source" : [{
          "context" : "src"
        }],
        "target" : [{
          "context" : "code",
          "contextType" : "variable",
          "element" : "coding",
          "variable" : "coding"
        }],
        "rule" : [{
          "name" : "codesystem",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "system",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "http://loinc.org"
            }]
          }]
        },
        {
          "name" : "codevalue",
          "source" : [{
            "context" : "src",
            "element" : "codeLoinc",
            "variable" : "codeLoinc"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "code",
            "transform" : "copy",
            "parameter" : [{
              "valueId" : "codeLoinc"
            }]
          }]
        }]
      },
      {
        "name" : "codetext",
        "source" : [{
          "context" : "src",
          "element" : "libelleTest",
          "variable" : "label"
        }],
        "target" : [{
          "context" : "code",
          "contextType" : "variable",
          "element" : "text",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "label"
          }]
        }]
      }]
    },
    {
      "name" : "obssubject",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "subject",
        "variable" : "ref",
        "transform" : "create",
        "parameter" : [{
          "valueString" : "Reference"
        }]
      }],
      "rule" : [{
        "name" : "subjectref",
        "source" : [{
          "context" : "patient",
          "element" : "id",
          "variable" : "patientId"
        }],
        "target" : [{
          "context" : "ref",
          "contextType" : "variable",
          "element" : "reference",
          "transform" : "evaluate",
          "parameter" : [{
            "valueString" : "'Patient/' + %patientId"
          }]
        },
        {
          "context" : "ref",
          "contextType" : "variable",
          "element" : "type",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "Patient"
          }]
        }]
      }]
    },
    {
      "name" : "effective",
      "source" : [{
        "context" : "src",
        "element" : "dateMesure",
        "variable" : "date",
        "condition" : "%date.exists()"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "effective",
        "transform" : "cast",
        "parameter" : [{
          "valueId" : "date"
        },
        {
          "valueString" : "dateTime"
        }]
      }]
    },
    {
      "name" : "quantity",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "value",
        "variable" : "qty",
        "transform" : "create",
        "parameter" : [{
          "valueString" : "Quantity"
        }]
      }],
      "rule" : [{
        "name" : "value",
        "source" : [{
          "context" : "src",
          "element" : "valeur",
          "variable" : "mesure"
        }],
        "target" : [{
          "context" : "qty",
          "contextType" : "variable",
          "element" : "value",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "mesure"
          }]
        }]
      },
      {
        "name" : "unit",
        "source" : [{
          "context" : "src",
          "element" : "unite",
          "variable" : "unit"
        }],
        "target" : [{
          "context" : "qty",
          "contextType" : "variable",
          "element" : "unit",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "unit"
          }]
        }]
      },
      {
        "name" : "code",
        "source" : [{
          "context" : "src",
          "element" : "unite",
          "variable" : "unit"
        }],
        "target" : [{
          "context" : "qty",
          "contextType" : "variable",
          "element" : "code",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "unit"
          }]
        }]
      },
      {
        "name" : "system",
        "source" : [{
          "context" : "src"
        }],
        "target" : [{
          "context" : "qty",
          "contextType" : "variable",
          "element" : "system",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "http://unitsofmeasure.org"
          }]
        }]
      }]
    }]
  },
  {
    "name" : "TransformTobaccoObservation",
    "typeMode" : "none",
    "documentation" : "========================================================================\r\nLIFESTYLE TRANSFORMATION - SEPARATE OBSERVATIONS\r\n========================================================================",
    "input" : [{
      "name" : "src",
      "mode" : "source"
    },
    {
      "name" : "tgtObs",
      "type" : "Observation",
      "mode" : "target"
    },
    {
      "name" : "patient",
      "mode" : "source"
    }],
    "rule" : [{
      "name" : "setId",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "id",
        "transform" : "uuid"
      }]
    },
    {
      "name" : "lifestyleidentifier",
      "source" : [{
        "context" : "src",
        "element" : "styleVieId",
        "variable" : "lsId"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "identifier",
        "variable" : "identifier"
      }],
      "rule" : [{
        "name" : "lifestyleidsystem",
        "source" : [{
          "context" : "lsId"
        }],
        "target" : [{
          "context" : "identifier",
          "contextType" : "variable",
          "element" : "system",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "https://hospital.eu/ehr/lifestyle-id"
          }]
        }]
      },
      {
        "name" : "lifestyleidvalue",
        "source" : [{
          "context" : "lsId"
        }],
        "target" : [{
          "context" : "identifier",
          "contextType" : "variable",
          "element" : "value",
          "transform" : "evaluate",
          "parameter" : [{
            "valueString" : "%lsId & '-tobacco'"
          }]
        }]
      }]
    },
    {
      "name" : "lifestylestatus",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "status",
        "transform" : "copy",
        "parameter" : [{
          "valueString" : "final"
        }]
      }]
    },
    {
      "name" : "lifestylecategory",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "category",
        "variable" : "category"
      }],
      "rule" : [{
        "name" : "categorycoding",
        "source" : [{
          "context" : "src"
        }],
        "target" : [{
          "context" : "category",
          "contextType" : "variable",
          "element" : "coding",
          "variable" : "coding"
        }],
        "rule" : [{
          "name" : "categorysystem",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "system",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "http://terminology.hl7.org/CodeSystem/observation-category"
            }]
          }]
        },
        {
          "name" : "categorycode",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "code",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "social-history"
            }]
          }]
        },
        {
          "name" : "categorydisplay",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "display",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "Social History"
            }]
          }]
        }]
      }]
    },
    {
      "name" : "tobaccocode",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "code",
        "variable" : "code"
      }],
      "rule" : [{
        "name" : "tobaccocoding",
        "source" : [{
          "context" : "src"
        }],
        "target" : [{
          "context" : "code",
          "contextType" : "variable",
          "element" : "coding",
          "variable" : "coding"
        }],
        "rule" : [{
          "name" : "codesystem",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "system",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "http://loinc.org"
            }]
          }]
        },
        {
          "name" : "codevalue",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "code",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "72166-2"
            }]
          }]
        },
        {
          "name" : "codedisplay",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "display",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "Tobacco smoking status"
            }]
          }]
        }]
      }]
    },
    {
      "name" : "lifestylesubject",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "subject",
        "variable" : "ref",
        "transform" : "create",
        "parameter" : [{
          "valueString" : "Reference"
        }]
      }],
      "rule" : [{
        "name" : "subjectref",
        "source" : [{
          "context" : "patient",
          "element" : "id",
          "variable" : "patientId"
        }],
        "target" : [{
          "context" : "ref",
          "contextType" : "variable",
          "element" : "reference",
          "transform" : "evaluate",
          "parameter" : [{
            "valueString" : "'Patient/' + %patientId"
          }]
        },
        {
          "context" : "ref",
          "contextType" : "variable",
          "element" : "type",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "Patient"
          }]
        }]
      }]
    },
    {
      "name" : "lifestyleeffective",
      "source" : [{
        "context" : "src",
        "element" : "dateRecueil",
        "variable" : "collectDate",
        "condition" : "%collectDate.exists()"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "effective",
        "transform" : "cast",
        "parameter" : [{
          "valueId" : "collectDate"
        },
        {
          "valueString" : "dateTime"
        }]
      }]
    },
    {
      "name" : "tobaccovalue",
      "source" : [{
        "context" : "src",
        "element" : "consommationTabac",
        "variable" : "tobacco"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "value",
        "variable" : "valueCC",
        "transform" : "create",
        "parameter" : [{
          "valueString" : "CodeableConcept"
        }]
      }],
      "rule" : [{
        "name" : "tobaccovaluetext",
        "source" : [{
          "context" : "tobacco"
        }],
        "target" : [{
          "context" : "valueCC",
          "contextType" : "variable",
          "element" : "text",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "tobacco"
          }]
        }]
      }]
    }]
  },
  {
    "name" : "TransformAlcoholObservation",
    "typeMode" : "none",
    "input" : [{
      "name" : "src",
      "mode" : "source"
    },
    {
      "name" : "tgtObs",
      "type" : "Observation",
      "mode" : "target"
    },
    {
      "name" : "patient",
      "mode" : "source"
    }],
    "rule" : [{
      "name" : "setId",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "id",
        "transform" : "uuid"
      }]
    },
    {
      "name" : "lifestyleidentifier",
      "source" : [{
        "context" : "src",
        "element" : "styleVieId",
        "variable" : "lsId"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "identifier",
        "variable" : "identifier"
      }],
      "rule" : [{
        "name" : "lifestyleidsystem",
        "source" : [{
          "context" : "lsId"
        }],
        "target" : [{
          "context" : "identifier",
          "contextType" : "variable",
          "element" : "system",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "https://hospital.eu/ehr/lifestyle-id"
          }]
        }]
      },
      {
        "name" : "lifestyleidvalue",
        "source" : [{
          "context" : "lsId"
        }],
        "target" : [{
          "context" : "identifier",
          "contextType" : "variable",
          "element" : "value",
          "transform" : "evaluate",
          "parameter" : [{
            "valueString" : "%lsId & '-alcohol'"
          }]
        }]
      }]
    },
    {
      "name" : "lifestylestatus",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "status",
        "transform" : "copy",
        "parameter" : [{
          "valueString" : "final"
        }]
      }]
    },
    {
      "name" : "lifestylecategory",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "category",
        "variable" : "category"
      }],
      "rule" : [{
        "name" : "categorycoding",
        "source" : [{
          "context" : "src"
        }],
        "target" : [{
          "context" : "category",
          "contextType" : "variable",
          "element" : "coding",
          "variable" : "coding"
        }],
        "rule" : [{
          "name" : "categorysystem",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "system",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "http://terminology.hl7.org/CodeSystem/observation-category"
            }]
          }]
        },
        {
          "name" : "categorycode",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "code",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "social-history"
            }]
          }]
        },
        {
          "name" : "categorydisplay",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "display",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "Social History"
            }]
          }]
        }]
      }]
    },
    {
      "name" : "alcoholcode",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "code",
        "variable" : "code"
      }],
      "rule" : [{
        "name" : "alcoholcoding",
        "source" : [{
          "context" : "src"
        }],
        "target" : [{
          "context" : "code",
          "contextType" : "variable",
          "element" : "coding",
          "variable" : "coding"
        }],
        "rule" : [{
          "name" : "codesystem",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "system",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "http://loinc.org"
            }]
          }]
        },
        {
          "name" : "codevalue",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "code",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "11331-6"
            }]
          }]
        },
        {
          "name" : "codedisplay",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "display",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "History of alcohol use"
            }]
          }]
        }]
      }]
    },
    {
      "name" : "lifestylesubject",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "subject",
        "variable" : "ref",
        "transform" : "create",
        "parameter" : [{
          "valueString" : "Reference"
        }]
      }],
      "rule" : [{
        "name" : "subjectref",
        "source" : [{
          "context" : "patient",
          "element" : "id",
          "variable" : "patientId"
        }],
        "target" : [{
          "context" : "ref",
          "contextType" : "variable",
          "element" : "reference",
          "transform" : "evaluate",
          "parameter" : [{
            "valueString" : "'Patient/' + %patientId"
          }]
        },
        {
          "context" : "ref",
          "contextType" : "variable",
          "element" : "type",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "Patient"
          }]
        }]
      }]
    },
    {
      "name" : "lifestyleeffective",
      "source" : [{
        "context" : "src",
        "element" : "dateRecueil",
        "variable" : "collectDate",
        "condition" : "%collectDate.exists()"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "effective",
        "transform" : "cast",
        "parameter" : [{
          "valueId" : "collectDate"
        },
        {
          "valueString" : "dateTime"
        }]
      }]
    },
    {
      "name" : "alcoholvalue",
      "source" : [{
        "context" : "src",
        "element" : "consommationAlcool",
        "variable" : "alcohol"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "value",
        "variable" : "valueCC",
        "transform" : "create",
        "parameter" : [{
          "valueString" : "CodeableConcept"
        }]
      }],
      "rule" : [{
        "name" : "alcoholvaluetext",
        "source" : [{
          "context" : "alcohol"
        }],
        "target" : [{
          "context" : "valueCC",
          "contextType" : "variable",
          "element" : "text",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "alcohol"
          }]
        }]
      }]
    }]
  },
  {
    "name" : "TransformDrugObservation",
    "typeMode" : "none",
    "input" : [{
      "name" : "src",
      "mode" : "source"
    },
    {
      "name" : "tgtObs",
      "type" : "Observation",
      "mode" : "target"
    },
    {
      "name" : "patient",
      "mode" : "source"
    }],
    "rule" : [{
      "name" : "setId",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "id",
        "transform" : "uuid"
      }]
    },
    {
      "name" : "lifestyleidentifier",
      "source" : [{
        "context" : "src",
        "element" : "styleVieId",
        "variable" : "lsId"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "identifier",
        "variable" : "identifier"
      }],
      "rule" : [{
        "name" : "lifestyleidsystem",
        "source" : [{
          "context" : "lsId"
        }],
        "target" : [{
          "context" : "identifier",
          "contextType" : "variable",
          "element" : "system",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "https://hospital.eu/ehr/lifestyle-id"
          }]
        }]
      },
      {
        "name" : "lifestyleidvalue",
        "source" : [{
          "context" : "lsId"
        }],
        "target" : [{
          "context" : "identifier",
          "contextType" : "variable",
          "element" : "value",
          "transform" : "evaluate",
          "parameter" : [{
            "valueString" : "%lsId & '-drugs'"
          }]
        }]
      }]
    },
    {
      "name" : "lifestylestatus",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "status",
        "transform" : "copy",
        "parameter" : [{
          "valueString" : "final"
        }]
      }]
    },
    {
      "name" : "lifestylecategory",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "category",
        "variable" : "category"
      }],
      "rule" : [{
        "name" : "categorycoding",
        "source" : [{
          "context" : "src"
        }],
        "target" : [{
          "context" : "category",
          "contextType" : "variable",
          "element" : "coding",
          "variable" : "coding"
        }],
        "rule" : [{
          "name" : "categorysystem",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "system",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "http://terminology.hl7.org/CodeSystem/observation-category"
            }]
          }]
        },
        {
          "name" : "categorycode",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "code",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "social-history"
            }]
          }]
        },
        {
          "name" : "categorydisplay",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "display",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "Social History"
            }]
          }]
        }]
      }]
    },
    {
      "name" : "drugcode",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "code",
        "variable" : "code"
      }],
      "rule" : [{
        "name" : "drugcoding",
        "source" : [{
          "context" : "src"
        }],
        "target" : [{
          "context" : "code",
          "contextType" : "variable",
          "element" : "coding",
          "variable" : "coding"
        }],
        "rule" : [{
          "name" : "codesystem",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "system",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "http://loinc.org"
            }]
          }]
        },
        {
          "name" : "codevalue",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "code",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "11342-3"
            }]
          }]
        },
        {
          "name" : "codedisplay",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "display",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "History of drug use"
            }]
          }]
        }]
      }]
    },
    {
      "name" : "lifestylesubject",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "subject",
        "variable" : "ref",
        "transform" : "create",
        "parameter" : [{
          "valueString" : "Reference"
        }]
      }],
      "rule" : [{
        "name" : "subjectref",
        "source" : [{
          "context" : "patient",
          "element" : "id",
          "variable" : "patientId"
        }],
        "target" : [{
          "context" : "ref",
          "contextType" : "variable",
          "element" : "reference",
          "transform" : "evaluate",
          "parameter" : [{
            "valueString" : "'Patient/' + %patientId"
          }]
        },
        {
          "context" : "ref",
          "contextType" : "variable",
          "element" : "type",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "Patient"
          }]
        }]
      }]
    },
    {
      "name" : "lifestyleeffective",
      "source" : [{
        "context" : "src",
        "element" : "dateRecueil",
        "variable" : "collectDate",
        "condition" : "%collectDate.exists()"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "effective",
        "transform" : "cast",
        "parameter" : [{
          "valueId" : "collectDate"
        },
        {
          "valueString" : "dateTime"
        }]
      }]
    },
    {
      "name" : "drugvalue",
      "source" : [{
        "context" : "src",
        "element" : "consommationAutresDrogues",
        "variable" : "drugs"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "value",
        "variable" : "valueCC",
        "transform" : "create",
        "parameter" : [{
          "valueString" : "CodeableConcept"
        }]
      }],
      "rule" : [{
        "name" : "drugvaluetext",
        "source" : [{
          "context" : "drugs"
        }],
        "target" : [{
          "context" : "valueCC",
          "contextType" : "variable",
          "element" : "text",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "drugs"
          }]
        }]
      }]
    }]
  },
  {
    "name" : "TransformPhysicalActivityObservation",
    "typeMode" : "none",
    "input" : [{
      "name" : "src",
      "mode" : "source"
    },
    {
      "name" : "tgtObs",
      "type" : "Observation",
      "mode" : "target"
    },
    {
      "name" : "patient",
      "mode" : "source"
    }],
    "rule" : [{
      "name" : "setId",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "id",
        "transform" : "uuid"
      }]
    },
    {
      "name" : "lifestyleidentifier",
      "source" : [{
        "context" : "src",
        "element" : "styleVieId",
        "variable" : "lsId"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "identifier",
        "variable" : "identifier"
      }],
      "rule" : [{
        "name" : "lifestyleidsystem",
        "source" : [{
          "context" : "lsId"
        }],
        "target" : [{
          "context" : "identifier",
          "contextType" : "variable",
          "element" : "system",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "https://hospital.eu/ehr/lifestyle-id"
          }]
        }]
      },
      {
        "name" : "lifestyleidvalue",
        "source" : [{
          "context" : "lsId"
        }],
        "target" : [{
          "context" : "identifier",
          "contextType" : "variable",
          "element" : "value",
          "transform" : "evaluate",
          "parameter" : [{
            "valueString" : "%lsId & '-physical'"
          }]
        }]
      }]
    },
    {
      "name" : "lifestylestatus",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "status",
        "transform" : "copy",
        "parameter" : [{
          "valueString" : "final"
        }]
      }]
    },
    {
      "name" : "lifestylecategory",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "category",
        "variable" : "category"
      }],
      "rule" : [{
        "name" : "categorycoding",
        "source" : [{
          "context" : "src"
        }],
        "target" : [{
          "context" : "category",
          "contextType" : "variable",
          "element" : "coding",
          "variable" : "coding"
        }],
        "rule" : [{
          "name" : "categorysystem",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "system",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "http://terminology.hl7.org/CodeSystem/observation-category"
            }]
          }]
        },
        {
          "name" : "categorycode",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "code",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "social-history"
            }]
          }]
        },
        {
          "name" : "categorydisplay",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "display",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "Social History"
            }]
          }]
        }]
      }]
    },
    {
      "name" : "physicalcode",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "code",
        "variable" : "code"
      }],
      "rule" : [{
        "name" : "physicalcoding",
        "source" : [{
          "context" : "src"
        }],
        "target" : [{
          "context" : "code",
          "contextType" : "variable",
          "element" : "coding",
          "variable" : "coding"
        }],
        "rule" : [{
          "name" : "codesystem",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "system",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "http://loinc.org"
            }]
          }]
        },
        {
          "name" : "codevalue",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "code",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "67504-6"
            }]
          }]
        },
        {
          "name" : "codedisplay",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "display",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "Exercise activity"
            }]
          }]
        }]
      }]
    },
    {
      "name" : "lifestylesubject",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "subject",
        "variable" : "ref",
        "transform" : "create",
        "parameter" : [{
          "valueString" : "Reference"
        }]
      }],
      "rule" : [{
        "name" : "subjectref",
        "source" : [{
          "context" : "patient",
          "element" : "id",
          "variable" : "patientId"
        }],
        "target" : [{
          "context" : "ref",
          "contextType" : "variable",
          "element" : "reference",
          "transform" : "evaluate",
          "parameter" : [{
            "valueString" : "'Patient/' + %patientId"
          }]
        },
        {
          "context" : "ref",
          "contextType" : "variable",
          "element" : "type",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "Patient"
          }]
        }]
      }]
    },
    {
      "name" : "lifestyleeffective",
      "source" : [{
        "context" : "src",
        "element" : "dateRecueil",
        "variable" : "collectDate",
        "condition" : "%collectDate.exists()"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "effective",
        "transform" : "cast",
        "parameter" : [{
          "valueId" : "collectDate"
        },
        {
          "valueString" : "dateTime"
        }]
      }]
    },
    {
      "name" : "physicalvalue",
      "source" : [{
        "context" : "src",
        "element" : "activitePhysique",
        "variable" : "physical"
      }],
      "target" : [{
        "context" : "tgtObs",
        "contextType" : "variable",
        "element" : "value",
        "variable" : "valueCC",
        "transform" : "create",
        "parameter" : [{
          "valueString" : "CodeableConcept"
        }]
      }],
      "rule" : [{
        "name" : "physicalvaluetext",
        "source" : [{
          "context" : "physical"
        }],
        "target" : [{
          "context" : "valueCC",
          "contextType" : "variable",
          "element" : "text",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "physical"
          }]
        }]
      }]
    }]
  },
  {
    "name" : "TransformMedicationAdministrationWOOrder",
    "typeMode" : "none",
    "documentation" : "========================================================================\r\nMEDICATION ADMINISTRATION TRANSFORMATION\r\n========================================================================",
    "input" : [{
      "name" : "src",
      "mode" : "source"
    },
    {
      "name" : "tgtMedAdmin",
      "type" : "MedicationAdministration",
      "mode" : "target"
    },
    {
      "name" : "patient",
      "mode" : "source"
    }],
    "rule" : [{
      "name" : "setId",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtMedAdmin",
        "contextType" : "variable",
        "element" : "id",
        "transform" : "uuid"
      }]
    },
    {
      "name" : "adminidentifier",
      "source" : [{
        "context" : "src",
        "element" : "administrationId",
        "variable" : "adminId"
      }],
      "target" : [{
        "context" : "tgtMedAdmin",
        "contextType" : "variable",
        "element" : "identifier",
        "variable" : "identifier"
      }],
      "rule" : [{
        "name" : "adminidsystem",
        "source" : [{
          "context" : "adminId"
        }],
        "target" : [{
          "context" : "identifier",
          "contextType" : "variable",
          "element" : "system",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "https://hospital.eu/ehr/administration-id"
          }]
        }]
      },
      {
        "name" : "adminidvalue",
        "source" : [{
          "context" : "adminId"
        }],
        "target" : [{
          "context" : "identifier",
          "contextType" : "variable",
          "element" : "value",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "adminId"
          }]
        }]
      }]
    },
    {
      "name" : "adminstatus",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtMedAdmin",
        "contextType" : "variable",
        "element" : "status",
        "transform" : "copy",
        "parameter" : [{
          "valueString" : "completed"
        }]
      }]
    },
    {
      "name" : "adminsubject",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtMedAdmin",
        "contextType" : "variable",
        "element" : "subject",
        "variable" : "ref",
        "transform" : "create",
        "parameter" : [{
          "valueString" : "Reference"
        }]
      }],
      "rule" : [{
        "name" : "subjectref",
        "source" : [{
          "context" : "patient",
          "element" : "id",
          "variable" : "patientId"
        }],
        "target" : [{
          "context" : "ref",
          "contextType" : "variable",
          "element" : "reference",
          "transform" : "evaluate",
          "parameter" : [{
            "valueString" : "'Patient/' + %patientId"
          }]
        },
        {
          "context" : "ref",
          "contextType" : "variable",
          "element" : "type",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "Patient"
          }]
        }]
      }]
    },
    {
      "name" : "adminmedication",
      "source" : [{
        "context" : "src",
        "element" : "denomination",
        "variable" : "denomination"
      }],
      "target" : [{
        "context" : "tgtMedAdmin",
        "contextType" : "variable",
        "element" : "medication",
        "variable" : "medication",
        "transform" : "create",
        "parameter" : [{
          "valueString" : "CodeableConcept"
        }]
      }],
      "rule" : [{
        "name" : "medicationtext",
        "source" : [{
          "context" : "denomination"
        }],
        "target" : [{
          "context" : "medication",
          "contextType" : "variable",
          "element" : "text",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "denomination"
          }]
        }]
      },
      {
        "name" : "atccoding",
        "source" : [{
          "context" : "src",
          "element" : "codeAtc",
          "variable" : "atc"
        }],
        "target" : [{
          "context" : "medication",
          "contextType" : "variable",
          "element" : "coding",
          "variable" : "coding"
        }],
        "rule" : [{
          "name" : "atcsystem",
          "source" : [{
            "context" : "atc"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "system",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "http://www.whocc.no/atc"
            }]
          }]
        },
        {
          "name" : "atccode",
          "source" : [{
            "context" : "atc"
          }],
          "target" : [{
            "context" : "coding",
            "contextType" : "variable",
            "element" : "code",
            "transform" : "copy",
            "parameter" : [{
              "valueId" : "atc"
            }]
          }]
        }]
      }]
    },
    {
      "name" : "admineffective",
      "source" : [{
        "context" : "src",
        "condition" : "src.dateHeureDebut.exists() or src.dateHeureFin.exists()"
      }],
      "target" : [{
        "context" : "tgtMedAdmin",
        "contextType" : "variable",
        "element" : "effective",
        "variable" : "period",
        "transform" : "create",
        "parameter" : [{
          "valueString" : "Period"
        }]
      }],
      "rule" : [{
        "name" : "periodstart",
        "source" : [{
          "context" : "src",
          "element" : "dateHeureDebut",
          "variable" : "startDate"
        }],
        "target" : [{
          "context" : "period",
          "contextType" : "variable",
          "element" : "start",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "startDate"
          }]
        }]
      },
      {
        "name" : "periodend",
        "source" : [{
          "context" : "src",
          "element" : "dateHeureFin",
          "variable" : "endDate"
        }],
        "target" : [{
          "context" : "period",
          "contextType" : "variable",
          "element" : "end",
          "transform" : "copy",
          "parameter" : [{
            "valueId" : "endDate"
          }]
        }]
      }]
    },
    {
      "name" : "admindosage",
      "source" : [{
        "context" : "src",
        "condition" : "src.quantite.exists() or src.voieAdministration.exists()"
      }],
      "target" : [{
        "context" : "tgtMedAdmin",
        "contextType" : "variable",
        "element" : "dosage",
        "variable" : "dosage"
      }],
      "rule" : [{
        "name" : "admindose",
        "source" : [{
          "context" : "src",
          "element" : "quantite",
          "variable" : "quantity"
        }],
        "target" : [{
          "context" : "dosage",
          "contextType" : "variable",
          "element" : "dose",
          "variable" : "dose",
          "transform" : "create",
          "parameter" : [{
            "valueString" : "Quantity"
          }]
        }],
        "rule" : [{
          "name" : "dosevalue",
          "source" : [{
            "context" : "quantity"
          }],
          "target" : [{
            "context" : "dose",
            "contextType" : "variable",
            "element" : "value",
            "transform" : "copy",
            "parameter" : [{
              "valueId" : "quantity"
            }]
          }]
        },
        {
          "name" : "doseunit",
          "source" : [{
            "context" : "src",
            "element" : "uniteQuantite",
            "variable" : "unit"
          }],
          "target" : [{
            "context" : "dose",
            "contextType" : "variable",
            "element" : "unit",
            "transform" : "copy",
            "parameter" : [{
              "valueId" : "unit"
            }]
          }]
        }]
      },
      {
        "name" : "dosageroute",
        "source" : [{
          "context" : "src",
          "element" : "voieAdministration",
          "variable" : "route"
        }],
        "target" : [{
          "context" : "dosage",
          "contextType" : "variable",
          "element" : "route",
          "variable" : "routeCC"
        }],
        "rule" : [{
          "name" : "routecoding",
          "source" : [{
            "context" : "route"
          }],
          "target" : [{
            "context" : "routeCC",
            "contextType" : "variable",
            "element" : "coding",
            "variable" : "routeCoding"
          }],
          "rule" : [{
            "name" : "routecode",
            "source" : [{
              "context" : "route"
            }],
            "target" : [{
              "context" : "routeCoding",
              "contextType" : "variable",
              "element" : "code",
              "transform" : "copy",
              "parameter" : [{
                "valueId" : "route"
              }]
            }]
          },
          {
            "name" : "routesystem",
            "source" : [{
              "context" : "route"
            }],
            "target" : [{
              "context" : "routeCoding",
              "contextType" : "variable",
              "element" : "system",
              "transform" : "copy",
              "parameter" : [{
                "valueString" : "https://smt.esante.gouv.fr/terminologie-standardterms"
              }]
            }]
          }]
        }]
      }]
    }]
  },
  {
    "name" : "TransformMedicationAdministrationWOrder",
    "extends" : "TransformMedicationAdministrationWOOrder",
    "typeMode" : "none",
    "input" : [{
      "name" : "src",
      "mode" : "source"
    },
    {
      "name" : "tgtMedAdmin",
      "type" : "MedicationAdministration",
      "mode" : "target"
    },
    {
      "name" : "patient",
      "mode" : "source"
    },
    {
      "name" : "order",
      "mode" : "source"
    }],
    "rule" : [{
      "name" : "admincontext",
      "source" : [{
        "context" : "src"
      }],
      "target" : [{
        "context" : "tgtMedAdmin",
        "contextType" : "variable",
        "element" : "request",
        "variable" : "ref",
        "transform" : "create",
        "parameter" : [{
          "valueString" : "Reference"
        }]
      }],
      "rule" : [{
        "name" : "encounterref",
        "source" : [{
          "context" : "order",
          "element" : "id",
          "variable" : "orderId"
        }],
        "target" : [{
          "context" : "ref",
          "contextType" : "variable",
          "element" : "reference",
          "transform" : "evaluate",
          "parameter" : [{
            "valueString" : "'MedicationRequest/' + %orderId"
          }]
        },
        {
          "context" : "ref",
          "contextType" : "variable",
          "element" : "type",
          "transform" : "copy",
          "parameter" : [{
            "valueString" : "MedicationRequest"
          }]
        }]
      }]
    }]
  },
  {
    "name" : "setEntryRequestAndFullUrl",
    "typeMode" : "none",
    "input" : [{
      "name" : "newRes",
      "mode" : "source"
    },
    {
      "name" : "tgtEntry",
      "mode" : "target"
    }],
    "rule" : [{
      "name" : "setResourceType",
      "source" : [{
        "context" : "newRes",
        "element" : "id",
        "variable" : "newResId"
      }],
      "rule" : [{
        "name" : "setFullUrl",
        "source" : [{
          "context" : "newResId"
        }],
        "target" : [{
          "context" : "tgtEntry",
          "contextType" : "variable",
          "element" : "fullUrl",
          "transform" : "evaluate",
          "parameter" : [{
            "valueString" : "'urn:ehr:' + %newRes.type().name + '/' + %newResId"
          }]
        }]
      }]
    }]
  }]
}

```
