# Transforms QuestionnaireResponse based on Questionnaire Usage Variables socles into FHIR resources conforming to DM profiles - Données socles des Entrepôts de Données de Santé Hospitalier 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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureMap/Q2FSL | *Version*:0.1.0 |
| Draft as of 2026-05-28 | *Computable Name*:Q2FSL |

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

### Explication détaillées

Le group `CreatePatient` alimente la ressource Patient à partir des éléments d'informations contenus dans le QR, à savoir :

* élément `id` : génération d'un uuid
* élément `name` : alimenté à partir des items "Nom patient" (8605698058770) et "Prénom patient" (6214879623503)
* élément `identifier` : plusieurs identifiants peuvent être créé : 
* le NIR, à partir de l'item "Numéro d'inscription au Répertoire (NIR)" (5711960356160)
* l'INS, à partir de l'item "Identité Nationale de Santé (INS)" (3764723550987)
 
* élément `birthDate` : alimenté à partir de l'item "Date de naissance" (5036133558154)
* élément `deceased[x]` : alimenté à partir de l'item "Date de décès" (5633552097315). La source de cette information peut être renseigné dans l'extension `edsh-death-source` à partir de l'item "Source de la date de décès" (9098810065693)
* élémént `multipleBirth[x]` : alimenté à partir de l'item "Rang gémellaire du bénéficiaire" (6931296968515)
* élément `gender` : alimenté à partir de l'item "Sexe" (3894630481120)
* élément `address` : plusieurs informations peuvent être renseigné : 
* le code commune PMSI, issue de l'item "Code géographique de résidence" (2446369196222) alimente l'extension `edsh-pmsi-code-geo`
* les coordonnées géographiques alimentent l'extension `geolocation` : 
* la latitude provient de l'item "Latitude" (3709843054556)
* la longitude provient de l'item "Longitude" (7651448032665)
 
* l'IRIS, issue de l'item "IRIS" (7621032273792) alimente l'extension `iso21090-ADXP-censusTract`
 

```
// Group: Create Patient from QuestionnaireResponse
group CreatePatient(source src : QuestionnaireResponse, target patient : Patient) {
  src -> patient.id = uuid() "patient-id";
  src -> patient.meta = create('Meta') as meta then {
    src -> meta.profile = 'https://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-patient' "patient-profile";
  } "patient-meta";

  // 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) "set-family";
        } "extract-family";
        identity.item as givenItem where (linkId = '6214879623503') then {
          givenItem.answer as ans -> name.given = (%ans.valueString) "set-given";
        } "extract-given";
      } "set-name";

      // 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' "nir-system";
          ans -> nir.value = (%ans.valueString) "nir-value";
          ans -> nir.type = cc('http://interopsante.org/fhir/CodeSystem/fr-v2-0203', 'NIR') "nir-type";
        } "set-nir";
      } "extract-nir";

      // 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' "ins-system";
          ans -> ins.value = (%ans.valueString) "ins-value";
          ans -> ins.type = cc('http://interopsante.org/fhir/CodeSystem/fr-v2-0203', 'INS-C') "ins-type";
        } "set-ins";
      } "extract-ins";

      // Birth date (linkId 5036133558154)
      identity.item as birthItem where (linkId = '5036133558154') then {
        birthItem.answer as ans -> patient.birthDate = (%ans.valueDate) "set-birthdate";
      } "extract-birthdate";

      // Death date (linkId 5633552097315)
      identity.item as deathItem where (linkId = '5633552097315') then {
        deathItem.answer as ans -> patient.deceased = (%ans.valueDate) "set-deceased-date";
        // 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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-death-source' "death-source-url";
            sourceAns -> ext.value = (%sourceAns.valueCoding) "death-source-value";
          } "set-death-source-ext";
        } "extract-death-source";
      } "extract-death";

      // Multiple birth rank (linkId 6931296968515)
      identity.item as multipleItem where (linkId = '6931296968515') then {
        multipleItem.answer as ans -> patient.multipleBirth = (%ans.valueInteger) "set-multiple-birth";
      } "extract-multiple-birth";

    } "process-identity";

    // 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.valueString as female where ($this = 'f') -> patient.gender = 'female' "setGenderF";
          ans.valueString as female where ($this = 'm') -> patient.gender = 'male' "setGenderM";
        } "valueCoding";
      } "extract-gender";

      // 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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-pmsi-code-geo' "codegeo-url";
            ans.value as val -> ext.value = cast(val, 'code') "codegeo-value";
          } "set-codegeo-ext";

          // Environnement
          socioDemo.item as environnementItem where (linkId = '5491974639955') then {
            // geolocation
            environnementItem.item as geocodageItem where (linkId = '3816475533472') -> addr.extension = create('Extension') as geolocationExt then {
              geocodageItem.item as latItem where (linkId = '3709843054556') -> geolocationExt.url = 'http://hl7.org/fhir/StructureDefinition/geolocation', geolocationExt.extension = create('Extension') as latExt then {
                latItem.answer as lat -> latExt.url = 'latitude', latExt.value = (%lat.valueDecimal) then {
                  geocodageItem.item as longItem where (linkId = '7651448032665') -> geolocationExt.extension = create('Extension') as longExt then {
                    longItem.answer as long -> longExt.url = 'longitude', longExt.value = (%long.valueDecimal) "setLong";
                  } "createLongExt";
                } "setLat";
              } "createLatExt";
            } "createGeolocExt";
            // IRIS
            environnementItem.item as irisItem where (linkId = '7621032273792') -> addr.line as addrLine, addrLine.extension = create('Extension') as irisExt then {
              irisItem.answer as ans -> irisExt.url = 'http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-censusTract',
              irisExt.valueString = (%ans.valueString) "setIrisExt";
            } "navIrisItem";

          } "navEnv";

        } "set-address";
      } "extract-codegeo";
    } "extract-pmsi-demographics";

  } "process-sociodemographics";
}

```



## Resource Content

```json
{
  "resourceType" : "StructureMap",
  "id" : "Q2FSL",
  "url" : "https://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureMap/Q2FSL",
  "version" : "0.1.0",
  "name" : "Q2FSL",
  "title" : "Transforms QuestionnaireResponse based on Questionnaire Usage Variables socles into FHIR resources conforming to DM profiles",
  "status" : "draft",
  "date" : "2026-05-28T20:54:01+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" : "FRA"
    }]
  }],
  "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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-patient"
          }]
        }]
      }]
    },
    {
      "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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-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" : "setmultiplebirth",
            "source" : [{
              "context" : "multipleItem",
              "element" : "answer",
              "variable" : "ans"
            }],
            "target" : [{
              "context" : "patient",
              "contextType" : "variable",
              "element" : "multipleBirth",
              "transform" : "evaluate",
              "parameter" : [{
                "valueString" : "%ans.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" : "setGenderF",
              "source" : [{
                "context" : "ans",
                "element" : "valueString",
                "variable" : "female",
                "condition" : "($this = 'f')"
              }],
              "target" : [{
                "context" : "patient",
                "contextType" : "variable",
                "element" : "gender",
                "transform" : "copy",
                "parameter" : [{
                  "valueString" : "female"
                }]
              }]
            },
            {
              "name" : "setGenderM",
              "source" : [{
                "context" : "ans",
                "element" : "valueString",
                "variable" : "female",
                "condition" : "($this = 'm')"
              }],
              "target" : [{
                "context" : "patient",
                "contextType" : "variable",
                "element" : "gender",
                "transform" : "copy",
                "parameter" : [{
                  "valueString" : "male"
                }]
              }]
            }]
          }]
        },
        {
          "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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-pmsi-code-geo"
                  }]
                }]
              },
              {
                "name" : "codegeovalue",
                "source" : [{
                  "context" : "ans",
                  "element" : "value",
                  "variable" : "val"
                }],
                "target" : [{
                  "context" : "ext",
                  "contextType" : "variable",
                  "element" : "value",
                  "transform" : "cast",
                  "parameter" : [{
                    "valueId" : "val"
                  },
                  {
                    "valueString" : "code"
                  }]
                }]
              }]
            },
            {
              "name" : "navEnv",
              "source" : [{
                "context" : "socioDemo",
                "element" : "item",
                "variable" : "environnementItem",
                "condition" : "(linkId = '5491974639955')"
              }],
              "rule" : [{
                "name" : "createGeolocExt",
                "source" : [{
                  "context" : "environnementItem",
                  "element" : "item",
                  "variable" : "geocodageItem",
                  "condition" : "(linkId = '3816475533472')"
                }],
                "target" : [{
                  "context" : "addr",
                  "contextType" : "variable",
                  "element" : "extension",
                  "variable" : "geolocationExt",
                  "transform" : "create",
                  "parameter" : [{
                    "valueString" : "Extension"
                  }]
                }],
                "rule" : [{
                  "name" : "createLatExt",
                  "source" : [{
                    "context" : "geocodageItem",
                    "element" : "item",
                    "variable" : "latItem",
                    "condition" : "(linkId = '3709843054556')"
                  }],
                  "target" : [{
                    "context" : "geolocationExt",
                    "contextType" : "variable",
                    "element" : "url",
                    "transform" : "copy",
                    "parameter" : [{
                      "valueString" : "http://hl7.org/fhir/StructureDefinition/geolocation"
                    }]
                  },
                  {
                    "context" : "geolocationExt",
                    "contextType" : "variable",
                    "element" : "extension",
                    "variable" : "latExt",
                    "transform" : "create",
                    "parameter" : [{
                      "valueString" : "Extension"
                    }]
                  }],
                  "rule" : [{
                    "name" : "setLat",
                    "source" : [{
                      "context" : "latItem",
                      "element" : "answer",
                      "variable" : "lat"
                    }],
                    "target" : [{
                      "context" : "latExt",
                      "contextType" : "variable",
                      "element" : "url",
                      "transform" : "copy",
                      "parameter" : [{
                        "valueString" : "latitude"
                      }]
                    },
                    {
                      "context" : "latExt",
                      "contextType" : "variable",
                      "element" : "value",
                      "transform" : "evaluate",
                      "parameter" : [{
                        "valueString" : "%lat.valueDecimal"
                      }]
                    }],
                    "rule" : [{
                      "name" : "createLongExt",
                      "source" : [{
                        "context" : "geocodageItem",
                        "element" : "item",
                        "variable" : "longItem",
                        "condition" : "(linkId = '7651448032665')"
                      }],
                      "target" : [{
                        "context" : "geolocationExt",
                        "contextType" : "variable",
                        "element" : "extension",
                        "variable" : "longExt",
                        "transform" : "create",
                        "parameter" : [{
                          "valueString" : "Extension"
                        }]
                      }],
                      "rule" : [{
                        "name" : "setLong",
                        "source" : [{
                          "context" : "longItem",
                          "element" : "answer",
                          "variable" : "long"
                        }],
                        "target" : [{
                          "context" : "longExt",
                          "contextType" : "variable",
                          "element" : "url",
                          "transform" : "copy",
                          "parameter" : [{
                            "valueString" : "longitude"
                          }]
                        },
                        {
                          "context" : "longExt",
                          "contextType" : "variable",
                          "element" : "value",
                          "transform" : "evaluate",
                          "parameter" : [{
                            "valueString" : "%long.valueDecimal"
                          }]
                        }]
                      }]
                    }]
                  }]
                }]
              },
              {
                "name" : "navIrisItem",
                "source" : [{
                  "context" : "environnementItem",
                  "element" : "item",
                  "variable" : "irisItem",
                  "condition" : "(linkId = '7621032273792')"
                }],
                "target" : [{
                  "context" : "addr",
                  "contextType" : "variable",
                  "element" : "line",
                  "variable" : "addrLine"
                },
                {
                  "context" : "addrLine",
                  "contextType" : "variable",
                  "element" : "extension",
                  "variable" : "irisExt",
                  "transform" : "create",
                  "parameter" : [{
                    "valueString" : "Extension"
                  }]
                }],
                "rule" : [{
                  "name" : "setIrisExt",
                  "source" : [{
                    "context" : "irisItem",
                    "element" : "answer",
                    "variable" : "ans"
                  }],
                  "target" : [{
                    "context" : "irisExt",
                    "contextType" : "variable",
                    "element" : "url",
                    "transform" : "copy",
                    "parameter" : [{
                      "valueString" : "http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-censusTract"
                    }]
                  },
                  {
                    "context" : "irisExt",
                    "contextType" : "variable",
                    "element" : "valueString",
                    "transform" : "evaluate",
                    "parameter" : [{
                      "valueString" : "%ans.valueString"
                    }]
                  }]
                }]
              }]
            }]
          }]
        }]
      }]
    }]
  },
  {
    "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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-location"
                  }]
                }]
              }]
            },
            {
              "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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-location"
                    }]
                  }]
                }]
              },
              {
                "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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-encounter"
              }]
            }]
          }]
        },
        {
          "name" : "setStatus",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "encounter",
            "contextType" : "variable",
            "element" : "status",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "finished"
            }]
          }]
        },
        {
          "name" : "setClass",
          "source" : [{
            "context" : "src"
          }],
          "target" : [{
            "context" : "encounter",
            "contextType" : "variable",
            "element" : "class",
            "transform" : "c",
            "parameter" : [{
              "valueString" : "http://terminology.hl7.org/CodeSystem/v3-ActCode"
            },
            {
              "valueString" : "IMP"
            }]
          }]
        },
        {
          "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')"
          }],
          "rule" : [{
            "name" : "navValue",
            "source" : [{
              "context" : "modeInItem",
              "element" : "answer",
              "variable" : "ans"
            }],
            "rule" : [{
              "name" : "setadmitsource",
              "source" : [{
                "context" : "ans",
                "element" : "valueString",
                "variable" : "valueString"
              }],
              "target" : [{
                "context" : "encounter",
                "contextType" : "variable",
                "element" : "hospitalization",
                "variable" : "hosp"
              },
              {
                "context" : "hosp",
                "contextType" : "variable",
                "element" : "admitSource",
                "variable" : "admitSource"
              },
              {
                "context" : "admitSource",
                "contextType" : "variable",
                "element" : "coding",
                "variable" : "admitSourceCoding"
              },
              {
                "context" : "admitSourceCoding",
                "contextType" : "variable",
                "element" : "code",
                "transform" : "copy",
                "parameter" : [{
                  "valueId" : "valueString"
                }]
              }]
            }]
          }]
        },
        {
          "name" : "extractmodeout",
          "source" : [{
            "context" : "pmsiItem",
            "element" : "item",
            "variable" : "modeOutItem",
            "condition" : "(linkId = '3354867075704')"
          }],
          "rule" : [{
            "name" : "navValue",
            "source" : [{
              "context" : "modeOutItem",
              "element" : "answer",
              "variable" : "ans"
            }],
            "rule" : [{
              "name" : "setdischargedisposition",
              "source" : [{
                "context" : "ans",
                "element" : "valueString",
                "variable" : "valueString"
              }],
              "target" : [{
                "context" : "encounter",
                "contextType" : "variable",
                "element" : "hospitalization",
                "variable" : "hosp"
              },
              {
                "context" : "hosp",
                "contextType" : "variable",
                "element" : "dischargeDisposition",
                "variable" : "dischargeDisposition"
              },
              {
                "context" : "dischargeDisposition",
                "contextType" : "variable",
                "element" : "coding",
                "variable" : "dischargeDispositionCoding"
              },
              {
                "context" : "dischargeDispositionCoding",
                "contextType" : "variable",
                "element" : "code",
                "transform" : "copy",
                "parameter" : [{
                  "valueId" : "valueString"
                }]
              }]
            }]
          }]
        },
        {
          "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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-condition"
              }]
            }]
          }]
        },
        {
          "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",
                "variable" : "coding"
              },
              {
                "context" : "coding",
                "contextType" : "variable",
                "element" : "code",
                "transform" : "evaluate",
                "parameter" : [{
                  "valueString" : "%ans.valueString"
                }]
              }]
            }]
          }]
        },
        {
          "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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/CodeSystem/pmsi-mco-diag-type"
                  }]
                }]
              },
              {
                "name" : "diagtypecode",
                "source" : [{
                  "context" : "ans"
                }],
                "target" : [{
                  "context" : "coding",
                  "contextType" : "variable",
                  "element" : "code",
                  "transform" : "evaluate",
                  "parameter" : [{
                    "valueString" : "%ans.valueString"
                  }]
                }]
              }]
            }]
          }]
        },
        {
          "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" : "setfullUrl",
          "source" : [{
            "context" : "pmsiItem"
          }],
          "target" : [{
            "context" : "condition",
            "contextType" : "variable",
            "element" : "id",
            "variable" : "condId"
          },
          {
            "context" : "conditionEntry",
            "contextType" : "variable",
            "element" : "fullUrl",
            "transform" : "append",
            "parameter" : [{
              "valueString" : "urn:uuid:"
            },
            {
              "valueId" : "condId"
            }]
          }]
        }]
      }]
    }]
  },
  {
    "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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-procedure"
              }]
            }]
          }]
        },
        {
          "name" : "setStatus",
          "source" : [{
            "context" : "acteGroup"
          }],
          "target" : [{
            "context" : "procedure",
            "contextType" : "variable",
            "element" : "status",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "completed"
            }]
          }]
        },
        {
          "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",
                "variable" : "coding"
              },
              {
                "context" : "coding",
                "contextType" : "variable",
                "element" : "code",
                "transform" : "evaluate",
                "parameter" : [{
                  "valueString" : "%ans.valueString"
                }]
              }]
            }]
          }]
        },
        {
          "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" : "setfullUrl",
          "source" : [{
            "context" : "pmsiItem"
          }],
          "target" : [{
            "context" : "procedure",
            "contextType" : "variable",
            "element" : "id",
            "variable" : "procId"
          },
          {
            "context" : "procedureEntry",
            "contextType" : "variable",
            "element" : "fullUrl",
            "transform" : "append",
            "parameter" : [{
              "valueString" : "urn:uuid:"
            },
            {
              "valueId" : "procId"
            }]
          }]
        }]
      }]
    }]
  },
  {
    "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" : "setfullUrl",
            "source" : [{
              "context" : "src"
            }],
            "target" : [{
              "context" : "medReq",
              "contextType" : "variable",
              "element" : "id",
              "variable" : "medReqId"
            },
            {
              "context" : "medReqEntry",
              "contextType" : "variable",
              "element" : "fullUrl",
              "transform" : "append",
              "parameter" : [{
                "valueString" : "urn:uuid:"
              },
              {
                "valueId" : "medReqId"
              }]
            }]
          },
          {
            "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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-medication-request"
                }]
              }]
            }]
          },
          {
            "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" : "navPrescribedMedication",
            "source" : [{
              "context" : "prescribedGroup",
              "element" : "answer",
              "variable" : "prescribedMedication"
            }],
            "rule" : [{
              "name" : "navAtcItem",
              "source" : [{
                "context" : "prescribedMedication",
                "element" : "item",
                "variable" : "atcItem",
                "condition" : "(linkId = '1923143398283')"
              }],
              "rule" : [{
                "name" : "setAtcCoding",
                "source" : [{
                  "context" : "atcItem",
                  "element" : "answer",
                  "variable" : "ans"
                }],
                "target" : [{
                  "context" : "medReq",
                  "contextType" : "variable",
                  "element" : "medication",
                  "variable" : "medReqCC",
                  "transform" : "create",
                  "parameter" : [{
                    "valueString" : "CodeableConcept"
                  }]
                },
                {
                  "context" : "medReqCC",
                  "contextType" : "variable",
                  "element" : "coding",
                  "variable" : "medReqC"
                },
                {
                  "context" : "medReqC",
                  "contextType" : "variable",
                  "element" : "code",
                  "transform" : "evaluate",
                  "parameter" : [{
                    "valueString" : "%ans.valueString"
                  }]
                },
                {
                  "context" : "medReqC",
                  "contextType" : "variable",
                  "element" : "display",
                  "transform" : "evaluate",
                  "parameter" : [{
                    "valueString" : "%prescribedMedication.valueString"
                  }]
                }]
              }]
            }]
          },
          {
            "name" : "setdosage",
            "source" : [{
              "context" : "prescribedGroup"
            }],
            "target" : [{
              "context" : "medReq",
              "contextType" : "variable",
              "element" : "dosageInstruction",
              "variable" : "dosage",
              "transform" : "create",
              "parameter" : [{
                "valueString" : "Dosage"
              }]
            }],
            "rule" : [{
              "name" : "navPrescribedMedication",
              "source" : [{
                "context" : "prescribedGroup",
                "element" : "answer",
                "variable" : "prescribedMedication"
              }],
              "rule" : [{
                "name" : "navRouteItem",
                "source" : [{
                  "context" : "prescribedMedication",
                  "element" : "item",
                  "variable" : "routeItem",
                  "condition" : "(linkId = '387026794874')"
                }],
                "rule" : [{
                  "name" : "setroute",
                  "source" : [{
                    "context" : "routeItem",
                    "element" : "answer",
                    "variable" : "ans"
                  }],
                  "target" : [{
                    "context" : "dosage",
                    "contextType" : "variable",
                    "element" : "route",
                    "variable" : "route"
                  }],
                  "rule" : [{
                    "name" : "setroutecoding",
                    "source" : [{
                      "context" : "ans"
                    }],
                    "target" : [{
                      "context" : "route",
                      "contextType" : "variable",
                      "element" : "coding",
                      "variable" : "routeCoding"
                    },
                    {
                      "context" : "routeCoding",
                      "contextType" : "variable",
                      "element" : "code",
                      "transform" : "evaluate",
                      "parameter" : [{
                        "valueString" : "%ans.valueString"
                      }]
                    }]
                  }]
                }]
              }]
            },
            {
              "name" : "navPoso",
              "source" : [{
                "context" : "medExpoGroup",
                "element" : "item",
                "variable" : "posoGroup",
                "condition" : "(linkId = '6348237104421')"
              }],
              "target" : [{
                "context" : "dosage",
                "contextType" : "variable",
                "element" : "timing",
                "variable" : "timing"
              },
              {
                "context" : "timing",
                "contextType" : "variable",
                "element" : "repeat",
                "variable" : "timingRepeat"
              },
              {
                "context" : "timingRepeat",
                "contextType" : "variable",
                "element" : "boundsPeriod",
                "variable" : "timingPeriod"
              }],
              "rule" : [{
                "name" : "navDateDeb",
                "source" : [{
                  "context" : "posoGroup",
                  "element" : "item",
                  "variable" : "DateDebItem",
                  "condition" : "(linkId = '316347573327')"
                }],
                "rule" : [{
                  "name" : "setDateDeb",
                  "source" : [{
                    "context" : "DateDebItem",
                    "element" : "answer",
                    "variable" : "ans"
                  }],
                  "target" : [{
                    "context" : "timingPeriod",
                    "contextType" : "variable",
                    "element" : "start",
                    "transform" : "evaluate",
                    "parameter" : [{
                      "valueString" : "%ans.valueDate"
                    }]
                  }]
                }]
              },
              {
                "name" : "navDateFin",
                "source" : [{
                  "context" : "posoGroup",
                  "element" : "item",
                  "variable" : "DateFinItem",
                  "condition" : "(linkId = '429570775935')"
                }],
                "rule" : [{
                  "name" : "setDateFin",
                  "source" : [{
                    "context" : "DateFinItem",
                    "element" : "answer",
                    "variable" : "ans"
                  }],
                  "target" : [{
                    "context" : "timingPeriod",
                    "contextType" : "variable",
                    "element" : "end",
                    "transform" : "evaluate",
                    "parameter" : [{
                      "valueString" : "%ans.valueDate"
                    }]
                  }]
                }]
              }]
            }]
          }]
        }]
      }]
    }]
  },
  {
    "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" : "setfullUrl",
            "source" : [{
              "context" : "src"
            }],
            "target" : [{
              "context" : "medAdmin",
              "contextType" : "variable",
              "element" : "id",
              "variable" : "medAdminId"
            },
            {
              "context" : "medAdminEntry",
              "contextType" : "variable",
              "element" : "fullUrl",
              "transform" : "append",
              "parameter" : [{
                "valueString" : "urn:uuid:"
              },
              {
                "valueId" : "medAdminId"
              }]
            }]
          },
          {
            "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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-medication-administration"
                }]
              }]
            }]
          },
          {
            "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" : "navadministeredMedication",
            "source" : [{
              "context" : "adminGroup",
              "element" : "answer",
              "variable" : "administeredMedication"
            }],
            "rule" : [{
              "name" : "navAtcItem",
              "source" : [{
                "context" : "administeredMedication",
                "element" : "item",
                "variable" : "atcItem",
                "condition" : "(linkId = '631972144976')"
              }],
              "rule" : [{
                "name" : "setAtcCoding",
                "source" : [{
                  "context" : "atcItem",
                  "element" : "answer",
                  "variable" : "ans"
                }],
                "target" : [{
                  "context" : "medAdmin",
                  "contextType" : "variable",
                  "element" : "medication",
                  "variable" : "medAdminCC",
                  "transform" : "create",
                  "parameter" : [{
                    "valueString" : "CodeableConcept"
                  }]
                },
                {
                  "context" : "medAdminCC",
                  "contextType" : "variable",
                  "element" : "coding",
                  "variable" : "medAdminC"
                },
                {
                  "context" : "medAdminC",
                  "contextType" : "variable",
                  "element" : "code",
                  "transform" : "evaluate",
                  "parameter" : [{
                    "valueString" : "%ans.valueString"
                  }]
                },
                {
                  "context" : "medAdminC",
                  "contextType" : "variable",
                  "element" : "display",
                  "transform" : "evaluate",
                  "parameter" : [{
                    "valueString" : "%administeredMedication.valueString"
                  }]
                }]
              }]
            }]
          },
          {
            "name" : "setdosage",
            "source" : [{
              "context" : "adminGroup"
            }],
            "target" : [{
              "context" : "medAdmin",
              "contextType" : "variable",
              "element" : "dosage",
              "variable" : "dosage"
            }],
            "rule" : [{
              "name" : "navadministeredMedication",
              "source" : [{
                "context" : "adminGroup",
                "element" : "answer",
                "variable" : "administeredMedication"
              }],
              "rule" : [{
                "name" : "navRoute",
                "source" : [{
                  "context" : "administeredMedication",
                  "element" : "item",
                  "variable" : "routeItem",
                  "condition" : "(linkId = '811931484859')"
                }],
                "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",
                      "variable" : "routeCoding"
                    },
                    {
                      "context" : "routeCoding",
                      "contextType" : "variable",
                      "element" : "code",
                      "transform" : "evaluate",
                      "parameter" : [{
                        "valueString" : "%ans.valueString"
                      }]
                    }]
                  }]
                }]
              }]
            },
            {
              "name" : "navDosage",
              "source" : [{
                "context" : "medExpoGroup",
                "element" : "item",
                "variable" : "doseGroup",
                "condition" : "(linkId = '5720103839343')"
              }],
              "rule" : [{
                "name" : "navquantity",
                "source" : [{
                  "context" : "doseGroup",
                  "element" : "item",
                  "variable" : "quantityItem",
                  "condition" : "(linkId = '4765772671997')"
                }],
                "rule" : [{
                  "name" : "setDose",
                  "source" : [{
                    "context" : "quantityItem",
                    "element" : "answer",
                    "variable" : "ans"
                  }],
                  "target" : [{
                    "context" : "dosage",
                    "contextType" : "variable",
                    "element" : "dose",
                    "transform" : "evaluate",
                    "parameter" : [{
                      "valueString" : "%ans.valueQuantity"
                    }]
                  }]
                }]
              },
              {
                "name" : "navStart",
                "source" : [{
                  "context" : "doseGroup",
                  "element" : "item",
                  "variable" : "startItem",
                  "condition" : "(linkId = '1443558617577')"
                }],
                "rule" : [{
                  "name" : "navStartAns",
                  "source" : [{
                    "context" : "startItem",
                    "element" : "answer",
                    "variable" : "startAns"
                  }],
                  "rule" : [{
                    "name" : "navEnd",
                    "source" : [{
                      "context" : "doseGroup",
                      "element" : "item",
                      "variable" : "endItem",
                      "condition" : "(linkId = '780829110731')"
                    }],
                    "rule" : [{
                      "name" : "setAdminPeriod",
                      "source" : [{
                        "context" : "endItem",
                        "element" : "answer",
                        "variable" : "endAns"
                      }],
                      "target" : [{
                        "context" : "medAdmin",
                        "contextType" : "variable",
                        "element" : "effectivePeriod",
                        "variable" : "adminPeriod"
                      },
                      {
                        "context" : "adminPeriod",
                        "contextType" : "variable",
                        "element" : "start",
                        "transform" : "evaluate",
                        "parameter" : [{
                          "valueString" : "%startAns.value"
                        }]
                      },
                      {
                        "context" : "adminPeriod",
                        "contextType" : "variable",
                        "element" : "end",
                        "transform" : "evaluate",
                        "parameter" : [{
                          "valueString" : "%endAns.value"
                        }]
                      }]
                    }]
                  }]
                }]
              }]
            }]
          }]
        }]
      }]
    }]
  },
  {
    "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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-observation-body-height"
                    }]
                  }]
                }]
              },
              {
                "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",
                  "variable" : "tgtObsVal",
                  "transform" : "evaluate",
                  "parameter" : [{
                    "valueString" : "%ans.valueQuantity"
                  }]
                },
                {
                  "context" : "tgtObsVal",
                  "contextType" : "variable",
                  "element" : "code",
                  "transform" : "evaluate",
                  "parameter" : [{
                    "valueString" : "%ans.valueQuantity.unit"
                  }]
                },
                {
                  "context" : "tgtObsVal",
                  "contextType" : "variable",
                  "element" : "system",
                  "transform" : "copy",
                  "parameter" : [{
                    "valueString" : "http://unitsofmeasure.org"
                  }]
                }]
              },
              {
                "name" : "extracteffective",
                "source" : [{
                  "context" : "ans",
                  "element" : "item",
                  "variable" : "dateItem",
                  "condition" : "(linkId = '941821315470')"
                }],
                "rule" : [{
                  "name" : "navDateAns",
                  "source" : [{
                    "context" : "dateItem",
                    "element" : "answer",
                    "variable" : "dateAns"
                  }],
                  "rule" : [{
                    "name" : "seteffective",
                    "source" : [{
                      "context" : "dateAns",
                      "element" : "value",
                      "variable" : "val"
                    }],
                    "target" : [{
                      "context" : "obs",
                      "contextType" : "variable",
                      "element" : "effective",
                      "transform" : "cast",
                      "parameter" : [{
                        "valueId" : "val"
                      },
                      {
                        "valueString" : "dateTime"
                      }]
                    }]
                  }]
                }]
              }]
            }]
          }]
        },
        {
          "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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-observation-body-weight"
                    }]
                  }]
                }]
              },
              {
                "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",
                  "variable" : "tgtObsVal",
                  "transform" : "evaluate",
                  "parameter" : [{
                    "valueString" : "%ans.valueQuantity"
                  }]
                },
                {
                  "context" : "tgtObsVal",
                  "contextType" : "variable",
                  "element" : "code",
                  "transform" : "evaluate",
                  "parameter" : [{
                    "valueString" : "%ans.valueQuantity.unit"
                  }]
                },
                {
                  "context" : "tgtObsVal",
                  "contextType" : "variable",
                  "element" : "system",
                  "transform" : "copy",
                  "parameter" : [{
                    "valueString" : "http://unitsofmeasure.org"
                  }]
                }]
              },
              {
                "name" : "extracteffective",
                "source" : [{
                  "context" : "ans",
                  "element" : "item",
                  "variable" : "dateItem",
                  "condition" : "(linkId = '151269044052')"
                }],
                "rule" : [{
                  "name" : "navDateAns",
                  "source" : [{
                    "context" : "dateItem",
                    "element" : "answer",
                    "variable" : "dateAns"
                  }],
                  "rule" : [{
                    "name" : "seteffective",
                    "source" : [{
                      "context" : "dateAns",
                      "element" : "value",
                      "variable" : "val"
                    }],
                    "target" : [{
                      "context" : "obs",
                      "contextType" : "variable",
                      "element" : "effective",
                      "transform" : "cast",
                      "parameter" : [{
                        "valueId" : "val"
                      },
                      {
                        "valueString" : "dateTime"
                      }]
                    }]
                  }]
                }]
              }]
            }]
          }]
        },
        {
          "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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/StructureDefinition/edsh-observation-blood-pressure"
                        }]
                      }]
                    }]
                  },
                  {
                    "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"
                    }],
                    "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",
                        "variable" : "sysVal",
                        "transform" : "evaluate",
                        "parameter" : [{
                          "valueString" : "%sysAns.valueQuantity"
                        }]
                      },
                      {
                        "context" : "sysVal",
                        "contextType" : "variable",
                        "element" : "code",
                        "transform" : "evaluate",
                        "parameter" : [{
                          "valueString" : "%sysAns.valueQuantity.unit"
                        }]
                      },
                      {
                        "context" : "sysVal",
                        "contextType" : "variable",
                        "element" : "system",
                        "transform" : "copy",
                        "parameter" : [{
                          "valueString" : "http://unitsofmeasure.org"
                        }]
                      }]
                    }]
                  },
                  {
                    "name" : "setdiastolic",
                    "source" : [{
                      "context" : "diaAns"
                    }],
                    "target" : [{
                      "context" : "obs",
                      "contextType" : "variable",
                      "element" : "component",
                      "variable" : "diaComp"
                    }],
                    "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",
                        "variable" : "diaVal",
                        "transform" : "evaluate",
                        "parameter" : [{
                          "valueString" : "%diaAns.valueQuantity"
                        }]
                      },
                      {
                        "context" : "diaVal",
                        "contextType" : "variable",
                        "element" : "code",
                        "transform" : "evaluate",
                        "parameter" : [{
                          "valueString" : "%diaAns.valueQuantity.unit"
                        }]
                      },
                      {
                        "context" : "diaVal",
                        "contextType" : "variable",
                        "element" : "system",
                        "transform" : "copy",
                        "parameter" : [{
                          "valueString" : "http://unitsofmeasure.org"
                        }]
                      }]
                    }]
                  },
                  {
                    "name" : "navDate",
                    "source" : [{
                      "context" : "sysAns",
                      "element" : "item",
                      "variable" : "sysDateItem",
                      "condition" : "(linkId = '987654638442')"
                    }],
                    "rule" : [{
                      "name" : "navDateAns",
                      "source" : [{
                        "context" : "sysDateItem",
                        "element" : "answer",
                        "variable" : "dateAns"
                      }],
                      "rule" : [{
                        "name" : "seteffective",
                        "source" : [{
                          "context" : "dateAns",
                          "element" : "value",
                          "variable" : "val"
                        }],
                        "target" : [{
                          "context" : "obs",
                          "contextType" : "variable",
                          "element" : "effective",
                          "transform" : "cast",
                          "parameter" : [{
                            "valueId" : "val"
                          },
                          {
                            "valueString" : "dateTime"
                          }]
                        }]
                      }]
                    }]
                  }]
                }]
              }]
            }]
          }]
        }]
      }]
    }]
  },
  {
    "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 = '813863316705')"
          }],
          "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 = '459731866614')"
          }],
          "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 = '163624088831')"
          }],
          "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 = '794156787471')"
          }],
          "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 = '961905168477')"
          }],
          "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 = '695150914696')"
          }],
          "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 = '700490326748')"
          }],
          "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 = '168661900522')"
          }],
          "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 = '658898841893')"
          }],
          "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 = '795145096241')"
          }],
          "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 = '796308115381')"
        }],
        "rule" : [{
          "name" : "extractasat",
          "source" : [{
            "context" : "liverGroup",
            "element" : "item",
            "variable" : "asatItem",
            "condition" : "(linkId = '715226319725')"
          }],
          "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 = '876439410327')"
          }],
          "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 = '287545455976')"
          }],
          "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 = '508269571594')"
          }],
          "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 = '927344090061')"
          }],
          "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 = '208196328453')"
          }],
          "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 = '334039497382')"
        }],
        "rule" : [{
          "name" : "extractglyc",
          "source" : [{
            "context" : "glucoseGroup",
            "element" : "item",
            "variable" : "glycItem",
            "condition" : "(linkId = '273778921448')"
          }],
          "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 = '632894677152')"
          }],
          "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://aphp.github.io/IG-FHIR-EDSH-SOCLE-COMMUN/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",
            "variable" : "tgtObsVal",
            "transform" : "evaluate",
            "parameter" : [{
              "valueString" : "%ans.valueQuantity"
            }]
          },
          {
            "context" : "tgtObsVal",
            "contextType" : "variable",
            "element" : "code",
            "transform" : "evaluate",
            "parameter" : [{
              "valueString" : "%ans.valueQuantity.unit"
            }]
          },
          {
            "context" : "tgtObsVal",
            "contextType" : "variable",
            "element" : "system",
            "transform" : "copy",
            "parameter" : [{
              "valueString" : "http://unitsofmeasure.org"
            }]
          }]
        },
        {
          "name" : "extractloinc",
          "source" : [{
            "context" : "ans",
            "element" : "item",
            "variable" : "loincItem",
            "condition" : "(text.contains('code loinc'))"
          }],
          "rule" : [{
            "name" : "setloinccoding",
            "source" : [{
              "context" : "loincItem",
              "element" : "answer",
              "variable" : "loincAns"
            }],
            "target" : [{
              "context" : "obs",
              "contextType" : "variable",
              "element" : "code",
              "variable" : "code"
            },
            {
              "context" : "code",
              "contextType" : "variable",
              "element" : "coding",
              "variable" : "coding"
            },
            {
              "context" : "coding",
              "contextType" : "variable",
              "element" : "code",
              "transform" : "evaluate",
              "parameter" : [{
                "valueString" : "%loincAns.valueString"
              }]
            }]
          }]
        },
        {
          "name" : "extracteffective",
          "source" : [{
            "context" : "ans",
            "element" : "item",
            "variable" : "dateItem",
            "condition" : "(text.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"
              }]
            }]
          }]
        },
        {
          "name" : "setrefrange",
          "source" : [{
            "context" : "ans"
          }],
          "target" : [{
            "context" : "obs",
            "contextType" : "variable",
            "element" : "referenceRange",
            "variable" : "refRange"
          }],
          "rule" : [{
            "name" : "extractlow",
            "source" : [{
              "context" : "ans",
              "element" : "item",
              "variable" : "lowItem",
              "condition" : "(text.contains('Borne inférieure'))"
            }],
            "rule" : [{
              "name" : "setlow",
              "source" : [{
                "context" : "lowItem",
                "element" : "answer",
                "variable" : "lowAns"
              }],
              "target" : [{
                "context" : "refRange",
                "contextType" : "variable",
                "element" : "low",
                "variable" : "tgtLow",
                "transform" : "evaluate",
                "parameter" : [{
                  "valueString" : "%lowAns.valueQuantity"
                }]
              },
              {
                "context" : "tgtLow",
                "contextType" : "variable",
                "element" : "code",
                "transform" : "evaluate",
                "parameter" : [{
                  "valueString" : "%ans.valueQuantity.unit"
                }]
              },
              {
                "context" : "tgtLow",
                "contextType" : "variable",
                "element" : "system",
                "transform" : "copy",
                "parameter" : [{
                  "valueString" : "http://unitsofmeasure.org"
                }]
              }]
            }]
          },
          {
            "name" : "extracthigh",
            "source" : [{
              "context" : "ans",
              "element" : "item",
              "variable" : "highItem",
              "condition" : "(text.contains('Borne supérieure'))"
            }],
            "rule" : [{
              "name" : "sethigh",
              "source" : [{
                "context" : "highItem",
                "element" : "answer",
                "variable" : "highAns"
              }],
              "target" : [{
                "context" : "refRange",
                "contextType" : "variable",
                "element" : "high",
                "variable" : "tgtHigh",
                "transform" : "evaluate",
                "parameter" : [{
                  "valueString" : "%highAns.valueQuantity"
                }]
              },
              {
                "context" : "tgtHigh",
                "contextType" : "variable",
                "element" : "code",
                "transform" : "evaluate",
                "parameter" : [{
                  "valueString" : "%ans.valueQuantity.unit"
                }]
              },
              {
                "context" : "tgtHigh",
                "contextType" : "variable",
                "element" : "system",
                "transform" : "copy",
                "parameter" : [{
                  "valueString" : "http://unitsofmeasure.org"
                }]
              }]
            }]
          }]
        }]
      }]
    }]
  }]
}

```
