SQL on FHIR
2.1.0-pre - release
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
| Active as of 2026-02-24 |
{
"resourceType" : "Library",
"id" : "SqlOnFhirExample",
"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 SqlOnFhirExample</b></p><a name=\"SqlOnFhirExample\"> </a><a name=\"hcSqlOnFhirExample\"> </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>Participants</h2><table class=\"grid\"><tr><td>Author</td><td>Clinical Informatics Team</td></tr></table><h2>Related Artifacts</h2><table class=\"grid\"><tr><td>Depends On</td><td>patient_view</td><td><code>https://example.org/ViewDefinition/patient_view</code></td></tr><tr><td>Depends On</td><td>blood_pressure_view</td><td><code>https://example.org/ViewDefinition/blood_pressure_view</code></td></tr></table><h2>Parameters</h2><table class=\"grid\"><tr><td>patient_id</td><td>in</td><td/><td/><td>string</td><td>Patient identifier</td></tr><tr><td>from_date</td><td>in</td><td/><td/><td>date</td><td>Start date for observations</td></tr><tr><td>to_date</td><td>in</td><td/><td/><td>date</td><td>End date for observations</td></tr></table><h2>Contents</h2><p><code>application/sql</code></p><pre><code>/*\n@name: SqlOnFhirExample\n@title: Blood Pressure Trend Report\n@description: Return blood pressure observations for a patient in a date range\n@version: 1.0.0\n@status: active\n@author: Clinical Informatics Team\n@publisher: Regional Medical Center\n*/\n\n-- @relatedDependency: https://example.org/ViewDefinition/patient_view as patient_view\n-- @relatedDependency: https://example.org/ViewDefinition/blood_pressure_view as blood_pressure_view\n-- @param: patient_id string Patient identifier\n-- @param: from_date date Start date (inclusive)\n-- @param: to_date date End date (inclusive)\nSELECT\n patient_view.id AS patient_id,\n patient_view.name,\n blood_pressure_view.systolic,\n blood_pressure_view.diastolic,\n blood_pressure_view.effective_date\nFROM patient_view\nJOIN blood_pressure_view\n ON patient_view.id = blood_pressure_view.patient_id\nWHERE patient_view.id = :patient_id\n AND blood_pressure_view.effective_date >= :from_date\n AND blood_pressure_view.effective_date <= :to_date\nORDER BY blood_pressure_view.effective_date</code></pre></div>"
},
"url" : "https://sql-on-fhir.org/ig/Library/SqlOnFhirExample",
"version" : "2.1.0-pre",
"name" : "SqlOnFhirExample",
"title" : "Blood Pressure Trend Report",
"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" : "Demonstrates SQL annotations that tooling can use to generate Library metadata.\n\n```sql\n/*\n@name: SqlOnFhirExample\n@title: Blood Pressure Trend Report\n@description: Return blood pressure observations for a patient in a date range\n@version: 1.0.0\n@status: active\n@author: Clinical Informatics Team\n@publisher: Regional Medical Center\n*/\n\n-- @relatedDependency: https://example.org/ViewDefinition/patient_view as patient_view\n-- @relatedDependency: https://example.org/ViewDefinition/blood_pressure_view as blood_pressure_view\n-- @param: patient_id string Patient identifier\n-- @param: from_date date Start date (inclusive)\n-- @param: to_date date End date (inclusive)\nSELECT\n patient_view.id AS patient_id,\n patient_view.name,\n blood_pressure_view.systolic,\n blood_pressure_view.diastolic,\n blood_pressure_view.effective_date\nFROM patient_view\nJOIN blood_pressure_view\n ON patient_view.id = blood_pressure_view.patient_id\nWHERE patient_view.id = :patient_id\n AND blood_pressure_view.effective_date >= :from_date\n AND blood_pressure_view.effective_date <= :to_date\nORDER BY blood_pressure_view.effective_date\n```",
"jurisdiction" : [
{
"coding" : [
{
"system" : "http://unstats.un.org/unsd/methods/m49/m49.htm",
"code" : "001",
"display" : "World"
}
]
}
],
"author" : [
{
"name" : "Clinical Informatics Team"
}
],
"relatedArtifact" : [
{
"type" : "depends-on",
"label" : "patient_view",
"resource" : "https://example.org/ViewDefinition/patient_view"
},
{
"type" : "depends-on",
"label" : "blood_pressure_view",
"resource" : "https://example.org/ViewDefinition/blood_pressure_view"
}
],
"parameter" : [
{
"name" : "patient_id",
"use" : "in",
"documentation" : "Patient identifier",
"type" : "string"
},
{
"name" : "from_date",
"use" : "in",
"documentation" : "Start date for observations",
"type" : "date"
},
{
"name" : "to_date",
"use" : "in",
"documentation" : "End date for observations",
"type" : "date"
}
],
"content" : [
{
"extension" : [
{
"url" : "https://sql-on-fhir.org/ig/StructureDefinition/sql-text",
"valueString" : "/*\n@name: SqlOnFhirExample\n@title: Blood Pressure Trend Report\n@description: Return blood pressure observations for a patient in a date range\n@version: 1.0.0\n@status: active\n@author: Clinical Informatics Team\n@publisher: Regional Medical Center\n*/\n\n-- @relatedDependency: https://example.org/ViewDefinition/patient_view as patient_view\n-- @relatedDependency: https://example.org/ViewDefinition/blood_pressure_view as blood_pressure_view\n-- @param: patient_id string Patient identifier\n-- @param: from_date date Start date (inclusive)\n-- @param: to_date date End date (inclusive)\nSELECT\n patient_view.id AS patient_id,\n patient_view.name,\n blood_pressure_view.systolic,\n blood_pressure_view.diastolic,\n blood_pressure_view.effective_date\nFROM patient_view\nJOIN blood_pressure_view\n ON patient_view.id = blood_pressure_view.patient_id\nWHERE patient_view.id = :patient_id\n AND blood_pressure_view.effective_date >= :from_date\n AND blood_pressure_view.effective_date <= :to_date\nORDER BY blood_pressure_view.effective_date"
}
],
"contentType" : "application/sql",
"data" : "LyoKQG5hbWU6IFNxbE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