FHIR Chat · CQL grouping equivalent · implementers

Stream: implementers

Topic: CQL grouping equivalent


view this post on Zulip Erik Smith (Feb 08 2022 at 16:21):

I want to express a query to find the claim provider with the most frequent visits for a member in CQL, not specific to FHIR. This would be straightforward if CQL had a SQL GROUP BY. It's unclear how I can accomplish this with aggregate. Any Ideas?

view this post on Zulip Bryn Rhodes (Feb 08 2022 at 17:15):

We didn't add a group by or having clause, but both of those are just short-hands. The long-hand for count of observations by category, for example, is:

define ObservationCountsByCategory:
  [Observation] O
    return {
      category: O.category,
      numberOfObservations: Count([Observation] InnerO where InnerO.category ~ O.category)
    }

view this post on Zulip Erik Smith (Feb 08 2022 at 19:26):

This is nice. I was thinking that you would want the outer source O need to be distinct observations by category , or just a a distinct category list, for the counts to work, but maybe that is optional since the result of this query will be distinct?

view this post on Zulip Bryn Rhodes (Feb 08 2022 at 19:51):

Right, the result will be distinct.


Last updated: Apr 12 2022 at 19:14 UTC