Closed JSRankins closed 3 years ago
@JSRankins - I just took a look at our code and we do have several unit tests that specifically test collapse of DateTime intervals without specifying a per unit. The tests all pass -- so there is some edge case happening here. I'll look into it further -- but it would help to know if there is anything unusual about the intervals being passed in. Are any of them null? Do any have null boundaries? If so, open null or closed null? Etc...
Hi @cmoesel No nulls. The inputs are actually datetime based (both using a Medication Order's relevantPeriod), but the CumulativeDuration function invokes MedicationPeriod function which uses a MedicationOrderPeriod function that strips off the time portion and ultimately passes the data back to the CumulativeDuration function as dates.
define function "MedicationOrderPeriod"(Order "Medication, Order" ):
if Order.relevantPeriod.low is null and Order.authorDatetime is null then
null
else if Order.relevantPeriod.high is not null then
Interval[date from Coalesce(Order.relevantPeriod.low, Order.authorDatetime), date from end of Order.relevantPeriod]
.....
Intervals used: Interval[@2012-04-01T08:00, @2012-10-13T08:15] Interval[@2012-10-14T08:00, @2012-10-16T08:15]
Hmmm... OK. Thanks! I'll try testing w/ those exact values to see what happens!
OK. I was able to reproduce this. Thanks for the extra information, @JSRankins. It looks like we have a bug when collapsing intervals of Date or intervals of Time when no per is provided (but collapsing intervals of DateTime with no per works fine). I have a local fix in place, but I need to test it some more before it's ready.
That confirms what we were seeing @cmoesel. When per is added to the CQL logic, https://github.com/cqframework/cql-execution/issues/256 arises. That issue is against the 2.2.0 source code, so this issue may be have been resolved in a later release - something we are wanting to confirm.
Tagging @brynrhodes on this since this issue impacts the QDM version of CumulativeMedicationDuration library. Bryn, sounds like @cmoesel is working on updating the code, but depending on timing for release and when something might be able to get into Bonnie, thoughts about using a workaround for this logic in the CMD library?
This fix is now available in the cql-execution 2.3.3 release.
The CumulativeMedicationDuration library contains a function using a collapse.
This function throws an error when more than one interval is in the list (e.g., {Interval[@2010-01-01, @2010-06-01], Interval[@2010-06-02, @2010-12-31]} ) provided to the function. Stacktrace:
CQL supports the use of collapse with or without a specified unit for the collapse. The function in the library does not specify a unit. Given the stacktrace, we speculate that this is the issue but question if that behavior is correct based on CQL.