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="SqlOnFhirExample"/>
<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">Blood Pressure Trend Report</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.4</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">Developer</th>
<td class="content-container">Clinical Informatics Team</td>
</tr>
<tr>
<th scope="row" class="row-header">Description</th>
<td class="content-container"><div><p>Demonstrates SQL annotations that tooling can use to generate Library metadata.</p>
<pre><code class="language-sql">/*
@name: SqlOnFhirExample
@title: Blood Pressure Trend Report
@description: Return blood pressure observations for a patient in a date range
@version: 1.0.0
@status: active
@author: Clinical Informatics Team
@publisher: Regional Medical Center
*/
-- @relatedDependency: https://example.org/ViewDefinition/patient_view as patient_view
-- @relatedDependency: https://example.org/ViewDefinition/blood_pressure_view as blood_pressure_view
-- @param: patient_id string Patient identifier
-- @param: from_date date Start date (inclusive)
-- @param: to_date date End date (inclusive)
SELECT
patient_view.id AS patient_id,
patient_view.name,
blood_pressure_view.systolic,
blood_pressure_view.diastolic,
blood_pressure_view.effective_date
FROM patient_view
JOIN blood_pressure_view
ON patient_view.id = blood_pressure_view.patient_id
WHERE patient_view.id = :patient_id
AND blood_pressure_view.effective_date >= :from_date
AND blood_pressure_view.effective_date <= :to_date
ORDER BY blood_pressure_view.effective_date
</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>Resource</em>: <code>https://example.org/ViewDefinition/patient_view</code>
<br/>
<em>Canonical URL</em>: <tt>https://example.org/ViewDefinition/patient_view</tt>
</td>
</tr>
<tr>
<th scope="row" class="row-header">Dependency</th>
<td class="content-container">
<em>Resource</em>: <code>https://example.org/ViewDefinition/blood_pressure_view</code>
<br/>
<em>Canonical URL</em>: <tt>https://example.org/ViewDefinition/blood_pressure_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>patient_id</td>
<td>In</td>
<td>0..1</td>
<td>string</td>
<td>Patient identifier</td>
</tr>
<tr>
<td>from_date</td>
<td>In</td>
<td>0..1</td>
<td>date</td>
<td>Start date for observations</td>
</tr>
<tr>
<td>to_date</td>
<td>In</td>
<td>0..1</td>
<td>date</td>
<td>End date for observations</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/SqlOnFhirExample"/>
<identifier>
<system value="urn:ietf:rfc:3986"/>
<value value="urn:oid:2.16.840.1.113883.4.642.40.77.28.4"/>
</identifier>
<version value="3.0.0-ballot"/>
<name value="SqlOnFhirExample"/>
<title value="Blood Pressure Trend Report"/>
<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="Demonstrates SQL annotations that tooling can use to generate Library metadata.
```sql
/*
@name: SqlOnFhirExample
@title: Blood Pressure Trend Report
@description: Return blood pressure observations for a patient in a date range
@version: 1.0.0
@status: active
@author: Clinical Informatics Team
@publisher: Regional Medical Center
*/
-- @relatedDependency: https://example.org/ViewDefinition/patient_view as patient_view
-- @relatedDependency: https://example.org/ViewDefinition/blood_pressure_view as blood_pressure_view
-- @param: patient_id string Patient identifier
-- @param: from_date date Start date (inclusive)
-- @param: to_date date End date (inclusive)
SELECT
patient_view.id AS patient_id,
patient_view.name,
blood_pressure_view.systolic,
blood_pressure_view.diastolic,
blood_pressure_view.effective_date
FROM patient_view
JOIN blood_pressure_view
ON patient_view.id = blood_pressure_view.patient_id
WHERE patient_view.id = :patient_id
AND blood_pressure_view.effective_date >= :from_date
AND blood_pressure_view.effective_date <= :to_date
ORDER BY blood_pressure_view.effective_date
```"/>
<jurisdiction>
<coding>
<system value="http://unstats.un.org/unsd/methods/m49/m49.htm"/>
<code value="001"/>
<display value="World"/>
</coding>
</jurisdiction>
<author>
<name value="Clinical Informatics Team"/>
</author>
<relatedArtifact>
<type value="depends-on"/>
<label value="patient_view"/>
<resource value="https://example.org/ViewDefinition/patient_view"/>
</relatedArtifact>
<relatedArtifact>
<type value="depends-on"/>
<label value="blood_pressure_view"/>
<resource value="https://example.org/ViewDefinition/blood_pressure_view"/>
</relatedArtifact>
<parameter>
<name value="patient_id"/>
<use value="in"/>
<documentation value="Patient identifier"/>
<type value="string"/>
</parameter>
<parameter>
<name value="from_date"/>
<use value="in"/>
<documentation value="Start date for observations"/>
<type value="date"/>
</parameter>
<parameter>
<name value="to_date"/>
<use value="in"/>
<documentation value="End date for observations"/>
<type value="date"/>
</parameter>
<content>
<extension
url="http://hl7.org/fhir/uv/sql-on-fhir/StructureDefinition/sql-text">
<valueString
value="/*
@name: SqlOnFhirExample
@title: Blood Pressure Trend Report
@description: Return blood pressure observations for a patient in a date range
@version: 1.0.0
@status: active
@author: Clinical Informatics Team
@publisher: Regional Medical Center
*/
-- @relatedDependency: https://example.org/ViewDefinition/patient_view as patient_view
-- @relatedDependency: https://example.org/ViewDefinition/blood_pressure_view as blood_pressure_view
-- @param: patient_id string Patient identifier
-- @param: from_date date Start date (inclusive)
-- @param: to_date date End date (inclusive)
SELECT
patient_view.id AS patient_id,
patient_view.name,
blood_pressure_view.systolic,
blood_pressure_view.diastolic,
blood_pressure_view.effective_date
FROM patient_view
JOIN blood_pressure_view
ON patient_view.id = blood_pressure_view.patient_id
WHERE patient_view.id = :patient_id
AND blood_pressure_view.effective_date >= :from_date
AND blood_pressure_view.effective_date <= :to_date
ORDER BY blood_pressure_view.effective_date"/>
</extension>
<contentType value="application/sql"/>
<data
value="LyoKQG5hbWU6IFNxbE9uRmhpckV4YW1wbGUKQHRpdGxlOiBCbG9vZCBQcmVzc3VyZSBUcmVuZCBSZXBvcnQKQGRlc2NyaXB0aW9u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