Clinical Decision Rules - broken for targets with no defined interval

openEMR 7.0.3(4)
Windows/xampp 3.3.0
php 8.1.6

Hi all.
I noticed that for some of the original rules that were manually added to the database, there is no target_interval defined in the rule_target table. Examples: rule_cs_colon, rule_blood_pressure, and rule_cs_prostate (there are others as well). For these rules, the targets always evaluate to true, so these rules always show as “not due”.
If you use the rule builder GUI to add/edit a rule target, the GUI always creates a target_interval row in the rule_target table.
When you add a target in the GUI, it shows a default interval of 1 month.
The logic in database_check() in library\clinical_rules.php does not similarly assume 1 month, and instead defaults to empty strings for $intervalValue and $intervalType, causing the targets to always evaluate to true. If these defaults are changed to ‘1’ and ‘month’, appropriate rule evaluation is observed.
I will try to roll a patch that has this change (might take me a while to get my git environment back up and running). In the meantime, folks might consider making these changes in database_check() themselves.
– Hank

Note, database_check is called in processing both demographic filters as well as rule targets. The issue described above applies only to target evaluation. Filters are not examined against an interval. So, the logic needs to set the default interval to 1 month only when processing targets, and not filters, in cases where no interval is listed in the database when database_check is called. database_check, when called to process a filter, is passed an empty $dateFocus value, and a non-blank value when processing a target. This difference can be used to decide whether to set the interval to 1 month when the passed interval is empty. Here is my code in database_check that does this:

 	if ($dateFocus) {
		$intervalType = 'month';
		$intervalValue = '1';
	}
	else {
		$intervalType = '';
		$intervalValue = '';
	}
	
	if (!empty($interval)) {
        $intervalType = $interval[0]['value'];
        $intervalValue = $interval[0]['interval'];
    }