Highway to PSR2
[openemr.git] / library / classes / rulesets / Cqm / reports / NFQ_0028a / Numerator.php
blob5eb0b23a1c930ac5a8c037954355692061b6d780
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 class NFQ_0028a_Numerator implements CqmFilterIF
11 public function getTitle()
13 return "Numerator";
16 public function test(CqmPatient $patient, $beginDate, $endDate)
18 // See if user has been a tobacco user before or simultaneosly to the encounter within two years (24 months)
19 foreach ($this->getApplicableEncounters() as $encType) {
20 $dates = Helper::fetchEncounterDates($encType, $patient, $beginDate, $endDate);
21 foreach ($dates as $date) {
22 // encounters time stamp is always 00:00:00, so change it to 23:59:59 or 00:00:00 as applicable
23 $date = date('Y-m-d 23:59:59', strtotime($date));
24 $beginMinus24Months = strtotime('-24 month', strtotime($date));
25 $beginMinus24Months = date('Y-m-d 00:00:00', $beginMinus24Months);
26 // this is basically a check to see if the patient's tobacco status has been evaluated in the two years previous to encounter.
27 if (Helper::check(ClinicalType::CHARACTERISTIC, Characteristic::TOBACCO_USER, $patient, $beginMinus24Months, $date) ||
28 Helper::check(ClinicalType::CHARACTERISTIC, Characteristic::TOBACCO_NON_USER, $patient, $beginMinus24Months, $date) ) {
29 return true;
34 return false;
37 private function getApplicableEncounters()
39 return array(
40 Encounter::ENC_OFF_VIS,
41 Encounter::ENC_HEA_AND_BEH,
42 Encounter::ENC_OCC_THER,
43 Encounter::ENC_PSYCH_AND_PSYCH,
44 Encounter::ENC_PRE_MED_SER_18_OLDER,
45 Encounter::ENC_PRE_IND_COUNSEL,
46 Encounter::ENC_PRE_MED_GROUP_COUNSEL,
47 Encounter::ENC_PRE_MED_OTHER_SERV );