3 // Copyright (C) 2011 Ken Chapple <ken@mi-squared.com>
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 require_once("ReportTypes.php");
10 use OpenEMR\Common\Logging\SystemLogger
;
14 public function __construct()
16 foreach (glob(dirname(__FILE__
) . "/library/*.php") as $filename) {
17 require_once($filename);
20 foreach (glob(dirname(__FILE__
) . "/Cqm/*.php") as $filename) {
21 require_once($filename);
24 foreach (glob(dirname(__FILE__
) . "/Amc/*.php") as $filename) {
25 require_once($filename);
29 public function runReport($rowRule, $patients, $dateTarget, $options = array())
31 $ruleId = $rowRule['id'];
32 $patientData = array();
33 foreach ($patients as $patient) {
34 $patientData [] = $patient['pid'];
37 $reportFactory = null;
38 if (ReportTypes
::getType($ruleId) == ReportTypes
::CQM
) {
39 $reportFactory = new CqmReportFactory();
40 } elseif (ReportTypes
::getType($ruleId) == ReportTypes
::AMC
) {
41 $reportFactory = new AmcReportFactory();
43 throw new Exception("Unknown rule: " . $ruleId);
47 if ($reportFactory instanceof RsReportFactoryAbstract
) {
48 $report = $reportFactory->createReport(ReportTypes
::getClassName($ruleId), $rowRule, $patientData, $dateTarget, $options);
53 $report instanceof RsReportIF
&&
54 !$report instanceof RsUnimplementedIF
57 $results = $report->getResults();
59 (new SystemLogger())->errorLogCaller("Rule class does not implement valid interfaces", ['ruleId' => $ruleId, 'class' => ReportTypes
::getClassName($ruleId)]);
62 return RsHelper
::formatClinicalRules($results);