PageRenderTime 42ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/library/classes/rulesets/ReportManager.php

https://bitbucket.org/astawiarski/openemr
PHP | 59 lines | 7 code | 1 blank | 51 comment | 0 complexity | 1944df432d50aceaa7573997256dc36a MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0, GPL-2.0, MPL-2.0
  1. <?php
  2. // Copyright (C) 2011 Ken Chapple <ken@mi-squared.com>
  3. //
  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. class ReportManager
  11. {
  12. public function __construct()
  13. {
  14. foreach ( glob( dirname(__FILE__)."/library/*.php" ) as $filename ) {
  15. require_once( $filename );
  16. }
  17. foreach ( glob( dirname(__FILE__)."/Cqm/*.php" ) as $filename ) {
  18. require_once( $filename );
  19. }
  20. foreach ( glob( dirname(__FILE__)."/Amc/*.php" ) as $filename ) {
  21. require_once( $filename );
  22. }
  23. }
  24. public function runReport( $rowRule, $patients, $dateTarget, $options=array() )
  25. {
  26. $ruleId = $rowRule['id'];
  27. $patientData = array();
  28. foreach( $patients as $patient ) {
  29. $patientData []= $patient['pid'];
  30. }
  31. $reportFactory = null;
  32. if ( ReportTypes::getType( $ruleId ) == ReportTypes::CQM ) {
  33. $reportFactory = new CqmReportFactory();
  34. } else if ( ReportTypes::getType( $ruleId ) == ReportTypes::AMC ) {
  35. $reportFactory = new AmcReportFactory();
  36. } else {
  37. throw new Exception( "Unknown rule: ".$ruleId );
  38. }
  39. $report = null;
  40. if ( $reportFactory instanceof RsReportFactoryAbstract ) {
  41. $report = $reportFactory->createReport( ReportTypes::getClassName( $ruleId ), $rowRule, $patientData, $dateTarget, $options );
  42. }
  43. $results = array();
  44. if ( $report instanceof RsReportIF &&
  45. !$report instanceof RsUnimplementedIF ) {
  46. $report->execute();
  47. $results = $report->getResults();
  48. }
  49. return RsHelper::formatClinicalRules( $results );
  50. }
  51. }