Highway to PSR2
[openemr.git] / library / classes / rulesets / Cqm / reports / NFQ_0028b / Numerator.php
blob615f895cdd45e8dbc5758bf6d4acbf5aa21dd6bb
1 <?php
2 // Copyright (C) 2011 Brady Miller <brady.g.miller@gmail.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_0028b_Numerator implements CqmFilterIF
11 public function getTitle()
13 return "Numerator";
16 public function test(CqmPatient $patient, $beginDate, $endDate)
18 // See if user has been counseled to stop smoking or been prescribed a smoking cessations medication within last 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 $smoke_cess = sqlQuery("SELECT * FROM `rule_patient_data` " .
27 "WHERE `category`='act_cat_inter' AND `item`='act_tobacco' AND `complete`='YES' " .
28 "AND `pid`=? AND `date`>=? AND `date`<=?", array($patient->id,$beginMinus24Months,$date));
29 // this is basically a check to see if the patient's action has occurred in the two years previous to encounter.
30 // TODO: how to check for the smoking cessation medication types (can also just be a smoking cessation order, ie. prescription)
31 if (!(empty($smoke_cess)) ||
32 Helper::checkMed(Medication::SMOKING_CESSATION, $patient, $beginMinus24Months, $date) ||
33 Helper::checkMed(Medication::SMOKING_CESSATION_ORDER, $patient, $beginMinus24Months, $date) ) {
34 return true;
39 return false;
42 private function getApplicableEncounters()
44 return array(
45 Encounter::ENC_OFF_VIS,
46 Encounter::ENC_HEA_AND_BEH,
47 Encounter::ENC_OCC_THER,
48 Encounter::ENC_PSYCH_AND_PSYCH,
49 Encounter::ENC_PRE_MED_SER_18_OLDER,
50 Encounter::ENC_PRE_IND_COUNSEL,
51 Encounter::ENC_PRE_MED_GROUP_COUNSEL,
52 Encounter::ENC_PRE_MED_OTHER_SERV );