Using CQL with FHIR, published by HL7 International / Clinical Decision Support. This guide is not an authorized publication; it is the continuous build for version 1.1.0-cibuild built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/HL7/cql-ig/ and changes regularly. See the Directory of published versions
Official URL: http://hl7.org/fhir/uv/cql/Library/TypeMappingExample | Version: 1.1.0-cibuild | |||
Active as of 2024-06-10 | Computable Name: TypeMappingExample | |||
Other Identifiers: OID:2.16.840.1.113883.4.642.40.37.28.6 |
Example CQL library providing a complete set of expressions that cover all possible CQL and FHIR Type Mapping, for both input and output. See the Type Mapping Evaluation Result example for an illustration of the type mapping in a Parameters resource.
depends-on | FHIR model information | http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1 |
depends-on | Library FHIRHelpers | http://fhir.org/guides/cqf/common/Library/FHIRHelpers|4.0.1 |
depends-on | Code system ExampleCodeSystem | CQL IG Example Code System |
depends-on | Code system LOINC | Logical Observation Identifiers, Names and Codes (LOINC) |
depends-on | Value set ExampleValueSet | Example Specific health concern(s) Codes |
ExampleVocabulary | in | 0 | 1 | Resource |
Patient | out | 0 | 1 | Patient |
CQLBooleanExample | out | 0 | 1 | boolean |
CQLCodeExample | out | 0 | 1 | Coding |
CQLCodeSystemExample | out | 0 | 1 | Resource |
CQLConceptExample | out | 0 | 1 | CodeableConcept |
CQLDateExample | out | 0 | 1 | date |
CQLDateTimeExample | out | 0 | 1 | dateTime |
CQLDecimalExample | out | 0 | 1 | decimal |
CQLLongExample | out | 0 | 1 | Resource |
CQLIntegerExample | out | 0 | 1 | integer |
CQLQuantityExample | out | 0 | 1 | Quantity |
CQLRatioExample | out | 0 | 1 | Ratio |
CQLStringExample | out | 0 | 1 | string |
CQLTimeExample | out | 0 | 1 | time |
CQLValueSetExample | out | 0 | 1 | Resource |
CQLVocabularyExample | out | 0 | 1 | Resource |
CQLDateIntervalExample | out | 0 | 1 | Period |
CQLDateTimeIntervalExample | out | 0 | 1 | Period |
CQLTimeIntervalExample | out | 0 | 1 | Resource |
CQLIntegerIntervalExample | out | 0 | 1 | Range |
CQLQuantityIntervalExample | out | 0 | 1 | Range |
CQLListExample | out | 0 | * | integer |
CQLTupleExample | out | 0 | 1 | Resource |
CQLChoiceListExample | out | 0 | * | Resource |
CQLTupleListExample | out | 0 | * | Resource |
CQLComplexTupleExample | out | 0 | 1 | Resource |
CQLComplexTupleListExample | out | 0 | * | Resource |
CQLEmptyListExample | out | 0 | * | Resource |
FHIRObservations | out | 0 | * | Observation |
FHIRBloodGlucoseObservation | out | 0 | 1 | Observation |
FHIRBooleanExample | out | 0 | 1 | boolean |
FHIRStringExample | out | 0 | 1 | string |
FHIRQuantityExample | out | 0 | 1 | Quantity |
FHIRPeriodExample | out | 0 | 1 | Period |
FHIRRangeExample | out | 0 | 1 | Range |
FHIRObservationExample | out | 0 | 1 | Observation |
FHIRObservationListExample | out | 0 | * | Observation |
FHIREmptyObservationListExample | out | 0 | * | Observation |
Type: Patient (Patient) |
Type: Observation (Observation) |
text/cql
/*
@description: An example library illustrating the FHIR Type mapping for CQL
*/
library TypeMappingExample
using FHIR version '4.0.1'
include FHIRHelpers version '4.0.1'
codesystem ExampleCodeSystem: 'http://hl7.org/fhir/uv/cql/CodeSystem/example'
codesystem LOINC: 'http://loinc.org'
valueset ExampleValueSet: 'http://hl7.org/fhir/uv/cql/ValueSet/example'
code ExampleCode: 'example-code' from ExampleCodeSystem
code BloodGlucose: '2339-0' from LOINC display 'Glucose Bld-mCnc'
concept ExampleConcept: { ExampleCode }
parameter ExampleVocabulary Vocabulary
context Patient
// Example values as output
// CQL Values
// Boolean
define CQLBooleanExample: true
// Code
define CQLCodeExample: ExampleCode
// CodeSystem
define CQLCodeSystemExample: ExampleCodeSystem
// Concept
define CQLConceptExample: ExampleConcept
// Date
define CQLDateExample: @2024-01-01
// DateTime
define CQLDateTimeExample: @2024-01-01T10:30:00Z
// Decimal
define CQLDecimalExample: 10.0
// Long
define CQLLongExample: 10L
// Integer
define CQLIntegerExample: 10
// Quantity
define CQLQuantityExample: 10 'mg'
// Ratio
define CQLRatioExample: 5 'mg' : 10 'mg'
// String
define CQLStringExample: 'John'
// Time
define CQLTimeExample: @T10:30:00
// ValueSet
define CQLValueSetExample: ExampleValueSet
// Vocabulary
define CQLVocabularyExample: ExampleVocabulary
// Interval<Date>
define CQLDateIntervalExample: Interval[@2024-01-01, @2024-01-31]
// Interval<DateTime>
define CQLDateTimeIntervalExample: Interval[@2024-01-01T10:30:00Z, @2024-01-31T10:30:00Z]
// Interval<Time>
define CQLTimeIntervalExample: Interval[@T10:30:00, @T11:30:00]
// Interval<Integer>
define CQLIntegerIntervalExample: Interval[5, 10]
// Interval<Quantity>
define CQLQuantityIntervalExample: Interval[5 'mg', 10 'mg']
// List
define CQLListExample: { 1, 2, 3, 4, 5 }
// Tuple
define CQLTupleExample: { X: 1, Y: 1 }
// ChoiceList
define CQLChoiceListExample: List<Choice<Integer, Decimal>> { 1, 1.0 }
// TupleList
define CQLTupleListExample: { { X: 1, Y: 1 }, { X: 1, Y: 2 }, { X: 1, Y: 3 } }
// ComplexTuple
define CQLComplexTupleExample: { id: 1, name: 'Patrick', address: { { street: '123 Spinning Ave', city: 'Dayton', state: 'OH' } } }
// ComplexTupleList
define CQLComplexTupleListExample: { CQLComplexTupleExample }
// EmptyList
define CQLEmptyListExample: CQLComplexTupleListExample E where false
// FHIR Values
define private FHIRObservations: [Observation]
define private FHIRBloodGlucoseObservation: (FHIRObservations O where O.code ~ BloodGlucose).single()
// boolean
define FHIRBooleanExample: Patient.active
// string
define FHIRStringExample: Patient.name.first().family
// Quantity
define FHIRQuantityExample: FHIRBloodGlucoseObservation.value as FHIR.Quantity
// Period
define FHIRPeriodExample: Patient.address.first().period
// Range
define FHIRRangeExample: FHIRBloodGlucoseObservation O return FHIR.Range { low: O.referenceRange.first().low, high: O.referenceRange.first().high }
// Observation
define FHIRObservationExample: FHIRBloodGlucoseObservation
// List<Observation>
define FHIRObservationListExample: FHIRObservations
// EmptyList<Observation>
define FHIREmptyObservationListExample: FHIRObservations O where false
Content not shown - (
application/elm+xml
, size = 287Kb )
Content not shown - (
application/elm+json
, size = 218Kb )