@extends('layouts.app') @section('title','New vs Revisit Patients') @section('content')

New vs Returning Patients

{{ $from->format('d M Y') }} — {{ $to->format('d M Y') }}

@include('reports._date-filter') {{-- ═══ CARDS ═══════════════════════════════════════════════════════════ Layout: New + Returning = unique patients seen. Total visits is a separate dimension (some patients have multiple visits). --}}

New Patients

{{ number_format($newPatients) }}

First-ever visit in window

Returning Patients

{{ number_format($revisits) }}

Visited before the window

Total Visits

{{ number_format($totalVisits) }}

All visit rows in window

{{-- ═══ INTERPRETATION HELPER ═══════════════════════════════════════════ This is a non-trivial set of definitions, so a small panel explaining the relationships saves a lot of "why does X not equal Y" questions. --}} @php $uniquePatients = $newPatients + $revisits; $newPct = $uniquePatients > 0 ? round(($newPatients / $uniquePatients) * 100, 1) : 0; $retPct = $uniquePatients > 0 ? round(($revisits / $uniquePatients) * 100, 1) : 0; @endphp

Unique patients seen: {{ number_format($uniquePatients) }} ({{ number_format($newPatients) }} new + {{ number_format($revisits) }} returning). New = {{ $newPct }}% · Returning = {{ $retPct }}%. @if($totalVisits > $uniquePatients) Some patients had multiple visits (total visits {{ number_format($totalVisits) }} > unique patients {{ number_format($uniquePatients) }}). @endif

{{-- ═══ DEFINITIONS BLOCK ═════════════════════════════════════════════ Inline glossary. Hidden in print. --}}

Definitions

New Patient
A patient whose first-ever visit to this hospital fell inside the selected window. The patient may have been registered earlier — what counts here is when they first walked in to receive care.
Returning Patient
A patient who visited inside the window AND has at least one earlier visit on record (before the window). They were already in the system before this period.
Total Visits
Every visit row created inside the window — including multiple visits by the same patient. New + Returning counts each patient once; Total Visits counts each encounter.
@endsection