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:
';
+ foreach ($selectedManualInvestRows as $row) {
+ $html .= '- ' . esc((string) ($row['label'] ?? '')) . ': ' . esc((string) ($row['value'] ?? '')) . '
';
+ }
+ $html .= '
';
+ }
+
+ if (! empty($selectedSpecialInvestRows)) {
+ $html .= 'Special Investigations:
';
+ foreach ($selectedSpecialInvestRows as $row) {
+ $html .= '- ' . esc((string) ($row['label'] ?? '')) . ': ' . esc((string) ($row['value'] ?? '')) . '
';
+ }
+ $html .= '
';
+ }
+
$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 = [
+
+