FHIR Chat · CQL Execution · cql

Stream: cql

Topic: CQL Execution


view this post on Zulip Mohammad Afaq Khan (Oct 19 2019 at 11:01):

Does CQL execute similar to SAS and SQL where it will go down records and execute code against every record? If I have a exists([retrieve] query) will the CQL run the exists for every record from the retrieve & query and only return records that meet the query's criteria or will it just return one Boolean value?

view this post on Zulip Bryn Rhodes (Oct 19 2019 at 11:10):

The result of exists([retrieve] query) will be a single boolean value, but it the exists will evaluate all the results of the retrieve. A pipelined execution could stop an exists as soon as it saw one record, but that would be an optimization of the engine.

view this post on Zulip Mohammad Afaq Khan (Oct 19 2019 at 12:06):

Ok thank you for the explanation. I know in some languages each record is evaluated against the code but thats not the case in CQL.

view this post on Zulip Chris Moesel (Oct 21 2019 at 12:48):

Right. If you see something like exists that takes a List as its argument, the general expectation is that the function operates on the entire list. How it does so is up to the implementor, however. I think the only place where you're definitely evaluating records one at a time is in the body of the query itself (i.e., such that..., where..., return ..., etc).

view this post on Zulip Mohammad Afaq Khan (Oct 21 2019 at 15:06):

If you use the exists() on a List it will still just return true or false, correct? It will operate on the entire List but if it finds any elements it returns true. Let's say the first object in the list is there exists() will return true?

view this post on Zulip Mohammad Afaq Khan (Oct 21 2019 at 15:11):

(deleted)

view this post on Zulip Mohammad Afaq Khan (Oct 21 2019 at 15:14):

The author documentation describes it as the opposite of an empty, so if the collection contains an object or record it should return true

view this post on Zulip Mohammad Afaq Khan (Oct 21 2019 at 15:25):

I think I finally understand even if it contains a null it returns true as long as it isn't empty?

view this post on Zulip Chris Moesel (Oct 21 2019 at 15:56):

I think you've got it mostly right except that last bit. According to https://cql.hl7.org/09-b-cqlreference.html#exists,

The exists operator returns true if the list contains any non-null elements.

So if you had a list with only null, then exists would return false. IIRC, this wasn't always the case, but recent versions of CQL clarified it to be so.

view this post on Zulip Alexander Kiel (Oct 21 2019 at 16:53):

I think you've got it mostly right except that last bit. According to https://cql.hl7.org/09-b-cqlreference.html#exists,

The exists operator returns true if the list contains any non-null elements.

So if you had a list with only null, then exists would return false. IIRC, this wasn't always the case, but recent versions of CQL clarified it to be so.

Oh really @Chris Moesel . Please have a look at http://www.hl7.org/dstucomments/showdetail_comment.cfm?commentid=1875 and https://github.com/HL7/cql/issues/52.

view this post on Zulip Chris Moesel (Oct 21 2019 at 17:33):

Hi @Alexander Kiel -- TBH, I had to look it up myself because I couldn't remember which way it went. But... it does appear that what I said above is true. Looking at CQL version history, this was changed in CQL 1.3.0 in response to this comment: http://www.hl7.org/dstucomments/showdetail_comment.cfm?commentid=1435

view this post on Zulip Jerry Goodnough (Oct 21 2019 at 20:08):

Is there any provision in CQL for associating a library with a canonical URL for that library? I

view this post on Zulip Bryn Rhodes (Oct 21 2019 at 20:51):

The Mother Infant Measure example shows how to do this

view this post on Zulip Bryn Rhodes (Oct 21 2019 at 20:52):

Basically, we use the "system" element of the versioned identifier of the library.

view this post on Zulip Alexander Kiel (Oct 22 2019 at 12:54):

@Chris Moesel Thanks for the clarification.

view this post on Zulip Jerry Goodnough (Oct 22 2019 at 17:30):

@Bryn Rhodes Thanks... I see it in the elm.xml, but there does not appear to be an equivalent in the CQL representation. Am I blind and missing something?

view this post on Zulip Bryn Rhodes (Oct 22 2019 at 17:41):

You're right Jerry, it's not in the CQL, since it's actually defined outside the context of any particular library. The use in ELM is only a reference and needs to be provided external to the CQL library. The plan is to have it be a parameter to the translator, but that feature isn't yet part of the translator.

view this post on Zulip Jerry Goodnough (Oct 22 2019 at 23:06):

So does it make sense to extend the syntax of the definition to include and optional custodian clause that is followed by a URL?

view this post on Zulip Bryn Rhodes (Oct 23 2019 at 04:13):

Well, the reason we didn't is because it's not defined per library, it's above the libraries, so we didn't want the possibility of the same namespace having different URLs in different libraries.

view this post on Zulip Jerry Goodnough (Oct 23 2019 at 15:42):

@Bryn Rhodes Thanks - Is there a clear place besides here that I should note inconsistencies in the 1.4.1 spec?

view this post on Zulip Bryn Rhodes (Oct 23 2019 at 15:43):

Yes, you can submit STU comments to the specification here: http://www.hl7.org/dstucomments/showdetail.cfm?dstuid=264

view this post on Zulip Bryn Rhodes (Oct 23 2019 at 15:44):

(Which is linked through the "Propose a change" link in the footer of the spec, but not directly, you have to click through the View STU).

view this post on Zulip Saoji Adhe (Oct 24 2019 at 11:28):

Hi ,
i want to test cqf-ruler-0.1.13-SNAPSHOT.jar with hapi-fhir-3.8 , to test $evaluate-measure
but it's not working with example given by hspc in there documentation
anybody know about where i will get example related to $evaluate-measure, $apply, cds-hooks etc...
Thank you in advance.

view this post on Zulip Mohammad Afaq Khan (Oct 29 2019 at 17:39):

How can someone access the same patient for a procedure in QDM? I know FHIR has procedure.subject but what about QDM?

view this post on Zulip Bryn Rhodes (Oct 29 2019 at 17:43):

In the Patient context, all the data accessed is related to the current patient in context.

view this post on Zulip Mohammad Afaq Khan (Oct 30 2019 at 12:12):

Thank you @Bryn Rhodes

view this post on Zulip Mohammad Afaq Khan (Oct 30 2019 at 12:13):

So in FHIR the procedure.subject helps to further reference/access the Patient Identifier?

view this post on Zulip Bryn Rhodes (Nov 01 2019 at 14:44):

In the patient context, the procedure.subject would be expected to match the current patient context, yes.


Last updated: Apr 12 2022 at 19:14 UTC