note that there is a let statement that first introduces dosage and then timing that uses dosage. This is useful and legal, but our current code batches up all lets in the same scope, and then adds them to the scope at the same time, which means that referring to a previous let in the same scope does not work.
I have fixed this in SingleSourceQuery by having each let introduce a new scope, with the subsequent lets defined in nested scopes. This is actually the formal way this is done in ML-style languages, so we might leave it at that.
In CMS AntidepressantMedicationManagementFHIR.cql we find the following (correct) snippet of CQL:
note that there is a
let
statement that first introducesdosage
and thentiming
that usesdosage
. This is useful and legal, but our current code batches up all lets in the same scope, and then adds them to the scope at the same time, which means that referring to a previous let in the same scope does not work.I have fixed this in
SingleSourceQuery
by having eachlet
introduce a new scope, with the subsequent lets defined in nested scopes. This is actually the formal way this is done in ML-style languages, so we might leave it at that.