Using CQL With FHIR
3.0.0-ballot - STU 3 Ballot

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

## : CQL Example

Page standards status: Informative

Raw xml | Download

    <Library xmlns="http://hl7.org/fhir">
      <id value="CQLExample"/>
      <meta>
        <profile
                 value="http://hl7.org/fhir/uv/cql/StructureDefinition/cql-library"/>
      </meta>
      <language value="en"/>
      <text>
        <status value="extensions"/>
        <div xmlns="http://www.w3.org/1999/xhtml">
      <table class="narrative-table">
        <tbody>
    <tr>

    <th colspan="2" scope="row" class="row-header">Metadata</th>

    </tr>

    <tr>

    <th scope="row" class="row-header">Title</th>

    <td class="content-container">CQL Example</td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Version</th>

    <td class="content-container">3.0.0-ballot</td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Identifier</th>

    <td class="content-container">urn:oid:2.16.840.1.113883.4.642.40.37.28.2</td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Experimental</th>

    <td class="content-container">true</td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Jurisdiction</th>

    <td class="content-container">
        World

    </td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Steward (Publisher)</th>

    <td class="content-container">HL7 International / Clinical Decision Support</td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Description</th>

    <td class="content-container"><div><p>Example CQL Library illustrating the CQL Profile (a Library with only text/cql content)</p>
    </div></td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Type</th>

    <td class="content-container">
        logic-library from <a href="http://terminology.hl7.org/7.3.0/CodeSystem-library-type.html">http://terminology.hl7.org/CodeSystem/library-type</a>

    </td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Dependency</th>

      <td class="content-container">

        <em>Description</em>: Library FHIRHelpers

        <br/>

        <em>Resource</em>: <a href="Library-FHIRHelpers.html">FHIR Helpers</a> version: 4.0.2-ballot
        <br/>
        <em>Canonical URL</em>: <tt>http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.2-ballot</tt>

      </td>
    </tr>

    <tr>

    <th scope="row" class="row-header">Dependency</th>

      <td class="content-container">

        <em>Description</em>: Code System LOINC

        <br/>

        <em>Resource</em>: <a href="http://tx.fhir.org/r4/ValueSet/x-loinc2.82">LOINC</a>
        <br/>
        <em>Canonical URL</em>: <tt>http://loinc.org</tt>

      </td>
    </tr>

    <tr>
      <th scope="row" class="row-header">Data Requirement</th>
      <td class="content-container">
        <em>Type</em>: Observation
        <br/>

        <em>Profile(s)</em>:

        <a href="http://hl7.org/fhir/R4/observation.html">Observation</a>
        <br/>

        <em>Code Filter(s)</em>:
        <br/>

        <span class="tab-one"><em>Path</em>: code</span>
        <br/>

        <span class="tab-one"><em>Code(s)</em>:

          <a href="https://loinc.org/2339-0">LOINC: 2339-0</a> (Glucose Bld-mCnc)

        </span>
        <br/>

      </td>
    </tr>

    <tr>

    <th colspan="2" scope="row" class="row-header"><a name="parameters"> </a>Parameters</th>

    </tr>

    <tr>

    <th scope="row" class="row-header"/>

      <td class="content-container">
        <table>
          <thead>
            <tr>
              <td><em>Name</em></td>
              <td><em>Use</em></td>
              <td><em>Card.</em></td>
              <td><em>Type</em></td>
              <td><em>Documentation</em></td>
            </tr>
          </thead>
          <tbody>

            <tr>
              <td>GlucoseThreshold</td>
              <td>In</td>
              <td>0..1</td>
              <td>Quantity</td>
              <td/>
            </tr>

            <tr>
              <td>Patient</td>
              <td>Out</td>
              <td>0..1</td>
              <td>Patient</td>
              <td/>
            </tr>

            <tr>
              <td>Blood Glucose Observations</td>
              <td>Out</td>
              <td>0..*</td>
              <td>Observation</td>
              <td/>
            </tr>

            <tr>
              <td>Patient Interpreter Required (refined)</td>
              <td>Out</td>
              <td>0..1</td>
              <td>Patient</td>
              <td/>
            </tr>

          </tbody>
        </table>
      </td>
    </tr>

      <tr>

    <th colspan="2" scope="row" class="row-header">Library Content</th>

    </tr>

        <tr>
          <th scope="row" class="row-header">CQL Content</th>
          <td>
            <a name="cql-content"> </a>
            <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">library CQLExample

    using FHIR version '4.0.1'

    include FHIRHelpers version '4.0.2-ballot'

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

    parameter GlucoseThreshold Quantity

    context Patient

    define &quot;Blood Glucose Observations&quot;:
      [Observation: &quot;Blood Glucose&quot;] BG
        where BG.value &gt; GlucoseThreshold

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

    define &quot;Patient Interpreter Required (refined)&quot;:
      Patient P
        where P.interpreterRequired() is true</code></pre>
          </td>
        </tr>

        <tr>
          <th scope="row" class="row-header">ELM JSON Content</th>
          <td>
            <pre style="border: none;" class="content-container highlight language-cql"><code>Encoded data </code></pre>
          </td>
        </tr>

    <tr>
      <th colspan="2" scope="row" class="row-header">Generated using version 0.5.6-cibuild of the sample-content-ig Liquid templates</th>
    </tr>

        </tbody>
      </table>
    </div>
      </text>
      <contained>
        <Parameters>
          <id value="options"/>
          <parameter>
            <name value="translatorVersion"/>
            <valueString value="3.9.0"/>
          </parameter>
          <parameter>
            <name value="enableAnnotations"/>
            <valueBoolean value="true"/>
          </parameter>
          <parameter>
            <name value="enableLocators"/>
            <valueBoolean value="true"/>
          </parameter>
          <parameter>
            <name value="disableListDemotion"/>
            <valueBoolean value="true"/>
          </parameter>
          <parameter>
            <name value="disableListPromotion"/>
            <valueBoolean value="true"/>
          </parameter>
          <parameter>
            <name value="format"/>
            <valueString value="JSON"/>
          </parameter>
          <parameter>
            <name value="format"/>
            <valueString value="XML"/>
          </parameter>
          <parameter>
            <name value="analyzeDataRequirements"/>
            <valueBoolean value="false"/>
          </parameter>
          <parameter>
            <name value="collapseDataRequirements"/>
            <valueBoolean value="true"/>
          </parameter>
          <parameter>
            <name value="compatibilityLevel"/>
            <valueString value="1.5"/>
          </parameter>
          <parameter>
            <name value="enableCqlOnly"/>
            <valueBoolean value="false"/>
          </parameter>
          <parameter>
            <name value="errorLevel"/>
            <valueString value="Info"/>
          </parameter>
          <parameter>
            <name value="signatureLevel"/>
            <valueString value="Overloads"/>
          </parameter>
          <parameter>
            <name value="validateUnits"/>
            <valueBoolean value="true"/>
          </parameter>
          <parameter>
            <name value="verifyOnly"/>
            <valueBoolean value="false"/>
          </parameter>
        </Parameters>
      </contained>
      <extension url="http://hl7.org/fhir/StructureDefinition/cqf-cqlOptions">
        <valueReference>
          <reference value="#options"/>
        </valueReference>
      </extension>
      <url value="http://hl7.org/fhir/uv/cql/Library/CQLExample"/>
      <identifier>
        <system value="urn:ietf:rfc:3986"/>
        <value value="urn:oid:2.16.840.1.113883.4.642.40.37.28.2"/>
      </identifier>
      <version value="3.0.0-ballot"/>
      <name value="CQLExample"/>
      <title value="CQL Example"/>
      <status value="active"/>
      <experimental value="true"/>
      <type>
        <coding>
          <system value="http://terminology.hl7.org/CodeSystem/library-type"/>
          <code value="logic-library"/>
        </coding>
      </type>
      <date value="2026-08-14T03:31:27+10:00"/>
      <publisher value="HL7 International / Clinical Decision Support"/>
      <contact>
        <telecom>
          <system value="url"/>
          <value value="http://www.hl7.org/Special/committees/dss"/>
        </telecom>
      </contact>
      <description
                   value="Example CQL Library illustrating the CQL Profile (a Library with only text/cql content)"/>
      <jurisdiction>
        <coding>
          <system value="http://unstats.un.org/unsd/methods/m49/m49.htm"/>
          <code value="001"/>
          <display value="World"/>
        </coding>
      </jurisdiction>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Library FHIRHelpers"/>
        <resource
                  value="http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.2-ballot"/>
      </relatedArtifact>
      <relatedArtifact>
        <type value="depends-on"/>
        <display value="Code System LOINC"/>
        <resource value="http://loinc.org"/>
      </relatedArtifact>
      <parameter>
        <name value="GlucoseThreshold"/>
        <use value="in"/>
        <min value="0"/>
        <max value="1"/>
        <type value="Quantity"/>
      </parameter>
      <parameter>
        <name value="Patient"/>
        <use value="out"/>
        <min value="0"/>
        <max value="1"/>
        <type value="Patient"/>
      </parameter>
      <parameter>
        <name value="Blood Glucose Observations"/>
        <use value="out"/>
        <min value="0"/>
        <max value="*"/>
        <type value="Observation"/>
      </parameter>
      <parameter>
        <name value="Patient Interpreter Required (refined)"/>
        <use value="out"/>
        <min value="0"/>
        <max value="1"/>
        <type value="Patient"/>
      </parameter>
      <dataRequirement>
        <type value="Observation"/>
        <profile value="http://hl7.org/fhir/StructureDefinition/Observation"/>
        <codeFilter>
          <path value="code"/>
          <code>
            <system value="http://loinc.org"/>
            <code value="2339-0"/>
            <display value="Glucose Bld-mCnc"/>
          </code>
        </codeFilter>
      </dataRequirement>
      <content>
        <contentType value="text/cql"/>
        <data
              value=" "/>
      </content>
      <content>
        <contentType value="application/elm+json"/>
        <data
              value=" "/>
      </content>
    </Library>