SQL on FHIR
2.1.0-pre - release International flag

SQL on FHIR - Local Development build (v2.1.0-pre) built by the FHIR (HL7® FHIR® Standard) Build Tools. See the Directory of published versions

Resource Profile: SQL Query Library

Official URL: https://sql-on-fhir.org/ig/StructureDefinition/SQLQuery Version: 2.1.0-pre
Draft as of 2025-07-31 Computable Name: SQLQuery

A profile for FHIR Library used to represent a single logical SQL query, possibly with multiple SQL dialects.

Purpose:

The FHIR Library represents the SQL expression as a content attachment. If there are multiple dialects specified for the single logical query, each will have a separate attachment.

The dialect may specified using a mime-type parameter dialect. For example:

Content-Type: application/sql; dialect=sql-2

The permitted values for dialect can be found the All SQL Dialect Codes valueset.

The attachment.data is a Base64-encoded string, per the FHIR specification. The library may include relatedArtifacts to refer to ViewDefinition dependencies or other resources that relate to the query.

Conformance Summary:

  • The library type must be a code to indicate the library contains query logic (SQLonFHIR#query-library).
  • The content of the Library must be sql expressions based on the contentType.
  • If present, the dialect must be a memeber of AllSQLDialectCodes valueset.

Usages:

You can also check for usages in the FHIR IG Statistics

Formal Views of Profile Content

Description of Profiles, Differentials, Snapshots and how the different presentations work.

This structure is derived from Library

NameFlagsCard.TypeDescription & Constraints    Filter: Filtersdoco
.. Library C 0..* Library Represents a library of quality improvement components
Constraints: sql-must-be-sql-expressions, sql-dialect-must-be-in-dialect-code-system
... type 1..1 CodeableConcept logic-library | model-definition | asset-collection | module-definition
Required Pattern: At least the following
.... coding 1..* Coding Code defined by a terminology system
Fixed Value: (Complex)
..... system 1..1 uri Identity of the terminology system
Fixed Value: https://sql-on-fhir.org/ig/CodeSystem/LibraryTypesCodes
..... code 1..1 code Symbol in syntax defined by the system
Fixed Value: sql-query

doco Documentation for this format

Constraints

IdGradePath(s)DetailsRequirements
sql-dialect-must-be-in-dialect-code-systemerrorLibraryThe dialect specified in the content attachment must match one of the codes in the AllSQLDialectCodes ValueSet.
: content.where(contentType.contains('dialect')).contentType.select(substring(indexOf('dialect=') + 8) memberOf('https://sql-on-fhir.org/ig/ValueSet/AllSQLDialectCodes')).allTrue()
sql-must-be-sql-expressionserrorLibraryThe content of the Library must be SQL expressions.
: content.contentType.startsWith('application/sql')
NameFlagsCard.TypeDescription & Constraints    Filter: Filtersdoco
.. Library C 0..* Library Represents a library of quality improvement components
Constraints: cnl-0, sql-must-be-sql-expressions, sql-dialect-must-be-in-dialect-code-system
... implicitRules ?!Σ 0..1 uri A set of rules under which this content was created
... contained 0..* Resource Contained, inline Resources
... modifierExtension ?!Σ 0..* Extension Extensions that cannot be ignored
... type Σ 1..1 CodeableConcept logic-library | model-definition | asset-collection | module-definition
Binding: LibraryType (extensible): The type of knowledge asset this library contains.
Required Pattern: At least the following
.... id 0..1 string Unique id for inter-element referencing
.... extension 0..* Extension Additional content defined by implementations
.... coding 1..* Coding Code defined by a terminology system
Fixed Value: (Complex)
..... id 0..1 string Unique id for inter-element referencing
..... extension 0..* Extension Additional content defined by implementations
..... system 1..1 uri Identity of the terminology system
Fixed Value: https://sql-on-fhir.org/ig/CodeSystem/LibraryTypesCodes
..... version 0..1 string Version of the system - if relevant
..... code 1..1 code Symbol in syntax defined by the system
Fixed Value: sql-query
..... display 0..1 string Representation defined by the system
..... userSelected 0..1 boolean If this coding was chosen directly by the user
.... text 0..1 string Plain text representation of the concept

doco Documentation for this format

Terminology Bindings

PathConformanceValueSet / CodeURI
Library.statusrequiredPublicationStatus
http://hl7.org/fhir/ValueSet/publication-status|5.0.0
From the FHIR Standard
Library.typeextensiblePattern Value: sql-query
http://hl7.org/fhir/ValueSet/library-type
From the FHIR Standard

Constraints

IdGradePath(s)DetailsRequirements
cnl-0warningLibraryName should be usable as an identifier for the module by machine processing applications such as code generation
: name.exists() implies name.matches('^[A-Z]([A-Za-z0-9_]){1,254}$')
ele-1error**ALL** elementsAll FHIR elements must have a @value or children
: hasValue() or (children().count() > id.count())
ext-1error**ALL** extensionsMust have either extensions or value[x], not both
: extension.exists() != value.exists()
sql-dialect-must-be-in-dialect-code-systemerrorLibraryThe dialect specified in the content attachment must match one of the codes in the AllSQLDialectCodes ValueSet.
: content.where(contentType.contains('dialect')).contentType.select(substring(indexOf('dialect=') + 8) memberOf('https://sql-on-fhir.org/ig/ValueSet/AllSQLDialectCodes')).allTrue()
sql-must-be-sql-expressionserrorLibraryThe content of the Library must be SQL expressions.
: content.contentType.startsWith('application/sql')
NameFlagsCard.TypeDescription & Constraints    Filter: Filtersdoco
.. Library C 0..* Library Represents a library of quality improvement components
Constraints: cnl-0, sql-must-be-sql-expressions, sql-dialect-must-be-in-dialect-code-system
... id Σ 0..1 id Logical id of this artifact
... meta Σ 0..1 Meta Metadata about the resource
... implicitRules ?!Σ 0..1 uri A set of rules under which this content was created
... language 0..1 code Language of the resource content
Binding: AllLanguages (required): IETF language tag for a human language
Additional BindingsPurpose
CommonLanguages Starter
... text 0..1 Narrative Text summary of the resource, for human interpretation
This profile does not constrain the narrative in regard to content, language, or traceability to data elements
... contained 0..* Resource Contained, inline Resources
... extension 0..* Extension Additional content defined by implementations
... modifierExtension ?!Σ 0..* Extension Extensions that cannot be ignored
... url ΣC 0..1 uri Canonical identifier for this library, represented as a URI (globally unique)
Constraints: cnl-1
... identifier Σ 0..* Identifier Additional identifier for the library
... version Σ 0..1 string Business version of the library
... versionAlgorithm[x] Σ 0..1 How to compare versions
Binding: VersionAlgorithm (extensible)
.... versionAlgorithmString string
.... versionAlgorithmCoding Coding
... name ΣC 0..1 string Name for this library (computer friendly)
... title Σ 0..1 string Name for this library (human friendly)
... subtitle 0..1 string Subordinate title of the library
... status ?!Σ 1..1 code draft | active | retired | unknown
Binding: PublicationStatus (required): The lifecycle status of an artifact.
... experimental Σ 0..1 boolean For testing purposes, not real usage
... type Σ 1..1 CodeableConcept logic-library | model-definition | asset-collection | module-definition
Binding: LibraryType (extensible): The type of knowledge asset this library contains.
Required Pattern: At least the following
.... id 0..1 string Unique id for inter-element referencing
.... extension 0..* Extension Additional content defined by implementations
.... coding 1..* Coding Code defined by a terminology system
Fixed Value: (Complex)
..... id 0..1 string Unique id for inter-element referencing
..... extension 0..* Extension Additional content defined by implementations
..... system 1..1 uri Identity of the terminology system
Fixed Value: https://sql-on-fhir.org/ig/CodeSystem/LibraryTypesCodes
..... version 0..1 string Version of the system - if relevant
..... code 1..1 code Symbol in syntax defined by the system
Fixed Value: sql-query
..... display 0..1 string Representation defined by the system
..... userSelected 0..1 boolean If this coding was chosen directly by the user
.... text 0..1 string Plain text representation of the concept
... subject[x] 0..1 Type of individual the library content is focused on
Binding: ParticipantResourceTypes (extensible): The possible types of subjects for a library (E.g. Patient, Practitioner, Organization, Location, etc.).
.... subjectCodeableConcept CodeableConcept
.... subjectReference Reference(Group)
... date Σ 0..1 dateTime Date last changed
... publisher Σ 0..1 string Name of the publisher/steward (organization or individual)
... contact Σ 0..* ContactDetail Contact details for the publisher
... description Σ 0..1 markdown Natural language description of the library
... useContext Σ 0..* UsageContext The context that the content is intended to support
... jurisdiction Σ 0..* CodeableConcept Intended jurisdiction for library (if applicable)
Binding: JurisdictionValueSet (extensible): Countries and regions within which this artifact is targeted for use.
... purpose 0..1 markdown Why this library is defined
... usage 0..1 markdown Describes the clinical usage of the library
... copyright 0..1 markdown Use and/or publishing restrictions
... copyrightLabel 0..1 string Copyright holder and year(s)
... approvalDate 0..1 date When the library was approved by publisher
... lastReviewDate 0..1 date When the library was last reviewed by the publisher
... effectivePeriod Σ 0..1 Period When the library is expected to be used
... topic 0..* CodeableConcept E.g. Education, Treatment, Assessment, etc
Binding: DefinitionTopic (example): High-level categorization of the definition, used for searching, sorting, and filtering.
... author 0..* ContactDetail Who authored the content
... editor 0..* ContactDetail Who edited the content
... reviewer 0..* ContactDetail Who reviewed the content
... endorser 0..* ContactDetail Who endorsed the content
... relatedArtifact 0..* RelatedArtifact Additional documentation, citations, etc
... parameter 0..* ParameterDefinition Parameters defined by the library
... dataRequirement 0..* DataRequirement What data is referenced by this library
... content Σ 0..* Attachment Contents of the library, either embedded or referenced

doco Documentation for this format

Terminology Bindings

PathConformanceValueSet / CodeURI
Library.languagerequiredAllLanguages
http://hl7.org/fhir/ValueSet/all-languages|5.0.0
From the FHIR Standard
Library.versionAlgorithm[x]extensibleVersionAlgorithm
http://hl7.org/fhir/ValueSet/version-algorithm
From the FHIR Standard
Library.statusrequiredPublicationStatus
http://hl7.org/fhir/ValueSet/publication-status|5.0.0
From the FHIR Standard
Library.typeextensiblePattern Value: sql-query
http://hl7.org/fhir/ValueSet/library-type
From the FHIR Standard
Library.subject[x]extensibleParticipantResourceTypes
http://hl7.org/fhir/ValueSet/participant-resource-types
From the FHIR Standard
Library.jurisdictionextensibleJurisdictionValueSet
http://hl7.org/fhir/ValueSet/jurisdiction
From the FHIR Standard
Library.topicexampleDefinitionTopic
http://hl7.org/fhir/ValueSet/definition-topic
From the FHIR Standard

Constraints

IdGradePath(s)DetailsRequirements
cnl-0warningLibraryName should be usable as an identifier for the module by machine processing applications such as code generation
: name.exists() implies name.matches('^[A-Z]([A-Za-z0-9_]){1,254}$')
cnl-1warningLibrary.urlURL should not contain | or # - these characters make processing canonical references problematic
: exists() implies matches('^[^|# ]+$')
ele-1error**ALL** elementsAll FHIR elements must have a @value or children
: hasValue() or (children().count() > id.count())
ext-1error**ALL** extensionsMust have either extensions or value[x], not both
: extension.exists() != value.exists()
sql-dialect-must-be-in-dialect-code-systemerrorLibraryThe dialect specified in the content attachment must match one of the codes in the AllSQLDialectCodes ValueSet.
: content.where(contentType.contains('dialect')).contentType.select(substring(indexOf('dialect=') + 8) memberOf('https://sql-on-fhir.org/ig/ValueSet/AllSQLDialectCodes')).allTrue()
sql-must-be-sql-expressionserrorLibraryThe content of the Library must be SQL expressions.
: content.contentType.startsWith('application/sql')

This structure is derived from Library

Summary

Differential View

This structure is derived from Library

NameFlagsCard.TypeDescription & Constraints    Filter: Filtersdoco
.. Library C 0..* Library Represents a library of quality improvement components
Constraints: sql-must-be-sql-expressions, sql-dialect-must-be-in-dialect-code-system
... type 1..1 CodeableConcept logic-library | model-definition | asset-collection | module-definition
Required Pattern: At least the following
.... coding 1..* Coding Code defined by a terminology system
Fixed Value: (Complex)
..... system 1..1 uri Identity of the terminology system
Fixed Value: https://sql-on-fhir.org/ig/CodeSystem/LibraryTypesCodes
..... code 1..1 code Symbol in syntax defined by the system
Fixed Value: sql-query

doco Documentation for this format

Constraints

IdGradePath(s)DetailsRequirements
sql-dialect-must-be-in-dialect-code-systemerrorLibraryThe dialect specified in the content attachment must match one of the codes in the AllSQLDialectCodes ValueSet.
: content.where(contentType.contains('dialect')).contentType.select(substring(indexOf('dialect=') + 8) memberOf('https://sql-on-fhir.org/ig/ValueSet/AllSQLDialectCodes')).allTrue()
sql-must-be-sql-expressionserrorLibraryThe content of the Library must be SQL expressions.
: content.contentType.startsWith('application/sql')

Key Elements View

NameFlagsCard.TypeDescription & Constraints    Filter: Filtersdoco
.. Library C 0..* Library Represents a library of quality improvement components
Constraints: cnl-0, sql-must-be-sql-expressions, sql-dialect-must-be-in-dialect-code-system
... implicitRules ?!Σ 0..1 uri A set of rules under which this content was created
... contained 0..* Resource Contained, inline Resources
... modifierExtension ?!Σ 0..* Extension Extensions that cannot be ignored
... type Σ 1..1 CodeableConcept logic-library | model-definition | asset-collection | module-definition
Binding: LibraryType (extensible): The type of knowledge asset this library contains.
Required Pattern: At least the following
.... id 0..1 string Unique id for inter-element referencing
.... extension 0..* Extension Additional content defined by implementations
.... coding 1..* Coding Code defined by a terminology system
Fixed Value: (Complex)
..... id 0..1 string Unique id for inter-element referencing
..... extension 0..* Extension Additional content defined by implementations
..... system 1..1 uri Identity of the terminology system
Fixed Value: https://sql-on-fhir.org/ig/CodeSystem/LibraryTypesCodes
..... version 0..1 string Version of the system - if relevant
..... code 1..1 code Symbol in syntax defined by the system
Fixed Value: sql-query
..... display 0..1 string Representation defined by the system
..... userSelected 0..1 boolean If this coding was chosen directly by the user
.... text 0..1 string Plain text representation of the concept

doco Documentation for this format

Terminology Bindings

PathConformanceValueSet / CodeURI
Library.statusrequiredPublicationStatus
http://hl7.org/fhir/ValueSet/publication-status|5.0.0
From the FHIR Standard
Library.typeextensiblePattern Value: sql-query
http://hl7.org/fhir/ValueSet/library-type
From the FHIR Standard

Constraints

IdGradePath(s)DetailsRequirements
cnl-0warningLibraryName should be usable as an identifier for the module by machine processing applications such as code generation
: name.exists() implies name.matches('^[A-Z]([A-Za-z0-9_]){1,254}$')
ele-1error**ALL** elementsAll FHIR elements must have a @value or children
: hasValue() or (children().count() > id.count())
ext-1error**ALL** extensionsMust have either extensions or value[x], not both
: extension.exists() != value.exists()
sql-dialect-must-be-in-dialect-code-systemerrorLibraryThe dialect specified in the content attachment must match one of the codes in the AllSQLDialectCodes ValueSet.
: content.where(contentType.contains('dialect')).contentType.select(substring(indexOf('dialect=') + 8) memberOf('https://sql-on-fhir.org/ig/ValueSet/AllSQLDialectCodes')).allTrue()
sql-must-be-sql-expressionserrorLibraryThe content of the Library must be SQL expressions.
: content.contentType.startsWith('application/sql')

Snapshot View

NameFlagsCard.TypeDescription & Constraints    Filter: Filtersdoco
.. Library C 0..* Library Represents a library of quality improvement components
Constraints: cnl-0, sql-must-be-sql-expressions, sql-dialect-must-be-in-dialect-code-system
... id Σ 0..1 id Logical id of this artifact
... meta Σ 0..1 Meta Metadata about the resource
... implicitRules ?!Σ 0..1 uri A set of rules under which this content was created
... language 0..1 code Language of the resource content
Binding: AllLanguages (required): IETF language tag for a human language
Additional BindingsPurpose
CommonLanguages Starter
... text 0..1 Narrative Text summary of the resource, for human interpretation
This profile does not constrain the narrative in regard to content, language, or traceability to data elements
... contained 0..* Resource Contained, inline Resources
... extension 0..* Extension Additional content defined by implementations
... modifierExtension ?!Σ 0..* Extension Extensions that cannot be ignored
... url ΣC 0..1 uri Canonical identifier for this library, represented as a URI (globally unique)
Constraints: cnl-1
... identifier Σ 0..* Identifier Additional identifier for the library
... version Σ 0..1 string Business version of the library
... versionAlgorithm[x] Σ 0..1 How to compare versions
Binding: VersionAlgorithm (extensible)
.... versionAlgorithmString string
.... versionAlgorithmCoding Coding
... name ΣC 0..1 string Name for this library (computer friendly)
... title Σ 0..1 string Name for this library (human friendly)
... subtitle 0..1 string Subordinate title of the library
... status ?!Σ 1..1 code draft | active | retired | unknown
Binding: PublicationStatus (required): The lifecycle status of an artifact.
... experimental Σ 0..1 boolean For testing purposes, not real usage
... type Σ 1..1 CodeableConcept logic-library | model-definition | asset-collection | module-definition
Binding: LibraryType (extensible): The type of knowledge asset this library contains.
Required Pattern: At least the following
.... id 0..1 string Unique id for inter-element referencing
.... extension 0..* Extension Additional content defined by implementations
.... coding 1..* Coding Code defined by a terminology system
Fixed Value: (Complex)
..... id 0..1 string Unique id for inter-element referencing
..... extension 0..* Extension Additional content defined by implementations
..... system 1..1 uri Identity of the terminology system
Fixed Value: https://sql-on-fhir.org/ig/CodeSystem/LibraryTypesCodes
..... version 0..1 string Version of the system - if relevant
..... code 1..1 code Symbol in syntax defined by the system
Fixed Value: sql-query
..... display 0..1 string Representation defined by the system
..... userSelected 0..1 boolean If this coding was chosen directly by the user
.... text 0..1 string Plain text representation of the concept
... subject[x] 0..1 Type of individual the library content is focused on
Binding: ParticipantResourceTypes (extensible): The possible types of subjects for a library (E.g. Patient, Practitioner, Organization, Location, etc.).
.... subjectCodeableConcept CodeableConcept
.... subjectReference Reference(Group)
... date Σ 0..1 dateTime Date last changed
... publisher Σ 0..1 string Name of the publisher/steward (organization or individual)
... contact Σ 0..* ContactDetail Contact details for the publisher
... description Σ 0..1 markdown Natural language description of the library
... useContext Σ 0..* UsageContext The context that the content is intended to support
... jurisdiction Σ 0..* CodeableConcept Intended jurisdiction for library (if applicable)
Binding: JurisdictionValueSet (extensible): Countries and regions within which this artifact is targeted for use.
... purpose 0..1 markdown Why this library is defined
... usage 0..1 markdown Describes the clinical usage of the library
... copyright 0..1 markdown Use and/or publishing restrictions
... copyrightLabel 0..1 string Copyright holder and year(s)
... approvalDate 0..1 date When the library was approved by publisher
... lastReviewDate 0..1 date When the library was last reviewed by the publisher
... effectivePeriod Σ 0..1 Period When the library is expected to be used
... topic 0..* CodeableConcept E.g. Education, Treatment, Assessment, etc
Binding: DefinitionTopic (example): High-level categorization of the definition, used for searching, sorting, and filtering.
... author 0..* ContactDetail Who authored the content
... editor 0..* ContactDetail Who edited the content
... reviewer 0..* ContactDetail Who reviewed the content
... endorser 0..* ContactDetail Who endorsed the content
... relatedArtifact 0..* RelatedArtifact Additional documentation, citations, etc
... parameter 0..* ParameterDefinition Parameters defined by the library
... dataRequirement 0..* DataRequirement What data is referenced by this library
... content Σ 0..* Attachment Contents of the library, either embedded or referenced

doco Documentation for this format

Terminology Bindings

PathConformanceValueSet / CodeURI
Library.languagerequiredAllLanguages
http://hl7.org/fhir/ValueSet/all-languages|5.0.0
From the FHIR Standard
Library.versionAlgorithm[x]extensibleVersionAlgorithm
http://hl7.org/fhir/ValueSet/version-algorithm
From the FHIR Standard
Library.statusrequiredPublicationStatus
http://hl7.org/fhir/ValueSet/publication-status|5.0.0
From the FHIR Standard
Library.typeextensiblePattern Value: sql-query
http://hl7.org/fhir/ValueSet/library-type
From the FHIR Standard
Library.subject[x]extensibleParticipantResourceTypes
http://hl7.org/fhir/ValueSet/participant-resource-types
From the FHIR Standard
Library.jurisdictionextensibleJurisdictionValueSet
http://hl7.org/fhir/ValueSet/jurisdiction
From the FHIR Standard
Library.topicexampleDefinitionTopic
http://hl7.org/fhir/ValueSet/definition-topic
From the FHIR Standard

Constraints

IdGradePath(s)DetailsRequirements
cnl-0warningLibraryName should be usable as an identifier for the module by machine processing applications such as code generation
: name.exists() implies name.matches('^[A-Z]([A-Za-z0-9_]){1,254}$')
cnl-1warningLibrary.urlURL should not contain | or # - these characters make processing canonical references problematic
: exists() implies matches('^[^|# ]+$')
ele-1error**ALL** elementsAll FHIR elements must have a @value or children
: hasValue() or (children().count() > id.count())
ext-1error**ALL** extensionsMust have either extensions or value[x], not both
: extension.exists() != value.exists()
sql-dialect-must-be-in-dialect-code-systemerrorLibraryThe dialect specified in the content attachment must match one of the codes in the AllSQLDialectCodes ValueSet.
: content.where(contentType.contains('dialect')).contentType.select(substring(indexOf('dialect=') + 8) memberOf('https://sql-on-fhir.org/ig/ValueSet/AllSQLDialectCodes')).allTrue()
sql-must-be-sql-expressionserrorLibraryThe content of the Library must be SQL expressions.
: content.contentType.startsWith('application/sql')

This structure is derived from Library

Summary

 

Other representations of profile: CSV, Excel, Schematron