From d751ff9b4bd13b395f0139f52c359d9592863cfb Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Sat, 1 Aug 2026 02:15:13 +0530 Subject: [PATCH] fix(discharge): honor investigation checkbox selection and print manual/special investigations --- app/Controllers/Ipd_discharge.php | 64 +++++++++++++++++++++- app/Views/billing/ipd/discharge_create.php | 2 + 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/app/Controllers/Ipd_discharge.php b/app/Controllers/Ipd_discharge.php index 78af58c..4f44d69 100644 --- a/app/Controllers/Ipd_discharge.php +++ b/app/Controllers/Ipd_discharge.php @@ -2509,7 +2509,29 @@ class Ipd_discharge extends BaseController } } - if (! empty($pathologyMatrix['rows']) || ! empty($selectedLabRows) || ! empty($selectedNonPathRows) || trim((string) ($otherExamParsed['text'] ?? '')) !== '') { + $manualInvestRows = $this->getMappedColRows('ipd_discharge_investigation_during_admit', 'ipd_discharge_1_d', $ipdId, 'Manual Exam', 1); + $selectedManualInvestRows = []; + foreach ($manualInvestRows as $row) { + $label = trim((string) ($row['label'] ?? '')); + $value = trim((string) ($row['value'] ?? '')); + if ($label === '' || $value === '') { + continue; + } + $selectedManualInvestRows[] = ['label' => $label, 'value' => $value]; + } + + $specialInvestRows = $this->getMappedColRows('ipd_discharge_special_investigation', 'ipd_discharge_1_e', $ipdId, 'Special Exam', 1); + $selectedSpecialInvestRows = []; + foreach ($specialInvestRows as $row) { + $label = trim((string) ($row['label'] ?? '')); + $value = trim((string) ($row['value'] ?? '')); + if ($label === '' || $value === '') { + continue; + } + $selectedSpecialInvestRows[] = ['label' => $label, 'value' => $value]; + } + + if (! empty($pathologyMatrix['rows']) || ! empty($selectedLabRows) || ! empty($selectedNonPathRows) || ! empty($selectedManualInvestRows) || ! empty($selectedSpecialInvestRows) || trim((string) ($otherExamParsed['text'] ?? '')) !== '') { $html = '

Clinical Investigation Reports

'; if (! empty($pathologyMatrix['rows'])) { @@ -2564,6 +2586,22 @@ class Ipd_discharge extends BaseController $html .= ''; } + if (! empty($selectedManualInvestRows)) { + $html .= '
Manual Clinical Investigations:
'; + } + + if (! empty($selectedSpecialInvestRows)) { + $html .= '
Special Investigations:
'; + } + $otherExamText = $this->normalizeRichText((string) ($otherExamParsed['text'] ?? '')); if ($otherExamText !== '') { $html .= '
Other Examinations / Provisional Diagnosis:
' . $this->renderRichText($otherExamText) . '
'; @@ -6593,9 +6631,20 @@ class Ipd_discharge extends BaseController $otherExamText = trim((string) ($this->request->getPost('other_exam_text') ?? '')); $postedClinicalDates = $this->request->getPost('lab_investigation_dates'); $postedNonPathIds = $this->request->getPost('non_path_investigation_ids'); + $clinicalLabSelectionMode = trim((string) ($this->request->getPost('clinical_lab_selection_mode') ?? '')); + $clinicalNonPathSelectionMode = trim((string) ($this->request->getPost('clinical_nonpath_selection_mode') ?? '')); $normalizedClinicalDates = []; $normalizedNonPathIds = []; - if (is_array($postedClinicalDates)) { + if ($clinicalLabSelectionMode === 'checkbox') { + if (is_array($postedClinicalDates)) { + foreach ($postedClinicalDates as $dt) { + $parsed = $this->normalizeDateValue((string) $dt); + if ($parsed !== null) { + $normalizedClinicalDates[$parsed] = $parsed; + } + } + } + } elseif (is_array($postedClinicalDates)) { foreach ($postedClinicalDates as $dt) { $parsed = $this->normalizeDateValue((string) $dt); if ($parsed !== null) { @@ -6609,7 +6658,16 @@ class Ipd_discharge extends BaseController } } - if (is_array($postedNonPathIds)) { + if ($clinicalNonPathSelectionMode === 'checkbox') { + if (is_array($postedNonPathIds)) { + foreach ($postedNonPathIds as $id) { + $id = (int) $id; + if ($id > 0) { + $normalizedNonPathIds[$id] = $id; + } + } + } + } elseif (is_array($postedNonPathIds)) { foreach ($postedNonPathIds as $id) { $id = (int) $id; if ($id > 0) { diff --git a/app/Views/billing/ipd/discharge_create.php b/app/Views/billing/ipd/discharge_create.php index 6bf9380..2279635 100644 --- a/app/Views/billing/ipd/discharge_create.php +++ b/app/Views/billing/ipd/discharge_create.php @@ -925,6 +925,8 @@ $historyFields = [ + +