/** * @param $rule * @return bool */ private function ckActiveProblems($rule) { if (isset($rule['concepts']['PROB']) && !empty($rule['concepts']['PROB'])) { $count = 0; foreach ($rule['concepts']['PROB'] as $concept) { $problems = $this->ActiveProblems->getPatientActiveProblemByPidAndCode($this->Patient->getPatientPid(), $concept['concept_code']); if (empty($problems)) { continue; } if ($concept['frequency_interval'] == 0) { $count++; continue; } $frequency = 0; foreach ($problems as $problem) { if ($this->isWithInterval($problem['begin_date'], $concept['frequency_interval'], $concept['frequency_operator'], 'Y-m-d')) { $frequency++; if ($concept['frequency'] == $frequency) { break; } } } if ($concept['frequency_operator'] == '' || $this->compare($frequency, $concept['frequency_operator'], $concept['frequency'])) { $count++; } } return $count == count($rule['concepts']['PROB']); } return true; }