FHM31052601IBL - search patient by nama/HP/DOB/NIK, hapus address bidx, tambah NIK bidx
- Search sekarang: nama, HP, DOB, NIK (alamat dihapus - boros disk) - Tambah M_PatientNIK_bidx untuk search by NIK - Migration script: NIK bidx + hapus address bidx dari m_patientaddress Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -92,7 +92,7 @@ class Patient extends MY_Controller
|
||||
$where_name = '';
|
||||
$where_hp = '';
|
||||
$where_dob = '';
|
||||
$where_addr = "AND M_PatientAddressNote = 'Utama'";
|
||||
$where_nik = '';
|
||||
|
||||
if (!empty($prm['noreg'])) {
|
||||
$noreg = $this->db_smartone->escape_like_str($prm['noreg']);
|
||||
@@ -102,7 +102,7 @@ class Patient extends MY_Controller
|
||||
if (!empty($prm['search'])) {
|
||||
$e = explode('+', $prm['search']);
|
||||
|
||||
// name — trigram blind index (min 3 karakter)
|
||||
// nama — trigram blind index (min 3 karakter)
|
||||
if (!empty($e[0]) && mb_strlen(trim($e[0])) >= 3) {
|
||||
$toks = $this->ibl_encryptor->query_tokens($e[0]);
|
||||
$conds = [];
|
||||
@@ -135,15 +135,15 @@ class Patient extends MY_Controller
|
||||
if ($conds) $where_dob = 'AND (' . implode(' AND ', $conds) . ')';
|
||||
}
|
||||
|
||||
// address — trigram blind index
|
||||
// nik — trigram blind index
|
||||
if (!empty($e[3]) && mb_strlen(trim($e[3])) >= 3) {
|
||||
$toks = $this->ibl_encryptor->query_tokens($e[3]);
|
||||
$conds = [];
|
||||
foreach ($toks as $tok) {
|
||||
$tok_esc = $this->db_smartone->escape_str($tok);
|
||||
$conds[] = "JSON_CONTAINS(M_PatientAddressDescription_bidx, '\"$tok_esc\"')";
|
||||
$conds[] = "JSON_CONTAINS(M_PatientNIK_bidx, '\"$tok_esc\"')";
|
||||
}
|
||||
if ($conds) $where_addr = 'AND (' . implode(' AND ', $conds) . ')';
|
||||
if ($conds) $where_nik = 'AND (' . implode(' AND ', $conds) . ')';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,12 +163,12 @@ class Patient extends MY_Controller
|
||||
M_PatientM_IdTypeID,
|
||||
M_PatientName_enc, M_PatientHP_enc, M_PatientDOB_enc,
|
||||
M_PatientEmail_enc, M_PatientPhone_enc, M_PatientPOB_enc,
|
||||
M_PatientIDNumber_enc, M_PatientAddressDescription_enc
|
||||
M_PatientIDNumber_enc, M_PatientNIK_enc, M_PatientAddressDescription_enc
|
||||
FROM m_patient
|
||||
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
||||
JOIN m_patientaddress ON M_PatientAddressM_PatientID = M_PatientID
|
||||
AND M_PatientAddressIsActive = 'Y' {$where_addr}
|
||||
AND M_PatientAddressIsActive = 'Y' AND M_PatientAddressNote = 'Utama'
|
||||
LEFT JOIN m_religion ON M_PatientM_ReligionID = M_ReligionID
|
||||
LEFT JOIN patient_signature ON Patient_SignatureM_PatientID = M_PatientID
|
||||
AND Patient_SignatureIsActive = 'Y'
|
||||
@@ -177,6 +177,7 @@ class Patient extends MY_Controller
|
||||
{$where_name}
|
||||
{$where_hp}
|
||||
{$where_dob}
|
||||
{$where_nik}
|
||||
GROUP BY M_PatientID
|
||||
LIMIT {$number_limit} OFFSET {$number_offset}";
|
||||
|
||||
@@ -205,6 +206,7 @@ class Patient extends MY_Controller
|
||||
$rows[$k]['M_PatientPhone'] = $phone;
|
||||
$rows[$k]['M_PatientPOB'] = $enc->decrypt($v['M_PatientPOB_enc']) ?? '';
|
||||
$rows[$k]['M_PatientIDNumber'] = $enc->decrypt($v['M_PatientIDNumber_enc']) ?? '';
|
||||
$rows[$k]['M_PatientNIK'] = $enc->decrypt($v['M_PatientNIK_enc']) ?? '';
|
||||
$rows[$k]['dob_ina'] = $dob_dec;
|
||||
$rows[$k]['hp'] = $phone ?: $hp;
|
||||
|
||||
@@ -269,6 +271,7 @@ class Patient extends MY_Controller
|
||||
'M_PatientM_IdTypeID' => $M_IdTypeID,
|
||||
'M_PatientIDNumber' => $this->_mask_id($prm['M_PatientIDNumber']),
|
||||
'M_PatientIDNumber_enc' => $this->ibl_encryptor->encrypt($prm['M_PatientIDNumber']),
|
||||
'M_PatientNIK_bidx' => $this->ibl_encryptor->search_bidx($prm['M_PatientNIK'] ?? ''),
|
||||
'M_PatientNote' => $prm['M_PatientNote'],
|
||||
'M_PatientUserID' => $userid,
|
||||
'M_PatientCreated' => date('Y-m-d H:i:s'),
|
||||
@@ -294,7 +297,6 @@ class Patient extends MY_Controller
|
||||
'M_PatientAddressM_PatientID' => $id,
|
||||
'M_PatientAddressDescription' => $this->_mask_address($address_description),
|
||||
'M_PatientAddressDescription_enc' => $this->ibl_encryptor->encrypt($address_description),
|
||||
'M_PatientAddressDescription_bidx' => $this->ibl_encryptor->search_bidx($address_description),
|
||||
'M_PatientAddressUserID' => $userid,
|
||||
'M_PatientAddressRegionalCd' => $prm['M_PatientAddressRegionalCd'],
|
||||
'M_PatientAddressLocation' => $prm['M_PatientAddressLocation'],
|
||||
@@ -373,6 +375,7 @@ class Patient extends MY_Controller
|
||||
->set('M_PatientM_IdTypeID', $prm['M_PatientM_IdTypeID'])
|
||||
->set('M_PatientIDNumber', $this->_mask_id($prm['M_PatientIDNumber']))
|
||||
->set('M_PatientIDNumber_enc', $this->ibl_encryptor->encrypt($prm['M_PatientIDNumber']))
|
||||
->set('M_PatientNIK_bidx', $this->ibl_encryptor->search_bidx($prm['M_PatientIDNumber'] ?? ''))
|
||||
->set('M_PatientNote', $prm['M_PatientNote'])
|
||||
->set('M_PatientUserID', $userid)
|
||||
->set('M_PatientLastUpdatedUserID', $userid)
|
||||
@@ -404,7 +407,6 @@ class Patient extends MY_Controller
|
||||
->set('M_PatientAddressCountryCode', $prm['M_PatientAddressCountryCode'])
|
||||
->set('M_PatientAddressDescription', $this->_mask_address($address_description))
|
||||
->set('M_PatientAddressDescription_enc', $this->ibl_encryptor->encrypt($address_description))
|
||||
->set('M_PatientAddressDescription_bidx', $this->ibl_encryptor->search_bidx($address_description))
|
||||
->set('M_PatientAddressUserID', $userid)
|
||||
->set('M_PatientAddressLastUpdatedUserID', $userid)
|
||||
->where('M_PatientAddressID', $id_address)
|
||||
|
||||
Reference in New Issue
Block a user