mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 21:32:18 +00:00
Add a user-defined custom-metric store alongside the built-in measurements on the Measurements surface. A user defines an arbitrary metric (name, unit, optional target window, decimals, description), logs values, and charts them. The store is a separate generic catalog + values pair, isolated from the closed measurement-type system: not synced, not in FHIR, not in insights — log and chart only. Names and units are plaintext, mirroring the biomarker catalog. The inline list lives beneath the measurement list (no new nav entry); tapping a metric opens a detail page with the trend chart, target band, stat strip, and an editable value history. Migration 0224 adds custom_metrics and custom_metric_entries.
20 lines
890 B
TypeScript
20 lines
890 B
TypeScript
/**
|
|
* v1.25.5 — TanStack Query keys for the user-defined custom-metric store.
|
|
*
|
|
* `customMetricEntries` bakes the metric id + sort direction into the key so an
|
|
* infinite-query accumulation never collides with another metric's feed (the
|
|
* project's queryKey-factory invariant). Mutations invalidate `customMetrics()`
|
|
* (the catalog list) and the per-metric detail / entry keys.
|
|
*/
|
|
export const customMetrics = {
|
|
/** The caller's custom-metric catalog list (with latest value). */
|
|
customMetrics: () => ["custom-metrics"] as const,
|
|
|
|
/** A single custom-metric detail. */
|
|
customMetricDetail: (id: string) => ["custom-metrics", "detail", id] as const,
|
|
|
|
/** Paginated (offset) value feed for one custom metric. */
|
|
customMetricEntries: (params: { customMetricId: string; sortDir: string }) =>
|
|
["custom-metric-entries", params.customMetricId, params.sortDir] as const,
|
|
};
|