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/HL7/sql-on-fhir/ and changes regularly. See the Directory of published versions

Resource Profile: SQL View Library

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.

Scope and Usage

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:

  • The Library type is fixed to LibraryTypesCodes#sql-view.
  • An SQLView SHALL NOT declare parameters. Dependent views cannot be parameterised in this iteration of the specification.

Boundaries and Relationships

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.

Resource Content

Dependencies

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.

No Parameters

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.

SQL Attachments

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.

Conformance

Constraints:

  • Library type SHALL be LibraryTypesCodes#sql-view
  • Library.parameter SHALL be absent
  • Every content.contentType SHALL start with application/sql
  • content.data SHALL be present; the sql-text extension MAY carry a plain-text copy
  • Dependencies SHALL use relatedArtifact with type = "depends-on", a label, and a resource referencing a ViewDefinition or SQLView

For notes on query composition, see the Notes tab below.

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
Interfaces Implemented: MetadataResource
Constraints: sql-must-be-sql-expressions
... 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-view
... relatedArtifact S 0..* RelatedArtifact Additional documentation, citations, etc
.... type S 1..1 code depends-on for ViewDefinition or SQLView references
Required Pattern: depends-on
.... label SC 1..1 string Table name used in SQL view
Constraints: sql-name
.... resource S 1..1 canonical(View Definition | SQL View Library) Canonical URL of a ViewDefinition or SQLView
... parameter 0..0 Not permitted (views cannot be parameterised)
.... Slices for extension Content/Rules for all slices
..... extension:sqlText S 0..1 string Plain-text SQL for readability
URL: https://sql-on-fhir.org/ig/StructureDefinition/sql-text
.... contentType S 1..1 code application/sql or application/sql;dialect=...
Binding: MimeTypes (required)
Additional BindingsPurpose
All SQL Content Type Codes Extensible
.... data S 1..1 base64Binary SQL view (base64-encoded)

doco Documentation for this format

Terminology Bindings (Differential)

Path Status Usage ValueSet Version Source
Library.content.contentType Base required Mime Types 📦5.0.0 FHIR Std.

Constraints

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_]*$')
NameFlagsCard.TypeDescription & Constraints    Filter: Filtersdoco
.. Library C 0..* Library Represents a library of quality improvement components
Interfaces Implemented: MetadataResource
Constraints: cnl-0, sql-must-be-sql-expressions
... 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-view
..... 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
... relatedArtifact S 0..* RelatedArtifact Additional documentation, citations, etc
.... type 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
.... label SΣC 1..1 string Table name used in SQL view
Constraints: sql-name
.... resource SΣ 1..1 canonical(View Definition | SQL View Library) Canonical URL of a ViewDefinition or SQLView
... content SΣ 1..* Attachment Contents of the library, either embedded or referenced
.... Slices for extension Content/Rules for all slices
..... extension:sqlText S 0..1 string Plain-text SQL for readability
URL: https://sql-on-fhir.org/ig/StructureDefinition/sql-text
.... contentType SΣC 1..1 code application/sql or application/sql;dialect=...
Binding: MimeTypes (required)
Additional BindingsPurpose
All SQL Content Type Codes Extensible

Example General: text/plain; charset=UTF-8, image/png
.... data SC 1..1 base64Binary SQL view (base64-encoded)

doco Documentation for this format

Terminology Bindings

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.

Constraints

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_]*$')
NameFlagsCard.TypeDescription & Constraints    Filter: Filtersdoco
.. Library C 0..* Library Represents a library of quality improvement components
Interfaces Implemented: MetadataResource
Constraints: cnl-0, sql-must-be-sql-expressions
... 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-view
..... 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 S 0..* RelatedArtifact Additional documentation, citations, etc
.... id 0..1 id Unique id for inter-element referencing
.... extension 0..* Extension Additional content defined by implementations
Slice: Unordered, Open by value:url
.... type 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
.... classifier Σ 0..* CodeableConcept Additional classifiers
Binding: CitationArtifactClassifier (example): Additional classifiers for the related artifact.
.... label SΣC 1..1 string Table name used in SQL view
Constraints: sql-name
.... display Σ 0..1 string Brief description of the related artifact
.... citation Σ 0..1 markdown Bibliographic citation for the artifact
.... document Σ 0..1 Attachment What document is being referenced
.... resource SΣ 1..1 canonical(View Definition | SQL View Library) Canonical URL of a ViewDefinition or SQLView
.... resourceReference Σ 0..1 Reference(Resource) What artifact, if not a conformance resource
.... publicationStatus Σ 0..1 code draft | active | retired | unknown
Binding: PublicationStatus (required): Publication status of an artifact being referred to.
.... publicationDate Σ 0..1 date Date of publication of the artifact being referred to
... dataRequirement 0..* DataRequirement What data is referenced by this library
... content SΣ 1..* Attachment Contents of the library, either embedded or referenced
.... id 0..1 id Unique id for inter-element referencing
.... Slices for extension 0..* Extension Additional content defined by implementations
Slice: Unordered, Open by value:url
..... extension:sqlText S 0..1 string Plain-text SQL for readability
URL: https://sql-on-fhir.org/ig/StructureDefinition/sql-text
.... contentType SΣC 1..1 code application/sql or application/sql;dialect=...
Binding: MimeTypes (required)
Additional BindingsPurpose
All SQL Content Type Codes Extensible

Example General: text/plain; charset=UTF-8, image/png
.... language Σ 0..1 code Human language of the content (BCP-47)
Binding: AllLanguages (required): IETF language tag for a human language.
Additional BindingsPurpose
CommonLanguages Starter

Example General: en-AU
.... data SC 1..1 base64Binary SQL view (base64-encoded)
.... url Σ 0..1 url Uri where the data can be found
Example General: http://www.acme.com/logo-small.png
.... size Σ 0..1 integer64 Number of bytes of content (if url provided)
.... hash Σ 0..1 base64Binary Hash of the data (sha-1, base64ed)
.... title Σ 0..1 string Label to display in place of the data
Example General: Official Corporate Logo
.... creation Σ 0..1 dateTime Date attachment was first created
.... height 0..1 positiveInt Height of the image in pixels (photo/video)
.... width 0..1 positiveInt Width of the image in pixels (photo/video)
.... frames 0..1 positiveInt Number of frames if > 1 (photo)
.... duration 0..1 decimal Length in seconds (audio / video)
.... pages 0..1 positiveInt Number of printed pages

doco Documentation for this format

Terminology Bindings

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.

Constraints

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

NameFlagsCard.TypeDescription & Constraints    Filter: Filtersdoco
.. Library C 0..* Library Represents a library of quality improvement components
Interfaces Implemented: MetadataResource
Constraints: sql-must-be-sql-expressions
... 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-view
... relatedArtifact S 0..* RelatedArtifact Additional documentation, citations, etc
.... type S 1..1 code depends-on for ViewDefinition or SQLView references
Required Pattern: depends-on
.... label SC 1..1 string Table name used in SQL view
Constraints: sql-name
.... resource S 1..1 canonical(View Definition | SQL View Library) Canonical URL of a ViewDefinition or SQLView
... parameter 0..0 Not permitted (views cannot be parameterised)
.... Slices for extension Content/Rules for all slices
..... extension:sqlText S 0..1 string Plain-text SQL for readability
URL: https://sql-on-fhir.org/ig/StructureDefinition/sql-text
.... contentType S 1..1 code application/sql or application/sql;dialect=...
Binding: MimeTypes (required)
Additional BindingsPurpose
All SQL Content Type Codes Extensible
.... data S 1..1 base64Binary SQL view (base64-encoded)

doco Documentation for this format

Terminology Bindings (Differential)

Path Status Usage ValueSet Version Source
Library.content.contentType Base required Mime Types 📦5.0.0 FHIR Std.

Constraints

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

NameFlagsCard.TypeDescription & Constraints    Filter: Filtersdoco
.. Library C 0..* Library Represents a library of quality improvement components
Interfaces Implemented: MetadataResource
Constraints: cnl-0, sql-must-be-sql-expressions
... 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-view
..... 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
... relatedArtifact S 0..* RelatedArtifact Additional documentation, citations, etc
.... type 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
.... label SΣC 1..1 string Table name used in SQL view
Constraints: sql-name
.... resource SΣ 1..1 canonical(View Definition | SQL View Library) Canonical URL of a ViewDefinition or SQLView
... content SΣ 1..* Attachment Contents of the library, either embedded or referenced
.... Slices for extension Content/Rules for all slices
..... extension:sqlText S 0..1 string Plain-text SQL for readability
URL: https://sql-on-fhir.org/ig/StructureDefinition/sql-text
.... contentType SΣC 1..1 code application/sql or application/sql;dialect=...
Binding: MimeTypes (required)
Additional BindingsPurpose
All SQL Content Type Codes Extensible

Example General: text/plain; charset=UTF-8, image/png
.... data SC 1..1 base64Binary SQL view (base64-encoded)

doco Documentation for this format

Terminology Bindings

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.

Constraints

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

NameFlagsCard.TypeDescription & Constraints    Filter: Filtersdoco
.. Library C 0..* Library Represents a library of quality improvement components
Interfaces Implemented: MetadataResource
Constraints: cnl-0, sql-must-be-sql-expressions
... 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-view
..... 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 S 0..* RelatedArtifact Additional documentation, citations, etc
.... id 0..1 id Unique id for inter-element referencing
.... extension 0..* Extension Additional content defined by implementations
Slice: Unordered, Open by value:url
.... type 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
.... classifier Σ 0..* CodeableConcept Additional classifiers
Binding: CitationArtifactClassifier (example): Additional classifiers for the related artifact.
.... label SΣC 1..1 string Table name used in SQL view
Constraints: sql-name
.... display Σ 0..1 string Brief description of the related artifact
.... citation Σ 0..1 markdown Bibliographic citation for the artifact
.... document Σ 0..1 Attachment What document is being referenced
.... resource SΣ 1..1 canonical(View Definition | SQL View Library) Canonical URL of a ViewDefinition or SQLView
.... resourceReference Σ 0..1 Reference(Resource) What artifact, if not a conformance resource
.... publicationStatus Σ 0..1 code draft | active | retired | unknown
Binding: PublicationStatus (required): Publication status of an artifact being referred to.
.... publicationDate Σ 0..1 date Date of publication of the artifact being referred to
... dataRequirement 0..* DataRequirement What data is referenced by this library
... content SΣ 1..* Attachment Contents of the library, either embedded or referenced
.... id 0..1 id Unique id for inter-element referencing
.... Slices for extension 0..* Extension Additional content defined by implementations
Slice: Unordered, Open by value:url
..... extension:sqlText S 0..1 string Plain-text SQL for readability
URL: https://sql-on-fhir.org/ig/StructureDefinition/sql-text
.... contentType SΣC 1..1 code application/sql or application/sql;dialect=...
Binding: MimeTypes (required)
Additional BindingsPurpose
All SQL Content Type Codes Extensible

Example General: text/plain; charset=UTF-8, image/png
.... language Σ 0..1 code Human language of the content (BCP-47)
Binding: AllLanguages (required): IETF language tag for a human language.
Additional BindingsPurpose
CommonLanguages Starter

Example General: en-AU
.... data SC 1..1 base64Binary SQL view (base64-encoded)
.... url Σ 0..1 url Uri where the data can be found
Example General: http://www.acme.com/logo-small.png
.... size Σ 0..1 integer64 Number of bytes of content (if url provided)
.... hash Σ 0..1 base64Binary Hash of the data (sha-1, base64ed)
.... title Σ 0..1 string Label to display in place of the data
Example General: Official Corporate Logo
.... creation Σ 0..1 dateTime Date attachment was first created
.... height 0..1 positiveInt Height of the image in pixels (photo/video)
.... width 0..1 positiveInt Width of the image in pixels (photo/video)
.... frames 0..1 positiveInt Number of frames if > 1 (photo)
.... duration 0..1 decimal Length in seconds (audio / video)
.... pages 0..1 positiveInt Number of printed pages

doco Documentation for this format

Terminology Bindings

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.

Constraints

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

Notes:

Query Composition

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.

Example

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.