From 0b865f41cd70277a1fe226d6700670edf1bb1079 Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Fri, 5 Jun 2026 15:55:34 +0530 Subject: [PATCH] Add textarea fallback for {{Tadvise_test_list}} placeholder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When opd_prescription_investigation table is empty but investigation textarea has content, parse textarea content (split by newlines) to populate the test list. This handles cases where tests are entered as free-text in the "Advise Investigation" textarea instead of selecting from master list. Parsing logic: - Try rx_investigations table first - If empty, split investigation textarea by newlines - Filter out empty lines and 'null' values - Build HTML bullet list from either source Example textarea content: USG WHOLE ABDOMEN CECT ABDOMEN PAC COMPLETE CARDIAC CHECK UP PAP SMEAR Will render as: • USG WHOLE ABDOMEN • CECT ABDOMEN • PAC • COMPLETE CARDIAC CHECK UP • PAP SMEAR --- app/Controllers/Opd.php | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/app/Controllers/Opd.php b/app/Controllers/Opd.php index de3b776..5c8c08b 100644 --- a/app/Controllers/Opd.php +++ b/app/Controllers/Opd.php @@ -2806,29 +2806,43 @@ class Opd extends BaseController // Build test list independently from textarea content $rxInvestigationTestList = ''; + $testNames = []; + + // First, try to get tests from rx_investigations table if (!empty($data['rx_investigations']) && is_array($data['rx_investigations'])) { - $testNames = []; foreach ($data['rx_investigations'] as $inv) { $txt = trim((string) ($inv['investigation_name'] ?? $inv['investigation'] ?? '')); if ($txt !== '') { $testNames[] = $txt; } } - - // If textarea is empty, also populate it with comma-separated tests - if ($rxInvestigation === '' && !empty($testNames)) { - $rxInvestigation = implode(', ', $testNames); - } - - // Always build formatted HTML test list for {{Tadvise_test_list}} placeholder - if (!empty($testNames)) { - $rxInvestigationTestList = ''; } } + + // If textarea is empty, populate it with comma-separated tests from table + if ($rxInvestigation === '' && !empty($testNames)) { + $rxInvestigation = implode(', ', $testNames); + } + + // Always build formatted HTML test list for {{Tadvise_test_list}} placeholder + if (!empty($testNames)) { + $rxInvestigationTestList = ''; + } $rxAdvice = $rxRead($rx, ['advice', 'Advice', 'prescription_advice', 'advice_notes', 'advice_note']); $rxAdviceLocal = '';