Overview
The Analytics Dashboard provides deep-dive business intelligence for clinic operations. It features interactive charts, KPI tracking, appointment analytics, service performance metrics, and doctor productivity monitoring.Time Period Filtering
All analytics can be filtered by time period using the dropdown selector:- 7 días
- 30 días
- 90 días
Last 7 days of data - ideal for weekly performance reviews
?period=30 (7, 30, or 90)
Key Performance Indicators
The KPI strip displays six critical metrics with color-coded cards:🏥 Pacientes Activos
Teal Card
Total active patients in the system
Total active patients in the system
💵 Cobrado este mes
Green Card
Total revenue collected current month (DOP)
Total revenue collected current month (DOP)
📋 Facturado este mes
Blue Card
Total amount billed/invoiced current month (DOP)
Total amount billed/invoiced current month (DOP)
🎫 Ticket Promedio
Amber Card
Average transaction value per appointment (DOP)
Average transaction value per appointment (DOP)
📅 Pendientes Hoy
Slate Card
Appointments scheduled for today
Appointments scheduled for today
❌ Canceladas Hoy
Rose Card
Cancelled appointments today
Cancelled appointments today
kpis object from sp_get_analytics_dashboard procedure
Revenue Analysis
Monthly Revenue Chart
Interactive SVG bar chart showing 6-month revenue trends: Features:- Gradient-filled bars (
#0d9488→#14b8a6) - Grid lines at 25%, 50%, 75%, and 100% of max
- Axis labels in Spanish (month abbreviations)
- Currency formatting on Y-axis
- Hover interactions
Appointment Analytics
Status Distribution Donut Chart
SVG donut chart displaying appointment status breakdown: Status Categories:Programadas (Scheduled)
Programadas (Scheduled)
Color: Teal (#0d9488)
Initial scheduled state
Initial scheduled state
Confirmadas (Confirmed)
Confirmadas (Confirmed)
Color: Blue (#3b82f6)
Patient confirmed attendance
Patient confirmed attendance
En sala (Waiting)
En sala (Waiting)
Color: Amber (#f59e0b)
Patient checked in and waiting
Patient checked in and waiting
Atendidas (Completed)
Atendidas (Completed)
Color: Green (#22c55e)
Appointment finished
Appointment finished
Canceladas (Cancelled)
Canceladas (Cancelled)
Color: Red (#ef4444)
Appointment cancelled
Appointment cancelled
Daily Appointments Sparkline
Area + line chart showing last 14 days of appointment volume: Visualization:- Teal line with gradient area fill
- Circular data point markers
- Daily labels (every other day for clarity)
- Value labels above each point
Patient Growth
New Patients by Month
Bar chart tracking patient registration trends: Features:- Blue gradient bars (
#2563eb→#3b82f6) - Value labels displayed above bars
- Monthly breakdown
- Zero values displayed as empty bars
Service Performance
Top Services Rankings
Ranked list of most frequently performed services: Display Format:- Rank: Position (1-6)
- Service Name: Treatment/procedure name (truncated)
- Frequency Bar: Relative performance (scaled to #1)
- Count: Number of times performed
- Revenue: Total income generated (DOP)
topServices from analytics API
Doctor Productivity
Completion Rate Tracking
Monitor doctor performance with appointment completion metrics: Display Components:Doctor Avatar
Circular badge with initials (e.g., “JD” for Juan Díaz)
Progress Bar
Visual completion rate with teal gradient fill
- Doctor Name: Full name
- Completed: Number of finished appointments
- Total: Total scheduled appointments
- Rate: Percentage (completed / total * 100)
API Integration
Analytics Endpoint
| Parameter | Type | Default | Description |
|---|---|---|---|
period | number | 30 | Time range in days (7, 30, 90) |
branchId | string | ”all” | Branch ID or “all” for system-wide |
/src/routes/api/analytics/+server.jsProcedure:
sp_get_analytics_dashboard(period, branchId)
Result Sets (7 total):
- Revenue by month (6 months)
- Appointment status distribution
- New patients by month
- Top services by frequency and revenue
- Daily appointment counts (14 days)
- Doctor productivity metrics
- KPI summary object
Visual Design
SVG Chart Configuration
Revenue Chart:- ViewBox:
0 0 520 170 - Bar height: 140px (scaled)
- Grid lines at 25% intervals
- Center: (80, 80)
- Radius: 54px
- Stroke width: 24px
- Rotation: -90° (start at top)
- ViewBox:
0 0 520 160 - Data range: 0-130px (vertical)
- Point radius: 4px
Responsive Behavior
- Desktop (> 900px)
- Tablet (≤ 900px)
- KPI grid: 3 columns
- Chart rows: 2 columns side-by-side
Loading States
Skeleton Placeholders:- 4 animated shimmer cards
- Gradient animation: left to right
- Colors:
#f1f5f9→#e2e8f0
Usage Examples
Example 1: Weekly Performance Review
Example 2: Monthly Revenue Analysis
Example 3: Service Strategy Planning
Related Pages
Financial Reports
Detailed revenue reports and debt tracking
Admin Dashboard
Real-time operational overview
