@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
@if (!empty($dailyChecks))
@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)
@endif
@if ($hasDailyAge)
@endif
@if ($hasDailyKp)
Unknown risk is counted as “General patients”.
@endif
@endif
@if ($hasDailyDisease || $hasDailyProgram)
@if ($hasDailyDisease)
@endif
@if ($hasDailyProgram)
@endif
@endif
@if (($viewMode ?? 'none') !== 'yearly')
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 {{ $dailyDurationSummary['dispensed'] ?? 0 }}
• Excluded (no dispensing) {{ $dailyDurationSummary['excludedNoDispensing'] ?? 0 }}
Calculation: start at reception check-in (`created_at` in followup_generals); end at dispensing time (`created_at` in consumptions). IDs without same-day dispensing are excluded from duration stats and shown in grey in the daily time-in-clinic band chart.
@endif
@if (($viewMode ?? 'none') !== 'yearly')
@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))
@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 (in_array(($viewMode ?? 'none'), ['monthly','quarterly'], true))
X-axis shows day + date in the selected report period. Stacked groups are waiting-time bands (minutes): 1-90, 91-150, 151-210, 211-270, 271-330.
Grey means excluded IDs with no same-day dispensing record.
Play Time-Lapse
Evidence-XLSX
@endif
@if ($hasPeriodGender || $hasPeriodAge || $hasPeriodKp)
@if ($hasPeriodGender)
@endif
@if ($hasPeriodAge)
@endif
@if ($hasPeriodKp)
@endif
@endif
@if (!empty($diseaseCategories))
@endif
@if (!empty($programCategories))
@endif
@php $showDataEntryCharts = false; @endphp
@if ($showDataEntryCharts && !empty($monthlyClerkSummary))
@endif
@if ($isPeriod)
No MD workload data for this month.
@endif
Edit this section to explain how each metric is counted and which tables it uses.
Service summary : followup_generals (Visit Date, New_Old, Unplan) + lab modules (Lab, Rprtest, LabGeneralTest, LabHbcTest, Urine, Labstitest, Lab_oi) + counsellor_records + consumptions.
Visits by age & status : followup_generals + pt_configs/patients (DOB, Agey/Agem). New = Reg Date in the same month as the selected day.
Gender (headcount) : pt_configs/patients (unique PIDs).
Key populations : pt_configs/patients Main Risk/Sub Risk for PIDs in followup_generals.
General diseases : ConsultationReportService fields from followup_generals (ugen_*, ogen_*, etc.).
Program workloads : ncd_followups, stimales, stifemales, coulsellings, anc_follow_ups, feeding_centerfups, cervicalcancer1s/cervicalcancers, cmvs, mental__healths, prevention_logsheets, prevention_c_b_s, pre_tb_records/pre_t_b_s, tb_register_o3_s, tbipts.
Planned vs unplanned : followup_generals.Unplan.
MD workload : followup_generals.Current_MD.
Time-in-clinic : followup_generals.created_at (reception start) to consumptions.created_at (dispensing end) per PID/day; IDs without dispensing are counted in excluded (grey).
@php
$ncdClinic = $clinicConnection ?? 'ALL';
$ncdHref = Route::has('ncd_analysis.dashboard')
? route('ncd_analysis.dashboard', ['clinic' => $ncdClinic])
: (Route::has('clinic_dashboard.ncd')
? route('clinic_dashboard.ncd', ['clinic' => $ncdClinic])
: url('ncd_analysis') . '?clinic=' . urlencode((string) $ncdClinic));
@endphp
@endsection
@push('scripts')
@endpush