@extends('layouts.app') @push('styles') @include('dashboard.styles') @endpush @section('content')
@if (!empty($clinicWarning ?? null))
{{ $clinicWarning }}
@endif @if (!empty($message ?? null))
{{ $message }}
@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 This period will be available after the scheduled cache generation runs. @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); $evidencePeriodType = $viewMode === 'quarterly' ? 'quarterly' : ($viewMode === 'monthly' ? 'monthly' : null); $evidencePeriodKey = $evidencePeriodType === 'quarterly' ? $exportQuarterKey : $exportMonthKey; $evidenceEnabled = $exportEnabled && !empty($evidencePeriodType) && !empty($evidencePeriodKey) && strtoupper((string) $clinicParam) !== 'ALL'; @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 {{ $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

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 (in_array(($viewMode ?? 'none'), ['monthly','quarterly'], true)) @php $timeInClinicPeriodSummary = []; $timeInClinicPeriodTotal = 0; foreach (($timeInClinicDailyBands['datasets'] ?? []) as $dataset) { $bandTotal = array_sum(array_map('intval', $dataset['data'] ?? [])); $timeInClinicPeriodTotal += $bandTotal; $timeInClinicPeriodSummary[] = [ 'label' => $dataset['label'] ?? 'Unknown', 'value' => $bandTotal, 'color' => $dataset['backgroundColor'] ?? '#64748b', ]; } $timeInClinicPeriodSummary = array_values(array_filter($timeInClinicPeriodSummary, fn ($row) => ($row['value'] ?? 0) > 0)); @endphp

Daily snapshot (report period)

Time-in-clinic by day

{{ $selectedMonthLabel }}
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. Hover a bar segment to see its count and percentage of that day. Grey means excluded IDs with no same-day dispensing record.
@if ($timeInClinicPeriodTotal > 0)
{{ ($viewMode ?? '') === 'monthly' ? 'Selected month' : 'Selected period' }} total: {{ number_format($timeInClinicPeriodTotal) }} records. Percentages below are calculated over this total.
@foreach ($timeInClinicPeriodSummary as $band) @php $bandPercent = $timeInClinicPeriodTotal > 0 ? round(($band['value'] / $timeInClinicPeriodTotal) * 100, 1) : 0; @endphp {{ $band['label'] }}: {{ number_format($band['value']) }} ({{ number_format($bandPercent, 1) }}%) @endforeach
@endif
Evidence-XLSX
@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 @php $showClinicTimeComparison = in_array(($clinicConnection ?? null), ['ALL', 'MAM_A+B+C1'], true) && ($viewMode ?? null) === 'monthly' && !empty($clinicTimeInClinicComparison ?? []); @endphp

Reference

How counts are calculated

Use this section to check 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).

Coverage map

Clinic areas in Myanmar

Base wards are from MIMU v9.4 ward boundaries and matched by Region, Township, and Ward from the registration data.

MAM_A Clinic MAM_B MAM_C1 Clinic MAM_A ID points MAM_B ID points MAM_C1 ID points MAM_SPT ID points MAM_SDG ID points MAM_TL ID points

Send clinic-to-ward details next, and this map will be updated with exact assignment and additional Myanmar locations.

@if ($showClinicTimeComparison)

{{ ($clinicConnection ?? null) === 'ALL' ? 'ALL clinics comparison' : (($clinicConnection ?? 'Clinic group') . ' comparison') }}

Time-in-clinic percentage by clinic

Stacked bars compare each clinic's time-in-clinic percentage for the selected month. Consultation total and MD counts are shown below for context only.

{{ $selectedMonthLabel }}
@foreach ($clinicTimeInClinicComparison as $clinicRow) @endforeach
Clinic Consultations MD workload visits MD count Time-in-clinic records
{{ $clinicRow['clinic'] ?? '' }} {{ number_format($clinicRow['consultations'] ?? 0) }} {{ number_format($clinicRow['mdVisits'] ?? 0) }} {{ number_format($clinicRow['mdProviders'] ?? 0) }} {{ number_format($clinicRow['timeInClinicTotal'] ?? 0) }}
@endif
@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