Files
med-plan-assistant/docs/2026-01-09_IMPLEMENTATION_SUMMARY.md

7.6 KiB
Raw Blame History

Pharmacokinetics Implementation Summary

Changes Implemented (January 9, 2026)

1. Core Parameter Updates

Constants & Defaults (src/constants/defaults.ts):

  • Updated LDX_TO_DAMPH_SALT_FACTOR from 0.2948 to 0.29677 (exact MW ratio: 135.21/455.60)
  • Added DEFAULT_F_ORAL = 0.96 (oral bioavailability from FDA label)
  • Changed LDX absorption half-life default from 1.5h to 0.9h (better matches ~1h Tmax)
  • Widened therapeutic range from 10.511.5 to 525 ng/mL (general adult range)
  • Bumped localStorage key to v7 (will reset existing user data)

2. Advanced Settings Features

New Parameters (src/constants/defaults.ts):

advanced: {
  weightBasedVd: { enabled: false, bodyWeight: '70' }, // kg
  foodEffect: { enabled: false, tmaxDelay: '1.0' }, // hours
  urinePh: { enabled: false, phTendency: '6.0' }, // pH 5.5-8.0
  fOral: '0.96', // bioavailability (editable)
  steadyStateDays: '7' // medication history (0-7 days)
}

Renamed Field:

  • ldx.absorptionRateldx.absorptionHalfLife (clarifies units = hours, not rate constant)

3. Pharmacokinetic Model Enhancements

Updated Calculations (src/utils/pharmacokinetics.ts):

Weight-Based Volume of Distribution

  • Formula: Vd = bodyWeight × 5.4 L/kg (Roberts et al. 2015)
  • Standard adult Vd: 377 L (70 kg × 5.4 ≈ 378 L)
  • Effect: Lighter users show higher peaks, heavier users lower peaks
  • Scaling: concentration × (377 / weightBasedVd)

Food Effect (High-Fat Meal)

  • Mechanism: Delays Tmax by ~1h without changing AUC (FDA label data)
  • Implementation: adjustedAbsorptionHL = absorptionHL × (1 + tmaxDelay/1.5)
  • Result: Slower onset, flatter curve

Urine pH Effects

  • Acidic (pH < 6): 30% faster elimination → HL × 0.7 → ~7-9h
  • Normal (pH 6-7.5): No adjustment → ~10-12h
  • Alkaline (pH > 7.5): 35% slower elimination → HL × 1.35 → ~13-15h
  • Rationale: Henderson-Hasselbalch equation (amphetamine pKa ~9.9)

Bioavailability Application

  • Now explicitly applied: effectiveDose = numDose × SALT_FACTOR × fOral
  • Transparent and user-adjustable in Advanced section

4. User Interface Changes

Settings Panel (src/components/settings.tsx):

Pharmacokinetic Settings (Updated)

  • d-Amphetamine Elimination Half-Life

    • Range: 5-34h (min-max)
    • Warning: Outside 9-12h (typical)
    • Error: Outside 7-15h (extreme)
    • Tooltip: Explains pH effects
  • LDX Conversion Half-Life

    • Range: 0.5-2h
    • Warning: Outside 0.7-1.2h
    • Tooltip: RBC conversion mechanism
  • LDX Absorption Half-Life (renamed from "Rate")

    • Range: 0.5-2h
    • Warning: Outside 0.7-1.2h
    • Tooltip: Food delay effects

Advanced Settings (New Section - Collapsed by Default)

  • Warning Banner: Yellow alert about deviations from population averages
  • Weight-Based Vd Scaling: Toggle + kg input (20-150 kg)
  • High-Fat Meal: Toggle + delay input (0-2h, default 1h)
  • Urine pH Tendency: Toggle + pH input (5.5-8.0)
  • Oral Bioavailability (F): Direct input (0.5-1.0, default 0.96)
  • Steady-State Days: Input (0-7 days) — 0 = "first day from scratch"

Tooltips: All parameters have detailed explanations with literature references

First-Start Modal (src/components/disclaimer-modal.tsx):

  • Shows on first app load (localStorage flag: medPlanDisclaimerAccepted_v1)
  • Sections:
    • Purpose & Limitations
    • Individual Variability (±30-40%)
    • Medical Consultation Required
    • Schedule II Controlled Substance Warning (red alert box)
    • Data Sources (Ermer, Boellner, Roberts, FDA PI)
    • No Warranties/Liability (hobbyist project, DE/EU focus)
  • Acknowledgment required before app use

Footer (src/App.tsx):

  • Added button to reopen disclaimer modal
  • Link text: "Medical Disclaimer & Data Sources"

6. Localization

English (src/locales/en.ts):

  • 30+ new strings for Advanced section, tooltips, warnings, modal
  • Clinical references in tooltip text (e.g., "Typical: 0.7-1.2h")

German (src/locales/de.ts):

  • Complete translations for all new strings
  • Adapted regulatory language for DE/EU context

7. Validation & Warnings

Non-Blocking Warnings (via FormNumericInput warning prop):

  • Absorption HL < 0.7 or > 1.2h: Yellow tooltip
  • Conversion HL < 0.7 or > 1.2h: Yellow tooltip
  • Elimination HL < 9 or > 12h: Yellow tooltip
  • Elimination HL < 7 or > 15h: Red error tooltip (extreme)
  • Inputs remain editable (user can override with warning)

Impact Analysis

Default Behavior Changes

Parameter Old New Effect
Salt Factor 0.2948 0.29677 +0.6% amplitude
Bioavailability Implicit 0.96 explicit No change (was baked in)
Absorption HL 1.5h 0.9h Earlier, higher peak
Therapeutic Range 10.5-11.5 5-25 Wider reference band

Example Scenario: 30 mg LDX Adult

Old Calculation:

  • Active dose: 30 × 0.2948 = 8.844 mg
  • Peak ~19.6 ng/mL (1.5h absorption)

New Calculation:

  • Active dose: 30 × 0.29677 × 0.96 = 8.551 mg
  • Peak ~20-22 ng/mL (0.9h absorption, earlier Tmax)

Net Effect: Slightly earlier peak, similar amplitude (±5%)

Advanced Feature Impact (When Enabled)

Weight Scaling Example (50 kg user, 30 mg dose):

  • Standard (70 kg): ~20 ng/mL
  • Weight-scaled (50 kg): ~28 ng/mL (+40%)
  • Aligns with pediatric literature (130 ng/mL at 70 mg for children)

Food Effect Example:

  • Fasted: Tmax ~3.5h, Cmax ~20 ng/mL
  • High-fat meal (+1h delay): Tmax ~4.5h, Cmax ~18-19 ng/mL (flatter)

Urine pH Example:

  • Acidic (pH 5.5): HL ~8h, faster washout
  • Alkaline (pH 7.8): HL ~15h, prolonged duration

Testing Recommendations

  1. Defaults Check: Open fresh app, verify:

    • Therapeutic range shows 5-25 ng/mL
    • Absorption HL = 0.9h
    • Disclaimer modal appears
  2. Advanced Toggle Test:

    • Enable weight scaling at 50 kg → peaks should increase
    • Enable food effect → curve should flatten/delay
    • Enable urine pH = 5.5 → elimination should speed up
  3. Warning Validation:

    • Set absorption HL to 2.0h → yellow warning appears
    • Set elimination HL to 5h → red error tooltip appears
    • Values remain editable despite warnings
  4. Localization: Switch language, verify German strings render correctly

Known Limitations

  1. No Calculation Summary Box: Deferred (complex UI, optional feature)
  2. No Dose Safety Checks Yet: >70mg warning not implemented (FormNumericInput integration pending)
  3. No Age/Child Preset: User must manually adjust Vd/weight for pediatric simulation

Migration Notes

  • Breaking Change: localStorage key changed to v7 — existing users will see defaults reset
  • State Compatibility: Old absorptionRate field auto-migrates to absorptionHalfLife via defaults
  • URL Sharing: Plans shared with old parameter names may not load correctly

References

All clinical data cited in tooltips and modal sourced from:

  • Ermer et al. (2016): Lisdexamfetamine Dimesylate PK in Adults
  • Boellner et al. (2010): Pediatric PK Study
  • Roberts et al. (2015): Population PK Analysis, Vd = 377 L
  • FDA Prescribing Information (2007-2017): Bioavailability, food effects, warnings
  • TGA Australia Assessment Report: Prodrug mechanism, RBC conversion

Implementation Date: January 9, 2026 Developer: Andreas Weyer (via GitHub Copilot) Status: Build successful, dev server running, no compilation errors