From c091b601681d8f28d7a20544a38b9db18bb9cd2f Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Thu, 11 Jun 2026 07:47:35 +0530 Subject: [PATCH] Add discharge summary free-text content to PDF output - Include ipd_discharge_instructions.comp_remark in discharge summary section - Previously only showed status header, missing actual discharge narrative - Reuse existing instructionRowForMeta query to avoid duplicate DB calls - Apply renderRichText() to properly display HTML editor content Fixes missing discharge summary text for IPD 1007168 and similar cases --- app/Controllers/Ipd_discharge.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/app/Controllers/Ipd_discharge.php b/app/Controllers/Ipd_discharge.php index 6ac0c21..afffebc 100644 --- a/app/Controllers/Ipd_discharge.php +++ b/app/Controllers/Ipd_discharge.php @@ -1873,13 +1873,28 @@ class Ipd_discharge extends BaseController // It is available as {{PATIENT_INFO_TABLE}} token for templates to use if needed. // This matches CI3 behavior where template controlled the patient info display. - // Build Discharge Summary section - ONLY the status header + // Build Discharge Summary section with status header and free-text content // Get discharge status text based on ipd_status from ipd_discharg_status table $dischargeStatusHeader = $this->getDischargeStatusText($ipd); - if ($dischargeStatusHeader !== '') { - // {{DISCHARGE_SUMMARY}} placeholder - ONLY the status header, no additional info - $sections[] = '

' . esc($dischargeStatusHeader) . '

'; + // Get discharge summary free-text content from ipd_discharge_instructions.comp_remark + // (instructionRowForMeta was already loaded above at line ~1856) + $dischargeSummaryText = $this->normalizeRichText((string) ($instructionRowForMeta['comp_remark'] ?? '')); + + if ($dischargeStatusHeader !== '' || $dischargeSummaryText !== '') { + $summaryHtml = ''; + + if ($dischargeStatusHeader !== '') { + $summaryHtml .= '

' . esc($dischargeStatusHeader) . '

'; + } + + if ($dischargeSummaryText !== '') { + $summaryHtml .= '
' . $this->renderRichText($dischargeSummaryText) . '
'; + } + + if ($summaryHtml !== '') { + $sections[] = $summaryHtml; + } } $complaints = $this->byIpdRows('ipd_discharge_complaint', ['comp_report', 'comp_remark'], 'id ASC', $ipdId);