Highway to PSR2
[openemr.git] / library / classes / ClinicalTypes / Characteristic.php
blob28cd0b0c271da2313bd1c079f8bd74b18f62911a
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 Characteristic extends ClinicalType
13 const TERMINAL_ILLNESS = 'terminal_illness';
14 const TOBACCO_USER = 'char_tobacco_user';
15 const TOBACCO_NON_USER = 'char_tobacco_non_user';
17 public function getListId()
19 return 'Clinical_Rules_Char_Types';
22 public function doPatientCheck(RsPatient $patient, $beginDate = null, $endDate = null, $options = null)
24 $return = false;
26 if ($this->getOptionId() == self::TERMINAL_ILLNESS) {
27 // TODO check for terminal illness
28 } else if ($this->getOptionId() == self::TOBACCO_USER) {
29 $tobaccoHistory = getHistoryData($patient->id, "tobacco", $beginDate, $endDate);
31 if (isset($tobaccoHistory['tobacco'])) {
32 $tmp = explode('|', $tobaccoHistory['tobacco']);
33 $tobaccoStatus = $tmp[1];
34 if ($tobaccoStatus == 'currenttobacco') {
35 $return = true;
36 } else if ($tobaccoStatus == 'quittobacco') {
37 $quitDate = $tmp[2];
38 if (strtotime($quitDate) > strtotime($beginDate)) {
39 $return = true;
43 } else if ($this->getOptionId() == self::TOBACCO_NON_USER) {
44 $tobaccoHistory = getHistoryData($patient->id, "tobacco", $beginDate, $endDate);
45 if (isset($tobaccoHistory['tobacco'])) {
46 $tmp = explode('|', $tobaccoHistory['tobacco']);
47 $tobaccoStatus = $tmp[1];
48 if ($tobaccoStatus == 'quittobacco') {
49 $quitDate = $tmp[2];
50 if (strtotime($quitDate) < strtotime($beginDate)) {
51 $return = true;
53 } else if ($tobaccoStatus == 'nevertobacco') {
54 $return = true;
59 return $return;