mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 07:13:29 +00:00
fix(glp1): match side-effect tags by key, not by an English/German word list
The GLP-1 side-effect chips in the mood form write the localised label into the flat `MoodEntry.tags` column, and three readers matched that label against a hand-written list of English and German words: the therapy timeline, the Coach snapshot, and the doctor report's GLP-1 block. The app ships six locales. Tap the nausea chip with the UI in French, Spanish, Italian or Polish and the day never reached the timeline, the Coach grounded its answers on an empty side-effect list, and a clinician read an empty table over a record that had three months of symptoms. Nothing on any of those surfaces said the table was a filter rather than the truth. The three lists had also drifted apart from each other. The chips are a closed set with stable keys, so matching the label was the defect and the key is the fix. `glp1-side-effect-tags.ts` holds the catalogue — seven keys, each with the i18n key its chip renders — and the mood form now draws its strip from it, so the write side and the read side cannot diverge again. `glp1-side-effect-tag-match.ts` builds the label-to-key index by reading `messages/<locale>.json` for every entry in `locales`, rather than transcribing the labels into a second list. Transcribing would have fixed today's four locales and reopened the same hole on the day a seventh is added; deriving means a new bundle is matchable as soon as it lands, with no edit in the matcher. Comparison folds case, accents and separators, so the English and German tags already in the database keep resolving and a straight apostrophe matches the typographic one the French bundle uses. All three readers now report the catalogue key instead of the stored string. The same recorded symptom yields one key whatever language it was tagged in, which also fixes the mixed-language output an account gets after switching UI locale; the doctor-report PDF resolves the key through the label map so the clinician reads it in the report's language. A tag outside the catalogue is still never counted — a free-text mood tag must not reach a doctor as an invented symptom, and the rest of somebody's day does not belong on a therapy timeline. It is no longer dropped without trace: the timeline route annotates the unresolved count on its wide event, so the classification rate stays answerable while the tag text stays in the database. The Coach's copy of the list also carried `vomiting`, `reflux` and `erbrechen`. Those are removed. No chip writes them, so they only ever matched a hand-typed tag in two of six languages; keeping them would have rebuilt the defect inside its own fix. Restoring either symptom means giving it a chip and a label in all six bundles. The response schema for `GET /api/insights/glp1-timeline` now enumerates the keys, and its description no longer documents the bilingual match as if it were the contract.
This commit is contained in:
1 parent
b76468f455
commit
97d0c26ceb
14 files changed
+833
-167
No files matched your search
@@ -64,6 +64,10 @@ import { dayOfLocalInput, useLinkedDayContext } from "./use-linked-day-context";
|
||||
import { MoodQuickTags } from "./mood-quick-tags";
|
||||
import { useRecentTags } from "./recent-tags";
|
||||
import { moodFaceIcon } from "./mood-tag-icons";
|
||||
// One catalogue for the chip strip and for every server-side reader of what it
|
||||
// writes. Split apart, the write side gained a locale and the read side did
|
||||
// not notice for four of them.
|
||||
import { GLP1_SIDE_EFFECT_TAGS } from "@/lib/medications/glp1-side-effect-tags";
|
||||
|
||||
// v1.12.0 — best-on-the-left face order for the "How are you?" hero,
|
||||
// mirroring the iOS `Mood1…Mood5` imageset order. The numeric `score`
|
||||
@@ -82,24 +86,6 @@ const MOOD_LEVELS = [
|
||||
// so the truncation at the cap is no longer silent.
|
||||
const NOTE_MAX_LENGTH = 500;
|
||||
|
||||
/**
|
||||
* v1.4.25 W4d — curated GLP-1 side-effect chip strip. Tapping a chip
|
||||
* appends the localised tag string to the existing free-text tag input
|
||||
* (comma-separated). The list is intentionally short — these are the
|
||||
* symptoms clinicians most often ask about at GLP-1 follow-up visits
|
||||
* (cf. PMC GLP-1 adverse-effects review). Generic mood entries that
|
||||
* never touch the chips keep their tag input byte-identical to v1.4.24.
|
||||
*/
|
||||
const GLP1_SIDE_EFFECT_KEYS = [
|
||||
"medications.sideEffectTagNausea",
|
||||
"medications.sideEffectTagConstipation",
|
||||
"medications.sideEffectTagDiarrhea",
|
||||
"medications.sideEffectTagFatigue",
|
||||
"medications.sideEffectTagAppetiteLoss",
|
||||
"medications.sideEffectTagHeartburn",
|
||||
"medications.sideEffectTagHeadache",
|
||||
] as const;
|
||||
|
||||
interface MoodFormProps {
|
||||
onSuccess?: () => void;
|
||||
onCancel?: () => void;
|
||||
@@ -491,18 +477,19 @@ export function MoodForm({ onSuccess, onCancel, footerSlot }: MoodFormProps) {
|
||||
autoCapitalize="none"
|
||||
autoComplete="off"
|
||||
/>
|
||||
{/* v1.4.25 W4d — GLP-1 side-effect quick-tags. Tapping a chip
|
||||
appends the localised label to the free-text tag list.
|
||||
Always visible for now (cheap UX; the Coach side-effect
|
||||
aggregator filters on the canonical English tag set so the
|
||||
German labels still register correctly). */}
|
||||
{/* GLP-1 side-effect quick-tags. Tapping a chip appends the
|
||||
localised label to the free-text tag list. The catalogue is
|
||||
shared with the server-side matcher, which indexes every shipped
|
||||
locale's label back to the chip's key — so what a chip writes is
|
||||
what the timeline, the Coach snapshot and the doctor report
|
||||
count, in all six languages. */}
|
||||
<div className="space-y-1.5 pt-1">
|
||||
<p className="text-muted-foreground text-xs">
|
||||
{t("medications.sideEffectTagsHelp")}
|
||||
</p>
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{GLP1_SIDE_EFFECT_KEYS.map((key) => {
|
||||
const label = t(key);
|
||||
{GLP1_SIDE_EFFECT_TAGS.map(({ key, labelKey }) => {
|
||||
const label = t(labelKey);
|
||||
const tags = tagsInput
|
||||
.split(",")
|
||||
.map((p) => p.trim().toLowerCase());
|
||||
|
||||
Reference in new issue
Block a user