@extends('layouts.app') @section('title', 'التقارير والإحصائيات') @section('page_title', 'التقارير والإحصائيات') @section('content')

{{ \App\Models\Appointment::whereDate('appointment_date', today())->count() }}

مواعيد اليوم

{{ \App\Models\Appointment::where('created_at', '>=', now()->subWeek())->count() }}

مواعيد هذا الأسبوع

{{ \App\Models\MedicalRecord::count() }}

السجلات الطبية

{{ \App\Models\Prescription::where('is_active', true)->count() }}

الوصفات النشطة

إحصائيات المواعيد الشهرية
أكثر الأطباء نشاطاً
@php $doctors = \App\Models\User::where('role', 'doctor') ->withCount(['doctorAppointments', 'doctorMedicalRecords']) ->orderBy('doctor_appointments_count', 'desc') ->get(); @endphp @foreach($doctors as $doctor) @endforeach
اسم الطبيب عدد المواعيد عدد المرضى السجلات الطبية معدل النشاط
د. {{ $doctor->name }} {{ $doctor->doctor_appointments_count }} {{ $doctor->doctorAppointments()->distinct('patient_id')->count() }} {{ $doctor->doctor_medical_records_count }} @php $activity = $doctor->doctor_appointments_count > 0 ? round(($doctor->doctor_medical_records_count / $doctor->doctor_appointments_count) * 100) : 0; @endphp
{{ $activity }}%
توزيع المستخدمين
حالة المواعيد
@php $appointmentStatuses = [ 'مؤكد' => \App\Models\Appointment::where('status', 'مؤكد')->count(), 'في الانتظار' => \App\Models\Appointment::where('status', 'في الانتظار')->count(), 'مكتمل' => \App\Models\Appointment::where('status', 'مكتمل')->count(), 'ملغي' => \App\Models\Appointment::where('status', 'ملغي')->count(), 'جديد' => \App\Models\Appointment::where('status', 'جديد')->count(), ]; @endphp @foreach($appointmentStatuses as $status => $count)
{{ $status }} {{ $count }}
@endforeach
إحصائيات سريعة
متوسط المواعيد اليومية

{{ round(\App\Models\Appointment::count() / max(\App\Models\Appointment::selectRaw('DATEDIFF(MAX(appointment_date), MIN(appointment_date)) + 1 as days')->value('days'), 1)) }}

أكثر الأيام نشاطاً

@php $busiestDay = \App\Models\Appointment::selectRaw('DAYNAME(appointment_date) as day_name, COUNT(*) as count') ->groupBy('day_name') ->orderBy('count', 'desc') ->first(); @endphp {{ $busiestDay ? $busiestDay->day_name : 'N/A' }}

معدل إكمال المواعيد
@php $totalAppointments = \App\Models\Appointment::count(); $completedAppointments = \App\Models\Appointment::where('status', 'مكتمل')->count(); $completionRate = $totalAppointments > 0 ? round(($completedAppointments / $totalAppointments) * 100) : 0; @endphp

{{ $completionRate }}%

@endsection