Stream: cql
Topic: Minimalist CQL
Richard Stanley (Jan 26 2021 at 19:28):
Hi folks. I'm new to this and trying to understand errors in a simple CQL statement (for the CQL-ELM-translator microservice). The CQL with inline errors is:
library DEMOG version '0.0.1'
using FHIR version '4.0.1'
context Patient
define “Initial Population”:
Patient.gender = "female" ("Could not resolve identifier female in the current library.")
define "Denominator":
"Initial Population" ("Could not resolve identifier Initial Population in the current library.")
Corey Sanders (Jan 26 2021 at 19:35):
Double quotes are for identifiers and single quotes represent string literals, so your "female" should be 'female'. You've got some odd double quotes around "Initial Population" in the define that you will need to fix.
Richard Stanley (Jan 26 2021 at 19:37):
Lovely, thanks! One error remaining: "Could not resolve library name FHIRHelpers." Is FHIRHelpers required for gender?
Corey Sanders (Jan 26 2021 at 19:39):
You can add include FHIRHelpers version '4.0.1'
. Use of FHIRHelpers is implicit in the translator, based on the modelinfo file, when you are dealing with FHIR. So, indirectly, yes. The fact that you are referencing Patient.gender causes the library to need to be included.
Richard Stanley (Jan 26 2021 at 19:42):
Awesome, thanks. Is there a way around FHIRHelpers? Not that I would do that in practice, but for info.
Corey Sanders (Jan 26 2021 at 19:44):
The only way I know of would be to provide your own modelinfo file to the translator for FHIR where you don't map anything to the helper functions. To the best of my knowledge, the CQL Translator service doesn't support translation with custom modelinfos right now, so you would have to roll your own or use the translator directly via the Java interface.
Richard Stanley (Jan 26 2021 at 19:45):
Ok, thanks. I appreciate the help and explanation.
Alexander Kiel (Feb 01 2021 at 10:34):
The reason why FHIRHelpers is needed here is, that Patient.gender date type is FHIR.code and 'female' is a String. So a ToString function from FHIRHelpers is needed here.
Vasyl Herman (Feb 20 2021 at 15:59):
@Richard Stanley
Hi, Is there some tutorial on how to master cql?
Thanks!
Richard Stanley (Feb 22 2021 at 16:10):
@Vasyl Herman There isn't really but starting with an existing IG is very helpful in learning. There's are a few basic examples, and then I use the main CQL authoring guide to find answers to my questions. I think the simplest 'hello, world' would help everyone but I haven't created it.
Bryn Rhodes (Feb 22 2021 at 18:05):
There is a Developer's Introduction to CQL. Feel free to provide comments/suggestions for improvement.
Bryn Rhodes (Feb 22 2021 at 18:06):
Of note, there is also a CQL Tutorial from HL7 coming up at the end of March.
Last updated: Apr 12 2022 at 19:14 UTC