{{-- Smart Report v2 - Urinalysis (UA, PEU). --}} {{-- Mirrors SmartReportService::GetUrinalysisPDF (lines 4930-6023). --}} {{-- Two pages: page 1 = chemical strip results, page 2 = microscopic. --}} @php $service = $service ?? app(\App\Services\SmartReportV2Service::class); $Package = $group['package'] ?? ($group['firstPackage'] ?? null); $model = $Package ? $service->buildUrinalysisModel($Package) : ['page1' => [], 'page2' => []]; $p1 = $model['page1']; $p2 = $model['page2']; // v1 (GetUrinalysisPDF 4930-4936): title = package test name with // REPORT_DISPLAY_NAME_AR override, description = SMART_DESC_AR. $uaTestName = $Package->lABCATEGORYPACKAGE->NAME_AR ?? ''; if (!empty($Package->lABCATEGORYPACKAGE->REPORT_DISPLAY_NAME_AR)) $uaTestName = $Package->lABCATEGORYPACKAGE->REPORT_DISPLAY_NAME_AR; $uaDescription = $Package->lABCATEGORYPACKAGE->SMART_DESC_AR ?? ''; @endphp {{-- ═══════════════════════════ PAGE 1 ═══════════════════════════ --}}
@include('pdf.smart_report.components.backgrounds.bg', ['template' => 'urinalysis', 'page' => 1]) @include('pdf.smart_report.components.patient_header', [ 'Order' => $Order, 'Profile' => $Profile, 'firstPackage' => $Package, 'Category' => $uaTestName, 'Description' => $uaDescription, // v1's urinalysis description is narrower than the generic pages: // right edge ~153mm (aligned with the title text), not 162mm. 'descWidth' => 141, 'setAdvice' => false, ]) {{-- ── Color ── image at (160,99) w=8; text at (56,101)/(56,107) --}} @if (!empty($p1['color'])) @if (!empty($p1['color']['image']) && is_file($p1['color']['image'])) @endif @php $hex = $p1['color']['hex_code'] ?? '#000'; $ht = ltrim($hex, '#'); $cr = hexdec(substr($ht,0,2)); $cg = hexdec(substr($ht,2,2)); $cb = hexdec(substr($ht,4,2)); @endphp
{{ $p1['color']['name_ar'] }}
{{ $p1['color']['name_en'] }}
@endif {{-- ── Clarity ── success icon (105,100) w=10 / error icon (108,102) w=6; text at (6,101)/(6,107) --}} @if (!empty($p1['clarity'])) @if (($p1['clarity']['image_url'] ?? '') === 'success.png' && !empty($p1['clarity']['image']) && is_file($p1['clarity']['image'])) @elseif (($p1['clarity']['image_url'] ?? '') === 'error.png' && !empty($p1['clarity']['image']) && is_file($p1['clarity']['image'])) @endif
{{ $p1['clarity']['name_ar'] }}
{{ $p1['clarity']['name_en'] }}
@endif {{-- ── SG (Specific Gravity) ── image at (95,131) w=50; text at (20,139) --}} @if (!empty($p1['sg'])) @if (!empty($p1['sg']['image']) && is_file($p1['sg']['image'])) @endif @php $sgColor = ($p1['sg']['is_valid'] ?? false) ? 'rgb(120,201,38)' : 'rgb(221,52,68)'; @endphp
{{ $p1['sg']['name_en'] }}
@if (!empty($p1['sg']['desc_ar']))
{!! $service->isolateLtrRuns($p1['sg']['desc_ar']) !!}
@endif @endif {{-- ── PH ── image at (95,144) w=50; text at (37,150) --}} @if (!empty($p1['ph'])) @if (!empty($p1['ph']['image']) && is_file($p1['ph']['image'])) @endif {{-- direction:ltr on the BLOCK (not a span): Qt ignores unicode-bidi:isolate, so "6.5 (Acidic)" was reordering to "(Acidic) 6.5" under the RTL page. --}}
{{ $p1['ph']['name_en'] }}
@if (!empty($p1['ph']['desc_ar']))
{!! $service->isolateLtrRuns($p1['ph']['desc_ar']) !!}
@endif @endif {{-- ── LEU ── image at (95,158) w=50; desc at (8,159) --}} @if (!empty($p1['leu'])) @if (!empty($p1['leu']['image']) && is_file($p1['leu']['image'])) @endif @if (!empty($p1['leu']['desc_ar']))
{!! $service->isolateLtrRuns($p1['leu']['desc_ar']) !!}
@endif @endif {{-- ── NIT ── image at (95,172) w=50; desc at (8,175) --}} @if (!empty($p1['nit'])) @if (!empty($p1['nit']['image']) && is_file($p1['nit']['image'])) @endif @if (!empty($p1['nit']['desc_ar']))
{!! $service->isolateLtrRuns($p1['nit']['desc_ar']) !!}
@endif @endif {{-- ── PRO ── image at (95,187) w=50; desc at (8,187) --}} @if (!empty($p1['pro'])) @if (!empty($p1['pro']['image']) && is_file($p1['pro']['image'])) @endif @if (!empty($p1['pro']['desc_ar']))
{!! $service->isolateLtrRuns($p1['pro']['desc_ar']) !!}
@endif @endif {{-- ── GC (Glucose) ── --}} @if (!empty($p1['gc'])) @if (($p1['gc']['variant'] ?? 'option') === 'option') {{-- option: image at (95,201) w=50; desc at (8,200) --}} @if (!empty($p1['gc']['image']) && is_file($p1['gc']['image'])) @endif @else {{-- numeric: image at (95,203) w=50; min at (14,198); max at (38,198) --}}
{{ $p1['gc']['min_normal'] }}
{{ $p1['gc']['max_normal'] }}
@if (!empty($p1['gc']['image']) && is_file($p1['gc']['image'])) @endif
{{ $p1['gc']['result'] }} {{ $p1['gc']['unit'] ?? '' }}
@endif @if (!empty($p1['gc']['desc_ar']))
{!! $service->isolateLtrRuns($p1['gc']['desc_ar']) !!}
@endif @endif {{-- ── KET ── image at (95,216) w=50; desc at (8,215) --}} @if (!empty($p1['ket'])) @if (!empty($p1['ket']['image']) && is_file($p1['ket']['image'])) @endif @if (!empty($p1['ket']['desc_ar']))
{!! $service->isolateLtrRuns($p1['ket']['desc_ar']) !!}
@endif @endif {{-- ── UR (Urobilinogen) ── --}} @if (!empty($p1['ur'])) @if (($p1['ur']['variant'] ?? 'option') === 'option') {{-- option: image at (95,227) w=50 --}} @if (!empty($p1['ur']['image']) && is_file($p1['ur']['image'])) @endif @else {{-- numeric: image at (95,230) w=50; min at (25,225); max at (48,225) --}}
{{ $p1['ur']['min_normal'] }}
{{ $p1['ur']['max_normal'] }}
@if (!empty($p1['ur']['image']) && is_file($p1['ur']['image'])) @endif @php $urColor = ($p1['ur']['type'] === 'normal') ? 'rgb(120,201,38)' : 'rgb(221,52,68)'; $urMv = (int) round($p1['ur']['move']); if ($p1['ur']['type'] === 'normal') $urLeft = 24 + ($urMv - 1) * 4; elseif ($p1['ur']['type'] === 'high') $urLeft = 52 + ($urMv - 1) * 3; else $urLeft = 22 - ($urMv - 1) * 3; @endphp
{{ $p1['ur']['result'] }} {{ $p1['ur']['unit'] ?? '' }}
@endif @if (!empty($p1['ur']['desc_ar']))
{!! $service->isolateLtrRuns($p1['ur']['desc_ar']) !!}
@endif @endif {{-- ── BIL ── image at (95,242) w=50; desc at (8,241). --}} {{-- Desc at 7.5pt (was 8) so a 2-3 line bilirubin text ends before the --}} {{-- Blood description that now starts at 248mm. --}} @if (!empty($p1['bil'])) @if (!empty($p1['bil']['image']) && is_file($p1['bil']['image'])) @endif @if (!empty($p1['bil']['desc_ar'])) {{-- line-height 1.15 + an 8.5mm cap: two 8pt lines INCLUDING their --}} {{-- Arabic descenders render fully (text ends ~245.2, clearing the --}} {{-- Blood block at 245.5); only a 3+-line text hits the clip. --}}
{!! $service->isolateLtrRuns($p1['bil']['desc_ar']) !!}
@endif @endif {{-- ── BLD ── last row: pulled UP from v1's (95,255)/(8,255) so its 4-line --}} {{-- description ends ABOVE the footer hairline (260.4mm) instead of --}} {{-- spilling into the footer band (QA). Meter at 250.5, desc at 248 in --}} {{-- 7pt/1.25 (4 lines ≈ 12mm → ends ~260), hard-capped at the hairline. --}} {{-- The الدم/Blood background labels moved up in step (urinalysis.blade). --}} @if (!empty($p1['bld'])) @if (!empty($p1['bld']['image']) && is_file($p1['bld']['image'])) @endif @if (!empty($p1['bld']['desc_ar']))
{!! $service->isolateLtrRuns($p1['bld']['desc_ar']) !!}
@endif @endif
{{-- ═══════════════════════════ PAGE 2 ═══════════════════════════ --}}
@include('pdf.smart_report.components.backgrounds.bg', ['template' => 'urinalysis', 'page' => 2]) @include('pdf.smart_report.components.patient_header', [ 'Order' => $Order, 'Profile' => $Profile, 'firstPackage' => $Package, 'Category' => $uaTestName, 'Description' => $uaDescription, 'setAdvice' => true, ]) {{-- ── PC (Pus Cells) ── option text at (50,103); numeric image at (100,98) w=50 --}} @if (!empty($p2['pc'])) @if (($p2['pc']['variant'] ?? '') === 'option')
{{ $p2['pc']['name_en'] }} {{ $p2['pc']['unit'] ?? '' }}
@elseif (($p2['pc']['variant'] ?? '') === 'numeric') @if (!empty($p2['pc']['image']) && is_file($p2['pc']['image'])) @endif
{{ $p2['pc']['result'] }} {{ $p2['pc']['unit'] ?? '' }}
@endif @if (!empty($p2['pc']['desc_ar']))
{!! $service->isolateLtrRuns($p2['pc']['desc_ar']) !!}
@endif @endif {{-- ── URBC (RBC) ── option text at (50,116); numeric image at (100,112) w=50 --}} @if (!empty($p2['urbc'])) @if (($p2['urbc']['variant'] ?? '') === 'option')
{{ $p2['urbc']['name_en'] }} {{ $p2['urbc']['unit'] ?? '' }}
@elseif (($p2['urbc']['variant'] ?? '') === 'numeric') @if (!empty($p2['urbc']['image']) && is_file($p2['urbc']['image'])) @endif
{{ $p2['urbc']['result'] }} {{ $p2['urbc']['unit'] ?? '' }}
@endif @if (!empty($p2['urbc']['desc_ar']))
{!! $service->isolateLtrRuns($p2['urbc']['desc_ar']) !!}
@endif @endif {{-- ── EP (Epithelial Cells) ── image at (100,126) w=50 --}} @if (!empty($p2['ep'])) @if (!empty($p2['ep']['image']) && is_file($p2['ep']['image'])) @endif @if (($p2['ep']['variant'] ?? '') === 'numeric')
{{ $p2['ep']['result'] }} {{ $p2['ep']['unit'] ?? '' }}
@endif @if (!empty($p2['ep']['desc_ar']))
{!! $service->isolateLtrRuns($p2['ep']['desc_ar']) !!}
@endif @endif {{-- ── CST (Casts) ── --}} @if (!empty($p2['cst'])) @if (($p2['cst']['variant'] ?? '') === 'label') @if (!empty($p2['cst']['image']) && is_file($p2['cst']['image'])) @endif @elseif (($p2['cst']['variant'] ?? '') === 'visual') @if (!empty($p2['cst']['unseen']) && is_file($p2['cst']['unseen'])) @endif @endif @if (!empty($p2['cst']['desc_ar']))
{!! $service->isolateLtrRuns($p2['cst']['desc_ar']) !!}
@endif @endif {{-- ── CRS (Crystals) ── --}} @if (!empty($p2['crs'])) @if (($p2['crs']['variant'] ?? '') === 'label') @if (!empty($p2['crs']['image']) && is_file($p2['crs']['image'])) @endif @elseif (($p2['crs']['variant'] ?? '') === 'visual') @if (!empty($p2['crs']['unseen']) && is_file($p2['crs']['unseen'])) @endif @endif @if (!empty($p2['crs']['desc_ar']))
{!! $service->isolateLtrRuns($p2['crs']['desc_ar']) !!}
@endif @endif {{-- ── UCRT (Crystal Types) ── name_ar at (86,165), name_en at (89,169), items at (55,169) --}} @if (!empty($p2['ucrt']) && !empty($p2['ucrt']['items']))
{{ $p2['ucrt']['name_ar'] }}
{{ $p2['ucrt']['name_en'] }}
{{ $p2['ucrt']['joined'] }}
@endif {{-- ── UCAT (Cast Types) ── name_ar at (102,179), name_en at (85,183), items at (45,180) --}} @if (!empty($p2['ucat']) && !empty($p2['ucat']['items']))
{{ $p2['ucat']['name_ar'] }}
{{ $p2['ucat']['name_en'] }}
{{ $p2['ucat']['joined'] }}
@endif {{-- ── UAM (Amorphous Materials) ── name_ar at (91,190), name_en at (102,194), items at (65,195) --}} @if (!empty($p2['uam']) && !empty($p2['uam']['items']))
{{ $p2['uam']['name_ar'] }}
{{ $p2['uam']['name_en'] }}
{{ $p2['uam']['joined'] }}
@endif {{-- ── OT (Others) ── name_ar at (76,202), name_en at (79,206), items at (45,203) --}} @if (!empty($p2['ot']) && !empty($p2['ot']['items']))
{{ $p2['ot']['name_ar'] }}
{{ $p2['ot']['name_en'] }}
{{ $p2['ot']['joined'] }}
@endif