Analytics Module
Na tej stronie
Overview
Dział zatytułowany „Overview”Analytics Module dostarcza dashboardy, wykresy i raporty dla zarządzania kliniką. Obejmuje statystyki wizyt, pacjentów, personelu i przychodów.
Architecture
Dział zatytułowany „Architecture”flowchart TB subgraph UI Dashboard[Analytics Dashboard] KPI[KPI Summary] Charts[Charts & Graphs] Tables[Data Tables] end
subgraph Hooks useAnalyticsData --> Dashboard useAnalyticsData --> Charts end
subgraph API analyticsService[analyticsService<br/>12 methods] end
subgraph Backend Commands[get_dashboard_stats<br/>get_visit_trends<br/>get_staff_performance<br/>...] end
Dashboard --> Hooks Hooks --> API API --> CommandsDashboard Tabs
Dział zatytułowany „Dashboard Tabs”| Tab | Data | Use Case |
|---|---|---|
| Overview | KPI summary, trends | Daily overview |
| Visits | Type distribution, time slots | Visit patterns |
| Patients | Demographics, species | Patient insights |
| Performance | Staff metrics, heatmap | Team management |
Key Metrics
Dział zatytułowany „Key Metrics”KPI Summary
Dział zatytułowany „KPI Summary”interface DashboardStats { totalVisits: number; totalPatients: number; avgVisitDuration: number; // minutes completionRate: number; // 0-100%}Visit Trends
Dział zatytułowany „Visit Trends”interface VisitTrend { date: string; // ISO date count: number;}
// Periods: week | month | yearStaff Performance
Dział zatytułowany „Staff Performance”interface StaffPerformance { staffId: string; staffName: string; totalVisits: number; avgDuration: number; completionRate: number;}Charts & Visualizations
Dział zatytułowany „Charts & Visualizations”Visit Type Distribution
Dział zatytułowany „Visit Type Distribution”┌─────────────────────────────┐│ Visit Types (Pie Chart) │├─────────────────────────────┤│ ││ Consultation 45% ││ Vaccination 25% ││ Surgery 15% ││ Follow-up 10% ││ Other 5% ││ │└─────────────────────────────┘Time Slot Analysis
Dział zatytułowany „Time Slot Analysis”┌─────────────────────────────┐│ Visits by Hour (Bar Chart) │├─────────────────────────────┤│ 8: ████ ││ 9: ████████████ ││ 10: ████████████████ │ ← Peak│ 11: ██████████████ ││ 12: ████████ ││ ... │└─────────────────────────────┘Day/Hour Heatmap
Dział zatytułowany „Day/Hour Heatmap” Mon Tue Wed Thu Fri Sat8:00 🟢 🟢 🟡 🟢 🟢 🟡9:00 🟡 🟠 🟠 🟠 🟡 🟡10:00 🔴 🔴 🔴 🔴 🟠 🟡 ← Peak11:00 🟠 🟠 🟠 🟠 🟠 🟢12:00 🟡 🟡 🟡 🟡 🟡 🟢Data Flow
Dział zatytułowany „Data Flow”sequenceDiagram participant UI as Analytics Dashboard participant Hook as useAnalyticsData participant Service as analyticsService participant BE as Backend
UI->>Hook: useAnalyticsData({ dateRange, activeTab }) Hook->>Hook: Determine required data
alt Overview Tab Hook->>Service: getOverviewBundle(scope) Service->>BE: get_overview_bundle else Visits Tab Hook->>Service: getVisitTypeDistribution(scope) Hook->>Service: getTimeSlotAnalysis(scope) else Patients Tab Hook->>Service: getPatientDemographics(scope) else Performance Tab Hook->>Service: getStaffPerformance(scope) Hook->>Service: getDayHourHeatmap(scope) end
BE-->>Service: Data Service-->>Hook: Transformed data Hook-->>UI: Ready for displayAnalytics Scope
Dział zatytułowany „Analytics Scope”interface AnalyticsScope { dateRange: { start: Date; end: Date; }; clinicId?: string; period?: 'week' | 'month' | 'year';}Caching
Dział zatytułowany „Caching”Wszystkie zapytania są cache’owane:
// Cache key patternanalytics:<sessionId>:<endpoint>:<scopeKey>
// Exampleanalytics:abc123:visitTrends:clinic1:2024-01-01:2024-01-31:monthInsights Generation
Dział zatytułowany „Insights Generation”// Auto-generated insightsgetPeakHourInsight(timeSlots)// → "Najwięcej wizyt o 10:00 (avg. 15/dzień)"
getBestDayHourInsight(heatmap)// → "Najlepszy dzień: Poniedziałek 9:00-11:00"Period Comparison
Dział zatytułowany „Period Comparison”// Compare current vs previous periodconst { current, previous } = await getVisitTrendsCompare(scope);
// Calculate changeconst change = ((current - previous) / previous) * 100;// → "+15% więcej wizyt niż poprzednio"Components
Dział zatytułowany „Components”| Component | Description |
|---|---|
AnalyticsDashboard | Main container |
KpiSummary | Top metrics cards |
VisitTrendsChart | Line/bar chart |
VisitTypesPieChart | Distribution pie |
TimeSlotBarChart | Hourly breakdown |
DayHourHeatmap | Weekly heatmap |
PerformanceTable | Staff rankings |
Revenue Data
Dział zatytułowany „Revenue Data”// get_revenue_datainterface RevenueData { month: string; // "2024-01" revenue: number; visitCount: number;}
// 12-month rolling dataawait analyticsService.getRevenueData(12);Related
Dział zatytułowany „Related”- Analytics Commands - API reference
- Dashboard - Main dashboard