From 670f6d3f1f8a3b93ef2fe20eadfa53e414cfac7c Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Mon, 10 Aug 2026 14:58:50 +0530 Subject: [PATCH] fix: respect configured discharge template content --- app/Controllers/Ipd_discharge.php | 39 ------------------------------- 1 file changed, 39 deletions(-) diff --git a/app/Controllers/Ipd_discharge.php b/app/Controllers/Ipd_discharge.php index 3eaf598..c4c4c09 100644 --- a/app/Controllers/Ipd_discharge.php +++ b/app/Controllers/Ipd_discharge.php @@ -1104,9 +1104,6 @@ class Ipd_discharge extends BaseController $tokenVars['INSTRUCTION_REMARK'] = ''; } - if (! $this->templateHasKnownDischargeTokens($templateHtml, $tokenVars)) { - $templateHtml .= "\n{{CONTENT}}"; - } $patientName = html_entity_decode((string) ($tokenVars['PATIENT_NAME'] ?? ''), ENT_QUOTES, 'UTF-8'); $patientCode = html_entity_decode((string) ($tokenVars['UHID'] ?? ''), ENT_QUOTES, 'UTF-8'); $ipdCode = html_entity_decode((string) ($tokenVars['IPD_CODE'] ?? ''), ENT_QUOTES, 'UTF-8'); @@ -1181,42 +1178,6 @@ class Ipd_discharge extends BaseController return $renderedHtml; } - private function templateHasKnownDischargeTokens(string $templateHtml, array $tokenVars): bool - { - if (trim($templateHtml) === '') { - return false; - } - - $matches = []; - $matchCount = preg_match_all('/\{\{\s*([A-Za-z0-9_]+)\s*\}\}|\{\s*([A-Za-z0-9_]+)\s*\}/', $templateHtml, $matches, PREG_SET_ORDER); - if ($matchCount === false || $matchCount === 0) { - return false; - } - - foreach ($matches as $match) { - $tokenName = (string) (($match[1] ?? '') !== '' ? $match[1] : ($match[2] ?? '')); - if ($tokenName === '') { - continue; - } - - $lower = strtolower($tokenName); - $candidates = [ - $tokenName, - strtoupper($tokenName), - $lower, - ucfirst($lower), - ]; - - foreach ($candidates as $candidate) { - if (array_key_exists($candidate, $tokenVars)) { - return true; - } - } - } - - return false; - } - private function shouldUseContentOnlyTemplate(string $content, string $templateHtml): bool { $content = trim($content);