{{-- Smart Report v2 - Another Semen Analysis (ASA, SAH). --}} {{-- Mirrors SmartReportService::GetAnotherSemenanalysisPDF (lines 7838-8039). --}} {{-- Tabular layout on pcr-test template with optional hours sub-section for SAH. --}} @php $service = $service ?? app(\App\Services\SmartReportV2Service::class); $Package = $group['package'] ?? ($group['firstPackage'] ?? null); $code = $Package->lABCATEGORYPACKAGE->CODE ?? ''; $isSah = ($code === 'SAH'); $model = $Package ? $service->buildAnotherSemenModel($Package, $Profile, $code) : ['code' => $code, 'pages' => [['header' => [], 'rows' => [], 'is_hours' => false]], 'comment' => null]; @endphp @foreach ($model['pages'] as $pageIdx => $page)
@include('pdf.smart_report.components.backgrounds.bg', ['template' => 'pcr', 'page' => 1]) @include('pdf.smart_report.components.patient_header', [ 'Order' => $Order, 'Profile' => $Profile, 'firstPackage' => $Package, 'Category' => $Package->lABCATEGORYPACKAGE->NAME_EN ?? '', 'Description' => $Package->lABCATEGORYPACKAGE->SMART_DESC_AR ?? '', 'setAdvice' => false, ]) @if ($page['is_hours'] ?? false) {{-- Hours grid: Test Name | 1/2 hour | 1st hour | 2nd hour, with --}} {{-- Vigorous / Sluggish / Non motile rows. Header + body are two --}} {{-- stacked tables so columns align across the header divider. --}} {{-- Columns: 50/40/37/40mm ≈ old x-gaps 25/75/115/152. --}} @php $baseY = $page['rows'][0]['y'] ?? 110; $subLabels = ['Vigorous', 'Sluggish', 'Non motile']; // Group results into rows of 3 (one per time column). $hourRows = array_chunk(array_map(fn ($r) => $r['result'] ?? '', $page['rows']), 3); @endphp @php $hourColW = [50, 40, 37, 40]; @endphp
@foreach ($page['header'] as $hi => $hdr)
{{ $hdr['text'] }}
@endforeach
@foreach ($hourRows as $gi => $cols)
{{ $subLabels[$gi] ?? '' }}
@foreach ([0, 1, 2] as $c)
{{ $cols[$c] ?? '' }}
@endforeach
@endforeach
@else {{-- Standard tabular rows: Test Name | Result | [Normal Range] | Unit --}} {{-- Header + body as two stacked display:table grids. Column widths --}} {{-- mirror the old x-gaps (SAH: 25/76/115/155; non-SAH: 25/90/-/155). --}} @php $nameW = $isSah ? 51 : 65; $resW = $isSah ? 39 : 65; @endphp
@foreach ($page['header'] as $hdr)
{{ $hdr['text'] }}
@endforeach
@foreach ($page['rows'] as $row) @php $displayValue = !empty($row['result']) ? $row['result'] : ($row['has_option'] ? $row['option_name'] : ''); @endphp
{{ $row['name_en'] }}
{{ $displayValue }}
@if ($isSah)
{{ $row['normal_range'] ?? '' }}
@endif
{{ $row['unit'] }}
@endforeach
@endif {{-- Comment (last page only) --}} @if ($loop->last && !empty($model['comment']))
{!! $service->sanitizeCommentHtml($model['comment']) !!}
@endif
@endforeach