@include('frontend.diagnostic.scan.partials.lab-report-pdf-running-header') @include('backend.template.diagnostic.cases.bill.partials.lab-report-running-footer', ['pdfRunningFooter' => true]) @php $grouped = $resultGroups ?? collect(); $shownNoteFingerprints = []; foreach ($grouped as $noteCategory => $groupTests) { $catNoteMeta = app(\App\Http\Controllers\Backend\CasesController::class) ->categoryPanelMeta($bill, (string) $noteCategory); $noteFp = \App\Support\RichTextSanitizer::plainTextFingerprint($catNoteMeta['note'] ?? ''); if ($noteFp !== '') { $shownNoteFingerprints[] = $noteFp; } } $reportInterpretation = trim((string) ($bill->report_interpretation ?? '')); $perTestInterpFingerprints = []; foreach ($grouped as $groupTests) { foreach ($groupTests as $row) { if (! empty($row->skip_interpretation)) { continue; } $rowInterp = trim((string) ($row->interpretation ?? '')); if ($rowInterp === '') { continue; } $rowFp = \App\Support\RichTextSanitizer::plainTextFingerprint($rowInterp); if ($rowFp !== '') { $perTestInterpFingerprints[] = $rowFp; } } } $interpFp = \App\Support\RichTextSanitizer::plainTextFingerprint($reportInterpretation); if ($interpFp !== '' && ( in_array($interpFp, $shownNoteFingerprints, true) || in_array($interpFp, $perTestInterpFingerprints, true) )) { $reportInterpretation = ''; } elseif ($reportInterpretation !== '') { $reportInterpretation = \App\Support\RichTextSanitizer::cleanClinicalNotes($reportInterpretation); } @endphp @if ($grouped->isEmpty())

No results entered yet.

--- End of report ---
@else @foreach ($grouped as $category => $tests)
{{ strtoupper($categoryLabels[$category] ?? $category) }}
@include('frontend.diagnostic.scan.partials.lab-report-results-rows', ['tests' => $tests])
TEST VALUE UNIT REFERENCE
@include('frontend.diagnostic.scan.partials.lab-report-category-notes', [ 'bill' => $bill, 'category' => $category, 'appendEndOfReport' => $loop->last && $reportInterpretation === '', ]) @if ($loop->last && $reportInterpretation === '') {{-- Fallback if this category had no notes box to attach the marker to. --}} @php $lastCatMeta = app(\App\Http\Controllers\Backend\CasesController::class)->categoryPanelMeta($bill, $category); $lastNoteHtml = \App\Support\RichTextSanitizer::cleanClinicalNotes($lastCatMeta['note'] ?? ''); $hadNotesBox = $lastNoteHtml !== '' || ($lastCatMeta['remarks'] ?? '') !== '' || ($lastCatMeta['advice'] ?? '') !== ''; @endphp @if (! $hadNotesBox)
--- End of report ---
@endif @endif @endforeach @endif @if ($reportInterpretation !== '')
 

Clinical Notes

{!! $reportInterpretation !!}
--- End of report ---
@endif