From a540581bf951f6151074a7711273f7b2102cc46e Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Fri, 5 Jun 2026 15:28:01 +0530 Subject: [PATCH] Fix {{Tadvise_test_list}} to always populate from rx_investigations Previous implementation only built test list when investigation textarea was empty, preventing {{Tadvise_test_list}} from showing when textarea had content. Changes: - Separated test list building from textarea population logic - {{Tadvise_test_list}} now always populates when rx_investigations exists - {{investigation}} still gets comma-separated fallback when textarea empty - Both placeholders now work independently Test list HTML output format: --- app/Controllers/Opd.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/Controllers/Opd.php b/app/Controllers/Opd.php index af14e1d..a70c2a3 100644 --- a/app/Controllers/Opd.php +++ b/app/Controllers/Opd.php @@ -2796,20 +2796,24 @@ class Opd extends BaseController }; $rxInvestigation = $rxRead($rx, ['investigation', 'Investigations', 'investigations', 'Investigation']); + + // Build test list independently from textarea content $rxInvestigationTestList = ''; - if ($rxInvestigation === '' && !empty($data['rx_investigations']) && is_array($data['rx_investigations'])) { - $parts = []; + 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 !== '') { - $parts[] = $txt; $testNames[] = $txt; } } - $rxInvestigation = implode(', ', $parts); - // Build formatted test list for {{Tadvise_test_list}} placeholder + // 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 = '