From 11860743b87d76c7d986f31205a28fd2a58a4908 Mon Sep 17 00:00:00 2001 From: "sas.fajri" Date: Thu, 11 Jun 2026 14:54:06 +0700 Subject: [PATCH] FHM09062601IBL - petugas penyuntik: autocomplete dari m_staff, ganti kolom ke M_StaffID Co-Authored-By: Claude Sonnet 4.6 --- .../klinik/doctorv5/Anamnesedoctor.php | 48 +++++++++++-------- ...1-alter-order-vaccine-petugas-to-staff.sql | 5 ++ 2 files changed, 32 insertions(+), 21 deletions(-) create mode 100644 sql/manual_changes/2026-06-11-alter-order-vaccine-petugas-to-staff.sql diff --git a/application/controllers/klinik/doctorv5/Anamnesedoctor.php b/application/controllers/klinik/doctorv5/Anamnesedoctor.php index c69cf616..6acb4185 100644 --- a/application/controllers/klinik/doctorv5/Anamnesedoctor.php +++ b/application/controllers/klinik/doctorv5/Anamnesedoctor.php @@ -3119,7 +3119,7 @@ function get_data_order_anamnesis($orderID){ // ─── Vaksin ──────────────────────────────────────────────────────────────── - // Master statis: injection_sites, routes, petugas (dipanggil sekali saat form dibuka) + // Master statis: injection_sites, routes (dipanggil sekali saat form dibuka) function get_vaccine_masters() { if (!$this->isLogin) { $this->sys_error("Invalid Token"); exit; } @@ -3144,24 +3144,32 @@ function get_data_order_anamnesis($orderID){ if (!$q) { $this->sys_error_db("get m_route_vaccine", $this->db_oneklinik); exit; } $result['routes'] = $q->result_array(); - // Petugas penyuntik - $q = $this->db_onedev->query( - "SELECT M_DoctorID as id, - CONCAT(IFNULL(M_DoctorPrefix,''), IFNULL(M_DoctorPrefix2,''), ' ', - M_DoctorName, ' ', - IFNULL(M_DoctorSufix,''), IFNULL(M_DoctorSufix2,''), IFNULL(M_DoctorSufix3,'')) as name - FROM m_doctormcu - JOIN m_doctor ON M_DoctorMcuM_DoctorID = M_DoctorID - WHERE M_DoctorMcuIsActive = 'Y' - ORDER BY M_DoctorName" - ); - if (!$q) { $this->sys_error_db("get doctors", $this->db_onedev); exit; } - $result['petugas'] = $q->result_array(); - $this->sys_ok($result); exit; } + // Autocomplete petugas penyuntik dari one_lab.m_staff, param: search + function get_vaccine_petugas() + { + if (!$this->isLogin) { $this->sys_error("Invalid Token"); exit; } + + $search = trim($this->sys_input['search'] ?? ''); + $search_esc = $this->db_onedev->escape_str($search); + + $sql = "SELECT M_StaffID as id, M_StaffName as name, M_StaffCode as code + FROM one_lab.m_staff + WHERE M_StaffIsActive = 'Y' + AND M_StaffName LIKE CONCAT('%', '{$search_esc}', '%') + ORDER BY M_StaffName + LIMIT 30"; + + $q = $this->db_onedev->query($sql); + if (!$q) { $this->sys_error_db("get m_staff", $this->db_onedev); exit; } + + $this->sys_ok(['records' => $q->result_array()]); + exit; + } + // Autocomplete jenis vaksin: filter by MOU order, param: orderid + search function get_vaccines() { @@ -3220,16 +3228,14 @@ function get_data_order_anamnesis($orderID){ t.T_TestSasCode as jenis_vaksin_code, ins.M_InjectionSiteName as injection_site_name, rv.M_RouteVaccineName as route_name, - CONCAT(IFNULL(d.M_DoctorPrefix,''), IFNULL(d.M_DoctorPrefix2,''), ' ', - d.M_DoctorName, ' ', - IFNULL(d.M_DoctorSufix,''), IFNULL(d.M_DoctorSufix2,''), IFNULL(d.M_DoctorSufix3,'')) as petugas_name + s.M_StaffName as petugas_name FROM one_klinik.order_vaccine ov LEFT JOIN one_lab.t_test t ON ov.orderVaccineT_TestID = t.T_TestID LEFT JOIN one_klinik.m_injection_site ins ON ov.orderVaccineInjectionSiteCode = ins.M_InjectionSiteCode LEFT JOIN one_klinik.m_route_vaccine rv ON ov.orderVaccineRouteCode = rv.M_RouteVaccineCode - LEFT JOIN m_doctor d ON ov.orderVaccinePetugasM_DoctorID = d.M_DoctorID + LEFT JOIN one_lab.m_staff s ON ov.orderVaccinePetugasM_StaffID = s.M_StaffID WHERE ov.orderVaccineOrderID = ? AND ov.orderVaccineIsActive = 'Y' ORDER BY ov.orderVaccineCreated ASC"; @@ -3280,7 +3286,7 @@ function get_data_order_anamnesis($orderID){ orderVaccineDosis = ?, orderVaccineInjectionSiteCode = ?, orderVaccineRouteCode = ?, - orderVaccinePetugasM_DoctorID = ?, + orderVaccinePetugasM_StaffID = ?, orderVaccineGivenAt = ?, orderVaccineNextDate = ?, orderVaccineCatatan = ?, @@ -3298,7 +3304,7 @@ function get_data_order_anamnesis($orderID){ "INSERT INTO one_klinik.order_vaccine (orderVaccineOrderID, orderVaccineT_TestID, orderVaccineBatchNumber, orderVaccineExpiredDate, orderVaccineDosis, orderVaccineInjectionSiteCode, - orderVaccineRouteCode, orderVaccinePetugasM_DoctorID, orderVaccineGivenAt, + orderVaccineRouteCode, orderVaccinePetugasM_StaffID, orderVaccineGivenAt, orderVaccineNextDate, orderVaccineCatatan, orderVaccineUserID) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)", [ diff --git a/sql/manual_changes/2026-06-11-alter-order-vaccine-petugas-to-staff.sql b/sql/manual_changes/2026-06-11-alter-order-vaccine-petugas-to-staff.sql new file mode 100644 index 00000000..82366904 --- /dev/null +++ b/sql/manual_changes/2026-06-11-alter-order-vaccine-petugas-to-staff.sql @@ -0,0 +1,5 @@ +-- Ganti kolom petugas penyuntik dari M_DoctorID ke M_StaffID (one_lab.m_staff) +ALTER TABLE one_klinik.order_vaccine + CHANGE COLUMN `orderVaccinePetugasM_DoctorID` + `orderVaccinePetugasM_StaffID` int(11) DEFAULT NULL + COMMENT 'petugas penyuntik FK one_lab.m_staff.M_StaffID';