From c8da77dbf26ddbeb54ab8214cc8d44ca1583abce Mon Sep 17 00:00:00 2001 From: rameen Date: Fri, 16 Oct 2026 02:52:46 +0330 Subject: [PATCH] Count started own lab cases on the dashboard and fit the gadgets to the screen. Lab numbers now follow the same cases as Cases and Tasks: a case the lab started itself is included, and a step already handed to another lab is not. Day labels stay inside the charts, the grid follows the dashboard width, and the progress rings share one thin stroke. --- .cursor/rules/dyolink-overview.mdc | 2 +- .cursor/skills/today-dashboard/SKILL.md | 28 ++- backend/src/modules/today/today.service.ts | 177 ++++++++++++------ .../src/components/today/chart-day-labels.ts | 17 +- .../today/today-dashboard-layout.ts | 11 +- .../components/ui/today/TodayAreaChart.tsx | 29 ++- .../ui/today/TodayCompletionGaugeKpiCard.tsx | 27 ++- .../ui/today/TodayDashboardGrid.tsx | 38 ++-- .../ui/today/TodayLabTaskActivityChart.tsx | 18 +- .../TodayPartnerCasesStackedBarChart.tsx | 7 +- .../ui/today/TodayRadialGaugeChart.tsx | 53 +++--- .../ui/today/TodaySubscriptionKpiCard.tsx | 52 ++--- frontend/src/lib/i18n/format.ts | 2 + frontend/src/styles/globals.css | 28 ++- frontend/src/types/today.ts | 4 + 15 files changed, 331 insertions(+), 162 deletions(-) diff --git a/.cursor/rules/dyolink-overview.mdc b/.cursor/rules/dyolink-overview.mdc index 866f845..f30ff6b 100644 --- a/.cursor/rules/dyolink-overview.mdc +++ b/.cursor/rules/dyolink-overview.mdc @@ -35,7 +35,7 @@ Treatment-type colors and labels: `components/shared/treatmentTypeDisplay.ts` + ## Today dashboard -CLINIC + LAB KPIs/charts in `modules/today/today.service.ts`. Deep links: `components/today/today-deep-links.ts`. Task KPIs need `TAB_TASKS_READ` (no owner bypass). Skill: `.cursor/skills/today-dashboard/SKILL.md`. +CLINIC + LAB KPIs/charts in `modules/today/today.service.ts`. Lab gadgets count the same cases as Cases and Tasks (started own cases included; outsourced steps excluded). Deep links: `components/today/today-deep-links.ts`. Task KPIs need `TAB_TASKS_READ` (no owner bypass). Skill: `.cursor/skills/today-dashboard/SKILL.md`. ## Lab case share link diff --git a/.cursor/skills/today-dashboard/SKILL.md b/.cursor/skills/today-dashboard/SKILL.md index 345e86c..6816f58 100644 --- a/.cursor/skills/today-dashboard/SKILL.md +++ b/.cursor/skills/today-dashboard/SKILL.md @@ -31,13 +31,25 @@ KPIs with count `0` still register; `getVisibleTodayKpis` hides when `formatValu Use `useRouter` from `@/i18n/navigation` for chart clicks. KPI cards use `Link`/`href` on `KpiCard`. +## Lab case scope + +Lab gadgets use `visibleStartedToLabWhere` in `today.service.ts`, the same cases Cases and Tasks show: + +- A received case has `sentAt` and a `LabCaseSend` for this lab (clinic dispatch or a received lab-to-lab case). +- A started own case is `LAB_INTERNAL`, `destinationOrganizationId` is this lab, and `startedAt` is set. Date windows use `startedAt` where a sent case uses `sentAt` (received today, activity “received”, partner chart). +- Unstarted drafts stay out. +- Task counts use `CURRENT_VISIBLE_TASK_FILTER`: current round only, and a step already handed to another lab is not counted. +- Partner chart name: the clinic, else `partnerClinicOrganizationId`, else the parent case’s lab for a received lab-to-lab case. + +Clinic gadgets are unchanged. + ## Charts (LAB examples) - **Tasks by prosthesis** — `TodayBarChart` + `colorForCode` from prosthesis catalog; `canViewTasks` -- **Cases due** — forward day buckets (next 7 / 30); active sent cases with due date + in-progress task; `canViewCases`; empty card still shown -- **Lab task activity** — stacked lookback day chart (7 / 30); `canViewCases \|\| canViewTasks` +- **Cases due** — forward day buckets (next 7 / 30); a due date plus an in-progress task on a received or started own case; `canViewCases`; empty card still shown +- **Lab task activity** — stacked lookback day chart (7 / 30); `canViewCases \|\| canViewTasks`. “Received” adds a send’s tasks, and a started own case’s current tasks on `startedAt`. -Week/month day labels: `useTodayDayLabelFormatter` + `mapWeekChartBuckets`. +Day axis tick is month + day (`APP_DATE.chartAxisDay` via `mapWeekChartBuckets`). The tooltip keeps the full weekday label. ## Chart period dropdowns @@ -50,6 +62,16 @@ Seven time-window charts support a compact header `