diff --git a/application/controllers/mockup/fo/ibl_registration/Patient.php b/application/controllers/mockup/fo/ibl_registration/Patient.php index f96bd322..c0d984d2 100644 --- a/application/controllers/mockup/fo/ibl_registration/Patient.php +++ b/application/controllers/mockup/fo/ibl_registration/Patient.php @@ -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) diff --git a/scripts/migrate_encrypt_patient.php b/scripts/migrate_encrypt_patient.php index dd8e8da0..a1ad6e9c 100644 --- a/scripts/migrate_encrypt_patient.php +++ b/scripts/migrate_encrypt_patient.php @@ -46,7 +46,7 @@ $stmt_upd = $pdo->prepare("UPDATE m_patient SET M_PatientPhone_enc = ?, M_PatientPOB_enc = ?, M_PatientIDNumber_enc = ?, - M_PatientNIK_enc = ?, + M_PatientNIK_enc = ?, M_PatientNIK_bidx = ?, M_PatientNIP_enc = ? WHERE M_PatientID = ?"); @@ -72,7 +72,7 @@ while (true) { $enc->encrypt($row['M_PatientPhone']), $enc->encrypt($row['M_PatientPOB']), $enc->encrypt($row['M_PatientIDNumber']), - $enc->encrypt($row['M_PatientNIK']), + $enc->encrypt($row['M_PatientNIK']), $enc->search_bidx($row['M_PatientNIK']), $enc->encrypt($row['M_PatientNIP']), $row['M_PatientID'], ]); @@ -90,7 +90,6 @@ $total = 0; $stmt_addr = $pdo->prepare("UPDATE m_patientaddress SET M_PatientAddressDescription_enc = ?, - M_PatientAddressDescription_bidx = ?, M_PatientAddressEmail_enc = ?, M_PatientAddressPhone_enc = ? WHERE M_PatientAddressID = ?"); @@ -109,7 +108,6 @@ while (true) { foreach ($rows as $row) { $stmt_addr->execute([ $enc->encrypt($row['M_PatientAddressDescription']), - $enc->search_bidx($row['M_PatientAddressDescription']), $enc->encrypt($row['M_PatientAddressEmail']), $enc->encrypt($row['M_PatientAddressPhone']), $row['M_PatientAddressID'], diff --git a/sql/manual_changes/2026-05-31-pdp-encrypt-columns.sql b/sql/manual_changes/2026-05-31-pdp-encrypt-columns.sql index e9c39416..53106da2 100644 --- a/sql/manual_changes/2026-05-31-pdp-encrypt-columns.sql +++ b/sql/manual_changes/2026-05-31-pdp-encrypt-columns.sql @@ -119,6 +119,12 @@ ALTER TABLE one_lab.so_resultentrysdsinterpretation ALTER TABLE one_lab.member_eligible ADD COLUMN Member_EligibleDescription_enc TEXT NULL AFTER Member_EligibleDescription; +-- ============================================================ +-- one_lab.mcu_resume_results: JSON snapshot hasil lab MCU +-- ============================================================ +ALTER TABLE one_lab.mcu_resume_results + ADD COLUMN Mcu_ResumeResultsJSON_enc MEDIUMTEXT NULL AFTER Mcu_ResumeResultsJSON; + -- ============================================================ -- one_lab_log.log_patient: audit log perubahan data pasien -- Fix charset ke utf8mb4 (default latin1 tidak support JSON UTF-8 dari trigger)