Bug for search for patient from patient finder using "care_team_facility" as a column

Situation
There appears to have a bug, when I added patient care team facility as one of the columns in patient finder, it does not search by facilities.

OpenEMR Version
I’m using OpenEMR version 7

Browser:
I’m using: Chrome

Operating System
I’m using: Windows 10

Logs
Did you check the logs?
Was there anything pertinent in them?
Please paste them here (surround with three backticks (```) for readability.
You can also turn on User Debugging under Administration->Globals->Logging User Debugging Options=>All

Hi Bo Wang,

put this code on dynamic_finder_ajax.php next to line number 151 and after this paste the same code on the line number next to 218

elseif ($colname == ‘care_team_facility’) {
if(ctype_digit($sSearch)) {

            $where .= "`" . escape_sql_column_name($colname, array('patient_data')) . "` LIKE ? ";
            array_push($srch_bind, ($sSearch . '%'));
           
           }
           else
           {
            $row = sqlQuery("SELECT id FROM facility WHERE name like ?", array("%".$sSearch."%"));
            //print_r($row['id']);exit();
            if(!empty($row['id']))
            {
            $where .= "`" . escape_sql_column_name($colname, array('patient_data')) . "` LIKE ? ";
            array_push($srch_bind, ($row['id'] . '%'));
            
            }
            else
            {

                $where .= "`" . escape_sql_column_name($colname, array('patient_data')) . "` LIKE ? ";
            array_push($srch_bind, ($sSearch . '%'));  
            }
        }
       
    }

Thanks
Param
help@capminds.com

1 Like

what if i need to add column to finder from Insurance and provider data ??

hello @yaqeen
This question is related to the other one you posted yesterday,

I can’t speak to the usefulness of the code in the earlier post of this thread (from 2022), but your quest to use the Finder to locate data from other tables will not work: the Finder is coded to only look in the patient_data table, and the data you want is not kept there.

https://www.open-emr.org/wiki/index.php/HOWTO:_Change_Search_Columns_in_Patient_Finder

If you really need to have those data displayed in the Finder screen you would need to add columns for them on the page, and re-write the MySQL query that the Finder executes. You would need to add a JOIN on the the pid value between patient_data and insurance_data to pull those columns out of insurance_data.

That is the programming that the OP in the other post said would be needed. But the Finder is not capable of doing what you want in its current state.

Good luck!

  • Harley

Thank you Harley
regard to my question i try to find the query for finder in dynamic_finder.php and dynamic_finder_ajax.php to edit the query to join it with other tables but i cant find it . its look like the finder use the demographics layout to bring the data into finder

any recommendation where will be the code modification ?

Hi @yaqeen
I know some principles of coding from my past learning and use of BASIC, COBOL, PERL and a few other languages. But I do not know php or the internal workings of OpenEMR so, sorry I cannot recommend code modification to accomplish this.
Good luck!

  • Harley