FHIR Chat · Testing CQL · cql

Stream: cql

Topic: Testing CQL


view this post on Zulip Tien Thai (Nov 13 2019 at 15:20):

My CQL file was successfully compiled by the Measure Authoring Tool (MAT) but the MAT produced a "System error. Unable to process information" error when packaging the eCQM. I have also checked this CQL file with the CQL-To_ELM translator and the translation completed successfully. As a result of this error, I will not be able to test my eCQM using the Bonnie tool. Is there any other tool that I can use to test my eCQM? Thank you very much.

view this post on Zulip Chris Moesel (Nov 13 2019 at 15:24):

Assuming that your eCQM is using the QDM data model (and not FHIR), I'm not aware of any other tools specifically for testing QDM-based eCQMs (especially if you want them also to consider the HQMF). I think @Bryn Rhodes has a Java CQL engine that supports the QDM data model, but I suspect it would take some work to get it to support eCQM testing in a user-friendly way.

I'd suggest reaching out to the MAT/Bonnie team for help. I think it's actually the same team behind both tools now, so hopefully they can help you!

view this post on Zulip Tien Thai (Nov 13 2019 at 15:30):

Thanks very much, Chris.

view this post on Zulip Mohammad Afaq Khan (Nov 20 2019 at 17:54):

We can use flatten to have duplicates added to a list but is there a way except doesnt remove all occurrences of an object in the first list?

view this post on Zulip Chris Moesel (Nov 20 2019 at 18:51):

I'm not sure I understand your question, @Mohammad Afaq Khan. Are you saying that List{1, 2, 2, 3, 4} except {2, 3} currently returns List{1, 4} but you want it to return List{1, 2, 4} (removing only the first 2)?

view this post on Zulip Mohammad Afaq Khan (Nov 20 2019 at 18:51):

Yes, that is my desired outcome

view this post on Zulip Mohammad Afaq Khan (Nov 20 2019 at 18:52):

It's very hard to do because we cant loop and set counters up when we define something as an integer we cant update its value

view this post on Zulip Mohammad Afaq Khan (Nov 20 2019 at 18:59):

I want to remove the number of occurrences of "2" present in the second list from the first list so if the second list had 2 instances of "2" the returned list after the except should have no "2"s in it

view this post on Zulip Chris Moesel (Nov 20 2019 at 19:11):

You're right. That's a tough one! Although it may be possible, no simple solutions come to mind... I'll think about it some more though.

view this post on Zulip Mohammad Afaq Khan (Nov 20 2019 at 19:15):

Ok thanks @Chris Moesel appreciate the help

view this post on Zulip Mohammad Afaq Khan (Nov 20 2019 at 20:35):

Btw IndexOf only returns the first instance of the second argument

view this post on Zulip Chris Moesel (Nov 21 2019 at 00:26):

I thought I had a nice solution, but then I remembered that CQL doesn't support recursion (when it wouldn't compile). Anyway, in case it sparks any ideas for you:

library Test version '1.0'

context Patient

// NOTE: This does NOT compile because of recursive reference to strictExcept!
define function strictExcept(sourceList List<Integer>, exceptList List<Integer>):
  if Count(exceptList) > 0 then
    strictExcept(removeFirstOccurrence(sourceList, First(exceptList)), Tail(exceptList))
  else
    sourceList

define function removeFirstOccurrence(list List<Integer>, item Integer):
  if item in list then
    flatten List{Take(list, IndexOf(list, item)), Skip(list, IndexOf(list, item) + 1)}
  else
    list

define strictExceptTest: strictExcept(List{1,2,2,2,3,4}, List{2,3})

view this post on Zulip Chris Moesel (Nov 21 2019 at 00:30):

Whoops -- copied in the wrong one up there at first. Now it's fixed. Well, still broken -- but broken in the expected way. Again, just hoping it might help spur some other ideas.

view this post on Zulip Bryn Rhodes (Nov 21 2019 at 11:12):

Is it just that you want to compute the distinct before you do the except?

view this post on Zulip Tien Thai (Nov 27 2019 at 18:04):

in QDM, is it safe to assume that each medication order must have a relevant period (i.e. start date and end date)? By that I mean the values for both medication's start date and end date are always available? If one of them is missing, lets say if the end date is NULL, is it possible to assign todays' date to this end date? Thanks.

view this post on Zulip Bryn Rhodes (Dec 03 2019 at 20:24):

Hi @Tien Thai , no, in QDM, whether the start and end date are present for a given interval is determined by the underlying data. If end date is null for an inclusive interval, then that indicates that the interval continues to the "end of time".

view this post on Zulip Bryn Rhodes (Dec 03 2019 at 20:24):

Assigning today's date for missing dates in source data is typically not advised, since it is making assumptions about what the underlying system means.


Last updated: Apr 12 2022 at 19:14 UTC