SQL on FHIR
2.1.0-pre - release
SQL on FHIR, published by SQL on FHIR Working Group. This guide is not an authorized publication; it is the continuous build for version 2.1.0-pre built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/FHIR/sql-on-fhir-v2/ and changes regularly. See the Directory of published versions
| Official URL: https://sql-on-fhir.org/ig/Library/OmopFhirPatientJoin | Version: 2.1.0-pre | |||
| Active as of 2026-02-24 | Computable Name: OmopFhirPatientJoin | |||
Uses labels to disambiguate patient views from different sources and joins patient diagnoses for downstream analytics.
SELECT
omop_person.person_id AS omop_person_id,
fhir_patient.id AS fhir_patient_id,
fhir_patient.name,
diagnoses_view.code AS diagnosis_code,
diagnoses_view.display AS diagnosis_display
FROM omop_person
JOIN fhir_patient
ON omop_person.person_id = fhir_patient.mrn
JOIN diagnoses_view
ON diagnoses_view.patient_id = fhir_patient.id
WHERE omop_person.source_system = :source_system
Profile: SQL Query Library
| Depends On | omop_person | OMOP Person view | https://example.org/omop/ViewDefinition/Patient |
| Depends On | fhir_patient | FHIR Patient view | https://example.org/fhir/ViewDefinition/Patient |
| Depends On | diagnoses_view | Diagnosis facts view | https://example.org/ViewDefinition/diagnoses_view |
| source_system | in | string | Source system identifier for OMOP records |
application/sql
SELECT
omop_person.person_id AS omop_person_id,
fhir_patient.id AS fhir_patient_id,
fhir_patient.name,
diagnoses_view.code AS diagnosis_code,
diagnoses_view.display AS diagnosis_display
FROM omop_person
JOIN fhir_patient
ON omop_person.person_id = fhir_patient.mrn
JOIN diagnoses_view
ON diagnoses_view.patient_id = fhir_patient.id
WHERE omop_person.source_system = :source_system