diff --git a/app/Controllers/Patient.php b/app/Controllers/Patient.php index 44cdf7c..92bef06 100644 --- a/app/Controllers/Patient.php +++ b/app/Controllers/Patient.php @@ -19,11 +19,11 @@ class Patient extends Controller { $PatientID = $this->request->getVar('PatientID'); $Name = $this->request->getVar('Name'); $BirthDate = $this->request->getVar('BirthDate'); - + $qname = "LOWER(CONCAT_WS(' ', IFNULL(Prefix,''), IFNULL(NameFirst,''), IFNULL(NameMiddle,''), IFNULL(NameLast,''), IFNULL(NameMaiden,''), IFNULL(Suffix,'')))"; $builder = $this->db->table('patient'); - + $builder->select("InternalPID, PatientID, $qname as FullName, Gender, BirthDate"); if ($Name !== null) { - $sql = "LOWER(CONCAT_WS(' ', IFNULL(Prefix,''), IFNULL(NameFirst,''), IFNULL(NameMiddle,''), IFNULL(NameLast,''), IFNULL(NameMaiden,''), IFNULL(Suffix,'')))"; + $sql = $qname; $rawSql = new RawSql($sql); $builder->like($rawSql, $Name, 'both'); }