Skip to content

feat(medications): calm detail page with four tabs and server-worded effect - #1628

Merged
MBombeck merged 29 commits into
release/v1.50.0from
feat/150-medication-detail
Nov 28, 2026
Merged

MBombeck merged 29 commits into
release/v1.50.0from
feat/150-medication-detail

Conversation

@MBombeck

@MBombeck MBombeck commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

The medication detail page, rebuilt to the approved "calm tabs" layout.

What changes

  • Header in one line: name, state chip, dose, cadence, and a menu (Edit, Pause/Resume, End). Start and end dates and the note moved into the plan.
  • Four tabs: Overview, History, Effect, Settings (Injection stays a fifth tab for injectables). Schedule, Supply and Advanced folded into Settings.
  • Overview: three cards with one anatomy (header with an optional chip, at most one sentence, a figure or short list, the shared ActionPair with the secondary left): Today (today's doses from the today list, Skip / Take; no sentence when the rows already say the time and state), Intake (server adherence, 14-day dose grid with legend, Log past dose / History), Effect (server result sentence, before → after, small SVG chart, Change measurement / Details). One filled button per screen (Take); History and Details are outlined. Below: the plan as one table (period, reminder, supply, note, leaflet; the cadence is the header's line only) and the links as the shared RecordLinksRow tile ("Verknüpfungen": chips and one "Link" menu, no tile when there is nothing to show or add).
  • Leaflet: one plan row. A saved leaflet is a chip; otherwise "Search" opens the registry; the registry hint, "Change registry", the registry reminder and saving a link sit behind "More". No filled button.
  • History: the shared ListGroup / ListItem: one card per week (the two newest first, older weeks on request), one row per dose. A dose taken at its planned time is a check; a second line appears only when something differs from the plan (taken at another time, another dose, pinned). A tap opens the dose's sheet: take, skip, pin/release, edit, the skipped/taken toggle, open the day, delete; a write delegate gets take and skip. Above the weeks: the rate with the non-zero counts (no bar; the overview has the picture), Log past dose, and the range switch.
  • Effect: the result sentence first, the before/after figures, the chart with its scale switch top right, the method (intro, counts, segmented fit, level shift) behind "How this is worked out". The Y axis shows its numbers again (it was 40 px wide and showed only "mmHg").
  • Settings: four headings (Plan, Period, Data, Delete), one line per setting, label left, control right, no folded explanations. Rows with a chevron open a sheet: dose times, supply, courses, plan history, export, API access, clinical codes; the reminder phases sheet now leads with the reminder plan sentence.
  • Old links: ?tab= schedule, supply, advanced and the German slugs resolve to Settings; ?tab=supply (the low-stock push) opens the supply sheet. Guarded by medication-tab-slugs.test.ts.

Contract (additive)

GET /api/medications/{id}/efficacy carries targets[].result: { direction: "lower" | "higher" | "unchanged" | null, text }, worded on the server in the reader's language (serverText.efficacyResult.*, ten locales). A change under 2 % of the before-mean reads unchanged. Feature key medication.efficacy-result in GET /api/version. OpenAPI regenerated. No other route, field or migration.

Measured (demo seed, 1440 px, active panel)

Tab Words before → after Actions before → after Height
Overview 85 → 142 (three cards + plan) 10 → 13 one screen
History (90 days) 731 → two weeks of rows on first paint, older weeks on request 183 → one tap target per dose plus Log past dose, range and "Show earlier weeks" 8,927 px → 1,262 px for the page at 1440 (once daily, demo seed)
Effect 382 → 109 8 → 9
Settings (was Schedule + Supply + Advanced) 175 + 20 + 115 → 53 17 + 1 + 15 → 19

Every action, before and after

Action Before After
Take next dose Overview status: "Take extra" (wide button) Overview › Today: Take (pair, right)
Skip next dose Overview status: Skip Overview › Today: Skip (pair, left)
Remind me later Overview status, under the buttons Overview › Today, above the pair
Jump to schedule / supply Overview status links Plan rows and Settings
Adherence explanation popover Overview › Adherence removed (sentence + figure say it)
Log a past dose History header "Log intake" Overview › Intake "Log past dose", Today (as-needed), History "Log past dose"
Open history Overview: none Overview › Intake "History"
Range 90 days / all History, top History card header, top right
Take an open dose today History row button History › dose sheet
Backfill a missed dose Row kebab Dose sheet
Skip a dose Row kebab (owner), button (delegate) Dose sheet (owner and delegate)
Pin / release an off-schedule take Row kebab Dose sheet
Edit an intake Row kebab Dose sheet
Toggle taken / skipped Row kebab Dose sheet
Delete an intake (with undo) Row kebab Dose sheet
Open the day Underlined date link Dose sheet "Open day"
Change effect measurement Effect intro: select + Apply Overview › Effect and Effect tab: "Change measurement" sheet
Reset measurement to default Effect intro button Same sheet
Effect scale absolute / % Under each card header Card header, top right
Effect data points table Chart fold unchanged
Effect details Effect tab Overview › Effect "Details"
Edit in the wizard Advanced › Lifecycle "Open editor"; ?edit=1 Header menu "Edit", Plan "Edit", Settings › Medication; ?edit=1
Pause / resume Advanced › Lifecycle switch Header menu, Settings › Period switch
End course Advanced › Lifecycle button + confirm Header menu, Settings › Period, same confirm
Courses (view, start, edit) Advanced › Lifecycle; guardian on Schedule tab Settings › Period › Courses sheet (guardian included)
Composition (offer) Advanced › Lifecycle Settings › Data
Composition card Overview Overview (unchanged)
Track intake on/off Schedule tab Settings › Plan switch
Dose times and windows Schedule tab editor Settings › Plan › Dose times sheet (same editor)
Reminder on/off (or iPhone chip) Schedule › Reminder Settings › Plan switch / chip
Record automatically Schedule › Reminder Settings › Plan switch
Reminder length Schedule › Reminder select Settings › Plan, inline select
Reminder phases Schedule › Reminder "Adjust" Settings › Plan row, same sheet (now with the plan sentence)
Notification channels Schedule link Settings › Plan row
Plan history, add / edit era Schedule tab Settings › Period › Plan history sheet
Supply: register pack, correct, packaging Supply tab Settings › Plan › Supply sheet (same section); low-stock link opens it
Export CSV (with history) Advanced › Data Settings › Data › Export sheet
Import intakes Advanced › Data Settings › Data › Import
API token, URL, request example Advanced › External API Settings › Data › API access sheet
Clinical codes ATC / RxNorm Advanced › External API Settings › Data › Clinical codes sheet
Delete history Advanced › Danger zone Settings › Delete › History (same confirm)
Delete medication Advanced › Danger zone Settings › Delete › Medication (same confirm)
Related records: link condition, document, visit Overview › Related Overview › Verknüpfungen, one "Link" menu (shared RecordLinksRow)
Leaflet: search registry Overview › Leaflet (filled button) Plan › Leaflet "Search"
Leaflet: open saved link Overview › Leaflet Plan › Leaflet chip
Leaflet: choose / change registry, save / edit / remove link Overview › Leaflet Plan › Leaflet › More
Injection tab (titration, side effects, drug level, dose curve) Injection tab unchanged

Nothing was removed except the adherence help popover and the ad-hoc "was due at" line in the history (the pin action in the dose sheet still names the slot), the extra-dose hint under Take (the button says "Take extra" and the toast confirms it) and the history's second adherence bar.

One source each

  • The on-time window of a schedule without its own value: the recurrence engine fell back to the legacy window span or 60 minutes, the compliance cycle walk to 60, the plan row and the reminder setting to 30. effectiveGraceMinutes (src/lib/medications/scheduling/grace.ts) is the one rule now; pause-and-grace-single-source.test.ts refuses a second numeric fallback.
  • The pause state: the header menu and the settings switch each seeded !active at mount and drifted after a pause from the other. The hook derives it from the stored flag and overrides it only while its write is in flight; the same test pins it.

Checks

  • pnpm typecheck, pnpm lint, pnpm test green; medication integration tests green.
  • New: medication-tab-slugs.test.ts (old slugs), efficacy-result.test.ts (direction, wording, all locales), overview-cards.test.tsx, e2e/medication-detail.spec.ts (tabs, button pairs of equal width, one row per dose and a card per week, the dose sheet, settings groups, old links, axe on every tab in both themes, no sideways scroll at 390 px). New: pause-and-grace-single-source.test.ts. Updated: leaflet, delegated affordances, dose vocabulary, summary, notification dispatch e2e.
  • Screenshots at 1440 dark and 390 light for a twice-daily and an as-needed medication were reviewed against the approved concept.

…effect

The detail page gets a one-line header with a menu (edit, pause, end) and
four tabs instead of six. The overview opens with three cards built the
same way (today, intake, effect), each ending in two equal buttons, then
the plan as one table that now also holds the leaflet. The history is one
row per day with a column per dose time and one menu per day. The effect
tab leads with its result and keeps the method behind a fold. Settings
replaces the schedule, supply and advanced tabs with four groups of
one-line rows; everything longer opens in a sheet.

The efficacy read carries targets[].result, the comparison's direction and
one sentence in the reader's language, behind the feature key
medication.efficacy-result. Old ?tab= slugs resolve to the tab that holds
their controls, and an old supply link opens the supply sheet.
@MBombeck
MBombeck marked this pull request as ready for review November 27, 2026 14:31
…edication-detail

# Conflicts:
#	CHANGELOG.md
The overview cards move into one module each (anatomy, today, intake,
effect, plan), the effect result helpers into their own module, and the
short cadence line beside the header that uses it. The settings tab, the
history table and the danger zone extract their sheet, groups, table and
confirmation, so no function grows past the size ratchet. The intake card
reads its rate through shownAdherence; the Polish and Russian miss
sentences use the missed word; baselines record the lower counts.
…edication-detail

# Conflicts:
#	CHANGELOG.md
#	docs/api/openapi.yaml
#	src/__tests__/baselines/source-file-lines.json
#	src/__tests__/baselines/source-function-lines.json
#	src/__tests__/baselines/version-stamp-comments.json
#	src/components/__tests__/delegated-write-affordances.test.tsx
#	src/lib/server-features.ts
…e source each

The recurrence engine closed a dose's on-time window after the schedule's
own value, else its legacy window span, else 60 minutes; the compliance
cycle walk fell back to 60 without the span, and the page's plan row and
reminder setting to 30. effectiveGraceMinutes is now the one rule and every
reader calls it.

The header menu and the settings switch each seeded a copy of the paused
state at mount, so pausing from one left the other saying the opposite.
The hook derives it from the stored active flag and overrides it only
while its own write is in flight. A test pins both.
The Today card's sentence read back the time and the state its rows show;
it now speaks only when there is no row. The Intake card named its window
in the chip and again in the sentence, the Effect card the change in the
sentence and again as a figure, and the plan repeated the cadence the
header line carries. One filled button per screen: History, Details and
the paused card's History are outlined.
… week

The history was a table with a day per row, a column per dose time and a
menu per day. It is now the shared ListGroup and ListItem: a card per week,
the two newest first and older weeks on request, a row per dose with its
state at the end and a second line only when what happened differs from
the plan. A dose taken on time is a check. A tap opens the dose's sheet
with take, skip, pin, release, edit, the toggle, open the day and delete;
a write delegate gets take and skip. The summary keeps the rate and the
counts that are not zero; its bar is gone, the overview has the picture.
…edication-detail

# Conflicts:
#	CHANGELOG.md
The retarget sheet passes its two buttons to the footer, the on-time check
comes from the dose-state look, the single-source test reads through the
source helpers, and the ratchets drop the entries the old dose table held.
…paused overview

As needed, the Today card no longer repeats the header's "as needed", the
Intake card leaves Log past dose to Today and its one-tone legend to the
sentence. A dose that cannot be taken now leaves the Today card without a
pair, since Intake below carries Log past dose and History.
…edication-detail

# Conflicts:
#	CHANGELOG.md
#	docs/api/openapi.yaml
#	src/__tests__/baselines/source-function-lines.json
#	src/__tests__/baselines/version-stamp-comments.json
#	src/components/medications/detail/medication-detail-tabs.tsx
…edication-detail

# Conflicts:
#	src/__tests__/baselines/source-file-lines.json
#	src/__tests__/baselines/source-function-lines.json
#	src/__tests__/baselines/version-stamp-comments.json
@MBombeck
MBombeck merged commit 9ac8fb0 into release/v1.50.0 Nov 28, 2026
40 checks passed
MBombeck pushed a commit that referenced this pull request Nov 28, 2026
eat/150-medication-detail (#1628) landed on `release/v1.50.0` after the
bundle was synced, so 52 English keys have no Chinese counterpart. `release`
is red on the plural guard because of it:

    i18n-count-plural-guard > zh-CN has a plural block
    migrations.detail.settingsTab.intakeCount: count

These are those 52, inside `medications.detail.*`, `medications.efficacy.*`,
`medications.leaflet.*` and `serverText.efficacyResult.*` — the new
medication detail screen, its intake log, its plan section and the efficacy
sentence the server writes.

Chinese has one plural form, so each block carries `other` only, which is what
the guard asks for. The measure-word rule from the typography change holds here
too: `{days}天`, `{count}次`, `{minutes}分钟`, never a space.

The bundle is now key for key with English again: 0 missing. 32 keys remain in
zh-CN that English no longer has — they are strays from the release renames, not
references from code, and they are left alone here so this change stays a
catch-up rather than a clean-up.

Verified: the plural guard and the rest of the i18n family (drift, reverse
coverage, English leak, typography and glyphs, title case, dose vocabulary,
glossary) are green, 327 cases.
@MBombeck
MBombeck deleted the feat/150-medication-detail branch December 1, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant