From d7e5f16f79b6189e039cd4ef223b19e7366e585a Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Fri, 31 Jul 2026 17:41:15 +0530 Subject: [PATCH] fix(ipd-discharge): honor updated DB template instead of forcing content-only fallback --- app/Controllers/Ipd_discharge.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/Controllers/Ipd_discharge.php b/app/Controllers/Ipd_discharge.php index fd2c414..3289496 100644 --- a/app/Controllers/Ipd_discharge.php +++ b/app/Controllers/Ipd_discharge.php @@ -1167,6 +1167,16 @@ class Ipd_discharge extends BaseController return false; } + // Respect configured DB templates. Only fall back to content-only mode + // when the template is effectively a plain CONTENT wrapper. + $normalizedTemplate = $this->normalizeLegacyDischargeTemplate($templateHtml); + $normalizedTemplate = $this->normalizeDischargeTemplatePlaceholders($normalizedTemplate); + $templateWithoutContent = (string) preg_replace('/\{\{\s*CONTENT\s*\}\}|\{\s*CONTENT\s*\}/i', '', $normalizedTemplate); + $templateWithoutContent = trim(strip_tags($templateWithoutContent)); + if ($templateWithoutContent !== '') { + return false; + } + // If the template explicitly places section placeholders, preserve that order. if ($this->templateHasDischargeSectionPlaceholders($templateHtml)) { return false;