FHM08062601IBL - add M_PatientPhoto to sp_rpt_fo_001 for kartu kontrol photo

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
sas.fajri
2026-06-15 15:50:07 +07:00
parent 5e1371a248
commit 0cf019ddf7

View File

@@ -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 ;