From 0cf019ddf7236f3bded9015fe8554c53f108eadb Mon Sep 17 00:00:00 2001 From: "sas.fajri" Date: Mon, 15 Jun 2026 15:50:07 +0700 Subject: [PATCH] FHM08062601IBL - add M_PatientPhoto to sp_rpt_fo_001 for kartu kontrol photo Co-Authored-By: Claude Sonnet 4.6 --- .../2026-06-15-add-photo-to-sp-rpt-fo-001.sql | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 sql/manual_changes/2026-06-15-add-photo-to-sp-rpt-fo-001.sql diff --git a/sql/manual_changes/2026-06-15-add-photo-to-sp-rpt-fo-001.sql b/sql/manual_changes/2026-06-15-add-photo-to-sp-rpt-fo-001.sql new file mode 100644 index 00000000..0686643b --- /dev/null +++ b/sql/manual_changes/2026-06-15-add-photo-to-sp-rpt-fo-001.sql @@ -0,0 +1,34 @@ +-- Add M_PatientPhoto AS Photo to sp_rpt_fo_001 so kartu_kontrol PDF can render patient photo + +DROP PROCEDURE IF EXISTS `sp_rpt_fo_001`; +DELIMITER $$ +CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_rpt_fo_001`(IN `PID` int, IN `username` varchar(100)) +BEGIN +DELETE FROM patient_print_cache WHERE ppc_created < NOW() - INTERVAL 5 MINUTE; + +SELECT + CONCAT(M_TitleName,' ',IFNULL(M_PatientPrefix,''),' ', + COALESCE(NULLIF(ppc.ppc_name,''), M_PatientName),' ',IFNULL(M_PatientSuffix,'')) AS M_PatientName, + COALESCE(NULLIF(ppc.ppc_dob,''), DATE_FORMAT(M_PatientDOB,'%d-%m-%Y')) AS M_PatientDOB, + CONCAT(COALESCE(NULLIF(ppc.ppc_dob,''), DATE_FORMAT(M_PatientDOB,'%d-%m-%Y')),' / ',T_OrderHeaderM_PatientAge,' / ',M_SexCode) AS Umur, + COALESCE(NULLIF(ppc.ppc_hp,''), M_PatientHP) AS M_PatientHP, + COALESCE(NULLIF(ppc.ppc_hp,''), M_PatientPhone) AS M_PatientPhone, + COALESCE(NULLIF(ppc.ppc_email,''), M_PatientEmail) AS M_PatientEmail, + COALESCE(NULLIF(ppc.ppc_address,''), + (SELECT M_PatientAddressDescription FROM m_patientaddress AS p + WHERE M_PatientAddressM_PatientID = M_PatientID + ORDER BY M_PatientAddressM_PatientID LIMIT 1) + ) AS M_PatientAddressDescription, + M_PatientNoReg, M_PatientIDNumber, M_PatientNIK, M_PatientPhoto AS Photo, + T_OrderHeaderLabNumber, DATE_FORMAT(T_OrderHeaderDate,'%d-%m-%Y') AS T_OrderHeaderDate, + T_OrderHeaderID, M_CompanyName, M_PatientNote +FROM t_orderheader +LEFT JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID +LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID +LEFT JOIN m_sex ON M_PatientM_SexID = M_SexID +JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID +LEFT JOIN patient_print_cache ppc ON ppc.ppc_order_id = T_OrderHeaderID +WHERE T_OrderHeaderID = PID AND T_OrderHeaderIsActive = 'Y'; +END +$$ +DELIMITER ;