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:
<ul style="margin:3px 0 0 16px;padding:0;list-style-type:disc;">
<li>CBC (Complete Blood Count)</li>
<li>ECG (Electrocardiogram)</li>
<li>HBA1C</li>
</ul>
This commit is contained in:
parent
6f6286f427
commit
a540581bf9
|
|
@ -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 = '<ul style="margin:3px 0 0 16px;padding:0;list-style-type:disc;">';
|
||||
foreach ($testNames as $testName) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user