From e24b71bbc92f9a4751223cc54380ace2dad8898c Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Tue, 1 Sep 2026 18:24:50 +0530 Subject: [PATCH] fix(ipd_discharge): enable serializeDischargeMedicineTable on form submit and robust JSON response handling --- app/Views/billing/ipd/discharge_create.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/Views/billing/ipd/discharge_create.php b/app/Views/billing/ipd/discharge_create.php index a6a4025..d8a5fb8 100644 --- a/app/Views/billing/ipd/discharge_create.php +++ b/app/Views/billing/ipd/discharge_create.php @@ -6807,9 +6807,15 @@ $historyFields = [ dataType: 'json', timeout: 30000 }).done(function(data) { + if (typeof data === 'string') { + try { + data = JSON.parse(data); + } catch (e) {} + } updateFormCsrf(activeForm, data || {}); - if (!data || typeof data !== 'object' || parseInt(data.update || '0', 10) !== 1) { + var isSuccess = data && (data.update === 1 || data.update === '1' || data.update === true || (data.row_id && parseInt(data.row_id, 10) > 0)); + if (!isSuccess) { setMedicineStatus((data && data.notice) ? data.notice : 'Failed to save medicine to database.', 'error'); return; } @@ -7297,8 +7303,7 @@ $historyFields = [ return; } syncEditorValues(); - // DISABLED: No longer needed since medicines are saved via AJAX on Add button - // serializeDischargeMedicineTable(); + serializeDischargeMedicineTable(); syncClinicalLabSelection(form); syncCoMorbidityHidden(form);