Update combined static Vd and weight-based settings

This commit is contained in:
2026-02-07 10:12:06 +00:00
parent b7a585a223
commit 199872d742
7 changed files with 73 additions and 77 deletions

View File

@@ -44,7 +44,7 @@ const getDefaultsForTranslation = (pkParams: any, therapeuticRange: any, uiSetti
// Advanced Settings
standardVdValue: defaults.pkParams.advanced.standardVd?.preset === 'adult' ? '377' : defaults.pkParams.advanced.standardVd?.preset === 'child' ? '175' : defaults.pkParams.advanced.standardVd?.customValue || '377',
standardVdPreset: defaults.pkParams.advanced.standardVd?.preset || 'adult',
bodyWeight: defaults.pkParams.advanced.weightBasedVd.bodyWeight,
bodyWeight: defaults.pkParams.advanced.standardVd.bodyWeight,
tmaxDelay: defaults.pkParams.advanced.foodEffect.tmaxDelay,
fOral: defaults.pkParams.advanced.fOral,
fOralPercent: String((parseFloat(defaults.pkParams.advanced.fOral) * 100).toFixed(1)),
@@ -374,7 +374,7 @@ const Settings = ({
</Tooltip>
</div>
{showTherapeuticRange && (
<div className="ml-8 space-y-2">
<div className="space-y-2">
<div className="flex items-center gap-2">
<Label className="font-medium">
{t('therapeuticRange')}
@@ -645,7 +645,7 @@ const Settings = ({
</Tooltip>
</div>
{steadyStateDaysEnabled && (
<div className="ml-8 space-y-2">
<div className="space-y-2">
<FormNumericInput
value={pkParams.advanced.steadyStateDays}
onChange={val => updateAdvancedDirect('steadyStateDays', val)}
@@ -827,7 +827,7 @@ const Settings = ({
</div>
<Select
value={pkParams.advanced.standardVd?.preset || 'adult'}
onValueChange={(value: 'adult' | 'child' | 'custom') => updateAdvanced('standardVd', 'preset', value)}
onValueChange={(value: 'adult' | 'child' | 'custom' | 'weight-based') => updateAdvanced('standardVd', 'preset', value)}
>
<SelectTrigger className="w-[360px]">
<SelectValue />
@@ -836,15 +836,16 @@ const Settings = ({
<SelectItem value="adult">{t('standardVdPresetAdult')}</SelectItem>
<SelectItem value="child">{t('standardVdPresetChild')}</SelectItem>
<SelectItem value="custom">{t('standardVdPresetCustom')}</SelectItem>
<SelectItem value="weight-based">{t('standardVdPresetWeightBased')}</SelectItem>
</SelectContent>
</Select>
{pkParams.advanced.weightBasedVd.enabled && (
{pkParams.advanced.standardVd?.preset === 'weight-based' && (
<div className="ml-0 mt-2 p-2 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded text-xs text-blue-800 dark:text-blue-200">
Weight-based Vd is enabled below. This setting is currently overridden.
{t('weightBasedVdInfo')}
</div>
)}
{pkParams.advanced.standardVd?.preset === 'custom' && (
<div className="ml-8 mt-2">
<div className="mt-2">
<Label className="text-sm font-medium">{t('customVdValue')}</Label>
<FormNumericInput
value={pkParams.advanced.standardVd?.customValue || '377'}
@@ -857,45 +858,8 @@ const Settings = ({
/>
</div>
)}
</div>
<Separator className="my-4" />
{/* Weight-Based Vd */}
<div className="space-y-3">
{pkParams.advanced.weightBasedVd.enabled && (
<div className="p-2 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded text-xs text-blue-800 dark:text-blue-200 mb-3">
When enabled, this overrides the Standard Vd setting above. Disable to use Standard Vd presets (Adult/Child/Custom).
</div>
)}
<div className="flex items-center gap-3">
<Switch
id="weightBasedVdEnabled"
checked={pkParams.advanced.weightBasedVd.enabled}
onCheckedChange={checked => updateAdvanced('weightBasedVd', 'enabled', checked)}
/>
<Label htmlFor="weightBasedVdEnabled" className="font-medium">
{t('weightBasedVdScaling')}
</Label>
<Tooltip open={openTooltipId === 'weightBasedVd'} onOpenChange={(open) => setOpenTooltipId(open ? 'weightBasedVd' : null)}>
<TooltipTrigger asChild>
<button
type="button"
onClick={handleTooltipToggle('weightBasedVd')}
onTouchStart={handleTooltipToggle('weightBasedVd')}
className="inline-flex items-center justify-center rounded-sm text-muted-foreground hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2"
aria-label={t('weightBasedVdTooltip')}
>
<Info className="h-4 w-4" />
</button>
</TooltipTrigger>
<TooltipContent side={tooltipSide}>
<p className="text-xs max-w-xs">{tWithDefaults(t, 'weightBasedVdTooltip', defaultsForT)}</p>
</TooltipContent>
</Tooltip>
</div>
{pkParams.advanced.weightBasedVd.enabled && (
<div className="ml-8 space-y-2">
{pkParams.advanced.standardVd?.preset === 'weight-based' && (
<div className="mt-2">
<div className="flex items-center gap-2">
<Label className="text-sm font-medium">{t('bodyWeight')}</Label>
<Tooltip open={openTooltipId === 'bodyWeight'} onOpenChange={(open) => setOpenTooltipId(open ? 'bodyWeight' : null)}>
@@ -916,8 +880,8 @@ const Settings = ({
</Tooltip>
</div>
<FormNumericInput
value={pkParams.advanced.weightBasedVd.bodyWeight}
onChange={val => updateAdvanced('weightBasedVd', 'bodyWeight', val)}
value={pkParams.advanced.standardVd?.bodyWeight || '70'}
onChange={val => updateAdvanced('standardVd', 'bodyWeight', val)}
increment={1}
min={20}
max={300}
@@ -930,8 +894,6 @@ const Settings = ({
<Separator className="my-4" />
<Separator className="my-4" />
{/* Food Effect Absorption Delay */}
<div className="space-y-3">
<div className="flex items-center gap-2">
@@ -1084,7 +1046,7 @@ const Settings = ({
</Tooltip>
</div>
{(pkParams.advanced.renalFunction?.enabled) && (
<div className="ml-8 space-y-2">
<div className="space-y-2">
<div className="flex items-center gap-2">
<Label className="text-sm font-medium">{t('renalFunctionSeverity')}</Label>
</div>

View File

@@ -39,8 +39,7 @@ 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
standardVd: { preset: 'adult' | 'child' | 'custom' | 'weight-based'; customValue: string; bodyWeight: string }; // Volume of distribution (L)
foodEffect: { enabled: boolean; tmaxDelay: string }; // hours
urinePh: { mode: 'normal' | 'acidic' | 'alkaline' }; // pH effect on elimination
fOral: string; // bioavailability fraction
@@ -138,8 +137,7 @@ export const getDefaultState = (): AppState => ({
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
standardVd: { preset: 'adult', customValue: '377', bodyWeight: '70' }, // Adult: 377L (Roberts 2015), Child: ~150-200L, Weight-based: ~5.4 L/kg
foodEffect: { enabled: false, tmaxDelay: '1.0' }, // hours delay
urinePh: { mode: 'normal' }, // 'normal' (6-7.5), 'acidic' (<6), 'alkaline' (>7.5)
fOral: String(DEFAULT_F_ORAL), // 0.96 bioavailability

View File

@@ -52,6 +52,38 @@ export const useAppState = () => {
}
}
}
// Migrate weightBasedVd from old {enabled, bodyWeight} to new standardVd structure
const oldWeightBasedVd = (migratedPkParams.advanced as any).weightBasedVd;
if (oldWeightBasedVd && typeof oldWeightBasedVd === 'object' && 'enabled' in oldWeightBasedVd) {
// Old format detected: {enabled: boolean, bodyWeight: string}
if (oldWeightBasedVd.enabled) {
// Convert to new weight-based preset
migratedPkParams.advanced.standardVd = {
preset: 'weight-based',
customValue: migratedPkParams.advanced.standardVd?.customValue || '377',
bodyWeight: oldWeightBasedVd.bodyWeight || '70'
};
} else {
// Keep existing standardVd, but ensure bodyWeight is present
if (!migratedPkParams.advanced.standardVd?.bodyWeight) {
migratedPkParams.advanced.standardVd = {
...migratedPkParams.advanced.standardVd,
bodyWeight: oldWeightBasedVd.bodyWeight || '70'
};
}
}
// Remove old weightBasedVd property
delete (migratedPkParams.advanced as any).weightBasedVd;
}
// Ensure bodyWeight exists in standardVd (for new installations or old formats)
if (!migratedPkParams.advanced.standardVd?.bodyWeight) {
migratedPkParams.advanced.standardVd = {
...migratedPkParams.advanced.standardVd,
bodyWeight: '70'
};
}
}
// Validate numeric fields and replace empty/invalid values with defaults

View File

@@ -79,11 +79,13 @@ export const de = {
advancedSettings: "Erweiterte Einstellungen",
advancedSettingsWarning: "⚠️ Diese Parameter beeinflussen die Simulationsgenauigkeit und können von Bevölkerungsdurchschnitten abweichen. Nur anpassen, wenn spezifische klinische Daten oder Forschungsreferenzen vorliegen.",
standardVolumeOfDistribution: "Verteilungsvolumen (Vd)",
standardVdTooltip: "Definiert wie sich der Wirkstoff im Körper verteilt. Erwachsene: 377L (Roberts 2015), Kinder: ~150-200L. Beeinflusst alle Konzentrationsberechnungen. Nur für pädiatrische oder spezialisierte Simulationen ändern. Standard: {{standardVdValue}}L ({{standardVdPreset}}).",
standardVdTooltip: "Definiert wie sich der Wirkstoff im Körper verteilt. Erwachsene: 377L (Roberts 2015), Kinder: ~150-200L. Gewichtsbasierte Skalierung: ~5,4 L/kg (für Erwachsene >18 Jahre basierend auf [Populations-Pharmakokinetik](https://pmc.ncbi.nlm.nih.gov/articles/PMC5572767/)). Beeinflusst alle Konzentrationsberechnungen. Nur für pädiatrische oder spezialisierte Simulationen ändern. Standard: {{standardVdValue}}L ({{standardVdPreset}}).",
standardVdPresetAdult: "Erwachsene (377L)",
standardVdPresetChild: "Kinder (175L)",
standardVdPresetCustom: "Benutzerdefiniert",
standardVdPresetWeightBased: "Gewichtsbasiert (~5,4 L/kg)",
customVdValue: "Benutzerdefiniertes Vd (L)",
weightBasedVdInfo: "Gewichtsbasiertes Vd passt Plasmakonzentrationen basierend auf Körpergewicht an (~5,4 L/kg). Leichtere Personen → höhere Spitzen, schwerere → niedrigere Spitzen. Diese Option ist für Erwachsene (>18 Jahre) basierend auf der Populations-PK-Studie vorgesehen. Für pädiatrische Patienten verwenden Sie die Voreinstellung 'Kinder'.",
xAxisTimeFormat: "Zeitformat",
xAxisFormatContinuous: "Fortlaufend",
xAxisFormatContinuousDesc: "Endlose Sequenz (0h, 6h, 12h...)",

View File

@@ -78,11 +78,13 @@ export const en = {
advancedSettings: "Advanced Settings",
advancedSettingsWarning: "⚠️ These parameters affect simulation accuracy and may deviate from population averages. Adjust only if you have specific clinical data or research references.",
standardVolumeOfDistribution: "Volume of Distribution (Vd)",
standardVdTooltip: "Defines how drug disperses in body. Adult: 377L (Roberts 2015), Child: ~150-200L. Affects all concentration calculations. Change only for pediatric or specialized simulations. Default: {{standardVdValue}}L ({{standardVdPreset}}).",
standardVdTooltip: "Defines how drug disperses in body. Adult: 377L (Roberts 2015), Child: ~150-200L. Weight-based scaling: ~5.4 L/kg (intended for adults >18 years based on [population PK analysis](https://pmc.ncbi.nlm.nih.gov/articles/PMC5572767/)). Affects all concentration calculations. Change only for pediatric or specialized simulations. Default: {{standardVdValue}}L ({{standardVdPreset}}).",
standardVdPresetAdult: "Adult (377L)",
standardVdPresetChild: "Child (175L)",
standardVdPresetCustom: "Custom",
standardVdPresetWeightBased: "Weight-Based (~5.4 L/kg)",
customVdValue: "Custom Vd (L)",
weightBasedVdInfo: "Weight-based Vd adjusts plasma concentrations based on body weight (~5.4 L/kg). Lighter persons → higher peaks, heavier → lower peaks. This option is intended for adults (>18 years) based on the population PK study. For pediatric patients, use the 'Child' preset.",
xAxisTimeFormat: "Time Format",
xAxisFormatContinuous: "Continuous",
xAxisFormatContinuousDesc: "Endless sequence (0h, 6h, 12h...)",

View File

@@ -242,7 +242,7 @@ export const validateImportData = (data: any): ImportValidationResult => {
// Validate advanced settings
if (importData.advancedSettings !== undefined) {
const validCategories = ['standardVd', 'weightBasedVd', 'foodEffect', 'urinePh', 'fOral', 'steadyStateDays', 'ageGroup', 'renalFunction'];
const validCategories = ['standardVd', 'foodEffect', 'urinePh', 'fOral', 'steadyStateDays', 'ageGroup', 'renalFunction'];
const importedCategories = Object.keys(importData.advancedSettings);
const unknownCategories = importedCategories.filter(c => !validCategories.includes(c));
if (unknownCategories.length > 0) {

View File

@@ -186,13 +186,13 @@ export const calculateSingleDoseConcentration = (
}
}
// Weight-based Vd scaling (OVERRIDES preset if enabled)
// Weight-based Vd scaling (selected as 'weight-based' preset)
// Research Section 8.1: Vd_damph ≈ 5.4 L/kg body weight
// Lighter person → smaller Vd → higher concentration
// Heavier person → larger Vd → lower concentration
let effectiveVd_damph = baseVd_damph;
if (pkParams.advanced.weightBasedVd.enabled) {
const bodyWeight = parseFloat(pkParams.advanced.weightBasedVd.bodyWeight);
if (pkParams.advanced.standardVd && pkParams.advanced.standardVd.preset === 'weight-based') {
const bodyWeight = parseFloat(pkParams.advanced.standardVd.bodyWeight);
if (!isNaN(bodyWeight) && bodyWeight > 0) {
effectiveVd_damph = bodyWeight * 5.4; // L/kg factor from literature
}