Update Index untuk search

This commit is contained in:
mikael-zakaria 2025-08-04 13:21:13 +07:00
parent 68c7ceeced
commit 475c10a6d6

View File

@ -15,24 +15,26 @@ class Patient extends Controller {
// OK - Done // OK - Done
public function index() { public function index() {
try { try {
$InternalPID = $this->request->getVar('InternalPID');
$PatientID = $this->request->getVar('PatientID'); $PatientID = $this->request->getVar('PatientID');
$AlternatePID = $this->request->getVar('AlternatePID'); // $AlternatePID = $this->request->getVar('AlternatePID');
$Prefix = $this->request->getVar('Prefix'); // $Prefix = $this->request->getVar('Prefix');
$name = $this->request->getVar('Name'); $Name = $this->request->getVar('Name');
$Suffix = $this->request->getVar('Suffix'); // $Suffix = $this->request->getVar('Suffix');
$BirthDate = $this->request->getVar('BirthDate'); $BirthDate = $this->request->getVar('BirthDate');
$startDate = $this->request->getVar('StartDate'); // $startDate = $this->request->getVar('StartDate');
$endDate = $this->request->getVar('EndDate'); // $endDate = $this->request->getVar('EndDate');
$builder = $this->db->table('patient'); $builder = $this->db->table('patient');
if ($name !== null) { if ($Name !== null) {
$sql = "LOWER(CONCAT_WS(' ', IFNULL(prefix,''), IFNULL(name_first,''), IFNULL(name_middle,''), IFNULL(name_last,''), IFNULL(name_maiden,''), IFNULL(suffix,'')))"; $sql = "LOWER(CONCAT_WS(' ', IFNULL(prefix,''), IFNULL(name_first,''), IFNULL(name_middle,''), IFNULL(name_last,''), IFNULL(name_maiden,''), IFNULL(suffix,'')))";
$rawSql = new RawSql($sql); $rawSql = new RawSql($sql);
$builder->like($rawSql, $name, 'both'); $builder->like($rawSql, $Name, 'both');
} }
if ($PatientID !== null) { $builder->where('PatientID', $pat_num); } if ($InternalPID !== null) { $builder->where('InternalPID', $InternalPID); }
if ($AlternatePID !== null) { $builder->where('AlternatePID', $pat_altnum); } if ($PatientID !== null) { $builder->where('PatientID', $PatientID); }
// if ($AlternatePID !== null) { $builder->where('AlternatePID', $pat_altnum); }
if ($BirthDate !== null) { $builder->where('BirthDate', $pat_dob); } if ($BirthDate !== null) { $builder->where('BirthDate', $pat_dob); }
/* /*
if ($startDate !== null || $endDate !== null) { if ($startDate !== null || $endDate !== null) {