SQL on FHIR
2.1.0-pre - release
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/HL7/sql-on-fhir/ and changes regularly. See the Directory of published versions
| Official URL: https://sql-on-fhir.org/ig/StructureDefinition/SQLView | Version: 2.1.0-pre | |||
| Draft as of 2026-06-13 | Computable Name: SQLView | |||
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.
Use SQLView for a reusable, named SQL query that other queries reference as a virtual table source, analogous to a SQL view. An SQLView is a near-twin of SQLQuery: it bundles SQL and its dependencies for sharing and versioning, but it is identified by its canonical URL so that other SQLQueries and SQLViews can build upon it.
The key differences from SQLQuery are:
type is fixed to LibraryTypesCodes#sql-view.SQLView does not define table schemas, data extraction, execution behaviour, or APIs; those belong to ViewDefinition and its operations. An SQLView references ViewDefinitions and other SQLViews; execution environments resolve these to physical or virtual tables.
Use relatedArtifact with type = "depends-on" to list the ViewDefinitions and
SQLViews this view builds upon. Each resource is the canonical URL of a
ViewDefinition or another SQLView, and each label defines the table name used
in the SQL.
"relatedArtifact": [
{ "type": "depends-on", "resource": "https://example.org/ViewDefinition/patient_view", "label": "patient_view" },
{ "type": "depends-on", "resource": "https://sql-on-fhir.org/ig/Library/ActivePatientsView", "label": "active_patients" }
]
The allowed targets are recorded as a targetProfile on
relatedArtifact.resource (Canonical(ViewDefinition or SQLView)). Validators
enforce this whenever the canonical resolves to a known resource; for canonicals
that cannot be resolved the constraint is advisory.
Unlike SQLQuery, an SQLView SHALL NOT declare Library.parameter entries
(parameter is constrained to 0..0). A view is a fixed, reusable building
block; callers compose with it by referencing it from a parameterised SQLQuery.
Store the view’s SQL in content exactly as for SQLQuery:
contentType starting with application/sql, the base64-encoded data element,
and an optional sql-text extension for
human readability. Dialect-specific variants follow the same selection rules as
SQLQuery.
Constraints:
LibraryTypesCodes#sql-viewLibrary.parameter SHALL be absentcontent.contentType SHALL start with application/sqlcontent.data SHALL be present; the sql-text extension MAY carry a plain-text copyrelatedArtifact with type = "depends-on", a label,
and a resource referencing a ViewDefinition or SQLViewFor notes on query composition, see the Notes tab below.
Usages:
You can also check for usages in the FHIR IG Statistics
Description of Profiles, Differentials, Snapshots and how the different presentations work.
This structure is derived from Library
| Name | Flags | Card. | Type | Description & Constraints Filter: ![]() ![]() | ||||
|---|---|---|---|---|---|---|---|---|
![]() |
C | 0..* | Library | Represents a library of quality improvement components Interfaces Implemented: MetadataResource Constraints: sql-must-be-sql-expressions | ||||
![]() ![]() |
1..1 | CodeableConcept | logic-library | model-definition | asset-collection | module-definition Required Pattern: At least the following | |||||
![]() ![]() ![]() |
1..* | Coding | Code defined by a terminology system Fixed Value: (Complex) | |||||
![]() ![]() ![]() ![]() |
1..1 | uri | Identity of the terminology system Fixed Value: https://sql-on-fhir.org/ig/CodeSystem/LibraryTypesCodes | |||||
![]() ![]() ![]() ![]() |
1..1 | code | Symbol in syntax defined by the system Fixed Value: sql-view | |||||
![]() ![]() |
S | 0..* | RelatedArtifact | Additional documentation, citations, etc | ||||
![]() ![]() ![]() |
S | 1..1 | code | depends-on for ViewDefinition or SQLView references Required Pattern: depends-on | ||||
![]() ![]() ![]() |
SC | 1..1 | string | Table name used in SQL view Constraints: sql-name | ||||
![]() ![]() ![]() |
S | 1..1 | canonical(View Definition | SQL View Library) | Canonical URL of a ViewDefinition or SQLView | ||||
![]() ![]() |
0..0 | Not permitted (views cannot be parameterised) | ||||||
![]() ![]() |
S | 1..* | Attachment | Contents of the library, either embedded or referenced | ||||
![]() ![]() ![]() |
Content/Rules for all slices | |||||||
![]() ![]() ![]() ![]() |
S | 0..1 | string | Plain-text SQL for readability URL: https://sql-on-fhir.org/ig/StructureDefinition/sql-text | ||||
![]() ![]() ![]() |
S | 1..1 | code | application/sql or application/sql;dialect=... Binding: MimeTypes (required)
| ||||
![]() ![]() ![]() |
S | 1..1 | base64Binary | SQL view (base64-encoded) | ||||
Documentation for this format | ||||||||
| Path | Status | Usage | ValueSet | Version | Source |
| Library.content.contentType | Base | required | Mime Types | 📦5.0.0 | FHIR Std. |
| Id | Grade | Path(s) | Description | Expression |
| sql-must-be-sql-expressions | error | Library | The content of the Library must be SQL expressions. |
content.all(contentType.startsWith('application/sql'))
|
| sql-name | error | Library.relatedArtifact.label | Name is limited to letters, numbers, or underscores and cannot start with an underscore -- i.e. with a regular expression of: ^[A-Za-z][A-Za-z0-9_]*$ This makes it usable as table names in a wide variety of databases. |
empty() or matches('^[A-Za-z][A-Za-z0-9_]*$')
|
| Name | Flags | Card. | Type | Description & Constraints Filter: ![]() ![]() | ||||
|---|---|---|---|---|---|---|---|---|
![]() |
C | 0..* | Library | Represents a library of quality improvement components Interfaces Implemented: MetadataResource Constraints: cnl-0, sql-must-be-sql-expressions | ||||
![]() ![]() |
?!Σ | 0..1 | uri | A set of rules under which this content was created | ||||
![]() ![]() |
0..* | Resource | Contained, inline Resources | |||||
![]() ![]() |
?!Σ | 0..* | Extension | Extensions that cannot be ignored | ||||
![]() ![]() |
?!Σ | 1..1 | code | draft | active | retired | unknown Binding: PublicationStatus (required): The lifecycle status of an artifact. | ||||
![]() ![]() |
Σ | 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 | ||||
![]() ![]() ![]() |
0..1 | string | Unique id for inter-element referencing | |||||
![]() ![]() ![]() |
0..* | Extension | Additional content defined by implementations | |||||
![]() ![]() ![]() |
1..* | Coding | Code defined by a terminology system Fixed Value: (Complex) | |||||
![]() ![]() ![]() ![]() |
0..1 | string | Unique id for inter-element referencing | |||||
![]() ![]() ![]() ![]() |
0..* | Extension | Additional content defined by implementations | |||||
![]() ![]() ![]() ![]() |
1..1 | uri | Identity of the terminology system Fixed Value: https://sql-on-fhir.org/ig/CodeSystem/LibraryTypesCodes | |||||
![]() ![]() ![]() ![]() |
0..1 | string | Version of the system - if relevant | |||||
![]() ![]() ![]() ![]() |
1..1 | code | Symbol in syntax defined by the system Fixed Value: sql-view | |||||
![]() ![]() ![]() ![]() |
0..1 | string | Representation defined by the system | |||||
![]() ![]() ![]() ![]() |
0..1 | boolean | If this coding was chosen directly by the user | |||||
![]() ![]() ![]() |
0..1 | string | Plain text representation of the concept | |||||
![]() ![]() |
S | 0..* | RelatedArtifact | Additional documentation, citations, etc | ||||
![]() ![]() ![]() |
SΣ | 1..1 | code | depends-on for ViewDefinition or SQLView references Binding: RelatedArtifactType (required): The type of relationship to the related artifact. Required Pattern: depends-on | ||||
![]() ![]() ![]() |
SΣC | 1..1 | string | Table name used in SQL view Constraints: sql-name | ||||
![]() ![]() ![]() |
SΣ | 1..1 | canonical(View Definition | SQL View Library) | Canonical URL of a ViewDefinition or SQLView | ||||
![]() ![]() |
SΣ | 1..* | Attachment | Contents of the library, either embedded or referenced | ||||
![]() ![]() ![]() |
Content/Rules for all slices | |||||||
![]() ![]() ![]() ![]() |
S | 0..1 | string | Plain-text SQL for readability URL: https://sql-on-fhir.org/ig/StructureDefinition/sql-text | ||||
![]() ![]() ![]() |
SΣC | 1..1 | code | application/sql or application/sql;dialect=... Binding: MimeTypes (required)
Example General: text/plain; charset=UTF-8, image/png | ||||
![]() ![]() ![]() |
SC | 1..1 | base64Binary | SQL view (base64-encoded) | ||||
Documentation for this format | ||||||||
| Path | Status | Usage | ValueSet | Version | Source |
| Library.status | Base | required | PublicationStatus | 📍5.0.0 | FHIR Std. |
| Library.type | Base | extensible | Library Type | 📍5.0.0 | FHIR Std. |
| Library.relatedArtifact.type | Base | required | RelatedArtifactType | 📍5.0.0 | FHIR Std. |
| Library.content.contentType | Base | required | Mime Types | 📦5.0.0 | FHIR Std. |
| Id | Grade | Path(s) | Description | Expression |
| cnl-0 | warning | Library | Name 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-1 | error | **ALL** elements | All FHIR elements must have a @value or children |
hasValue() or (children().count() > id.count())
|
| ext-1 | error | **ALL** extensions | Must have either extensions or value[x], not both |
extension.exists() != value.exists()
|
| sql-must-be-sql-expressions | error | Library | The content of the Library must be SQL expressions. |
content.all(contentType.startsWith('application/sql'))
|
| sql-name | error | Library.relatedArtifact.label | Name is limited to letters, numbers, or underscores and cannot start with an underscore -- i.e. with a regular expression of: ^[A-Za-z][A-Za-z0-9_]*$ This makes it usable as table names in a wide variety of databases. |
empty() or matches('^[A-Za-z][A-Za-z0-9_]*$')
|
| Name | Flags | Card. | Type | Description & Constraints Filter: ![]() ![]() | ||||
|---|---|---|---|---|---|---|---|---|
![]() |
C | 0..* | Library | Represents a library of quality improvement components Interfaces Implemented: MetadataResource Constraints: cnl-0, sql-must-be-sql-expressions | ||||
![]() ![]() |
Σ | 0..1 | id | Logical id of this artifact | ||||
![]() ![]() |
Σ | 0..1 | Meta | Metadata about the resource | ||||
![]() ![]() |
?!Σ | 0..1 | uri | A set of rules under which this content was created | ||||
![]() ![]() |
0..1 | code | Language of the resource content Binding: AllLanguages (required): IETF language tag for a human language
| |||||
![]() ![]() |
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 | |||||
![]() ![]() |
0..* | Resource | Contained, inline Resources | |||||
![]() ![]() |
0..* | Extension | Additional content defined by implementations | |||||
![]() ![]() |
?!Σ | 0..* | Extension | Extensions that cannot be ignored | ||||
![]() ![]() |
ΣC | 0..1 | uri | Canonical identifier for this library, represented as a URI (globally unique) Constraints: cnl-1 | ||||
![]() ![]() |
Σ | 0..* | Identifier | Additional identifier for the library | ||||
![]() ![]() |
Σ | 0..1 | string | Business version of the library | ||||
![]() ![]() |
Σ | 0..1 | How to compare versions Binding: VersionAlgorithm (extensible) | |||||
![]() ![]() ![]() |
string | |||||||
![]() ![]() ![]() |
Coding | |||||||
![]() ![]() |
ΣC | 0..1 | string | Name for this library (computer friendly) | ||||
![]() ![]() |
Σ | 0..1 | string | Name for this library (human friendly) | ||||
![]() ![]() |
0..1 | string | Subordinate title of the library | |||||
![]() ![]() |
?!Σ | 1..1 | code | draft | active | retired | unknown Binding: PublicationStatus (required): The lifecycle status of an artifact. | ||||
![]() ![]() |
Σ | 0..1 | boolean | For testing purposes, not real usage | ||||
![]() ![]() |
Σ | 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 | ||||
![]() ![]() ![]() |
0..1 | string | Unique id for inter-element referencing | |||||
![]() ![]() ![]() |
0..* | Extension | Additional content defined by implementations | |||||
![]() ![]() ![]() |
1..* | Coding | Code defined by a terminology system Fixed Value: (Complex) | |||||
![]() ![]() ![]() ![]() |
0..1 | string | Unique id for inter-element referencing | |||||
![]() ![]() ![]() ![]() |
0..* | Extension | Additional content defined by implementations | |||||
![]() ![]() ![]() ![]() |
1..1 | uri | Identity of the terminology system Fixed Value: https://sql-on-fhir.org/ig/CodeSystem/LibraryTypesCodes | |||||
![]() ![]() ![]() ![]() |
0..1 | string | Version of the system - if relevant | |||||
![]() ![]() ![]() ![]() |
1..1 | code | Symbol in syntax defined by the system Fixed Value: sql-view | |||||
![]() ![]() ![]() ![]() |
0..1 | string | Representation defined by the system | |||||
![]() ![]() ![]() ![]() |
0..1 | boolean | If this coding was chosen directly by the user | |||||
![]() ![]() ![]() |
0..1 | string | Plain text representation of the concept | |||||
![]() ![]() |
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.). | ||||||
![]() ![]() ![]() |
CodeableConcept | |||||||
![]() ![]() ![]() |
Reference(Group) | |||||||
![]() ![]() |
Σ | 0..1 | dateTime | Date last changed | ||||
![]() ![]() |
Σ | 0..1 | string | Name of the publisher/steward (organization or individual) | ||||
![]() ![]() |
Σ | 0..* | ContactDetail | Contact details for the publisher | ||||
![]() ![]() |
Σ | 0..1 | markdown | Natural language description of the library | ||||
![]() ![]() |
Σ | 0..* | UsageContext | The context that the content is intended to support | ||||
![]() ![]() |
Σ | 0..* | CodeableConcept | Intended jurisdiction for library (if applicable) Binding: JurisdictionValueSet (extensible): Countries and regions within which this artifact is targeted for use. | ||||
![]() ![]() |
0..1 | markdown | Why this library is defined | |||||
![]() ![]() |
0..1 | markdown | Describes the clinical usage of the library | |||||
![]() ![]() |
0..1 | markdown | Use and/or publishing restrictions | |||||
![]() ![]() |
0..1 | string | Copyright holder and year(s) | |||||
![]() ![]() |
0..1 | date | When the library was approved by publisher | |||||
![]() ![]() |
0..1 | date | When the library was last reviewed by the publisher | |||||
![]() ![]() |
Σ | 0..1 | Period | When the library is expected to be used | ||||
![]() ![]() |
0..* | CodeableConcept | E.g. Education, Treatment, Assessment, etc Binding: DefinitionTopic (example): High-level categorization of the definition, used for searching, sorting, and filtering. | |||||
![]() ![]() |
0..* | ContactDetail | Who authored the content | |||||
![]() ![]() |
0..* | ContactDetail | Who edited the content | |||||
![]() ![]() |
0..* | ContactDetail | Who reviewed the content | |||||
![]() ![]() |
0..* | ContactDetail | Who endorsed the content | |||||
![]() ![]() |
S | 0..* | RelatedArtifact | Additional documentation, citations, etc | ||||
![]() ![]() ![]() |
0..1 | id | Unique id for inter-element referencing | |||||
![]() ![]() ![]() |
0..* | Extension | Additional content defined by implementations Slice: Unordered, Open by value:url | |||||
![]() ![]() ![]() |
SΣ | 1..1 | code | depends-on for ViewDefinition or SQLView references Binding: RelatedArtifactType (required): The type of relationship to the related artifact. Required Pattern: depends-on | ||||
![]() ![]() ![]() |
Σ | 0..* | CodeableConcept | Additional classifiers Binding: CitationArtifactClassifier (example): Additional classifiers for the related artifact. | ||||
![]() ![]() ![]() |
SΣC | 1..1 | string | Table name used in SQL view Constraints: sql-name | ||||
![]() ![]() ![]() |
Σ | 0..1 | string | Brief description of the related artifact | ||||
![]() ![]() ![]() |
Σ | 0..1 | markdown | Bibliographic citation for the artifact | ||||
![]() ![]() ![]() |
Σ | 0..1 | Attachment | What document is being referenced | ||||
![]() ![]() ![]() |
SΣ | 1..1 | canonical(View Definition | SQL View Library) | Canonical URL of a ViewDefinition or SQLView | ||||
![]() ![]() ![]() |
Σ | 0..1 | Reference(Resource) | What artifact, if not a conformance resource | ||||
![]() ![]() ![]() |
Σ | 0..1 | code | draft | active | retired | unknown Binding: PublicationStatus (required): Publication status of an artifact being referred to. | ||||
![]() ![]() ![]() |
Σ | 0..1 | date | Date of publication of the artifact being referred to | ||||
![]() ![]() |
0..* | DataRequirement | What data is referenced by this library | |||||
![]() ![]() |
SΣ | 1..* | Attachment | Contents of the library, either embedded or referenced | ||||
![]() ![]() ![]() |
0..1 | id | Unique id for inter-element referencing | |||||
![]() ![]() ![]() |
0..* | Extension | Additional content defined by implementations Slice: Unordered, Open by value:url | |||||
![]() ![]() ![]() ![]() |
S | 0..1 | string | Plain-text SQL for readability URL: https://sql-on-fhir.org/ig/StructureDefinition/sql-text | ||||
![]() ![]() ![]() |
SΣC | 1..1 | code | application/sql or application/sql;dialect=... Binding: MimeTypes (required)
Example General: text/plain; charset=UTF-8, image/png | ||||
![]() ![]() ![]() |
Σ | 0..1 | code | Human language of the content (BCP-47) Binding: AllLanguages (required): IETF language tag for a human language.
Example General: en-AU | ||||
![]() ![]() ![]() |
SC | 1..1 | base64Binary | SQL view (base64-encoded) | ||||
![]() ![]() ![]() |
Σ | 0..1 | url | Uri where the data can be found Example General: http://www.acme.com/logo-small.png | ||||
![]() ![]() ![]() |
Σ | 0..1 | integer64 | Number of bytes of content (if url provided) | ||||
![]() ![]() ![]() |
Σ | 0..1 | base64Binary | Hash of the data (sha-1, base64ed) | ||||
![]() ![]() ![]() |
Σ | 0..1 | string | Label to display in place of the data Example General: Official Corporate Logo | ||||
![]() ![]() ![]() |
Σ | 0..1 | dateTime | Date attachment was first created | ||||
![]() ![]() ![]() |
0..1 | positiveInt | Height of the image in pixels (photo/video) | |||||
![]() ![]() ![]() |
0..1 | positiveInt | Width of the image in pixels (photo/video) | |||||
![]() ![]() ![]() |
0..1 | positiveInt | Number of frames if > 1 (photo) | |||||
![]() ![]() ![]() |
0..1 | decimal | Length in seconds (audio / video) | |||||
![]() ![]() ![]() |
0..1 | positiveInt | Number of printed pages | |||||
Documentation for this format | ||||||||
| Path | Status | Usage | ValueSet | Version | Source |
| Library.language | Base | required | All Languages | 📍5.0.0 | FHIR Std. |
| Library.versionAlgorithm[x] | Base | extensible | Version Algorithm | 📍5.0.0 | FHIR Std. |
| Library.status | Base | required | PublicationStatus | 📍5.0.0 | FHIR Std. |
| Library.type | Base | extensible | Library Type | 📍5.0.0 | FHIR Std. |
| Library.subject[x] | Base | extensible | Participant Resource Types | 📍5.0.0 | FHIR Std. |
| Library.jurisdiction | Base | extensible | Jurisdiction ValueSet | 📍5.0.0 | FHIR Std. |
| Library.topic | Base | example | Definition Topic | 📍5.0.0 | FHIR Std. |
| Library.relatedArtifact.type | Base | required | RelatedArtifactType | 📍5.0.0 | FHIR Std. |
| Library.relatedArtifact.classifier | Base | example | Citation Artifact Classifier | 📍5.0.0 | FHIR Std. |
| Library.relatedArtifact.publicationStatus | Base | required | PublicationStatus | 📍5.0.0 | FHIR Std. |
| Library.content.contentType | Base | required | Mime Types | 📦5.0.0 | FHIR Std. |
| Library.content.language | Base | required | All Languages | 📍5.0.0 | FHIR Std. |
| Id | Grade | Path(s) | Description | Expression |
| cnl-0 | warning | Library | Name 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-1 | warning | Library.url | URL should not contain | or # - these characters make processing canonical references problematic |
exists() implies matches('^[^|# ]+$')
|
| ele-1 | error | **ALL** elements | All FHIR elements must have a @value or children |
hasValue() or (children().count() > id.count())
|
| ext-1 | error | **ALL** extensions | Must have either extensions or value[x], not both |
extension.exists() != value.exists()
|
| sql-must-be-sql-expressions | error | Library | The content of the Library must be SQL expressions. |
content.all(contentType.startsWith('application/sql'))
|
| sql-name | error | Library.relatedArtifact.label | Name is limited to letters, numbers, or underscores and cannot start with an underscore -- i.e. with a regular expression of: ^[A-Za-z][A-Za-z0-9_]*$ This makes it usable as table names in a wide variety of databases. |
empty() or matches('^[A-Za-z][A-Za-z0-9_]*$')
|
This structure is derived from Library
Summary
Mandatory: 3 elements(2 nested mandatory elements)
Must-Support: 8 elements
Prohibited: 1 element
Structures
This structure refers to these other structures:
Extensions
This structure refers to these extensions:
Differential View
This structure is derived from Library
| Name | Flags | Card. | Type | Description & Constraints Filter: ![]() ![]() | ||||
|---|---|---|---|---|---|---|---|---|
![]() |
C | 0..* | Library | Represents a library of quality improvement components Interfaces Implemented: MetadataResource Constraints: sql-must-be-sql-expressions | ||||
![]() ![]() |
1..1 | CodeableConcept | logic-library | model-definition | asset-collection | module-definition Required Pattern: At least the following | |||||
![]() ![]() ![]() |
1..* | Coding | Code defined by a terminology system Fixed Value: (Complex) | |||||
![]() ![]() ![]() ![]() |
1..1 | uri | Identity of the terminology system Fixed Value: https://sql-on-fhir.org/ig/CodeSystem/LibraryTypesCodes | |||||
![]() ![]() ![]() ![]() |
1..1 | code | Symbol in syntax defined by the system Fixed Value: sql-view | |||||
![]() ![]() |
S | 0..* | RelatedArtifact | Additional documentation, citations, etc | ||||
![]() ![]() ![]() |
S | 1..1 | code | depends-on for ViewDefinition or SQLView references Required Pattern: depends-on | ||||
![]() ![]() ![]() |
SC | 1..1 | string | Table name used in SQL view Constraints: sql-name | ||||
![]() ![]() ![]() |
S | 1..1 | canonical(View Definition | SQL View Library) | Canonical URL of a ViewDefinition or SQLView | ||||
![]() ![]() |
0..0 | Not permitted (views cannot be parameterised) | ||||||
![]() ![]() |
S | 1..* | Attachment | Contents of the library, either embedded or referenced | ||||
![]() ![]() ![]() |
Content/Rules for all slices | |||||||
![]() ![]() ![]() ![]() |
S | 0..1 | string | Plain-text SQL for readability URL: https://sql-on-fhir.org/ig/StructureDefinition/sql-text | ||||
![]() ![]() ![]() |
S | 1..1 | code | application/sql or application/sql;dialect=... Binding: MimeTypes (required)
| ||||
![]() ![]() ![]() |
S | 1..1 | base64Binary | SQL view (base64-encoded) | ||||
Documentation for this format | ||||||||
| Path | Status | Usage | ValueSet | Version | Source |
| Library.content.contentType | Base | required | Mime Types | 📦5.0.0 | FHIR Std. |
| Id | Grade | Path(s) | Description | Expression |
| sql-must-be-sql-expressions | error | Library | The content of the Library must be SQL expressions. |
content.all(contentType.startsWith('application/sql'))
|
| sql-name | error | Library.relatedArtifact.label | Name is limited to letters, numbers, or underscores and cannot start with an underscore -- i.e. with a regular expression of: ^[A-Za-z][A-Za-z0-9_]*$ This makes it usable as table names in a wide variety of databases. |
empty() or matches('^[A-Za-z][A-Za-z0-9_]*$')
|
Key Elements View
| Name | Flags | Card. | Type | Description & Constraints Filter: ![]() ![]() | ||||
|---|---|---|---|---|---|---|---|---|
![]() |
C | 0..* | Library | Represents a library of quality improvement components Interfaces Implemented: MetadataResource Constraints: cnl-0, sql-must-be-sql-expressions | ||||
![]() ![]() |
?!Σ | 0..1 | uri | A set of rules under which this content was created | ||||
![]() ![]() |
0..* | Resource | Contained, inline Resources | |||||
![]() ![]() |
?!Σ | 0..* | Extension | Extensions that cannot be ignored | ||||
![]() ![]() |
?!Σ | 1..1 | code | draft | active | retired | unknown Binding: PublicationStatus (required): The lifecycle status of an artifact. | ||||
![]() ![]() |
Σ | 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 | ||||
![]() ![]() ![]() |
0..1 | string | Unique id for inter-element referencing | |||||
![]() ![]() ![]() |
0..* | Extension | Additional content defined by implementations | |||||
![]() ![]() ![]() |
1..* | Coding | Code defined by a terminology system Fixed Value: (Complex) | |||||
![]() ![]() ![]() ![]() |
0..1 | string | Unique id for inter-element referencing | |||||
![]() ![]() ![]() ![]() |
0..* | Extension | Additional content defined by implementations | |||||
![]() ![]() ![]() ![]() |
1..1 | uri | Identity of the terminology system Fixed Value: https://sql-on-fhir.org/ig/CodeSystem/LibraryTypesCodes | |||||
![]() ![]() ![]() ![]() |
0..1 | string | Version of the system - if relevant | |||||
![]() ![]() ![]() ![]() |
1..1 | code | Symbol in syntax defined by the system Fixed Value: sql-view | |||||
![]() ![]() ![]() ![]() |
0..1 | string | Representation defined by the system | |||||
![]() ![]() ![]() ![]() |
0..1 | boolean | If this coding was chosen directly by the user | |||||
![]() ![]() ![]() |
0..1 | string | Plain text representation of the concept | |||||
![]() ![]() |
S | 0..* | RelatedArtifact | Additional documentation, citations, etc | ||||
![]() ![]() ![]() |
SΣ | 1..1 | code | depends-on for ViewDefinition or SQLView references Binding: RelatedArtifactType (required): The type of relationship to the related artifact. Required Pattern: depends-on | ||||
![]() ![]() ![]() |
SΣC | 1..1 | string | Table name used in SQL view Constraints: sql-name | ||||
![]() ![]() ![]() |
SΣ | 1..1 | canonical(View Definition | SQL View Library) | Canonical URL of a ViewDefinition or SQLView | ||||
![]() ![]() |
SΣ | 1..* | Attachment | Contents of the library, either embedded or referenced | ||||
![]() ![]() ![]() |
Content/Rules for all slices | |||||||
![]() ![]() ![]() ![]() |
S | 0..1 | string | Plain-text SQL for readability URL: https://sql-on-fhir.org/ig/StructureDefinition/sql-text | ||||
![]() ![]() ![]() |
SΣC | 1..1 | code | application/sql or application/sql;dialect=... Binding: MimeTypes (required)
Example General: text/plain; charset=UTF-8, image/png | ||||
![]() ![]() ![]() |
SC | 1..1 | base64Binary | SQL view (base64-encoded) | ||||
Documentation for this format | ||||||||
| Path | Status | Usage | ValueSet | Version | Source |
| Library.status | Base | required | PublicationStatus | 📍5.0.0 | FHIR Std. |
| Library.type | Base | extensible | Library Type | 📍5.0.0 | FHIR Std. |
| Library.relatedArtifact.type | Base | required | RelatedArtifactType | 📍5.0.0 | FHIR Std. |
| Library.content.contentType | Base | required | Mime Types | 📦5.0.0 | FHIR Std. |
| Id | Grade | Path(s) | Description | Expression |
| cnl-0 | warning | Library | Name 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-1 | error | **ALL** elements | All FHIR elements must have a @value or children |
hasValue() or (children().count() > id.count())
|
| ext-1 | error | **ALL** extensions | Must have either extensions or value[x], not both |
extension.exists() != value.exists()
|
| sql-must-be-sql-expressions | error | Library | The content of the Library must be SQL expressions. |
content.all(contentType.startsWith('application/sql'))
|
| sql-name | error | Library.relatedArtifact.label | Name is limited to letters, numbers, or underscores and cannot start with an underscore -- i.e. with a regular expression of: ^[A-Za-z][A-Za-z0-9_]*$ This makes it usable as table names in a wide variety of databases. |
empty() or matches('^[A-Za-z][A-Za-z0-9_]*$')
|
Snapshot View
| Name | Flags | Card. | Type | Description & Constraints Filter: ![]() ![]() | ||||
|---|---|---|---|---|---|---|---|---|
![]() |
C | 0..* | Library | Represents a library of quality improvement components Interfaces Implemented: MetadataResource Constraints: cnl-0, sql-must-be-sql-expressions | ||||
![]() ![]() |
Σ | 0..1 | id | Logical id of this artifact | ||||
![]() ![]() |
Σ | 0..1 | Meta | Metadata about the resource | ||||
![]() ![]() |
?!Σ | 0..1 | uri | A set of rules under which this content was created | ||||
![]() ![]() |
0..1 | code | Language of the resource content Binding: AllLanguages (required): IETF language tag for a human language
| |||||
![]() ![]() |
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 | |||||
![]() ![]() |
0..* | Resource | Contained, inline Resources | |||||
![]() ![]() |
0..* | Extension | Additional content defined by implementations | |||||
![]() ![]() |
?!Σ | 0..* | Extension | Extensions that cannot be ignored | ||||
![]() ![]() |
ΣC | 0..1 | uri | Canonical identifier for this library, represented as a URI (globally unique) Constraints: cnl-1 | ||||
![]() ![]() |
Σ | 0..* | Identifier | Additional identifier for the library | ||||
![]() ![]() |
Σ | 0..1 | string | Business version of the library | ||||
![]() ![]() |
Σ | 0..1 | How to compare versions Binding: VersionAlgorithm (extensible) | |||||
![]() ![]() ![]() |
string | |||||||
![]() ![]() ![]() |
Coding | |||||||
![]() ![]() |
ΣC | 0..1 | string | Name for this library (computer friendly) | ||||
![]() ![]() |
Σ | 0..1 | string | Name for this library (human friendly) | ||||
![]() ![]() |
0..1 | string | Subordinate title of the library | |||||
![]() ![]() |
?!Σ | 1..1 | code | draft | active | retired | unknown Binding: PublicationStatus (required): The lifecycle status of an artifact. | ||||
![]() ![]() |
Σ | 0..1 | boolean | For testing purposes, not real usage | ||||
![]() ![]() |
Σ | 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 | ||||
![]() ![]() ![]() |
0..1 | string | Unique id for inter-element referencing | |||||
![]() ![]() ![]() |
0..* | Extension | Additional content defined by implementations | |||||
![]() ![]() ![]() |
1..* | Coding | Code defined by a terminology system Fixed Value: (Complex) | |||||
![]() ![]() ![]() ![]() |
0..1 | string | Unique id for inter-element referencing | |||||
![]() ![]() ![]() ![]() |
0..* | Extension | Additional content defined by implementations | |||||
![]() ![]() ![]() ![]() |
1..1 | uri | Identity of the terminology system Fixed Value: https://sql-on-fhir.org/ig/CodeSystem/LibraryTypesCodes | |||||
![]() ![]() ![]() ![]() |
0..1 | string | Version of the system - if relevant | |||||
![]() ![]() ![]() ![]() |
1..1 | code | Symbol in syntax defined by the system Fixed Value: sql-view | |||||
![]() ![]() ![]() ![]() |
0..1 | string | Representation defined by the system | |||||
![]() ![]() ![]() ![]() |
0..1 | boolean | If this coding was chosen directly by the user | |||||
![]() ![]() ![]() |
0..1 | string | Plain text representation of the concept | |||||
![]() ![]() |
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.). | ||||||
![]() ![]() ![]() |
CodeableConcept | |||||||
![]() ![]() ![]() |
Reference(Group) | |||||||
![]() ![]() |
Σ | 0..1 | dateTime | Date last changed | ||||
![]() ![]() |
Σ | 0..1 | string | Name of the publisher/steward (organization or individual) | ||||
![]() ![]() |
Σ | 0..* | ContactDetail | Contact details for the publisher | ||||
![]() ![]() |
Σ | 0..1 | markdown | Natural language description of the library | ||||
![]() ![]() |
Σ | 0..* | UsageContext | The context that the content is intended to support | ||||
![]() ![]() |
Σ | 0..* | CodeableConcept | Intended jurisdiction for library (if applicable) Binding: JurisdictionValueSet (extensible): Countries and regions within which this artifact is targeted for use. | ||||
![]() ![]() |
0..1 | markdown | Why this library is defined | |||||
![]() ![]() |
0..1 | markdown | Describes the clinical usage of the library | |||||
![]() ![]() |
0..1 | markdown | Use and/or publishing restrictions | |||||
![]() ![]() |
0..1 | string | Copyright holder and year(s) | |||||
![]() ![]() |
0..1 | date | When the library was approved by publisher | |||||
![]() ![]() |
0..1 | date | When the library was last reviewed by the publisher | |||||
![]() ![]() |
Σ | 0..1 | Period | When the library is expected to be used | ||||
![]() ![]() |
0..* | CodeableConcept | E.g. Education, Treatment, Assessment, etc Binding: DefinitionTopic (example): High-level categorization of the definition, used for searching, sorting, and filtering. | |||||
![]() ![]() |
0..* | ContactDetail | Who authored the content | |||||
![]() ![]() |
0..* | ContactDetail | Who edited the content | |||||
![]() ![]() |
0..* | ContactDetail | Who reviewed the content | |||||
![]() ![]() |
0..* | ContactDetail | Who endorsed the content | |||||
![]() ![]() |
S | 0..* | RelatedArtifact | Additional documentation, citations, etc | ||||
![]() ![]() ![]() |
0..1 | id | Unique id for inter-element referencing | |||||
![]() ![]() ![]() |
0..* | Extension | Additional content defined by implementations Slice: Unordered, Open by value:url | |||||
![]() ![]() ![]() |
SΣ | 1..1 | code | depends-on for ViewDefinition or SQLView references Binding: RelatedArtifactType (required): The type of relationship to the related artifact. Required Pattern: depends-on | ||||
![]() ![]() ![]() |
Σ | 0..* | CodeableConcept | Additional classifiers Binding: CitationArtifactClassifier (example): Additional classifiers for the related artifact. | ||||
![]() ![]() ![]() |
SΣC | 1..1 | string | Table name used in SQL view Constraints: sql-name | ||||
![]() ![]() ![]() |
Σ | 0..1 | string | Brief description of the related artifact | ||||
![]() ![]() ![]() |
Σ | 0..1 | markdown | Bibliographic citation for the artifact | ||||
![]() ![]() ![]() |
Σ | 0..1 | Attachment | What document is being referenced | ||||
![]() ![]() ![]() |
SΣ | 1..1 | canonical(View Definition | SQL View Library) | Canonical URL of a ViewDefinition or SQLView | ||||
![]() ![]() ![]() |
Σ | 0..1 | Reference(Resource) | What artifact, if not a conformance resource | ||||
![]() ![]() ![]() |
Σ | 0..1 | code | draft | active | retired | unknown Binding: PublicationStatus (required): Publication status of an artifact being referred to. | ||||
![]() ![]() ![]() |
Σ | 0..1 | date | Date of publication of the artifact being referred to | ||||
![]() ![]() |
0..* | DataRequirement | What data is referenced by this library | |||||
![]() ![]() |
SΣ | 1..* | Attachment | Contents of the library, either embedded or referenced | ||||
![]() ![]() ![]() |
0..1 | id | Unique id for inter-element referencing | |||||
![]() ![]() ![]() |
0..* | Extension | Additional content defined by implementations Slice: Unordered, Open by value:url | |||||
![]() ![]() ![]() ![]() |
S | 0..1 | string | Plain-text SQL for readability URL: https://sql-on-fhir.org/ig/StructureDefinition/sql-text | ||||
![]() ![]() ![]() |
SΣC | 1..1 | code | application/sql or application/sql;dialect=... Binding: MimeTypes (required)
Example General: text/plain; charset=UTF-8, image/png | ||||
![]() ![]() ![]() |
Σ | 0..1 | code | Human language of the content (BCP-47) Binding: AllLanguages (required): IETF language tag for a human language.
Example General: en-AU | ||||
![]() ![]() ![]() |
SC | 1..1 | base64Binary | SQL view (base64-encoded) | ||||
![]() ![]() ![]() |
Σ | 0..1 | url | Uri where the data can be found Example General: http://www.acme.com/logo-small.png | ||||
![]() ![]() ![]() |
Σ | 0..1 | integer64 | Number of bytes of content (if url provided) | ||||
![]() ![]() ![]() |
Σ | 0..1 | base64Binary | Hash of the data (sha-1, base64ed) | ||||
![]() ![]() ![]() |
Σ | 0..1 | string | Label to display in place of the data Example General: Official Corporate Logo | ||||
![]() ![]() ![]() |
Σ | 0..1 | dateTime | Date attachment was first created | ||||
![]() ![]() ![]() |
0..1 | positiveInt | Height of the image in pixels (photo/video) | |||||
![]() ![]() ![]() |
0..1 | positiveInt | Width of the image in pixels (photo/video) | |||||
![]() ![]() ![]() |
0..1 | positiveInt | Number of frames if > 1 (photo) | |||||
![]() ![]() ![]() |
0..1 | decimal | Length in seconds (audio / video) | |||||
![]() ![]() ![]() |
0..1 | positiveInt | Number of printed pages | |||||
Documentation for this format | ||||||||
| Path | Status | Usage | ValueSet | Version | Source |
| Library.language | Base | required | All Languages | 📍5.0.0 | FHIR Std. |
| Library.versionAlgorithm[x] | Base | extensible | Version Algorithm | 📍5.0.0 | FHIR Std. |
| Library.status | Base | required | PublicationStatus | 📍5.0.0 | FHIR Std. |
| Library.type | Base | extensible | Library Type | 📍5.0.0 | FHIR Std. |
| Library.subject[x] | Base | extensible | Participant Resource Types | 📍5.0.0 | FHIR Std. |
| Library.jurisdiction | Base | extensible | Jurisdiction ValueSet | 📍5.0.0 | FHIR Std. |
| Library.topic | Base | example | Definition Topic | 📍5.0.0 | FHIR Std. |
| Library.relatedArtifact.type | Base | required | RelatedArtifactType | 📍5.0.0 | FHIR Std. |
| Library.relatedArtifact.classifier | Base | example | Citation Artifact Classifier | 📍5.0.0 | FHIR Std. |
| Library.relatedArtifact.publicationStatus | Base | required | PublicationStatus | 📍5.0.0 | FHIR Std. |
| Library.content.contentType | Base | required | Mime Types | 📦5.0.0 | FHIR Std. |
| Library.content.language | Base | required | All Languages | 📍5.0.0 | FHIR Std. |
| Id | Grade | Path(s) | Description | Expression |
| cnl-0 | warning | Library | Name 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-1 | warning | Library.url | URL should not contain | or # - these characters make processing canonical references problematic |
exists() implies matches('^[^|# ]+$')
|
| ele-1 | error | **ALL** elements | All FHIR elements must have a @value or children |
hasValue() or (children().count() > id.count())
|
| ext-1 | error | **ALL** extensions | Must have either extensions or value[x], not both |
extension.exists() != value.exists()
|
| sql-must-be-sql-expressions | error | Library | The content of the Library must be SQL expressions. |
content.all(contentType.startsWith('application/sql'))
|
| sql-name | error | Library.relatedArtifact.label | Name is limited to letters, numbers, or underscores and cannot start with an underscore -- i.e. with a regular expression of: ^[A-Za-z][A-Za-z0-9_]*$ This makes it usable as table names in a wide variety of databases. |
empty() or matches('^[A-Za-z][A-Za-z0-9_]*$')
|
This structure is derived from Library
Summary
Mandatory: 3 elements(2 nested mandatory elements)
Must-Support: 8 elements
Prohibited: 1 element
Structures
This structure refers to these other structures:
Extensions
This structure refers to these extensions:
Other representations of profile: CSV, Excel, Schematron
SQLView exists so that queries can build on one another, much like SQL views. A ViewDefinition produces a tabular projection of FHIR resources; an SQLView wraps a query over those projections (or over other SQLViews) and gives it a canonical URL; an SQLQuery then references ViewDefinitions and SQLViews alike as its table sources.
References made through relatedArtifact form a directed graph of
ViewDefinitions, SQLViews, and SQLQueries, in which each referenced result acts
as a virtual table for the referencing query. Authors SHOULD keep this graph
acyclic.
Whether circular dependencies are detected or rejected, any limit on dependency depth, and whether intermediate results are materialised or inlined (for example as CTEs or database views) are implementation decisions and are not mandated by this specification. A SQL engine that creates real views will reject a cyclic definition; a CTE-based implementation detects loops itself.
The Active Patients view selects active
patients from a ViewDefinition. The
Active Patient Addresses query then
references that SQLView by its canonical URL, using the active_patients label
as a table name and joining it to a further ViewDefinition. The executing engine
may materialise the view’s result or inline it; either approach conforms to this
specification.