Skip to main content

Overview

The Reports module provides in-depth financial and operational analytics for clinic administrators. It offers insights into revenue trends, service profitability, patient distribution, and outstanding debts.
This feature is restricted to users with admin role. All monetary values are displayed in Dominican Peso (DOP).

Report Categories

The reports page features two main sections accessible via tab navigation:
Statistical analysis including:
  • Monthly revenue trends (6-month view)
  • Top 5 services by income
  • Patient distribution by branch
  • Performance summary

Revenue Analysis

Monthly Income Chart

Visual representation of the last 6 months of revenue: Data Structure:
{
  "month": "2026-03",     // YYYY-MM format
  "income": 125000.00    // Total revenue in DOP
}
Visualization:
  • Horizontal bar chart with gradient fill
  • Bars scaled relative to maximum monthly income
  • Month labels formatted as “marzo 2026”
  • Currency values displayed on bars
Formatting:
function formatMonth(monthStr) {
  const [year, month] = monthStr.split('-').map(Number);
  const date = new Date(year, month - 1);
  return date.toLocaleString('es-ES', { 
    month: 'long', 
    year: 'numeric' 
  });
}

Top Services by Revenue

Displays the 5 most profitable treatment types: Metrics Shown:
  • Service/treatment name
  • Total revenue generated
  • Relative performance bar (scaled to #1 service)
The most profitable service is highlighted and referenced in the performance summary.
Data Source: sp_get_main_reports() procedure, result set 1

Branch Analytics

Patient Distribution

Table showing patient counts across all clinic branches:
ColumnDescription
SucursalBranch name
Total PacientesNumber of registered patients
Usage Insight: Helps identify high-volume locations for resource allocation and staffing decisions.

Performance Summary

The highlight card provides executive-level insights:

Key Metrics

  • Total Facturado Reciente: Sum of last 6 months revenue
  • Top Service: Most profitable treatment type
  • Priority Branch: Location with highest patient count
  • Strategic Recommendations: Auto-generated based on data
Calculation Example:
const totalRevenue = monthlyIncome.reduce(
  (acc, m) => acc + Number(m.income), 
  0
);

Debt Management

Outstanding Debts Report

Comprehensive patient debt tracking with collection tools: Table Columns:
Patient identification including:
  • Full name (bold)
  • Medical record number (medrecno)
  • Contact phone number
Total amount budgeted/quoted for treatments in DOP
Total amount paid to date (displayed in green)
Outstanding balance due (displayed in red, bold)Calculated as: total_budgeted - total_paid
“Ver Ficha” button linking to /patients/{id} for detailed patient profile and payment processing

Empty State

When no debts exist, displays: “No hay deudas pendientes registradas. ✅“

API Integration

Main Reports Endpoint

GET /api/reports
Authorization: Admin role required Response Structure:
{
  "success": true,
  "monthlyIncome": [
    {
      "month": "2026-03",
      "income": 125000.00
    }
  ],
  "incomeByService": [
    {
      "service_name": "Implante Dental",
      "income": 250000.00
    }
  ],
  "patientsByBranch": [
    {
      "branch_name": "Sede Centro",
      "count": 450
    }
  ]
}
Source: /src/routes/api/reports/+server.js
Procedure: sp_get_main_reports()
Result Sets:
  1. Monthly income data (6 months)
  2. Top 5 services by revenue
  3. Patient counts by branch

Debts Report Endpoint

GET /api/reports/debts
Authorization: Admin role required Response Structure:
{
  "success": true,
  "debts": [
    {
      "id": 123,
      "patient_name": "Juan Pérez",
      "medrecno": "MR-001234",
      "phone": "809-555-0100",
      "total_budgeted": 15000.00,
      "total_paid": 10000.00,
      "balance_due": 5000.00
    }
  ]
}
Source: /src/routes/api/reports/debts/+server.js
Procedure: sp_get_debts_report()
Built-in print support for generating hard copies:
1

Navigate to Reports

Access /admin/reports page
2

Select Tab

Choose either Estadísticas or Cobros Pendientes
3

Click Print Button

Use the “🖨️ Imprimir” button in the header
4

Print Dialog

Browser print dialog opens with print-optimized layout
Print Styling:
  • Header navigation hidden via @media print
  • Clean layout for professional reports
  • Currency and data formatting preserved

Visual Components

Chart Styling

The revenue chart uses a responsive design:
.chart-bar {
  height: 12px;
  background: linear-gradient(90deg, var(--teal), var(--teal-light));
  border-radius: 99px;
  transition: width 0.8s ease;
}
Animation: Bars animate on load with 0.8s ease transition.

Color Coding

Revenue

Teal gradient
#0d9488#14b8a6

Paid Amounts

Green
var(--green)

Debts

Rose (bold)
var(--rose)

Usage Examples

1

View Monthly Chart

Check the ”💰 Ingresos” chart for 6-month trend
2

Identify Peaks

Look for months with highest bars
3

Compare Services

Review ”🦷 Top 5 Tratamientos” for profitability drivers
4

Read Summary

Check performance summary for total revenue calculation

Example 2: Managing Outstanding Debts

1

Switch to Debts Tab

Click ”💸 Cobros Pendientes” tab
2

Review Patient List

Scan for high-balance accounts
3

Access Patient Profile

Click “Ver Ficha” for specific patient
4

Process Payment

Use patient profile to record payment and update balance

Example 3: Branch Performance Assessment

1

Check Patient Distribution

Review ”🏢 Pacientes por Sucursal” table
2

Identify High-Volume Branches

Note branches with highest patient counts
3

Cross-Reference Revenue

Compare with monthly income trends
4

Strategic Planning

Use insights for staffing and resource allocation

Data Refresh

Reports fetch fresh data on page load via parallel API calls:
async function fetchReports() {
  const [statsRes, debtsRes] = await Promise.all([
    fetch('/api/reports'),
    fetch('/api/reports/debts')
  ]);
  // Process responses
}
To refresh data without page reload, implement a manual refresh button that calls fetchReports() again.

Analytics Dashboard

Deep-dive metrics with advanced visualizations

Admin Dashboard

Quick financial overview in dashboard stats

Build docs developers (and LLMs) love