Using CQL with FHIR
2.0.0-ballot - STU2Ballot International flag

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 2.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/cql-ig/ and changes regularly. See the Directory of published versions

Library: CQL Example (Experimental)

Official URL: http://hl7.org/fhir/uv/cql/Library/CQLExample Version: 2.0.0-ballot
Active as of 2024-12-16 Computable Name: CQLExample
Other Identifiers: OID:2.16.840.1.113883.4.642.40.37.28.2

Example CQL Library illustrating the CQL Profile (a Library with only text/cql content)

Title: CQL Example
Id: CQLExample
Version: 2.0.0-ballot
Url: CQL Example

urn:oid:2.16.840.1.113883.4.642.40.37.28.2

Experimental: true
Type:

system: http://terminology.hl7.org/CodeSystem/library-type

code: logic-library

Date: 2024-12-16 19:25:00+0000
Publisher: HL7 International / Clinical Decision Support
Description:

Example CQL Library illustrating the CQL Profile (a Library with only text/cql content)

Jurisdiction: 001
Related Artifacts:

Dependencies

Parameters:
NameTypeMinMaxIn/Out
GlucoseThresholdQuantity01In
PatientPatient01Out
Blood Glucose ObservationsObservation0*Out
Patient Birth Sex Is Male (refined)Patient01Out
Data Requirements:
TypeProfileMSCode Filter
Observation http://hl7.org/fhir/StructureDefinition/Observation code filter:
path: code

system: http://loinc.org

code: 2339-0

display: Glucose Bld-mCnc

Content: text/cql
library CQLExample

using FHIR version '4.0.1'

include FHIRHelpers version '2.0.0-ballot'

codesystem LOINC: 'http://loinc.org'
code "Blood Glucose": '2339-0' from LOINC display 'Glucose Bld-mCnc'

parameter GlucoseThreshold Quantity

context Patient

define "Blood Glucose Observations":
  [Observation: "Blood Glucose"] BG
    where BG.value > GlucoseThreshold

define fluent function birthsex(patient Patient):
  (singleton from (
    patient.extension E where E.url = 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex'
  )).value as FHIR.code

define "Patient Birth Sex Is Male (refined)":
  Patient P
    where P.birthsex() = 'M'
Content: application/elm+xml
Encoded data (7304 characters)
Content: application/elm+json
Encoded data (12168 characters)