FHIR Chat · Query with at most one per day · cql

Stream: cql

Topic: Query with at most one per day


view this post on Zulip Matthew Dugal (Jun 06 2018 at 16:56):

I am having difficulty formulating a query. I need to select a list of data elements but at most one per day (preferably the last one to happen on that date). Any suggestions on how to write this query?

view this post on Zulip Matthew Dugal (Jun 07 2018 at 14:36):

I was never able to find any sort of grouping operator. So I came up with this.

[All Event] except [Events with another event on same day] union ([Events with another event on same day] except [Events with another event on same day that have an event starting after])

So it's all events removing everything that has same day stuff. Then adding back the all of the events that have another on the same day except for the ones that have another later in the day (leaving only the last event of the day).

view this post on Zulip Matthew Dugal (Jun 07 2018 at 14:40):

I don't see a lot of activity or interest here, but I thought I should post what I was able to find anyway. This is an interesting language.

view this post on Zulip Bryn Rhodes (Jun 07 2018 at 19:49):

Sorry, this fell off my radar and I forgot to get back to it. :(

view this post on Zulip Bryn Rhodes (Jun 07 2018 at 19:50):

Event E return { day: E.day, lastEvent: Last(Event I where I.day = E.day sort by date) }

view this post on Zulip Matthew Dugal (Jun 08 2018 at 15:48):

Hey. Thank you!


Last updated: Apr 12 2022 at 19:14 UTC