mirror of
https://github.com/temetro/temetro.git
synced 2026-07-27 04:08:56 +00:00
8ab0552cf8
The Analysis page only showed KPI numbers. Add two real time-series and render them as dependency-free bar charts (matching components/chat/sparkline.tsx): - backend: GET /api/analytics now returns `trends.patientsByMonth` (new patients per month over the last 6 months) and `trends.appointmentsByWeekday` (appointments per day for the current week), bucketed in JS from one query each. - frontend: new components/analysis/bar-chart.tsx and two chart sections on the Analysis view (Patient growth, Appointments this week), with i18n keys. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
36 lines
793 B
TypeScript
36 lines
793 B
TypeScript
import { apiFetch } from "@/lib/api-client";
|
|
|
|
// Server-computed clinic analytics. Mirrors the backend `src/types/analytics.ts`.
|
|
// All figures are aggregates over the active clinic's real data.
|
|
export type TrendPoint = { label: string; count: number };
|
|
|
|
export type Analytics = {
|
|
patients: {
|
|
total: number;
|
|
newThisMonth: number;
|
|
active: number;
|
|
};
|
|
appointments: {
|
|
thisWeek: number;
|
|
completed: number;
|
|
cancelled: number;
|
|
upcoming: number;
|
|
};
|
|
prescriptions: {
|
|
total: number;
|
|
active: number;
|
|
};
|
|
tasks: {
|
|
open: number;
|
|
done: number;
|
|
};
|
|
trends: {
|
|
patientsByMonth: TrendPoint[];
|
|
appointmentsByWeekday: TrendPoint[];
|
|
};
|
|
};
|
|
|
|
export function getAnalytics(): Promise<Analytics> {
|
|
return apiFetch<Analytics>("/api/analytics");
|
|
}
|