Skip to content

Commit

Permalink
First step in refactoring/integrating the amc rules for MU2, take 2.
Browse files Browse the repository at this point in the history
  • Loading branch information
bradymiller committed Nov 21, 2015
1 parent dd34aef commit 34db4df
Show file tree
Hide file tree
Showing 29 changed files with 198 additions and 73 deletions.
55 changes: 38 additions & 17 deletions library/classes/rulesets/Amc/library/AbstractAmcReport.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
<?php
// Copyright (C) 2011 Ken Chapple <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
/**
* AbstractAmcReport class
*
* Copyright (C) 2011 Ken Chapple <[email protected]>
* Copyright (C) 2015 Brady Miller <[email protected]>
*
* LICENSE: This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://opensource.org/licenses/gpl-license.php>;.
*
* @package OpenEMR
* @author Ken Chapple <[email protected]>
* @author Brady Miller <[email protected]>
* @link https://www.open-emr.org
*/

require_once( 'AmcFilterIF.php' );
require_once( dirname(__FILE__)."/../../../../clinical_rules.php" );
require_once( dirname(__FILE__)."/../../../../amc.php" );
Expand Down Expand Up @@ -216,6 +232,14 @@ private function collectObjects ($patient,$object_label,$begin,$end) {
"AND `date` >= ? AND `date` <= ?";
array_push($sqlBindArray, $patient->id, $begin, $end);
break;
case "encounters_office_visit":
$sql = "SELECT * " .
"FROM `form_encounter` LEFT JOIN `enc_category_map` ON (form_encounter.pc_catid = enc_category_map.main_cat_id) " .
"WHERE enc_category_map.rule_enc_id = 'enc_off_vis' " .
"AND `pid` = ? " .
"AND `date` >= ? AND `date` <= ?";
array_push($sqlBindArray, $patient->id, $begin, $end);
break;
case "prescriptions":
$sql = "SELECT * " .
"FROM `prescriptions` " .
Expand Down Expand Up @@ -259,6 +283,9 @@ private function collectObjects ($patient,$object_label,$begin,$end) {
break;

case "med_orders":
// AMC MU2 TODO :
// Note the cpoe_flag and functionality does not exist in OpenEMR official codebase.
//
$sql = "SELECT cpoe_flag as cpoe_stat " .
"FROM `prescriptions` " .
"WHERE `patient_id` = ? " .
Expand Down Expand Up @@ -286,22 +313,16 @@ private function collectObjects ($patient,$object_label,$begin,$end) {
break;

case "pres_non_substance":
// AMC MU2 TODO :
// Note the cpoe_flag, eTransmit, and formulary functionality does not exist in OpenEMR official codebase.
// Note that this was to be used in the AMC_304b rules (but is currently not being used yet, though).
//
$sql = "SELECT formulary, cpoe_flag as transmit_stat, eTransmit " .
"FROM `prescriptions` " .
"WHERE controlledsubstance = 'no' " .
"AND `patient_id` = ? ".
"AND `date_added` BETWEEN ? AND ?";
array_push($sqlBindArray, $patient->id, $begin, $end);
break;

case "encounters_office_vist":
$sql = "SELECT * " .
"FROM `form_encounter` fe " .
"INNER JOIN openemr_postcalendar_categories opc ON fe.pc_catid = opc.pc_catid ".
"WHERE opc.pc_catname = 'Office Visit' ".
"AND`pid` = ? " .
"AND `date` >= ? AND `date` <= ?";
array_push($sqlBindArray, $patient->id, $begin, $end);
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public function test( AmcPatient $patient, $beginDate, $endDate )
// Is patient provided patient specific education during the report period.

// Check for any patient specific education instances.
//
// AMC MU2 TODO :
// Need to look into this measure, since as I recall it is measuring the patient education
// stuff that Rod added for MU2.
//
$item = sqlQuery("SELECT * FROM `amc_misc_data` as amc, `form_encounter` as enc " .
"WHERE enc.pid = amc.pid AND enc.pid = ? " .
"AND amc.map_category = 'form_encounter' " .
Expand Down
4 changes: 4 additions & 0 deletions library/classes/rulesets/Amc/reports/AMC_304a_3/Numerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public function getTitle()
public function test( AmcPatient $patient, $beginDate, $endDate )
{
// MEASURE STAGE2: Medication Order(s) Created as CPOE
//
// AMC MU2 TODO :
// Note the counter for this is using prescriptions which does not incorporate the cpoe_stat field.
//
if ( $patient->object['cpoe_stat'] == 'yes') {
return true;
}else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public function getTitle()
public function test( AmcPatient $patient, $beginDate, $endDate )
{
//The number of prescriptions in the denominator generated, queried for a drug formulary and transmitted electronically
//
// AMC MU2 TODO :
// Note OpenEMR official codebase does not support the eTransmit and forumulary items
//
if ( ($patient->object['eTransmit'] == 1) && ($patient->object['formulary'] == 'yes') ) {
return true;
}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public function getTitle()
public function test( AmcPatient $patient, $beginDate, $endDate )
{
//The number of prescriptions in the denominator generated, queried for a drug formulary and transmitted electronically.
//
// AMC MU2 TODO :
// Note OpenEMR official codebase does not support the eTransmit and forumulary items
//
if ( ($patient->object['eTransmit'] == 1) && ($patient->object['formulary'] == 'yes') ) {
return true;
}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public function getTitle()
public function test( AmcPatient $patient, $beginDate, $endDate )
{
//The number of prescriptions in the denominator transmitted electronically
//
// AMC MU2 TODO :
// Note OpenEMR official codebase does not support the eTransmit item
//
if($patient->object['eTransmit'] == 1) {
return true;
}else{
Expand Down
2 changes: 1 addition & 1 deletion library/classes/rulesets/Amc/reports/AMC_304h.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function getTitle()

public function getObjectToCount()
{
return "encounters";
return "encounters_office_visit";
}

public function createDenominator()
Expand Down
29 changes: 20 additions & 9 deletions library/classes/rulesets/Amc/reports/AMC_304h/Numerator.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
<?php
// Copyright (C) 2011 Brady Miller <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//

/**
* class AMC_304h_Numerator
*
* Copyright (C) 2011-2015 Brady Miller <[email protected]>
*
* LICENSE: This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://opensource.org/licenses/gpl-license.php>;.
*
* @package OpenEMR
* @author Brady Miller <[email protected]>
* @link https://www.open-emr.org
*/

class AMC_304h_Numerator implements AmcFilterIF
{
Expand All @@ -21,7 +33,6 @@ public function test( AmcPatient $patient, $beginDate, $endDate )
$amcElement = amcCollect('provide_sum_pat_amc',$patient->id,'form_encounter',$patient->object['encounter']);
if (!(empty($amcElement))) {
$daysDifference = businessDaysDifference( date("Y-m-d",strtotime($patient->object['date'])) , date("Y-m-d",strtotime($amcElement['date_completed'])) );
error_log("DEBUG: ".$daysDifference,0);
if ($daysDifference < 4) {
return true;
}
Expand Down
4 changes: 3 additions & 1 deletion library/classes/rulesets/Amc/reports/AMC_304h_STG2.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* AMC 304h STAGE2
*
* Copyright (C) 2015 Ensoftek, Inc
* Copyright (C) 2015 Brady Miller <[email protected]>
*
* LICENSE: This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Expand All @@ -18,6 +19,7 @@
*
* @package OpenEMR
* @author Ensoftek
* @author Brady Miller <[email protected]>
* @link https://www.open-emr.org
*/

Expand All @@ -30,7 +32,7 @@ public function getTitle()

public function getObjectToCount()
{
return "encounters_office_vist";
return "encounters_office_visit";
}

public function createDenominator()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public function getTitle()
public function test( AmcPatient $patient, $beginDate, $endDate )
{
//The number of transitions of care and referrals in the denominator where a summary of care record was provided.(VIEW/TRANSMITTED)
//
// AMC MU2 TODO :
// Note from_ccda is not in the main OpenEMR codebase. Should ask Z&H on strategy for this one.
//
$sumQry = "SELECT count(*) as cnt FROM amc_misc_data ".
"WHERE map_category = 'form_encounter' ".
"AND amc_id IN( 'med_reconc_amc', 'provide_sum_pat_amc' ) ".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public function getTitle()
public function test( AmcPatient $patient, $beginDate, $endDate )
{
//The number of transitions of care and referrals in the denominator where a summary of care record was electronically transmitted using CEHRT to a recipient.
//
// AMC MU2 TODO :
// Note from_ccda is not in the main OpenEMR codebase. Should ask Z&H on strategy for this one.
//
$sumQry = "SELECT count(*) as cnt FROM amc_misc_data ".
"WHERE map_category = 'form_encounter' ".
"AND amc_id IN( 'med_reconc_amc' ) ".
Expand Down
4 changes: 3 additions & 1 deletion library/classes/rulesets/Amc/reports/AMC_314g_1_2_14.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* AMC 314g 1 2 14 STAGE1
*
* Copyright (C) 2015 Ensoftek, Inc
* Copyright (C) 2015 Brady Miller <[email protected]>
*
* LICENSE: This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Expand All @@ -18,6 +19,7 @@
*
* @package OpenEMR
* @author Ensoftek
* @author Brady Miller <[email protected]>
* @link https://www.open-emr.org
*/

Expand All @@ -30,7 +32,7 @@ public function getTitle()

public function getObjectToCount()
{
return "encounters";
return "patients";
}

public function createDenominator()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* AMC 314g_1_2_14 STAGE1 Denominator
*
* Copyright (C) 2015 Ensoftek, Inc
* Copyright (C) 2015 Brady Miller <[email protected]>
*
* LICENSE: This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Expand All @@ -18,24 +19,27 @@
*
* @package OpenEMR
* @author Ensoftek
* @author Brady Miller <[email protected]>
* @link https://www.open-emr.org
*/

class AMC_314g_1_2_14_Denominator implements AmcFilterIF
{
public $patArr = array();
public function getTitle()
{
return "AMC_314g_1_2_14 Denominator";
}

public function test( AmcPatient $patient, $beginDate, $endDate )
{
if(!in_array($patient->id, $this->patArr)){
$this->patArr[] = $patient->id;
return true;
}
else
return false;
// Seen by the EP
// (basically needs an encounter within the report dates)
$options = array( Encounter::OPTION_ENCOUNTER_COUNT => 1 );
if (Helper::checkAnyEncounter($patient, $beginDate, $endDate, $options)) {
return true;
}
else {
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public function test( AmcPatient $patient, $beginDate, $endDate )
{
//The number of patients in the denominator who have timely (within 4 business days after the information is available to the EP) on-line access to their health information.
//Patient Portal has access to done V/D/T
//
// AMC MU2 TODO :
// This needs to be converted to the Z&H solution.
//
$portalQry = "SELECT count(*) as cnt FROM patient_data pd ".
"INNER JOIN ccda_log cl ON pd.pid = cl.patient_id AND cl.user_type = 2 AND cl.event IN ('patient-record-view', 'patient-record-download', 'patient-record-transmit') ".
"WHERE pd.pid = ? AND cl.date BETWEEN ? AND ?";
Expand All @@ -43,4 +47,4 @@ public function test( AmcPatient $patient, $beginDate, $endDate )
}
}
}
?>
?>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* AMC 314g_1_2_14 STAGE2
*
* Copyright (C) 2015 Ensoftek, Inc
* Copyright (C) 2015 Brady Miller <[email protected]>
*
* LICENSE: This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Expand All @@ -18,6 +19,7 @@
*
* @package OpenEMR
* @author Ensoftek
* @author Brady Miller <[email protected]>
* @link https://www.open-emr.org
*/

Expand All @@ -31,7 +33,7 @@ public function getTitle()

public function getObjectToCount()
{
return "encounters";
return "patients";
}

public function createDenominator()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* AMC 314g_1_2_14 STAGE2 Denominator
*
* Copyright (C) 2015 Ensoftek, Inc
* Copyright (C) 2015 Brady Miller <[email protected]>
*
* LICENSE: This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Expand All @@ -18,24 +19,27 @@
*
* @package OpenEMR
* @author Ensoftek
* @author Brady Miller <[email protected]>
* @link https://www.open-emr.org
*/

class AMC_314g_1_2_14_STG2_Denominator implements AmcFilterIF
{
public $patArr = array();
public function getTitle()
{
return "AMC_314g_1_2_14_STG2 Denominator";
}

public function test( AmcPatient $patient, $beginDate, $endDate )
{
if(!in_array($patient->id, $this->patArr)){
$this->patArr[] = $patient->id;
return true;
}
else
return false;
// Seen by the EP
// (basically needs an encounter within the report dates)
$options = array( Encounter::OPTION_ENCOUNTER_COUNT => 1 );
if (Helper::checkAnyEncounter($patient, $beginDate, $endDate, $options)) {
return true;
}
else {
return false;
}
}
}
Loading

0 comments on commit 34db4df

Please sign in to comment.