From: Kevin Yeh Date: Sat, 9 Feb 2013 02:16:23 +0000 (-0500) Subject: alternate --ALL-- fix X-Git-Tag: whats-been-changed~412 X-Git-Url: https://repo.or.cz/w/openemr.git/commitdiff_plain/e904c8aafde0bef90845e0424cef77e876638f08 alternate --ALL-- fix --- diff --git a/custom/code_types.inc.php b/custom/code_types.inc.php index 7d876b711..152b3eb0e 100644 --- a/custom/code_types.inc.php +++ b/custom/code_types.inc.php @@ -359,9 +359,8 @@ function code_set_search($form_code_type,$search_term="",$count=false,$active=tr if ( $table_id==0 || ($form_code_type == '--ALL--') ) { // Search from default codes table. --ALL-- only means all codes in the default tables if($table_id==0){ $table_info[EXT_FILTER_CLAUSES]=array("code_type=".$code_types[$form_code_type]['id']); } // Add a filter for the code type - else {$table_info[EXT_FILTER_CLAUSES]=array("ct_external=0");} // define filter array for "--ALL--" + else {$table_info[EXT_FILTER_CLAUSES]=array("ct.ct_external=0");} // define filter array for "--ALL--" $table_dot="c."; // $table_dot is used to prevent awkward looking concatenations when referring to columns in - $table_dot_all="ct."; // special case used in the where filter clause for the --ALL-- searching $code_col="code"; $code_text_col="code_text"; @@ -500,13 +499,14 @@ function code_set_search($form_code_type,$search_term="",$count=false,$active=tr // Add the metadata related filter clauses foreach($table_info[EXT_FILTER_CLAUSES] as $filter_clause) { - if ($form_code_type == '--ALL--') { - // special case in the ALL search - $query .= " AND ".$table_dot_all.$filter_clause; + $query.=" AND "; + $dot_location=strpos($filter_clause,"."); + if($dot_location!==false) { + // The filter clause already includes a table specifier, so don't add one + $query .=$filter_clause; } else { - // normal case - $query .= " AND ".$table_dot.$filter_clause; + $query .=$table_dot.$filter_clause; } }