Skip to content

Expose API method to CqlEngine to allow callers to resolve the CQL-defined default value of a named parameter#1674

Merged
JPercival merged 2 commits intomasterfrom
ld-20260209-enhance-functions-api
Feb 10, 2026
Merged

Expose API method to CqlEngine to allow callers to resolve the CQL-defined default value of a named parameter#1674
JPercival merged 2 commits intomasterfrom
ld-20260209-enhance-functions-api

Conversation

@lukedegruchy
Copy link
Copy Markdown
Contributor

Summary

This MR adds a new public API method CqlEngine.resolveParameterDefault() that allows callers to resolve the CQL-defined default value of a named parameter without manipulating engine internals.

  1. New CqlEngine.resolveParameterDefault(VersionedIdentifier, String, ZonedDateTime?): Any? method that resolves a library, finds the named ParameterDef, and evaluates its default expression using the standard engine lifecycle (init / beginEvaluation / endEvaluation / exitLibrary), with proper error handling via processException(). Returns null if the parameter has no default.
  2. No changes to State.kt -- the implementation reuses existing state lifecycle methods rather than introducing new low-level stack manipulation methods, consistent with the architecture established in commits 23f71e39 (evaluate API refactor) and 2803f628 (class name simplification).
  3. Comprehensive test coverage via ResolveParameterDefaultTest (8 tests) exercising the measurement-period interval scenario, parameters without defaults, integer defaults, Now() evaluation with custom evaluationDateTime, error cases, and state isolation between resolveParameterDefault() and evaluate() calls.

Code Review Suggestions

  • Verify that calling state.init(library) (which asserts stack.isEmpty()) is safe in all realistic call sequences from clinical-reasoning. If clinical-reasoning ever calls resolveParameterDefault while the engine state is not clean (e.g., mid-evaluation), the assertion will fail. Confirm the upstream caller (MeasureProcessorTimeUtils) always calls this before any evaluate().
  • The method uses environment.resolveLibrary(libraryIdentifier) which bypasses the multi-library loadAndValidate() path and its structured error collection. Confirm this is acceptable -- the assumption is the library is already compiled/loaded by the time a caller wants to inspect parameter defaults.
  • The evaluationVisitor property is @Deprecated. This method encapsulates its usage, but confirm no linting or Sonar rules will flag the internal usage (the clinical-reasoning side will drop its @SuppressWarnings once migrated).
  • Check whether state.endEvaluation() in the finally block can throw if beginEvaluation() was not reached (e.g., if state.init(library) throws due to a failed assertion). If so, the cleanup in finally could mask the original exception.

…of a named parameter in a library. To be used by client projects that current use low-level CQL APIs to accomplish the same objective.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 9, 2026

Formatting check succeeded!

initializeEvalTime(evaluationDateTime)
state.init(library)
state.beginEvaluation()
try {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick:
return try {
....
whatever
}
catch
{
....
null
}

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 10, 2026

Codecov Report

❌ Patch coverage is 60.86957% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.91%. Comparing base (a14a3d9) to head (6a43c9a).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
.../org/opencds/cqf/cql/engine/execution/CqlEngine.kt 60.86% 8 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1674      +/-   ##
============================================
+ Coverage     65.89%   65.91%   +0.01%     
  Complexity     1645     1645              
============================================
  Files           478      478              
  Lines         27641    27664      +23     
  Branches       5497     5499       +2     
============================================
+ Hits          18215    18235      +20     
- Misses         7098     7104       +6     
+ Partials       2328     2325       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
66.7% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@JPercival JPercival merged commit d0643c5 into master Feb 10, 2026
8 of 9 checks passed
@JPercival JPercival deleted the ld-20260209-enhance-functions-api branch February 10, 2026 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants