@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 ── --}}
{{-- ── 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
| Parameter |
Value |
Unit |
Reference Range |
Flag |
@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
| {{ $row['name'] ?? '' }} |
{{ $row['value'] ?? '' }} |
{{ $row['unit'] ?? '' }} |
{{ $row['reference_range'] ?? '' }} |
{{ $flagLabel }} |
@endif
@endforeach
{{-- ── GENERIC TABLE ROWS ── --}}
@elseif(isset($resultData['generic_rows']) && count($resultData['generic_rows']) > 0)
Result Details
| Parameter | Finding | Reference Range | Interpretation |
@foreach($resultData['generic_rows'] as $row)
@if(!empty($row['param']) || !empty($row['finding']))
| {{ $row['param'] ?? '' }} |
{{ $row['finding'] ?? '' }} |
{{ $row['ref'] ?? '' }} |
{{ $row['interp'] ?? '' }} |
@endif
@endforeach
{{-- ── 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 |