mirror of
https://github.com/temetro/temetro.git
synced 2026-08-31 04:47:57 +00:00
frontend: pharmacy inventory, lab add-result & analysis charts
- Pharmacy: the sidebar entry now expands into Pharmacy + a new Inventory page (searchable medication stock with derived in-stock/low/out availability, backed by /api/inventory). Fix the dispensing-queue "Expiring" badge so it only flags courses ending within the next 7 days, not ones already elapsed. - Lab "Add analysis result": the patient picker no longer lists patients until you type and supports arrow-key + Enter selection; the test field offers a catalog of common analyses with an Advanced option (custom analysis + ref range); submitted results now show immediately in a Recent results feed. - Analysis: add a Live panel (real-time line chart) and replace the flat trend sparklines with bklit-ui area + bar charts (installed from the @bklit shadcn registry; chart CSS variables wired into the theme for light and dark). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
const DEFAULT_SKELETON_DATA_KEY = "value";
|
||||
const DEFAULT_SKELETON_POINT_COUNT = 7;
|
||||
|
||||
export interface GenerateChartSkeletonDataOptions {
|
||||
/** Key used for y values in each row. Default: `"value"`. */
|
||||
dataKey?: string;
|
||||
/** Number of points. Default: 7. */
|
||||
pointCount?: number;
|
||||
/** Start date for the x axis. Default: 2025-01-01. */
|
||||
baseDate?: Date;
|
||||
}
|
||||
|
||||
/** Placeholder series used while `status="loading"` and data is empty. */
|
||||
export function generateChartSkeletonData(
|
||||
options: GenerateChartSkeletonDataOptions = {}
|
||||
): Record<string, unknown>[] {
|
||||
const dataKey = options.dataKey ?? DEFAULT_SKELETON_DATA_KEY;
|
||||
const pointCount = options.pointCount ?? DEFAULT_SKELETON_POINT_COUNT;
|
||||
const baseDate = options.baseDate ?? new Date("2025-01-01");
|
||||
|
||||
return Array.from({ length: pointCount }, (_, index) => {
|
||||
const date = new Date(baseDate);
|
||||
date.setDate(baseDate.getDate() + index);
|
||||
return {
|
||||
date,
|
||||
[dataKey]: Math.round(110 + Math.sin(index * 1.15) * 36 + index * 9),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/** Skeleton rows that mirror target dates/count with lower magnitudes for Y tween. */
|
||||
export function generateChartSkeletonFromTarget(
|
||||
targetData: Record<string, unknown>[],
|
||||
dataKey: string
|
||||
): Record<string, unknown>[] {
|
||||
return targetData.map((row, index) => ({
|
||||
...row,
|
||||
[dataKey]: Math.round(95 + Math.sin(index * 1.05) * 28 + index * 7),
|
||||
}));
|
||||
}
|
||||
|
||||
export { DEFAULT_SKELETON_DATA_KEY, DEFAULT_SKELETON_POINT_COUNT };
|
||||
Reference in New Issue
Block a user