diff --git a/interface/patient_file/reminder/clinical_reminders.php b/interface/patient_file/reminder/clinical_reminders.php index 29b84ba116e..aa48ae16419 100644 --- a/interface/patient_file/reminder/clinical_reminders.php +++ b/interface/patient_file/reminder/clinical_reminders.php @@ -60,7 +60,8 @@
@@ -85,6 +86,55 @@
+ + + + + + + + + + + + + + + + +
'1','list_id'=>'clinical_plans'), $plan['id']); ?> + + + + +
+
+
@@ -197,6 +247,16 @@ }); }); + $(".plan_show").change(function() { + top.restoreSession(); + $.post( "../../../library/ajax/plan_setting.php", { + plan: this.name, + type: 'normal', + setting: this.value, + patient_id: '' + }); + }); + $(".medium_modal").fancybox( { 'overlayOpacity' : 0.0, 'showCloseButton' : true, diff --git a/library/ajax/plan_setting.php b/library/ajax/plan_setting.php new file mode 100644 index 00000000000..9bbde956bb1 --- /dev/null +++ b/library/ajax/plan_setting.php @@ -0,0 +1,30 @@ + +// +// 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. +// +// +// This file contains functions that manage custom user +// settings +// + +//SANITIZE ALL ESCAPES +$sanitize_all_escapes=true; +// + +//STOP FAKE REGISTER GLOBALS +$fake_register_globals=false; +// + +require_once(dirname(__FILE__) . "/../../interface/globals.php"); +require_once(dirname(__FILE__) . "/../clinical_rules.php"); + +//set the rule setting for patient (ensure all variables exist) +if ($_POST['plan'] && $_POST['type'] && $_POST['setting'] && $_POST['patient_id']) { + set_plan_activity_patient($_POST['plan'], $_POST['type'], $_POST['setting'], $_POST['patient_id']); +} + +?> diff --git a/library/clinical_rules.php b/library/clinical_rules.php index 829433fc2a4..fe590045f9b 100644 --- a/library/clinical_rules.php +++ b/library/clinical_rules.php @@ -641,7 +641,7 @@ function resolve_plans_sql($type='',$patient_id='0',$configurableOnly=FALSE) { if ($configurableOnly) { // Collect all default, configurable (per patient) plans into an array // (ie. ignore the cqm rules) - $sql = sqlStatement("SELECT * FROM `clinical_plans` WHERE `pid`=0 AND `cqm` !=1 ORDER BY `id`"); + $sql = sqlStatement("SELECT * FROM `clinical_plans` WHERE `pid`=0 AND `cqm_flag` !=1 ORDER BY `id`"); } else { // Collect all default plans into an array @@ -705,6 +705,59 @@ function resolve_plans_sql($type='',$patient_id='0',$configurableOnly=FALSE) { return $returnArray; } +// Function to return a specific plan +// Parameters: +// $plan - id(string) of plan +// $patient_id - pid of selected patient. (if set to 0, then will return +// the default rule). +// Return: array containing a rule +function collect_plan($plan,$patient_id='0') { + + return sqlQuery("SELECT * FROM `clinical_plans` WHERE `id`=? AND `pid`=?", array($plan,$patient_id) ); + +} + +// Function to set a specific plan activity for a specific patient +// Parameters: +// $plan - id(string) of plan +// $type - plan filter (normal,cqm) +// $setting - activity of plan (yes,no,default) +// $patient_id - pid of selected patient. +// Return: nothing +function set_plan_activity_patient($plan,$type,$setting,$patient_id) { + + // Don't allow messing with the default plans here + if ($patient_id == "0") { + return; + } + + // Convert setting + if ($setting == "on") { + $setting = 1; + } + else if ($setting == "off") { + $setting = 0; + } + else { // $setting == "default" + $setting = NULL; + } + + // Collect patient specific plan, if already exists. + $query = "SELECT * FROM `clinical_plans` WHERE `id` = ? AND `pid` = ?"; + $patient_plan = sqlQuery($query, array($plan,$patient_id) ); + + if (empty($patient_plan)) { + // Create a new patient specific plan with flags all set to default + $query = "INSERT into `clinical_plans` (`id`, `pid`) VALUES (?,?)"; + sqlStatement($query, array($plan, $patient_id) ); + } + + // Update patient specific row + $query = "UPDATE `clinical_plans` SET `" . add_escape_custom($type) . "_flag`= ? WHERE id = ? AND pid = ?"; + sqlStatement($query, array($setting,$plan,$patient_id) ); + +} + // Function to return active rules // Parameters: // $type - rule filter (active_alert,passive_alert,cqm,amc,patient_reminder) @@ -840,8 +893,6 @@ function set_rule_activity_patient($rule,$type,$setting,$patient_id) { $query = "SELECT * FROM `clinical_rules` WHERE `id` = ? AND `pid` = ?"; $patient_rule = sqlQuery($query, array($rule,$patient_id) ); - error_log("DEBUG :".$rule.$type.$setting.$patient_id,0); - if (empty($patient_rule)) { // Create a new patient specific rule with flags all set to default $query = "INSERT into `clinical_rules` (`id`, `pid`) VALUES (?,?)";