Highway to PSR2
[openemr.git] / library / classes / ClinicalTypes / Helper.php
blob93a0dcd0bcb7a5e4e03ffcf345081d4e4298a005
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('ClinicalType.php');
11 class Helper
13 public static function checkAllergy($subType, RsPatient $patient, $beginDate = null, $endDate = null, $options = null)
15 return self::check(ClinicalType::ALLERGY, $subType, $patient, $beginDate, $endDate, $options);
18 public static function checkDiagActive($subType, RsPatient $patient, $beginDate = null, $endDate = null, $options = null)
20 // TODO append options array
21 return self::check(ClinicalType::DIAGNOSIS, $subType, $patient, $beginDate, $endDate, array( Diagnosis::OPTION_STATE => Diagnosis::STATE_ACTIVE ));
24 public static function checkDiagInactive($subType, RsPatient $patient, $beginDate = null, $endDate = null, $options = null)
26 return self::check(ClinicalType::DIAGNOSIS, $subType, $patient, $beginDate, $endDate, array( Diagnosis::OPTION_STATE => Diagnosis::STATE_INACTIVE ));
29 public static function checkDiagResolved($subType, RsPatient $patient, $beginDate = null, $endDate = null, $options = null)
31 return self::check(ClinicalType::DIAGNOSIS, $subType, $patient, $beginDate, $endDate, array( Diagnosis::OPTION_STATE => Diagnosis::STATE_RESOLVED ));
34 public static function checkEncounter($subType, RsPatient $patient, $beginDate = null, $endDate = null, $options = null)
36 return self::check(ClinicalType::ENCOUNTER, $subType, $patient, $beginDate, $endDate, $options);
39 public static function checkLab($subType, RsPatient $patient, $beginDate = null, $endDate = null, $options = null)
41 return self::check(ClinicalType::LAB_RESULT, $subType, $patient, $beginDate, $endDate, $options);
44 public static function checkMed($subType, RsPatient $patient, $beginDate = null, $endDate = null, $options = null)
46 return self::check(ClinicalType::MEDICATION, $subType, $patient, $beginDate, $endDate, $options);
49 public static function check($type, $subType, RsPatient $patient, $beginDate = null, $endDate = null, $options = null)
51 $typeObj = new $type( $subType );
52 if ($typeObj instanceof ClinicalType) {
53 if ($beginDate == null) {
54 $beginDate = $patient->dob;
57 if ($endDate == null) {
58 $endDate = date("Y-m-d");
61 return $typeObj->doPatientCheck($patient, $beginDate, $endDate, $options);
62 } else {
63 throw new Exception("Type must be a subclass of AbstractClinicalType");
67 public static function fetchEncounterDates($encounterType, RsPatient $patient, $beginDate = null, $endDate = null)
69 $encounter = new Encounter($encounterType);
70 return $encounter->fetchDates($patient, $beginDate, $endDate);
73 public static function checkAnyEncounter(RsPatient $patient, $beginDate = null, $endDate = null, $options = null)
75 $encounters = Encounter::getEncounterTypes();
76 foreach ($encounters as $encounter) {
77 if (self::checkEncounter($encounter, $patient, $beginDate, $endDate, $options)) {
78 return true;
82 return false;