@extends('layouts.app') @section('title', 'Direct Encounter · ' . ($visit->visit_number ?? '')) @section('content') @php $isLab = $visit->visit_type === 'direct_lab'; $patient = $visit->patient; @endphp
← Back to Direct Encounters · {{ $visit->visit_number }}
@if(session('success'))
{{ session('success') }}
@endif @if(session('warning'))
{{ session('warning') }}
@endif {{-- Header card --}}

{{ $patient->full_name ?? '—' }} {{ $patient->mrn ?? '' }}

{{ ucfirst($patient->gender ?? '—') }} · {{ $patient->age ?? '—' }} · Direct {{ $isLab ? 'Lab' : 'Imaging' }} Encounter · Checked in {{ optional($visit->check_in_at)->format('d M Y, H:i') }}

@php $statusClass = match($visit->status) { 'at_lab' => 'bg-teal-100 text-teal-800', 'at_radiology' => 'bg-purple-100 text-purple-800', 'completed' => 'bg-green-100 text-green-800', 'cancelled' => 'bg-gray-100 text-gray-600', default => 'bg-blue-100 text-blue-800', }; @endphp {{ str_replace('_', ' ', $visit->status) }}
{{-- Orders panel --}}

{{ $isLab ? 'Lab Orders' : 'Imaging Requests' }}

@if($isLab) @forelse($visit->labOrders as $o) @empty @endforelse
Test Sample Status Result
{{ $o->test_name }} {{ $o->sample_type ?: '—' }} {{ str_replace('_', ' ', $o->status) }} @if($o->result && $o->result->status === 'validated') View @elseif($o->result) Pending validation @else Awaiting @endif
No orders.
@else @forelse($visit->imagingRequests as $r) @empty @endforelse
Type Body Part Status Indication
{{ $r->imaging_type }} {{ $r->body_part ?: '—' }} {{ str_replace('_', ' ', $r->status) }} {{ $r->clinical_indication ?: '—' }}
No requests.
@endif
{{-- Side: invoice + actions --}}
{{-- Invoice card --}}

Invoice

@if($visit->invoice)
Invoice #
{{ $visit->invoice->invoice_number }}
Total
KES {{ number_format($visit->invoice->total_amount) }}
Paid
KES {{ number_format($visit->invoice->amount_paid) }}
Balance
KES {{ number_format($visit->invoice->balance) }}
@else

No invoice on file.

@endif
{{-- Convert-to-OPD card. Only for in-flight encounters. --}} @if(in_array($visit->status, ['at_lab', 'at_radiology']) && auth()->user()->hasAnyRole('Super Admin', 'Hospital Admin', 'Clinician', 'Receptionist'))

Convert to OPD Visit

Patient needs clinical care after the {{ $isLab ? 'lab' : 'imaging' }} work? Convert this encounter into a full OPD visit. Existing orders and the invoice carry over.

@csrf
@endif {{-- Conversion history (if applicable, won't render for direct encounters but kept here for show after conversion) --}} @if($visit->converted_from_direct_at)
Originally a {{ str_replace('_', ' ', $visit->converted_from_direct_type) }} encounter. Converted to OPD on {{ $visit->converted_from_direct_at->format('d M Y, H:i') }}.
@endif
@endsection