mirror of
https://github.com/bitbaum/vitareba.git
synced 2026-12-05 09:08:17 +01:00
ChartKit 0.7.0 closes the three gaps recorded in package-plan.json (#136): LineChart labels days on short spans, Sparkline takes per-point tones and null gaps, and Meter takes a tone and showValue={false}. - CheckinTrendChart and AssessmentTrendChart render ChartKit's LineChart on the server, dated by ISO day in the app's en-GB locale. Callers pass the day instead of a pre-formatted label, and the assessments page drops its client wrapper. - The patients table's 7-day strip is a Sparkline: one point a day, toned by wellness level (SPARK_LEVEL_TONES), a gap on a day without a check-in, and the counts in its accessible name. - Dimension score bars (/assessments, the public results overlay) and the reports adherence bars are toned Meters; scoreColor becomes scoreTone. The overlay sets --ck-line to its own hairline. - --ck-series-4 maps to the gold: it defaulted to --ck-up, the same teal as the accent, so Energy and Focus drew in one colour. - recharts, the metric colour field, --purple and the bar/dot CSS are removed; the design gate's allowlist drops the three files that no longer need a style prop. All three exceptions leave package-plan.json. Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9 Co-authored-by: Claude <noreply@anthropic.com>
80 lines
2.9 KiB
TypeScript
80 lines
2.9 KiB
TypeScript
// Admin signal thresholds — SSOT, no magic numbers in page files
|
||
|
||
import { CHECKIN_METRICS, type MetricKey } from "@/lib/config/portal";
|
||
|
||
/** Days since last check-in before patient is marked critical (has prior check-in history) */
|
||
export const NO_CHECKIN_CRITICAL_DAYS = 5;
|
||
|
||
/** Assessment score must drop by MORE THAN this many points to trigger critical signal (strict >, not >=) */
|
||
export const SCORE_DROP_CRITICAL = 10;
|
||
|
||
/** Days after registration where no activity is expected (new patient grace period) */
|
||
export const NEW_PATIENT_GRACE_DAYS = 3;
|
||
|
||
/** Days after an attended consultation before a follow-up booking is flagged as needed */
|
||
export const ATTENDED_FOLLOW_UP_DAYS = 30;
|
||
|
||
/** Days of check-in history to fetch for sparkline and signal computation */
|
||
export const SIGNAL_CHECKIN_WINDOW_DAYS = 7;
|
||
|
||
export const PATIENT_SIGNAL_VALUES = ["critical", "attention", "active", "new"] as const;
|
||
export type PatientSignal = (typeof PATIENT_SIGNAL_VALUES)[number];
|
||
|
||
/** Named constants for patient signal values — use in comparisons instead of string literals */
|
||
export const PATIENT_SIGNAL = {
|
||
critical: "critical",
|
||
attention: "attention",
|
||
active: "active",
|
||
new: "new",
|
||
} as const satisfies Record<PatientSignal, PatientSignal>;
|
||
|
||
/** Check-in metric keys that can be linked to clinical goals — derived from CHECKIN_METRICS SSOT */
|
||
export const CHECKIN_GOAL_METRICS = CHECKIN_METRICS.map((m) => m.key);
|
||
export type CheckinGoalMetric = MetricKey;
|
||
|
||
/** Sort order for signal severity — lower = shown first */
|
||
export const SIGNAL_SORT_ORDER: Record<PatientSignal, number> = {
|
||
critical: 0,
|
||
attention: 1,
|
||
active: 2,
|
||
new: 3,
|
||
};
|
||
|
||
export const SIGNAL_LABELS: Record<PatientSignal, string> = {
|
||
critical: "Critical",
|
||
attention: "Attention",
|
||
active: "Active",
|
||
new: "New",
|
||
};
|
||
|
||
/** Average check-in wellbeing score (mood+energy+sleep, 1–5) below which a dip is flagged */
|
||
export const CHECKIN_DIP_ALERT_THRESHOLD = 2.5;
|
||
|
||
/** Number of consecutive days at or below the threshold before Manuel is alerted */
|
||
export const CHECKIN_DIP_ALERT_DAYS = 3;
|
||
|
||
/** Wellness sparkline level thresholds (avg of 5 metrics, 1–5 scale) */
|
||
export const SPARKLINE_LOW_THRESHOLD = 2.5;
|
||
export const SPARKLINE_MID_THRESHOLD = 3.5;
|
||
|
||
/** A ChartKit bar tone: drawn in --ck-down / --ck-warning / --ck-up (globals.css). */
|
||
export type ChartTone = "positive" | "warning" | "negative";
|
||
|
||
/** Chart tone for each signal severity — SSOT for signal colour in charts. `new` has none: neutral ink. */
|
||
export const SIGNAL_TONES: Record<PatientSignal, ChartTone | undefined> = {
|
||
critical: "negative",
|
||
attention: "warning",
|
||
active: "positive",
|
||
new: undefined,
|
||
};
|
||
|
||
/** A day's wellness level in the patients table's check-in sparkline. */
|
||
export type SparkLevel = "low" | "mid" | "high";
|
||
|
||
/** Sparkline dot tone for each wellness level — the same scale as the signal tones. */
|
||
export const SPARK_LEVEL_TONES: Record<SparkLevel, ChartTone> = {
|
||
low: "negative",
|
||
mid: "warning",
|
||
high: "positive",
|
||
};
|