# Transformation FHIR DocumentReference en message HL7v2 MDM^T02 (description) - Guide d'implémentation pour l'atelier v0.1.0

* [**Table of Contents**](toc.md)
* [**Artifacts Summary**](artifacts.md)
* **Transformation FHIR DocumentReference en message HL7v2 MDM^T02 (description)**

## StructureMap: Transformation FHIR DocumentReference en message HL7v2 MDM^T02 (description) 

| | |
| :--- | :--- |
| *Official URL*:https://interop.aphp.fr/ig/fhir/atelier/StructureMap/DocumentReferenceToT02 | *Version*:0.1.0 |
| Active as of 2026-03-31 | *Computable Name*:DocumentReferenceToT02 |

 
Transformation FHIR DocumentReference en message HL7v2 MDM^T02 (description) 

**Figure 1 — Transformation FHIR DocumentReference en message HL7v2 MDM**



## Resource Content

```json
{
  "resourceType" : "StructureMap",
  "id" : "DocumentReferenceToT02",
  "url" : "https://interop.aphp.fr/ig/fhir/atelier/StructureMap/DocumentReferenceToT02",
  "version" : "0.1.0",
  "name" : "DocumentReferenceToT02",
  "title" : "Transformation FHIR DocumentReference en message HL7v2 MDM^T02 (description)",
  "status" : "active",
  "date" : "2026-03-31T08:46:55+00:00",
  "publisher" : "AP-HP",
  "contact" : [{
    "name" : "AP-HP",
    "telecom" : [{
      "system" : "url",
      "value" : "https://aphp.fr"
    }]
  }],
  "description" : "Transformation FHIR DocumentReference en message HL7v2 MDM^T02 (description)",
  "jurisdiction" : [{
    "coding" : [{
      "system" : "urn:iso:std:iso:3166",
      "code" : "FRA"
    }]
  }],
  "structure" : [{
    "url" : "http://hl7.org/fhir/StructureDefinition/DocumentReference|4.0.1",
    "mode" : "source",
    "alias" : "DocumentReference"
  },
  {
    "url" : "https://interop.aphp.fr/ig/fhir/atelier/StructureDefinition/mdm|0.1.0",
    "mode" : "target",
    "alias" : "Mdm"
  },
  {
    "url" : "https://interop.aphp.fr/ig/fhir/atelier/StructureDefinition/msh|0.1.0",
    "mode" : "target",
    "alias" : "Msh"
  },
  {
    "url" : "https://interop.aphp.fr/ig/fhir/atelier/StructureDefinition/pid|0.1.0",
    "mode" : "target",
    "alias" : "Pid"
  }],
  "group" : [{
    "name" : "documentReferenceToT02",
    "typeMode" : "none",
    "input" : [{
      "name" : "srcDocRef",
      "type" : "DocumentReference",
      "mode" : "source"
    },
    {
      "name" : "tgtMdm",
      "type" : "Mdm",
      "mode" : "target"
    }],
    "rule" : [{
      "name" : "toMsh",
      "source" : [{
        "context" : "srcDocRef"
      }],
      "target" : [{
        "context" : "tgtMdm",
        "contextType" : "variable",
        "element" : "msh",
        "variable" : "tgtMsh"
      }],
      "dependent" : [{
        "name" : "toMsh",
        "variable" : ["srcDocRef", "tgtMsh"]
      }]
    },
    {
      "name" : "toPid",
      "source" : [{
        "context" : "srcDocRef"
      }],
      "target" : [{
        "context" : "tgtMdm",
        "contextType" : "variable",
        "element" : "pid",
        "variable" : "tgtPid"
      }],
      "dependent" : [{
        "name" : "toPid",
        "variable" : ["srcDocRef", "tgtPid"]
      }]
    }]
  },
  {
    "name" : "toMsh",
    "typeMode" : "none",
    "input" : [{
      "name" : "srcDocRef",
      "mode" : "source"
    },
    {
      "name" : "tgtMsh",
      "type" : "Msh",
      "mode" : "target"
    }],
    "rule" : [{
      "name" : "setFieldSep",
      "source" : [{
        "context" : "srcDocRef"
      }],
      "target" : [{
        "context" : "tgtMsh",
        "contextType" : "variable",
        "element" : "msh1",
        "transform" : "copy",
        "parameter" : [{
          "valueString" : "|"
        }]
      }]
    },
    {
      "name" : "setEncoding",
      "source" : [{
        "context" : "srcDocRef"
      }],
      "target" : [{
        "context" : "tgtMsh",
        "contextType" : "variable",
        "element" : "msh2",
        "transform" : "evaluate",
        "parameter" : [{
          "valueString" : "'^~\\\\&'"
        }]
      }]
    },
    {
      "name" : "setReceivingApp",
      "source" : [{
        "context" : "srcDocRef"
      }],
      "target" : [{
        "context" : "tgtMsh",
        "contextType" : "variable",
        "element" : "msh5",
        "transform" : "copy",
        "parameter" : [{
          "valueString" : "DPI"
        }]
      }]
    },
    {
      "name" : "setReceivingFacility",
      "source" : [{
        "context" : "srcDocRef"
      }],
      "target" : [{
        "context" : "tgtMsh",
        "contextType" : "variable",
        "element" : "msh6",
        "transform" : "copy",
        "parameter" : [{
          "valueString" : "APHP"
        }]
      }]
    },
    {
      "name" : "setDateTime",
      "source" : [{
        "context" : "srcDocRef"
      }],
      "target" : [{
        "context" : "tgtMsh",
        "contextType" : "variable",
        "element" : "msh7",
        "transform" : "evaluate",
        "parameter" : [{
          "valueString" : "now().toString().replace('-', '').replace('T', '').replace(':', '').substring(0, 14)"
        }]
      }]
    },
    {
      "name" : "setMessageType",
      "source" : [{
        "context" : "srcDocRef"
      }],
      "target" : [{
        "context" : "tgtMsh",
        "contextType" : "variable",
        "element" : "msh9",
        "transform" : "copy",
        "parameter" : [{
          "valueString" : "MDM^T02"
        }]
      }]
    },
    {
      "name" : "setMsgControlId",
      "source" : [{
        "context" : "srcDocRef"
      }],
      "target" : [{
        "context" : "tgtMsh",
        "contextType" : "variable",
        "element" : "msh10",
        "transform" : "uuid"
      }]
    },
    {
      "name" : "setProcessingId",
      "source" : [{
        "context" : "srcDocRef"
      }],
      "target" : [{
        "context" : "tgtMsh",
        "contextType" : "variable",
        "element" : "msh11",
        "transform" : "copy",
        "parameter" : [{
          "valueString" : "P"
        }]
      }]
    },
    {
      "name" : "setVersion",
      "source" : [{
        "context" : "srcDocRef"
      }],
      "target" : [{
        "context" : "tgtMsh",
        "contextType" : "variable",
        "element" : "msh12",
        "transform" : "copy",
        "parameter" : [{
          "valueString" : "2.5"
        }]
      }]
    },
    {
      "name" : "setCharSet",
      "source" : [{
        "context" : "srcDocRef"
      }],
      "target" : [{
        "context" : "tgtMsh",
        "contextType" : "variable",
        "element" : "msh18",
        "transform" : "copy",
        "parameter" : [{
          "valueString" : "8859/15"
        }]
      }]
    },
    {
      "name" : "navCustodian",
      "source" : [{
        "context" : "srcDocRef",
        "element" : "custodian",
        "variable" : "srcCustodian"
      }],
      "rule" : [{
        "name" : "navCustIdentifier",
        "source" : [{
          "context" : "srcCustodian",
          "element" : "identifier",
          "variable" : "srcCustIdentifier",
          "condition" : "system = 'https://interop.aphp.fr/info/Device/hopex'"
        }],
        "rule" : [{
          "name" : "setMsh3",
          "source" : [{
            "context" : "srcCustIdentifier",
            "element" : "value",
            "variable" : "srcCustIdentVal"
          }],
          "target" : [{
            "context" : "tgtMsh",
            "contextType" : "variable",
            "element" : "msh3",
            "transform" : "copy",
            "parameter" : [{
              "valueId" : "srcCustIdentVal"
            }]
          }]
        }]
      }]
    },
    {
      "name" : "navUnit",
      "source" : [{
        "context" : "srcDocRef",
        "element" : "author",
        "variable" : "srcServiceRespMed",
        "condition" : "(identifier.system = 'https://interop.aphp.fr/info/Organization/Sirius')"
      }],
      "rule" : [{
        "name" : "navUnitIdentifier",
        "source" : [{
          "context" : "srcServiceRespMed",
          "element" : "identifier",
          "variable" : "srcServiceRespMedId"
        }],
        "rule" : [{
          "name" : "setMsh4",
          "source" : [{
            "context" : "srcServiceRespMedId",
            "element" : "value",
            "variable" : "srcServiceRespMedIdValue",
            "condition" : "($this.length() >= 3)"
          }],
          "target" : [{
            "context" : "tgtMsh",
            "contextType" : "variable",
            "element" : "msh4",
            "transform" : "evaluate",
            "parameter" : [{
              "valueString" : "%srcServiceRespMedIdValue.substring(0, 3)"
            }]
          }]
        }]
      }]
    }]
  },
  {
    "name" : "toPid",
    "typeMode" : "none",
    "input" : [{
      "name" : "srcDocRef",
      "mode" : "source"
    },
    {
      "name" : "tgtPid",
      "type" : "Pid",
      "mode" : "target"
    }],
    "rule" : [{
      "name" : "navSubject",
      "source" : [{
        "context" : "srcDocRef",
        "element" : "subject",
        "variable" : "srcSubject"
      }],
      "rule" : [{
        "name" : "navSubjectReference",
        "source" : [{
          "context" : "srcSubject",
          "element" : "reference",
          "variable" : "srcSubjectReference"
        }],
        "rule" : [{
          "name" : "navContainedSubject",
          "source" : [{
            "context" : "srcDocRef",
            "type" : "Patient",
            "element" : "contained",
            "variable" : "srcDocSubj",
            "condition" : "(('#' + id) = %srcSubjectReference)"
          }],
          "rule" : [{
            "name" : "setPid3",
            "source" : [{
              "context" : "srcDocSubj",
              "element" : "identifier",
              "variable" : "srcDocSubjIdentifier",
              "condition" : "system = 'https://interop.aphp.fr/info/Patient/ipp'"
            }],
            "target" : [{
              "context" : "tgtPid",
              "contextType" : "variable",
              "element" : "pid3",
              "variable" : "tgtPid3"
            },
            {
              "context" : "tgtPid3",
              "contextType" : "variable",
              "element" : "cx5",
              "transform" : "copy",
              "parameter" : [{
                "valueString" : "PN"
              }]
            },
            {
              "context" : "tgtPid3",
              "contextType" : "variable",
              "element" : "cx4",
              "transform" : "copy",
              "parameter" : [{
                "valueString" : "APHP"
              }]
            },
            {
              "context" : "tgtPid3",
              "contextType" : "variable",
              "element" : "cx1",
              "transform" : "evaluate",
              "parameter" : [{
                "valueString" : "%srcDocSubjIdentifier.value"
              }]
            }]
          },
          {
            "name" : "navName",
            "source" : [{
              "context" : "srcDocSubj",
              "element" : "name",
              "variable" : "srcSubjName",
              "condition" : "use = 'official'"
            }],
            "target" : [{
              "context" : "tgtPid",
              "contextType" : "variable",
              "element" : "pid5",
              "variable" : "tgtPid5"
            }],
            "rule" : [{
              "name" : "setFamilyName",
              "source" : [{
                "context" : "srcSubjName",
                "element" : "family",
                "variable" : "srcSubjFamilyName"
              }],
              "target" : [{
                "context" : "tgtPid5",
                "contextType" : "variable",
                "element" : "xpn1",
                "transform" : "copy",
                "parameter" : [{
                  "valueId" : "srcSubjFamilyName"
                }]
              }]
            },
            {
              "name" : "setGivenName",
              "source" : [{
                "context" : "srcSubjName",
                "element" : "given",
                "variable" : "srcSubjGivenName"
              }],
              "target" : [{
                "context" : "tgtPid5",
                "contextType" : "variable",
                "element" : "xpn2",
                "transform" : "copy",
                "parameter" : [{
                  "valueId" : "srcSubjGivenName"
                }]
              }],
              "rule" : [{
                "name" : "navGivenNamesExt",
                "source" : [{
                  "context" : "srcSubjName",
                  "element" : "extension",
                  "variable" : "srcSubjectGivenNamesExt",
                  "condition" : "url = 'https://hl7.fr/ig/fhir/core/StructureDefinition/fr-core-patient-birth-list-given-name'"
                }],
                "rule" : [{
                  "name" : "setGivenNames",
                  "source" : [{
                    "context" : "srcSubjectGivenNamesExt",
                    "type" : "string",
                    "element" : "value",
                    "variable" : "srcSubjectGivenNamesValue"
                  }],
                  "target" : [{
                    "context" : "tgtPid5",
                    "contextType" : "variable",
                    "element" : "xpn3",
                    "transform" : "evaluate",
                    "parameter" : [{
                      "valueString" : "%srcSubjectGivenNamesValue.toString().substring(%srcSubjGivenName.length() + 1)"
                    }]
                  }]
                }]
              }]
            }]
          },
          {
            "name" : "setBirthDate",
            "source" : [{
              "context" : "srcDocSubj",
              "element" : "birthDate",
              "variable" : "srcSubjBirthDate"
            }],
            "target" : [{
              "context" : "tgtPid",
              "contextType" : "variable",
              "element" : "pid7",
              "transform" : "evaluate",
              "parameter" : [{
                "valueString" : "%srcSubjBirthDate.toString().replace('-', '')"
              }]
            }]
          },
          {
            "name" : "setGender",
            "source" : [{
              "context" : "srcDocSubj",
              "element" : "gender",
              "variable" : "srcSubjGender"
            }],
            "target" : [{
              "context" : "tgtPid",
              "contextType" : "variable",
              "element" : "pid8",
              "transform" : "translate",
              "parameter" : [{
                "valueId" : "srcSubjGender"
              },
              {
                "valueString" : "https://interop.aphp.fr/ig/fhir/atelier/ConceptMap/patient-gender-to-aphp-table-0001"
              },
              {
                "valueString" : "code"
              }]
            }]
          },
          {
            "name" : "setPid18",
            "source" : [{
              "context" : "srcDocSubj"
            }],
            "target" : [{
              "context" : "tgtPid",
              "contextType" : "variable",
              "element" : "pid18",
              "transform" : "copy",
              "parameter" : [{
                "valueString" : "NDA"
              }]
            }]
          }]
        }]
      }]
    }]
  }]
}

```
