Update pharmacokinetic parameters/calculations, add advanced settings, add disclaimer/citations, many improvements

This commit is contained in:
2026-01-09 19:50:15 +00:00
parent abd8e790b8
commit b396caa67a
14 changed files with 2222 additions and 192 deletions

View File

@@ -8,13 +8,27 @@
* @license MIT
*/
export const LOCAL_STORAGE_KEY = 'medPlanAssistantState_v6';
export const LDX_TO_DAMPH_CONVERSION_FACTOR = 0.2948;
export const LOCAL_STORAGE_KEY = 'medPlanAssistantState_v7';
// Pharmacokinetic Constants (from research literature)
// MW ratio: 135.21 (d-amphetamine) / 455.60 (LDX dimesylate) = 0.29677
export const LDX_TO_DAMPH_SALT_FACTOR = 0.29677;
// Oral bioavailability for LDX (FDA label, 96.4%)
export const DEFAULT_F_ORAL = 0.96;
// Type definitions
export interface AdvancedSettings {
weightBasedVd: { enabled: boolean; bodyWeight: string }; // kg
foodEffect: { enabled: boolean; tmaxDelay: string }; // hours
urinePh: { enabled: boolean; phTendency: string }; // 5.5-8.0 range
fOral: string; // bioavailability fraction
steadyStateDays: string; // days of medication history to simulate
}
export interface PkParams {
damph: { halfLife: string };
ldx: { halfLife: string; absorptionRate: string };
ldx: { halfLife: string; absorptionHalfLife: string }; // renamed from absorptionRate
advanced: AdvancedSettings;
}
export interface DayDose {
@@ -82,7 +96,17 @@ export interface ConcentrationPoint {
export const getDefaultState = (): AppState => ({
pkParams: {
damph: { halfLife: '11' },
ldx: { halfLife: '0.8', absorptionRate: '1.5' },
ldx: {
halfLife: '0.8',
absorptionHalfLife: '0.9' // changed from 1.5, better reflects ~1h Tmax
},
advanced: {
weightBasedVd: { enabled: false, bodyWeight: '70' }, // kg, adult average
foodEffect: { enabled: false, tmaxDelay: '1.0' }, // hours delay
urinePh: { enabled: false, phTendency: '6.0' }, // pH scale (5.5-8.0)
fOral: String(DEFAULT_F_ORAL), // 0.96 bioavailability
steadyStateDays: '7' // days of prior medication history
}
},
days: [
{
@@ -96,15 +120,15 @@ export const getDefaultState = (): AppState => ({
]
}
],
steadyStateConfig: { daysOnMedication: '7' },
therapeuticRange: { min: '10.5', max: '11.5' },
steadyStateConfig: { daysOnMedication: '7' }, // kept for backwards compatibility, now sourced from pkParams.advanced
therapeuticRange: { min: '5', max: '25' }, // widened from 10.5-11.5 to general adult range
doseIncrement: '2.5',
uiSettings: {
showDayTimeOnXAxis: '24h',
showTemplateDay: true,
chartView: 'damph',
yAxisMin: '8',
yAxisMax: '13',
yAxisMin: '',
yAxisMax: '',
simulationDays: '5',
displayedDays: '2',
showTherapeuticRange: true,