eRx captured and displayed in AMC report,
[openemr.git] / library / classes / rulesets / Amc / reports / AMC_302d / Numerator.php
blobd870ff817238747a8c94ce5366c14fa5692f2992
1 <?php
2 // Copyright (C) 2011 Brady Miller <brady@sparmy.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 //
11 class AMC_302d_Numerator implements AmcFilterIF
13 public function getTitle()
15 return "AMC_302d Numerator";
18 public function test( AmcPatient $patient, $beginDate, $endDate )
20 // Have at least one entry or an indication that no medications are known for the
21 // patient recorded as structured data.
22 // (true if an entry in lists_touch(medication token) or an active entry in lists preceding the date-end)
23 // (In the lists_touch, theres is also a special case entry to support the NewCropRx module
24 // since that module also manages medications. These special case entries use the prescription_erx
25 // token.)
26 $firstCheck = sqlQuery("SELECT * FROM `lists_touch` WHERE `pid`=? AND (`type`=? OR type=?) AND `date`<=?", array($patient->id,'medication','prescription_erx',$endDate) );
27 $secondCheck = sqlQuery("SELECT * FROM `lists` WHERE `activity`='1' AND `pid`=? AND `type`=? AND `date`<=?", array($patient->id,'medication',$endDate) );
28 if ( !(empty($firstCheck)) || !(empty($secondCheck)) ) {
29 return true;
31 else {
32 return false;