From dc586c63f4e17b4c7b8cc06f2c81e3c2e49f871c Mon Sep 17 00:00:00 2001 From: "sas.fajri" Date: Wed, 10 Jun 2026 11:36:44 +0700 Subject: [PATCH] FHM09062601IBL - doctorv5/anamnesedoctor: fix kelurahan sub-query, tambah PDP decrypt, gunakan regional Co-Authored-By: Claude Sonnet 4.6 --- .../klinik/doctorv5/Anamnesedoctor.php | 65 ++++++++++++------- 1 file changed, 42 insertions(+), 23 deletions(-) diff --git a/application/controllers/klinik/doctorv5/Anamnesedoctor.php b/application/controllers/klinik/doctorv5/Anamnesedoctor.php index ede73ef1..f88edcc4 100644 --- a/application/controllers/klinik/doctorv5/Anamnesedoctor.php +++ b/application/controllers/klinik/doctorv5/Anamnesedoctor.php @@ -14,6 +14,7 @@ class Anamnesedoctor extends MY_Controller parent::__construct(); $this->db_onedev = $this->load->database("onedev", true); $this->db_oneklinik = $this->load->database("onedev", true); + $this->load->library('ibl_encryptor'); $this->IP_SOCKET_IO = "localhost"; } @@ -37,15 +38,23 @@ class Anamnesedoctor extends MY_Controller M_PatientNoReg, M_PatientPrefix, M_PatientName, + M_PatientName_enc, M_PatientSuffix, M_PatientHP, + M_PatientHP_enc, M_PatientEmail, + M_PatientEmail_enc, M_PatientPOB, + M_PatientPOB_enc, M_PatientPhone, + M_PatientPhone_enc, M_PatientIDNumber, + M_PatientIDNumber_enc, DATE_FORMAT(M_PatientDOB,'%d-%m-%Y') as M_PatientDOB, + M_PatientDOB_enc, M_PatientNote, M_PatientNIK, + M_PatientNIK_enc, M_PatientJabatan, M_PatientKedudukan, M_PatientPJ, @@ -61,9 +70,12 @@ class Anamnesedoctor extends MY_Controller M_IdTypeName, M_PatientIDNumber, IF(ISNULL(M_PatientSuspendID),'active','suspend' ) as status, - M_PatientAddressM_KelurahanID M_KelurahanID, - 0 M_DistrictID, - 0 M_CityID, + M_PatientAddressM_KelurahanID M_KelurahanID, + M_PatientAddressRegionalCd, + M_PatientAddressDescription, + M_PatientAddressDescription_enc, + 0 M_DistrictID, + 0 M_CityID, 0 M_ProvinceID FROM one_klinik.order JOIN m_patient ON M_PatientID = orderM_PatientID AND M_PatientIsActive = 'Y' @@ -86,26 +98,33 @@ class Anamnesedoctor extends MY_Controller $rows = $query->result_array(); foreach ($rows as $k => $v) { - $rows[$k]['M_PatientName'] = stripslashes($rows[$k]['M_PatientName']); - $rows[$k]['M_PatientAddressDescription'] = stripslashes($v['M_PatientAddressDescription']); - $patient_name = str_replace("'", "\\'", $prm['M_PatientName']); - $sql = "SELECT *, concat('{$rows[$k]['M_PatientAddressDescription']}', '\n\n', - m_kelurahanname, ', ', - m_districtname,'\n', - m_cityname, ', ', - m_provincename) as xaddress - FROM m_kelurahan - JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID - JOIN m_city ON M_DistrictM_CityID = M_CityID - JOIN m_province ON M_CityM_ProvinceID = M_ProvinceID - WHERE - M_KelurahanID = {$v['M_KelurahanID']} "; - //echo $sql; - $row_address = $this->db_onedev->query($sql)->row_array(); - $rows[$k]['M_PatientAddress'] = stripslashes($row_address['xaddress']); - $rows[$k]['M_DistrictID'] = $row_address['M_DistrictID']; - $rows[$k]['M_CityID'] = $row_address['M_CityID']; - $rows[$k]['M_ProvinceID'] = $row_address['M_ProvinceID']; + $enc = $this->ibl_encryptor; + $rows[$k]['M_PatientName'] = $enc->decrypt($v['M_PatientName_enc'] ?? '') ?: stripslashes($v['M_PatientName']); + $rows[$k]['M_PatientHP'] = $enc->decrypt($v['M_PatientHP_enc'] ?? '') ?: $v['M_PatientHP']; + $rows[$k]['M_PatientEmail'] = $enc->decrypt($v['M_PatientEmail_enc'] ?? '') ?: $v['M_PatientEmail']; + $rows[$k]['M_PatientPOB'] = $enc->decrypt($v['M_PatientPOB_enc'] ?? '') ?: $v['M_PatientPOB']; + $rows[$k]['M_PatientPhone'] = $enc->decrypt($v['M_PatientPhone_enc'] ?? '') ?: $v['M_PatientPhone']; + $rows[$k]['M_PatientIDNumber'] = $enc->decrypt($v['M_PatientIDNumber_enc'] ?? '') ?: $v['M_PatientIDNumber']; + $rows[$k]['M_PatientDOB'] = $enc->decrypt($v['M_PatientDOB_enc'] ?? '') ?: $v['M_PatientDOB']; + $rows[$k]['M_PatientNIK'] = $enc->decrypt($v['M_PatientNIK_enc'] ?? '') ?: $v['M_PatientNIK']; + $rows[$k]['M_PatientAddressDescription'] = $enc->decrypt($v['M_PatientAddressDescription_enc'] ?? '') ?: stripslashes($v['M_PatientAddressDescription'] ?? ''); + + $reg_cd = $v['M_PatientAddressRegionalCd'] ?? ''; + if ($reg_cd) { + $reg = $this->db_onedev->query( + "SELECT r_kel.regional_name as kel_name, r_kec.regional_name as kec_name, r_kab.regional_name as kab_name, r_pro.regional_name as pro_name + FROM regional r_kel + LEFT JOIN regional r_kec ON r_kec.regional_cd = LEFT(r_kel.regional_cd,7) AND RIGHT(r_kec.regional_cd,3)='000' + LEFT JOIN regional r_kab ON r_kab.regional_cd = LEFT(r_kel.regional_cd,4) AND RIGHT(r_kab.regional_cd,6)='000000' + LEFT JOIN regional r_pro ON r_pro.regional_cd = LEFT(r_kel.regional_cd,2) AND RIGHT(r_pro.regional_cd,8)='00000000' + WHERE r_kel.regional_cd = ?", [$reg_cd] + )->row_array(); + $rows[$k]['M_PatientAddress'] = $rows[$k]['M_PatientAddressDescription'] . "\n\n" . + implode(', ', array_filter([$reg['kel_name'] ?? '', $reg['kec_name'] ?? '', $reg['kab_name'] ?? '', $reg['pro_name'] ?? ''])); + } else { + $rows[$k]['M_PatientAddress'] = $rows[$k]['M_PatientAddressDescription']; + } + $info = $this->db_onedev->query("SELECT fn_fo_patient_visit(?) info", [$v['M_PatientID']])->row(); $rows[$k]['info'] = json_decode($info->info); }