SQL on FHIR, published by HL7 International / FHIR Infrastructure. This guide is not an authorized publication; it is the continuous build for version 3.0.0-ballot built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/HL7/sql-on-fhir/ and changes regularly. See the Directory of published versions
| Page standards status: Informative |
<Library xmlns="http://hl7.org/fhir">
<id value="OmopFhirPatientJoin"/>
<meta>
<profile
value="http://hl7.org/fhir/uv/sql-on-fhir/StructureDefinition/SQLQuery"/>
</meta>
<language value="en"/>
<text>
<status value="extensions"/>
<div xmlns="http://www.w3.org/1999/xhtml">
<table class="narrative-table">
<tbody>
<tr>
<th colspan="2" scope="row" class="row-header">Metadata</th>
</tr>
<tr>
<th scope="row" class="row-header">Title</th>
<td class="content-container">OMOP/FHIR Patient Match with Diagnoses</td>
</tr>
<tr>
<th scope="row" class="row-header">Version</th>
<td class="content-container">3.0.0-ballot</td>
</tr>
<tr>
<th scope="row" class="row-header">Identifier</th>
<td class="content-container">urn:oid:2.16.840.1.113883.4.642.40.77.28.3</td>
</tr>
<tr>
<th scope="row" class="row-header">Jurisdiction</th>
<td class="content-container">
World
</td>
</tr>
<tr>
<th scope="row" class="row-header">Steward (Publisher)</th>
<td class="content-container">HL7 International / FHIR Infrastructure</td>
</tr>
<tr>
<th scope="row" class="row-header">Steward Contact</th>
<td class="content-container">HL7 International / FHIR Infrastructure</td>
</tr>
<tr>
<th scope="row" class="row-header">Description</th>
<td class="content-container"><div><p>Uses labels to disambiguate patient views from different sources and joins
patient diagnoses for downstream analytics.</p>
<pre><code class="language-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
</code></pre>
</div></td>
</tr>
<tr>
<th scope="row" class="row-header">Type</th>
<td class="content-container">
sql-query from <a href="CodeSystem-LibraryTypesCodes.html">http://hl7.org/fhir/uv/sql-on-fhir/CodeSystem/LibraryTypesCodes</a>
</td>
</tr>
<tr>
<th scope="row" class="row-header">Dependency</th>
<td class="content-container">
<em>Description</em>: OMOP Person view
<br/>
<em>Resource</em>: <code>https://example.org/omop/ViewDefinition/Patient</code>
<br/>
<em>Canonical URL</em>: <tt>https://example.org/omop/ViewDefinition/Patient</tt>
</td>
</tr>
<tr>
<th scope="row" class="row-header">Dependency</th>
<td class="content-container">
<em>Description</em>: FHIR Patient view
<br/>
<em>Resource</em>: <code>https://example.org/fhir/ViewDefinition/Patient</code>
<br/>
<em>Canonical URL</em>: <tt>https://example.org/fhir/ViewDefinition/Patient</tt>
</td>
</tr>
<tr>
<th scope="row" class="row-header">Dependency</th>
<td class="content-container">
<em>Description</em>: Diagnosis facts view
<br/>
<em>Resource</em>: <code>https://example.org/ViewDefinition/diagnoses_view</code>
<br/>
<em>Canonical URL</em>: <tt>https://example.org/ViewDefinition/diagnoses_view</tt>
</td>
</tr>
<tr>
<th colspan="2" scope="row" class="row-header"><a name="parameters"> </a>Parameters</th>
</tr>
<tr>
<th scope="row" class="row-header"/>
<td class="content-container">
<table>
<thead>
<tr>
<td><em>Name</em></td>
<td><em>Use</em></td>
<td><em>Card.</em></td>
<td><em>Type</em></td>
<td><em>Documentation</em></td>
</tr>
</thead>
<tbody>
<tr>
<td>source_system</td>
<td>In</td>
<td>0..1</td>
<td>string</td>
<td>Source system identifier for OMOP records</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<th colspan="2" scope="row" class="row-header">Library Content</th>
</tr>
<tr>
<th scope="row" class="row-header">application/sqlContent</th>
<td>
<pre style="border: none;" class="content-container highlight language-cql"><code>Encoded data </code></pre>
</td>
</tr>
<tr>
<th colspan="2" scope="row" class="row-header">Generated using version 0.5.4 of the sample-content-ig Liquid templates</th>
</tr>
</tbody>
</table>
</div>
</text>
<url
value="http://hl7.org/fhir/uv/sql-on-fhir/Library/OmopFhirPatientJoin"/>
<identifier>
<system value="urn:ietf:rfc:3986"/>
<value value="urn:oid:2.16.840.1.113883.4.642.40.77.28.3"/>
</identifier>
<version value="3.0.0-ballot"/>
<name value="OmopFhirPatientJoin"/>
<title value="OMOP/FHIR Patient Match with Diagnoses"/>
<status value="active"/>
<type>
<coding>
<system
value="http://hl7.org/fhir/uv/sql-on-fhir/CodeSystem/LibraryTypesCodes"/>
<code value="sql-query"/>
</coding>
</type>
<date value="2026-08-13T15:42:34+00:00"/>
<publisher value="HL7 International / FHIR Infrastructure"/>
<contact>
<name value="HL7 International / FHIR Infrastructure"/>
<telecom>
<system value="url"/>
<value value="http://www.hl7.org/Special/committees/fiwg"/>
</telecom>
</contact>
<description
value="Uses labels to disambiguate patient views from different sources and joins
patient diagnoses for downstream analytics.
```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
```"/>
<jurisdiction>
<coding>
<system value="http://unstats.un.org/unsd/methods/m49/m49.htm"/>
<code value="001"/>
<display value="World"/>
</coding>
</jurisdiction>
<relatedArtifact>
<type value="depends-on"/>
<label value="omop_person"/>
<display value="OMOP Person view"/>
<resource value="https://example.org/omop/ViewDefinition/Patient"/>
</relatedArtifact>
<relatedArtifact>
<type value="depends-on"/>
<label value="fhir_patient"/>
<display value="FHIR Patient view"/>
<resource value="https://example.org/fhir/ViewDefinition/Patient"/>
</relatedArtifact>
<relatedArtifact>
<type value="depends-on"/>
<label value="diagnoses_view"/>
<display value="Diagnosis facts view"/>
<resource value="https://example.org/ViewDefinition/diagnoses_view"/>
</relatedArtifact>
<parameter>
<name value="source_system"/>
<use value="in"/>
<documentation value="Source system identifier for OMOP records"/>
<type value="string"/>
</parameter>
<content>
<extension
url="http://hl7.org/fhir/uv/sql-on-fhir/StructureDefinition/sql-text">
<valueString
value="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"/>
</extension>
<contentType value="application/sql"/>
<data
value="U0VMRUNUCiAgb21vcF9wZXJzb24ucGVyc29uX2lkIEFTIG9tb3BfcGVyc29uX2lkLAogIGZoaXJfcGF0aWVudC5pZCBBUyBmaGlyX3BhdGllbnRfaWQsCiAgZmhpcl9wYXRpZW50Lm5hbWUsCiAgZGlhZ25vc2VzX3ZpZXcuY29kZSBBUyBkaWFnbm9zaXNfY29kZSwKICBkaWFnbm9zZXNfdmlldy5kaXNwbGF5IEFTIGRpYWdub3Npc19kaXNwbGF5CkZST00gb21vcF9wZXJzb24KSk9JTiBmaGlyX3BhdGllbnQKICBPTiBvbW9wX3BlcnNvbi5wZXJzb25faWQgPSBmaGlyX3BhdGllbnQubXJuCkpPSU4gZGlhZ25vc2VzX3ZpZXcKICBPTiBkaWFnbm9zZXNfdmlldy5wYXRpZW50X2lkID0gZmhpcl9wYXRpZW50LmlkCldIRVJFIG9tb3BfcGVyc29uLnNvdXJjZV9zeXN0ZW0gPSA6c291cmNlX3N5c3RlbQ=="/>
</content>
</Library>