From a5f14e43b11cf1c2cfb853168f40e79cee68df69 Mon Sep 17 00:00:00 2001 From: bradymiller Date: Tue, 12 Mar 2013 23:59:54 -0700 Subject: [PATCH] Integrating the problem list improvements with the recent fee sheet improvements, take 3. --- custom/code_types.inc.php | 20 ++++++++++++++++++++ .../forms/fee_sheet/review/fee_sheet_classes.php | 11 +++++++++++ .../fee_sheet/review/fee_sheet_justify_view_model.js | 9 ++++++++- .../forms/fee_sheet/review/fee_sheet_queries.php | 11 +++++++++-- .../forms/fee_sheet/review/views/justify_display.php | 4 ++-- 5 files changed, 50 insertions(+), 5 deletions(-) diff --git a/custom/code_types.inc.php b/custom/code_types.inc.php index 7d668cd10..f647b6753 100644 --- a/custom/code_types.inc.php +++ b/custom/code_types.inc.php @@ -238,6 +238,26 @@ function convert_type_id_to_key($id) { } /** + * Checks if a key string (ct_key) is selected for an element/filter(s) + * + * @param string $key + * @param array $filter (array of elements that can include 'active','fee','rel','nofs','diag','claim','proc','term','problem') + * @return boolean + */ +function check_code_set_filters($key,$filters=array()) { + global $code_types; + + if (empty($filters)) return false; + + foreach ($filters as $filter) { + if ($code_types[$key][$filter] != 1) return false; + } + + // Filter was passed + return true; +} + +/** * Return listing of pertinent and active code types. * * Function will return listing (ct_key) of pertinent diff --git a/interface/forms/fee_sheet/review/fee_sheet_classes.php b/interface/forms/fee_sheet/review/fee_sheet_classes.php index 8a75996b0..549b51054 100644 --- a/interface/forms/fee_sheet/review/fee_sheet_classes.php +++ b/interface/forms/fee_sheet/review/fee_sheet_classes.php @@ -24,6 +24,9 @@ * This is an encapsulation of code, code_type and description representing * a code */ + +require_once("$srcdir/../custom/code_types.inc.php"); + class code_info { function __construct($c,$ct,$desc,$selected=true) @@ -32,12 +35,20 @@ class code_info $this->code_type=$ct; $this->description=$desc; $this->selected=$selected; + // check if the code type is active and allowed to create medical problems from diagnosis elements + $this->allowed_to_create_problem_from_diagnosis="FALSE"; + if (check_code_set_filters($ct,array("active","problem"))) $this->allowed_to_create_problem_from_diagnosis="TRUE"; + // check if the code type is active and allowed to create diagnosis elements from medical problems + $this->allowed_to_create_diagnosis_from_problem="FALSE"; + if (check_code_set_filters($ct,array("active","diag"))) $this->allowed_to_create_diagnosis_from_problem="TRUE"; } public $code; public $code_type; public $description; public $selected; public $db_id; + public $allowed_to_create_problem_from_diagnosis; + public $allowed_to_create_diagnosis_from_problem; public $create_problem; public function getKey() diff --git a/interface/forms/fee_sheet/review/fee_sheet_justify_view_model.js b/interface/forms/fee_sheet/review/fee_sheet_justify_view_model.js index 2d3336612..27a26f6da 100644 --- a/interface/forms/fee_sheet/review/fee_sheet_justify_view_model.js +++ b/interface/forms/fee_sheet/review/fee_sheet_justify_view_model.js @@ -52,6 +52,7 @@ function justify_entry(json_object) retval.encounter_issue=ko.observable(false); retval.edit_mode=ko.observable(false); retval.prob_id=ko.observable(); + retval.allowed_to_create_problem_from_diagnosis=ko.observable(); retval.create_problem=ko.observable(false); retval.jsonify=function() { @@ -59,6 +60,7 @@ function justify_entry(json_object) json.code=this.code(); json.code_type=this.code_type(); json.description=this.description(); + json.allowed_to_create_problem_from_diagnosis=this.allowed_to_create_problem_from_diagnosis(); json.prob_id=this.prob_id(); json.create_problem=this.create_problem(); return json; @@ -287,6 +289,7 @@ function setup_justify(model,current,patient,common) //new_justify.priority(idx+1); new_justify.source='current'; new_justify.source_idx=idx; + new_justify.allowed_to_create_problem_from_diagnosis(cur_entry.allowed_to_create_problem_from_diagnosis); model.diagnosis_options.push(new_justify); } @@ -309,6 +312,7 @@ function setup_justify(model,current,patient,common) new_justify.source='patient'; new_justify.source_idx=idx; new_justify.prob_id(cur_entry.db_id); + new_justify.allowed_to_create_problem_from_diagnosis(cur_entry.allowed_to_create_problem_from_diagnosis); model.diagnosis_options.push(new_justify); } else @@ -317,6 +321,7 @@ function setup_justify(model,current,patient,common) if((entry.prob_id()!=null) &&(entry.prob_id()!=cur_entry.db_id)) { new_justify.prob_id(cur_entry.db_id); + new_justify.allowed_to_create_problem_from_diagnosis(cur_entry.allowed_to_create_problem_from_diagnosis); if(model.duplicates().length==0) { model.duplicates.push(entry); @@ -326,6 +331,7 @@ function setup_justify(model,current,patient,common) else { entry.prob_id(cur_entry.db_id); + entry.allowed_to_create_problem_from_diagnosis(cur_entry.allowed_to_create_problem_from_diagnosis); entry.description(cur_entry.description); if(cur_entry.selected) { @@ -346,6 +352,7 @@ function setup_justify(model,current,patient,common) lookup_justify(model.current_justify(),new_justify); new_justify.source='common'; new_justify.source_idx=idx; + new_justify.allowed_to_create_problem_from_diagnosis(cur_entry.allowed_to_create_problem_from_diagnosis); model.diagnosis_options.push(new_justify); } } @@ -394,4 +401,4 @@ function fee_sheet_justify_view_model(billing_id,enc_id,pat_id,current_justify) }, "json"); return this; -} \ No newline at end of file +} diff --git a/interface/forms/fee_sheet/review/fee_sheet_queries.php b/interface/forms/fee_sheet/review/fee_sheet_queries.php index 0ee6b05df..2b074d99a 100644 --- a/interface/forms/fee_sheet/review/fee_sheet_queries.php +++ b/interface/forms/fee_sheet/review/fee_sheet_queries.php @@ -49,7 +49,7 @@ function update_issues($pid,$encounter,$diags) $target_date=$res['date']; $lists_params=array(); $encounter_params=array(); - $sqlUpdateIssueDescription="UPDATE lists SET title=? WHERE id=? AND TITLE!=?"; + $sqlUpdateIssueDescription="UPDATE lists SET title=?, modifydate=NOW() WHERE id=? AND TITLE!=?"; $sqlFindProblem = "SELECT id, title FROM lists WHERE "; $sqlFindProblem.= " ( (`begdate` IS NULL) OR (`begdate` IS NOT NULL AND `begdate`<=?) ) AND " ; array_push($lists_params,$target_date); @@ -64,10 +64,13 @@ function update_issues($pid,$encounter,$diags) $sqlCreateIssueEncounter = " INSERT into issue_encounter(pid,list_id,encounter)values (?,?,?) "; - $sqlCreateProblem = " INSERT into lists(date,begdate,type,occurrence,classification,pid,diagnosis,title) values(?,?,'medical_problem',0,0,?,?,?)"; + $sqlCreateProblem = " INSERT into lists(date,begdate,type,occurrence,classification,pid,diagnosis,title,modifydate) values(?,?,'medical_problem',0,0,?,?,?,NOW())"; $idx_list_id=count($encounter_params)-1; foreach($diags as $diags) { + // ensure that a problem is allowed to be created from the diagnostic element + if ($diags->allowed_to_create_problem_from_diagnosis != "TRUE") continue; + $diagnosis_key=$diags->code_type.":".$diags->code; $list_id=null; if($diags->db_id!=null) @@ -252,6 +255,10 @@ function issue_diagnoses($pid,$encounter) $code=$diagnosis[1]; $code_type=$diagnosis[0]; $new_info=new code_info($code,$code_type,$title,$res['selected']!=0); + + //ensure that a diagnostic element is allowed to be created from a problem element + if ($new_info->allowed_to_create_diagnosis_from_problem != "TRUE") continue; + $new_info->db_id=$db_id; $retval[]=$new_info; diff --git a/interface/forms/fee_sheet/review/views/justify_display.php b/interface/forms/fee_sheet/review/views/justify_display.php index 2cb86965a..5b0a169e5 100644 --- a/interface/forms/fee_sheet/review/views/justify_display.php +++ b/interface/forms/fee_sheet/review/views/justify_display.php @@ -59,7 +59,7 @@ - + @@ -73,4 +73,4 @@ "/> - \ No newline at end of file + -- 2.11.4.GIT