CdaFrMDEToBundle
type: StructureMap
node role: treeRoot
id:
  v: CdaFrMDEToBundle
text:
  status:
    v: generated
  div:
    v: Narratif généré : StructureMap CdaFrMDEToBundle #xD; map "https://interop.esante.gouv.fr/ig/fhir/mappingcdafhir/StructureMap/CdaFrMDEToBundle" = "CdaFrMDEToBundle"#xD; #xD; // Mapping CSE-MDE vers FHIR Bundle - Contexte Français#xD; #xD; uses "http://hl7.org/cda/stds/core/StructureDefinition/ClinicalDocument" alias ClinicalDocument as source#xD; uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias Bundle as target#xD; uses "http://hl7.org/fhir/StructureDefinition/Composition" alias Composition as target#xD; uses "http://hl7.org/fhir/StructureDefinition/Patient" alias Patient as target#xD; uses "http://hl7.org/fhir/StructureDefinition/Observation" alias Observation as target#xD; #xD; imports "https://interop.esante.gouv.fr/ig/fhir/mappingcdafhir/StructureMap/CdaToFHIRTypes"#xD; imports "https://interop.esante.gouv.fr/ig/fhir/mappingcdafhir/StructureMap/CdaToBundle"#xD; imports "https://interop.esante.gouv.fr/ig/fhir/mappingcdafhir/StructureMap/CdaFrToBundle"#xD; #xD; // Entry point#xD; group CdaFrMDEToBundle(source cda : ClinicalDocument, target bundle : Bundle) {#xD; cda -> bundle.entry as e, e.resource = create('Composition') as composition, composition.id = uuid() as uuid, e.fullUrl = append('urn:uuid:', uuid), bundle.entry as e2, e2.resource = create('Patient') as patient, patient.id = uuid() as uuid2, e2.fullUrl = append('urn:uuid:', uuid2) then CdaFrMDEMapping(cda, patient, composition, bundle) "main";#xD; }#xD; #xD; // Main mapping group#xD; group CdaFrMDEMapping(source cda : ClinicalDocument, target patient : Patient, target composition : Composition, target bundle : Bundle) {#xD; // Bundle metadata#xD; cda -> bundle.id = uuid() "bundleId";#xD; cda.id as cdaId -> bundle.identifier as identifier then {#xD; cdaId.root as root where cdaId.extension.exists() -> identifier.system = translate(root, '#oid2uri', 'uri') "system";#xD; cdaId.extension as extension -> identifier.value = extension "value";#xD; cdaId.root as root where cdaId.extension.empty() -> ide…
url:
  v: https://interop.esante.gouv.fr/ig/fhir/mappingcdafhir/StructureMap/CdaFrMDEToBundle
  l: CdaFrMDEToBundle
version:
  v: 0.1.0
name:
  v: CdaFrMDEToBundle
title:
  v: Mapping CSE-MDE vers FHIR Bundle - Contexte Français
status:
  v: draft
date:
  v: 2025-11-07T10:30:30+00:00
publisher:
  v: Agence du Numérique en Santé (ANS) - 2-10 Rue d'Oradour-sur-Glane, 75015 Paris
contact:
  name:
    v: Agence du Numérique en Santé (ANS) - 2-10 Rue d'Oradour-sur-Glane, 75015 Paris
  telecom:
    system:
      v: url
    value:
      v: https://esante.gouv.fr
description:
  v: Mapping CSE-MDE vers FHIR Bundle - Contexte Français
jurisdiction:
  coding:
    system:
      v: urn:iso:std:iso:3166
      l: 3166
    code:
      v: FR
    display:
      v: FRANCE
structure:
  url:
    v: http://hl7.org/cda/stds/core/StructureDefinition/ClinicalDocument
    l: ClinicalDocument
  mode:
    v: source
  alias:
    v: ClinicalDocument
structure:
  url:
    v: http://hl7.org/fhir/StructureDefinition/Bundle
    l: Bundle
  mode:
    v: target
  alias:
    v: Bundle
structure:
  url:
    v: http://hl7.org/fhir/StructureDefinition/Composition
    l: Composition
  mode:
    v: target
  alias:
    v: Composition
structure:
  url:
    v: http://hl7.org/fhir/StructureDefinition/Patient
    l: Patient
  mode:
    v: target
  alias:
    v: Patient
structure:
  url:
    v: http://hl7.org/fhir/StructureDefinition/Observation
    l: Observation
  mode:
    v: target
  alias:
    v: Observation
import:
  v: https://interop.esante.gouv.fr/ig/fhir/mappingcdafhir/StructureMap/CdaToFHIRTypes
  l: CdaToFHIRTypes
import:
  v: https://interop.esante.gouv.fr/ig/fhir/mappingcdafhir/StructureMap/CdaToBundle
  l: CdaToBundle
import:
  v: https://interop.esante.gouv.fr/ig/fhir/mappingcdafhir/StructureMap/CdaFrToBundle
  l: CdaFrToBundle
group:
  name:
    v: CdaFrMDEToBundle
  type mode:
    v: none
  documentation:
    v: Entry point
  input:
    name:
      v: cda
    type:
      v: ClinicalDocument
    mode:
      v: source
  input:
    name:
      v: bundle
    type:
      v: Bundle
    mode:
      v: target
  rule:
    name:
      v: main
    source:
      context:
        v: cda
    target:
      context:
        v: bundle
      context type:
        v: variable
      element:
        v: entry
      variable:
        v: e
    target:
      context:
        v: e
      context type:
        v: variable
      element:
        v: resource
      variable:
        v: composition
      transform:
        v: create
      parameter:
        value: String
    target:
      context:
        v: composition
      context type:
        v: variable
      element:
        v: id
      variable:
        v: uuid
      transform:
        v: uuid
    target:
      context:
        v: e
      context type:
        v: variable
      element:
        v: fullUrl
      transform:
        v: append
      parameter:
        value: String
      parameter:
        value: Id
    target:
      context:
        v: bundle
      context type:
        v: variable
      element:
        v: entry
      variable:
        v: e2
    target:
      context:
        v: e2
      context type:
        v: variable
      element:
        v: resource
      variable:
        v: patient
      transform:
        v: create
      parameter:
        value: String
    target:
      context:
        v: patient
      context type:
        v: variable
      element:
        v: id
      variable:
        v: uuid2
      transform:
        v: uuid
    target:
      context:
        v: e2
      context type:
        v: variable

String
v: Composition

String
v: urn:uuid:

Id
v: uuid

String
v: Patient

v: fullUrl

v: append

value: String
  v: urn:uuid:

value: Id
  v: uuid2

name:
  v: CdaFrMDEMapping
variable:
  v: cda
variable:
  v: patient
variable:
  v: composition
variable:
  v: bundle

name:
  v: CdaFrMDEMapping
type mode:
  v: none
documentation:
  v: Main mapping group
input:
  name:
    v: cda
  type:
    v: ClinicalDocument
  mode:
    v: source
input:
  name:
    v: patient
  type:
    v: Patient
  mode:
    v: target
input:
  name:
    v: composition
  type:
    v: Composition
  mode:
    v: target
input:
  name:
    v: bundle
  type:
    v: Bundle
  mode:
    v: target
rule:
  name:
    v: bundleId
  source:
    context:
      v: cda
  target:
    context:
      v: bundle
    context type:
      v: variable
    element:
      v: id
    transform:
      v: uuid
rule:
  name:
    v: bundleIdentifier
  source:
    context:
      v: cda
    element:
      v: id
    variable:
      v: cdaId
  target:
    context:
      v: bundle
    context type:
      v: variable
    element:
      v: identifier
    variable:
      v: identifier
  rule:
    name:
      v: system
    source:
      context:
        v: cdaId
      element:
        v: root
      variable:
        v: root
      condition:
        v: cdaId.extension.exists()
    target:
      context:
        v: identifier
      context type:
        v: variable
      element:
        v: system
      transform:
        v: translate
      parameter:
        value: Id
      parameter:
        value: String
      parameter:
        value: String
  rule:
    name:
      v: value
    source:
      context:
        v: cdaId
      element:
        v: extension
      variable:
        v: extension
    target:
      context:
        v: identifier
      context type:
        v: variable
      element:
        v: value
      transform:
        v: copy
      parameter:
        value: Id
  rule:
    name:
      v: systemOid
    source:
      context:
        v: cdaId
      element:
        v: root
      variable:
        v: root
      condition:
        v: cdaId.extension.empty()
    target:
      context:
        v: identifier
      context type:
        v: variable
      element:
        v: system
      transform:
        v: copy
      parameter:
        value: String
  rule:
    name:
      v: valueOid
    source:
      context:
        v: cdaId
      element:
        v: root
      variable:
        v: root
      condition:
        v: cdaId.extension.empty()
    target:
      context:
        v: identifier
      context type:
        v: variable
      element:
        v: value
      transform:
        v: append
      parameter:
        value: String
      parameter:
        value: Id
rule:
  name:
    v: bundleType
  source:
    context:
      v: cda
  target:
    context:
      v: bundle
    context type:
      v: variable
    element:
      v: type
    transform:
      v: copy
    parameter:
      value: String
        v: document
rule:
  name:
    v: bundleTimestamp
  source:
    context:
      v: cda
    element:
      v: effectiveTime
    variable:
      v: effectiveTime
  target:
    context:
      v: bundle
    context type:
      v: variable
    element:
      v: timestamp
    variable:
      v: timestamp
    transform:
      v: create

Id
v: root

String
v: #oid2uri

String
v: uri

Id
v: extension

String
v: urn:ietf:rfc:3986

String
v: urn:oid:

Id
v: root

value: String
  v: instant

name:
  v: TSInstant
variable:
  v: effectiveTime
variable:
  v: timestamp

name:
  v: composition
source:
  context:
    v: cda
target:
  context:
    v: composition
  context type:
    v: variable
dependent:
  name:
    v: ClinicalDocumentComposition
  variable:
    v: cda
  variable:
    v: composition
  variable:
    v: patient
  variable:
    v: bundle

name:
  v: recordTargetGender
source:
  context:
    v: cda
  element:
    v: recordTarget
  variable:
    v: recordTarget
rule:
  name:
    v: patientRole
  source:
    context:
      v: recordTarget
    element:
      v: patientRole
    variable:
      v: patientRole
  rule:
    name:
      v: cdaPatient
    source:
      context:
        v: patientRole
      element:
        v: patient
      variable:
        v: cdaPatient
    rule:
      name:
        v: patientGender

v: cdaPatient

v: administrativeGenderCode

v: gender

v: MapGender

v: gender

v: patient

name:
  v: cdaComponent
source:
  context:
    v: cda
  element:
    v: component
  variable:
    v: cdaComp
rule:
  name:
    v: structuredBody
  source:
    context:
      v: cdaComp
    element:
      v: structuredBody
    variable:
      v: body
  rule:
    name:
      v: bodyComponent
    source:
      context:
        v: body
      element:
        v: component
      variable:
        v: bodyComp
    rule:
      name:
        v: section

v: bodyComp

v: section

v: section

v: compSection

context:
  v: section

context:
  v: composition
context type:
  v: variable
element:
  v: section
variable:
  v: compSection

name:
  v: sectionTitle
source:
  context:
    v: section
  element:
    v: title
  variable:
    v: sectionTitle
target:
  context:
    v: compSection
  context type:
    v: variable
  element:
    v: title
  transform:
    v: evaluate
  parameter:
    value: String
      v: sectionTitle.xmlText

name:
  v: sectionCode
source:
  context:
    v: section
  element:
    v: code
  variable:
    v: sectionCode
target:
  context:
    v: compSection
  context type:
    v: variable
  element:
    v: code
  variable:
    v: cc
  transform:
    v: create
  parameter:
    value: String
      v: CodeableConcept
dependent:
  name:
    v: CDCodeableConcept
  variable:
    v: sectionCode
  variable:
    v: cc

name:
  v: sectionText
source:
  context:
    v: section
  element:
    v: text
  variable:
    v: sectionText
target:
  context:
    v: compSection
  context type:
    v: variable
  element:
    v: text
  transform:
    v: copy
  parameter:
    value: Id
      v: sectionText

name:
  v: entry
source:
  context:
    v: section
  element:
    v: entry
  variable:
    v: entry
rule:
  name:
    v: organizer
  source:
    context:
      v: entry
    element:
      v: organizer
    variable:
      v: organizer
  rule:
    name:
      v: orgComponent
    source:
      context:
        v: organizer
      element:
        v: component
      variable:
        v: orgComp
    rule:
      name:
        v: observation

v: orgComp

v: observation

v: obs

v: processObs

context:
  v: obs

context:
  v: bundle
context type:
  v: variable
element:
  v: entry
variable:
  v: obsEntry

context:
  v: obsEntry
context type:
  v: variable
element:
  v: resource
variable:
  v: observation
transform:
  v: create
parameter:
  value: String
    v: Observation

context:
  v: observation
context type:
  v: variable
element:
  v: id
variable:
  v: obsUuid
transform:
  v: uuid

context:
  v: obsEntry
context type:
  v: variable
element:
  v: fullUrl
transform:
  v: append
parameter:
  value: String
    v: urn:uuid:
parameter:
  value: Id
    v: obsUuid

context:
  v: compSection
context type:
  v: variable
element:
  v: entry
variable:
  v: obsRef
transform:
  v: create
parameter:
  value: String
    v: Reference

context:
  v: obsRef
context type:
  v: variable
element:
  v: reference
transform:
  v: append
parameter:
  value: String
    v: urn:uuid:
parameter:
  value: Id
    v: obsUuid

name:
  v: ProcessObservation
variable:
  v: cda
variable:
  v: obs
variable:
  v: observation
variable:
  v: patient
variable:
  v: composition

name:
  v: ProcessObservation
type mode:
  v: none
documentation:
  v: Process individual observation using CdaToFHIRTypes functions
input:
  name:
    v: cda
  type:
    v: ClinicalDocument
  mode:
    v: source
input:
  name:
    v: obs
  mode:
    v: source
input:
  name:
    v: observation
  type:
    v: Observation
  mode:
    v: target
input:
  name:
    v: patient
  type:
    v: Patient
  mode:
    v: target
input:
  name:
    v: composition
  type:
    v: Composition
  mode:
    v: target
rule:
  name:
    v: metaWeight
  source:
    context:
      v: obs
    element:
      v: code
    variable:
      v: obsCode
    condition:
      v: code = '29463-7'
  target:
    context:
      v: observation
    context type:
      v: variable
    element:
      v: meta
    variable:
      v: meta
    transform:
      v: create
    parameter:
      value: String
        v: Meta
  rule:
    name:
      v: profileWeight
    source:
      context:
        v: obsCode
    target:
      context:
        v: meta
      context type:
        v: variable
      element:
        v: profile
      transform:
        v: copy
      parameter:
        value: String
rule:
  name:
    v: metaHeight
  source:
    context:
      v: obs
    element:
      v: code
    variable:
      v: obsCode
    condition:
      v: code = '8302-2'
  target:
    context:
      v: observation
    context type:
      v: variable
    element:
      v: meta
    variable:
      v: meta
    transform:
      v: create
    parameter:
      value: String
        v: Meta
  rule:
    name:
      v: profileHeight
    source:
      context:
        v: obsCode
    target:
      context:
        v: meta
      context type:
        v: variable
      element:
        v: profile
      transform:
        v: copy
      parameter:
        value: String
rule:
  name:
    v: metaHeadCirc
  source:
    context:
      v: obs
    element:
      v: code
    variable:
      v: obsCode
    condition:
      v: code = '8287-5'
  target:
    context:
      v: observation
    context type:
      v: variable
    element:
      v: meta
    variable:
      v: meta
    transform:
      v: create
    parameter:
      value: String
        v: Meta
  rule:
    name:
      v: profileHeadCirc
    source:
      context:
        v: obsCode
    target:
      context:
        v: meta
      context type:
        v: variable
      element:
        v: profile
      transform:
        v: copy
      parameter:
        value: String
rule:
  name:
    v: statusCompleted
  source:
    context:
      v: obs
    element:
      v: statusCode
    variable:
      v: statusCode
    condition:
      v: code = 'completed'
  target:
    context:
      v: observation
    context type:
      v: variable
    element:
      v: status
    transform:
      v: copy
    parameter:
      value: String
        v: final
rule:
  name:
    v: statusOther
  source:
    context:
      v: obs
    element:
      v: statusCode
    variable:
      v: statusCode

v: code != 'completed'

context:
  v: observation
context type:
  v: variable
element:
  v: status
variable:
  v: status
transform:
  v: create
parameter:
  value: String
    v: code

name:
  v: CSCode
variable:
  v: statusCode
variable:
  v: status

name:
  v: category
source:
  context:
    v: obs
target:
  context:
    v: observation
  context type:
    v: variable
  element:
    v: category
  variable:
    v: category
  transform:
    v: create
  parameter:
    value: String
      v: CodeableConcept
rule:
  name:
    v: coding
  source:
    context:
      v: obs
  target:
    context:
      v: category
    context type:
      v: variable
    element:
      v: coding
    variable:
      v: coding
    transform:
      v: create
    parameter:
      value: String
        v: Coding
  rule:
    name:
      v: system
    source:
      context:
        v: obs
    target:
      context:
        v: coding
      context type:
        v: variable
      element:
        v: system
      transform:
        v: copy
      parameter:
        value: String
  rule:
    name:
      v: code
    source:
      context:
        v: obs
    target:
      context:
        v: coding
      context type:
        v: variable
      element:
        v: code
      transform:
        v: copy
      parameter:
        value: String

String
v: vital-signs

name:
  v: obsCode
source:
  context:
    v: obs
  element:
    v: code
  variable:
    v: code
target:
  context:
    v: observation
  context type:
    v: variable
  element:
    v: code
  variable:
    v: cc
  transform:
    v: create
  parameter:
    value: String
      v: CodeableConcept
dependent:
  name:
    v: CDCodeableConcept
  variable:
    v: code
  variable:
    v: cc

name:
  v: effectiveDateTime
source:
  context:
    v: obs
  element:
    v: effectiveTime
  variable:
    v: effectiveTime
target:
  context:
    v: observation
  context type:
    v: variable
  element:
    v: effective
  variable:
    v: dt
  transform:
    v: create
  parameter:
    value: String
      v: dateTime
dependent:
  name:
    v: TSDateTime
  variable:
    v: effectiveTime
  variable:
    v: dt

name:
  v: obsValue
source:
  context:
    v: obs
  element:
    v: value
  variable:
    v: value
target:
  context:
    v: observation
  context type:
    v: variable
  element:
    v: value
  variable:
    v: qty
  transform:
    v: create
  parameter:
    value: String
      v: Quantity
dependent:
  name:
    v: PQQuantity
  variable:
    v: value
  variable:
    v: qty

name:
  v: obsSubject
source:
  context:
    v: obs
target:
  context:
    v: observation
  context type:
    v: variable
  element:
    v: subject
  variable:
    v: ref
  transform:
    v: create
  parameter:
    value: String
      v: Reference
target:
  context:
    v: ref
  context type:
    v: variable
  element:
    v: reference
  transform:
    v: evaluate
  parameter:
    value: String
      v: 'urn:uuid:' + %patient.id

name:
  v: MapGender
type mode:
  v: none
documentation:
  v: Map CDA v3 administrative gender to FHIR gender
input:
  name:
    v: src
  mode:
    v: source
input:
  name:
    v: patient
  type:
    v: Patient
  mode:
    v: target
rule:
  name:
    v: genderMale
  source:
    context:
      v: src
    condition:
      v: code = 'M'
  target:
    context:
      v: patient
    context type:
      v: variable
    element:
      v: gender
    transform:
      v: copy
    parameter:
      value: String
        v: male
rule:
  name:
    v: genderFemale
  source:
    context:
      v: src
    condition:
      v: code = 'F'
  target:
    context:
      v: patient
    context type:
      v: variable
    element:
      v: gender
    transform:
      v: copy
    parameter:
      value: String
        v: female
rule:
  name:
    v: genderOther
  source:
    context:
      v: src
    condition:
      v: code = 'UN'
  target:
    context:
      v: patient
    context type:
      v: variable
    element:
      v: gender
    transform:
      v: copy
    parameter:
      value: String
        v: other
rule:
  name:
    v: genderUnknown
  source:
    context:
      v: src
    condition:
      v: code = 'UNK'
  target:
    context:
      v: patient
    context type:
      v: variable
    element:
      v: gender
    transform:
      v: copy
    parameter:
      value: String
        v: unknown