Skip to content

Commit

Permalink
Ev/cdr bug fix (openemr#360)
Browse files Browse the repository at this point in the history
* Fix for cdr: cdr engine does not ignore deleted forms
  • Loading branch information
eyalvo-matrix authored and bradymiller committed Dec 6, 2016
1 parent 889a6e8 commit e61153d
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions library/clinical_rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -1914,13 +1914,28 @@ function exist_database_item($patient_id,$table,$column='',$data_comp,$data='',$
"WHERE " . add_escape_custom($patient_id_label) . "=? " . $customSQL, array($patient_id) );
}
else {
// search for number of specific items
$sql = sqlStatementCdrEngine("SELECT `" . add_escape_custom($column) . "` " .
"FROM `" . add_escape_custom($table) . "` " .
" ". $whereTables. " ".
"WHERE `" . add_escape_custom($column) ."`" . $compSql . "? " .
"AND " . add_escape_custom($patient_id_label) . "=? " . $customSQL .
$dateSql, array($data,$patient_id) );
if ($whereTables=="" && strpos($table, 'form_')!== false){
//To handle standard forms starting with form_
$sql =sqlStatementCdrEngine(
"SELECT b.`" . add_escape_custom($column) . "` " .
"FROM forms a ".
"LEFT JOIN `" . add_escape_custom($table) . "` " . " b ".
"ON (a.form_id=b.id AND a.formdir LIKE '".add_escape_custom(substr($table, 5))."')".
"WHERE a.deleted != '1'".
"AND b.`" .add_escape_custom($column) ."`" . $compSql . "? " .
"AND b." . add_escape_custom($patient_id_label) . "=? " . $customSQL
.substr_replace($dateSql,'b.',5,0)
,array($data, $patient_id));
}
else {
// search for number of specific items
$sql = sqlStatementCdrEngine("SELECT `" . add_escape_custom($column) . "` " .
"FROM `" . add_escape_custom($table) . "` " .
" " . $whereTables . " " .
"WHERE `" . add_escape_custom($column) . "`" . $compSql . "? " .
"AND " . add_escape_custom($patient_id_label) . "=? " . $customSQL .
$dateSql, array($data, $patient_id));
}
}

// See if number of returned items passes the comparison
Expand Down

0 comments on commit e61153d

Please sign in to comment.