SQL on FHIR
2.1.0-pre - release International flag

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

Library: OMOP/FHIR Patient Match with Diagnoses

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

Related Artifacts

Depends Onomop_personOMOP Person viewhttps://example.org/omop/ViewDefinition/Patient
Depends Onfhir_patientFHIR Patient viewhttps://example.org/fhir/ViewDefinition/Patient
Depends Ondiagnoses_viewDiagnosis facts viewhttps://example.org/ViewDefinition/diagnoses_view

Parameters

source_systeminstringSource system identifier for OMOP records

Contents

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