fix: Update patient_tracker.php (#6595)
[openemr.git] / library / classes / ClinicalTypes / Helper.php
blob20c7da3955289cfea83991db645a3dcce48933e0
1 <?php
3 // Copyright (C) 2011 Ken Chapple <ken@mi-squared.com>
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 require_once('ClinicalType.php');
12 class Helper
14 public static function checkAllergy($subType, RsPatient $patient, $beginDate = null, $endDate = null, $options = null)
16 return self::check(ClinicalType::ALLERGY, $subType, $patient, $beginDate, $endDate, $options);
19 public static function checkDiagActive($subType, RsPatient $patient, $beginDate = null, $endDate = null, $options = null)
21 // TODO append options array
22 return self::check(ClinicalType::DIAGNOSIS, $subType, $patient, $beginDate, $endDate, array( Diagnosis::OPTION_STATE => Diagnosis::STATE_ACTIVE ));
25 public static function checkDiagInactive($subType, RsPatient $patient, $beginDate = null, $endDate = null, $options = null)
27 return self::check(ClinicalType::DIAGNOSIS, $subType, $patient, $beginDate, $endDate, array( Diagnosis::OPTION_STATE => Diagnosis::STATE_INACTIVE ));
30 public static function checkDiagResolved($subType, RsPatient $patient, $beginDate = null, $endDate = null, $options = null)
32 return self::check(ClinicalType::DIAGNOSIS, $subType, $patient, $beginDate, $endDate, array( Diagnosis::OPTION_STATE => Diagnosis::STATE_RESOLVED ));
35 public static function checkEncounter($subType, RsPatient $patient, $beginDate = null, $endDate = null, $options = null)
37 return self::check(ClinicalType::ENCOUNTER, $subType, $patient, $beginDate, $endDate, $options);
40 public static function checkLab($subType, RsPatient $patient, $beginDate = null, $endDate = null, $options = null)
42 return self::check(ClinicalType::LAB_RESULT, $subType, $patient, $beginDate, $endDate, $options);
45 public static function checkMed($subType, RsPatient $patient, $beginDate = null, $endDate = null, $options = null)
47 return self::check(ClinicalType::MEDICATION, $subType, $patient, $beginDate, $endDate, $options);
50 public static function check($type, $subType, RsPatient $patient, $beginDate = null, $endDate = null, $options = null)
52 $typeObj = new $type($subType);
53 if ($typeObj instanceof ClinicalType) {
54 if ($beginDate == null) {
55 $beginDate = $patient->dob;
58 if ($endDate == null) {
59 $endDate = date("Y-m-d");
62 return $typeObj->doPatientCheck($patient, $beginDate, $endDate, $options);
63 } else {
64 throw new Exception("Type must be a subclass of AbstractClinicalType");
68 public static function fetchEncounterDates($encounterType, RsPatient $patient, $beginDate = null, $endDate = null)
70 $encounter = new Encounter($encounterType);
71 return $encounter->fetchDates($patient, $beginDate, $endDate);
74 public static function checkAnyEncounter(RsPatient $patient, $beginDate = null, $endDate = null, $options = null)
76 $encounters = Encounter::getEncounterTypes();
77 foreach ($encounters as $encounter) {
78 if (self::checkEncounter($encounter, $patient, $beginDate, $endDate, $options)) {
79 return true;
83 return false;