Uploaded image for project: 'BONNIE MAT MADiE Issue Tracker'
  1. BONNIE MAT MADiE Issue Tracker
  2. BONNIEMAT-989

Unexpected coalesce performance in an if then statement

XMLWordPrintable

    • Icon: Question Question
    • Resolution: Referred to External Party for Resolution
    • Icon: Blocker Blocker
    • Measure Calculation
    • None
    • BONNIE
    • Bonnie QDM
    • Follow-Up Care for Children Prescribed ADHD Medication (ADD)
    • CMS136
    • QDM/CQL
    • Test TestCMD
    • Our goal is to test the updated logic in CMS136 before submitting them by 9/10 via CRP for public comment.

      Dear Bonnie Team,

      I noticed an unexpected performance with "Coalesce" in the first "if then" statement of this function "MedicationOrderPeriod". The intent of the first "if then" statement is as such: if relevantPeriod.end is available, return an interval starting with relevantPeriod.start and ending with releavntPeriod.end; if relevantPeriod.start is null, use authorDatetime instead.

      Please find test case set up and result below. I would appreciate your assistance in pinpointing whether this is a cql-execution or logic issue. Thank you in advance!

      define function "MedicationOrderPeriod"(Order "Medication, Order"):
        if Global.HasEnd ( Order.relevantPeriod ) then Interval[Coalesce(start of Order.relevantPeriod, Order.authorDatetime), 
      end of Order.relevantPeriod]
        else ( Coalesce(Order.daysSupplied, Order.supply /(Order.dosage * ToDaily(Order.frequency)))* ( 1 + Coalesce(Order.refills, 0)) ) durationInDays
        let startDatetime: Coalesce(start of Order.relevantPeriod, Order.authorDatetime)
        return if durationInDays is not null then Interval[startDatetime, startDatetime + System.Quantity { value: durationInDays.value, unit: 'days' }]
          else null                   
      

      Test case:

      • Medication, Order
      • relevantPeriod.start: null
      • relevantPeriod.end: 1/4/2012 8:15am
      • authorDatetime: 1/2/2012 8:00am
      • Refills: 1
      • Dosage: 50 'mg'
      • Supply: 150 'mg'
      • Frequency: SNOMEDCT 229797004
      • Days Supplied: 10

      Expected output vs actual:

      • Expected: 1/2/2012 8:00am - 1/14/2012 8:15am
      • Actual: Invalid date - 1/14/2012 8:15am

       

            nalbritton Noel Albritton
            dlee38 Dorothy Lee
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: