@extends('layouts.app') @section('title', 'Patient History | ' . $patient->full_name) @section('content') {{-- ════════════════════════════════════════════════════════════ PATIENT HISTORY — unified timeline across OPD/IPD/ANC/Maternity ════════════════════════════════════════════════════════════ - Cross-encounter summary at top (allergies, chronic conditions, active meds, encounter counts) - Filter chips by encounter type - Date range + free-text search - Paginated timeline (20 per page) - Expand/collapse per row, details lazy-loaded via AJAX - Billing-only mode for Receptionist/Finance roles --}} @php $typeChips = [ '' => ['label' => 'All', 'count' => array_sum($summary['totals'])], 'opd' => ['label' => 'OPD', 'count' => $summary['totals']['opd']], 'dental' => ['label' => 'Dental', 'count' => $summary['totals']['dental']], 'ipd' => ['label' => 'IPD', 'count' => $summary['totals']['ipd']], 'anc' => ['label' => 'ANC', 'count' => $summary['totals']['anc']], 'maternity' => ['label' => 'Maternity', 'count' => $summary['totals']['maternity']], ]; $activeType = $filters['type'] ?? ''; @endphp {{-- ── PATIENT HEADER STRIP ────────────────────────────────────── --}}
← Back to Patient
{{ strtoupper(substr($patient->first_name,0,1).substr($patient->last_name,0,1)) }}

{{ $patient->full_name }}

{{ $patient->mrn }} · {{ ucfirst($patient->gender ?? '') }} · {{ $patient->age ?? '' }}

@if($billingOnly) Billing-only view @endif
{{-- ── CROSS-ENCOUNTER SUMMARY (allergies, chronic, active meds) ── --}} @unless($billingOnly)

Allergies

@if(count($summary['allergies']))
@foreach($summary['allergies'] as $a) {{ $a }} @endforeach
@else

None on record

@endif

Chronic Conditions

@if(count($summary['chronic_conditions']))
@foreach($summary['chronic_conditions'] as $c) {{ $c }} @endforeach
@else

None on record

@endif

Active Medications ({{ count($summary['active_medications']) }})

@if(count($summary['active_medications'])) @else

None active

@endif
@endunless {{-- ── FILTERS ──────────────────────────────────────────────────── --}}
{{-- Type chips --}}
@foreach($typeChips as $key => $chip) {{ $chip['label'] }} ({{ $chip['count'] }}) @endforeach
{{-- Date range — unified hmis-date-input style (round 10). Auto-submits on change; Filter button still works for users who set both then click. --}}
to
{{-- Search --}} {{-- Preserve type if set --}} @if($filters['type'])@endif @if($filters['from'] || $filters['to'] || $filters['search']) Clear @endif
{{-- ── TIMELINE ─────────────────────────────────────────────────── --}}
@forelse($timeline as $entry) @include('patients.partials._patient-history-row', ['entry' => $entry, 'patient' => $patient]) @empty
No encounters match these filters.
@endforelse
{{-- Pagination --}}
{{ $timeline->links() }}
{{-- ── DETAILS LAZY-LOAD JS ─────────────────────────────────────── --}} @endsection