Clinical Quality Language (CQL) is a standardized language designed to express clinical logic in a way that is both human-readable and computable. It plays a critical role in defining electronic clinical quality measures (eCQMs) and clinical decision support rules, ensuring consistency and interoperability across healthcare systems. CQL enables clinicians and developers to articulate complex clinical criteria using a structured, yet accessible format. By providing a common framework for defining clinical logic, CQL helps improve efficiency in healthcare decision-making while reducing variability in interpretation. It integrates seamlessly with health IT infrastructures, supporting the development of high-quality, evidence-based clinical guidelines that enhance patient care.
CQL execution engines serve as the mechanism for translating CQL logic into actionable insights by interpreting and executing CQL expressions within electronic health record (EHR) systems and other healthcare applications. These engines parse and process CQL statements to retrieve relevant patient data, evaluate clinical conditions, and generate results that support clinical decision-making. They ensure scalability and efficiency in healthcare workflows, facilitating real-time assessment of patient eligibility for treatments, adherence to clinical protocols, and compliance with regulatory guidelines. By bridging the gap between structured clinical definitions and practical application, CQL execution engines empower healthcare providers with accurate, automated decision support, ultimately improving the precision and effectiveness of clinical interventions. Different execution engines exist with variations in performance, compatibility, and supported versions of CQL. Here is a popular CQL engine implementation.
CQL execution based on FHIRPath is unable to process assertions within the FHIR DocumentReference resource, limiting its ability to handle unstructured text effectively. To overcome this, the LLM-in-the-Loop (LitL) pattern incorporates large language models (LLMs) that interpret and process unstructured text before passing results to the CQL execution engine for structured decision-making. As part of the LitL implementation, we added a hook pattern into the above CQL execution engine that gets triggered when a DocumentReference is encountered.
The GitHub repository below is a fork of the CQL Execution Framework, which provides a TypeScript/JavaScript library for executing Clinical Quality Language (CQL) artifacts expressed as JSON ELM. The fork introduces an experimental feature supporting LLM-based assertion checking on DocumentReference. The framework enables execution of CQL logic within different data models, such as QDM and FHIR, but does not provide direct support for data models or terminology services. The library implements various features from CQL 1.4 and 1.5 but has some limitations, such as incomplete support for specific datatypes and functions. It includes documentation on project setup, execution steps, unit testing, and development workflows, helping users integrate and test CQL logic efficiently.