Stream: cql
Topic: CQL Questions
Grahame Grieve (Jul 21 2017 at 20:49):
@Bryn Rhodes shouldn't there be a way to associate a namespace with a CQL library?
Grahame Grieve (Jul 22 2017 at 07:19):
another more simple question: I'm having trouble with parsing this:
Grahame Grieve (Jul 22 2017 at 07:19):
[Condition: severity in "Acute Severity"
Grahame Grieve (Jul 22 2017 at 07:21):
for which the Antlr grammar is :
Grahame Grieve (Jul 22 2017 at 07:22):
'[' namedTypeSpecifier (':' (codePath 'in')? terminology)? ']'
Grahame Grieve (Jul 22 2017 at 07:22):
why is it 'codepath' if it can't be a code path? What are you supposed to do if it is a code path?
Grahame Grieve (Jul 22 2017 at 07:23):
"AllergyIntolerance" : reaction.substance in "x"]
Grahame Grieve (Jul 22 2017 at 07:24):
the other thing I don't like about it - and this seems often true of cql - is that you have to parse ahead to know what the thing is.
Grahame Grieve (Jul 22 2017 at 10:35):
like how far you have to parse into a statement before you find out whether you parsing a retrieve or a query. That's just nuts....
Grahame Grieve (Jul 22 2017 at 10:39):
in fact, as far as I can tell, the only way to know, once you get to the ] of a retrieve, whether what follows is the alias is to read over it and look for 'where' or something. That's pretty unfriendly.
Grahame Grieve (Jul 22 2017 at 13:34):
as for this:
Grahame Grieve (Jul 22 2017 at 13:34):
not exists (Common."Results Present For Chlamydia Screening" S where S."issued" during Interval[Today() - 1 years, Today()])
Grahame Grieve (Jul 22 2017 at 13:34):
so far as I can figure, the only way to know that "S" is an alias is because it's not an operation or a reserved word
Grahame Grieve (Jul 22 2017 at 13:35):
I really miss a keyword like 'alias' to stabilise the syntax here
Grahame Grieve (Jul 22 2017 at 22:39):
there's a typo in one of the example CQL files...
Grahame Grieve (Jul 22 2017 at 22:39):
parameter MeasurementPeriod default Interval[DateTime(2013, 1, 1, 0, 0, 0, 0), DateTime(2014, 1, 1, 0, 0, 0, 0))
Grahame Grieve (Jul 22 2017 at 22:39):
should be
Grahame Grieve (Jul 22 2017 at 22:39):
parameter MeasurementPeriod default Interval[DateTime(2013, 1, 1, 0, 0, 0, 0), DateTime(2014, 1, 1, 0, 0, 0, 0)]
Grahame Grieve (Jul 22 2017 at 22:39):
ChlamydiaScreening_CQM.cql
Bryn Rhodes (Jul 24 2017 at 07:35):
@Grahame Grieve, on the namespace question, the name of the library is the namespace, in general, but you can also alias a referenced library using the called
clause of the include
declaration.
Grahame Grieve (Jul 24 2017 at 07:38):
I suspect global namespaces will be called for
Grahame Grieve (Jul 24 2017 at 07:39):
that typo appears in about 2/3 of the example CQL files packaged with the spec - closing an interval declaration with a ) instead of ]
Bryn Rhodes (Jul 24 2017 at 07:41):
On the typo, that's not a typo, Interval syntax in CQL indicates open/closed boundaries with (
for open and [
for closed.
Bryn Rhodes (Jul 24 2017 at 07:41):
So those are DateTime intervals beginning on the first day of the year and ending immediately before the first day of the next year.
Grahame Grieve (Jul 24 2017 at 07:43):
hm I missed that in the grammar
Bryn Rhodes (Jul 24 2017 at 07:44):
On the codePath question, yes, that should be a path in general, but we left it as an identifier for simplicity at this point. You can specify a codePath with full path syntax in the model info for the default codePath, but allowing it in the retrieve would be a good enhancement.
Bryn Rhodes (Jul 24 2017 at 07:45):
Submit a comment?
Grahame Grieve (Jul 24 2017 at 07:46):
well, it might connect as is with the split between parameter and path in FHIR.
Grahame Grieve (Jul 24 2017 at 07:47):
where would I submit a comment for CQL?
Bryn Rhodes (Jul 24 2017 at 07:48):
http://www.hl7.org/dstucomments/showdetail.cfm?dstuid=211
Bryn Rhodes (Jul 24 2017 at 07:50):
On the missing an "alias" keyword, we purposely omitted a query-start token (except for multi-source queries, which start with from
) because it cluttered the simplest case. We've received mixed feedback on that feature though, and I'd be happy to see a comment on that as well.
Grahame Grieve (Jul 24 2017 at 12:32):
this I think is a typo:
Grahame Grieve (Jul 24 2017 at 12:32):
with "InpatientEncounters" E such that ED."period" ends 1 hour or less before start of E."period"
Grahame Grieve (Jul 24 2017 at 12:32):
should be
Grahame Grieve (Jul 24 2017 at 12:32):
with "InpatientEncounters" E such that ED."period" ends 1 hours or less before start of E."period"
Bryn Rhodes (Jul 24 2017 at 14:11):
No, the language allows both plural and singular time durations.
Grahame Grieve (Jul 24 2017 at 15:35):
really? i just cannot find that in the antlr grammar
Grahame Grieve (Jul 24 2017 at 15:41):
do you have to get that right with the value? 1 hour or 2 hours? or is 1 hours or 2 hour acceptable?
Bryn Rhodes (Jul 24 2017 at 17:30):
It's in the quantity rule, which is in the imported fhirpath.g4. unit can be a dateTimePrecision, or a pluralDateTimePrecision, or a UCUM string.
Bryn Rhodes (Jul 24 2017 at 17:31):
And no, it doesn't have to match with the value, 1 hours
and 2 hour
are both acceptable. It's a flexibility to enable authors to write the most natural phrasing, but doesn't have any impact on the semantics.
Tien Thai (Aug 19 2021 at 17:19):
Is there a way to check if a given RxNORM is part of a Value Set in CQL? Basically, I would like to define a function that takes an RxNORM as a parameter and check if this RxNORM code is part of a value set (e.g. "Opioid Medications")? Thanks very much for your help.
Michael Riley (Aug 19 2021 at 18:24):
Why do you want to do this in CQL? You could use a terminology server like the Value Set Authority Center (VSAC) https://vsac.nlm.nih.gov/ which has an api to expand valuesets into collections of codes.
Tien Thai (Aug 19 2021 at 18:50):
Michael,
Thank you very much for your response. Can you please point me to such API as I could not find any API in the VSAC site?
The reason for this check is that we want to be able to tell if the given RxNORM is part of our specific value set and if it is return the name of the medication back to caller.
Bryn Rhodes (Aug 19 2021 at 18:56):
CQL has terminology declarations to allow you to do this in CQL, but engage a terminology server to perform the actual check when the CQL is evaluated. See the Terminology section of the author's guide for examples and discussion.
Michael Riley (Aug 20 2021 at 17:34):
Tien, sorry that front page link isn't very helpful is it? This is a more in depth documentation on how to use the FHIR Terminology Service that VSAC hosts. You have to sign up and get an api key, but you can expand valuesets there with an HTTP request, no CQL required. https://www.nlm.nih.gov/vsac/support/usingvsac/vsacfhirapi.html. You can even use the $validate-code operation they provide to check if a specific code is in the valueset on a request, instead of parsing yourself.
Last updated: Apr 12 2022 at 19:14 UTC