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

: OMOP/FHIR Patient Match with Diagnoses - JSON Representation

Active as of 2026-02-24

Raw json | Download

{
  "resourceType" : "Library",
  "id" : "OmopFhirPatientJoin",
  "meta" : {
    "profile" : [
      🔗 "https://sql-on-fhir.org/ig/StructureDefinition/SQLQuery"
    ]
  },
  "text" : {
    "status" : "generated",
    "div" : "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p class=\"res-header-id\"><b>Generated Narrative: Library OmopFhirPatientJoin</b></p><a name=\"OmopFhirPatientJoin\"> </a><a name=\"hcOmopFhirPatientJoin\"> </a><div style=\"display: inline-block; background-color: #d9e0e7; padding: 6px; margin: 4px; border: 1px solid #8da1b4; border-radius: 5px; line-height: 60%\"><p style=\"margin-bottom: 0px\"/><p style=\"margin-bottom: 0px\">Profile: <a href=\"StructureDefinition-SQLQuery.html\">SQL Query Library</a></p></div><h2>Related Artifacts</h2><table class=\"grid\"><tr><td>Depends On</td><td>omop_person</td><td>OMOP Person view</td><td><code>https://example.org/omop/ViewDefinition/Patient</code></td></tr><tr><td>Depends On</td><td>fhir_patient</td><td>FHIR Patient view</td><td><code>https://example.org/fhir/ViewDefinition/Patient</code></td></tr><tr><td>Depends On</td><td>diagnoses_view</td><td>Diagnosis facts view</td><td><code>https://example.org/ViewDefinition/diagnoses_view</code></td></tr></table><h2>Parameters</h2><table class=\"grid\"><tr><td>source_system</td><td>in</td><td/><td/><td>string</td><td>Source system identifier for OMOP records</td></tr></table><h2>Contents</h2><p><code>application/sql</code></p><pre><code>SELECT\n  omop_person.person_id AS omop_person_id,\n  fhir_patient.id AS fhir_patient_id,\n  fhir_patient.name,\n  diagnoses_view.code AS diagnosis_code,\n  diagnoses_view.display AS diagnosis_display\nFROM omop_person\nJOIN fhir_patient\n  ON omop_person.person_id = fhir_patient.mrn\nJOIN diagnoses_view\n  ON diagnoses_view.patient_id = fhir_patient.id\nWHERE omop_person.source_system = :source_system</code></pre></div>"
  },
  "url" : "https://sql-on-fhir.org/ig/Library/OmopFhirPatientJoin",
  "version" : "2.1.0-pre",
  "name" : "OmopFhirPatientJoin",
  "title" : "OMOP/FHIR Patient Match with Diagnoses",
  "status" : "active",
  "type" : {
    "coding" : [
      {
        "system" : "https://sql-on-fhir.org/ig/CodeSystem/LibraryTypesCodes",
        "code" : "sql-query"
      }
    ]
  },
  "date" : "2026-02-24T21:00:17+00:00",
  "publisher" : "SQL on FHIR Working Group",
  "contact" : [
    {
      "name" : "SQL on FHIR Working Group",
      "telecom" : [
        {
          "system" : "url",
          "value" : "https://sql-on-fhir.org"
        }
      ]
    }
  ],
  "description" : "Uses labels to disambiguate patient views from different sources and joins\npatient diagnoses for downstream analytics.\n\n```sql\nSELECT\n  omop_person.person_id AS omop_person_id,\n  fhir_patient.id AS fhir_patient_id,\n  fhir_patient.name,\n  diagnoses_view.code AS diagnosis_code,\n  diagnoses_view.display AS diagnosis_display\nFROM omop_person\nJOIN fhir_patient\n  ON omop_person.person_id = fhir_patient.mrn\nJOIN diagnoses_view\n  ON diagnoses_view.patient_id = fhir_patient.id\nWHERE omop_person.source_system = :source_system\n```",
  "jurisdiction" : [
    {
      "coding" : [
        {
          "system" : "http://unstats.un.org/unsd/methods/m49/m49.htm",
          "code" : "001",
          "display" : "World"
        }
      ]
    }
  ],
  "relatedArtifact" : [
    {
      "type" : "depends-on",
      "label" : "omop_person",
      "display" : "OMOP Person view",
      "resource" : "https://example.org/omop/ViewDefinition/Patient"
    },
    {
      "type" : "depends-on",
      "label" : "fhir_patient",
      "display" : "FHIR Patient view",
      "resource" : "https://example.org/fhir/ViewDefinition/Patient"
    },
    {
      "type" : "depends-on",
      "label" : "diagnoses_view",
      "display" : "Diagnosis facts view",
      "resource" : "https://example.org/ViewDefinition/diagnoses_view"
    }
  ],
  "parameter" : [
    {
      "name" : "source_system",
      "use" : "in",
      "documentation" : "Source system identifier for OMOP records",
      "type" : "string"
    }
  ],
  "content" : [
    {
      "extension" : [
        {
          "url" : "https://sql-on-fhir.org/ig/StructureDefinition/sql-text",
          "valueString" : "SELECT\n  omop_person.person_id AS omop_person_id,\n  fhir_patient.id AS fhir_patient_id,\n  fhir_patient.name,\n  diagnoses_view.code AS diagnosis_code,\n  diagnoses_view.display AS diagnosis_display\nFROM omop_person\nJOIN fhir_patient\n  ON omop_person.person_id = fhir_patient.mrn\nJOIN diagnoses_view\n  ON diagnoses_view.patient_id = fhir_patient.id\nWHERE omop_person.source_system = :source_system"
        }
      ],
      "contentType" : "application/sql",
      "data" : "U0VMRUNUCiAgb21vcF9wZXJzb24ucGVyc29uX2lkIEFTIG9tb3BfcGVyc29uX2lkLAogIGZoaXJfcGF0aWVudC5pZCBBUyBmaGlyX3BhdGllbnRfaWQsCiAgZmhpcl9wYXRpZW50Lm5hbWUsCiAgZGlhZ25vc2VzX3ZpZXcuY29kZSBBUyBkaWFnbm9zaXNfY29kZSwKICBkaWFnbm9zZXNfdmlldy5kaXNwbGF5IEFTIGRpYWdub3Npc19kaXNwbGF5CkZST00gb21vcF9wZXJzb24KSk9JTiBmaGlyX3BhdGllbnQKICBPTiBvbW9wX3BlcnNvbi5wZXJzb25faWQgPSBmaGlyX3BhdGllbnQubXJuCkpPSU4gZGlhZ25vc2VzX3ZpZXcKICBPTiBkaWFnbm9zZXNfdmlldy5wYXRpZW50X2lkID0gZmhpcl9wYXRpZW50LmlkCldIRVJFIG9tb3BfcGVyc29uLnNvdXJjZV9zeXN0ZW0gPSA6c291cmNlX3N5c3RlbQ=="
    }
  ]
}