fix(discharge): honor investigation checkbox selection and print manual/special investigations

This commit is contained in:
DevSoftTech Server 2026-08-01 02:15:13 +05:30
parent bb448a38eb
commit d751ff9b4b
2 changed files with 63 additions and 3 deletions

View File

@ -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 = '<h4 class="discharge-section-heading">Clinical Investigation Reports</h4>';
if (! empty($pathologyMatrix['rows'])) {
@ -2564,6 +2586,22 @@ class Ipd_discharge extends BaseController
$html .= '</ul>';
}
if (! empty($selectedManualInvestRows)) {
$html .= '<div><b>Manual Clinical Investigations:</b></div><ul class="discharge-sublist">';
foreach ($selectedManualInvestRows as $row) {
$html .= '<li><b>' . esc((string) ($row['label'] ?? '')) . ':</b> ' . esc((string) ($row['value'] ?? '')) . '</li>';
}
$html .= '</ul>';
}
if (! empty($selectedSpecialInvestRows)) {
$html .= '<div><b>Special Investigations:</b></div><ul class="discharge-sublist">';
foreach ($selectedSpecialInvestRows as $row) {
$html .= '<li><b>' . esc((string) ($row['label'] ?? '')) . ':</b> ' . esc((string) ($row['value'] ?? '')) . '</li>';
}
$html .= '</ul>';
}
$otherExamText = $this->normalizeRichText((string) ($otherExamParsed['text'] ?? ''));
if ($otherExamText !== '') {
$html .= '<div><b>Other Examinations / Provisional Diagnosis:</b><br>' . $this->renderRichText($otherExamText) . '</div>';
@ -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) {

View File

@ -925,6 +925,8 @@ $historyFields = [
<input type="hidden" name="lab_investigation_list" id="lab_investigation_list" value="<?= esc($labInvestigationList) ?>">
<input type="hidden" name="non_path_investigation_list" id="non_path_investigation_list" value="<?= esc($nonPathInvestigationList) ?>">
<input type="hidden" name="clinical_lab_selection_mode" value="checkbox">
<input type="hidden" name="clinical_nonpath_selection_mode" value="checkbox">
<div class="mt-3 d-flex justify-content-end">
<button type="submit" class="btn btn-outline-success btn-sm" name="action" value="save_main" data-reload-section="section-investigation">Save Clinical Investigation</button>