FHIR Chat · Query Evaluation · cql

Stream: cql

Topic: Query Evaluation


view this post on Zulip Matthew Dugal (Apr 04 2018 at 14:18):

Hi,
I am trying to understand the vision of query evaluation as laid out in the CQL Specification, specifically 5.3.4 Implementing Query Evaluation. Hopefully understanding this vision will help me understand the most complex aspects of the language.

Using the following example:

define "Encounters with overlapping Warfarin and Parenteral Therapies":
    from "Encounters" E,
         "Warfarin Therapy" W,
         "Parenteral Therapy" P

Implementation step 1:
"For each query source beyond the first, use a Times operation to produce a result with a tuple for each combination, named the same as the alias used to introduce the source in the query."

What does this mean? And what would an example tuple look like for one of these combinations?

Does this mean step 1 will result in a list of tuples that contains every possible combination of E, W, and P? As in ^2, ^3, or more?

Is it expected to look something like this?

Tuple: {
    Name: 'RetrieveCombination_1',
    Values: [
                Tuple: { DataElement: Entry1, Alias: "E" },
                Tuple: { DataElement: Entry25, Alias: "W" },
                Tuple: { DataElement: Entry31, Alias: "P" }
            ]
}, ...

view this post on Zulip Christopher Schuler (Apr 05 2018 at 19:07):

Hi @Matthew Dugal . Your understanding of multi-source queries is correct, but your expected result is incorrect. I think the easiest way to clear up your understanding is to run some example code.
Here are the steps to do that:
1. Navigate to http://cql-runner.dataphoria.org/
2. Click the "Config" button in the menu bar, input Patient-12214 in the Patient Id field, and press OK
3. Run the following code:

library MultiSourceQueryExample version '1.0'

using FHIR version '3.0.0'

context Patient

define Conditions:
    [Condition]

define Procedures:
    [Procedure]

define "Multisource Query":
    from Conditions C,
         Procedures P

4. The results will be displayed in the output window. The results will consist of the Patient resource and the resources from the expressions. Note that there are 5 Condition resources and 6 Procedure resources for the patient. The outcome of the multi-source query expression is a list of tuples with the 30 possible combinations.

Hopefully that helps.

view this post on Zulip Matthew Dugal (Apr 06 2018 at 03:05):

This is actually very helpful. Thank you.

It leads me into the part that I've been working through with some difficulty. And if you or someone could help, that would be much appreciated. For the slightly modified version of your query, what would the return values of "overlaps" look like and how would the "and" statement operate on them?

define "Multisource Query":
    from Conditions C,
         Procedures P

    with "Encounters" E
      such that E.relevantPeriod overlaps C.prevalencePeriod
            and E.relevantPeriod overlaps P.relevantPeriod

view this post on Zulip Matthew Dugal (Apr 06 2018 at 14:17):

I think the problem I am having understanding this is that it feels so much like the what is described on page 2-2 of "Implementing Computation of Specific Occurrences". Am I wrong in thinking the only difference is the locality of combinations?

view this post on Zulip Bryn Rhodes (Apr 22 2018 at 18:53):

Apologies for the very late response here, can you tell me what you mean by "locality of combinations"? I'm not sure I understand that part.


Last updated: Apr 12 2022 at 19:14 UTC