Fix various issues with pharmacokinetics, improved parameters, distinction between adult/child

This commit is contained in:
2026-01-17 20:27:00 +00:00
parent b911fa1e16
commit 6983ce3853
13 changed files with 1505 additions and 115 deletions

View File

@@ -26,7 +26,7 @@ const versionInfo = versionJsonDefault && Object.keys(versionJsonDefault).length
gitDate: 'unknown',
};
export const LOCAL_STORAGE_KEY = 'medPlanAssistantState_v7';
export const LOCAL_STORAGE_KEY = 'medPlanAssistantState_v8'; // Incremented for ageGroup + renalFunction fields
export const PROJECT_REPOSITORY_URL = 'https://git.11001001.org/cbaoth/med-plan-assistant';
export const APP_VERSION = versionInfo.version;
export const BUILD_INFO = versionInfo;
@@ -39,11 +39,23 @@ export const DEFAULT_F_ORAL = 0.96;
// Type definitions
export interface AdvancedSettings {
standardVd: { preset: 'adult' | 'child' | 'custom'; customValue: string }; // Volume of distribution (L)
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
// Age-specific pharmacokinetics (Research Section 5.2)
// Children (6-12y) have faster elimination: t½ ~9h vs adult ~11h
ageGroup?: {
preset: 'child' | 'adult' | 'custom';
};
// Renal function effects (Research Section 8.2, FDA label 8.6)
// Severe impairment extends half-life by ~50% (11h → 16.5h)
renalFunction?: {
enabled: boolean;
severity: 'normal' | 'mild' | 'severe';
};
}
export interface PkParams {
@@ -57,6 +69,7 @@ export interface DayDose {
time: string;
ldx: string;
damph?: string; // Optional, kept for backwards compatibility but not used in UI
isFed?: boolean; // Optional: indicates if dose is taken with food (delays absorption ~1h)
}
export interface DayGroup {
@@ -121,9 +134,10 @@ export const getDefaultState = (): AppState => ({
damph: { halfLife: '11' },
ldx: {
halfLife: '0.8',
absorptionHalfLife: '0.9' // changed from 1.5, better reflects ~1h Tmax
absorptionHalfLife: '0.7' // Updated from 0.9 for better ~1h Tmax of prodrug
},
advanced: {
standardVd: { preset: 'adult', customValue: '377' }, // Adult: 377L (Roberts 2015), Child: ~150-200L
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)
@@ -144,7 +158,7 @@ export const getDefaultState = (): AppState => ({
}
],
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
therapeuticRange: { min: '', max: '' }, // Empty by default - users should personalize based on their response
doseIncrement: '2.5',
uiSettings: {
showDayTimeOnXAxis: '24h',
@@ -154,7 +168,7 @@ export const getDefaultState = (): AppState => ({
yAxisMax: '',
simulationDays: '5',
displayedDays: '2',
showTherapeuticRange: true,
showTherapeuticRange: false,
steadyStateDaysEnabled: true,
stickyChart: false,
}