Skip to main content

2 posts tagged with "Performance"

View All Tags

Translating Clinical Quality Language to SQL: How CQL Compiles to Relational Queries

· 7 min read

When clinical informaticists and healthcare data engineers talk about CQL to SQL, they are addressing an architectural divide in health IT: computable clinical knowledge—such as CMS electronic Clinical Quality Measures (eCQMs) and decision support guidelines—is authored in HL7 Clinical Quality Language (CQL), but population analytics, quality reporting, and observational research run on relational data warehouses and SQL query engines.

(Note: "CQL" is also the acronym for Cassandra Query Language in Apache Cassandra database migrations. This article is about the HL7 healthcare standard: compiling Clinical Quality Language into relational SQL queries).

Traditionally, executing CQL has required an imperative, row-by-row Java engine (cqframework and HAPI FHIR). While that architecture works for transactional decision support on an individual patient in an EHR, evaluating thousands or millions of patients for quality reporting in a JVM quickly runs into memory and throughput walls.

Here is how compiling CQL directly to relational SQL works in fhir4ds, how the translator handles complex clinical constructs (temporal intervals, polymorphic choice fields, and terminology resolution), and the performance characteristics of running CQL as set-based relational algebra.

Where Clinical Measure Time Actually Goes: eCQM Scaling to 5,000 Patients

· 8 min read

A clinical quality measure is a good stress test for a query engine. You take an HL7 CQL library — hundreds of definitions, value sets, temporal intervals, polymorphic FHIR fields — compile it to one population query, and run it over an entire patient cohort at once. Nothing is cached between measures, and nothing is pre-flattened: the engine reads raw FHIR JSON.

We wanted a number for "how does this behave as the cohort grows", and more importantly where the time goes. So we built a ladder — the same measures at 100, 1,000 and 5,000 patients — with a query profile captured at every rung, run identically on both DuckDB engine lines.

The short version of what the profiles say: a measure's cost is set by its access pattern — which resource types it touches, how many times, and where the per-row predicates run — not by the size of its CQL or the number of terminology calls it makes. And you cannot see any of that by reading the SQL; you have to profile the operators.