lsgs / redcap-extended-reports

Provides various additional options to enhance REDCap's built-in reporting functionality.
GNU General Public License v3.0
1 stars 3 forks source link

Bug: Minimum/maximum value may be incorrect if at some point 0 is the min/max on the non-last instance #15

Closed steentje34 closed 5 months ago

steentje34 commented 5 months ago

When using the 'Minimum value' or 'Maximum value' options, the result could be incorrect if at some point in the process 0 is the min/max on the non-last instance of a repeating instrument. Please find below 2 examples to clarify.

Example 1: option 'Minimum value'

Example 2: option 'Maximum value'

I am seeing this behaviour using REDCap 13.7.30 and EM version 2.1.0, but I think this bug has been there since EM version 2.0.0 and is linked to the lines below: https://github.com/lsgs/redcap-extended-reports/blob/c35fe00799059d2a8fa903c5b72aa108e9f49c56/Report.php#L813 https://github.com/lsgs/redcap-extended-reports/blob/c35fe00799059d2a8fa903c5b72aa108e9f49c56/Report.php#L820

In both examples, $thisRecValue is equal to 0 when instance 3 is evaluated. Since 0 == '' in PHP, the value from instance 3 is automatically taken as the $thisRecValue, making the EM disregard all previous instances.

If I am not mistaken, changing the operator == to === should solve the issue without breaking any other functionality.

Thanks @lsgs for your continued support of this EM that is much in demand at our institution!

lsgs commented 5 months ago

Thanks @steentje34 - I'll try and get this fixed up asap...

lsgs commented 5 months ago

I've made this change and included it in release v2.1.1.