@php $hs = \App\Helpers\HospitalSettings::all(); $patient = $labOrder->patient; $result = $labOrder->result; $params = $labOrder->labTest->parameters ?? collect(); $isCrit = $result?->is_critical ?? false; $isAbnor = $result?->is_abnormal ?? false; @endphp {{-- ── HEADER ── --}}
{{ $hs['hospital_name'] ?? 'Clara Rosa Hospital' }}
{{ $hs['hospital_address'] ?? '' }}
Tel: {{ $hs['hospital_phone'] ?? '' }}
Laboratory Report
Report Date: {{ now()->format('d M Y H:i') }}
Ordered: {{ $labOrder->created_at->format('d M Y H:i') }} @if($labOrder->sample_collected_at)
Collected: {{ $labOrder->sample_collected_at->format('d M Y H:i') }}@endif @if($result?->created_at)
Resulted: {{ $result->created_at->format('d M Y H:i') }}@endif
{{-- ── TITLE ── --}}
{{ $labOrder->test_name }} @if($isCrit) CRITICAL VALUES @elseif($isAbnor) ABNORMAL @elseif($result) NORMAL@endif
{{-- ── PATIENT DEMOGRAPHICS ── --}}
Patient:{{ $patient->full_name ?? '' }} MRN:{{ $patient->mrn ?? '' }} Age/Sex:{{ $patient->age ?? '' }} / {{ ucfirst($patient->gender ?? '') }}
Visit:{{ $labOrder->visit->visit_number ?? '' }} Ordered by:{{ $labOrder->orderedBy->name ?? '' }} Sample:{{ $labOrder->sample_type ?? $labOrder->labTest->sample_type ?? '' }}
@if($result) @php $resultData = is_array($result->results) ? $result->results : (json_decode($result->results, true) ?? []); @endphp {{-- ── STRUCTURED RESULTS ── --}} @if($params->count() && count($resultData) > 0)
Result Details
@foreach($resultData as $key => $row) @if(is_array($row) && isset($row['name'])) @php $flag = $row['flag'] ?? 'normal'; $flagClass = match(true) { str_contains($flag,'critical_high') => 'flag-ch', str_contains($flag,'critical_low') => 'flag-cl', str_contains($flag,'high') => 'flag-h', str_contains($flag,'low') => 'flag-l', str_contains($flag,'abnormal') => 'flag-abn', default => 'normal', }; $flagLabel = match($flag) { 'critical_high' => 'Critical ↑', 'critical_low' => 'Critical ↓', 'high' => 'High ↑', 'low' => 'Low ↓', 'abnormal' => 'Abnormal', default => 'Normal', }; @endphp @endif @endforeach
Parameter Value Unit Reference Range Flag
{{ $row['name'] ?? '' }} {{ $row['value'] ?? '' }} {{ $row['unit'] ?? '' }} {{ $row['reference_range'] ?? '' }} {{ $flagLabel }}
{{-- ── GENERIC TABLE ROWS ── --}} @elseif(isset($resultData['generic_rows']) && count($resultData['generic_rows']) > 0)
Result Details
@foreach($resultData['generic_rows'] as $row) @if(!empty($row['param']) || !empty($row['finding'])) @endif @endforeach
ParameterFindingReference RangeInterpretation
{{ $row['param'] ?? '' }} {{ $row['finding'] ?? '' }} {{ $row['ref'] ?? '' }} {{ $row['interp'] ?? '' }}
{{-- ── LEGACY GENERIC TEXTAREA ── --}} @elseif(isset($resultData['generic']))
Result
{{ $resultData['generic']['value'] ?? '' }}
@else
Result
{{ $result->narrative_result ?? $result->comments ?? 'No structured result available.' }}
@endif {{-- ── COMMENTS ── --}} @if($result->remarks)
Comments / Interpretation
{{ $result->remarks }}
@endif @else
Result not yet available. Status: {{ ucfirst(str_replace('_',' ',$labOrder->status)) }}
@endif {{-- ── SIGNATURES ── --}}
Lab Technician / Analyst
Verified / Authorized by