SQL on FHIR
3.0.0-ballot - STU 3 Ballot International flag

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

Example ViewDefinition: US Core Blood Pressures

This view acts on the Observation resource to produce a table named "us_core_blood_pressures" where code.coding.exists(system='http://loinc.org' and code=%bp_code).

The table contains the following columns:

NameFhir TypeSQL TypeCollection
idstringString
patient_idstringString
effective_date_timedateTimeDateTime
sbp_quantity_systemuriString
sbp_quantity_codestringString
sbp_quantity_unitstringString
sbp_quantity_valuedecimalDecimal
dbp_quantity_systemuriString
dbp_quantity_codestringString
dbp_quantity_unitstringString
dbp_quantity_valuedecimalDecimal

Constants:

NameValue
systolic_bp8480-6
diastolic_bp8462-4
bp_code85354-9

Selection Rules:

ItemCollTypeDescription
.. us_core_blood_pressuresObservation
... Select
.... idgetResourceKey()
.... patient_idsubject.getReferenceKey(Patient)
Can be used to join to patient tables created by other views.
.... effective_date_timeeffective.ofType(dateTime)
... Selectfor each component.where(code.coding.exists(system='http://loinc.org' and code=%systolic_bp)).first()
.... sbp_quantity_systemvalue.ofType(Quantity).system
.... sbp_quantity_codevalue.ofType(Quantity).code
.... sbp_quantity_unitvalue.ofType(Quantity).unit
.... sbp_quantity_valuevalue.ofType(Quantity).value
... Selectfor each component.where(code.coding.exists(system='http://loinc.org' and code=%diastolic_bp)).first()
.... dbp_quantity_systemvalue.ofType(Quantity).system
.... dbp_quantity_codevalue.ofType(Quantity).code
.... dbp_quantity_unitvalue.ofType(Quantity).unit
.... dbp_quantity_valuevalue.ofType(Quantity).value