FHM31052601IBL - Patient add_new/edit: tulis masked value ke kolom plaintext lama
Kolom lama (M_PatientName, HP, Email, dll) kini menyimpan nilai masked. Data asli tetap aman di _enc. Konsisten dengan bulk masking script. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -30,6 +30,14 @@ class Patient extends MY_Controller
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
$this->load->library('ibl_encryptor');
|
||||
}
|
||||
|
||||
// Masking untuk kolom plaintext lama (data asli di _enc)
|
||||
private function _mask_name($v) { if (!$v) return $v; $v=trim($v); $l=mb_strlen($v,'UTF-8'); if($l<=2) return '***'; return mb_substr($v,0,2,'UTF-8').str_repeat('*',min(3,$l-2)); }
|
||||
private function _mask_phone($v) { if (!$v) return $v; $d=preg_replace('/[^0-9]/','',trim($v)); $l=strlen($d); if($l<=4) return '****'; if($l<=8) return substr($d,0,4).str_repeat('*',$l-4); return substr($d,0,4).str_repeat('*',$l-7).substr($d,-3); }
|
||||
private function _mask_email($v) { if (!$v||strpos($v,'@')===false) return $v; [$loc,$dom]=explode('@',$v,2); return mb_substr($loc,0,min(2,mb_strlen($loc,'UTF-8')),'UTF-8').'***@'.$dom; }
|
||||
private function _mask_short($v) { if (!$v) return $v; $v=trim($v); $l=mb_strlen($v,'UTF-8'); if($l<=2) return '***'; return mb_substr($v,0,2,'UTF-8').'***'; }
|
||||
private function _mask_id($v) { if (!$v) return $v; $v=trim($v); $l=strlen($v); if($l<=4) return '****'; return substr($v,0,4).str_repeat('*',max(3,$l-6)).($l>6?substr($v,-2):''); }
|
||||
private function _mask_address($v) { if (!$v) return $v; $v=trim($v); $l=mb_strlen($v,'UTF-8'); if($l<=5) return '***'; return mb_substr($v,0,5,'UTF-8').'***'; }
|
||||
function _add_address(&$pat) {
|
||||
if (count($pat) == "0") {
|
||||
return array();
|
||||
@@ -238,7 +246,7 @@ class Patient extends MY_Controller
|
||||
$patient_name = str_replace("'", "\\'", $prm['M_PatientName']);
|
||||
$dob_str = date('d-m-Y', strtotime($prm['M_PatientDOB']));
|
||||
$ptn = [
|
||||
'M_PatientName' => $patient_name,
|
||||
'M_PatientName' => $this->_mask_name($patient_name),
|
||||
'M_PatientName_enc' => $this->ibl_encryptor->encrypt($patient_name),
|
||||
'M_PatientName_bidx' => $this->ibl_encryptor->search_bidx($patient_name),
|
||||
'M_PatientM_TitleID' => $prm['M_PatientM_TitleID'],
|
||||
@@ -249,17 +257,17 @@ class Patient extends MY_Controller
|
||||
'M_PatientDOB' => $prm['M_PatientDOB'],
|
||||
'M_PatientDOB_enc' => $this->ibl_encryptor->encrypt($dob_str),
|
||||
'M_PatientDOB_bidx' => $this->ibl_encryptor->search_bidx($dob_str),
|
||||
'M_PatientPOB' => $prm['M_PatientPOB'],
|
||||
'M_PatientPOB' => $this->_mask_short($prm['M_PatientPOB']),
|
||||
'M_PatientPOB_enc' => $this->ibl_encryptor->encrypt($prm['M_PatientPOB']),
|
||||
'M_PatientHP' => $prm['M_PatientHP'],
|
||||
'M_PatientHP' => $this->_mask_phone($prm['M_PatientHP']),
|
||||
'M_PatientHP_enc' => $this->ibl_encryptor->encrypt($prm['M_PatientHP']),
|
||||
'M_PatientHP_bidx' => $this->ibl_encryptor->search_bidx($prm['M_PatientHP']),
|
||||
'M_PatientPhone' => $prm['M_PatientPhone'],
|
||||
'M_PatientPhone' => $this->_mask_phone($prm['M_PatientPhone']),
|
||||
'M_PatientPhone_enc' => $this->ibl_encryptor->encrypt($prm['M_PatientPhone']),
|
||||
'M_PatientEmail' => $prm['M_PatientEmail'],
|
||||
'M_PatientEmail' => $this->_mask_email($prm['M_PatientEmail']),
|
||||
'M_PatientEmail_enc' => $this->ibl_encryptor->encrypt($prm['M_PatientEmail']),
|
||||
'M_PatientM_IdTypeID' => $M_IdTypeID,
|
||||
'M_PatientIDNumber' => $prm['M_PatientIDNumber'],
|
||||
'M_PatientIDNumber' => $this->_mask_id($prm['M_PatientIDNumber']),
|
||||
'M_PatientIDNumber_enc' => $this->ibl_encryptor->encrypt($prm['M_PatientIDNumber']),
|
||||
'M_PatientNote' => $prm['M_PatientNote'],
|
||||
'M_PatientUserID' => $userid,
|
||||
@@ -284,7 +292,7 @@ class Patient extends MY_Controller
|
||||
// save address
|
||||
$add = [
|
||||
'M_PatientAddressM_PatientID' => $id,
|
||||
'M_PatientAddressDescription' => $address_description,
|
||||
'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,
|
||||
@@ -342,7 +350,7 @@ class Patient extends MY_Controller
|
||||
$patient_name = str_replace("'", "\\'", $prm['M_PatientName']);
|
||||
$dob_str = date('d-m-Y', strtotime($prm['M_PatientDOB']));
|
||||
|
||||
$this->db_smartone->set('M_PatientName', $patient_name)
|
||||
$this->db_smartone->set('M_PatientName', $this->_mask_name($patient_name))
|
||||
->set('M_PatientName_enc', $this->ibl_encryptor->encrypt($patient_name))
|
||||
->set('M_PatientName_bidx', $this->ibl_encryptor->search_bidx($patient_name))
|
||||
->set('M_PatientM_TitleID', $prm['M_PatientM_TitleID'])
|
||||
@@ -353,17 +361,17 @@ class Patient extends MY_Controller
|
||||
->set('M_PatientDOB', $prm['M_PatientDOB'])
|
||||
->set('M_PatientDOB_enc', $this->ibl_encryptor->encrypt($dob_str))
|
||||
->set('M_PatientDOB_bidx', $this->ibl_encryptor->search_bidx($dob_str))
|
||||
->set('M_PatientPOB', $prm['M_PatientPOB'])
|
||||
->set('M_PatientPOB', $this->_mask_short($prm['M_PatientPOB']))
|
||||
->set('M_PatientPOB_enc', $this->ibl_encryptor->encrypt($prm['M_PatientPOB']))
|
||||
->set('M_PatientHP', $prm['M_PatientHP'])
|
||||
->set('M_PatientHP', $this->_mask_phone($prm['M_PatientHP']))
|
||||
->set('M_PatientHP_enc', $this->ibl_encryptor->encrypt($prm['M_PatientHP']))
|
||||
->set('M_PatientHP_bidx', $this->ibl_encryptor->search_bidx($prm['M_PatientHP']))
|
||||
->set('M_PatientPhone', $prm['M_PatientPhone'])
|
||||
->set('M_PatientPhone', $this->_mask_phone($prm['M_PatientPhone']))
|
||||
->set('M_PatientPhone_enc', $this->ibl_encryptor->encrypt($prm['M_PatientPhone']))
|
||||
->set('M_PatientEmail', $prm['M_PatientEmail'])
|
||||
->set('M_PatientEmail', $this->_mask_email($prm['M_PatientEmail']))
|
||||
->set('M_PatientEmail_enc', $this->ibl_encryptor->encrypt($prm['M_PatientEmail']))
|
||||
->set('M_PatientM_IdTypeID', $prm['M_PatientM_IdTypeID'])
|
||||
->set('M_PatientIDNumber', $prm['M_PatientIDNumber'])
|
||||
->set('M_PatientIDNumber', $this->_mask_id($prm['M_PatientIDNumber']))
|
||||
->set('M_PatientIDNumber_enc', $this->ibl_encryptor->encrypt($prm['M_PatientIDNumber']))
|
||||
->set('M_PatientNote', $prm['M_PatientNote'])
|
||||
->set('M_PatientUserID', $userid)
|
||||
@@ -394,7 +402,7 @@ class Patient extends MY_Controller
|
||||
->set('M_PatientAddressState', $prm['M_PatientAddressState'])
|
||||
->set('M_PatientAddressCountry', $prm['M_PatientAddressCountry'])
|
||||
->set('M_PatientAddressCountryCode', $prm['M_PatientAddressCountryCode'])
|
||||
->set('M_PatientAddressDescription', $address_description)
|
||||
->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)
|
||||
|
||||
Reference in New Issue
Block a user