@extends('layouts.app') @push('styles') @include('dashboard.styles') @endpush @section('content')
@if (!empty($clinicWarning ?? null))
{{ $clinicWarning }}
@endif @if (!empty($message ?? null))
{{ $message }}
@endif @if (!empty($cacheCleared ?? null))
Generated data cleared.
@endif

Clinic Leader Dr.

Clinic dashboard

@php $mode = $viewMode ?? 'none'; $isPeriod = in_array($mode, ['monthly', 'quarterly', 'yearly']); $heroCards = $mode === 'daily' ? $dailyChecks : ($isPeriod ? $monthlyChecks : []); $hasData = ($mode === 'daily' && !empty($dailyChecks)) || ($isPeriod && !empty($monthlyChecks)); $heroValue = $hasData ? ($heroCards[0]['value'] ?? 0) : null; $clinicLabel = $clinicConnection ?? 'Clinic'; $periodLabel = $hasData ? ($mode === 'daily' ? ($dailyDurationSummary['dateLabel'] ?? '') : ($selectedMonthLabel ?? $selectedQuarter ?? '')) : 'Select a view to load data'; $modeLabel = $hasData ? ucfirst($mode) : ''; @endphp

Pulse across reception, labs, and follow-ups tailored for {{ $clinicLeader }}.

Daily check Monthly report Mobile friendly
@php $statusMode = $viewMode ?? 'none'; $isDailyMode = $statusMode === 'daily'; $isGeneratedMode = in_array($statusMode, ['monthly', 'quarterly', 'yearly'], true); $cacheStamp = $cacheUpdatedAt ?? null; @endphp @if ($isDailyMode || $isGeneratedMode)
@if ($isDailyMode) Live Daily counts are live. @elseif ($cacheStamp) Generated Cached {{ $cacheStamp }}. @else Not generated Run Generate to build this period. @endif
@endif
Total Consultations
{{ $heroValue !== null ? $heroValue : '—' }}
@if($hasData)
patients • {{ $modeLabel }} • {{ $clinicLabel }} • {{ $periodLabel }}
@else
Choose Daily, Monthly, Quarterly, or Yearly and apply filters to load data.
@endif
@php $selectedClinic = $clinicConnection ?? config('database.default'); $currentYear = now()->year; $selectedYearUi = request('year', $currentYear); $quarterYears = array_reverse(range($currentYear - 5, $currentYear + 1)); $quartersByYear = []; foreach ($quarterYears as $y) { $quartersByYear[$y] = [ "{$y}-Q1" => "Q1 ({$y} Jan-Mar)", "{$y}-Q2" => "Q2 ({$y} Apr-Jun)", "{$y}-Q3" => "Q3 ({$y} Jul-Sep)", "{$y}-Q4" => "Q4 ({$y} Oct-Dec)", ]; } $reportMode = in_array(($viewMode ?? ''), ['daily', 'monthly', 'quarterly', 'yearly'], true) ? $viewMode : 'monthly'; @endphp
@php $selectedQuarterValue = $selectedQuarter ?? ''; $selectedQuarterLabel = $selectedQuarterValue; foreach ($quartersByYear as $year => $qList) { if (isset($qList[$selectedQuarterValue])) { $selectedQuarterLabel = $qList[$selectedQuarterValue]; break; } } @endphp Green = cached, Orange = old/legacy, Gray = not cached
@php $clinicParam = $selectedClinic; $exportMonthKey = ($viewMode === 'quarterly') ? ($monthInputValue ?? $selectedMonth) : ($selectedMonth ?? $monthInputValue); $exportQuarterKey = $selectedQuarter ?? ($periodKey ?? ''); $exportEnabled = in_array(($viewMode ?? ''), ['monthly', 'quarterly'], true); @endphp
@if (!empty($dailyChecks))

Daily report

Service summary (day)

@foreach(($dailyChecks ?? []) as $item) @php $accent = $item['accent'] ?? '#0ea5e9'; $rawValue = $item['value'] ?? 0; $value = is_numeric($rawValue) ? number_format((float) $rawValue) : $rawValue; @endphp
{{ $item['title'] ?? '' }} {{ $value }} @if (!empty($item['change'])) • {{ $item['change'] }} @endif
@endforeach
Counts are total visits for the selected day. “Reached lab/counsellor/dispensing” means a same-day record exists in that service module. Gender (headcount) counts unique patients.
@endif @php $dailyGenderBreakdown = array_values(array_filter($dailyGenderBreakdown ?? [], function ($item) { return ($item['title'] ?? '') !== 'Unknown'; })); $hasDailyGender = !empty($dailyGenderBreakdown ?? []); $hasDailyAge = !empty($dailyAgeSummary ?? []) && array_sum($dailyAgeSummary ?? []) > 0; $hasDailyKp = !empty($dailyKpBreakdown ?? []) && array_sum(array_column($dailyKpBreakdown ?? [], 'value')) > 0; $hasDailyDisease = !empty($dailyDiseaseCategories ?? []) && array_sum(array_column($dailyDiseaseCategories ?? [], 'value')) > 0; $hasDailyProgram = !empty($dailyProgramWorkloads ?? []) && array_sum(array_column($dailyProgramWorkloads ?? [], 'value')) > 0; @endphp @if ($hasDailyGender || $hasDailyAge || $hasDailyKp)
@if ($hasDailyGender)

Daily report

Gender (headcount) (day)

@endif @if ($hasDailyAge)

Daily report

Visits by age & status (day)

@endif @if ($hasDailyKp)

Daily report

Key populations (day)

Unknown risk is counted as “General patients”.
@endif
@endif @if ($hasDailyDisease || $hasDailyProgram)
@if ($hasDailyDisease)

Daily report

General diseases (day)

@endif @if ($hasDailyProgram)

Daily report

Program workloads (day)

@endif
@endif
@if (($viewMode ?? 'none') !== 'yearly')

Daily snapshot

Time-in-clinic

{{ $dailyDurationSummary['dateLabel'] }}
Average stay
{{ $dailyDurationSummary['average'] }} mins
Median {{ $dailyDurationSummary['median'] }} mins
90th percentile
{{ $dailyDurationSummary['p90'] }} mins
Long wait >90 mins: {{ $dailyDurationSummary['longWaitRate'] }}%
Long-wait patients
{{ $dailyDurationSummary['longWaiters'] }}
Reception → dispensing • Included {{ max(($dailyDurationSummary['dispensed'] ?? 0) - ($dailyDurationSummary['excludedAfterCutoff'] ?? 0), 0) }} of {{ $dailyDurationSummary['dispensed'] ?? 0 }} dispensed (cutoff {{ $dailyDurationSummary['cutoff'] ?? '16:30' }})
Calculation: start at reception check-in (`created_at` in followup_generals); end at first dispensing time (`created_at` in consumptions). Only PIDs that reached dispensing are included, and any reception/dispensing after 16:30 is excluded. Averages/median/p90 and long-wait (>90 mins) use those intervals per included PID.
@endif

Daily MDs

MD workload (day)

@if (($viewMode ?? 'none') !== 'yearly')

Daily report

Service populated hours (day)

@endif
@php $periodEyebrow = $viewMode === 'quarterly' ? 'Quarterly report' : ($viewMode === 'yearly' ? 'Yearly report' : 'Monthly report'); $periodGenderBreakdown = array_values(array_filter($periodGenderBreakdown ?? [], function ($item) { return ($item['title'] ?? '') !== 'Unknown'; })); $hasPeriodGender = !empty($periodGenderBreakdown ?? []) && array_sum(array_column($periodGenderBreakdown ?? [], 'value')) > 0; $hasPeriodAge = !empty($monthlyAgeSummary ?? []) && array_sum($monthlyAgeSummary ?? []) > 0; $hasPeriodKp = !empty($periodKpBreakdown ?? []) && array_sum(array_column($periodKpBreakdown ?? [], 'value')) > 0; @endphp @if (!empty($monthlyChecks))

{{ $periodEyebrow }}

{{ $viewMode === 'quarterly' ? 'Service summary (Quarter)' : ($viewMode === 'yearly' ? 'Service summary (Year)' : 'Service summary') }}

@if (!empty($periodIsPartial ?? false) && !empty($periodThroughLabel ?? null) && isset($periodRemainingDays))
Through {{ $periodThroughLabel }} • {{ $periodRemainingDays }} day{{ ((int) $periodRemainingDays) === 1 ? '' : 's' }} remaining
@endif
@foreach(($monthlyChecks ?? []) as $item) @php $accent = $item['accent'] ?? '#0ea5e9'; $rawValue = $item['value'] ?? 0; $value = is_numeric($rawValue) ? number_format((float) $rawValue) : $rawValue; @endphp
{{ $item['title'] ?? '' }} {{ $value }} @if (!empty($item['change'])) • {{ $item['change'] }} @endif
@endforeach
Counts are total visits for the selected period. “Reached lab/counsellor/dispensing” means a record exists in that module within the same period. Gender (headcount) counts unique patients.
@endif @if ($hasPeriodGender || $hasPeriodAge || $hasPeriodKp)
@if ($hasPeriodGender)

{{ $periodEyebrow }}

Gender (headcount)

@endif @if ($hasPeriodAge)

{{ $periodEyebrow }}

Visits by age & status

@endif @if ($hasPeriodKp)

{{ $periodEyebrow }}

Key populations

@endif
@endif
@if (!empty($diseaseCategories))

{{ $periodEyebrow ?? ($viewMode === 'quarterly' ? 'Quarterly report' : ($viewMode === 'yearly' ? 'Yearly report' : 'Monthly report')) }}

General diseases ({{ $selectedMonthLabel }})

@endif @if (!empty($programCategories))

{{ $periodEyebrow ?? ($viewMode === 'quarterly' ? 'Quarterly report' : ($viewMode === 'yearly' ? 'Yearly report' : 'Monthly report')) }}

Program workloads

@endif

{{ $periodEyebrow ?? ($viewMode === 'quarterly' ? 'Quarterly report' : ($viewMode === 'yearly' ? 'Yearly report' : 'Monthly report')) }}

Planned vs unplanned

Appointments
@php $showDataEntryCharts = false; @endphp @if ($showDataEntryCharts && !empty($monthlyClerkSummary))

Monthly report

Data entry workload (month)

Monthly report

Data entry populated hours (month)

@endif @if ($isPeriod)

{{ $periodEyebrow }}

MD workload ({{ $selectedMonthLabel }})

@endif
@endsection @push('scripts') @endpush