Calendar patient search, different format than patient search, can they be the same?

chriskuhar wrote on Friday, January 17, 2014:

we noticed that from the “Patients” page, entering a single name, first name and last name are searched.

Select “Calendar” -> “click available time popup” -> “Patient Select popup” It follows the format

LastName, Firstname

if you want to search by just first name

, FirstName

NOTE: leading comma.

The following code change would be nice to have in the product so both searches worked similiar:

diff --git a/library/patient.inc b/library/patient.inc
index 732c4a7…1913c89 100644
— a/library/patient.inc
+++ b/library/patient.inc
@@ -410,7 +410,17 @@ function getPatientLnames($lname = “%”, $given = "pid, id, lname, fname, mname,
if ((strlen($fname) < 1)|| ($fname{0} != strtoupper($fname{0}))) {$search_for_pieces2 = ‘%’;}

 $sqlBindArray = array();
  • $where = "lname LIKE ? AND fname LIKE ? ";
  • // making consistant with search in rest of product
  • // check both first and last if just one name is given
  • //
  • if(strlen($fname) < 1) {
  •   $fname = $lname;
    
  •   $where = "lname LIKE ? OR fname LIKE ? ";
    
  • } else {
  •   $where = "lname LIKE ? AND fname LIKE ? ";
    
  • }
  • array_push($sqlBindArray, $search_for_pieces1.$lname."%", $search_for_pieces2.$fname."%");
    if (!empty($GLOBALS[‘pt_restrict_field’])) {
    if ( $_SESSION{“authUser”} != ‘admin’ || $GLOBALS[‘pt_restrict_admin’] ) {

mdsupport wrote on Friday, January 17, 2014:

Few months ago we switched to inline search using Select2. Here is a function that saves at least 10-15 seconds per search. These time savings add up very quickly for a busy practice.

    $sql = "SELECT pid id, concat_ws('',IF(IFNULL(deceased_date,0)=0,'','*')
            ,lname,', ', fname, ' (',dob,')') text  ".
           "FROM patient_data ".
           'WHERE CONCAT_WS("\t",lname,fname,mname,dob) LIKE ? '.
           'ORDER BY IFNULL(deceased_date,0) ASC '.
           'LIMIT 20';
    $rs = sqlStatement($sql, array($qry));

User input to the function is altered here prior to function call

$qry = '%'.preg_replace('/\s+/', '%', $qry).'%';

Throughout the application if looking for jane doe with dob Jan 26 1947, user can begin typing something as obscure as do j 47 26 and ajax lookup does wildcard search after first 2 characters have been entered. All searches are routed through a single function so future changes will be universal.

Something you should also think about is deceased patients are displayed lower in the list with ‘*’.