Open EvanMachusak opened 1 year ago
IMO, the implementation makes sense -- if a list is passed to ToList
, it should return the list as-is rather than increase the dimensions of the list. Which means that my recommendation would be to update the specification. I'd consider this a "technical correction". @brynrhodes - what say you?
I can see it either way.
I don't mind whether this is an implementation change or a spec change.
We could tack this into the ELM spec:
When applied to a value that is already a List, this expression returns the existing List.
According to the ELM spec,
https://cql.hl7.org/04-logicalspecification.html#tolist
However: https://github.com/cqframework/clinical_quality_language/blob/d10c4ef801a8e160510b2a868c044dea5bdb85c1/Src/java/engine/src/main/java/org/opencds/cqf/cql/engine/elm/execution/ToListEvaluator.java
When operand is already a list, the ruler simply returns the operand. That logic is on line 12.
This is important as the cql-to-elm translator assumes this behavior. Consider this CQL:
The translator is generating this ELM for the codes property of the Retrieve:
Because the ruler ignores the ToList for expressions that are already lists, it codes would end up being expressed as a
List<Code>
.If you were to follow the letter of the ELM spec, codes ends up expressed as a
List<List<Code>>
.This confounds engines that expect the terminology element of the retrieve statement to be a
List<Code
> (or a value set, which is implicitly convertible to aList<Code>
).