FHM31052601IBL - pdp masking & enkripsi patient di controller dan SP mcu

- mask_name nama satu kata: tampil 2 char + bintang sisanya
- masking + enkripsi insert/update m_patient di Registrationv3, ibl_registration/Patient, Patientv4, setupmcuoffline-ibl/Preregister, mcuoffline/Preregisterapp
- masking insert ke mcu_preregister_patients (PatientName, KTP, NIK, Email, Hp)
- search patient pakai bidx, decrypt setelah query di mcuoffline/Preregisterapp
- matching existing patient ganti LIKE ke bidx search
- SP sp_upsert_mcu_patient_by_preregister_id & sp_upsert_mcu_patient_by_mgm_mcuid JOIN m_patient ambil _enc, simpan ke one_lab_dashboard.mcu_patient
- ALTER mcu_patient.Mcu_PatientName dan Mcu_PatientDOB ke TEXT

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
sas.fajri
2026-05-31 20:10:15 +07:00
parent 8c49b3356f
commit 065e3ebb34
8 changed files with 885 additions and 496 deletions

View File

@@ -8,9 +8,34 @@ class Preregister extends MY_Controller
public function __construct()
{
parent::__construct();
$this->load->library('ibl_encryptor');
// $this->db = $this->load->database("cpone", true);
}
private function _mask_name($v) {
if (!$v) return $v;
$v = trim($v);
$words = preg_split('/\s+/', $v);
if (count($words) === 1) {
$l = mb_strlen($v, 'UTF-8');
if ($l <= 2) return $v;
return mb_substr($v, 0, 2, 'UTF-8') . str_repeat('*', $l - 2);
}
$first = $words[0];
$rest = array_slice($words, 1);
$masked = array_map(function($w) {
if (!$w) return '';
$init = mb_substr($w, 0, 1, 'UTF-8');
return $init . str_repeat('*', max(3, mb_strlen($w, 'UTF-8') - 1));
}, $rest);
return $first . ' ' . implode(' ', $masked);
}
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').'***'; }
public function index()
{
// $cek = $this->db->query("select database() as current_db")->result();
@@ -59,8 +84,8 @@ class Preregister extends MY_Controller
}
}
function cekKTP($nik, $tanggal, $bulan, $tahun)
{
function cekKTP($nik, $tanggal, $bulan, $tahun)
{
if (strlen($nik) != 16) {
return false;
}
@@ -88,30 +113,30 @@ class Preregister extends MY_Controller
return false;
}
//setelah berhasil melewati rintangan, berarti nomornya valid (tidak 100% valid)
return true;
}
function normalize_schedule_date($rawDate)
{
$rawDate = trim((string) $rawDate);
if ($rawDate === '') {
return '';
}
$formats = array('d-m-Y', 'Y-m-d', 'd/m/Y', 'Y/m/d');
foreach ($formats as $format) {
$dt = DateTime::createFromFormat($format, $rawDate);
if ($dt && $dt->format($format) === $rawDate) {
return $dt->format('Y-m-d');
}
}
$timestamp = strtotime($rawDate);
if ($timestamp === false) {
return '';
}
return date('Y-m-d', $timestamp);
}
return true;
}
function normalize_schedule_date($rawDate)
{
$rawDate = trim((string) $rawDate);
if ($rawDate === '') {
return '';
}
$formats = array('d-m-Y', 'Y-m-d', 'd/m/Y', 'Y/m/d');
foreach ($formats as $format) {
$dt = DateTime::createFromFormat($format, $rawDate);
if ($dt && $dt->format($format) === $rawDate) {
return $dt->format('Y-m-d');
}
}
$timestamp = strtotime($rawDate);
if ($timestamp === false) {
return '';
}
return date('Y-m-d', $timestamp);
}
function savecsv()
{
@@ -149,7 +174,7 @@ class Preregister extends MY_Controller
$exist_patients_arr = [];
$exist_pat = [];
foreach ($datas as $k => $v) {
foreach ($datas as $k => $v) {
$timestamp = strtotime($v['TANGGAL_LAHIR']);
$pdob = date('Y-m-d', $timestamp);
$v['NAMA'] = trim(str_replace("'", "\\'", $v['NAMA']));
@@ -302,11 +327,16 @@ class Preregister extends MY_Controller
$this->sys_error("select mcu_preregister_patients : " . $last_qry);
exit;
}
$exist_r = $qry_pre->result_array();
$preregister_patient_id = 0;
if (count($exist_r) == 0) {
$query = " INSERT INTO mcu_preregister_patients (
$exist_r = $qry_pre->result_array();
$preregister_patient_id = 0;
if (count($exist_r) == 0) {
$m_nama = $this->db->escape_str($this->_mask_name($v['NAMA']));
$m_ktp = $this->_mask_id($v['KTP']);
$m_nip = $this->_mask_id($v['NIP']);
$m_email = $this->_mask_email($v['EMAIL']);
$m_hp = $this->_mask_phone($v['HP']);
$query = " INSERT INTO mcu_preregister_patients (
Mcu_PreregisterPatientsMgm_McuID,
Mcu_PreregisterPatientsCompanyNumber,
Mcu_PreregisterPatientsNIP,
@@ -331,16 +361,16 @@ class Preregister extends MY_Controller
VALUES(
'{$prm['xid']}',
'{$rowcor["M_CompanyNumber"]}',
'{$v['NIP']}',
'{$v['KTP']}',
'{$m_nip}',
'{$m_ktp}',
'{$patient_id}',
'{$title_id}',
'{$v['NAMA']}',
'{$m_nama}',
{$sex_id},
'{$pdob}',
'{$v['JOB']}',
'{$v['EMAIL']}',
'{$v['HP']}',
'{$m_email}',
'{$m_hp}',
'{$v['POSISI']}',
'{$v['DIVISI']}',
'{$v['LOKASI']}',
@@ -360,11 +390,11 @@ class Preregister extends MY_Controller
$this->sys_error("insert mcu_preregister_patients : " . $last_qry);
exit;
}
if ($rows) {
$last_id_x = $this->db->insert_id();
$preregister_patient_id = intval($last_id_x);
if ($patient_id == 0) {
if ($rows) {
$last_id_x = $this->db->insert_id();
$preregister_patient_id = intval($last_id_x);
if ($patient_id == 0) {
$sql = "SELECT *
FROM m_patient
WHERE
@@ -543,50 +573,50 @@ class Preregister extends MY_Controller
$sql = "UPDATE mcu_preregister_patients SET Mcu_PreregisterPatientsM_PatientID = {$patient_id}
WHERE Mcu_PreregisterPatientsID = {$last_id_x}";
$query = $this->db->query($sql);
if (!$query) {
$last_qry = $this->db->last_query();
$this->db->trans_rollback();
$this->sys_error("update mcu_preregister_patients : " . $last_qry);
exit;
}
}
} else {
$preregister_patient_id = intval($exist_r[0]['Mcu_PreregisterPatientsID']);
}
// Simpan jadwal MCU per preregister patient jika parameter TANGGAL_MCU dikirim
$scheduleDate = isset($v['TANGGAL_MCU']) ? $this->normalize_schedule_date($v['TANGGAL_MCU']) : '';
if ($preregister_patient_id > 0 && $scheduleDate !== '') {
$sqlSchedule = "INSERT INTO mcu_preregister_date (
Mcu_PreregisterDateMcu_PreregisterPatientsID,
Mcu_PreregisterDateCheckinSchedule,
Mcu_PreregisterDateIsActive,
Mcu_PreregisterDateCreated,
Mcu_PreregisterDateCreatedUserID,
Mcu_PreregisterDateLastUpdated,
Mcu_PreregisterDateLastUpdatedUserID
) VALUES (
?, ?, 'Y', NOW(), ?, NOW(), ?
)
ON DUPLICATE KEY UPDATE
Mcu_PreregisterDateIsActive = 'Y',
Mcu_PreregisterDateLastUpdated = NOW(),
Mcu_PreregisterDateLastUpdatedUserID = VALUES(Mcu_PreregisterDateLastUpdatedUserID)";
$qrySchedule = $this->db->query($sqlSchedule, array(
$preregister_patient_id,
$scheduleDate,
$userid,
$userid
));
if (!$qrySchedule) {
$last_qry = $this->db->last_query();
$this->db->trans_rollback();
$this->sys_error("insert mcu_preregister_date : " . $last_qry);
exit;
}
}
}
$query = $this->db->query($sql);
if (!$query) {
$last_qry = $this->db->last_query();
$this->db->trans_rollback();
$this->sys_error("update mcu_preregister_patients : " . $last_qry);
exit;
}
}
} else {
$preregister_patient_id = intval($exist_r[0]['Mcu_PreregisterPatientsID']);
}
// Simpan jadwal MCU per preregister patient jika parameter TANGGAL_MCU dikirim
$scheduleDate = isset($v['TANGGAL_MCU']) ? $this->normalize_schedule_date($v['TANGGAL_MCU']) : '';
if ($preregister_patient_id > 0 && $scheduleDate !== '') {
$sqlSchedule = "INSERT INTO mcu_preregister_date (
Mcu_PreregisterDateMcu_PreregisterPatientsID,
Mcu_PreregisterDateCheckinSchedule,
Mcu_PreregisterDateIsActive,
Mcu_PreregisterDateCreated,
Mcu_PreregisterDateCreatedUserID,
Mcu_PreregisterDateLastUpdated,
Mcu_PreregisterDateLastUpdatedUserID
) VALUES (
?, ?, 'Y', NOW(), ?, NOW(), ?
)
ON DUPLICATE KEY UPDATE
Mcu_PreregisterDateIsActive = 'Y',
Mcu_PreregisterDateLastUpdated = NOW(),
Mcu_PreregisterDateLastUpdatedUserID = VALUES(Mcu_PreregisterDateLastUpdatedUserID)";
$qrySchedule = $this->db->query($sqlSchedule, array(
$preregister_patient_id,
$scheduleDate,
$userid,
$userid
));
if (!$qrySchedule) {
$last_qry = $this->db->last_query();
$this->db->trans_rollback();
$this->sys_error("insert mcu_preregister_date : " . $last_qry);
exit;
}
}
}
if ($this->db->trans_status() === FALSE) {
$this->db->trans_rollback();
@@ -960,32 +990,36 @@ class Preregister extends MY_Controller
}
if ($v['KTP'] != '') {
$sql = "SELECT *
FROM m_patient
$enc = $this->ibl_encryptor;
$ktp_toks = $enc->query_tokens($v['KTP']);
$ktp_conds = [];
foreach ($ktp_toks as $tok) {
$tok_esc = $this->db_onedev->escape_str($tok);
$ktp_conds[] = "JSON_CONTAINS(M_PatientNIK_bidx, '\"$tok_esc\"')";
}
$ktp_where = $ktp_conds ? implode(' AND ', $ktp_conds) : '0';
$sql = "SELECT m_patient.*, M_SexCode
FROM m_patient
JOIN m_sex ON M_PatientM_SexID = M_SexID
WHERE M_PatientM_IdTypeID = 1 AND
M_PatientIDNumber = '{$v['KTP']}' AND
M_PatientIsActive = 'Y'
WHERE M_PatientIsActive = 'Y' AND ({$ktp_where})
LIMIT 1";
$exist_r = $this->db_onedev->query($sql)->row_array();
if ($exist_r) {
$patient_id = $exist_r["M_PatientID"];
$v['NAMA'] = $exist_r["M_PatientName"];
//$pdob = date('Y-m-d',strtotime($exist_r['M_PatientDOB']));
$v['NAMA'] = $enc->decrypt($exist_r['M_PatientName_enc']) ?? $exist_r["M_PatientName"];
$title_id = $exist_r["M_PatientM_TitleID"];
$sex_id = $exist_r["M_PatientM_SexID"];
$religion_id = $exist_r["M_PatientM_ReligionID"];
$v['NIK'] = $v['NIK'] ? $v['NIK'] : $exist_r["M_PatientNIK"];
$v['EMAIL'] = $v['EMAIL'] ? $v['EMAIL'] : $exist_r["M_PatientEmail"];
$v['HP'] = $v['HP'] ? $v['HP'] : $exist_r["M_PatientHP"];
$v['NIK'] = $v['NIK'] ? $v['NIK'] : ($enc->decrypt($exist_r['M_PatientNIK_enc'] ?? '') ?? $exist_r["M_PatientNIK"]);
$v['EMAIL'] = $v['EMAIL'] ? $v['EMAIL'] : ($enc->decrypt($exist_r['M_PatientEmail_enc'] ?? '') ?? $exist_r["M_PatientEmail"]);
$v['HP'] = $v['HP'] ? $v['HP'] : ($enc->decrypt($exist_r['M_PatientHP_enc'] ?? '') ?? $exist_r["M_PatientHP"]);
$v['KEDUDUKAN'] = $v['KEDUDUKAN'] ? $v['KEDUDUKAN'] : $exist_r["M_PatientKedudukan"];
$v['JABATAN'] = $v['JABATAN'] ? $v['JABATAN'] : $exist_r["M_PatientJabatan"];
$v['JOB'] = $v['JOB'] ? $v['JOB'] : $exist_r["M_PatientJob"];
$v['LOKASI'] = $v['LOKASI'] ? addslashes($v['LOKASI']) : addslashes($exist_r["M_PatientLocation"]);
$v['JENIS_KELAMIN'] = $exist_r["M_SexCode"];
$v['KTP'] = $v['KTP'] ? $v['KTP'] : $exist_r["M_PatientIDNumber"];
$v['KTP'] = $v['KTP'] ? $v['KTP'] : ($enc->decrypt($exist_r['M_PatientIDNumber_enc'] ?? '') ?? $exist_r["M_PatientIDNumber"]);
}
//echo $sql;
}
if ($patient_id == 0) {
@@ -1005,6 +1039,11 @@ class Preregister extends MY_Controller
$sql = "SELECT * FROM m_religion WHERE M_ReligionName = 'OTHERS' AND M_ReligionIsActive = 'Y' LIMIT 1";
$religion_id = $this->db_onedev->query($sql)->row()->M_ReligionID;
}
$m_nama = $this->db_onedev->escape_str($this->_mask_name($v['NAMA']));
$m_ktp = $this->_mask_id($v['KTP']);
$m_nik = $this->_mask_id($v['NIK']);
$m_email = $this->_mask_email($v['EMAIL']);
$m_hp = $this->_mask_phone($v['HP']);
$query = " INSERT INTO mcu_preregister_patients (
Mcu_PreregisterDetailsMcuOfflinePrepareID,
Mcu_PreregisterDetailsPID,
@@ -1029,13 +1068,13 @@ class Preregister extends MY_Controller
VALUES(
'{$prm['xid']}',
'{$v['PID']}',
'{$v['KTP']}',
'{$v['NIK']}',
'{$m_ktp}',
'{$m_nik}',
'{$title_id}',
'{$v['NAMA']}',
'{$m_nama}',
'{$religion_id}',
'{$v['EMAIL']}',
'{$v['HP']}',
'{$m_email}',
'{$m_hp}',
'{$pdob}',
'{$v['KEDUDUKAN']}',
'{$v['JABATAN']}',
@@ -1060,18 +1099,22 @@ class Preregister extends MY_Controller
//print_r($row_header);
if ($patient_id == 0) {
$sql = "SELECT *
FROM m_patient
WHERE
M_PatientName = '{$v['NAMA']}' AND
M_PatientDOB = '{$pdob}' AND
M_PatientNIP = '{$v['NIK']}' AND
M_PatientIsActive = 'Y' LIMIT 1";
$enc = $this->ibl_encryptor;
$name_toks = $enc->query_tokens($v['NAMA']);
$name_conds = [];
foreach ($name_toks as $tok) {
$tok_esc = $this->db_onedev->escape_str($tok);
$name_conds[] = "JSON_CONTAINS(M_PatientName_bidx, '\"$tok_esc\"')";
}
$name_where = $name_conds ? implode(' AND ', $name_conds) : '0';
$sql = "SELECT M_PatientID FROM m_patient
WHERE ({$name_where})
AND M_PatientDOB = '{$pdob}'
AND M_PatientIsActive = 'Y' LIMIT 1";
$exist_r = $this->db_onedev->query($sql)->row_array();
if ($exist_r) {
$patient_id = $exist_r["M_PatientID"];
$patient_id = $exist_r["M_PatientID"];
}
//echo $sql;
}
//echo $patient_id;
@@ -1084,85 +1127,53 @@ class Preregister extends MY_Controller
$M_PatientM_IdTypeID = 1;
$M_PatientIDNumber = $v["KTP"];
}
$sql = "INSERT INTO m_patient (
M_PatientName,
M_PatientM_TitleID,
M_PatientM_SexID,
M_PatientM_ReligionID,
M_PatientPOB,
M_PatientDOB,
M_PatientNIK,
M_PatientM_IdTypeID,
M_PatientIDNumber,
M_PatientJabatan,
M_PatientLocation,
M_PatientKedudukan,
M_PatientJob,
M_PatientEmail,
M_PatientHP,
M_PatientUserID
)
VALUES(
'{$v["NAMA"]}',
{$title_id},
{$sex_id},
{$religion_id},
'-',
'{$pdob}',
'{$v["NIK"]}',
'{$M_PatientM_IdTypeID}',
'{$M_PatientIDNumber}',
'{$v['JABATAN']}',
'{$v['LOKASI']}',
'{$v['KEDUDUKAN']}',
'{$v['JOB']}',
'{$v['EMAIL']}',
'{$v['HP']}',
'{$userid}'
)";
//echo $sql;
$this->db_onedev->query($sql);
$data_insert_patient = array(
'M_PatientName' => $v["NAMA"],
'M_PatientM_TitleID' => $title_id,
'M_PatientM_SexID' => $sex_id,
$enc = $this->ibl_encryptor;
$dob_str = date('d-m-Y', strtotime($pdob));
$data_insert_patient = [
'M_PatientName' => $this->_mask_name($v["NAMA"]),
'M_PatientName_enc' => $enc->encrypt($v["NAMA"]),
'M_PatientName_bidx' => $enc->search_bidx($v["NAMA"]),
'M_PatientM_TitleID' => $title_id,
'M_PatientM_SexID' => $sex_id,
'M_PatientM_ReligionID' => $religion_id,
'M_PatientPOB' => '-',
'M_PatientDOB' => $pdob,
'M_PatientNIK' => $v["NIK"],
'M_PatientJabatan' => $v['JABATAN'],
'M_PatientLocation' => $v['LOKASI'],
'M_PatientKedudukan' => $v['KEDUDUKAN'],
'M_PatientJob' => $v['JOB'],
'M_PatientEmail' => $v['EMAIL'],
'M_PatientHP' => $v['HP'],
'M_PatientUserID' => $userid
);
//$this->db->insert('m_patient', $data_insert_patient);
//echo $this->db_onedev->last_query();
'M_PatientPOB' => '***',
'M_PatientPOB_enc' => $enc->encrypt('-'),
'M_PatientDOB' => $pdob,
'M_PatientDOB_enc' => $enc->encrypt($dob_str),
'M_PatientDOB_bidx' => $enc->search_bidx($dob_str),
'M_PatientNIK' => $v["NIK"],
'M_PatientNIK_bidx' => $enc->search_bidx($v["NIK"] ?? ''),
'M_PatientM_IdTypeID' => $M_PatientM_IdTypeID,
'M_PatientIDNumber' => $M_PatientIDNumber ? $this->_mask_id($M_PatientIDNumber) : null,
'M_PatientIDNumber_enc' => $M_PatientIDNumber ? $enc->encrypt($M_PatientIDNumber) : null,
'M_PatientJabatan' => $v['JABATAN'],
'M_PatientLocation' => $v['LOKASI'],
'M_PatientKedudukan' => $v['KEDUDUKAN'],
'M_PatientJob' => $v['JOB'],
'M_PatientEmail' => $this->_mask_email($v['EMAIL']),
'M_PatientEmail_enc' => $enc->encrypt($v['EMAIL']),
'M_PatientHP' => $this->_mask_phone($v['HP']),
'M_PatientHP_enc' => $enc->encrypt($v['HP']),
'M_PatientHP_bidx' => $enc->search_bidx($v['HP']),
'M_PatientUserID' => $userid,
];
$this->db_onedev->insert('m_patient', $data_insert_patient);
$patient_id = $this->db_onedev->insert_id();
//$sql = "SELECT LAST_INSERT_ID() as xid";
//$patient_id = $this->db_onedev->query($sql)->row()->xid;
//echo $patient_id ;
$sql = "INSERT INTO m_patientaddress (
M_PatientAddressM_PatientID,
M_PatientAddressDescription,
M_PatientAddressM_KelurahanID,
M_PatientAddressCreated,
M_PatientAddressUserID
)
VALUES(
{$patient_id},
'{$row_header['M_CompanyAddress']}',
'{$row_header['M_CompanyM_KelurahanID']}',
NOW(),
'{$userid}'
)";
$this->db_onedev->query($sql);
$enc = $this->ibl_encryptor;
$addr_desc = $row_header['M_CompanyAddress'];
$this->db_onedev->insert('m_patientaddress', [
'M_PatientAddressM_PatientID' => $patient_id,
'M_PatientAddressDescription' => $this->_mask_address($addr_desc),
'M_PatientAddressDescription_enc' => $enc->encrypt($addr_desc),
'M_PatientAddressM_KelurahanID' => $row_header['M_CompanyM_KelurahanID'],
'M_PatientAddressCreated' => date('Y-m-d H:i:s'),
'M_PatientAddressUserID' => $userid,
]);
//echo $sql;
//$patient_addr_id = $this->db_onedev->insert_id();
//$sql = "SELECT * FROM m_patientaddress WHERE M_PatientAddressID = {$patient_addr_id}";
@@ -1174,20 +1185,31 @@ class Preregister extends MY_Controller
} else {
//echo 'masuk';
//$pdob = date('Y-m-d',strtotime($prm['Mcu_PreregisterDetailsDOB']));
$data_update_patient = array(
'M_PatientDOB' => $pdob
);
$enc = $this->ibl_encryptor;
$dob_str2 = date('d-m-Y', strtotime($pdob));
$data_update_patient = [
'M_PatientDOB' => $pdob,
'M_PatientDOB_enc' => $enc->encrypt($dob_str2),
'M_PatientDOB_bidx'=> $enc->search_bidx($dob_str2),
];
if ($v['JENIS_KELAMIN'] == 'L')
$data_update_patient['M_PatientM_TitleID'] = 2;
else
$data_update_patient['M_PatientM_TitleID'] = 4;
if ($v['EMAIL'] != '')
$data_update_patient['M_PatientEmail'] = $v['EMAIL'];
if ($v['HP'] != '')
$data_update_patient['M_PatientHP'] = $v['HP'];
if ($v['NIK'] != '')
$data_update_patient['M_PatientNIK'] = $v['NIK'];
if ($v['EMAIL'] != '') {
$data_update_patient['M_PatientEmail'] = $this->_mask_email($v['EMAIL']);
$data_update_patient['M_PatientEmail_enc'] = $enc->encrypt($v['EMAIL']);
}
if ($v['HP'] != '') {
$data_update_patient['M_PatientHP'] = $this->_mask_phone($v['HP']);
$data_update_patient['M_PatientHP_enc'] = $enc->encrypt($v['HP']);
$data_update_patient['M_PatientHP_bidx'] = $enc->search_bidx($v['HP']);
}
if ($v['NIK'] != '') {
$data_update_patient['M_PatientNIK'] = $v['NIK'];
$data_update_patient['M_PatientNIK_bidx'] = $enc->search_bidx($v['NIK']);
}
if ($v['JABATAN'] != '')
$data_update_patient['M_PatientJabatan'] = $v['JABATAN'];
if ($v['KEDUDUKAN'] != '')
@@ -1198,8 +1220,9 @@ class Preregister extends MY_Controller
$data_update_patient['M_PatientJob'] = $v['JOB'];
if (isset($v["KTP"]) && $v["KTP"] != '') {
$data_update_patient['M_PatientM_IdTypeID'] = 1;
$data_update_patient['M_PatientIDNumber'] = $v["KTP"];
$data_update_patient['M_PatientM_IdTypeID'] = 1;
$data_update_patient['M_PatientIDNumber'] = $this->_mask_id($v["KTP"]);
$data_update_patient['M_PatientIDNumber_enc'] = $enc->encrypt($v["KTP"]);
}
$this->db_onedev->where('M_PatientID', $patient_id);
@@ -1247,56 +1270,46 @@ class Preregister extends MY_Controller
$prm = $this->sys_input;
$userid = $this->sys_user["M_UserID"];
$pdob = date('Y-m-d', strtotime($prm['M_PatientDOB']));
$query = "INSERT INTO m_patient (
M_PatientM_TitleID,
M_PatientPrefix,
M_PatientName,
M_PatientSuffix,
M_PatientDOB,
M_PatientM_SexID,
M_PatientM_ReligionID,
M_PatientEmail,
M_PatientPOB,
M_PatientHP,
M_PatientPhone,
M_PatientM_IdTypeID,
M_PatientIDNumber,
M_PatientNote,
M_PatientNIK,
M_PatientJabatan,
M_PatientKedudukan,
M_PatientPJ,
M_PatientLocation,
M_PatientJob,
M_PatientUserID
)
VALUES(
'{$prm['M_PatientM_TitleID']}',
'{$prm['M_PatientPrefix']}',
'{$prm['M_PatientName']}',
'{$prm['M_PatientSuffix']}',
'{$pdob}',
'{$prm['M_PatientM_SexID']}',
'{$prm['M_PatientM_ReligionID']}',
'{$prm['M_PatientEmail']}',
'{$prm['M_PatientPOB']}',
'{$prm['M_PatientHP']}',
'{$prm['M_PatientPhone']}',
'{$prm['M_PatientM_IdTypeID']}',
'{$prm['M_PatientIDNumber']}',
'{$prm['M_PatientNote']}',
'{$prm['M_PatientNIK']}',
'{$prm['M_PatientJabatan']}',
'{$prm['M_PatientKedudukan']}',
'{$prm['M_PatientPJ']}',
'{$prm['M_PatientLocation']}',
'{$prm['M_PatientJob']}',
$userid
)
";
//echo $query;
$rows = $this->db_onedev->query($query);
$pdob = date('Y-m-d', strtotime($prm['M_PatientDOB']));
$dob_str = date('d-m-Y', strtotime($prm['M_PatientDOB']));
$patient_name = $prm['M_PatientName'];
$enc = $this->ibl_encryptor;
$ptn = [
'M_PatientName' => $this->_mask_name($patient_name),
'M_PatientName_enc' => $enc->encrypt($patient_name),
'M_PatientName_bidx' => $enc->search_bidx($patient_name),
'M_PatientM_TitleID' => $prm['M_PatientM_TitleID'],
'M_PatientPrefix' => $prm['M_PatientPrefix'],
'M_PatientSuffix' => $prm['M_PatientSuffix'],
'M_PatientDOB' => $pdob,
'M_PatientDOB_enc' => $enc->encrypt($dob_str),
'M_PatientDOB_bidx' => $enc->search_bidx($dob_str),
'M_PatientM_SexID' => $prm['M_PatientM_SexID'],
'M_PatientM_ReligionID' => $prm['M_PatientM_ReligionID'],
'M_PatientEmail' => $this->_mask_email($prm['M_PatientEmail']),
'M_PatientEmail_enc' => $enc->encrypt($prm['M_PatientEmail']),
'M_PatientPOB' => $this->_mask_short($prm['M_PatientPOB']),
'M_PatientPOB_enc' => $enc->encrypt($prm['M_PatientPOB']),
'M_PatientHP' => $this->_mask_phone($prm['M_PatientHP']),
'M_PatientHP_enc' => $enc->encrypt($prm['M_PatientHP']),
'M_PatientHP_bidx' => $enc->search_bidx($prm['M_PatientHP']),
'M_PatientPhone' => $this->_mask_phone($prm['M_PatientPhone']),
'M_PatientPhone_enc' => $enc->encrypt($prm['M_PatientPhone']),
'M_PatientM_IdTypeID' => $prm['M_PatientM_IdTypeID'],
'M_PatientIDNumber' => $this->_mask_id($prm['M_PatientIDNumber']),
'M_PatientIDNumber_enc' => $enc->encrypt($prm['M_PatientIDNumber']),
'M_PatientNIK' => $prm['M_PatientNIK'],
'M_PatientNIK_bidx' => $enc->search_bidx($prm['M_PatientNIK'] ?? ''),
'M_PatientNote' => $prm['M_PatientNote'],
'M_PatientJabatan' => $prm['M_PatientJabatan'],
'M_PatientKedudukan' => $prm['M_PatientKedudukan'],
'M_PatientPJ' => $prm['M_PatientPJ'],
'M_PatientLocation' => $prm['M_PatientLocation'],
'M_PatientJob' => $prm['M_PatientJob'],
'M_PatientUserID' => $userid,
];
$this->db_onedev->insert('m_patient', $ptn);
$last_id = $this->db_onedev->insert_id();
$result = array(
"total" => 1,