Integrating the problem list improvements with the recent fee sheet improvements...
authorbradymiller <bradymiller@users.sourceforge.net>
Wed, 13 Mar 2013 06:59:54 +0000 (12 23:59 -0700)
committerbradymiller <bradymiller@users.sourceforge.net>
Sat, 16 Mar 2013 09:50:51 +0000 (16 02:50 -0700)
custom/code_types.inc.php
interface/forms/fee_sheet/review/fee_sheet_classes.php
interface/forms/fee_sheet/review/fee_sheet_justify_view_model.js
interface/forms/fee_sheet/review/fee_sheet_queries.php
interface/forms/fee_sheet/review/views/justify_display.php

index 7d668cd..f647b67 100644 (file)
@@ -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
index 8a75996..549b510 100644 (file)
@@ -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()
index 2d33366..27a26f6 100644 (file)
@@ -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
+}
index 0ee6b05..2b074d9 100644 (file)
@@ -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;
             
index 2cb8696..5b0a169 100644 (file)
@@ -59,7 +59,7 @@
                 <tr data-bind="attr:{class: source, encounter_issue: encounter_issue}">
                     <td class="priority" data-bind="text: priority()!=99999 ? priority() : ''"/></td>
                     <td class="checkbox"><input type="checkbox" data-bind="checked: selected, event:{click: function(data,event){return check_justify(data,event,$parent);}}" /></td>
-                    <td class="problem_info"><input type="checkbox" data-bind="visible: $data.prob_id()==null,checked: create_problem" title="<?php echo xla('Check to create problem from this diagnosis');?>"/></td>
+                    <td class="problem_info"><input type="checkbox" data-bind="visible: $data.prob_id()==null && $data.allowed_to_create_problem_from_diagnosis()=='TRUE', checked: create_problem" title="<?php echo xla('Check to create problem from this diagnosis');?>"/></td>
                     <td class="info" data-bind="text: code, attr:{title:code_type}"></td>
                     <td class="info">
                         <span title="<?php echo xla('Click to edit description'); ?>" data-bind="text: description, visible: !edit_mode(), event: {click: start_edit}"></span>
@@ -73,4 +73,4 @@
             <input class="cancel_dialog" type="button" data-bind="click: cancel_justify" value="<?php echo xla("Cancel");?>"/>
         </div>
     </div>
-</script>
\ No newline at end of file
+</script>