Skip to content

Commit

Permalink
Third step in refactoring/integrating the amc rules for MU2.
Browse files Browse the repository at this point in the history
amc item 8 completed
(just have the following items left to complete: 7,14, and 20)
  • Loading branch information
bradymiller committed Dec 22, 2015
1 parent 3f2a572 commit ffe1ea6
Show file tree
Hide file tree
Showing 14 changed files with 100 additions and 59 deletions.
20 changes: 20 additions & 0 deletions controllers/C_Prescription.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,26 @@ function edit_action_process() {
processAmcCall('e_prescribe_amc', true, 'remove', $this->prescriptions[0]->get_patient_id(), 'prescriptions', $this->prescriptions[0]->id);
}

// Set the AMC reporting flag (to record prescriptions that checked drug formulary)
if (!(empty($_POST['checked_formulary_flag']))) {
// add the e-prescribe flag
processAmcCall('e_prescribe_chk_formulary_amc', true, 'add', $this->prescriptions[0]->get_patient_id(), 'prescriptions', $this->prescriptions[0]->id);
}
else {
// remove the e-prescribe flag
processAmcCall('e_prescribe_chk_formulary_amc', true, 'remove', $this->prescriptions[0]->get_patient_id(), 'prescriptions', $this->prescriptions[0]->id);
}

// Set the AMC reporting flag (to record prescriptions that are controlled substances)
if (!(empty($_POST['controlled_substance_flag']))) {
// add the e-prescribe flag
processAmcCall('e_prescribe_cont_subst_amc', true, 'add', $this->prescriptions[0]->get_patient_id(), 'prescriptions', $this->prescriptions[0]->id);
}
else {
// remove the e-prescribe flag
processAmcCall('e_prescribe_cont_subst_amc', true, 'remove', $this->prescriptions[0]->get_patient_id(), 'prescriptions', $this->prescriptions[0]->id);
}

// TajEmo Work by CB 2012/05/29 02:58:29 PM to stop from going to send screen. Improves Work Flow
// if ($this->prescriptions[0]->get_active() > 0) {
// return $this->send_action($this->prescriptions[0]->id);
Expand Down
14 changes: 0 additions & 14 deletions library/classes/rulesets/Amc/library/AbstractAmcReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,20 +301,6 @@ private function collectObjects ($patient,$object_label,$begin,$end) {
"patient_id = ? " .
"AND (date_ordered BETWEEN ? AND ?)";
array_push($sqlBindArray, $patient->id, $begin, $end);
break;

case "pres_non_substance":
// Still TODO
// 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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
*/
// Denominator:
// Reporting period start and end date
// Prescription written for drugs requiring a prescription in order to be dispensed
// Generate and transmit permissible prescriptions electronically (Controlled substances with drug formulary).( AMC-2014:170.314(g)(1)/(2)–8 )
// Prescription written for drugs requiring a prescription in order to be dispensed(including controlled substance)
class AMC_304b_1_STG2_Denominator implements AmcFilterIF
{
public function getTitle()
Expand All @@ -33,7 +32,7 @@ public function getTitle()

public function test( AmcPatient $patient, $beginDate, $endDate )
{
return true;
return true;
}

}
20 changes: 9 additions & 11 deletions library/classes/rulesets/Amc/reports/AMC_304b_1_STG2/Numerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,14 @@ 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
//
// Still TODO
// 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{
return false;
}
//The number of prescriptions in the denominator generated, queried for a drug formulary and transmitted electronically
$eprescribe = amcCollect('e_prescribe_amc',$patient->id,'prescriptions',$patient->object['id']);
$checkformulary = amcCollect('e_prescribe_chk_formulary_amc',$patient->id,'prescriptions',$patient->object['id']);
if ( !(empty($eprescribe)) && !(empty($checkformulary)) ) {
return true;
}
else {
return false;
}
}
}
1 change: 0 additions & 1 deletion library/classes/rulesets/Amc/reports/AMC_304b_2_STG2.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public function getTitle()

public function getObjectToCount()
{
//return "pres_non_substance";
return "prescriptions";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,17 @@ public function getTitle()

public function test( AmcPatient $patient, $beginDate, $endDate )
{
return true;
// Check if prescription is for a controlled substance
$controlledSubstanceCheck = amcCollect('e_prescribe_cont_subst_amc',$patient->id,'prescriptions',$patient->object['id']);
// Exclude controlled substances
if (empty($controlledSubstanceCheck)) {
// Not a controlled substance, so include in denominator.
return true;
}
else {
// Is a controlled substance, so exclude from denominator.
return false;
}
}

}
20 changes: 9 additions & 11 deletions library/classes/rulesets/Amc/reports/AMC_304b_2_STG2/Numerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@ 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.
//
// Still TODO
// 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{
return false;
}
//The number of prescriptions in the denominator generated, queried for a drug formulary and transmitted electronically
$eprescribe = amcCollect('e_prescribe_amc',$patient->id,'prescriptions',$patient->object['id']);
$checkformulary = amcCollect('e_prescribe_chk_formulary_amc',$patient->id,'prescriptions',$patient->object['id']);
if ( !(empty($eprescribe)) && !(empty($checkformulary)) ) {
return true;
}
else {
return false;
}
}
}
1 change: 0 additions & 1 deletion library/classes/rulesets/Amc/reports/AMC_304b_STG1.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public function getTitle()

public function getObjectToCount()
{
//return "pres_non_substance";
return "prescriptions";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,17 @@ public function getTitle()

public function test( AmcPatient $patient, $beginDate, $endDate )
{
return true;
// Check if prescription is for a controlled substance
$controlledSubstanceCheck = amcCollect('e_prescribe_cont_subst_amc',$patient->id,'prescriptions',$patient->object['id']);
// Exclude controlled substances
if (empty($controlledSubstanceCheck)) {
// Not a controlled substance, so include in denominator.
return true;
}
else {
// Is a controlled substance, so exclude from denominator.
return false;
}
}

}
19 changes: 8 additions & 11 deletions library/classes/rulesets/Amc/reports/AMC_304b_STG1/Numerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,13 @@ public function getTitle()

public function test( AmcPatient $patient, $beginDate, $endDate )
{
//The number of prescriptions in the denominator transmitted electronically
//
// Still TODO
// AMC MU2 TODO :
// Note OpenEMR official codebase does not support the eTransmit item
//
if($patient->object['eTransmit'] == 1) {
return true;
}else{
return false;
}
// The number of prescriptions in the denominator transmitted electronically.
$amcElement = amcCollect('e_prescribe_amc',$patient->id,'prescriptions',$patient->object['id']);
if (!(empty($amcElement))) {
return true;
}
else {
return false;
}
}
}
12 changes: 10 additions & 2 deletions sql/4_2_0-to-4_2_1_upgrade.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12259,7 +12259,7 @@ INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `is_default`

#IfNotRow2D list_options list_id clinical_rules option_id e_prescribe_stage1_amc
INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `mapping`, `notes`, `codes`, `toggle_setting_1`, `toggle_setting_2`) VALUES
('clinical_rules', 'e_prescribe_stage1_amc', 'Generate and transmit permissible prescriptions electronically (Uncontrolled Substances).', 50, 0, 0, '', '', '', 0, 0);
('clinical_rules', 'e_prescribe_stage1_amc', 'Generate and transmit permissible prescriptions electronically (Not including controlled substances).', 50, 0, 0, '', '', '', 0, 0);
#EndIf

#IfNotRow clinical_rules id e_prescribe_1_stage2_amc
Expand All @@ -12281,7 +12281,7 @@ INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `is_default`

#IfNotRow2D list_options list_id clinical_rules option_id e_prescribe_2_stage2_amc
INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `mapping`, `notes`, `codes`, `toggle_setting_1`, `toggle_setting_2`) VALUES
('clinical_rules', 'e_prescribe_2_stage2_amc', 'Generate and transmit permissible prescriptions electronically (Uncontrolled substances with drug formulary).', 50, 0, 0, '', '', '', 0, 0);
('clinical_rules', 'e_prescribe_2_stage2_amc', 'Generate and transmit permissible prescriptions electronically (Not including controlled substances).', 50, 0, 0, '', '', '', 0, 0);
#EndIf

#IfMissingColumn users cpoe
Expand Down Expand Up @@ -12584,3 +12584,11 @@ INSERT INTO `rule_reminder` ( `id`, `method`, `method_detail`, `value` ) VALUES
INSERT INTO `rule_target` ( `id`, `group_id`, `include_flag`, `required_flag`, `method`, `value`, `interval` ) VALUES ('rule_socsec_entry', 1, 1, 1, 'target_database', '::patient_data::ss::::::ge::1', 0);
#EndIf

#IfRow2D list_options list_id clinical_rules option_id e_prescribe_stage1_amc
UPDATE `list_options` SET `title` = 'Generate and transmit permissible prescriptions electronically (Not including controlled substances).' WHERE list_id = 'clinical_rules' AND option_id = 'e_prescribe_stage1_amc';
#EndIf

#IfRow2D list_options list_id clinical_rules option_id e_prescribe_2_stage2_amc
UPDATE `list_options` SET `title` = 'Generate and transmit permissible prescriptions electronically (Not including controlled substances).' WHERE list_id = 'clinical_rules' AND option_id = 'e_prescribe_2_stage2_amc';
#EndIf

4 changes: 2 additions & 2 deletions sql/database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3716,11 +3716,11 @@ INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `is_default`
INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `mapping`, `notes`, `codes`, `toggle_setting_1`, `toggle_setting_2`) VALUES
('clinical_rules', 'send_sum_stage2_amc', 'The EP, eligible hospital or CAH who transitions their patient to another setting of care or provider of care or refers their patient to another provider of care should provide summary of care record for each transition of care or referral (Measure B).', 80, 0, 0, '', '', '', 0, 0);
INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `mapping`, `notes`, `codes`, `toggle_setting_1`, `toggle_setting_2`) VALUES
('clinical_rules', 'e_prescribe_stage1_amc', 'Generate and transmit permissible prescriptions electronically (Uncontrolled Substances).', 50, 0, 0, '', '', '', 0, 0);
('clinical_rules', 'e_prescribe_stage1_amc', 'Generate and transmit permissible prescriptions electronically (Not including controlled substances).', 50, 0, 0, '', '', '', 0, 0);
INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `mapping`, `notes`, `codes`, `toggle_setting_1`, `toggle_setting_2`) VALUES
('clinical_rules', 'e_prescribe_1_stage2_amc', 'Generate and transmit permissible prescriptions electronically (All Prescriptions).', 50, 0, 0, '', '', '', 0, 0);
INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `mapping`, `notes`, `codes`, `toggle_setting_1`, `toggle_setting_2`) VALUES
('clinical_rules', 'e_prescribe_2_stage2_amc', 'Generate and transmit permissible prescriptions electronically (Uncontrolled substances with drug formulary).', 50, 0, 0, '', '', '', 0, 0);
('clinical_rules', 'e_prescribe_2_stage2_amc', 'Generate and transmit permissible prescriptions electronically (Not including controlled substances).', 50, 0, 0, '', '', '', 0, 0);

-- order types
INSERT INTO list_options ( list_id, option_id, title, seq, is_default ) VALUES ('lists','order_type','Order Types', 1,0);
Expand Down
17 changes: 17 additions & 0 deletions templates/prescription/general_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,23 @@
<input type="checkbox" id="escribe_flag" name="escribe_flag" checked>
{/if}
<span class="text">{xl t='E-Prescription?'}</span><br>

{amcCollect amc_id='e_prescribe_chk_formulary_amc' patient_id=$prescription->patient->id object_category='prescriptions' object_id=$prescription->id}
{if not $amcCollectReturn}
<input type="checkbox" id="checked_formulary_flag" name="checked_formulary_flag">
{else}
<input type="checkbox" id="checked_formulary_flag" name="checked_formulary_flag" checked>
{/if}
<span class="text">{xl t='Checked Drug Formulary?'}</span><br>

{amcCollect amc_id='e_prescribe_cont_subst_amc' patient_id=$prescription->patient->id object_category='prescriptions' object_id=$prescription->id}
{if not $amcCollectReturn}
<input type="checkbox" id="controlled_substance_flag" name="controlled_substance_flag">
{else}
<input type="checkbox" id="controlled_substance_flag" name="controlled_substance_flag" checked>
{/if}
<span class="text">{xl t='Controlled Substance?'}</span><br>

</div>
</div>
{php} } {/php}
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// is a database change in the course of development. It is used
// internally to determine when a database upgrade is needed.
//
$v_database = 149;
$v_database = 150;

// Access control version identifier, this is to be incremented whenever there
// is a access control change in the course of development. It is used
Expand Down

0 comments on commit ffe1ea6

Please sign in to comment.