SQL on FHIR
2.1.0-pre - release
SQL on FHIR - Local Development build (v2.1.0-pre) built by the FHIR (HL7® FHIR® Standard) Build Tools. See the Directory of published versions
Official URL: https://sql-on-fhir.org/ig/Library/SqlOnFhirExample | Version: 2.1.0-pre | |||
Active as of 2025-07-31 | Computable Name: SqlOnFhirExample |
Demonstrating a SQL Query Library with basic annotations that can assist in generating properties and metadata.
/*
@title: SQL on FHIR Example
@description: Demonstrating converting SQL to FHIR Library with basic annotations
@version: 4.2.0
@status: active
@author: Clinical Informatics Team
@publisher: Regional Medical Center
*/
-- @relatedDependency: https://sql-on-fhir.org/ig/StructureDefinition/ViewDefinition/PatientDemographics
-- @relatedDependency: https://sql-on-fhir.org/ig/StructureDefinition/ViewDefinition/PatientAddresses
-- @param: city string
WITH RankedAddresses AS (
SELECT
pd.*,
pa.*,
ROW_NUMBER() OVER (PARTITION BY pd.patient_id ORDER BY pa.address_id) AS address_rank
FROM
patient_demographics pd
JOIN
patient_addresses pa ON pd.patient_id = pa.patient_id
WHERE
pd.age > 18
AND pa.city = :city
)
Profile: SQL Query Library
Author | Clinical Informatics Team |
Depends On | https://sql-on-fhir.org/ig/StructureDefinition/ViewDefinition/PatientDemographics |
Depends On | https://sql-on-fhir.org/ig/StructureDefinition/ViewDefinition/PatientAddresses |
city | in | string |
sql_on_fhir_example.sql: (application/sql
)
/*
@title: Trivial SQL on FHIR Example
@description: Demonstrating converting SQL to FHIR Library with basic annotations
@version: 4.2.0
@status: active
@author: Clinical Informatics Team
@publisher: Regional Medical Center
*/
-- @relatedDependency: https://sql-on-fhir.org/ig/StructureDefinition/ViewDefinition/PatientDemographics
-- @relatedDependency: https://sql-on-fhir.org/ig/StructureDefinition/ViewDefinition/PatientAddresses
-- @param: city string
WITH RankedAddresses AS (
SELECT
pd.*,
pa.*,
ROW_NUMBER() OVER (PARTITION BY pd.patient_id ORDER BY pa.address_id) AS address_rank
FROM
patient_demographics pd
JOIN
patient_addresses pa ON pd.patient_id = pa.patient_id
WHERE
pd.age > 18
AND pa.city = :city
)