Using CQL with FHIR
1.1.0-cibuild - CIBuild 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 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

: CQL Example - TTL Representation

Active as of 2024-06-10

Raw ttl | Download


@prefix fhir: <http://hl7.org/fhir/> .
@prefix loinc: <https://loinc.org/rdf/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

# - resource -------------------------------------------------------------------

 a fhir:Library ;
  fhir:nodeRole fhir:treeRoot ;
  fhir:id [ fhir:v "CQLExample"] ; # 
  fhir:meta [
    ( fhir:profile [
fhir:v "http://hl7.org/fhir/uv/cql/StructureDefinition/cql-library"^^xsd:anyURI ;
fhir:link <http://hl7.org/fhir/uv/cql/StructureDefinition/cql-library>     ] )
  ] ; # 
  fhir:text [
fhir:status [ fhir:v "generated" ] ;
fhir:div "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h2>Related Artifacts</h2><table class=\"grid\"><tr><td>depends-on</td><td>FHIR model information</td><td><code>http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1</code></td></tr><tr><td>depends-on</td><td>Library FHIRHelpers</td><td><code>http://fhir.org/guides/cqf/common/Library/FHIRHelpers|4.0.1</code></td></tr><tr><td>depends-on</td><td>Code system LOINC</td><td><a href=\"http://terminology.hl7.org/5.5.0/CodeSystem-v3-loinc.html\">Logical Observation Identifiers, Names and Codes (LOINC)</a></td></tr></table><h2>Parameters</h2><table class=\"grid\"><tr><td>GlucoseThreshold</td><td>in</td><td>0</td><td>1</td><td>Quantity</td></tr><tr><td>Patient</td><td>out</td><td>0</td><td>1</td><td>Patient</td></tr><tr><td>Blood Glucose Observations</td><td>out</td><td>0</td><td>*</td><td>Observation</td></tr></table><h2>Data Requirements</h2><table class=\"grid\"><tr><td colspan=\"2\"><b>Type</b>: <a href=\"http://hl7.org/fhir/R4/patient.html\">Patient</a> (<a href=\"http://hl7.org/fhir/R4/patient.html\">Patient</a>)</td></tr></table><table class=\"grid\"><tr><td colspan=\"2\"><b>Type</b>: <a href=\"http://hl7.org/fhir/R4/observation.html\">Observation</a> (<a href=\"http://hl7.org/fhir/R4/observation.html\">Observation</a>)</td></tr><tr style=\"background-color: #efefef\"><td>Filter</td><td>Value</td></tr><tr><td>code</td><td>One of these codes: <a href=\"https://loinc.org/2339-0\">Logical Observation Identifiers, Names and Codes (LOINC)</a> 2339-0: Glucose Bld-mCnc</td></tr></table><h2>Contents</h2><p><code>text/cql</code></p><pre><code class=\"language-sql\">library CQLExample\r\n\r\nusing FHIR version '4.0.1'\r\n\r\ninclude FHIRHelpers version '4.0.1'\r\n\r\ncodesystem LOINC: 'http://loinc.org'\r\ncode &quot;Blood Glucose&quot;: '2339-0' from LOINC display 'Glucose Bld-mCnc'\r\n\r\nparameter GlucoseThreshold Quantity\r\n\r\ncontext Patient\r\n\r\ndefine &quot;Blood Glucose Observations&quot;:\r\n  [Observation: &quot;Blood Glucose&quot;] BG\r\n    where BG.value &gt; GlucoseThreshold\r\n</code></pre></div>"
  ] ; # 
  fhir:contained ( [
a fhir:Parameters ;
fhir:id [ fhir:v "options" ] ;
    ( fhir:parameter [
fhir:name [ fhir:v "translatorVersion" ] ;
fhir:value [ fhir:v "3.9.0" ]     ] [
fhir:name [ fhir:v "enableAnnotations" ] ;
fhir:value [ fhir:v "true"^^xsd:boolean ]     ] [
fhir:name [ fhir:v "enableLocators" ] ;
fhir:value [ fhir:v "true"^^xsd:boolean ]     ] [
fhir:name [ fhir:v "disableListDemotion" ] ;
fhir:value [ fhir:v "true"^^xsd:boolean ]     ] [
fhir:name [ fhir:v "disableListPromotion" ] ;
fhir:value [ fhir:v "true"^^xsd:boolean ]     ] [
fhir:name [ fhir:v "format" ] ;
fhir:value [ fhir:v "JSON" ]     ] [
fhir:name [ fhir:v "format" ] ;
fhir:value [ fhir:v "XML" ]     ] [
fhir:name [ fhir:v "analyzeDataRequirements" ] ;
fhir:value [ fhir:v "false"^^xsd:boolean ]     ] [
fhir:name [ fhir:v "collapseDataRequirements" ] ;
fhir:value [ fhir:v "true"^^xsd:boolean ]     ] [
fhir:name [ fhir:v "compatibilityLevel" ] ;
fhir:value [ fhir:v "1.5" ]     ] [
fhir:name [ fhir:v "enableCqlOnly" ] ;
fhir:value [ fhir:v "false"^^xsd:boolean ]     ] [
fhir:name [ fhir:v "errorLevel" ] ;
fhir:value [ fhir:v "Info" ]     ] [
fhir:name [ fhir:v "signatureLevel" ] ;
fhir:value [ fhir:v "Overloads" ]     ] [
fhir:name [ fhir:v "validateUnits" ] ;
fhir:value [ fhir:v "true"^^xsd:boolean ]     ] [
fhir:name [ fhir:v "verifyOnly" ] ;
fhir:value [ fhir:v "false"^^xsd:boolean ]     ] )
  ] ) ; # 
  fhir:extension ( [
fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-cqlOptions"^^xsd:anyURI ] ;
fhir:value [
a fhir:Reference ;
fhir:reference [ fhir:v "#options" ]     ]
  ] ) ; # 
  fhir:url [ fhir:v "http://hl7.org/fhir/uv/cql/Library/CQLExample"^^xsd:anyURI] ; # 
  fhir:identifier ( [
fhir:system [ fhir:v "urn:ietf:rfc:3986"^^xsd:anyURI ] ;
fhir:value [ fhir:v "urn:oid:2.16.840.1.113883.4.642.40.37.28.2" ]
  ] ) ; # 
  fhir:version [ fhir:v "1.1.0-cibuild"] ; # 
  fhir:name [ fhir:v "CQLExample"] ; # 
  fhir:title [ fhir:v "CQL Example"] ; # 
  fhir:status [ fhir:v "active"] ; # 
  fhir:experimental [ fhir:v "true"^^xsd:boolean] ; # 
  fhir:type [
    ( fhir:coding [
fhir:system [ fhir:v "http://terminology.hl7.org/CodeSystem/library-type"^^xsd:anyURI ] ;
fhir:code [ fhir:v "logic-library" ]     ] )
  ] ; # 
  fhir:date [ fhir:v "2024-06-10T16:43:49+00:00"^^xsd:dateTime] ; # 
  fhir:publisher [ fhir:v "HL7 International / Clinical Decision Support"] ; # 
  fhir:contact ( [
    ( fhir:telecom [
fhir:system [ fhir:v "url" ] ;
fhir:value [ fhir:v "http://www.hl7.org/Special/committees/dss" ]     ] )
  ] ) ; # 
  fhir:description [ fhir:v "Example CQL Library illustrating the CQL Profile (a Library with only text/cql content)"] ; # 
  fhir:jurisdiction ( [
    ( fhir:coding [
fhir:system [ fhir:v "http://unstats.un.org/unsd/methods/m49/m49.htm"^^xsd:anyURI ] ;
fhir:code [ fhir:v "001" ] ;
fhir:display [ fhir:v "World" ]     ] )
  ] ) ; # 
  fhir:relatedArtifact ( [
fhir:type [ fhir:v "depends-on" ] ;
fhir:display [ fhir:v "FHIR model information" ] ;
fhir:resource [
fhir:v "http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1"^^xsd:anyURI ;
fhir:link <http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1>     ]
  ] [
fhir:type [ fhir:v "depends-on" ] ;
fhir:display [ fhir:v "Library FHIRHelpers" ] ;
fhir:resource [
fhir:v "http://fhir.org/guides/cqf/common/Library/FHIRHelpers|4.0.1"^^xsd:anyURI ;
fhir:link <http://fhir.org/guides/cqf/common/Library/FHIRHelpers|4.0.1>     ]
  ] [
fhir:type [ fhir:v "depends-on" ] ;
fhir:display [ fhir:v "Code system LOINC" ] ;
fhir:resource [
fhir:v "http://loinc.org"^^xsd:anyURI ;
fhir:link <http://loinc.org>     ]
  ] ) ; # 
  fhir:parameter ( [
fhir:name [ fhir:v "GlucoseThreshold" ] ;
fhir:use [ fhir:v "in" ] ;
fhir:min [ fhir:v "0"^^xsd:integer ] ;
fhir:max [ fhir:v "1" ] ;
fhir:type [ fhir:v "Quantity" ]
  ] [
fhir:name [ fhir:v "Patient" ] ;
fhir:use [ fhir:v "out" ] ;
fhir:min [ fhir:v "0"^^xsd:integer ] ;
fhir:max [ fhir:v "1" ] ;
fhir:type [ fhir:v "Patient" ]
  ] [
fhir:name [ fhir:v "Blood Glucose Observations" ] ;
fhir:use [ fhir:v "out" ] ;
fhir:min [ fhir:v "0"^^xsd:integer ] ;
fhir:max [ fhir:v "*" ] ;
fhir:type [ fhir:v "Observation" ]
  ] ) ; # 
  fhir:dataRequirement ( [
fhir:type [ fhir:v "Patient" ] ;
    ( fhir:profile [
fhir:v "http://hl7.org/fhir/StructureDefinition/Patient"^^xsd:anyURI ;
fhir:link <http://hl7.org/fhir/StructureDefinition/Patient>     ] )
  ] [
fhir:type [ fhir:v "Observation" ] ;
    ( fhir:profile [
fhir:v "http://hl7.org/fhir/StructureDefinition/Observation"^^xsd:anyURI ;
fhir:link <http://hl7.org/fhir/StructureDefinition/Observation>     ] ) ;
    ( fhir:mustSupport [ fhir:v "code" ] [ fhir:v "value" ] ) ;
    ( fhir:codeFilter [
fhir:path [ fhir:v "code" ] ;
      ( fhir:code [
a loinc:2339-0 ;
fhir:system [ fhir:v "http://loinc.org"^^xsd:anyURI ] ;
fhir:code [ fhir:v "2339-0" ] ;
fhir:display [ fhir:v "Glucose Bld-mCnc" ]       ] )     ] )
  ] ) ; # 
  fhir:content ( [
fhir:contentType [ fhir:v "text/cql" ] ;
fhir:data [ fhir:v "bGlicmFyeSBDUUxFeGFtcGxlDQoNCnVzaW5nIEZISVIgdmVyc2lvbiAnNC4wLjEnDQoNCmluY2x1ZGUgRkhJUkhlbHBlcnMgdmVyc2lvbiAnNC4wLjEnDQoNCmNvZGVzeXN0ZW0gTE9JTkM6ICdodHRwOi8vbG9pbmMub3JnJw0KY29kZSAiQmxvb2QgR2x1Y29zZSI6ICcyMzM5LTAnIGZyb20gTE9JTkMgZGlzcGxheSAnR2x1Y29zZSBCbGQtbUNuYycNCg0KcGFyYW1ldGVyIEdsdWNvc2VUaHJlc2hvbGQgUXVhbnRpdHkNCg0KY29udGV4dCBQYXRpZW50DQoNCmRlZmluZSAiQmxvb2QgR2x1Y29zZSBPYnNlcnZhdGlvbnMiOg0KICBbT2JzZXJ2YXRpb246ICJCbG9vZCBHbHVjb3NlIl0gQkcNCiAgICB3aGVyZSBCRy52YWx1ZSA+IEdsdWNvc2VUaHJlc2hvbGQNCg=="^^xsd:base64Binary ]
  ] ) . #