Highway to PSR2
[openemr.git] / library / classes / rulesets / Cqm / reports / NFQ_0002 / Numerator.php
blob65ebb93b0bd9d37ffbfcc33a2140da6255089d8b
1 <?php
2 /**
4 * CQM NQF 0002 Numerator
6 * Copyright (C) 2015 Ensoftek, Inc
8 * LICENSE: This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
19 * @package OpenEMR
20 * @author Ensoftek
21 * @link http://www.open-emr.org
24 class NFQ_0002_Numerator implements CqmFilterIF
26 public function getTitle()
28 return "Numerator";
31 public function test(CqmPatient $patient, $beginDate, $endDate)
34 //Group A Streptococcus Test Array
35 $strep_test_code = "'".implode("','", Codes::lookup(LabResult::STREPTOCOCCUS_TEST, 'LOINC'))."'";
37 //Patients who were tested for Streptococcus A during the same encounter that the antibiotic was prescribed, Encounter category should be office visit.
38 $query = "SELECT count(*) as cnt FROM form_encounter fe ".
39 "INNER JOIN openemr_postcalendar_categories opc ON fe.pc_catid = opc.pc_catid ".
40 "INNER JOIN procedure_order po ON po.encounter_id = fe.encounter ".
41 "INNER JOIN procedure_order_code pc ON po.procedure_order_id = pc.procedure_order_id ".
42 "INNER JOIN procedure_report pr on pr.procedure_order_id = po.procedure_order_id ".
43 "INNER JOIN procedure_result pres on pres.procedure_report_id = pr.procedure_report_id ".
44 "WHERE opc.pc_catname = 'Office Visit' AND fe.pid = ? AND (fe.date BETWEEN ? AND ? ) ".
45 " AND pres.result_code in ($strep_test_code) AND ( DATEDIFF(po.date_ordered,fe.date) between 0 and 3 or DATEDIFF(fe.date,po.date_ordered) between 0 and 3)";
47 $check = sqlQuery($query, array($patient->id, $beginDate, $endDate));
48 if ($check['cnt'] > 0) {
49 return true;
50 } else {
51 return false;