fix: Update patient_tracker.php (#6595)
[openemr.git] / library / classes / ClinicalTypes / Characteristic.php
blob21d51b3b056df3ff4ab6ca9192821225e0d622a2
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 Characteristic extends ClinicalType
14 const TERMINAL_ILLNESS = 'terminal_illness';
15 const TOBACCO_USER = 'char_tobacco_user';
16 const TOBACCO_NON_USER = 'char_tobacco_non_user';
18 public function getListId()
20 return 'Clinical_Rules_Char_Types';
23 public function doPatientCheck(RsPatient $patient, $beginDate = null, $endDate = null, $options = null)
25 $return = false;
27 if ($this->getOptionId() == self::TERMINAL_ILLNESS) {
28 // TODO check for terminal illness
29 } elseif ($this->getOptionId() == self::TOBACCO_USER) {
30 $tobaccoHistory = getHistoryData($patient->id, "tobacco", $beginDate, $endDate);
32 if (isset($tobaccoHistory['tobacco'])) {
33 $tmp = explode('|', $tobaccoHistory['tobacco']);
34 $tobaccoStatus = $tmp[1];
35 if ($tobaccoStatus == 'currenttobacco') {
36 $return = true;
37 } elseif ($tobaccoStatus == 'quittobacco') {
38 $quitDate = $tmp[2];
39 if (strtotime($quitDate) > strtotime($beginDate)) {
40 $return = true;
44 } elseif ($this->getOptionId() == self::TOBACCO_NON_USER) {
45 $tobaccoHistory = getHistoryData($patient->id, "tobacco", $beginDate, $endDate);
46 if (isset($tobaccoHistory['tobacco'])) {
47 $tmp = explode('|', $tobaccoHistory['tobacco']);
48 $tobaccoStatus = $tmp[1];
49 if ($tobaccoStatus == 'quittobacco') {
50 $quitDate = $tmp[2];
51 if (strtotime($quitDate) < strtotime($beginDate)) {
52 $return = true;
54 } elseif ($tobaccoStatus == 'nevertobacco') {
55 $return = true;
60 return $return;