Fixes #7621 validation save errors w/ translations (#7622)
[openemr.git] / library / classes / rulesets / ReportManager.php
bloba5c314593033b3d6ef15fdc15033d7d67636d797
1 <?php
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.
8 //
9 require_once("ReportTypes.php");
10 use OpenEMR\Common\Logging\SystemLogger;
12 class ReportManager
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();
42 } else {
43 throw new Exception("Unknown rule: " . $ruleId);
46 $report = null;
47 if ($reportFactory instanceof RsReportFactoryAbstract) {
48 $report = $reportFactory->createReport(ReportTypes::getClassName($ruleId), $rowRule, $patientData, $dateTarget, $options);
51 $results = array();
52 if (
53 $report instanceof RsReportIF &&
54 !$report instanceof RsUnimplementedIF
55 ) {
56 $report->execute();
57 $results = $report->getResults();
58 } else {
59 (new SystemLogger())->errorLogCaller("Rule class does not implement valid interfaces", ['ruleId' => $ruleId, 'class' => ReportTypes::getClassName($ruleId)]);
62 return RsHelper::formatClinicalRules($results);