FHM31052601IBL - fix mask_patient_plaintext: cursor-based pagination, pisahkan masking nama
Nama ditangani remask_patient_name.php (decrypt dari _enc). Script ini handle HP/email/alamat/NIK/POB dengan cursor-based agar tidak infinite loop pada nama pendek satu kata. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -87,16 +87,18 @@ function mask_address($v) {
|
||||
return mb_substr($v, 0, 5, 'UTF-8') . '***';
|
||||
}
|
||||
|
||||
$batch = 500;
|
||||
$batch = 500;
|
||||
$last_id = 0;
|
||||
|
||||
// ============================================================
|
||||
// m_patient
|
||||
// m_patient — HP, Email, Phone, POB, IDNumber, NIK, NIP
|
||||
// Nama TIDAK dimasking di sini — pakai remask_patient_name.php
|
||||
// (cursor-based, decrypt dari _enc, format "NAMA DEPAN I*****")
|
||||
// ============================================================
|
||||
echo "=== Masking m_patient ===\n";
|
||||
echo "=== Masking m_patient (field selain nama) ===\n";
|
||||
$total = 0;
|
||||
|
||||
$stmt = $pdo->prepare("UPDATE m_patient SET
|
||||
M_PatientName = ?,
|
||||
M_PatientHP = ?,
|
||||
M_PatientPhone = ?,
|
||||
M_PatientEmail = ?,
|
||||
@@ -107,13 +109,13 @@ $stmt = $pdo->prepare("UPDATE m_patient SET
|
||||
WHERE M_PatientID = ?");
|
||||
|
||||
while (true) {
|
||||
// Skip rows already masked (ada '***' di nama)
|
||||
$rows = $pdo->query(
|
||||
"SELECT M_PatientID, M_PatientName, M_PatientHP, M_PatientPhone,
|
||||
"SELECT M_PatientID, M_PatientHP, M_PatientPhone,
|
||||
M_PatientEmail, M_PatientPOB, M_PatientIDNumber, M_PatientNIK, M_PatientNIP
|
||||
FROM m_patient
|
||||
WHERE M_PatientName_enc IS NOT NULL
|
||||
AND M_PatientName NOT LIKE '%***%'
|
||||
AND M_PatientID > {$last_id}
|
||||
ORDER BY M_PatientID ASC
|
||||
LIMIT {$batch}"
|
||||
)->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
@@ -121,7 +123,6 @@ while (true) {
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$stmt->execute([
|
||||
mask_name($row['M_PatientName']),
|
||||
mask_phone($row['M_PatientHP']),
|
||||
mask_phone($row['M_PatientPhone']),
|
||||
mask_email($row['M_PatientEmail']),
|
||||
@@ -131,6 +132,7 @@ while (true) {
|
||||
mask_id($row['M_PatientNIP']),
|
||||
$row['M_PatientID'],
|
||||
]);
|
||||
$last_id = $row['M_PatientID'];
|
||||
$total++;
|
||||
}
|
||||
echo " {$total} rows...\n";
|
||||
@@ -141,7 +143,8 @@ echo "m_patient selesai: {$total} rows\n\n";
|
||||
// m_patientaddress
|
||||
// ============================================================
|
||||
echo "=== Masking m_patientaddress ===\n";
|
||||
$total = 0;
|
||||
$total = 0;
|
||||
$last_id = 0;
|
||||
|
||||
$stmt2 = $pdo->prepare("UPDATE m_patientaddress SET
|
||||
M_PatientAddressDescription = ?,
|
||||
@@ -155,8 +158,8 @@ while (true) {
|
||||
M_PatientAddressEmail, M_PatientAddressPhone
|
||||
FROM m_patientaddress
|
||||
WHERE M_PatientAddressDescription_enc IS NOT NULL
|
||||
AND (M_PatientAddressDescription IS NULL
|
||||
OR M_PatientAddressDescription NOT LIKE '%***%')
|
||||
AND M_PatientAddressID > {$last_id}
|
||||
ORDER BY M_PatientAddressID ASC
|
||||
LIMIT {$batch}"
|
||||
)->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
@@ -169,6 +172,7 @@ while (true) {
|
||||
mask_phone($row['M_PatientAddressPhone']),
|
||||
$row['M_PatientAddressID'],
|
||||
]);
|
||||
$last_id = $row['M_PatientAddressID'];
|
||||
$total++;
|
||||
}
|
||||
echo " {$total} rows...\n";
|
||||
|
||||
Reference in New Issue
Block a user