Skip to content

Update CQL to 5.8.0 and lazy FHIR-to-CQL conversion - #1151

Merged
c-schuler merged 2 commits into
mainfrom
cql-5.8.0
Nov 26, 2026
Merged

c-schuler merged 2 commits into
mainfrom
cql-5.8.0

Conversation

@c-schuler

Copy link
Copy Markdown
Contributor

Summary

Adds two opt-in performance levers to the CQL retrieve path and updates the engine to the released CQL 5.8.0. Both levers are off by default, so existing behavior is unchanged unless a caller enables them.

Lazy FHIR-to-CQL conversion

Resources returned from a retrieve were always eagerly converted to CQL values - every element materialized up front, even fields the CQL never reads. This restores the engine 4.6.0 "convert only what you read" behavior as an opt-in via RetrieveSettings.conversionMode:

  • AUTO (default) - lazy only when the repository is known to return value-stable resources, which today means an InMemoryFhirRepository (bundle-backed, read-only during evaluation); eager otherwise.
  • EAGER - always convert every element up front (safe for any repository).
  • LAZY - always convert lazily (only for a repository known to return stable resources).

RepositoryRetrieveProvider resolves the mode once and passes the flag through the new toCqlValue(resource, expandPrimitives, lazy) overload landed in CQL 5.8.0 (cqframework/clinical_quality_language#1954). Lazy conversion reads resource fields at access time, so AUTO deliberately scopes it to the in-memory repository rather than enabling it broadly.

Evaluated-resources collection toggle

Adds CqlEngineOptions.isEvaluatedResourcesCollectionDisabled (off by default), wiring the engine's DisableEvaluatedResourcesCollection option (cqframework/clinical_quality_language#1939). This is a memory lever — the engine otherwise retains every resource touched during a run. Measure evaluation populates MeasureReport.evaluatedResource from the per-expression evaluated resources, so this must only be enabled once verified not to empty that output (covered by EvaluatedResourcesCollectionToggleTest).

CQL 5.8.0 bump + data-requirements count updates

Updates the CQL engine dependency to the released 5.8.0. That release includes cqframework/clinical_quality_language#1958 (collapse duplicate data requirements emitted by function inlining), which deduplicates module-definition dataRequirement output. Several golden-count assertions were updated to the deduped values — these are reductions from removed exact duplicates, not behavioral changes:

  • Analysis layer (PlanDefinition / Library / Questionnaire): R4 19→12, R5 19→13, DSTU3 29→22.
  • Measure layer (DataRequirementsTest): resource-basis 28/29→16, boolean-basis 3→2.

The matching parameterDef / relatedArtifact counts are unchanged, so period handling and other semantics are intact - only duplicate dataRequirement entries were collapsed.

Testing

  • New ConversionModeParityTest asserts EAGER vs LAZY produce identical population counts, measure scores, SDE values, and evaluated-resource provenance.
  • New EvaluatedResourcesCollectionToggleTest covers the toggle's effect on MeasureReport.evaluatedResource.
  • :cqf-fhir-cql:test and :cqf-fhir-cr:test green against released 5.8.0; spotless clean.

🤖 Generated with Claude Code

@c-schuler c-schuler self-assigned this Nov 25, 2026
@c-schuler c-schuler added the enhancement New feature or request label Nov 25, 2026
@github-actions

Copy link
Copy Markdown

Formatting check succeeded!

@sonarqubecloud

Copy link
Copy Markdown

@c-schuler
c-schuler requested a review from antvaset November 25, 2026 23:52
@c-schuler
c-schuler merged commit c6c76c7 into main Nov 26, 2026
8 of 9 checks passed
@c-schuler
c-schuler deleted the cql-5.8.0 branch November 26, 2026 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants