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

Artifacts Summary

This page provides a list of the FHIR artifacts defined as part of this implementation guide.

Behavior: Operation Definitions

These are custom operations that can be supported by and/or invoked by systems conforming to this implementation guide.

SQL Export

Export one or more ViewDefinitions, SQLQuery Libraries and SQLView Libraries as a single asynchronous job, using the FHIR Asynchronous Interaction Request Pattern.

SQL Run

Execute a ViewDefinition, SQLQuery Library or SQLView Library and return the result in the requested output format.

Behavior: Search Parameters

These define the properties by which a RESTful server can be searched. They can also be used for sorting and including related resources.

ViewDefinitionContextQuantitySearchParam

A quantity- or range-valued use context assigned to the view definition

ViewDefinitionContextSearchParam

A use context assigned to the view definition

ViewDefinitionContextTypeQuantitySearchParam

A use context type and quantity- or range-based value assigned to the view definition

ViewDefinitionContextTypeSearchParam

A type of use context assigned to the view definition

ViewDefinitionContextTypeValueSearchParam

A use context type and value assigned to the view definition

ViewDefinitionDateSearchParam

The view definition publication date

ViewDefinitionDescriptionSearchParam

The description of the view definition

ViewDefinitionIdentifierSearchParam

External identifier for the view definition

ViewDefinitionJurisdictionSearchParam

Intended jurisdiction for the view definition

ViewDefinitionNameSearchParam

Computationally friendly name of the view definition

ViewDefinitionProfileSearchParam

A FHIR profile the view definition is intended to be executed against

ViewDefinitionPublisherSearchParam

Name of the publisher of the view definition

ViewDefinitionResourceSearchParam

The FHIR resource type the view definition is based upon

ViewDefinitionStatusSearchParam

The current status of the view definition

ViewDefinitionTitleSearchParam

The human-friendly name of the view definition

ViewDefinitionUrlSearchParam

The uri that identifies the view definition

ViewDefinitionVersionSearchParam

The business version of the view definition

Structures: Additional Resources

'Additional' resources that are not yet published in the FHIR core specification.

View Definition

A ViewDefinition represents a tabular projection of a FHIR resource, where the columns and inclusion criteria are defined by FHIRPath expressions.

Structures: Resource Profiles

These define constraints on FHIR resources for systems conforming to this implementation guide.

SQL Query Library

The SQLQuery profile represents a SQL query that runs against ViewDefinition tables. It bundles the SQL, dependencies, and parameters for sharing and versioning.

SQL View Library

The SQLView profile represents a reusable, named SQL query that other queries reference as a virtual table source, analogous to a SQL view. It bundles the SQL and its dependencies for sharing and versioning. Unlike SQLQuery, an SQLView cannot declare parameters.

Shareable View Definition

A profile for View Definitions intended to be shared between multiple systems. This requires that the View Definition have a defined URL and name. It also requires declaration of the FHIR version that the view is intended to be executed over, and the FHIR type of each column. This ensures consistent interpretation of the view across different view runner implementations.

Tabular View Definition

A profile for View Definitions where each resulting field must contain only a simple scalar value. This is sometimes referred to as 'CSV Mode', but applies to any system that explicitly constrains its views or tables to tabular data.

Structures: Extension Definitions

These define constraints on FHIR data types for systems conforming to this implementation guide.

SQL Text

Plain-text SQL query for human readability. Supplements the base64-encoded Attachment.data.

Terminology: Value Sets

These define sets of codes used by systems conforming to this implementation guide.

All SQL Content Type Codes

ValueSet of all codes from SQL Content Type Codes codesystem

Export Output Format Codes

Output format codes supported by the export operations. Excludes fhir, which applies to the run operations only; see Common Operation Behavior.

Export Status Codes

ValueSet of all codes from Export Status Codes codesystem

Output Format Codes

ValueSet of all codes from the Output Format Codes code system. Used by the synchronous run operations; see Common Operation Behavior.

Terminology: Code Systems

These define new code systems used by systems conforming to this implementation guide.

Export Status Code System

Export status codes for SQL on FHIR.

Output Format Code System

Output format codes for SQL on FHIR.

SQL Content Type Codes

Permitted contentType values for SQLQuery attachments, including dialect-specific variants.

SQL Library Types Code System

Library types for SQL on FHIR.

Example: Example Instances

These are example instances that show what data produced and consumed by systems conforming with this implementation guide might look like.

Active Patient Addresses

A SQL query that composes the ActivePatientsView, demonstrating an SQLQuery that references an SQLView as a virtual table.

Active Patients

A reusable SQL view selecting active patients, intended to be referenced as a virtual table by other queries.

Blood Pressure Trend Report

Annotated SQL query example demonstrating how tooling can derive Library metadata.

CodeSystem Hierarchy

Demonstrates using repeat with nested select to traverse a CodeSystem concept hierarchy. This produces parent-child code pairs by using repeat to walk down the concept tree and a nested forEach to extract each child concept at every level. Useful for building concept maps or analysing hierarchical terminologies.

Condition Flat

A simple view for flattening a Condition resource. Some of the more commonly used fields are included in this flat view. A notable point is flattening of category.coding fields with one forEach construct as FHIRPath will take care of handling of nested arrays.

Encounter Flat

A simple view for flattening an Encounter resource. Some of the more commonly used fields are included in this flat view. Note this is valid for an R4 Encounter resource but not R5 (hence the fhirVersion).

OMOP/FHIR Patient Match with Diagnoses

Disambiguates OMOP and FHIR Patient views and joins diagnoses for context.

Patient Addresses

An example of unnesting patient addresses into multiple rows. This view uses forEach to indicate we are unrolling these into separate rows. The join function is used to create a single address line.

Patient Demographics

A minimal example of a patient demographics view. This view uses the first 'official' patient name for our demographics table.

Patient Names with Index

An example demonstrating the use of %rowIndex to capture the position of elements within a collection. This is useful for preserving FHIR ordering semantics and creating surrogate keys that combine resource ID with element position.

Patient and Contact Address Union

An example of unnesting patient addresses and contact addresss into multiple rows, which are unioned together into a single table.

Questionnaire Response Items

Demonstrates using the repeat directive to recursively flatten nested QuestionnaireResponse items. Unlike forEach, which only unnests a single level, repeat traverses all levels of nesting to produce one row per item regardless of depth. This is useful for analysing survey responses where questions may be grouped into nested sections.

Shareable Patient Demographics

Creates the same view as the 'PatientDemographics' example, but applies both the ShareableViewDefinition and TabularViewDefinition profiles.

US Core Blood Pressures

A simple view of blood pressure observations, with separate columns for systolic and diastolic values.

Unique Patient Addresses

A SQL query that retrieves the most recent address per patient with a city filter.

Other

These are resources that are used within this implementation guide that do not fit into one of the other categories.

ViewDefinition Operations

All the ViewDefinition operations defined by this guide.