Stream: cql
Topic: CQL Feedback
Matt Berg (Feb 14 2022 at 12:26):
Hi @Bryn Rhodes some feedback from our team on issues when using CQL. cc @Francis Otieno and Maimoona.
- No direct mapping of CQL/FHIR types. We had to use myVal: decimal {value: 3.0} instead of myVal: 3.0. Sample CQL
- FHIR inner static classes can not be initialized so we had to add a class to let CQL handle it explicitly. Sample CQL. We have added an extension to R4FHIRModelResolver to accomplish this.
- CQL Runner is very helpful but a very old version of CQL and does not recognize Now(), and QuestionnaireResponse. The CQL here does not work on this IDE but works on code. I am not sure if Bryn can address this one.
- Related to point # 1 . Since FHIR Types are not recognized I had to us
define "G6PDTemp": decimal {value: "G6PDObs".value} // G6PDObs=DecimalType
define "G6PDValue": ToString("G6PDTemp")
instead of
define "G6PDValue": ToString("G6PDObs".value)
// OR
define "G6PDValue": ToString("G6PDObs")
Matt Berg (Feb 14 2022 at 12:26):
Matt Berg (Feb 14 2022 at 12:27):
Bryn Rhodes (Feb 16 2022 at 20:40):
Apologies for the delay, thank you so much for the feedback.
- Regarding CQL/FHIR Types, there is a FHIRHelpers library that defines conversions between FHIR and CQL types, and those are registered with the FHIR ModelInfo as implicit conversions. It works well for converting CQL primitives to FHIR primitives when they are both referenced in expressions, but it doesn't work when "assigning" a value as in the selectors there. We could potentially define implicit conversions the other direction to support that use case, I'll take a look at that, if you wouldn't mind submitting a tracker to the CQL-to-ELM translator to remind me?
- There is documentation on FHIRHelpers available here: https://fhir.org/guides/cqf/common/#fhir-helpers
- I've used this pattern quite a bit as well, it would be good to consolidate those to a common library, something like a next version of this: https://fhir.org/guides/cqf/common/Library-FHIRCommon.html, feel free to submit issues to that github repository proposing common functions, and take a look at the ones that are there to see if any match what you are needing
- CQL Runner is great for a quick start, but yeah, it's an older version of the CQL stack and we haven't gotten around to updating it. There is a devcontainer here that builds a VSCode container with the CQL VSCode extension installed so you can author in that container with validation and execution.
- To work around the lack of implicit conversions in selectors, I've tended to define helper functions, like:
define function FHIRDecimal(value Decimal): FHIR.decimal { value: System.Decimal }
Last updated: Apr 12 2022 at 19:14 UTC