Email change of a developer (#503)
[openemr.git] / library / classes / rulesets / Cqm / reports / NFQ_0028b / Denominator.php
blob170beb9d7b2d1af3be8f7b0ee172c0e561b65ebb
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_Denominator implements CqmFilterIF
11 public function getTitle()
13 return "NFQ 0028b Denominator";
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 $date_array = array();
20 foreach ( $this->getApplicableEncounters() as $encType )
22 $dates = Helper::fetchEncounterDates( $encType, $patient, $beginDate, $endDate );
23 $date_array = array_merge($date_array,$dates);
26 // sort array to get the most recent encounter first
27 $date_array = array_unique($date_array);
28 rsort($date_array);
30 // go through each unique date from most recent
31 foreach ( $date_array as $date )
33 // encounters time stamp is always 00:00:00, so change it to 23:59:59 or 00:00:00 as applicable
34 $date = date( 'Y-m-d 23:59:59', strtotime( $date ));
35 $beginMinus24Months = strtotime( '-24 month' , strtotime ( $date ) );
36 $beginMinus24Months = date( 'Y-m-d 00:00:00' , $beginMinus24Months );
37 // this is basically a check to see if the patient is an reported as an active smoker on their last encounter
38 if ( Helper::check( ClinicalType::CHARACTERISTIC, Characteristic::TOBACCO_USER, $patient, $beginMinus24Months, $date ) ) {
39 return true;
41 else if ( Helper::check( ClinicalType::CHARACTERISTIC, Characteristic::TOBACCO_NON_USER, $patient, $beginMinus24Months, $date ) ) {
42 return false;
44 else {
45 // nothing reported during this date period, so move on to next encounter
49 return false;
52 private function getApplicableEncounters()
54 return array(
55 Encounter::ENC_OFF_VIS,
56 Encounter::ENC_HEA_AND_BEH,
57 Encounter::ENC_OCC_THER,
58 Encounter::ENC_PSYCH_AND_PSYCH,
59 Encounter::ENC_PRE_MED_SER_18_OLDER,
60 Encounter::ENC_PRE_IND_COUNSEL,
61 Encounter::ENC_PRE_MED_GROUP_COUNSEL,
62 Encounter::ENC_PRE_MED_OTHER_SERV );