Skip to content

Commit

Permalink
Integrating the problem list improvements with the recent fee sheet i…
Browse files Browse the repository at this point in the history
…mprovements, take 3.
  • Loading branch information
bradymiller committed Mar 16, 2013
1 parent ba952a1 commit a5f14e4
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 5 deletions.
20 changes: 20 additions & 0 deletions custom/code_types.inc.php
Expand Up @@ -237,6 +237,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.
*
Expand Down
11 changes: 11 additions & 0 deletions interface/forms/fee_sheet/review/fee_sheet_classes.php
Expand Up @@ -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)
Expand All @@ -32,12 +35,20 @@ function __construct($c,$ct,$desc,$selected=true)
$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()
Expand Down
Expand Up @@ -52,13 +52,15 @@ 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()
{
var json={};
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;
Expand Down Expand Up @@ -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);

}
Expand All @@ -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
Expand All @@ -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);
Expand All @@ -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)
{
Expand All @@ -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);
}
}
Expand Down Expand Up @@ -394,4 +401,4 @@ function fee_sheet_justify_view_model(billing_id,enc_id,pat_id,current_justify)
},
"json");
return this;
}
}
11 changes: 9 additions & 2 deletions interface/forms/fee_sheet/review/fee_sheet_queries.php
Expand Up @@ -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);
Expand All @@ -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)
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions interface/forms/fee_sheet/review/views/justify_display.php
Expand Up @@ -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>
Expand All @@ -73,4 +73,4 @@
<input class="cancel_dialog" type="button" data-bind="click: cancel_justify" value="<?php echo xla("Cancel");?>"/>
</div>
</div>
</script>
</script>

2 comments on commit a5f14e4

@yehster
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just hiding the checkbox when it's not an "allowed code type" doesn't work properly as the checkbox still exists and gets set invisibly.

@bradymiller
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if set for a code type that is not allowed, it will not be processed (see code above).

Please sign in to comment.