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

SQL on FHIR, published by HL7 International / FHIR Infrastructure. This guide is not an authorized publication; it is the continuous build for version 3.0.0-ballot built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/HL7/sql-on-fhir/ and changes regularly. See the Directory of published versions

Resource Profile: SQL View Library

Official URL: http://hl7.org/fhir/uv/sql-on-fhir/StructureDefinition/SQLView Version: 3.0.0-ballot
Standards status: Trial-use Maturity Level: 2 Computable Name: SQLView
Other Identifiers: OID:2.16.840.1.113883.4.642.40.77.42.2

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 behavior, or APIs; those belong to ViewDefinition and its operations. An SQLView references ViewDefinitions, other SQLViews, ValueSets and ConceptMaps; execution environments resolve these to physical or virtual tables. A ValueSet is exposed to the SQL as a relation of its member codes, and a ConceptMap as a relation of its mappings (see Terminology in SQL).

Resource Content

Dependencies

Use relatedArtifact with type = "depends-on" to list the ViewDefinitions, SQLViews, ValueSets and ConceptMaps this view builds upon. Each resource is the canonical URL of a ViewDefinition, another SQLView, a ValueSet or a ConceptMap, 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": "http://hl7.org/fhir/uv/sql-on-fhir/Library/ActivePatientsView", "label": "active_patients" },
  { "type": "depends-on", "resource": "http://example.org/ValueSet/cardiovascular-disease|2026", "label": "cvd_codes" },
  { "type": "depends-on", "resource": "http://example.org/ConceptMap/sct-to-icd10|2026", "label": "sct_to_icd10" }
]

The allowed targets are recorded as a targetProfile on relatedArtifact.resource (Canonical(ViewDefinition or SQLView or ValueSet or ConceptMap)). Validators enforce this whenever the canonical resolves to a known resource; for canonicals that cannot be resolved the constraint is advisory. A ValueSet dependency is read as a relation with the columns system, version, code, display and inactive, and a ConceptMap dependency as a relation with the columns source_system, source_version, source_code, source_display, target_system, target_version, target_code, target_display and relationship, as specified in Terminology in SQL.

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 parameterized 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, SQLView, ValueSet or ConceptMap

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 Differentials, Snapshots, and other representations.

NameFlagsCard.TypeDescription & Constraints    Filter: doco
Library C 0..* Library Represents a library of quality improvement components
Interfaces Implemented: MetadataResource
Constraints: cnl-0, sql-must-be-sql-expressions
Library.implicitRules This element is a modifier element. This element is included in summaries. 0..1 uri A set of rules under which this content was created
Library.contained 0..* Resource Contained, inline Resources
Library.modifierExtension This element is a modifier element. This element is included in summaries. 0..* Extension Extensions that cannot be ignored
Slice: Unordered, Open by value:url
Library.status This element is a modifier element. This element is included in summaries. 1..1 code draft | active | retired | unknown
Binding: PublicationStatus (required): The lifecycle status of an artifact.
Library.type This element is included in summaries. 1..1 CodeableConcept logic-library | model-definition | asset-collection | module-definition | etc.
Binding: LibraryType (extensible): The type of knowledge artifact this library contains.
Required Pattern: At least the following
Library.type.id 0..1 string Unique id for inter-element referencing
Library.type.extension 0..* Extension Additional content defined by implementations
Library.type.coding 1..* Coding Code defined by a terminology system
Fixed Value: (Complex)
Library.type.coding.id 0..1 string Unique id for inter-element referencing
Library.type.coding.extension 0..* Extension Additional content defined by implementations
Library.type.coding.system 1..1 uri Identity of the terminology system
Fixed Value: http://hl7.org/fhir/uv/sql-on-fhir/CodeSystem/LibraryTypesCodes
Library.type.coding.version 0..1 string Version of the system - if relevant
Library.type.coding.code 1..1 code Symbol in syntax defined by the system
Fixed Value: sql-view
Library.type.coding.display 0..1 string Representation defined by the system
Library.type.coding.userSelected 0..1 boolean If this coding was chosen directly by the user
Library.type.text 0..1 string Plain text representation of the concept
Library.relatedArtifact This element must be supported. C 0..* RelatedArtifact Additional documentation, citations, etc
Constraints: lib-2
Library.relatedArtifact.type This element must be supported. This element is included in summaries. 1..1 code depends-on for ViewDefinition, SQLView, ValueSet or ConceptMap references
Binding: RelatedArtifactType (required): The type of relationship to the related artifact.
Required Pattern: depends-on
Library.relatedArtifact.label This element must be supported. This element is included in summaries. C 1..1 string Table name used in SQL view
Constraints: sql-name
Library.relatedArtifact.resource This element must be supported. This element is included in summaries. 1..1 canonical(View Definition | SQL View Library | ValueSet | ConceptMap) Canonical URL of a ViewDefinition, SQLView, ValueSet or ConceptMap
Library.content This element must be supported. This element is included in summaries. 1..* Attachment Contents of the library, either embedded or referenced
Library.content.Slices for extension Content/Rules for all slices
Library.content.Slices for extension.extension:sqlText This element must be supported. 0..1 string Plain-text SQL for readability
URL: http://hl7.org/fhir/uv/sql-on-fhir/StructureDefinition/sql-text
Library.content.contentType This element must be supported. This element is included in summaries. 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
Library.content.data This element must be supported. C 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 📍6.0.0-snapshot1 FHIR Std.
Library.type Base extensible LibraryType 📦1.0.1 THO v7.4
Library.relatedArtifact.​type Base required RelatedArtifactType 📍6.0.0-snapshot1 FHIR Std.
Library.content.contentType Base required Mime Types 📦6.0.0-snapshot1 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())
lib-2 warning Library.relatedArtifact Dependencies and components of a Library should reference a resource type in ('depends-on' | 'composed-of' | 'part-of') implies ((resource.exists() xor resourceReference.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

NameFlagsCard.TypeDescription & Constraints    Filter: doco
Library C 0..* Library Represents a library of quality improvement components
Interfaces Implemented: MetadataResource
Constraints: sql-must-be-sql-expressions
Library.type 1..1 CodeableConcept logic-library | model-definition | asset-collection | module-definition | etc.
Required Pattern: At least the following
Library.type.coding 1..* Coding Code defined by a terminology system
Fixed Value: (Complex)
Library.type.coding.system 1..1 uri Identity of the terminology system
Fixed Value: http://hl7.org/fhir/uv/sql-on-fhir/CodeSystem/LibraryTypesCodes
Library.type.coding.code 1..1 code Symbol in syntax defined by the system
Fixed Value: sql-view
Library.relatedArtifact This element must be supported. 0..* RelatedArtifact Additional documentation, citations, etc
Library.relatedArtifact.type This element must be supported. 1..1 code depends-on for ViewDefinition, SQLView, ValueSet or ConceptMap references
Required Pattern: depends-on
Library.relatedArtifact.label This element must be supported. C 1..1 string Table name used in SQL view
Constraints: sql-name
Library.relatedArtifact.resource This element must be supported. 1..1 canonical(View Definition | SQL View Library | ValueSet | ConceptMap) Canonical URL of a ViewDefinition, SQLView, ValueSet or ConceptMap
Library.parameter 0..0 Not permitted (views cannot be parameterized)
Library.content.Slices for extension Content/Rules for all slices
Library.content.Slices for extension.extension:sqlText This element must be supported. 0..1 string Plain-text SQL for readability
URL: http://hl7.org/fhir/uv/sql-on-fhir/StructureDefinition/sql-text
Library.content.contentType This element must be supported. 1..1 code application/sql or application/sql;dialect=...
Binding: MimeTypes (required)
Additional BindingsPurpose
All SQL Content Type Codes Extensible
Library.content.data This element must be supported. 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 📦6.0.0-snapshot1 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: doco
Library C 0..* Library Represents a library of quality improvement components
Interfaces Implemented: MetadataResource
Constraints: cnl-0, sql-must-be-sql-expressions
Library.id This element is included in summaries. 0..1 id Logical id of this artifact
Library.meta This element is included in summaries. 0..1 Meta Metadata about the resource
Library.implicitRules This element is a modifier element. This element is included in summaries. 0..1 uri A set of rules under which this content was created
Library.language 0..1 code Language of the resource content
Binding: AllLanguages (required): IETF language tag for a human language
Additional BindingsPurpose
CommonLanguages Starter
Library.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
Library.contained 0..* Resource Contained, inline Resources
Library.extension 0..* Extension Additional content defined by implementations
Slice: Unordered, Open by value:url
Library.modifierExtension This element is a modifier element. This element is included in summaries. 0..* Extension Extensions that cannot be ignored
Slice: Unordered, Open by value:url
Library.url This element is included in summaries. C 0..1 uri Canonical identifier for this library, represented as a URI (globally unique)
Constraints: cnl-1
Library.identifier This element is included in summaries. 0..* Identifier Additional identifier for the library
Library.version This element is included in summaries. 0..1 string Business version of the library
Library.versionAlgorithm[x] This element is included in summaries. 0..1 How to compare versions
Binding: VersionAlgorithm (extensible)
Library.versionAlgorithm[x].versionAlgorithmString string
Library.versionAlgorithm[x].versionAlgorithmCoding Coding
Library.name This element is included in summaries. C 0..1 string Name for this library (computer friendly)
Library.title This element is included in summaries. 0..1 string Name for this library (human friendly)
Library.subtitle 0..1 string Subordinate title of the library
Library.status This element is a modifier element. This element is included in summaries. 1..1 code draft | active | retired | unknown
Binding: PublicationStatus (required): The lifecycle status of an artifact.
Library.experimental This element is included in summaries. 0..1 boolean For testing only - never for real usage
Library.type This element is included in summaries. 1..1 CodeableConcept logic-library | model-definition | asset-collection | module-definition | etc.
Binding: LibraryType (extensible): The type of knowledge artifact this library contains.
Required Pattern: At least the following
Library.type.id 0..1 string Unique id for inter-element referencing
Library.type.extension 0..* Extension Additional content defined by implementations
Library.type.coding 1..* Coding Code defined by a terminology system
Fixed Value: (Complex)
Library.type.coding.id 0..1 string Unique id for inter-element referencing
Library.type.coding.extension 0..* Extension Additional content defined by implementations
Library.type.coding.system 1..1 uri Identity of the terminology system
Fixed Value: http://hl7.org/fhir/uv/sql-on-fhir/CodeSystem/LibraryTypesCodes
Library.type.coding.version 0..1 string Version of the system - if relevant
Library.type.coding.code 1..1 code Symbol in syntax defined by the system
Fixed Value: sql-view
Library.type.coding.display 0..1 string Representation defined by the system
Library.type.coding.userSelected 0..1 boolean If this coding was chosen directly by the user
Library.type.text 0..1 string Plain text representation of the concept
Library.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.).
Library.subject[x].subjectCodeableConcept CodeableConcept
Library.subject[x].subjectReference Reference(Group)
Library.date This element is included in summaries. 0..1 dateTime Date last changed
Library.publisher This element is included in summaries. 0..1 string Name of the publisher/steward (organization or individual)
Library.contact This element is included in summaries. 0..* ContactDetail Contact details for the publisher
Library.description This element is included in summaries. 0..1 markdown Natural language description of the library
Library.useContext This element is included in summaries. 0..* UsageContext The context that the content is intended to support
Library.jurisdiction This element is included in summaries. 0..* CodeableConcept Jurisdiction of the authority that maintains the library (if applicable)
Binding: Jurisdiction ValueSet (extensible): Countries and regions within which this artifact is targeted for use.
Library.purpose 0..1 markdown Why this library is defined
Library.usage 0..1 markdown Describes the clinical usage of the library
Library.copyright 0..1 markdown Notice about intellectual property ownership, can include restrictions on use
Library.copyrightLabel 0..1 string Copyright holder and year(s)
Library.approvalDate 0..1 date When the library was approved by publisher
Library.lastReviewDate 0..1 date When the library was last reviewed by the publisher
Library.effectivePeriod This element is included in summaries. 0..1 Period When the library is expected to be used
Library.topic 0..* CodeableConcept E.g. Education, Treatment, Assessment, etc
Binding: DefinitionTopic (example): High-level categorization of the definition, used for searching, sorting, and filtering.
Library.author 0..* ContactDetail Who authored the content
Library.editor 0..* ContactDetail Who edited the content
Library.reviewer 0..* ContactDetail Who reviewed the content
Library.endorser 0..* ContactDetail Who endorsed the content
Library.relatedArtifact This element must be supported. C 0..* RelatedArtifact Additional documentation, citations, etc
Constraints: lib-2
Library.relatedArtifact.id 0..1 string Unique id for inter-element referencing
Library.relatedArtifact.extension 0..* Extension Additional content defined by implementations
Slice: Unordered, Open by value:url
Library.relatedArtifact.type This element must be supported. This element is included in summaries. 1..1 code depends-on for ViewDefinition, SQLView, ValueSet or ConceptMap references
Binding: RelatedArtifactType (required): The type of relationship to the related artifact.
Required Pattern: depends-on
Library.relatedArtifact.label This element must be supported. This element is included in summaries. C 1..1 string Table name used in SQL view
Constraints: sql-name
Library.relatedArtifact.display This element is included in summaries. 0..1 string Brief description of the related artifact
Library.relatedArtifact.citation This element is included in summaries. 0..1 markdown Bibliographic citation for the artifact
Library.relatedArtifact.url This element is included in summaries. 0..1 url A url for the artifact that can be followed to access the actual content
Library.relatedArtifact.document This element is included in summaries. 0..1 Attachment What document is being referenced
Library.relatedArtifact.resource This element must be supported. This element is included in summaries. 1..1 canonical(View Definition | SQL View Library | ValueSet | ConceptMap) Canonical URL of a ViewDefinition, SQLView, ValueSet or ConceptMap
Library.relatedArtifact.resourceReference This element is included in summaries. 0..1 Reference(Resource) What artifact, if not a conformance resource
Library.dataRequirement 0..* DataRequirement What data is referenced by this library
Library.content This element must be supported. This element is included in summaries. 1..* Attachment Contents of the library, either embedded or referenced
Library.content.id 0..1 string Unique id for inter-element referencing
Library.content.Slices for extension 0..* Extension Additional content defined by implementations
Slice: Unordered, Open by value:url
Library.content.Slices for extension.extension:sqlText This element must be supported. 0..1 string Plain-text SQL for readability
URL: http://hl7.org/fhir/uv/sql-on-fhir/StructureDefinition/sql-text
Library.content.contentType This element must be supported. This element is included in summaries. 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
Library.content.language This element is included in summaries. 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
Library.content.data This element must be supported. C 1..1 base64Binary SQL view (base64-encoded)
Library.content.url This element is included in summaries. 0..1 url Uri where the data can be found
Example General: http://www.acme.com/logo-small.png
Library.content.size This element is included in summaries. 0..1 integer64 Number of bytes of content (if url provided)
Library.content.hash This element is included in summaries. 0..1 base64Binary Hash of the data (sha-1, base64ed)
Library.content.title This element is included in summaries. 0..1 string Label to display in place of the data
Example General: Official Corporate Logo
Library.content.creation This element is included in summaries. 0..1 dateTime Date attachment was first created
Library.content.height 0..1 positiveInt Height of the image in pixels (photo/video)
Library.content.width 0..1 positiveInt Width of the image in pixels (photo/video)
Library.content.frames 0..1 positiveInt Number of frames if > 1 (photo)
Library.content.duration 0..1 decimal Length in seconds (audio / video)
Library.content.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 📍6.0.0-snapshot1 FHIR Std.
Library.versionAlgorithm[x] Base extensible Version Algorithm 📍6.0.0-snapshot1 FHIR Std.
Library.status Base required PublicationStatus 📍6.0.0-snapshot1 FHIR Std.
Library.type Base extensible LibraryType 📦1.0.1 THO v7.4
Library.subject[x] Base extensible Participant Resource Types 📍6.0.0-snapshot1 FHIR Std.
Library.jurisdiction Base extensible Jurisdiction ValueSet 📦1.0.0 THO v7.4
Library.topic Base example Definition Topic 📍6.0.0-snapshot1 FHIR Std.
Library.relatedArtifact.​type Base required RelatedArtifactType 📍6.0.0-snapshot1 FHIR Std.
Library.content.contentType Base required Mime Types 📦6.0.0-snapshot1 FHIR Std.
Library.content.language Base required All Languages 📍6.0.0-snapshot1 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())
lib-2 warning Library.relatedArtifact Dependencies and components of a Library should reference a resource type in ('depends-on' | 'composed-of' | 'part-of') implies ((resource.exists() xor resourceReference.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:

Maturity: 2

Key Elements View

NameFlagsCard.TypeDescription & Constraints    Filter: doco
Library C 0..* Library Represents a library of quality improvement components
Interfaces Implemented: MetadataResource
Constraints: cnl-0, sql-must-be-sql-expressions
Library.implicitRules This element is a modifier element. This element is included in summaries. 0..1 uri A set of rules under which this content was created
Library.contained 0..* Resource Contained, inline Resources
Library.modifierExtension This element is a modifier element. This element is included in summaries. 0..* Extension Extensions that cannot be ignored
Slice: Unordered, Open by value:url
Library.status This element is a modifier element. This element is included in summaries. 1..1 code draft | active | retired | unknown
Binding: PublicationStatus (required): The lifecycle status of an artifact.
Library.type This element is included in summaries. 1..1 CodeableConcept logic-library | model-definition | asset-collection | module-definition | etc.
Binding: LibraryType (extensible): The type of knowledge artifact this library contains.
Required Pattern: At least the following
Library.type.id 0..1 string Unique id for inter-element referencing
Library.type.extension 0..* Extension Additional content defined by implementations
Library.type.coding 1..* Coding Code defined by a terminology system
Fixed Value: (Complex)
Library.type.coding.id 0..1 string Unique id for inter-element referencing
Library.type.coding.extension 0..* Extension Additional content defined by implementations
Library.type.coding.system 1..1 uri Identity of the terminology system
Fixed Value: http://hl7.org/fhir/uv/sql-on-fhir/CodeSystem/LibraryTypesCodes
Library.type.coding.version 0..1 string Version of the system - if relevant
Library.type.coding.code 1..1 code Symbol in syntax defined by the system
Fixed Value: sql-view
Library.type.coding.display 0..1 string Representation defined by the system
Library.type.coding.userSelected 0..1 boolean If this coding was chosen directly by the user
Library.type.text 0..1 string Plain text representation of the concept
Library.relatedArtifact This element must be supported. C 0..* RelatedArtifact Additional documentation, citations, etc
Constraints: lib-2
Library.relatedArtifact.type This element must be supported. This element is included in summaries. 1..1 code depends-on for ViewDefinition, SQLView, ValueSet or ConceptMap references
Binding: RelatedArtifactType (required): The type of relationship to the related artifact.
Required Pattern: depends-on
Library.relatedArtifact.label This element must be supported. This element is included in summaries. C 1..1 string Table name used in SQL view
Constraints: sql-name
Library.relatedArtifact.resource This element must be supported. This element is included in summaries. 1..1 canonical(View Definition | SQL View Library | ValueSet | ConceptMap) Canonical URL of a ViewDefinition, SQLView, ValueSet or ConceptMap
Library.content This element must be supported. This element is included in summaries. 1..* Attachment Contents of the library, either embedded or referenced
Library.content.Slices for extension Content/Rules for all slices
Library.content.Slices for extension.extension:sqlText This element must be supported. 0..1 string Plain-text SQL for readability
URL: http://hl7.org/fhir/uv/sql-on-fhir/StructureDefinition/sql-text
Library.content.contentType This element must be supported. This element is included in summaries. 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
Library.content.data This element must be supported. C 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 📍6.0.0-snapshot1 FHIR Std.
Library.type Base extensible LibraryType 📦1.0.1 THO v7.4
Library.relatedArtifact.​type Base required RelatedArtifactType 📍6.0.0-snapshot1 FHIR Std.
Library.content.contentType Base required Mime Types 📦6.0.0-snapshot1 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())
lib-2 warning Library.relatedArtifact Dependencies and components of a Library should reference a resource type in ('depends-on' | 'composed-of' | 'part-of') implies ((resource.exists() xor resourceReference.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_]*$')

Differential View

This structure is derived from Library

NameFlagsCard.TypeDescription & Constraints    Filter: doco
Library C 0..* Library Represents a library of quality improvement components
Interfaces Implemented: MetadataResource
Constraints: sql-must-be-sql-expressions
Library.type 1..1 CodeableConcept logic-library | model-definition | asset-collection | module-definition | etc.
Required Pattern: At least the following
Library.type.coding 1..* Coding Code defined by a terminology system
Fixed Value: (Complex)
Library.type.coding.system 1..1 uri Identity of the terminology system
Fixed Value: http://hl7.org/fhir/uv/sql-on-fhir/CodeSystem/LibraryTypesCodes
Library.type.coding.code 1..1 code Symbol in syntax defined by the system
Fixed Value: sql-view
Library.relatedArtifact This element must be supported. 0..* RelatedArtifact Additional documentation, citations, etc
Library.relatedArtifact.type This element must be supported. 1..1 code depends-on for ViewDefinition, SQLView, ValueSet or ConceptMap references
Required Pattern: depends-on
Library.relatedArtifact.label This element must be supported. C 1..1 string Table name used in SQL view
Constraints: sql-name
Library.relatedArtifact.resource This element must be supported. 1..1 canonical(View Definition | SQL View Library | ValueSet | ConceptMap) Canonical URL of a ViewDefinition, SQLView, ValueSet or ConceptMap
Library.parameter 0..0 Not permitted (views cannot be parameterized)
Library.content This element must be supported. 1..* Attachment Contents of the library, either embedded or referenced
Library.content.Slices for extension Content/Rules for all slices
Library.content.Slices for extension.extension:sqlText This element must be supported. 0..1 string Plain-text SQL for readability
URL: http://hl7.org/fhir/uv/sql-on-fhir/StructureDefinition/sql-text
Library.content.contentType This element must be supported. 1..1 code application/sql or application/sql;dialect=...
Binding: MimeTypes (required)
Additional BindingsPurpose
All SQL Content Type Codes Extensible
Library.content.data This element must be supported. 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 📦6.0.0-snapshot1 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_]*$')

Snapshot ViewView

NameFlagsCard.TypeDescription & Constraints    Filter: doco
Library C 0..* Library Represents a library of quality improvement components
Interfaces Implemented: MetadataResource
Constraints: cnl-0, sql-must-be-sql-expressions
Library.id This element is included in summaries. 0..1 id Logical id of this artifact
Library.meta This element is included in summaries. 0..1 Meta Metadata about the resource
Library.implicitRules This element is a modifier element. This element is included in summaries. 0..1 uri A set of rules under which this content was created
Library.language 0..1 code Language of the resource content
Binding: AllLanguages (required): IETF language tag for a human language
Additional BindingsPurpose
CommonLanguages Starter
Library.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
Library.contained 0..* Resource Contained, inline Resources
Library.extension 0..* Extension Additional content defined by implementations
Slice: Unordered, Open by value:url
Library.modifierExtension This element is a modifier element. This element is included in summaries. 0..* Extension Extensions that cannot be ignored
Slice: Unordered, Open by value:url
Library.url This element is included in summaries. C 0..1 uri Canonical identifier for this library, represented as a URI (globally unique)
Constraints: cnl-1
Library.identifier This element is included in summaries. 0..* Identifier Additional identifier for the library
Library.version This element is included in summaries. 0..1 string Business version of the library
Library.versionAlgorithm[x] This element is included in summaries. 0..1 How to compare versions
Binding: VersionAlgorithm (extensible)
Library.versionAlgorithm[x].versionAlgorithmString string
Library.versionAlgorithm[x].versionAlgorithmCoding Coding
Library.name This element is included in summaries. C 0..1 string Name for this library (computer friendly)
Library.title This element is included in summaries. 0..1 string Name for this library (human friendly)
Library.subtitle 0..1 string Subordinate title of the library
Library.status This element is a modifier element. This element is included in summaries. 1..1 code draft | active | retired | unknown
Binding: PublicationStatus (required): The lifecycle status of an artifact.
Library.experimental This element is included in summaries. 0..1 boolean For testing only - never for real usage
Library.type This element is included in summaries. 1..1 CodeableConcept logic-library | model-definition | asset-collection | module-definition | etc.
Binding: LibraryType (extensible): The type of knowledge artifact this library contains.
Required Pattern: At least the following
Library.type.id 0..1 string Unique id for inter-element referencing
Library.type.extension 0..* Extension Additional content defined by implementations
Library.type.coding 1..* Coding Code defined by a terminology system
Fixed Value: (Complex)
Library.type.coding.id 0..1 string Unique id for inter-element referencing
Library.type.coding.extension 0..* Extension Additional content defined by implementations
Library.type.coding.system 1..1 uri Identity of the terminology system
Fixed Value: http://hl7.org/fhir/uv/sql-on-fhir/CodeSystem/LibraryTypesCodes
Library.type.coding.version 0..1 string Version of the system - if relevant
Library.type.coding.code 1..1 code Symbol in syntax defined by the system
Fixed Value: sql-view
Library.type.coding.display 0..1 string Representation defined by the system
Library.type.coding.userSelected 0..1 boolean If this coding was chosen directly by the user
Library.type.text 0..1 string Plain text representation of the concept
Library.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.).
Library.subject[x].subjectCodeableConcept CodeableConcept
Library.subject[x].subjectReference Reference(Group)
Library.date This element is included in summaries. 0..1 dateTime Date last changed
Library.publisher This element is included in summaries. 0..1 string Name of the publisher/steward (organization or individual)
Library.contact This element is included in summaries. 0..* ContactDetail Contact details for the publisher
Library.description This element is included in summaries. 0..1 markdown Natural language description of the library
Library.useContext This element is included in summaries. 0..* UsageContext The context that the content is intended to support
Library.jurisdiction This element is included in summaries. 0..* CodeableConcept Jurisdiction of the authority that maintains the library (if applicable)
Binding: Jurisdiction ValueSet (extensible): Countries and regions within which this artifact is targeted for use.
Library.purpose 0..1 markdown Why this library is defined
Library.usage 0..1 markdown Describes the clinical usage of the library
Library.copyright 0..1 markdown Notice about intellectual property ownership, can include restrictions on use
Library.copyrightLabel 0..1 string Copyright holder and year(s)
Library.approvalDate 0..1 date When the library was approved by publisher
Library.lastReviewDate 0..1 date When the library was last reviewed by the publisher
Library.effectivePeriod This element is included in summaries. 0..1 Period When the library is expected to be used
Library.topic 0..* CodeableConcept E.g. Education, Treatment, Assessment, etc
Binding: DefinitionTopic (example): High-level categorization of the definition, used for searching, sorting, and filtering.
Library.author 0..* ContactDetail Who authored the content
Library.editor 0..* ContactDetail Who edited the content
Library.reviewer 0..* ContactDetail Who reviewed the content
Library.endorser 0..* ContactDetail Who endorsed the content
Library.relatedArtifact This element must be supported. C 0..* RelatedArtifact Additional documentation, citations, etc
Constraints: lib-2
Library.relatedArtifact.id 0..1 string Unique id for inter-element referencing
Library.relatedArtifact.extension 0..* Extension Additional content defined by implementations
Slice: Unordered, Open by value:url
Library.relatedArtifact.type This element must be supported. This element is included in summaries. 1..1 code depends-on for ViewDefinition, SQLView, ValueSet or ConceptMap references
Binding: RelatedArtifactType (required): The type of relationship to the related artifact.
Required Pattern: depends-on
Library.relatedArtifact.label This element must be supported. This element is included in summaries. C 1..1 string Table name used in SQL view
Constraints: sql-name
Library.relatedArtifact.display This element is included in summaries. 0..1 string Brief description of the related artifact
Library.relatedArtifact.citation This element is included in summaries. 0..1 markdown Bibliographic citation for the artifact
Library.relatedArtifact.url This element is included in summaries. 0..1 url A url for the artifact that can be followed to access the actual content
Library.relatedArtifact.document This element is included in summaries. 0..1 Attachment What document is being referenced
Library.relatedArtifact.resource This element must be supported. This element is included in summaries. 1..1 canonical(View Definition | SQL View Library | ValueSet | ConceptMap) Canonical URL of a ViewDefinition, SQLView, ValueSet or ConceptMap
Library.relatedArtifact.resourceReference This element is included in summaries. 0..1 Reference(Resource) What artifact, if not a conformance resource
Library.dataRequirement 0..* DataRequirement What data is referenced by this library
Library.content This element must be supported. This element is included in summaries. 1..* Attachment Contents of the library, either embedded or referenced
Library.content.id 0..1 string Unique id for inter-element referencing
Library.content.Slices for extension 0..* Extension Additional content defined by implementations
Slice: Unordered, Open by value:url
Library.content.Slices for extension.extension:sqlText This element must be supported. 0..1 string Plain-text SQL for readability
URL: http://hl7.org/fhir/uv/sql-on-fhir/StructureDefinition/sql-text
Library.content.contentType This element must be supported. This element is included in summaries. 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
Library.content.language This element is included in summaries. 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
Library.content.data This element must be supported. C 1..1 base64Binary SQL view (base64-encoded)
Library.content.url This element is included in summaries. 0..1 url Uri where the data can be found
Example General: http://www.acme.com/logo-small.png
Library.content.size This element is included in summaries. 0..1 integer64 Number of bytes of content (if url provided)
Library.content.hash This element is included in summaries. 0..1 base64Binary Hash of the data (sha-1, base64ed)
Library.content.title This element is included in summaries. 0..1 string Label to display in place of the data
Example General: Official Corporate Logo
Library.content.creation This element is included in summaries. 0..1 dateTime Date attachment was first created
Library.content.height 0..1 positiveInt Height of the image in pixels (photo/video)
Library.content.width 0..1 positiveInt Width of the image in pixels (photo/video)
Library.content.frames 0..1 positiveInt Number of frames if > 1 (photo)
Library.content.duration 0..1 decimal Length in seconds (audio / video)
Library.content.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 📍6.0.0-snapshot1 FHIR Std.
Library.versionAlgorithm[x] Base extensible Version Algorithm 📍6.0.0-snapshot1 FHIR Std.
Library.status Base required PublicationStatus 📍6.0.0-snapshot1 FHIR Std.
Library.type Base extensible LibraryType 📦1.0.1 THO v7.4
Library.subject[x] Base extensible Participant Resource Types 📍6.0.0-snapshot1 FHIR Std.
Library.jurisdiction Base extensible Jurisdiction ValueSet 📦1.0.0 THO v7.4
Library.topic Base example Definition Topic 📍6.0.0-snapshot1 FHIR Std.
Library.relatedArtifact.​type Base required RelatedArtifactType 📍6.0.0-snapshot1 FHIR Std.
Library.content.contentType Base required Mime Types 📦6.0.0-snapshot1 FHIR Std.
Library.content.language Base required All Languages 📍6.0.0-snapshot1 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())
lib-2 warning Library.relatedArtifact Dependencies and components of a Library should reference a resource type in ('depends-on' | 'composed-of' | 'part-of') implies ((resource.exists() xor resourceReference.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:

Maturity: 2

 

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. A ValueSet or ConceptMap dependency joins the same graph as a leaf, exposed as a relation of its member codes or of its mappings (see Terminology in SQL). Authors SHOULD keep this graph acyclic.

Whether circular dependencies are detected or rejected, any limit on dependency depth, and whether intermediate results are materialized 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 materialize the view's result or inline it; either approach conforms to this specification.