diff --git a/application/controllers/klinik/Registrationv3.php b/application/controllers/klinik/Registrationv3.php index b3634435..7dab1117 100644 --- a/application/controllers/klinik/Registrationv3.php +++ b/application/controllers/klinik/Registrationv3.php @@ -864,7 +864,10 @@ class Registrationv3 extends MY_Controller $number_offset = (!isset($prm['current_page']) ? 1 : $prm['current_page'] - 1) * $number_limit; $where_noreg = ''; - $where_nik = ''; + $where_name = ''; + $where_hp = ''; + $where_dob = ''; + $where_idnum = ''; $where_snorm = ''; if (!empty($prm['noreg'])) { @@ -877,8 +880,6 @@ class Registrationv3 extends MY_Controller } elseif (!empty($prm['search'])) { $e = explode('+', $prm['search']); - $field_conds = []; - if (!empty($e[0]) && mb_strlen(trim($e[0])) >= 3) { $toks = $this->ibl_encryptor->query_tokens($e[0]); $conds = []; @@ -886,7 +887,7 @@ class Registrationv3 extends MY_Controller $tok_esc = $this->db_onedev->escape_str($tok); $conds[] = "JSON_CONTAINS(M_PatientName_bidx, '\"$tok_esc\"')"; } - if ($conds) $field_conds[] = '(' . implode(' AND ', $conds) . ')'; + if ($conds) $where_name = 'AND (' . implode(' AND ', $conds) . ')'; } if (!empty($e[1]) && mb_strlen(trim($e[1])) >= 3) { @@ -896,7 +897,7 @@ class Registrationv3 extends MY_Controller $tok_esc = $this->db_onedev->escape_str($tok); $conds[] = "JSON_CONTAINS(M_PatientHP_bidx, '\"$tok_esc\"')"; } - if ($conds) $field_conds[] = '(' . implode(' AND ', $conds) . ')'; + if ($conds) $where_hp = 'AND (' . implode(' AND ', $conds) . ')'; } if (!empty($e[2]) && mb_strlen(trim($e[2])) >= 3) { @@ -906,15 +907,13 @@ class Registrationv3 extends MY_Controller $tok_esc = $this->db_onedev->escape_str($tok); $conds[] = "JSON_CONTAINS(M_PatientDOB_bidx, '\"$tok_esc\"')"; } - if ($conds) $field_conds[] = '(' . implode(' AND ', $conds) . ')'; + if ($conds) $where_dob = 'AND (' . implode(' AND ', $conds) . ')'; } if (!empty($e[3]) && mb_strlen(trim($e[3])) >= 3) { - $id_esc = $this->db_onedev->escape_like_str(trim($e[3])); - $field_conds[] = "(M_PatientIDNumber LIKE '%{$id_esc}%')"; + $id_esc = $this->db_onedev->escape_like_str(trim($e[3])); + $where_idnum = "AND M_PatientIDNumber LIKE '%{$id_esc}%'"; } - - if ($field_conds) $where_nik = 'AND (' . implode(' OR ', $field_conds) . ')'; } if (empty($prm['snorm']) && empty($prm['search']) && empty($prm['noreg'])) { @@ -942,7 +941,10 @@ class Registrationv3 extends MY_Controller WHERE M_PatientIsActive = 'Y' AND M_PatientSuspendID IS NULL {$where_noreg} {$where_snorm} - {$where_nik} + {$where_name} + {$where_hp} + {$where_dob} + {$where_idnum} GROUP BY M_PatientID LIMIT {$number_limit} OFFSET {$number_offset}";