Data Management with FHIR
0.1.0 - ci-build France flag

Data Management with FHIR - Local Development build (v0.1.0) built by the FHIR (HL7® FHIR® Standard) Build Tools. See the Directory of published versions

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";
  };
}