QA Using Just the Date of a DateTime - cqframework/CQL-Formatting-and-Usage-Wiki GitHub Wiki

Questions and Answers


Q&A - Using Just the Date of a DateTime

Question

Our test case is failing in Bonnie. We are not sure what the reason is as the CQL logic is correct but the test case is still failing.

Answer

The logic in question is:

  define "GA with TOD4":
    "TOD 2" T
      with "Gestational age at Delivery" G
        such that G.authorDatetime less than 1 day on or before day of start of T.relevantPeriod

"T" here represents the "Encounter, Performed: Encounter Inpatient" with relevant period starting 1/1/2012 8am

"G" here represents the "Assessment, Perfomred: Estimated Gestational Age at Delivery" with author date time at 12/31/2011 9am.

12/31/2011 at 9am is less than 1 day on or before day of 1/1/2012.

Based on this, it appears that the logic is performing as expected.

Question

We have made changes such that the logic points to the "time of delivery" and not the "encounter" However, the test case is still failing.

Answer

The issue here is "day of"; "day of" makes it so it only pays attention to the date rather than the time. If you want it to pay attention to the time, change:

  such that G.authorDatetime less than 1 day on or before day of A.authorDatetime

to:

  such that G.authorDatetime less than 1 day on or before A.authorDatetime