Last active
July 21, 2025 19:18
-
-
Save bkaney/3a6fe2ae4179679765490f492b14e651 to your computer and use it in GitHub Desktop.
SQL-on-FHIR - example tool to build FHIR Library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
@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 | |
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 = 'New York' | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"resourceType": "Library", | |
"id": "sql-on-fhir-example", | |
"meta": { | |
"versionId": "1", | |
"lastUpdated": "2025-07-21T15:16:54.620668Z" | |
}, | |
"status": "active", | |
"type": { | |
"coding": [ | |
{ | |
"system": "http://terminology.hl7.org/CodeSystem/library-type", | |
"code": "logic-library", | |
"display": "Logic Library" | |
} | |
] | |
}, | |
"content": [ | |
{ | |
"contentType": "application/sql", | |
"data": "LyoKQHRpdGxlOiBUcml2aWFsIFNRTCBvbiBGSElSIEV4YW1wbGUKQGRlc2NyaXB0aW9uOiBEZW1vbnN0cmF0aW5nIGNvbnZlcnRpbmcgU1FMIHRvIEZISVIgTGlicmFyeSB3aXRoIGJhc2ljIGFubm90YXRpb25zIApAdmVyc2lvbjogNC4yLjAKQHN0YXR1czogYWN0aXZlCkBhdXRob3I6IENsaW5pY2FsIEluZm9ybWF0aWNzIFRlYW0KQHB1Ymxpc2hlcjogUmVnaW9uYWwgTWVkaWNhbCBDZW50ZXIKKi8KCi0tIEByZWxhdGVkRGVwZW5kZW5jeTogaHR0cHM6Ly9zcWwtb24tZmhpci5vcmcvaWcvU3RydWN0dXJlRGVmaW5pdGlvbi9WaWV3RGVmaW5pdGlvbi9QYXRpZW50RGVtb2dyYXBoaWNzCi0tIEByZWxhdGVkRGVwZW5kZW5jeTogaHR0cHM6Ly9zcWwtb24tZmhpci5vcmcvaWcvU3RydWN0dXJlRGVmaW5pdGlvbi9WaWV3RGVmaW5pdGlvbi9QYXRpZW50QWRkcmVzc2VzCldJVEggUmFua2VkQWRkcmVzc2VzIEFTICgKICAgIFNFTEVDVCAKICAgICAgICBwZC4qLAogICAgICAgIHBhLiosCiAgICAgICAgUk9XX05VTUJFUigpIE9WRVIgKFBBUlRJVElPTiBCWSBwZC5wYXRpZW50X2lkIE9SREVSIEJZIHBhLmFkZHJlc3NfaWQpIEFTIGFkZHJlc3NfcmFuawogICAgRlJPTSAKICAgICAgICBwYXRpZW50X2RlbW9ncmFwaGljcyBwZAogICAgSk9JTiAKICAgICAgICBwYXRpZW50X2FkZHJlc3NlcyBwYSBPTiBwZC5wYXRpZW50X2lkID0gcGEucGF0aWVudF9pZAogICAgV0hFUkUgCiAgICAgICAgcGQuYWdlID4gMTgKICAgICAgICBBTkQgcGEuY2l0eSA9ICdOZXcgWW9yaycKKQo=", | |
"title": "sql_on_fhir_example.sql", | |
"creation": "2025-07-21T15:16:54.620675Z" | |
} | |
], | |
"title": "Trivial SQL on FHIR Example", | |
"description": "Demonstrating converting SQL to FHIR Library with basic annotations", | |
"version": "4.2.0", | |
"author": [ | |
{ | |
"name": "Clinical Informatics Team" | |
} | |
], | |
"publisher": "Regional Medical Center", | |
"relatedArtifact": [ | |
{ | |
"type": "depends-on", | |
"resource": "https://sql-on-fhir.org/ig/StructureDefinition/ViewDefinition/PatientDemographics" | |
}, | |
{ | |
"type": "depends-on", | |
"resource": "https://sql-on-fhir.org/ig/StructureDefinition/ViewDefinition/PatientAddresses" | |
} | |
], | |
"name": "TrivialSqlOnFhirExample" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment