cqframework / clinical_quality_language

Clinical Quality Language (CQL) is an HL7 specification for the expression of clinical knowledge that can be used within both the Clinical Decision Support (CDS) and Clinical Quality Measurement (CQM) domains. This repository contains complementary tooling in support of that specification.
https://confluence.hl7.org/display/CDS/Clinical+Quality+Language
Apache License 2.0
262 stars 121 forks source link

Revisit CQL Engine and Result APIs #1287

Open JPercival opened 10 months ago

JPercival commented 10 months ago

The CqlEngine APIs were created in an ad hoc fashion, as we were uncertain what an optimal API would look like. This has resulted in a few cases where the APIs are inconsistent, don't follow Java best practices, or suffer from code smells such as "telescoping constructor", or having many function overloads.

The engine still isn't API complete/final. Specifically, we don't have all the debugging APIs in place, so any current work on updating the APIs will be a step along the way.

Example of many overloads (potentially addressed by a params class): https://github.com/cqframework/clinical_quality_language/blob/master/Src/java/engine/src/main/java/org/opencds/cqf/cql/engine/execution/CqlEngine.java#L110-L176

Example of brittle API, which is not extensible as new retrieve options are added: https://github.com/cqframework/clinical_quality_language/blob/e3171ced48fd64257dc7bf1a8d5fe09639bd95db/Src/java/engine/src/main/java/org/opencds/cqf/cql/engine/retrieve/RetrieveProvider.java#L6

Example of improper hiding: https://github.com/cqframework/clinical_quality_language/blob/e3171ced48fd64257dc7bf1a8d5fe09639bd95db/Src/java/engine/src/main/java/org/opencds/cqf/cql/engine/execution/EvaluationResult.java#L9

This story is a place holder for a design task to revise these to be more useful/consistent.