Clinical_rules - divide by zero error

Another simple fix

If you have an equal number of successful inclusion and exclusion filters for a rule, you will get a divide by zero error when the rule is calculated.
This comes from calculate_percentage(), which I updated as shown below to test for $pass_filt matching $exclude_filt


function calculate_percentage($pass_filt, $exclude_filt, $pass_targ, $rule, $source)
{
    if ($pass_filt > 0) {
		if ($pass_filt == $exclude_filt) // don't want to divide by zero
			$perc = "0" . xl('%'); 
		else
			$perc = number_format(($pass_targ / ($pass_filt - $exclude_filt)) * 100, 4) . xl('%');
    } else {
        $perc = "0" . xl('%');
    }

    return $perc;
}
1 Like

Hey Hank, are you familiar with git or github? If you have fixes you’d like included in the OpenEMR codebase, the best way to get it incorporated is to send those to us via a github pull request. A member of the project admin team will review your PR and bring it in or suggest improvements.