# Mapping FHIR Patient resource to OMOP Person - Data Management with FHIR v0.1.0

* [**Table of Contents**](toc.md)
* [**Artifacts Summary**](artifacts.md)
* **Mapping FHIR Patient resource to OMOP Person**

## StructureMap: Mapping FHIR Patient resource to OMOP Person 

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

 
Mapping FHIR Patient resource to OMOP Person 

```

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

// Mapping FHIR Patient resource to OMOP Person

uses "http://hl7.org/fhir/StructureDefinition/Patient" alias Patient as source
uses "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/OMOPPerson" alias PersonTable as target

group Person(source src : Patient, target tgt : PersonTable) {
  src.id as srcId -> tgt.person_source_value = srcId;
  src.gender as srcGender then {
    srcGender -> tgt.gender_concept_id = create('Reference') as tgtReference then {
      srcGender ->  translate(srcGender, 'https://interop.aphp.fr/ig/fhir/dm/ConceptMap/hl7-gender-to-ohdsi-gender', 'code') as genderCode,  tgtReference.reference = append('Concept/', genderCode) "ref";
    } "refConcept";
    srcGender -> tgt.gender_source_value = srcGender "sourceGender";
  };
  src.birthDate as srcBirthDate then {
    srcBirthDate -> tgt.birth_datetime = srcBirthDate "dateTime";
    srcBirthDate -> tgt.year_of_birth = (%srcBirthDate.toString().substring(0, 4).toInteger()) "year";
    srcBirthDate -> tgt.month_of_birth = (%srcBirthDate.toString().substring(5, 2).toInteger()) "month";
    srcBirthDate -> tgt.day_of_birth = (%srcBirthDate.toString().substring(8, 2).toInteger()) "day";
  };
}


```



## Resource Content

```json
{
  "resourceType" : "StructureMap",
  "id" : "CoreFHIR2OMOPPerson",
  "url" : "https://interop.aphp.fr/ig/fhir/dm/StructureMap/CoreFHIR2OMOPPerson",
  "version" : "0.1.0",
  "name" : "CoreFHIR2OMOPPerson",
  "title" : "Mapping FHIR Patient resource to OMOP Person",
  "status" : "draft",
  "date" : "2025-10-23T20:49:03+00:00",
  "publisher" : "AP-HP",
  "contact" : [
    {
      "name" : "AP-HP",
      "telecom" : [
        {
          "system" : "url",
          "value" : "https://aphp.fr"
        }
      ]
    }
  ],
  "description" : "Mapping FHIR Patient resource to OMOP Person",
  "jurisdiction" : [
    {
      "coding" : [
        {
          "system" : "urn:iso:std:iso:3166",
          "code" : "FR",
          "display" : "France"
        }
      ]
    }
  ],
  "structure" : [
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/Patient",
      "mode" : "source",
      "alias" : "Patient"
    },
    {
      "url" : "https://interop.aphp.fr/ig/fhir/dm/StructureDefinition/OMOPPerson",
      "mode" : "target",
      "alias" : "PersonTable"
    }
  ],
  "group" : [
    {
      "name" : "Person",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "src",
          "type" : "Patient",
          "mode" : "source"
        },
        {
          "name" : "tgt",
          "type" : "PersonTable",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "id",
          "source" : [
            {
              "context" : "src",
              "element" : "id",
              "variable" : "srcId"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "person_source_value",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueId" : "srcId"
                }
              ]
            }
          ]
        },
        {
          "name" : "gender",
          "source" : [
            {
              "context" : "src",
              "element" : "gender",
              "variable" : "srcGender"
            }
          ],
          "rule" : [
            {
              "name" : "refConcept",
              "source" : [
                {
                  "context" : "srcGender"
                }
              ],
              "target" : [
                {
                  "context" : "tgt",
                  "contextType" : "variable",
                  "element" : "gender_concept_id",
                  "variable" : "tgtReference",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Reference"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "ref",
                  "source" : [
                    {
                      "context" : "srcGender"
                    }
                  ],
                  "target" : [
                    {
                      "contextType" : "variable",
                      "variable" : "genderCode",
                      "transform" : "translate",
                      "parameter" : [
                        {
                          "valueId" : "srcGender"
                        },
                        {
                          "valueString" : "https://interop.aphp.fr/ig/fhir/dm/ConceptMap/hl7-gender-to-ohdsi-gender"
                        },
                        {
                          "valueString" : "code"
                        }
                      ]
                    },
                    {
                      "context" : "tgtReference",
                      "contextType" : "variable",
                      "element" : "reference",
                      "transform" : "append",
                      "parameter" : [
                        {
                          "valueString" : "Concept/"
                        },
                        {
                          "valueId" : "genderCode"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "sourceGender",
              "source" : [
                {
                  "context" : "srcGender"
                }
              ],
              "target" : [
                {
                  "context" : "tgt",
                  "contextType" : "variable",
                  "element" : "gender_source_value",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueId" : "srcGender"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "birthDate",
          "source" : [
            {
              "context" : "src",
              "element" : "birthDate",
              "variable" : "srcBirthDate"
            }
          ],
          "rule" : [
            {
              "name" : "dateTime",
              "source" : [
                {
                  "context" : "srcBirthDate"
                }
              ],
              "target" : [
                {
                  "context" : "tgt",
                  "contextType" : "variable",
                  "element" : "birth_datetime",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueId" : "srcBirthDate"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "year",
              "source" : [
                {
                  "context" : "srcBirthDate"
                }
              ],
              "target" : [
                {
                  "context" : "tgt",
                  "contextType" : "variable",
                  "element" : "year_of_birth",
                  "transform" : "evaluate",
                  "parameter" : [
                    {
                      "valueString" : "%srcBirthDate.toString().substring(0, 4).toInteger()"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "month",
              "source" : [
                {
                  "context" : "srcBirthDate"
                }
              ],
              "target" : [
                {
                  "context" : "tgt",
                  "contextType" : "variable",
                  "element" : "month_of_birth",
                  "transform" : "evaluate",
                  "parameter" : [
                    {
                      "valueString" : "%srcBirthDate.toString().substring(5, 2).toInteger()"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "day",
              "source" : [
                {
                  "context" : "srcBirthDate"
                }
              ],
              "target" : [
                {
                  "context" : "tgt",
                  "contextType" : "variable",
                  "element" : "day_of_birth",
                  "transform" : "evaluate",
                  "parameter" : [
                    {
                      "valueString" : "%srcBirthDate.toString().substring(8, 2).toInteger()"
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

```
