# Transforms QuestionnaireResponse based on Questionnaire Usage Variables socles into FHIR resources conforming to DM profiles - Data Management with FHIR v0.1.0

* [**Table of Contents**](toc.md)
* [**Artifacts Summary**](artifacts.md)
* **Transforms QuestionnaireResponse based on Questionnaire Usage Variables socles into FHIR resources conforming to DM profiles**

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

| | |
| :--- | :--- |
| *Official URL*:https://interop.aphp.fr/ig/fhir/dm/StructureMap/Q2FSL | *Version*:0.1.0 |
| Draft as of 2025-10-23 | *Computable Name*:Q2FSL |

 
Transforms QuestionnaireResponse based on Questionnaire Usage Variables socles into FHIR resources conforming to DM profiles 

```

map "https://interop.aphp.fr/ig/fhir/dm/StructureMap/Q2FSL" = "Q2FSL"

// Transforms QuestionnaireResponse based on Questionnaire Usage Variables socles into FHIR resources conforming to DM profiles

uses "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse" alias QuestionnaireResponse as source
uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias Bundle as target

// Main entry point: Transform QuestionnaireResponse to Bundle
group QuestionnaireResponseToBundle(source src : QuestionnaireResponse, target bundle : Bundle) {
  // Initialize Bundle
  src -> bundle.id = uuid() "bundleid";
  src -> bundle.type = 'collection' "bundletype";
  src -> bundle.timestamp = (now()) "setTimestamp";
  // Create Patient resource
  src -> bundle.entry as patientEntry then {
    src -> patientEntry.resource = create('Patient') as patient then {
      src then CreatePatient(src, patient) "createpatient";
      src ->  patient.id as patientId,  patientEntry.fullUrl = append('urn:uuid:', patientId) "setfullUrl";
      // Create Locations from geocoding data
      // src then CreateLocations(src, patient, bundle) "create-locations";
      // Create Encounters from PMSI data
      src then CreateEncounters(src, patient, bundle) "createencounters";
      // Create Laboratory Observations
      src then CreateLaboratoryObservations(src, patient, bundle) "createlabobservations";
      // Create Medication Requests
      src then CreateMedicationRequests(src, patient, bundle) "createmedicationrequests";
      // Create Medication Administrations
      src then CreateMedicationAdministrations(src, patient, bundle) "createmedicationadministrations";
      // Create Vital Sign Observations
      src then CreateVitalSignObservations(src, patient, bundle) "createvitalsigns";
    } "createpatientresource";
  } "patiententry";
}

// Group: Create Patient from QuestionnaireResponse
group CreatePatient(source src : QuestionnaireResponse, target patient : Patient) {
  src -> patient.id = uuid() "patientid";
  src -> patient.meta = create('Meta') as meta then {
    src -> meta.profile = 'https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMPatient' "patientprofile";
  } "patientmeta";
  // Extract patient identity data from linkId 4647259356106 > 2958000860428
  src.item as socioDemo where (linkId = '4647259356106') then {
    socioDemo.item as identity where (linkId = '2958000860428') then {
      // Patient name (linkId 8605698058770 = family, 6214879623503 = given)
      identity -> patient.name = create('HumanName') as name then {
        identity.item as familyItem where (linkId = '8605698058770') then {
          familyItem.answer as ans -> name.family = (ans.valueString) "setfamily";
        } "extractfamily";
        identity.item as givenItem where (linkId = '6214879623503') then {
          givenItem.answer as ans -> name.given = (ans.valueString) "setgiven";
        } "extractgiven";
      } "setname";
      // NIR identifier (linkId 5711960356160)
      identity.item as nirItem where (linkId = '5711960356160') then {
        nirItem.answer as ans -> patient.identifier = create('Identifier') as nir then {
          ans -> nir.system = 'urn:oid:1.2.250.1.213.1.4.8' "nirsystem";
          ans -> nir.value = (ans.valueString) "nirvalue";
          ans -> nir.type = cc('http://interopsante.org/fhir/CodeSystem/fr-v2-0203', 'NIR') "nirtype";
        } "setnir";
      } "extractnir";
      // INS identifier (linkId 3764723550987)
      identity.item as insItem where (linkId = '3764723550987') then {
        insItem.answer as ans -> patient.identifier = create('Identifier') as ins then {
          ans -> ins.system = 'urn:oid:1.2.250.1.213.1.4.10' "inssystem";
          ans -> ins.value = (ans.valueString) "insvalue";
          ans -> ins.type = cc('http://interopsante.org/fhir/CodeSystem/fr-v2-0203', 'INS-C') "instype";
        } "setins";
      } "extractins";
      // Birth date (linkId 5036133558154)
      identity.item as birthItem where (linkId = '5036133558154') then {
        birthItem.answer as ans -> patient.birthDate = (ans.valueDate) "setbirthdate";
      } "extractbirthdate";
      // Death date (linkId 5633552097315)
      identity.item as deathItem where (linkId = '5633552097315') then {
        deathItem.answer as ans -> patient.deceased = (ans.valueDate) "setdeceaseddate";
        // Death source (linkId 9098810065693)
        deathItem.item as deathSource where (linkId = '9098810065693') then {
          deathSource.answer as sourceAns -> patient.extension = create('Extension') as ext then {
            sourceAns -> ext.url = 'https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/death-source' "deathsourceurl";
            sourceAns -> ext.value = (sourceAns.valueCoding) "deathsourcevalue";
          } "setdeathsourceext";
        } "extractdeathsource";
      } "extractdeath";
      // Multiple birth rank (linkId 6931296968515)
      identity.item as multipleItem where (linkId = '6931296968515') then {
        multipleItem.answer as ans then {
          ans.valueInteger as valueInteger -> patient.multipleBirth = valueInteger "setmultiplebirth";
        } "navigatevalue";
      } "extractmultiplebirth";
    } "processidentity";
    // Gender from PMSI data (linkId 3894630481120 within 2825244231605)
    src.item as pmsiGroup where (linkId = '2825244231605') then {
      pmsiGroup.item as sexItem where (linkId = '3894630481120') then {
        sexItem.answer as ans then {
          ans.valueCoding as valueCoding -> patient.gender = translate(valueCoding, 'https://interop.aphp.fr/ig/fhir/dm/ConceptMap/dpi-gender-2-hl7-gender', 'code') "setgender";
        } "valueCoding";
      } "extractgender";
      // Address from code géographique (linkId 2446369196222)
      pmsiGroup.item as codeGeoItem where (linkId = '2446369196222') then {
        codeGeoItem.answer as ans -> patient.address = create('Address') as addr then {
          ans -> addr.extension = create('Extension') as ext then {
            ans -> ext.url = 'https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/pmsi-code-geo' "codegeourl";
            ans -> ext.value = (ans.valueCoding) "codegeovalue";
          } "setcodegeoext";
        } "setaddress";
      } "extractcodegeo";
    } "extractpmsidemographics";
  } "processsociodemographics";
}

// Group: Create Locations from geocoding and IRIS data
group CreateLocations(source src : QuestionnaireResponse, target patient : Patient, target bundle : Bundle) {
  // Extract geocoding data from linkId 4647259356106 > 5491974639955 > 3816475533472
  src.item as socioDemo where (linkId = '4647259356106') then {
    socioDemo.item as environment where (linkId = '5491974639955') then {
      // Geocoding locations (repeating group 3816475533472)
      environment.item as geocodingItem where (linkId = '3816475533472') -> bundle.entry as locationEntry then {
        geocodingItem -> locationEntry.resource = create('Location') as location then {
          geocodingItem -> location.id = uuid() "locationid";
          geocodingItem -> location.meta = create('Meta') as meta then {
            geocodingItem -> meta.profile = 'https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMLocation' "locationprofile";
          } "locationmeta";
          // Position with latitude and longitude
          geocodingItem -> location.position = create('LocationPosition') as pos then {
            // Latitude (linkId 3709843054556)
            geocodingItem.item as latItem where (linkId = '3709843054556') then {
              latItem.answer as ans -> pos.latitude = (ans.valueDecimal) "setlatitude";
            } "extractlatitude";
            // Longitude (linkId 7651448032665)
            geocodingItem.item as longItem where (linkId = '7651448032665') then {
              longItem.answer as ans -> pos.longitude = (ans.valueDecimal) "setlongitude";
            } "extractlongitude";
          } "setposition";
          // Extension for collection date (linkId 1185653257776)
          // geocodingItem.item as dateItem where (linkId = '1185653257776') then {             dateItem.answer as ans -> location.extension = create('Extension') as ext then {               ans -> ext.url = 'http://hl7.org/fhir/StructureDefinition/data-collection-date' "date-url";               ans -> ext.value = (ans.valueDate) "date-value";             } "set-collection-date";           } "extract-collection-date";
          location -> locationEntry.request as request then {
            location -> request.method = 'POST' "setmethod";
            location -> request.url = 'Location' "seturl";
          } "setrequest";
          location.id as locId -> locationEntry.fullUrl = append('urn:uuid:', locId) "setfullUrl";
        } "createlocation";
      } "geocodinglocationentry";
      // IRIS locations (repeating item 7621032273792)
      environment.item as irisItem where (linkId = '7621032273792') then {
        irisItem.answer as irisAnswer -> bundle.entry as locationEntry then {
          irisAnswer -> locationEntry.resource = create('Location') as location then {
            irisAnswer -> location.id = uuid() "locationid";
            irisAnswer -> location.meta = create('Meta') as meta then {
              irisAnswer -> meta.profile = 'https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMLocation' "locationprofile";
            } "locationmeta";
            // IRIS code as identifier
            irisAnswer -> location.identifier = create('Identifier') as identifier then {
              irisAnswer -> identifier.system = 'urn:oid:2.16.840.1.113883.2.8.1.5.5' "irissystem";
              irisAnswer -> identifier.value = (irisAnswer.valueCoding.code) "irisvalue";
            } "setirisidentifier";
            // Collection date from nested item (linkId 4999580038872)
            // irisAnswer.item as dateItem where (linkId = '4999580038872') then {               dateItem.answer as ans -> location.extension = create('Extension') as ext then {                 ans -> ext.url = 'http://hl7.org/fhir/StructureDefinition/data-collection-date' "date-url";                 ans -> ext.value = (ans.valueDate) "date-value";               } "set-collection-date";             } "extract-iris-date";
            location -> locationEntry.request as request then {
              location -> request.method = 'POST' "setmethod";
              location -> request.url = 'Location' "seturl";
            } "setrequest";
            location.id as locId -> locationEntry.fullUrl = append('urn:uuid:', locId) "setfullUrl";
          } "createirislocation";
        } "irislocationentry";
      } "processiris";
    } "processenvironment";
  } "processsociodemographicslocation";
}

// Group: Create Encounters from PMSI data
group CreateEncounters(source src : QuestionnaireResponse, target patient : Patient, target bundle : Bundle) {
  // PMSI data group (linkId 2825244231605) - Note: This can repeat in the structure
  src.item as pmsiItem where (linkId = '2825244231605') -> bundle.entry as encounterEntry then {
    pmsiItem -> encounterEntry.resource = create('Encounter') as encounter then {
      pmsiItem -> encounter.id = uuid() "encounterid";
      pmsiItem -> encounter.meta = create('Meta') as meta then {
        pmsiItem -> meta.profile = 'https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMEncounter' "encounterprofile";
      } "encountermeta";
      // Link to patient
      src ->  encounter.subject = create('Reference') as ref,  patient.id as patId,  ref.reference = append('Patient/', patId) "setsubject";
      // Encounter period (start: 5991443718282, end: 6114780320846)
      pmsiItem -> encounter.period = create('Period') as period then {
        pmsiItem.item as startItem where (linkId = '5991443718282') then {
          startItem.answer as ans -> period.start = (ans.valueDate) "setstart";
        } "extractstart";
        pmsiItem.item as endItem where (linkId = '6114780320846') then {
          endItem.answer as ans -> period.end = (ans.valueDate) "setend";
        } "extractend";
      } "setperiod";
      // Mode d'entrée (linkId 6172398101212)
      pmsiItem.item as modeInItem where (linkId = '6172398101212') "extractmodein";
      // Mode de sortie (linkId 3354867075704)
      pmsiItem.item as modeOutItem where (linkId = '3354867075704') "extractmodeout";
      src ->  encounter.id as encId,  encounterEntry.fullUrl = append('urn:uuid:', encId) "setfullUrl";
      // Create nested Conditions and Procedures
      pmsiItem then CreateConditions(pmsiItem, patient, encounter, bundle) "createconditions";
      pmsiItem then CreateProcedures(pmsiItem, patient, encounter, bundle) "createprocedures";
    } "createencounter";
  } "encounterentry";
}

// Group: Create Conditions from nested diagnostics
group CreateConditions(source pmsiItem, target patient : Patient, target encounter : Encounter, target bundle : Bundle) {
  // Diagnostics group (linkId 9391816419630) - can repeat
  pmsiItem.item as diagGroup where (linkId = '9391816419630') -> bundle.entry as conditionEntry then {
    diagGroup -> conditionEntry.resource = create('Condition') as condition then {
      diagGroup -> condition.id = uuid() "conditionid";
      diagGroup -> condition.meta = create('Meta') as meta then {
        diagGroup -> meta.profile = 'https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMCondition' "conditionprofile";
      } "conditionmeta";
      // Link to patient
      diagGroup ->  condition.subject = create('Reference') as ref,  patient.id as patId,  ref.reference = append('Patient/', patId) "setsubject";
      // Link to encounter
      diagGroup ->  encounter.id as encId,  condition.encounter = create('Reference') as ref,  ref.reference = append('Encounter/', encId) "setencounter";
      // Diagnostic code (linkId 5505101189372) - CIM-10
      diagGroup.item as diagCodeItem where (linkId = '5505101189372') then {
        diagCodeItem.answer as ans -> condition.code = create('CodeableConcept') as code then {
          ans -> code.coding = (ans.valueCoding) "setcoding";
        } "setcode";
      } "extractdiagcode";
      // Type de diagnostic (linkId 6427586743735) - DP/DAS/DR
      diagGroup.item as diagTypeItem where (linkId = '6427586743735') then {
        diagTypeItem.answer as ans -> condition.category = create('CodeableConcept') as category then {
          ans -> category.coding = create('Coding') as coding then {
            ans -> coding.system = 'https://interop.aphp.fr/ig/fhir/dm/CodeSystem/pmsi-mco-diag-type' "diagtypesystem";
            ans -> coding.code = (ans.valueCoding.code) "diagtypecode";
            ans -> coding.display = (ans.valueCoding.display) "diagtypedisplay";
          } "setcategorycoding";
        } "setcategory";
      } "extractdiagtype";
      // Recorded date (linkId 7114466839467)
      diagGroup.item as dateItem where (linkId = '7114466839467') then {
        dateItem.answer as ans -> condition.recordedDate = (ans.valueDate) "setrecordeddate";
      } "extractrecordeddate";
    } "createcondition";
  } "conditionentry";
}

// Group: Create Procedures from nested actes
group CreateProcedures(source pmsiItem, target patient : Patient, target encounter : Encounter, target bundle : Bundle) {
  // Actes group (linkId 591926901726) - can repeat
  pmsiItem.item as acteGroup where (linkId = '591926901726') -> bundle.entry as procedureEntry then {
    acteGroup -> procedureEntry.resource = create('Procedure') as procedure then {
      acteGroup -> procedure.id = uuid() "procedureid";
      acteGroup -> procedure.meta = create('Meta') as meta then {
        acteGroup -> meta.profile = 'https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMProcedure' "procedureprofile";
      } "proceduremeta";
      // Link to patient
      acteGroup ->  procedure.subject = create('Reference') as ref,  patient.id as patId,  ref.reference = append('Patient/', patId) "setsubject";
      // Link to encounter
      acteGroup ->  encounter.id as encId,  procedure.encounter = create('Reference') as ref,  ref.reference = append('Encounter/', encId) "setencounter";
      // Acte code (linkId 7758110033600) - CCAM
      acteGroup.item as acteCodeItem where (linkId = '7758110033600') then {
        acteCodeItem.answer as ans -> procedure.code = create('CodeableConcept') as code then {
          ans -> code.coding = (ans.valueCoding) "setcoding";
        } "setcode";
      } "extractactecode";
      // Date de l'acte (linkId 5066866286682)
      acteGroup.item as dateItem where (linkId = '5066866286682') then {
        dateItem.answer as ans -> procedure.performed = (ans.valueDateTime) "setperformed";
      } "extractperformeddate";
    } "createprocedure";
  } "procedureentry";
}

// Group: Create Medication Requests
group CreateMedicationRequests(source src : QuestionnaireResponse, target patient : Patient, target bundle : Bundle) {
  // Exposition médicamenteuse (linkId 817801935685)
  src.item as medExpoGroup where (linkId = '817801935685') then {
    // Médicament prescrit (linkId 156631794800) - repeating
    medExpoGroup.item as prescribedGroup where (linkId = '156631794800') -> bundle.entry as medReqEntry then {
      prescribedGroup -> medReqEntry.resource = create('MedicationRequest') as medReq then {
        prescribedGroup -> medReq.id = uuid() "medreqid";
        prescribedGroup -> medReq.meta = create('Meta') as meta then {
          prescribedGroup -> meta.profile = 'https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMMedicationRequest' "medreqprofile";
        } "medreqmeta";
        // Link to patient
        prescribedGroup ->  medReq.subject = create('Reference') as ref,  patient.id as patId,  ref.reference = append('Patient/', patId) "setsubject";
        // Status and intent
        prescribedGroup -> medReq.status = 'active' "setstatus";
        prescribedGroup -> medReq.intent = 'order' "setintent";
        // Create Medication resource and reference
        prescribedGroup -> bundle.entry as medEntry then {
          prescribedGroup -> medEntry.resource = create('Medication') as medication then {
            prescribedGroup -> medication.id = uuid() "medid";
            // ATC code from nested items
            prescribedGroup.item as atcItem where (linkId.contains('ATC')) then {
              atcItem.answer as ans -> medication.code = create('CodeableConcept') as code then {
                ans -> code.coding = (ans.valueCoding) "setatccoding";
              } "setmedcode";
            } "extractatc";
            prescribedGroup ->  medication.id as medId,  medEntry.fullUrl = append('urn:uuid:', medId) "setfullUrl";
            // Link MedicationRequest to Medication
            prescribedGroup ->  medication.id as medId,  medReq.medication = create('Reference') as ref,  ref.reference = append('Medication/', medId) "setmedicationreference";
          } "createmedication";
        } "medicationentry";
        // Dosage instructions
        prescribedGroup -> medReq.dosageInstruction = create('Dosage') as dosage then {
          // Route
          prescribedGroup.item as routeItem where (linkId.contains('voie')) then {
            routeItem.answer as ans -> dosage.route = create('CodeableConcept') as route then {
              ans -> route.coding = (ans.valueCoding) "setroutecoding";
            } "setroute";
          } "extractroute";
          // Timing
          prescribedGroup.item as timingItem where (linkId.contains('timing') or linkId.contains('fréquence')) then {
            timingItem.answer as ans -> dosage.timing = create('Timing') as timing then {
              ans -> timing.repeat = create('TimingRepeat') as repeat "settiming";
            } "settimingstructure";
          } "extracttiming";
        } "setdosage";
      } "createmedreq";
    } "medreqentry";
  } "processmedexpo";
}

// Group: Create Medication Administrations
group CreateMedicationAdministrations(source src : QuestionnaireResponse, target patient : Patient, target bundle : Bundle) {
  // Exposition médicamenteuse (linkId 817801935685)
  src.item as medExpoGroup where (linkId = '817801935685') then {
    // Médicament administré (linkId 266852453304) - repeating
    medExpoGroup.item as adminGroup where (linkId = '266852453304') -> bundle.entry as medAdminEntry then {
      adminGroup -> medAdminEntry.resource = create('MedicationAdministration') as medAdmin then {
        adminGroup -> medAdmin.id = uuid() "medadminid";
        adminGroup -> medAdmin.meta = create('Meta') as meta then {
          adminGroup -> meta.profile = 'https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMMedicationAdministration' "medadminprofile";
        } "medadminmeta";
        // Link to patient
        adminGroup ->  medAdmin.subject = create('Reference') as ref,  patient.id as patId,  ref.reference = append('Patient/', patId) "setsubject";
        // Status
        adminGroup -> medAdmin.status = 'completed' "setstatus";
        // Create Medication resource and reference
        adminGroup -> bundle.entry as medEntry then {
          adminGroup -> medEntry.resource = create('Medication') as medication then {
            adminGroup -> medication.id = uuid() "medid";
            // ATC code from nested items
            adminGroup.item as atcItem where (linkId.contains('ATC')) then {
              atcItem.answer as ans -> medication.code = create('CodeableConcept') as code then {
                ans -> code.coding = (ans.valueCoding) "setatccoding";
              } "setmedcode";
            } "extractatc";
            adminGroup ->  medication.id as medId,  medEntry.fullUrl = append('Medication/', medId) "setfullUrl";
            // Link MedicationAdministration to Medication
            adminGroup ->  medication.id as medId,  medAdmin.medication = create('Reference') as ref,  ref.reference = append('urn:uuid:', medId) "setmedicationreference";
          } "createmedication";
        } "medicationentry";
        // Effective period
        adminGroup -> medAdmin.effective = create('Period') as period then {
          adminGroup.item as startItem where (linkId.contains('début')) then {
            startItem.answer as ans -> period.start = (ans.valueDateTime) "setstart";
          } "extractstart";
          adminGroup.item as endItem where (linkId.contains('fin')) then {
            endItem.answer as ans -> period.end = (ans.valueDateTime) "setend";
          } "extractend";
        } "seteffective";
        // Dosage
        adminGroup -> medAdmin.dosage = create('Dosage') as dosage then {
          // Route
          adminGroup.item as routeItem where (linkId.contains('voie')) then {
            routeItem.answer as ans -> dosage.route = create('CodeableConcept') as route then {
              ans -> route.coding = (ans.valueCoding) "setroutecoding";
            } "setroute";
          } "extractroute";
          // Dose
          adminGroup.item as doseItem where (linkId.contains('dose')) then {
            doseItem.answer as ans -> dosage.dose = (ans.valueQuantity) "setdose";
          } "extractdose";
        } "setdosage";
      } "createmedadmin";
    } "medadminentry";
  } "processmedexpoadmin";
}

// Group: Create Vital Sign Observations
group CreateVitalSignObservations(source src : QuestionnaireResponse, target patient : Patient, target bundle : Bundle) {
  // Examen clinique (linkId 214880328197)
  src.item as examGroup where (linkId = '214880328197') then {
    // Dossier de soins (linkId 305831246173) - repeating
    examGroup.item as dossierGroup where (linkId = '305831246173') then {
      // Height (linkId 4846902346416)
      dossierGroup.item as heightItem where (linkId = '4846902346416') then {
        heightItem.answer as ans -> bundle.entry as obsEntry then {
          ans -> obsEntry.resource = create('Observation') as obs then {
            ans -> obs.id = uuid() "obsid";
            ans ->  obs.id as obsId,  obsEntry.fullUrl = append('urn:uuid:', obsId) "setfullUrl";
            ans -> obs.meta = create('Meta') as meta then {
              ans -> meta.profile = 'https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMObservationBodyHeight' "obsprofile";
            } "obsmeta";
            ans -> obs.status = 'final' "obsstatus";
            ans -> obs.category = cc('http://terminology.hl7.org/CodeSystem/observation-category', 'vital-signs') "obscategory";
            ans -> obs.code = cc('http://loinc.org', '8302-2', 'Body height') "obscode";
            // Link to patient
            ans ->  obs.subject = create('Reference') as ref,  patient.id as patId,  ref.reference = append('Patient/', patId) "setsubject";
            // Value
            ans -> obs.value = (ans.valueQuantity) "setvalue";
            // Effective date from nested item
            heightItem.item as dateItem where (linkId.contains('Date')) then {
              dateItem.answer as dateAns -> obs.effective = (dateAns.valueDate) "seteffective";
            } "extracteffective";
          } "createheightobs";
        } "heightobsentry";
      } "extractheight";
      // Weight (linkId 451513217936)
      dossierGroup.item as weightItem where (linkId = '451513217936') then {
        weightItem.answer as ans -> bundle.entry as obsEntry then {
          ans -> obsEntry.resource = create('Observation') as obs then {
            ans -> obs.id = uuid() "obsid";
            ans ->  obs.id as obsId,  obsEntry.fullUrl = append('urn:uuid:', obsId) "setfullUrl";
            ans -> obs.meta = create('Meta') as meta then {
              ans -> meta.profile = 'https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMObservationBodyWeight' "obsprofile";
            } "obsmeta";
            ans -> obs.status = 'final' "obsstatus";
            ans -> obs.category = cc('http://terminology.hl7.org/CodeSystem/observation-category', 'vital-signs') "obscategory";
            ans -> obs.code = cc('http://loinc.org', '29463-7', 'Body weight') "obscode";
            // Link to patient
            ans ->  obs.subject = create('Reference') as ref,  patient.id as patId,  ref.reference = append('Patient/', patId) "setsubject";
            // Value
            ans -> obs.value = (ans.valueQuantity) "setvalue";
            // Effective date from nested item
            weightItem.item as dateItem where (linkId.contains('Date')) then {
              dateItem.answer as dateAns -> obs.effective = (dateAns.valueDate) "seteffective";
            } "extracteffective";
          } "createweightobs";
        } "weightobsentry";
      } "extractweight";
      // Blood Pressure - need both systolic and diastolic
      dossierGroup.item as sysItem where (linkId = '4160905247955') then {
        sysItem.answer as sysAns then {
          dossierGroup.item as diaItem where (linkId = '848797127998') then {
            diaItem.answer as diaAns -> bundle.entry as obsEntry then {
              sysAns -> obsEntry.resource = create('Observation') as obs then {
                sysAns -> obs.id = uuid() "obsid";
                sysAns ->  obs.id as obsId,  obsEntry.fullUrl = append('urn:uuid:', obsId) "setfullUrl";
                sysAns -> obs.meta = create('Meta') as meta then {
                  sysAns -> meta.profile = 'https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMObservationBloodPressure' "obsprofile";
                } "obsmeta";
                sysAns -> obs.status = 'final' "obsstatus";
                sysAns -> obs.category = cc('http://terminology.hl7.org/CodeSystem/observation-category', 'vital-signs') "obscategory";
                sysAns -> obs.code = cc('http://loinc.org', '85354-9', 'Blood pressure panel') "obscode";
                // Link to patient
                sysAns ->  obs.subject = create('Reference') as ref,  patient.id as patId,  ref.reference = append('Patient/', patId) "setsubject";
                // Systolic component
                sysAns -> obs.component = create('Observation') as sysComp then {
                  sysAns -> sysComp.code = cc('http://loinc.org', '8480-6', 'Systolic blood pressure') "syscode";
                  sysAns -> sysComp.value = (sysAns.valueQuantity) "sysvalue";
                } "setsystolic";
                // Diastolic component
                diaAns -> obs.component = create('Observation') as diaComp then {
                  diaAns -> diaComp.code = cc('http://loinc.org', '8462-4', 'Diastolic blood pressure') "diacode";
                  diaAns -> diaComp.value = (diaAns.valueQuantity) "diavalue";
                } "setdiastolic";
                // Effective date from nested item
                sysItem.item as dateItem where (linkId.contains('Date')) then {
                  dateItem.answer as dateAns -> obs.effective = (dateAns.valueDate) "seteffective";
                } "extracteffective";
              } "createbpobs";
            } "bpobsentr";
          } "extractdiastolic";
        } "processsystolic";
      } "extractbloodpressure";
    } "processdossier";
  } "processexam";
}

// Group: Create Laboratory Observations
group CreateLaboratoryObservations(source src : QuestionnaireResponse, target patient : Patient, target bundle : Bundle) {
  // Biologie group (linkId 7702944131447)
  src.item as bioGroup where (linkId = '7702944131447') then {
    // Fonction rénale (linkId 5241323453538)
    bioGroup.item as renalGroup where (linkId = '5241323453538') then {
      // Urée (linkId 7169026818760)
      renalGroup.item as ureaItem where (linkId = '7169026818760') then {
        ureaItem.answer as ans -> bundle then CreateLabObservation(ans, ureaItem, patient, bundle) "createureaobs";
      } "extracturea";
      // Créatininémie (linkId 500408205043)
      renalGroup.item as creatItem where (linkId = '500408205043') then {
        creatItem.answer as ans -> bundle then CreateLabObservation(ans, creatItem, patient, bundle) "createcreatobs";
      } "extractcreat";
      // DFG (linkId 786621340679)
      renalGroup.item as dfgItem where (linkId = '786621340679') then {
        dfgItem.answer as ans -> bundle then CreateLabObservation(ans, dfgItem, patient, bundle) "createdfgobs";
      } "extractdfg";
    } "processrenal";
    // Hémogramme (linkId 419282985970)
    bioGroup.item as hemoGroup where (linkId = '419282985970') then {
      // Leucocytes (linkId 210077225604)
      hemoGroup.item as leukoItem where (linkId = '210077225604') then {
        leukoItem.answer as ans -> bundle then CreateLabObservation(ans, leukoItem, patient, bundle) "createleukoobs";
      } "extractleuko";
      // Hémoglobine (linkId 304159088493)
      hemoGroup.item as hemoItem where (linkId = '304159088493') then {
        hemoItem.answer as ans -> bundle then CreateLabObservation(ans, hemoItem, patient, bundle) "createhemoobs";
      } "extracthemo";
      // Hématocrite (linkId 5687959006070)
      hemoGroup.item as hematItem where (linkId = '5687959006070') then {
        hematItem.answer as ans -> bundle then CreateLabObservation(ans, hematItem, patient, bundle) "createhematobs";
      } "extracthemat";
      // Erythrocytes (linkId 8697447896867)
      hemoGroup.item as eryItem where (linkId = '8697447896867') then {
        eryItem.answer as ans -> bundle then CreateLabObservation(ans, eryItem, patient, bundle) "createeryobs";
      } "extractery";
      // VGM (linkId 5584978899134)
      hemoGroup.item as vgmItem where (linkId = '5584978899134') then {
        vgmItem.answer as ans -> bundle then CreateLabObservation(ans, vgmItem, patient, bundle) "createvgmobs";
      } "extractvgm";
      // Plaquettes (linkId 2881119993430)
      hemoGroup.item as platItem where (linkId = '2881119993430') then {
        platItem.answer as ans -> bundle then CreateLabObservation(ans, platItem, patient, bundle) "createplatobs";
      } "extractplat";
      // Neutrophiles (linkId 7408951746270)
      hemoGroup.item as neutItem where (linkId = '7408951746270') then {
        neutItem.answer as ans -> bundle then CreateLabObservation(ans, neutItem, patient, bundle) "createneutobs";
      } "extractneut";
      // Lymphocytes (linkId 809808816195)
      hemoGroup.item as lymphItem where (linkId = '809808816195') then {
        lymphItem.answer as ans -> bundle then CreateLabObservation(ans, lymphItem, patient, bundle) "createlymphobs";
      } "extractlymph";
      // Eosinophiles (linkId 6451887990893)
      hemoGroup.item as eosiItem where (linkId = '6451887990893') then {
        eosiItem.answer as ans -> bundle then CreateLabObservation(ans, eosiItem, patient, bundle) "createeosiobs";
      } "extracteosi";
      // Monocytes (linkId 7935935816936)
      hemoGroup.item as monoItem where (linkId = '7935935816936') then {
        monoItem.answer as ans -> bundle then CreateLabObservation(ans, monoItem, patient, bundle) "createmonoobs";
      } "extractmono";
      // TP (linkId 2055949655770)
      hemoGroup.item as tpItem where (linkId = '2055949655770') then {
        tpItem.answer as ans -> bundle then CreateLabObservation(ans, tpItem, patient, bundle) "createtpobs";
      } "extracttp";
      // TCA (linkId 2527095476817)
      hemoGroup.item as tcaItem where (linkId = '2527095476817') then {
        tcaItem.answer as ans -> bundle then CreateLabObservation(ans, tcaItem, patient, bundle) "createtcaobs";
      } "extracttca";
    } "processhemo";
    // Bilan hépatique (linkId 3893612773040)
    bioGroup.item as liverGroup where (linkId = '3893612773040') then {
      // ASAT (linkId 3028330976100)
      liverGroup.item as asatItem where (linkId = '3028330976100') then {
        asatItem.answer as ans -> bundle then CreateLabObservation(ans, asatItem, patient, bundle) "createasatobs";
      } "extractasat";
      // ALAT (linkId 8486813893880)
      liverGroup.item as alatItem where (linkId = '8486813893880') then {
        alatItem.answer as ans -> bundle then CreateLabObservation(ans, alatItem, patient, bundle) "createalatobs";
      } "extractalat";
      // GGT (linkId 3663296044037)
      liverGroup.item as ggtItem where (linkId = '3663296044037') then {
        ggtItem.answer as ans -> bundle then CreateLabObservation(ans, ggtItem, patient, bundle) "createggtobs";
      } "extractggt";
      // PAL (linkId 2690026606933)
      liverGroup.item as palItem where (linkId = '2690026606933') then {
        palItem.answer as ans -> bundle then CreateLabObservation(ans, palItem, patient, bundle) "createpalobs";
      } "extractpal";
      // Bilirubine totale (linkId 9068831071023)
      liverGroup.item as bilTotItem where (linkId = '9068831071023') then {
        bilTotItem.answer as ans -> bundle then CreateLabObservation(ans, bilTotItem, patient, bundle) "createbiltotobs";
      } "extractbiltot";
      // Bilirubine conjuguée (linkId 8893717988787)
      liverGroup.item as bilConjItem where (linkId = '8893717988787') then {
        bilConjItem.answer as ans -> bundle then CreateLabObservation(ans, bilConjItem, patient, bundle) "createbilconjobs";
      } "extractbilconj";
    } "processliver";
    // Métabolisme glucidique (linkId 8929068894076)
    bioGroup.item as glucoseGroup where (linkId = '8929068894076') then {
      // Glycémie à jeun (linkId 8193929027997)
      glucoseGroup.item as glycItem where (linkId = '8193929027997') then {
        glycItem.answer as ans -> bundle then CreateLabObservation(ans, glycItem, patient, bundle) "createglycobs";
      } "extractglyc";
      // HbA1c (linkId 7063892830923)
      glucoseGroup.item as hba1cItem where (linkId = '7063892830923') then {
        hba1cItem.answer as ans -> bundle then CreateLabObservation(ans, hba1cItem, patient, bundle) "createhba1cobs";
      } "extracthba1c";
    } "processglucose";
  } "processbiology";
}

// Helper: Create a single Laboratory Observation
group CreateLabObservation(source ans, source parentItem, target patient : Patient, target bundle : Bundle) {
  ans -> bundle.entry as obsEntry then {
    ans -> obsEntry.resource = create('Observation') as obs then {
      ans -> obs.id = uuid() "obsid";
      ans ->  obs.id as obsId,  obsEntry.fullUrl = append('urn:uuid:', obsId) "setfullUrl";
      ans -> obs.meta = create('Meta') as meta then {
        ans -> meta.profile = 'https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/dm-observation-laboratory-generic' "obsprofile";
      } "obsmeta";
      // Status
      ans -> obs.status = 'final' "obsstatus";
      // Category
      ans -> obs.category = create('CodeableConcept') as cat then {
        ans -> cat.coding = create('Coding') as coding then {
          ans -> coding.system = 'http://terminology.hl7.org/CodeSystem/observation-category' "catsystem";
          ans -> coding.code = 'laboratory' "catcode";
        } "setcategorycoding";
      } "setcategory";
      // Link to patient
      ans ->  obs.subject = create('Reference') as ref,  patient.id as patId,  ref.reference = append('Patient/', patId) "setsubject";
      // Value as Quantity
      ans -> obs.value = (ans.valueQuantity) "setvalue";
      // Extract nested items - LOINC code, effective date, status, reference ranges
      parentItem.item as loincItem where (linkId.contains('code loinc')) then {
        loincItem.answer as loincAns -> obs.code = create('CodeableConcept') as code then {
          loincAns -> code.coding = (loincAns.valueCoding) "setloinccoding";
        } "setcode";
      } "extractloinc";
      parentItem.item as dateItem where (linkId.contains('Date et heure du prélèvement')) then {
        dateItem.answer as dateAns -> obs.effective = (dateAns.valueDateTime) "seteffective";
      } "extracteffective";
    } "createobs";
  } "obsentry";
}


```



## Resource Content

```json
{
  "resourceType" : "StructureMap",
  "id" : "Q2FSL",
  "url" : "https://interop.aphp.fr/ig/fhir/dm/StructureMap/Q2FSL",
  "version" : "0.1.0",
  "name" : "Q2FSL",
  "title" : "Transforms QuestionnaireResponse based on Questionnaire Usage Variables socles into FHIR resources conforming to DM profiles",
  "status" : "draft",
  "date" : "2025-10-23T20:49:03+00:00",
  "publisher" : "AP-HP",
  "contact" : [
    {
      "name" : "AP-HP",
      "telecom" : [
        {
          "system" : "url",
          "value" : "https://aphp.fr"
        }
      ]
    }
  ],
  "description" : "Transforms QuestionnaireResponse based on Questionnaire Usage Variables socles into FHIR resources conforming to DM profiles",
  "jurisdiction" : [
    {
      "coding" : [
        {
          "system" : "urn:iso:std:iso:3166",
          "code" : "FR",
          "display" : "France"
        }
      ]
    }
  ],
  "structure" : [
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse",
      "mode" : "source",
      "alias" : "QuestionnaireResponse"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/Bundle",
      "mode" : "target",
      "alias" : "Bundle"
    }
  ],
  "group" : [
    {
      "name" : "QuestionnaireResponseToBundle",
      "typeMode" : "none",
      "documentation" : "Main entry point: Transform QuestionnaireResponse to Bundle",
      "input" : [
        {
          "name" : "src",
          "type" : "QuestionnaireResponse",
          "mode" : "source"
        },
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "bundleid",
          "source" : [
            {
              "context" : "src"
            }
          ],
          "target" : [
            {
              "context" : "bundle",
              "contextType" : "variable",
              "element" : "id",
              "transform" : "uuid"
            }
          ]
        },
        {
          "name" : "bundletype",
          "source" : [
            {
              "context" : "src"
            }
          ],
          "target" : [
            {
              "context" : "bundle",
              "contextType" : "variable",
              "element" : "type",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "collection"
                }
              ]
            }
          ]
        },
        {
          "name" : "setTimestamp",
          "source" : [
            {
              "context" : "src"
            }
          ],
          "target" : [
            {
              "context" : "bundle",
              "contextType" : "variable",
              "element" : "timestamp",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "now()"
                }
              ]
            }
          ]
        },
        {
          "name" : "patiententry",
          "source" : [
            {
              "context" : "src"
            }
          ],
          "target" : [
            {
              "context" : "bundle",
              "contextType" : "variable",
              "element" : "entry",
              "variable" : "patientEntry"
            }
          ],
          "rule" : [
            {
              "name" : "createpatientresource",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "patientEntry",
                  "contextType" : "variable",
                  "element" : "resource",
                  "variable" : "patient",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Patient"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "createpatient",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "dependent" : [
                    {
                      "name" : "CreatePatient",
                      "variable" : ["src", "patient"]
                    }
                  ]
                },
                {
                  "name" : "setfullUrl",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "patient",
                      "contextType" : "variable",
                      "element" : "id",
                      "variable" : "patientId"
                    },
                    {
                      "context" : "patientEntry",
                      "contextType" : "variable",
                      "element" : "fullUrl",
                      "transform" : "append",
                      "parameter" : [
                        {
                          "valueString" : "urn:uuid:"
                        },
                        {
                          "valueId" : "patientId"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "createencounters",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "dependent" : [
                    {
                      "name" : "CreateEncounters",
                      "variable" : ["src", "patient", "bundle"]
                    }
                  ]
                },
                {
                  "name" : "createlabobservations",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "dependent" : [
                    {
                      "name" : "CreateLaboratoryObservations",
                      "variable" : ["src", "patient", "bundle"]
                    }
                  ]
                },
                {
                  "name" : "createmedicationrequests",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "dependent" : [
                    {
                      "name" : "CreateMedicationRequests",
                      "variable" : ["src", "patient", "bundle"]
                    }
                  ]
                },
                {
                  "name" : "createmedicationadministrations",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "dependent" : [
                    {
                      "name" : "CreateMedicationAdministrations",
                      "variable" : ["src", "patient", "bundle"]
                    }
                  ]
                },
                {
                  "name" : "createvitalsigns",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "dependent" : [
                    {
                      "name" : "CreateVitalSignObservations",
                      "variable" : ["src", "patient", "bundle"]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "CreatePatient",
      "typeMode" : "none",
      "documentation" : "Group: Create Patient from QuestionnaireResponse",
      "input" : [
        {
          "name" : "src",
          "type" : "QuestionnaireResponse",
          "mode" : "source"
        },
        {
          "name" : "patient",
          "type" : "Patient",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "patientid",
          "source" : [
            {
              "context" : "src"
            }
          ],
          "target" : [
            {
              "context" : "patient",
              "contextType" : "variable",
              "element" : "id",
              "transform" : "uuid"
            }
          ]
        },
        {
          "name" : "patientmeta",
          "source" : [
            {
              "context" : "src"
            }
          ],
          "target" : [
            {
              "context" : "patient",
              "contextType" : "variable",
              "element" : "meta",
              "variable" : "meta",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Meta"
                }
              ]
            }
          ],
          "rule" : [
            {
              "name" : "patientprofile",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "meta",
                  "contextType" : "variable",
                  "element" : "profile",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMPatient"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "processsociodemographics",
          "source" : [
            {
              "context" : "src",
              "element" : "item",
              "variable" : "socioDemo",
              "condition" : "(linkId = '4647259356106')"
            }
          ],
          "rule" : [
            {
              "name" : "processidentity",
              "source" : [
                {
                  "context" : "socioDemo",
                  "element" : "item",
                  "variable" : "identity",
                  "condition" : "(linkId = '2958000860428')"
                }
              ],
              "rule" : [
                {
                  "name" : "setname",
                  "source" : [
                    {
                      "context" : "identity"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "patient",
                      "contextType" : "variable",
                      "element" : "name",
                      "variable" : "name",
                      "transform" : "create",
                      "parameter" : [
                        {
                          "valueString" : "HumanName"
                        }
                      ]
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "extractfamily",
                      "source" : [
                        {
                          "context" : "identity",
                          "element" : "item",
                          "variable" : "familyItem",
                          "condition" : "(linkId = '8605698058770')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "setfamily",
                          "source" : [
                            {
                              "context" : "familyItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "name",
                              "contextType" : "variable",
                              "element" : "family",
                              "transform" : "evaluate",
                              "parameter" : [
                                {
                                  "valueString" : "ans.valueString"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractgiven",
                      "source" : [
                        {
                          "context" : "identity",
                          "element" : "item",
                          "variable" : "givenItem",
                          "condition" : "(linkId = '6214879623503')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "setgiven",
                          "source" : [
                            {
                              "context" : "givenItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "name",
                              "contextType" : "variable",
                              "element" : "given",
                              "transform" : "evaluate",
                              "parameter" : [
                                {
                                  "valueString" : "ans.valueString"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extractnir",
                  "source" : [
                    {
                      "context" : "identity",
                      "element" : "item",
                      "variable" : "nirItem",
                      "condition" : "(linkId = '5711960356160')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "setnir",
                      "source" : [
                        {
                          "context" : "nirItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "patient",
                          "contextType" : "variable",
                          "element" : "identifier",
                          "variable" : "nir",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Identifier"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "nirsystem",
                          "source" : [
                            {
                              "context" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "nir",
                              "contextType" : "variable",
                              "element" : "system",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueString" : "urn:oid:1.2.250.1.213.1.4.8"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "nirvalue",
                          "source" : [
                            {
                              "context" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "nir",
                              "contextType" : "variable",
                              "element" : "value",
                              "transform" : "evaluate",
                              "parameter" : [
                                {
                                  "valueString" : "ans.valueString"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "nirtype",
                          "source" : [
                            {
                              "context" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "nir",
                              "contextType" : "variable",
                              "element" : "type",
                              "transform" : "cc",
                              "parameter" : [
                                {
                                  "valueString" : "http://interopsante.org/fhir/CodeSystem/fr-v2-0203"
                                },
                                {
                                  "valueString" : "NIR"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extractins",
                  "source" : [
                    {
                      "context" : "identity",
                      "element" : "item",
                      "variable" : "insItem",
                      "condition" : "(linkId = '3764723550987')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "setins",
                      "source" : [
                        {
                          "context" : "insItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "patient",
                          "contextType" : "variable",
                          "element" : "identifier",
                          "variable" : "ins",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Identifier"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "inssystem",
                          "source" : [
                            {
                              "context" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "ins",
                              "contextType" : "variable",
                              "element" : "system",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueString" : "urn:oid:1.2.250.1.213.1.4.10"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "insvalue",
                          "source" : [
                            {
                              "context" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "ins",
                              "contextType" : "variable",
                              "element" : "value",
                              "transform" : "evaluate",
                              "parameter" : [
                                {
                                  "valueString" : "ans.valueString"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "instype",
                          "source" : [
                            {
                              "context" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "ins",
                              "contextType" : "variable",
                              "element" : "type",
                              "transform" : "cc",
                              "parameter" : [
                                {
                                  "valueString" : "http://interopsante.org/fhir/CodeSystem/fr-v2-0203"
                                },
                                {
                                  "valueString" : "INS-C"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extractbirthdate",
                  "source" : [
                    {
                      "context" : "identity",
                      "element" : "item",
                      "variable" : "birthItem",
                      "condition" : "(linkId = '5036133558154')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "setbirthdate",
                      "source" : [
                        {
                          "context" : "birthItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "patient",
                          "contextType" : "variable",
                          "element" : "birthDate",
                          "transform" : "evaluate",
                          "parameter" : [
                            {
                              "valueString" : "ans.valueDate"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extractdeath",
                  "source" : [
                    {
                      "context" : "identity",
                      "element" : "item",
                      "variable" : "deathItem",
                      "condition" : "(linkId = '5633552097315')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "setdeceaseddate",
                      "source" : [
                        {
                          "context" : "deathItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "patient",
                          "contextType" : "variable",
                          "element" : "deceased",
                          "transform" : "evaluate",
                          "parameter" : [
                            {
                              "valueString" : "ans.valueDate"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractdeathsource",
                      "source" : [
                        {
                          "context" : "deathItem",
                          "element" : "item",
                          "variable" : "deathSource",
                          "condition" : "(linkId = '9098810065693')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "setdeathsourceext",
                          "source" : [
                            {
                              "context" : "deathSource",
                              "element" : "answer",
                              "variable" : "sourceAns"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "patient",
                              "contextType" : "variable",
                              "element" : "extension",
                              "variable" : "ext",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Extension"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "deathsourceurl",
                              "source" : [
                                {
                                  "context" : "sourceAns"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "ext",
                                  "contextType" : "variable",
                                  "element" : "url",
                                  "transform" : "copy",
                                  "parameter" : [
                                    {
                                      "valueString" : "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/death-source"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "deathsourcevalue",
                              "source" : [
                                {
                                  "context" : "sourceAns"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "ext",
                                  "contextType" : "variable",
                                  "element" : "value",
                                  "transform" : "evaluate",
                                  "parameter" : [
                                    {
                                      "valueString" : "sourceAns.valueCoding"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extractmultiplebirth",
                  "source" : [
                    {
                      "context" : "identity",
                      "element" : "item",
                      "variable" : "multipleItem",
                      "condition" : "(linkId = '6931296968515')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "navigatevalue",
                      "source" : [
                        {
                          "context" : "multipleItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "setmultiplebirth",
                          "source" : [
                            {
                              "context" : "ans",
                              "element" : "valueInteger",
                              "variable" : "valueInteger"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "patient",
                              "contextType" : "variable",
                              "element" : "multipleBirth",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueId" : "valueInteger"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "extractpmsidemographics",
              "source" : [
                {
                  "context" : "src",
                  "element" : "item",
                  "variable" : "pmsiGroup",
                  "condition" : "(linkId = '2825244231605')"
                }
              ],
              "rule" : [
                {
                  "name" : "extractgender",
                  "source" : [
                    {
                      "context" : "pmsiGroup",
                      "element" : "item",
                      "variable" : "sexItem",
                      "condition" : "(linkId = '3894630481120')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "valueCoding",
                      "source" : [
                        {
                          "context" : "sexItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "setgender",
                          "source" : [
                            {
                              "context" : "ans",
                              "element" : "valueCoding",
                              "variable" : "valueCoding"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "patient",
                              "contextType" : "variable",
                              "element" : "gender",
                              "transform" : "translate",
                              "parameter" : [
                                {
                                  "valueId" : "valueCoding"
                                },
                                {
                                  "valueString" : "https://interop.aphp.fr/ig/fhir/dm/ConceptMap/dpi-gender-2-hl7-gender"
                                },
                                {
                                  "valueString" : "code"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extractcodegeo",
                  "source" : [
                    {
                      "context" : "pmsiGroup",
                      "element" : "item",
                      "variable" : "codeGeoItem",
                      "condition" : "(linkId = '2446369196222')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "setaddress",
                      "source" : [
                        {
                          "context" : "codeGeoItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "patient",
                          "contextType" : "variable",
                          "element" : "address",
                          "variable" : "addr",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Address"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "setcodegeoext",
                          "source" : [
                            {
                              "context" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "addr",
                              "contextType" : "variable",
                              "element" : "extension",
                              "variable" : "ext",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Extension"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "codegeourl",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "ext",
                                  "contextType" : "variable",
                                  "element" : "url",
                                  "transform" : "copy",
                                  "parameter" : [
                                    {
                                      "valueString" : "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/pmsi-code-geo"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "codegeovalue",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "ext",
                                  "contextType" : "variable",
                                  "element" : "value",
                                  "transform" : "evaluate",
                                  "parameter" : [
                                    {
                                      "valueString" : "ans.valueCoding"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "CreateLocations",
      "typeMode" : "none",
      "documentation" : "Group: Create Locations from geocoding and IRIS data",
      "input" : [
        {
          "name" : "src",
          "type" : "QuestionnaireResponse",
          "mode" : "source"
        },
        {
          "name" : "patient",
          "type" : "Patient",
          "mode" : "target"
        },
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "processsociodemographicslocation",
          "source" : [
            {
              "context" : "src",
              "element" : "item",
              "variable" : "socioDemo",
              "condition" : "(linkId = '4647259356106')"
            }
          ],
          "rule" : [
            {
              "name" : "processenvironment",
              "source" : [
                {
                  "context" : "socioDemo",
                  "element" : "item",
                  "variable" : "environment",
                  "condition" : "(linkId = '5491974639955')"
                }
              ],
              "rule" : [
                {
                  "name" : "geocodinglocationentry",
                  "source" : [
                    {
                      "context" : "environment",
                      "element" : "item",
                      "variable" : "geocodingItem",
                      "condition" : "(linkId = '3816475533472')"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "bundle",
                      "contextType" : "variable",
                      "element" : "entry",
                      "variable" : "locationEntry"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "createlocation",
                      "source" : [
                        {
                          "context" : "geocodingItem"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "locationEntry",
                          "contextType" : "variable",
                          "element" : "resource",
                          "variable" : "location",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Location"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "locationid",
                          "source" : [
                            {
                              "context" : "geocodingItem"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "location",
                              "contextType" : "variable",
                              "element" : "id",
                              "transform" : "uuid"
                            }
                          ]
                        },
                        {
                          "name" : "locationmeta",
                          "source" : [
                            {
                              "context" : "geocodingItem"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "location",
                              "contextType" : "variable",
                              "element" : "meta",
                              "variable" : "meta",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Meta"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "locationprofile",
                              "source" : [
                                {
                                  "context" : "geocodingItem"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "meta",
                                  "contextType" : "variable",
                                  "element" : "profile",
                                  "transform" : "copy",
                                  "parameter" : [
                                    {
                                      "valueString" : "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMLocation"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "setposition",
                          "source" : [
                            {
                              "context" : "geocodingItem"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "location",
                              "contextType" : "variable",
                              "element" : "position",
                              "variable" : "pos",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "LocationPosition"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "extractlatitude",
                              "source" : [
                                {
                                  "context" : "geocodingItem",
                                  "element" : "item",
                                  "variable" : "latItem",
                                  "condition" : "(linkId = '3709843054556')"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "setlatitude",
                                  "source" : [
                                    {
                                      "context" : "latItem",
                                      "element" : "answer",
                                      "variable" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "pos",
                                      "contextType" : "variable",
                                      "element" : "latitude",
                                      "transform" : "evaluate",
                                      "parameter" : [
                                        {
                                          "valueString" : "ans.valueDecimal"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "extractlongitude",
                              "source" : [
                                {
                                  "context" : "geocodingItem",
                                  "element" : "item",
                                  "variable" : "longItem",
                                  "condition" : "(linkId = '7651448032665')"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "setlongitude",
                                  "source" : [
                                    {
                                      "context" : "longItem",
                                      "element" : "answer",
                                      "variable" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "pos",
                                      "contextType" : "variable",
                                      "element" : "longitude",
                                      "transform" : "evaluate",
                                      "parameter" : [
                                        {
                                          "valueString" : "ans.valueDecimal"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "setrequest",
                          "source" : [
                            {
                              "context" : "location"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "locationEntry",
                              "contextType" : "variable",
                              "element" : "request",
                              "variable" : "request"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "setmethod",
                              "source" : [
                                {
                                  "context" : "location"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "request",
                                  "contextType" : "variable",
                                  "element" : "method",
                                  "transform" : "copy",
                                  "parameter" : [
                                    {
                                      "valueString" : "POST"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "seturl",
                              "source" : [
                                {
                                  "context" : "location"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "request",
                                  "contextType" : "variable",
                                  "element" : "url",
                                  "transform" : "copy",
                                  "parameter" : [
                                    {
                                      "valueString" : "Location"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "setfullUrl",
                          "source" : [
                            {
                              "context" : "location",
                              "element" : "id",
                              "variable" : "locId"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "locationEntry",
                              "contextType" : "variable",
                              "element" : "fullUrl",
                              "transform" : "append",
                              "parameter" : [
                                {
                                  "valueString" : "urn:uuid:"
                                },
                                {
                                  "valueId" : "locId"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "processiris",
                  "source" : [
                    {
                      "context" : "environment",
                      "element" : "item",
                      "variable" : "irisItem",
                      "condition" : "(linkId = '7621032273792')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "irislocationentry",
                      "source" : [
                        {
                          "context" : "irisItem",
                          "element" : "answer",
                          "variable" : "irisAnswer"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable",
                          "element" : "entry",
                          "variable" : "locationEntry"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createirislocation",
                          "source" : [
                            {
                              "context" : "irisAnswer"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "locationEntry",
                              "contextType" : "variable",
                              "element" : "resource",
                              "variable" : "location",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Location"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "locationid",
                              "source" : [
                                {
                                  "context" : "irisAnswer"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "location",
                                  "contextType" : "variable",
                                  "element" : "id",
                                  "transform" : "uuid"
                                }
                              ]
                            },
                            {
                              "name" : "locationmeta",
                              "source" : [
                                {
                                  "context" : "irisAnswer"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "location",
                                  "contextType" : "variable",
                                  "element" : "meta",
                                  "variable" : "meta",
                                  "transform" : "create",
                                  "parameter" : [
                                    {
                                      "valueString" : "Meta"
                                    }
                                  ]
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "locationprofile",
                                  "source" : [
                                    {
                                      "context" : "irisAnswer"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "meta",
                                      "contextType" : "variable",
                                      "element" : "profile",
                                      "transform" : "copy",
                                      "parameter" : [
                                        {
                                          "valueString" : "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMLocation"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "setirisidentifier",
                              "source" : [
                                {
                                  "context" : "irisAnswer"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "location",
                                  "contextType" : "variable",
                                  "element" : "identifier",
                                  "variable" : "identifier",
                                  "transform" : "create",
                                  "parameter" : [
                                    {
                                      "valueString" : "Identifier"
                                    }
                                  ]
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "irissystem",
                                  "source" : [
                                    {
                                      "context" : "irisAnswer"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "identifier",
                                      "contextType" : "variable",
                                      "element" : "system",
                                      "transform" : "copy",
                                      "parameter" : [
                                        {
                                          "valueString" : "urn:oid:2.16.840.1.113883.2.8.1.5.5"
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "irisvalue",
                                  "source" : [
                                    {
                                      "context" : "irisAnswer"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "identifier",
                                      "contextType" : "variable",
                                      "element" : "value",
                                      "transform" : "evaluate",
                                      "parameter" : [
                                        {
                                          "valueString" : "irisAnswer.valueCoding.code"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "setrequest",
                              "source" : [
                                {
                                  "context" : "location"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "locationEntry",
                                  "contextType" : "variable",
                                  "element" : "request",
                                  "variable" : "request"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "setmethod",
                                  "source" : [
                                    {
                                      "context" : "location"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "request",
                                      "contextType" : "variable",
                                      "element" : "method",
                                      "transform" : "copy",
                                      "parameter" : [
                                        {
                                          "valueString" : "POST"
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "seturl",
                                  "source" : [
                                    {
                                      "context" : "location"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "request",
                                      "contextType" : "variable",
                                      "element" : "url",
                                      "transform" : "copy",
                                      "parameter" : [
                                        {
                                          "valueString" : "Location"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "setfullUrl",
                              "source" : [
                                {
                                  "context" : "location",
                                  "element" : "id",
                                  "variable" : "locId"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "locationEntry",
                                  "contextType" : "variable",
                                  "element" : "fullUrl",
                                  "transform" : "append",
                                  "parameter" : [
                                    {
                                      "valueString" : "urn:uuid:"
                                    },
                                    {
                                      "valueId" : "locId"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "CreateEncounters",
      "typeMode" : "none",
      "documentation" : "Group: Create Encounters from PMSI data",
      "input" : [
        {
          "name" : "src",
          "type" : "QuestionnaireResponse",
          "mode" : "source"
        },
        {
          "name" : "patient",
          "type" : "Patient",
          "mode" : "target"
        },
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "encounterentry",
          "source" : [
            {
              "context" : "src",
              "element" : "item",
              "variable" : "pmsiItem",
              "condition" : "(linkId = '2825244231605')"
            }
          ],
          "target" : [
            {
              "context" : "bundle",
              "contextType" : "variable",
              "element" : "entry",
              "variable" : "encounterEntry"
            }
          ],
          "rule" : [
            {
              "name" : "createencounter",
              "source" : [
                {
                  "context" : "pmsiItem"
                }
              ],
              "target" : [
                {
                  "context" : "encounterEntry",
                  "contextType" : "variable",
                  "element" : "resource",
                  "variable" : "encounter",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Encounter"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "encounterid",
                  "source" : [
                    {
                      "context" : "pmsiItem"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "encounter",
                      "contextType" : "variable",
                      "element" : "id",
                      "transform" : "uuid"
                    }
                  ]
                },
                {
                  "name" : "encountermeta",
                  "source" : [
                    {
                      "context" : "pmsiItem"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "encounter",
                      "contextType" : "variable",
                      "element" : "meta",
                      "variable" : "meta",
                      "transform" : "create",
                      "parameter" : [
                        {
                          "valueString" : "Meta"
                        }
                      ]
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "encounterprofile",
                      "source" : [
                        {
                          "context" : "pmsiItem"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "meta",
                          "contextType" : "variable",
                          "element" : "profile",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMEncounter"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "setsubject",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "encounter",
                      "contextType" : "variable",
                      "element" : "subject",
                      "variable" : "ref",
                      "transform" : "create",
                      "parameter" : [
                        {
                          "valueString" : "Reference"
                        }
                      ]
                    },
                    {
                      "context" : "patient",
                      "contextType" : "variable",
                      "element" : "id",
                      "variable" : "patId"
                    },
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "reference",
                      "transform" : "append",
                      "parameter" : [
                        {
                          "valueString" : "Patient/"
                        },
                        {
                          "valueId" : "patId"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "setperiod",
                  "source" : [
                    {
                      "context" : "pmsiItem"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "encounter",
                      "contextType" : "variable",
                      "element" : "period",
                      "variable" : "period",
                      "transform" : "create",
                      "parameter" : [
                        {
                          "valueString" : "Period"
                        }
                      ]
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "extractstart",
                      "source" : [
                        {
                          "context" : "pmsiItem",
                          "element" : "item",
                          "variable" : "startItem",
                          "condition" : "(linkId = '5991443718282')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "setstart",
                          "source" : [
                            {
                              "context" : "startItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "period",
                              "contextType" : "variable",
                              "element" : "start",
                              "transform" : "evaluate",
                              "parameter" : [
                                {
                                  "valueString" : "ans.valueDate"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "extractend",
                      "source" : [
                        {
                          "context" : "pmsiItem",
                          "element" : "item",
                          "variable" : "endItem",
                          "condition" : "(linkId = '6114780320846')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "setend",
                          "source" : [
                            {
                              "context" : "endItem",
                              "element" : "answer",
                              "variable" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "period",
                              "contextType" : "variable",
                              "element" : "end",
                              "transform" : "evaluate",
                              "parameter" : [
                                {
                                  "valueString" : "ans.valueDate"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extractmodein",
                  "source" : [
                    {
                      "context" : "pmsiItem",
                      "element" : "item",
                      "variable" : "modeInItem",
                      "condition" : "(linkId = '6172398101212')"
                    }
                  ]
                },
                {
                  "name" : "extractmodeout",
                  "source" : [
                    {
                      "context" : "pmsiItem",
                      "element" : "item",
                      "variable" : "modeOutItem",
                      "condition" : "(linkId = '3354867075704')"
                    }
                  ]
                },
                {
                  "name" : "setfullUrl",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "encounter",
                      "contextType" : "variable",
                      "element" : "id",
                      "variable" : "encId"
                    },
                    {
                      "context" : "encounterEntry",
                      "contextType" : "variable",
                      "element" : "fullUrl",
                      "transform" : "append",
                      "parameter" : [
                        {
                          "valueString" : "urn:uuid:"
                        },
                        {
                          "valueId" : "encId"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "createconditions",
                  "source" : [
                    {
                      "context" : "pmsiItem"
                    }
                  ],
                  "dependent" : [
                    {
                      "name" : "CreateConditions",
                      "variable" : ["pmsiItem", "patient", "encounter", "bundle"]
                    }
                  ]
                },
                {
                  "name" : "createprocedures",
                  "source" : [
                    {
                      "context" : "pmsiItem"
                    }
                  ],
                  "dependent" : [
                    {
                      "name" : "CreateProcedures",
                      "variable" : ["pmsiItem", "patient", "encounter", "bundle"]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "CreateConditions",
      "typeMode" : "none",
      "documentation" : "Group: Create Conditions from nested diagnostics",
      "input" : [
        {
          "name" : "pmsiItem",
          "mode" : "source"
        },
        {
          "name" : "patient",
          "type" : "Patient",
          "mode" : "target"
        },
        {
          "name" : "encounter",
          "type" : "Encounter",
          "mode" : "target"
        },
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "conditionentry",
          "source" : [
            {
              "context" : "pmsiItem",
              "element" : "item",
              "variable" : "diagGroup",
              "condition" : "(linkId = '9391816419630')"
            }
          ],
          "target" : [
            {
              "context" : "bundle",
              "contextType" : "variable",
              "element" : "entry",
              "variable" : "conditionEntry"
            }
          ],
          "rule" : [
            {
              "name" : "createcondition",
              "source" : [
                {
                  "context" : "diagGroup"
                }
              ],
              "target" : [
                {
                  "context" : "conditionEntry",
                  "contextType" : "variable",
                  "element" : "resource",
                  "variable" : "condition",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Condition"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "conditionid",
                  "source" : [
                    {
                      "context" : "diagGroup"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "condition",
                      "contextType" : "variable",
                      "element" : "id",
                      "transform" : "uuid"
                    }
                  ]
                },
                {
                  "name" : "conditionmeta",
                  "source" : [
                    {
                      "context" : "diagGroup"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "condition",
                      "contextType" : "variable",
                      "element" : "meta",
                      "variable" : "meta",
                      "transform" : "create",
                      "parameter" : [
                        {
                          "valueString" : "Meta"
                        }
                      ]
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "conditionprofile",
                      "source" : [
                        {
                          "context" : "diagGroup"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "meta",
                          "contextType" : "variable",
                          "element" : "profile",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMCondition"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "setsubject",
                  "source" : [
                    {
                      "context" : "diagGroup"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "condition",
                      "contextType" : "variable",
                      "element" : "subject",
                      "variable" : "ref",
                      "transform" : "create",
                      "parameter" : [
                        {
                          "valueString" : "Reference"
                        }
                      ]
                    },
                    {
                      "context" : "patient",
                      "contextType" : "variable",
                      "element" : "id",
                      "variable" : "patId"
                    },
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "reference",
                      "transform" : "append",
                      "parameter" : [
                        {
                          "valueString" : "Patient/"
                        },
                        {
                          "valueId" : "patId"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "setencounter",
                  "source" : [
                    {
                      "context" : "diagGroup"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "encounter",
                      "contextType" : "variable",
                      "element" : "id",
                      "variable" : "encId"
                    },
                    {
                      "context" : "condition",
                      "contextType" : "variable",
                      "element" : "encounter",
                      "variable" : "ref",
                      "transform" : "create",
                      "parameter" : [
                        {
                          "valueString" : "Reference"
                        }
                      ]
                    },
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "reference",
                      "transform" : "append",
                      "parameter" : [
                        {
                          "valueString" : "Encounter/"
                        },
                        {
                          "valueId" : "encId"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extractdiagcode",
                  "source" : [
                    {
                      "context" : "diagGroup",
                      "element" : "item",
                      "variable" : "diagCodeItem",
                      "condition" : "(linkId = '5505101189372')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "setcode",
                      "source" : [
                        {
                          "context" : "diagCodeItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "condition",
                          "contextType" : "variable",
                          "element" : "code",
                          "variable" : "code",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "CodeableConcept"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "setcoding",
                          "source" : [
                            {
                              "context" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "code",
                              "contextType" : "variable",
                              "element" : "coding",
                              "transform" : "evaluate",
                              "parameter" : [
                                {
                                  "valueString" : "ans.valueCoding"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extractdiagtype",
                  "source" : [
                    {
                      "context" : "diagGroup",
                      "element" : "item",
                      "variable" : "diagTypeItem",
                      "condition" : "(linkId = '6427586743735')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "setcategory",
                      "source" : [
                        {
                          "context" : "diagTypeItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "condition",
                          "contextType" : "variable",
                          "element" : "category",
                          "variable" : "category",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "CodeableConcept"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "setcategorycoding",
                          "source" : [
                            {
                              "context" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "category",
                              "contextType" : "variable",
                              "element" : "coding",
                              "variable" : "coding",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Coding"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "diagtypesystem",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "coding",
                                  "contextType" : "variable",
                                  "element" : "system",
                                  "transform" : "copy",
                                  "parameter" : [
                                    {
                                      "valueString" : "https://interop.aphp.fr/ig/fhir/dm/CodeSystem/pmsi-mco-diag-type"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "diagtypecode",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "coding",
                                  "contextType" : "variable",
                                  "element" : "code",
                                  "transform" : "evaluate",
                                  "parameter" : [
                                    {
                                      "valueString" : "ans.valueCoding.code"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "diagtypedisplay",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "coding",
                                  "contextType" : "variable",
                                  "element" : "display",
                                  "transform" : "evaluate",
                                  "parameter" : [
                                    {
                                      "valueString" : "ans.valueCoding.display"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extractrecordeddate",
                  "source" : [
                    {
                      "context" : "diagGroup",
                      "element" : "item",
                      "variable" : "dateItem",
                      "condition" : "(linkId = '7114466839467')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "setrecordeddate",
                      "source" : [
                        {
                          "context" : "dateItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "condition",
                          "contextType" : "variable",
                          "element" : "recordedDate",
                          "transform" : "evaluate",
                          "parameter" : [
                            {
                              "valueString" : "ans.valueDate"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "CreateProcedures",
      "typeMode" : "none",
      "documentation" : "Group: Create Procedures from nested actes",
      "input" : [
        {
          "name" : "pmsiItem",
          "mode" : "source"
        },
        {
          "name" : "patient",
          "type" : "Patient",
          "mode" : "target"
        },
        {
          "name" : "encounter",
          "type" : "Encounter",
          "mode" : "target"
        },
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "procedureentry",
          "source" : [
            {
              "context" : "pmsiItem",
              "element" : "item",
              "variable" : "acteGroup",
              "condition" : "(linkId = '591926901726')"
            }
          ],
          "target" : [
            {
              "context" : "bundle",
              "contextType" : "variable",
              "element" : "entry",
              "variable" : "procedureEntry"
            }
          ],
          "rule" : [
            {
              "name" : "createprocedure",
              "source" : [
                {
                  "context" : "acteGroup"
                }
              ],
              "target" : [
                {
                  "context" : "procedureEntry",
                  "contextType" : "variable",
                  "element" : "resource",
                  "variable" : "procedure",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Procedure"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "procedureid",
                  "source" : [
                    {
                      "context" : "acteGroup"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "procedure",
                      "contextType" : "variable",
                      "element" : "id",
                      "transform" : "uuid"
                    }
                  ]
                },
                {
                  "name" : "proceduremeta",
                  "source" : [
                    {
                      "context" : "acteGroup"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "procedure",
                      "contextType" : "variable",
                      "element" : "meta",
                      "variable" : "meta",
                      "transform" : "create",
                      "parameter" : [
                        {
                          "valueString" : "Meta"
                        }
                      ]
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "procedureprofile",
                      "source" : [
                        {
                          "context" : "acteGroup"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "meta",
                          "contextType" : "variable",
                          "element" : "profile",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMProcedure"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "setsubject",
                  "source" : [
                    {
                      "context" : "acteGroup"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "procedure",
                      "contextType" : "variable",
                      "element" : "subject",
                      "variable" : "ref",
                      "transform" : "create",
                      "parameter" : [
                        {
                          "valueString" : "Reference"
                        }
                      ]
                    },
                    {
                      "context" : "patient",
                      "contextType" : "variable",
                      "element" : "id",
                      "variable" : "patId"
                    },
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "reference",
                      "transform" : "append",
                      "parameter" : [
                        {
                          "valueString" : "Patient/"
                        },
                        {
                          "valueId" : "patId"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "setencounter",
                  "source" : [
                    {
                      "context" : "acteGroup"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "encounter",
                      "contextType" : "variable",
                      "element" : "id",
                      "variable" : "encId"
                    },
                    {
                      "context" : "procedure",
                      "contextType" : "variable",
                      "element" : "encounter",
                      "variable" : "ref",
                      "transform" : "create",
                      "parameter" : [
                        {
                          "valueString" : "Reference"
                        }
                      ]
                    },
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "reference",
                      "transform" : "append",
                      "parameter" : [
                        {
                          "valueString" : "Encounter/"
                        },
                        {
                          "valueId" : "encId"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extractactecode",
                  "source" : [
                    {
                      "context" : "acteGroup",
                      "element" : "item",
                      "variable" : "acteCodeItem",
                      "condition" : "(linkId = '7758110033600')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "setcode",
                      "source" : [
                        {
                          "context" : "acteCodeItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "procedure",
                          "contextType" : "variable",
                          "element" : "code",
                          "variable" : "code",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "CodeableConcept"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "setcoding",
                          "source" : [
                            {
                              "context" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "code",
                              "contextType" : "variable",
                              "element" : "coding",
                              "transform" : "evaluate",
                              "parameter" : [
                                {
                                  "valueString" : "ans.valueCoding"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extractperformeddate",
                  "source" : [
                    {
                      "context" : "acteGroup",
                      "element" : "item",
                      "variable" : "dateItem",
                      "condition" : "(linkId = '5066866286682')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "setperformed",
                      "source" : [
                        {
                          "context" : "dateItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "procedure",
                          "contextType" : "variable",
                          "element" : "performed",
                          "transform" : "evaluate",
                          "parameter" : [
                            {
                              "valueString" : "ans.valueDateTime"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "CreateMedicationRequests",
      "typeMode" : "none",
      "documentation" : "Group: Create Medication Requests",
      "input" : [
        {
          "name" : "src",
          "type" : "QuestionnaireResponse",
          "mode" : "source"
        },
        {
          "name" : "patient",
          "type" : "Patient",
          "mode" : "target"
        },
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "processmedexpo",
          "source" : [
            {
              "context" : "src",
              "element" : "item",
              "variable" : "medExpoGroup",
              "condition" : "(linkId = '817801935685')"
            }
          ],
          "rule" : [
            {
              "name" : "medreqentry",
              "source" : [
                {
                  "context" : "medExpoGroup",
                  "element" : "item",
                  "variable" : "prescribedGroup",
                  "condition" : "(linkId = '156631794800')"
                }
              ],
              "target" : [
                {
                  "context" : "bundle",
                  "contextType" : "variable",
                  "element" : "entry",
                  "variable" : "medReqEntry"
                }
              ],
              "rule" : [
                {
                  "name" : "createmedreq",
                  "source" : [
                    {
                      "context" : "prescribedGroup"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "medReqEntry",
                      "contextType" : "variable",
                      "element" : "resource",
                      "variable" : "medReq",
                      "transform" : "create",
                      "parameter" : [
                        {
                          "valueString" : "MedicationRequest"
                        }
                      ]
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "medreqid",
                      "source" : [
                        {
                          "context" : "prescribedGroup"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "medReq",
                          "contextType" : "variable",
                          "element" : "id",
                          "transform" : "uuid"
                        }
                      ]
                    },
                    {
                      "name" : "medreqmeta",
                      "source" : [
                        {
                          "context" : "prescribedGroup"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "medReq",
                          "contextType" : "variable",
                          "element" : "meta",
                          "variable" : "meta",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Meta"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "medreqprofile",
                          "source" : [
                            {
                              "context" : "prescribedGroup"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "meta",
                              "contextType" : "variable",
                              "element" : "profile",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueString" : "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMMedicationRequest"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "setsubject",
                      "source" : [
                        {
                          "context" : "prescribedGroup"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "medReq",
                          "contextType" : "variable",
                          "element" : "subject",
                          "variable" : "ref",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Reference"
                            }
                          ]
                        },
                        {
                          "context" : "patient",
                          "contextType" : "variable",
                          "element" : "id",
                          "variable" : "patId"
                        },
                        {
                          "context" : "ref",
                          "contextType" : "variable",
                          "element" : "reference",
                          "transform" : "append",
                          "parameter" : [
                            {
                              "valueString" : "Patient/"
                            },
                            {
                              "valueId" : "patId"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "setstatus",
                      "source" : [
                        {
                          "context" : "prescribedGroup"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "medReq",
                          "contextType" : "variable",
                          "element" : "status",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "active"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "setintent",
                      "source" : [
                        {
                          "context" : "prescribedGroup"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "medReq",
                          "contextType" : "variable",
                          "element" : "intent",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "order"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "medicationentry",
                      "source" : [
                        {
                          "context" : "prescribedGroup"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable",
                          "element" : "entry",
                          "variable" : "medEntry"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createmedication",
                          "source" : [
                            {
                              "context" : "prescribedGroup"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "medEntry",
                              "contextType" : "variable",
                              "element" : "resource",
                              "variable" : "medication",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Medication"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "medid",
                              "source" : [
                                {
                                  "context" : "prescribedGroup"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "medication",
                                  "contextType" : "variable",
                                  "element" : "id",
                                  "transform" : "uuid"
                                }
                              ]
                            },
                            {
                              "name" : "extractatc",
                              "source" : [
                                {
                                  "context" : "prescribedGroup",
                                  "element" : "item",
                                  "variable" : "atcItem",
                                  "condition" : "(linkId.contains('ATC'))"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "setmedcode",
                                  "source" : [
                                    {
                                      "context" : "atcItem",
                                      "element" : "answer",
                                      "variable" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "medication",
                                      "contextType" : "variable",
                                      "element" : "code",
                                      "variable" : "code",
                                      "transform" : "create",
                                      "parameter" : [
                                        {
                                          "valueString" : "CodeableConcept"
                                        }
                                      ]
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "setatccoding",
                                      "source" : [
                                        {
                                          "context" : "ans"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "code",
                                          "contextType" : "variable",
                                          "element" : "coding",
                                          "transform" : "evaluate",
                                          "parameter" : [
                                            {
                                              "valueString" : "ans.valueCoding"
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "setfullUrl",
                              "source" : [
                                {
                                  "context" : "prescribedGroup"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "medication",
                                  "contextType" : "variable",
                                  "element" : "id",
                                  "variable" : "medId"
                                },
                                {
                                  "context" : "medEntry",
                                  "contextType" : "variable",
                                  "element" : "fullUrl",
                                  "transform" : "append",
                                  "parameter" : [
                                    {
                                      "valueString" : "urn:uuid:"
                                    },
                                    {
                                      "valueId" : "medId"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "setmedicationreference",
                              "source" : [
                                {
                                  "context" : "prescribedGroup"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "medication",
                                  "contextType" : "variable",
                                  "element" : "id",
                                  "variable" : "medId"
                                },
                                {
                                  "context" : "medReq",
                                  "contextType" : "variable",
                                  "element" : "medication",
                                  "variable" : "ref",
                                  "transform" : "create",
                                  "parameter" : [
                                    {
                                      "valueString" : "Reference"
                                    }
                                  ]
                                },
                                {
                                  "context" : "ref",
                                  "contextType" : "variable",
                                  "element" : "reference",
                                  "transform" : "append",
                                  "parameter" : [
                                    {
                                      "valueString" : "Medication/"
                                    },
                                    {
                                      "valueId" : "medId"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "setdosage",
                      "source" : [
                        {
                          "context" : "prescribedGroup"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "medReq",
                          "contextType" : "variable",
                          "element" : "dosageInstruction",
                          "variable" : "dosage",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Dosage"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "extractroute",
                          "source" : [
                            {
                              "context" : "prescribedGroup",
                              "element" : "item",
                              "variable" : "routeItem",
                              "condition" : "(linkId.contains('voie'))"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "setroute",
                              "source" : [
                                {
                                  "context" : "routeItem",
                                  "element" : "answer",
                                  "variable" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "dosage",
                                  "contextType" : "variable",
                                  "element" : "route",
                                  "variable" : "route",
                                  "transform" : "create",
                                  "parameter" : [
                                    {
                                      "valueString" : "CodeableConcept"
                                    }
                                  ]
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "setroutecoding",
                                  "source" : [
                                    {
                                      "context" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "route",
                                      "contextType" : "variable",
                                      "element" : "coding",
                                      "transform" : "evaluate",
                                      "parameter" : [
                                        {
                                          "valueString" : "ans.valueCoding"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "extracttiming",
                          "source" : [
                            {
                              "context" : "prescribedGroup",
                              "element" : "item",
                              "variable" : "timingItem",
                              "condition" : "(linkId.contains('timing') or linkId.contains('fréquence'))"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "settimingstructure",
                              "source" : [
                                {
                                  "context" : "timingItem",
                                  "element" : "answer",
                                  "variable" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "dosage",
                                  "contextType" : "variable",
                                  "element" : "timing",
                                  "variable" : "timing",
                                  "transform" : "create",
                                  "parameter" : [
                                    {
                                      "valueString" : "Timing"
                                    }
                                  ]
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "settiming",
                                  "source" : [
                                    {
                                      "context" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "timing",
                                      "contextType" : "variable",
                                      "element" : "repeat",
                                      "variable" : "repeat",
                                      "transform" : "create",
                                      "parameter" : [
                                        {
                                          "valueString" : "TimingRepeat"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "CreateMedicationAdministrations",
      "typeMode" : "none",
      "documentation" : "Group: Create Medication Administrations",
      "input" : [
        {
          "name" : "src",
          "type" : "QuestionnaireResponse",
          "mode" : "source"
        },
        {
          "name" : "patient",
          "type" : "Patient",
          "mode" : "target"
        },
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "processmedexpoadmin",
          "source" : [
            {
              "context" : "src",
              "element" : "item",
              "variable" : "medExpoGroup",
              "condition" : "(linkId = '817801935685')"
            }
          ],
          "rule" : [
            {
              "name" : "medadminentry",
              "source" : [
                {
                  "context" : "medExpoGroup",
                  "element" : "item",
                  "variable" : "adminGroup",
                  "condition" : "(linkId = '266852453304')"
                }
              ],
              "target" : [
                {
                  "context" : "bundle",
                  "contextType" : "variable",
                  "element" : "entry",
                  "variable" : "medAdminEntry"
                }
              ],
              "rule" : [
                {
                  "name" : "createmedadmin",
                  "source" : [
                    {
                      "context" : "adminGroup"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "medAdminEntry",
                      "contextType" : "variable",
                      "element" : "resource",
                      "variable" : "medAdmin",
                      "transform" : "create",
                      "parameter" : [
                        {
                          "valueString" : "MedicationAdministration"
                        }
                      ]
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "medadminid",
                      "source" : [
                        {
                          "context" : "adminGroup"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "medAdmin",
                          "contextType" : "variable",
                          "element" : "id",
                          "transform" : "uuid"
                        }
                      ]
                    },
                    {
                      "name" : "medadminmeta",
                      "source" : [
                        {
                          "context" : "adminGroup"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "medAdmin",
                          "contextType" : "variable",
                          "element" : "meta",
                          "variable" : "meta",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Meta"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "medadminprofile",
                          "source" : [
                            {
                              "context" : "adminGroup"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "meta",
                              "contextType" : "variable",
                              "element" : "profile",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueString" : "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMMedicationAdministration"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "setsubject",
                      "source" : [
                        {
                          "context" : "adminGroup"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "medAdmin",
                          "contextType" : "variable",
                          "element" : "subject",
                          "variable" : "ref",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Reference"
                            }
                          ]
                        },
                        {
                          "context" : "patient",
                          "contextType" : "variable",
                          "element" : "id",
                          "variable" : "patId"
                        },
                        {
                          "context" : "ref",
                          "contextType" : "variable",
                          "element" : "reference",
                          "transform" : "append",
                          "parameter" : [
                            {
                              "valueString" : "Patient/"
                            },
                            {
                              "valueId" : "patId"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "setstatus",
                      "source" : [
                        {
                          "context" : "adminGroup"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "medAdmin",
                          "contextType" : "variable",
                          "element" : "status",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "completed"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "medicationentry",
                      "source" : [
                        {
                          "context" : "adminGroup"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable",
                          "element" : "entry",
                          "variable" : "medEntry"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createmedication",
                          "source" : [
                            {
                              "context" : "adminGroup"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "medEntry",
                              "contextType" : "variable",
                              "element" : "resource",
                              "variable" : "medication",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Medication"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "medid",
                              "source" : [
                                {
                                  "context" : "adminGroup"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "medication",
                                  "contextType" : "variable",
                                  "element" : "id",
                                  "transform" : "uuid"
                                }
                              ]
                            },
                            {
                              "name" : "extractatc",
                              "source" : [
                                {
                                  "context" : "adminGroup",
                                  "element" : "item",
                                  "variable" : "atcItem",
                                  "condition" : "(linkId.contains('ATC'))"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "setmedcode",
                                  "source" : [
                                    {
                                      "context" : "atcItem",
                                      "element" : "answer",
                                      "variable" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "medication",
                                      "contextType" : "variable",
                                      "element" : "code",
                                      "variable" : "code",
                                      "transform" : "create",
                                      "parameter" : [
                                        {
                                          "valueString" : "CodeableConcept"
                                        }
                                      ]
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "setatccoding",
                                      "source" : [
                                        {
                                          "context" : "ans"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "code",
                                          "contextType" : "variable",
                                          "element" : "coding",
                                          "transform" : "evaluate",
                                          "parameter" : [
                                            {
                                              "valueString" : "ans.valueCoding"
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "setfullUrl",
                              "source" : [
                                {
                                  "context" : "adminGroup"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "medication",
                                  "contextType" : "variable",
                                  "element" : "id",
                                  "variable" : "medId"
                                },
                                {
                                  "context" : "medEntry",
                                  "contextType" : "variable",
                                  "element" : "fullUrl",
                                  "transform" : "append",
                                  "parameter" : [
                                    {
                                      "valueString" : "Medication/"
                                    },
                                    {
                                      "valueId" : "medId"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "setmedicationreference",
                              "source" : [
                                {
                                  "context" : "adminGroup"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "medication",
                                  "contextType" : "variable",
                                  "element" : "id",
                                  "variable" : "medId"
                                },
                                {
                                  "context" : "medAdmin",
                                  "contextType" : "variable",
                                  "element" : "medication",
                                  "variable" : "ref",
                                  "transform" : "create",
                                  "parameter" : [
                                    {
                                      "valueString" : "Reference"
                                    }
                                  ]
                                },
                                {
                                  "context" : "ref",
                                  "contextType" : "variable",
                                  "element" : "reference",
                                  "transform" : "append",
                                  "parameter" : [
                                    {
                                      "valueString" : "urn:uuid:"
                                    },
                                    {
                                      "valueId" : "medId"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "seteffective",
                      "source" : [
                        {
                          "context" : "adminGroup"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "medAdmin",
                          "contextType" : "variable",
                          "element" : "effective",
                          "variable" : "period",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Period"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "extractstart",
                          "source" : [
                            {
                              "context" : "adminGroup",
                              "element" : "item",
                              "variable" : "startItem",
                              "condition" : "(linkId.contains('début'))"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "setstart",
                              "source" : [
                                {
                                  "context" : "startItem",
                                  "element" : "answer",
                                  "variable" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "period",
                                  "contextType" : "variable",
                                  "element" : "start",
                                  "transform" : "evaluate",
                                  "parameter" : [
                                    {
                                      "valueString" : "ans.valueDateTime"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "extractend",
                          "source" : [
                            {
                              "context" : "adminGroup",
                              "element" : "item",
                              "variable" : "endItem",
                              "condition" : "(linkId.contains('fin'))"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "setend",
                              "source" : [
                                {
                                  "context" : "endItem",
                                  "element" : "answer",
                                  "variable" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "period",
                                  "contextType" : "variable",
                                  "element" : "end",
                                  "transform" : "evaluate",
                                  "parameter" : [
                                    {
                                      "valueString" : "ans.valueDateTime"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "setdosage",
                      "source" : [
                        {
                          "context" : "adminGroup"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "medAdmin",
                          "contextType" : "variable",
                          "element" : "dosage",
                          "variable" : "dosage",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Dosage"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "extractroute",
                          "source" : [
                            {
                              "context" : "adminGroup",
                              "element" : "item",
                              "variable" : "routeItem",
                              "condition" : "(linkId.contains('voie'))"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "setroute",
                              "source" : [
                                {
                                  "context" : "routeItem",
                                  "element" : "answer",
                                  "variable" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "dosage",
                                  "contextType" : "variable",
                                  "element" : "route",
                                  "variable" : "route",
                                  "transform" : "create",
                                  "parameter" : [
                                    {
                                      "valueString" : "CodeableConcept"
                                    }
                                  ]
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "setroutecoding",
                                  "source" : [
                                    {
                                      "context" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "route",
                                      "contextType" : "variable",
                                      "element" : "coding",
                                      "transform" : "evaluate",
                                      "parameter" : [
                                        {
                                          "valueString" : "ans.valueCoding"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "extractdose",
                          "source" : [
                            {
                              "context" : "adminGroup",
                              "element" : "item",
                              "variable" : "doseItem",
                              "condition" : "(linkId.contains('dose'))"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "setdose",
                              "source" : [
                                {
                                  "context" : "doseItem",
                                  "element" : "answer",
                                  "variable" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "dosage",
                                  "contextType" : "variable",
                                  "element" : "dose",
                                  "transform" : "evaluate",
                                  "parameter" : [
                                    {
                                      "valueString" : "ans.valueQuantity"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "CreateVitalSignObservations",
      "typeMode" : "none",
      "documentation" : "Group: Create Vital Sign Observations",
      "input" : [
        {
          "name" : "src",
          "type" : "QuestionnaireResponse",
          "mode" : "source"
        },
        {
          "name" : "patient",
          "type" : "Patient",
          "mode" : "target"
        },
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "processexam",
          "source" : [
            {
              "context" : "src",
              "element" : "item",
              "variable" : "examGroup",
              "condition" : "(linkId = '214880328197')"
            }
          ],
          "rule" : [
            {
              "name" : "processdossier",
              "source" : [
                {
                  "context" : "examGroup",
                  "element" : "item",
                  "variable" : "dossierGroup",
                  "condition" : "(linkId = '305831246173')"
                }
              ],
              "rule" : [
                {
                  "name" : "extractheight",
                  "source" : [
                    {
                      "context" : "dossierGroup",
                      "element" : "item",
                      "variable" : "heightItem",
                      "condition" : "(linkId = '4846902346416')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "heightobsentry",
                      "source" : [
                        {
                          "context" : "heightItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable",
                          "element" : "entry",
                          "variable" : "obsEntry"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createheightobs",
                          "source" : [
                            {
                              "context" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "obsEntry",
                              "contextType" : "variable",
                              "element" : "resource",
                              "variable" : "obs",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Observation"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "obsid",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "obs",
                                  "contextType" : "variable",
                                  "element" : "id",
                                  "transform" : "uuid"
                                }
                              ]
                            },
                            {
                              "name" : "setfullUrl",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "obs",
                                  "contextType" : "variable",
                                  "element" : "id",
                                  "variable" : "obsId"
                                },
                                {
                                  "context" : "obsEntry",
                                  "contextType" : "variable",
                                  "element" : "fullUrl",
                                  "transform" : "append",
                                  "parameter" : [
                                    {
                                      "valueString" : "urn:uuid:"
                                    },
                                    {
                                      "valueId" : "obsId"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "obsmeta",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "obs",
                                  "contextType" : "variable",
                                  "element" : "meta",
                                  "variable" : "meta",
                                  "transform" : "create",
                                  "parameter" : [
                                    {
                                      "valueString" : "Meta"
                                    }
                                  ]
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "obsprofile",
                                  "source" : [
                                    {
                                      "context" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "meta",
                                      "contextType" : "variable",
                                      "element" : "profile",
                                      "transform" : "copy",
                                      "parameter" : [
                                        {
                                          "valueString" : "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMObservationBodyHeight"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "obsstatus",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "obs",
                                  "contextType" : "variable",
                                  "element" : "status",
                                  "transform" : "copy",
                                  "parameter" : [
                                    {
                                      "valueString" : "final"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "obscategory",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "obs",
                                  "contextType" : "variable",
                                  "element" : "category",
                                  "transform" : "cc",
                                  "parameter" : [
                                    {
                                      "valueString" : "http://terminology.hl7.org/CodeSystem/observation-category"
                                    },
                                    {
                                      "valueString" : "vital-signs"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "obscode",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "obs",
                                  "contextType" : "variable",
                                  "element" : "code",
                                  "transform" : "cc",
                                  "parameter" : [
                                    {
                                      "valueString" : "http://loinc.org"
                                    },
                                    {
                                      "valueString" : "8302-2"
                                    },
                                    {
                                      "valueString" : "Body height"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "setsubject",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "obs",
                                  "contextType" : "variable",
                                  "element" : "subject",
                                  "variable" : "ref",
                                  "transform" : "create",
                                  "parameter" : [
                                    {
                                      "valueString" : "Reference"
                                    }
                                  ]
                                },
                                {
                                  "context" : "patient",
                                  "contextType" : "variable",
                                  "element" : "id",
                                  "variable" : "patId"
                                },
                                {
                                  "context" : "ref",
                                  "contextType" : "variable",
                                  "element" : "reference",
                                  "transform" : "append",
                                  "parameter" : [
                                    {
                                      "valueString" : "Patient/"
                                    },
                                    {
                                      "valueId" : "patId"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "setvalue",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "obs",
                                  "contextType" : "variable",
                                  "element" : "value",
                                  "transform" : "evaluate",
                                  "parameter" : [
                                    {
                                      "valueString" : "ans.valueQuantity"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "extracteffective",
                              "source" : [
                                {
                                  "context" : "heightItem",
                                  "element" : "item",
                                  "variable" : "dateItem",
                                  "condition" : "(linkId.contains('Date'))"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "seteffective",
                                  "source" : [
                                    {
                                      "context" : "dateItem",
                                      "element" : "answer",
                                      "variable" : "dateAns"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "obs",
                                      "contextType" : "variable",
                                      "element" : "effective",
                                      "transform" : "evaluate",
                                      "parameter" : [
                                        {
                                          "valueString" : "dateAns.valueDate"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extractweight",
                  "source" : [
                    {
                      "context" : "dossierGroup",
                      "element" : "item",
                      "variable" : "weightItem",
                      "condition" : "(linkId = '451513217936')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "weightobsentry",
                      "source" : [
                        {
                          "context" : "weightItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable",
                          "element" : "entry",
                          "variable" : "obsEntry"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "createweightobs",
                          "source" : [
                            {
                              "context" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "obsEntry",
                              "contextType" : "variable",
                              "element" : "resource",
                              "variable" : "obs",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Observation"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "obsid",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "obs",
                                  "contextType" : "variable",
                                  "element" : "id",
                                  "transform" : "uuid"
                                }
                              ]
                            },
                            {
                              "name" : "setfullUrl",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "obs",
                                  "contextType" : "variable",
                                  "element" : "id",
                                  "variable" : "obsId"
                                },
                                {
                                  "context" : "obsEntry",
                                  "contextType" : "variable",
                                  "element" : "fullUrl",
                                  "transform" : "append",
                                  "parameter" : [
                                    {
                                      "valueString" : "urn:uuid:"
                                    },
                                    {
                                      "valueId" : "obsId"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "obsmeta",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "obs",
                                  "contextType" : "variable",
                                  "element" : "meta",
                                  "variable" : "meta",
                                  "transform" : "create",
                                  "parameter" : [
                                    {
                                      "valueString" : "Meta"
                                    }
                                  ]
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "obsprofile",
                                  "source" : [
                                    {
                                      "context" : "ans"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "meta",
                                      "contextType" : "variable",
                                      "element" : "profile",
                                      "transform" : "copy",
                                      "parameter" : [
                                        {
                                          "valueString" : "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMObservationBodyWeight"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "obsstatus",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "obs",
                                  "contextType" : "variable",
                                  "element" : "status",
                                  "transform" : "copy",
                                  "parameter" : [
                                    {
                                      "valueString" : "final"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "obscategory",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "obs",
                                  "contextType" : "variable",
                                  "element" : "category",
                                  "transform" : "cc",
                                  "parameter" : [
                                    {
                                      "valueString" : "http://terminology.hl7.org/CodeSystem/observation-category"
                                    },
                                    {
                                      "valueString" : "vital-signs"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "obscode",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "obs",
                                  "contextType" : "variable",
                                  "element" : "code",
                                  "transform" : "cc",
                                  "parameter" : [
                                    {
                                      "valueString" : "http://loinc.org"
                                    },
                                    {
                                      "valueString" : "29463-7"
                                    },
                                    {
                                      "valueString" : "Body weight"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "setsubject",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "obs",
                                  "contextType" : "variable",
                                  "element" : "subject",
                                  "variable" : "ref",
                                  "transform" : "create",
                                  "parameter" : [
                                    {
                                      "valueString" : "Reference"
                                    }
                                  ]
                                },
                                {
                                  "context" : "patient",
                                  "contextType" : "variable",
                                  "element" : "id",
                                  "variable" : "patId"
                                },
                                {
                                  "context" : "ref",
                                  "contextType" : "variable",
                                  "element" : "reference",
                                  "transform" : "append",
                                  "parameter" : [
                                    {
                                      "valueString" : "Patient/"
                                    },
                                    {
                                      "valueId" : "patId"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "setvalue",
                              "source" : [
                                {
                                  "context" : "ans"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "obs",
                                  "contextType" : "variable",
                                  "element" : "value",
                                  "transform" : "evaluate",
                                  "parameter" : [
                                    {
                                      "valueString" : "ans.valueQuantity"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "extracteffective",
                              "source" : [
                                {
                                  "context" : "weightItem",
                                  "element" : "item",
                                  "variable" : "dateItem",
                                  "condition" : "(linkId.contains('Date'))"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "seteffective",
                                  "source" : [
                                    {
                                      "context" : "dateItem",
                                      "element" : "answer",
                                      "variable" : "dateAns"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "obs",
                                      "contextType" : "variable",
                                      "element" : "effective",
                                      "transform" : "evaluate",
                                      "parameter" : [
                                        {
                                          "valueString" : "dateAns.valueDate"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extractbloodpressure",
                  "source" : [
                    {
                      "context" : "dossierGroup",
                      "element" : "item",
                      "variable" : "sysItem",
                      "condition" : "(linkId = '4160905247955')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "processsystolic",
                      "source" : [
                        {
                          "context" : "sysItem",
                          "element" : "answer",
                          "variable" : "sysAns"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "extractdiastolic",
                          "source" : [
                            {
                              "context" : "dossierGroup",
                              "element" : "item",
                              "variable" : "diaItem",
                              "condition" : "(linkId = '848797127998')"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "bpobsentr",
                              "source" : [
                                {
                                  "context" : "diaItem",
                                  "element" : "answer",
                                  "variable" : "diaAns"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "bundle",
                                  "contextType" : "variable",
                                  "element" : "entry",
                                  "variable" : "obsEntry"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "createbpobs",
                                  "source" : [
                                    {
                                      "context" : "sysAns"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "obsEntry",
                                      "contextType" : "variable",
                                      "element" : "resource",
                                      "variable" : "obs",
                                      "transform" : "create",
                                      "parameter" : [
                                        {
                                          "valueString" : "Observation"
                                        }
                                      ]
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "obsid",
                                      "source" : [
                                        {
                                          "context" : "sysAns"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "obs",
                                          "contextType" : "variable",
                                          "element" : "id",
                                          "transform" : "uuid"
                                        }
                                      ]
                                    },
                                    {
                                      "name" : "setfullUrl",
                                      "source" : [
                                        {
                                          "context" : "sysAns"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "obs",
                                          "contextType" : "variable",
                                          "element" : "id",
                                          "variable" : "obsId"
                                        },
                                        {
                                          "context" : "obsEntry",
                                          "contextType" : "variable",
                                          "element" : "fullUrl",
                                          "transform" : "append",
                                          "parameter" : [
                                            {
                                              "valueString" : "urn:uuid:"
                                            },
                                            {
                                              "valueId" : "obsId"
                                            }
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "name" : "obsmeta",
                                      "source" : [
                                        {
                                          "context" : "sysAns"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "obs",
                                          "contextType" : "variable",
                                          "element" : "meta",
                                          "variable" : "meta",
                                          "transform" : "create",
                                          "parameter" : [
                                            {
                                              "valueString" : "Meta"
                                            }
                                          ]
                                        }
                                      ],
                                      "rule" : [
                                        {
                                          "name" : "obsprofile",
                                          "source" : [
                                            {
                                              "context" : "sysAns"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "meta",
                                              "contextType" : "variable",
                                              "element" : "profile",
                                              "transform" : "copy",
                                              "parameter" : [
                                                {
                                                  "valueString" : "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/DMObservationBloodPressure"
                                                }
                                              ]
                                            }
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "name" : "obsstatus",
                                      "source" : [
                                        {
                                          "context" : "sysAns"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "obs",
                                          "contextType" : "variable",
                                          "element" : "status",
                                          "transform" : "copy",
                                          "parameter" : [
                                            {
                                              "valueString" : "final"
                                            }
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "name" : "obscategory",
                                      "source" : [
                                        {
                                          "context" : "sysAns"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "obs",
                                          "contextType" : "variable",
                                          "element" : "category",
                                          "transform" : "cc",
                                          "parameter" : [
                                            {
                                              "valueString" : "http://terminology.hl7.org/CodeSystem/observation-category"
                                            },
                                            {
                                              "valueString" : "vital-signs"
                                            }
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "name" : "obscode",
                                      "source" : [
                                        {
                                          "context" : "sysAns"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "obs",
                                          "contextType" : "variable",
                                          "element" : "code",
                                          "transform" : "cc",
                                          "parameter" : [
                                            {
                                              "valueString" : "http://loinc.org"
                                            },
                                            {
                                              "valueString" : "85354-9"
                                            },
                                            {
                                              "valueString" : "Blood pressure panel"
                                            }
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "name" : "setsubject",
                                      "source" : [
                                        {
                                          "context" : "sysAns"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "obs",
                                          "contextType" : "variable",
                                          "element" : "subject",
                                          "variable" : "ref",
                                          "transform" : "create",
                                          "parameter" : [
                                            {
                                              "valueString" : "Reference"
                                            }
                                          ]
                                        },
                                        {
                                          "context" : "patient",
                                          "contextType" : "variable",
                                          "element" : "id",
                                          "variable" : "patId"
                                        },
                                        {
                                          "context" : "ref",
                                          "contextType" : "variable",
                                          "element" : "reference",
                                          "transform" : "append",
                                          "parameter" : [
                                            {
                                              "valueString" : "Patient/"
                                            },
                                            {
                                              "valueId" : "patId"
                                            }
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "name" : "setsystolic",
                                      "source" : [
                                        {
                                          "context" : "sysAns"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "obs",
                                          "contextType" : "variable",
                                          "element" : "component",
                                          "variable" : "sysComp",
                                          "transform" : "create",
                                          "parameter" : [
                                            {
                                              "valueString" : "Observation"
                                            }
                                          ]
                                        }
                                      ],
                                      "rule" : [
                                        {
                                          "name" : "syscode",
                                          "source" : [
                                            {
                                              "context" : "sysAns"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "sysComp",
                                              "contextType" : "variable",
                                              "element" : "code",
                                              "transform" : "cc",
                                              "parameter" : [
                                                {
                                                  "valueString" : "http://loinc.org"
                                                },
                                                {
                                                  "valueString" : "8480-6"
                                                },
                                                {
                                                  "valueString" : "Systolic blood pressure"
                                                }
                                              ]
                                            }
                                          ]
                                        },
                                        {
                                          "name" : "sysvalue",
                                          "source" : [
                                            {
                                              "context" : "sysAns"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "sysComp",
                                              "contextType" : "variable",
                                              "element" : "value",
                                              "transform" : "evaluate",
                                              "parameter" : [
                                                {
                                                  "valueString" : "sysAns.valueQuantity"
                                                }
                                              ]
                                            }
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "name" : "setdiastolic",
                                      "source" : [
                                        {
                                          "context" : "diaAns"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "obs",
                                          "contextType" : "variable",
                                          "element" : "component",
                                          "variable" : "diaComp",
                                          "transform" : "create",
                                          "parameter" : [
                                            {
                                              "valueString" : "Observation"
                                            }
                                          ]
                                        }
                                      ],
                                      "rule" : [
                                        {
                                          "name" : "diacode",
                                          "source" : [
                                            {
                                              "context" : "diaAns"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "diaComp",
                                              "contextType" : "variable",
                                              "element" : "code",
                                              "transform" : "cc",
                                              "parameter" : [
                                                {
                                                  "valueString" : "http://loinc.org"
                                                },
                                                {
                                                  "valueString" : "8462-4"
                                                },
                                                {
                                                  "valueString" : "Diastolic blood pressure"
                                                }
                                              ]
                                            }
                                          ]
                                        },
                                        {
                                          "name" : "diavalue",
                                          "source" : [
                                            {
                                              "context" : "diaAns"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "diaComp",
                                              "contextType" : "variable",
                                              "element" : "value",
                                              "transform" : "evaluate",
                                              "parameter" : [
                                                {
                                                  "valueString" : "diaAns.valueQuantity"
                                                }
                                              ]
                                            }
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "name" : "extracteffective",
                                      "source" : [
                                        {
                                          "context" : "sysItem",
                                          "element" : "item",
                                          "variable" : "dateItem",
                                          "condition" : "(linkId.contains('Date'))"
                                        }
                                      ],
                                      "rule" : [
                                        {
                                          "name" : "seteffective",
                                          "source" : [
                                            {
                                              "context" : "dateItem",
                                              "element" : "answer",
                                              "variable" : "dateAns"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "obs",
                                              "contextType" : "variable",
                                              "element" : "effective",
                                              "transform" : "evaluate",
                                              "parameter" : [
                                                {
                                                  "valueString" : "dateAns.valueDate"
                                                }
                                              ]
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "CreateLaboratoryObservations",
      "typeMode" : "none",
      "documentation" : "Group: Create Laboratory Observations",
      "input" : [
        {
          "name" : "src",
          "type" : "QuestionnaireResponse",
          "mode" : "source"
        },
        {
          "name" : "patient",
          "type" : "Patient",
          "mode" : "target"
        },
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "processbiology",
          "source" : [
            {
              "context" : "src",
              "element" : "item",
              "variable" : "bioGroup",
              "condition" : "(linkId = '7702944131447')"
            }
          ],
          "rule" : [
            {
              "name" : "processrenal",
              "source" : [
                {
                  "context" : "bioGroup",
                  "element" : "item",
                  "variable" : "renalGroup",
                  "condition" : "(linkId = '5241323453538')"
                }
              ],
              "rule" : [
                {
                  "name" : "extracturea",
                  "source" : [
                    {
                      "context" : "renalGroup",
                      "element" : "item",
                      "variable" : "ureaItem",
                      "condition" : "(linkId = '7169026818760')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "createureaobs",
                      "source" : [
                        {
                          "context" : "ureaItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateLabObservation",
                          "variable" : ["ans", "ureaItem", "patient", "bundle"]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extractcreat",
                  "source" : [
                    {
                      "context" : "renalGroup",
                      "element" : "item",
                      "variable" : "creatItem",
                      "condition" : "(linkId = '500408205043')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "createcreatobs",
                      "source" : [
                        {
                          "context" : "creatItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateLabObservation",
                          "variable" : ["ans", "creatItem", "patient", "bundle"]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extractdfg",
                  "source" : [
                    {
                      "context" : "renalGroup",
                      "element" : "item",
                      "variable" : "dfgItem",
                      "condition" : "(linkId = '786621340679')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "createdfgobs",
                      "source" : [
                        {
                          "context" : "dfgItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateLabObservation",
                          "variable" : ["ans", "dfgItem", "patient", "bundle"]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "processhemo",
              "source" : [
                {
                  "context" : "bioGroup",
                  "element" : "item",
                  "variable" : "hemoGroup",
                  "condition" : "(linkId = '419282985970')"
                }
              ],
              "rule" : [
                {
                  "name" : "extractleuko",
                  "source" : [
                    {
                      "context" : "hemoGroup",
                      "element" : "item",
                      "variable" : "leukoItem",
                      "condition" : "(linkId = '210077225604')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "createleukoobs",
                      "source" : [
                        {
                          "context" : "leukoItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateLabObservation",
                          "variable" : ["ans", "leukoItem", "patient", "bundle"]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extracthemo",
                  "source" : [
                    {
                      "context" : "hemoGroup",
                      "element" : "item",
                      "variable" : "hemoItem",
                      "condition" : "(linkId = '304159088493')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "createhemoobs",
                      "source" : [
                        {
                          "context" : "hemoItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateLabObservation",
                          "variable" : ["ans", "hemoItem", "patient", "bundle"]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extracthemat",
                  "source" : [
                    {
                      "context" : "hemoGroup",
                      "element" : "item",
                      "variable" : "hematItem",
                      "condition" : "(linkId = '5687959006070')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "createhematobs",
                      "source" : [
                        {
                          "context" : "hematItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateLabObservation",
                          "variable" : ["ans", "hematItem", "patient", "bundle"]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extractery",
                  "source" : [
                    {
                      "context" : "hemoGroup",
                      "element" : "item",
                      "variable" : "eryItem",
                      "condition" : "(linkId = '8697447896867')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "createeryobs",
                      "source" : [
                        {
                          "context" : "eryItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateLabObservation",
                          "variable" : ["ans", "eryItem", "patient", "bundle"]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extractvgm",
                  "source" : [
                    {
                      "context" : "hemoGroup",
                      "element" : "item",
                      "variable" : "vgmItem",
                      "condition" : "(linkId = '5584978899134')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "createvgmobs",
                      "source" : [
                        {
                          "context" : "vgmItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateLabObservation",
                          "variable" : ["ans", "vgmItem", "patient", "bundle"]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extractplat",
                  "source" : [
                    {
                      "context" : "hemoGroup",
                      "element" : "item",
                      "variable" : "platItem",
                      "condition" : "(linkId = '2881119993430')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "createplatobs",
                      "source" : [
                        {
                          "context" : "platItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateLabObservation",
                          "variable" : ["ans", "platItem", "patient", "bundle"]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extractneut",
                  "source" : [
                    {
                      "context" : "hemoGroup",
                      "element" : "item",
                      "variable" : "neutItem",
                      "condition" : "(linkId = '7408951746270')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "createneutobs",
                      "source" : [
                        {
                          "context" : "neutItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateLabObservation",
                          "variable" : ["ans", "neutItem", "patient", "bundle"]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extractlymph",
                  "source" : [
                    {
                      "context" : "hemoGroup",
                      "element" : "item",
                      "variable" : "lymphItem",
                      "condition" : "(linkId = '809808816195')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "createlymphobs",
                      "source" : [
                        {
                          "context" : "lymphItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateLabObservation",
                          "variable" : ["ans", "lymphItem", "patient", "bundle"]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extracteosi",
                  "source" : [
                    {
                      "context" : "hemoGroup",
                      "element" : "item",
                      "variable" : "eosiItem",
                      "condition" : "(linkId = '6451887990893')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "createeosiobs",
                      "source" : [
                        {
                          "context" : "eosiItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateLabObservation",
                          "variable" : ["ans", "eosiItem", "patient", "bundle"]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extractmono",
                  "source" : [
                    {
                      "context" : "hemoGroup",
                      "element" : "item",
                      "variable" : "monoItem",
                      "condition" : "(linkId = '7935935816936')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "createmonoobs",
                      "source" : [
                        {
                          "context" : "monoItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateLabObservation",
                          "variable" : ["ans", "monoItem", "patient", "bundle"]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extracttp",
                  "source" : [
                    {
                      "context" : "hemoGroup",
                      "element" : "item",
                      "variable" : "tpItem",
                      "condition" : "(linkId = '2055949655770')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "createtpobs",
                      "source" : [
                        {
                          "context" : "tpItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateLabObservation",
                          "variable" : ["ans", "tpItem", "patient", "bundle"]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extracttca",
                  "source" : [
                    {
                      "context" : "hemoGroup",
                      "element" : "item",
                      "variable" : "tcaItem",
                      "condition" : "(linkId = '2527095476817')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "createtcaobs",
                      "source" : [
                        {
                          "context" : "tcaItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateLabObservation",
                          "variable" : ["ans", "tcaItem", "patient", "bundle"]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "processliver",
              "source" : [
                {
                  "context" : "bioGroup",
                  "element" : "item",
                  "variable" : "liverGroup",
                  "condition" : "(linkId = '3893612773040')"
                }
              ],
              "rule" : [
                {
                  "name" : "extractasat",
                  "source" : [
                    {
                      "context" : "liverGroup",
                      "element" : "item",
                      "variable" : "asatItem",
                      "condition" : "(linkId = '3028330976100')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "createasatobs",
                      "source" : [
                        {
                          "context" : "asatItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateLabObservation",
                          "variable" : ["ans", "asatItem", "patient", "bundle"]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extractalat",
                  "source" : [
                    {
                      "context" : "liverGroup",
                      "element" : "item",
                      "variable" : "alatItem",
                      "condition" : "(linkId = '8486813893880')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "createalatobs",
                      "source" : [
                        {
                          "context" : "alatItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateLabObservation",
                          "variable" : ["ans", "alatItem", "patient", "bundle"]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extractggt",
                  "source" : [
                    {
                      "context" : "liverGroup",
                      "element" : "item",
                      "variable" : "ggtItem",
                      "condition" : "(linkId = '3663296044037')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "createggtobs",
                      "source" : [
                        {
                          "context" : "ggtItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateLabObservation",
                          "variable" : ["ans", "ggtItem", "patient", "bundle"]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extractpal",
                  "source" : [
                    {
                      "context" : "liverGroup",
                      "element" : "item",
                      "variable" : "palItem",
                      "condition" : "(linkId = '2690026606933')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "createpalobs",
                      "source" : [
                        {
                          "context" : "palItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateLabObservation",
                          "variable" : ["ans", "palItem", "patient", "bundle"]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extractbiltot",
                  "source" : [
                    {
                      "context" : "liverGroup",
                      "element" : "item",
                      "variable" : "bilTotItem",
                      "condition" : "(linkId = '9068831071023')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "createbiltotobs",
                      "source" : [
                        {
                          "context" : "bilTotItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateLabObservation",
                          "variable" : ["ans", "bilTotItem", "patient", "bundle"]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extractbilconj",
                  "source" : [
                    {
                      "context" : "liverGroup",
                      "element" : "item",
                      "variable" : "bilConjItem",
                      "condition" : "(linkId = '8893717988787')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "createbilconjobs",
                      "source" : [
                        {
                          "context" : "bilConjItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateLabObservation",
                          "variable" : ["ans", "bilConjItem", "patient", "bundle"]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "processglucose",
              "source" : [
                {
                  "context" : "bioGroup",
                  "element" : "item",
                  "variable" : "glucoseGroup",
                  "condition" : "(linkId = '8929068894076')"
                }
              ],
              "rule" : [
                {
                  "name" : "extractglyc",
                  "source" : [
                    {
                      "context" : "glucoseGroup",
                      "element" : "item",
                      "variable" : "glycItem",
                      "condition" : "(linkId = '8193929027997')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "createglycobs",
                      "source" : [
                        {
                          "context" : "glycItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateLabObservation",
                          "variable" : ["ans", "glycItem", "patient", "bundle"]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extracthba1c",
                  "source" : [
                    {
                      "context" : "glucoseGroup",
                      "element" : "item",
                      "variable" : "hba1cItem",
                      "condition" : "(linkId = '7063892830923')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "createhba1cobs",
                      "source" : [
                        {
                          "context" : "hba1cItem",
                          "element" : "answer",
                          "variable" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CreateLabObservation",
                          "variable" : ["ans", "hba1cItem", "patient", "bundle"]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "CreateLabObservation",
      "typeMode" : "none",
      "documentation" : "Helper: Create a single Laboratory Observation",
      "input" : [
        {
          "name" : "ans",
          "mode" : "source"
        },
        {
          "name" : "parentItem",
          "mode" : "source"
        },
        {
          "name" : "patient",
          "type" : "Patient",
          "mode" : "target"
        },
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "obsentry",
          "source" : [
            {
              "context" : "ans"
            }
          ],
          "target" : [
            {
              "context" : "bundle",
              "contextType" : "variable",
              "element" : "entry",
              "variable" : "obsEntry"
            }
          ],
          "rule" : [
            {
              "name" : "createobs",
              "source" : [
                {
                  "context" : "ans"
                }
              ],
              "target" : [
                {
                  "context" : "obsEntry",
                  "contextType" : "variable",
                  "element" : "resource",
                  "variable" : "obs",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Observation"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "obsid",
                  "source" : [
                    {
                      "context" : "ans"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "obs",
                      "contextType" : "variable",
                      "element" : "id",
                      "transform" : "uuid"
                    }
                  ]
                },
                {
                  "name" : "setfullUrl",
                  "source" : [
                    {
                      "context" : "ans"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "obs",
                      "contextType" : "variable",
                      "element" : "id",
                      "variable" : "obsId"
                    },
                    {
                      "context" : "obsEntry",
                      "contextType" : "variable",
                      "element" : "fullUrl",
                      "transform" : "append",
                      "parameter" : [
                        {
                          "valueString" : "urn:uuid:"
                        },
                        {
                          "valueId" : "obsId"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "obsmeta",
                  "source" : [
                    {
                      "context" : "ans"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "obs",
                      "contextType" : "variable",
                      "element" : "meta",
                      "variable" : "meta",
                      "transform" : "create",
                      "parameter" : [
                        {
                          "valueString" : "Meta"
                        }
                      ]
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "obsprofile",
                      "source" : [
                        {
                          "context" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "meta",
                          "contextType" : "variable",
                          "element" : "profile",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/dm-observation-laboratory-generic"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "obsstatus",
                  "source" : [
                    {
                      "context" : "ans"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "obs",
                      "contextType" : "variable",
                      "element" : "status",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "final"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "setcategory",
                  "source" : [
                    {
                      "context" : "ans"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "obs",
                      "contextType" : "variable",
                      "element" : "category",
                      "variable" : "cat",
                      "transform" : "create",
                      "parameter" : [
                        {
                          "valueString" : "CodeableConcept"
                        }
                      ]
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "setcategorycoding",
                      "source" : [
                        {
                          "context" : "ans"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "cat",
                          "contextType" : "variable",
                          "element" : "coding",
                          "variable" : "coding",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Coding"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "catsystem",
                          "source" : [
                            {
                              "context" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "coding",
                              "contextType" : "variable",
                              "element" : "system",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueString" : "http://terminology.hl7.org/CodeSystem/observation-category"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "catcode",
                          "source" : [
                            {
                              "context" : "ans"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "coding",
                              "contextType" : "variable",
                              "element" : "code",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueString" : "laboratory"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "setsubject",
                  "source" : [
                    {
                      "context" : "ans"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "obs",
                      "contextType" : "variable",
                      "element" : "subject",
                      "variable" : "ref",
                      "transform" : "create",
                      "parameter" : [
                        {
                          "valueString" : "Reference"
                        }
                      ]
                    },
                    {
                      "context" : "patient",
                      "contextType" : "variable",
                      "element" : "id",
                      "variable" : "patId"
                    },
                    {
                      "context" : "ref",
                      "contextType" : "variable",
                      "element" : "reference",
                      "transform" : "append",
                      "parameter" : [
                        {
                          "valueString" : "Patient/"
                        },
                        {
                          "valueId" : "patId"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "setvalue",
                  "source" : [
                    {
                      "context" : "ans"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "obs",
                      "contextType" : "variable",
                      "element" : "value",
                      "transform" : "evaluate",
                      "parameter" : [
                        {
                          "valueString" : "ans.valueQuantity"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extractloinc",
                  "source" : [
                    {
                      "context" : "parentItem",
                      "element" : "item",
                      "variable" : "loincItem",
                      "condition" : "(linkId.contains('code loinc'))"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "setcode",
                      "source" : [
                        {
                          "context" : "loincItem",
                          "element" : "answer",
                          "variable" : "loincAns"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "obs",
                          "contextType" : "variable",
                          "element" : "code",
                          "variable" : "code",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "CodeableConcept"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "setloinccoding",
                          "source" : [
                            {
                              "context" : "loincAns"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "code",
                              "contextType" : "variable",
                              "element" : "coding",
                              "transform" : "evaluate",
                              "parameter" : [
                                {
                                  "valueString" : "loincAns.valueCoding"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "extracteffective",
                  "source" : [
                    {
                      "context" : "parentItem",
                      "element" : "item",
                      "variable" : "dateItem",
                      "condition" : "(linkId.contains('Date et heure du prélèvement'))"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "seteffective",
                      "source" : [
                        {
                          "context" : "dateItem",
                          "element" : "answer",
                          "variable" : "dateAns"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "obs",
                          "contextType" : "variable",
                          "element" : "effective",
                          "transform" : "evaluate",
                          "parameter" : [
                            {
                              "valueString" : "dateAns.valueDateTime"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

```
