Using CQL With FHIR
3.0.0-ballot - STU 3 Ballot

Using CQL With FHIR - Downloaded Version null See the Directory of published versions

## Library: Type Mapping Example (Experimental)

Official URL: http://hl7.org/fhir/uv/cql/Library/TypeMappingExample | Version: 3.0.0-ballot | Highlight text changes?
Standards status: Informative | 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.

Metadata
Title | Type Mapping Example
Version | 3.0.0-ballot
Identifier | urn:oid:2.16.840.1.113883.4.642.40.37.28.6
Experimental | true
Jurisdiction | World
Steward (Publisher) | HL7 International / Clinical Decision Support
Description | 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.
Type | logic-library from http://terminology.hl7.org/CodeSystem/library-type
Dependency | Description: Library FHIRHelpers Resource: FHIR Helpers version: 4.0.2-ballot Canonical URL: `http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.2-ballot`
Dependency | Description: Code System ExampleCodeSystem Resource: CQL IG Example Code System Canonical URL: `http://hl7.org/fhir/uv/cql/CodeSystem/example`
Dependency | Description: Code System LOINC Resource: LOINC Canonical URL: `http://loinc.org`
Dependency | Description: Value Set ExampleValueSet Resource: Example Specific health concern(s) Codes Canonical URL: `http://hl7.org/fhir/uv/cql/ValueSet/shareable-example`
Data Requirement | Type: Observation Profile(s): Observation
Parameters
Name | Use | Card. | Type | Documentation
ExampleVocabulary | In | 0..1 | Resource |
Patient | Out | 0..1 | Patient |
CQLBooleanExample | Out | 0..1 | boolean |
CQLBooleanNullExample | 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 |
CQLPartialDateTimeExample | Out | 0..1 | dateTime |
CQLPartialDateTimeMinutesExample | Out | 0..1 | dateTime |
CQLDecimalExample | Out | 0..1 | decimal |
CQLDecimalPrecisionExample | 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 |
CQLPartialTimeExample | 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 | Resource |
CQLDecimalIntervalExample | Out | 0..1 | Resource |
CQLDecimalUnclosedIntervalExample | Out | 0..1 | Resource |
CQLLongIntervalExample | Out | 0..1 | Resource |
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 |
CQLListListExample | Out | 0..* | Resource |
CQLEmptyTupleExample | Out | 0..1 | Resource |
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 |
FHIRBackboneElementExample | Out | 0..1 | BackboneElement |
FHIRSimpleExtensionExample | Out | 0..1 | Extension |
FHIRComplexExtensionExample | Out | 0..1 | Extension |
Library Content
CQL Content |
    /*
    @description: An example library illustrating the FHIR Type mapping for CQL
    */
    library TypeMappingExample

    using FHIR version '4.0.1'

    include FHIRHelpers version '4.0.2-ballot'

    codesystem ExampleCodeSystem: 'http://hl7.org/fhir/uv/cql/CodeSystem/example'
    codesystem LOINC: 'http://loinc.org'
    valueset ExampleValueSet: 'http://hl7.org/fhir/uv/cql/ValueSet/shareable-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
    // Boolean Null
    define CQLBooleanNullExample: null as Boolean
    // 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
    define CQLPartialDateTimeExample: @2024-01-01TZ
    define CQLPartialDateTimeMinutesExample: @2024-01-01T10:30Z
    // Decimal
    define CQLDecimalExample: 10.0
    define CQLDecimalPrecisionExample: 10.0000
    // 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
    define CQLPartialTimeExample: @T10:30
    // 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<Decimal>
    define CQLDecimalIntervalExample: Interval[5.5, 10.5]
    define CQLDecimalUnclosedIntervalExample: Interval[1.0, 1.4)
    // Interval<Long>
    define CQLLongIntervalExample: Interval[3000000000L,4000000000L]
    // 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
    // ListList
    define CQLListListExample: { CQLListExample, CQLListExample }
    // EmptyTuple
    define CQLEmptyTupleExample: { : }

    // 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
    // BackboneElement
    // TODO: Should not need to cast this, but without it the ELM gets an error on the type code Patient.Contact
    define FHIRBackboneElementExample: Patient.contact.first() as FHIR.BackboneElement
    // Extension (simple)
    define FHIRSimpleExtensionExample: Patient.birthDate.extension.where(url = 'http://hl7.org/fhir/StructureDefinition/patient-birthTime').first()
    // Extension (complex)
    define FHIRComplexExtensionExample: Patient.extension.where(url = 'http://hl7.org/fhir/StructureDefinition/patient-citizenship').first()
ELM JSON Content |
    Encoded data
Generated using version 0.5.6-cibuild of the sample-content-ig Liquid templates