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

Library: Blood Pressure Trend Report

Official URL: https://sql-on-fhir.org/ig/Library/SqlOnFhirExample Version: 2.1.0-pre
Active as of 2026-02-24 Computable Name: SqlOnFhirExample

Demonstrates SQL annotations that tooling can use to generate Library metadata.

/*
@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

Participants

AuthorClinical Informatics Team

Related Artifacts

Depends Onpatient_viewhttps://example.org/ViewDefinition/patient_view
Depends Onblood_pressure_viewhttps://example.org/ViewDefinition/blood_pressure_view

Parameters

patient_idinstringPatient identifier
from_dateindateStart date for observations
to_dateindateEnd date for observations

Contents

application/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