Fix pharmaco. value handling and vaildations
This commit is contained in:
@@ -193,7 +193,7 @@ const Settings = ({
|
|||||||
<Label className="font-medium">{t('halfLife')}</Label>
|
<Label className="font-medium">{t('halfLife')}</Label>
|
||||||
<FormNumericInput
|
<FormNumericInput
|
||||||
value={pkParams.damph.halfLife}
|
value={pkParams.damph.halfLife}
|
||||||
onChange={val => onUpdatePkParams('damph', { halfLife: val })}
|
onChange={val => onUpdatePkParams('damph', { ...pkParams.damph, halfLife: val })}
|
||||||
increment={0.5}
|
increment={0.5}
|
||||||
min={0.1}
|
min={0.1}
|
||||||
unit="h"
|
unit="h"
|
||||||
@@ -209,7 +209,7 @@ const Settings = ({
|
|||||||
<Label className="font-medium">{t('conversionHalfLife')}</Label>
|
<Label className="font-medium">{t('conversionHalfLife')}</Label>
|
||||||
<FormNumericInput
|
<FormNumericInput
|
||||||
value={pkParams.ldx.halfLife}
|
value={pkParams.ldx.halfLife}
|
||||||
onChange={val => onUpdatePkParams('ldx', { halfLife: val })}
|
onChange={val => onUpdatePkParams('ldx', { ...pkParams.ldx, halfLife: val })}
|
||||||
increment={0.1}
|
increment={0.1}
|
||||||
min={0.1}
|
min={0.1}
|
||||||
unit="h"
|
unit="h"
|
||||||
@@ -222,7 +222,7 @@ const Settings = ({
|
|||||||
<Label className="font-medium">{t('absorptionRate')}</Label>
|
<Label className="font-medium">{t('absorptionRate')}</Label>
|
||||||
<FormNumericInput
|
<FormNumericInput
|
||||||
value={pkParams.ldx.absorptionRate}
|
value={pkParams.ldx.absorptionRate}
|
||||||
onChange={val => onUpdatePkParams('ldx', { absorptionRate: val })}
|
onChange={val => onUpdatePkParams('ldx', { ...pkParams.ldx, absorptionRate: val })}
|
||||||
increment={0.1}
|
increment={0.1}
|
||||||
min={0.1}
|
min={0.1}
|
||||||
unit={t('faster')}
|
unit={t('faster')}
|
||||||
|
|||||||
@@ -100,6 +100,11 @@ export const de = {
|
|||||||
errorTimeRequired: "Bitte gib eine gültige Zeitangabe ein.",
|
errorTimeRequired: "Bitte gib eine gültige Zeitangabe ein.",
|
||||||
warningDuplicateTime: "Mehrere Dosen zur gleichen Zeit.",
|
warningDuplicateTime: "Mehrere Dosen zur gleichen Zeit.",
|
||||||
warningZeroDose: "Nulldosis hat keine Auswirkung auf die Simulation.",
|
warningZeroDose: "Nulldosis hat keine Auswirkung auf die Simulation.",
|
||||||
|
halfLifeRequired: "Halbwertszeit ist erforderlich.",
|
||||||
|
conversionHalfLifeRequired: "Umwandlungs-Halbwertszeit ist erforderlich.",
|
||||||
|
absorptionRateRequired: "Absorptionsrate ist erforderlich.",
|
||||||
|
therapeuticRangeMinRequired: "Minimaler therapeutischer Bereich ist erforderlich.",
|
||||||
|
therapeuticRangeMaxRequired: "Maximaler therapeutischer Bereich ist erforderlich.",
|
||||||
|
|
||||||
// Day-based schedule
|
// Day-based schedule
|
||||||
regularPlan: "Regulärer Plan",
|
regularPlan: "Regulärer Plan",
|
||||||
|
|||||||
@@ -99,6 +99,11 @@ export const en = {
|
|||||||
errorTimeRequired: "Please enter a valid time.",
|
errorTimeRequired: "Please enter a valid time.",
|
||||||
warningDuplicateTime: "Multiple doses at same time.",
|
warningDuplicateTime: "Multiple doses at same time.",
|
||||||
warningZeroDose: "Zero dose has no effect on simulation.",
|
warningZeroDose: "Zero dose has no effect on simulation.",
|
||||||
|
halfLifeRequired: "Half-life is required.",
|
||||||
|
conversionHalfLifeRequired: "Conversion half-life is required.",
|
||||||
|
absorptionRateRequired: "Absorption rate is required.",
|
||||||
|
therapeuticRangeMinRequired: "Minimum therapeutic range is required.",
|
||||||
|
therapeuticRangeMaxRequired: "Maximum therapeutic range is required.",
|
||||||
|
|
||||||
// Time picker
|
// Time picker
|
||||||
timePickerHour: "Hour",
|
timePickerHour: "Hour",
|
||||||
|
|||||||
@@ -25,9 +25,20 @@ export const calculateSingleDoseConcentration = (
|
|||||||
const numDose = parseFloat(dose) || 0;
|
const numDose = parseFloat(dose) || 0;
|
||||||
if (timeSinceDoseHours < 0 || numDose <= 0) return { ldx: 0, damph: 0 };
|
if (timeSinceDoseHours < 0 || numDose <= 0) return { ldx: 0, damph: 0 };
|
||||||
|
|
||||||
const ka_ldx = Math.log(2) / (parseFloat(pkParams.ldx.absorptionRate) || 1);
|
const absorptionRate = parseFloat(pkParams.ldx.absorptionRate);
|
||||||
const k_conv = Math.log(2) / (parseFloat(pkParams.ldx.halfLife) || 1);
|
const conversionHalfLife = parseFloat(pkParams.ldx.halfLife);
|
||||||
const ke_damph = Math.log(2) / (parseFloat(pkParams.damph.halfLife) || 1);
|
const damphHalfLife = parseFloat(pkParams.damph.halfLife);
|
||||||
|
|
||||||
|
// Validate parameters to avoid division by zero or invalid calculations
|
||||||
|
if (isNaN(absorptionRate) || absorptionRate <= 0 ||
|
||||||
|
isNaN(conversionHalfLife) || conversionHalfLife <= 0 ||
|
||||||
|
isNaN(damphHalfLife) || damphHalfLife <= 0) {
|
||||||
|
return { ldx: 0, damph: 0 };
|
||||||
|
}
|
||||||
|
|
||||||
|
const ka_ldx = Math.log(2) / absorptionRate;
|
||||||
|
const k_conv = Math.log(2) / conversionHalfLife;
|
||||||
|
const ke_damph = Math.log(2) / damphHalfLife;
|
||||||
|
|
||||||
let ldxConcentration = 0;
|
let ldxConcentration = 0;
|
||||||
if (Math.abs(ka_ldx - k_conv) > 0.0001) {
|
if (Math.abs(ka_ldx - k_conv) > 0.0001) {
|
||||||
|
|||||||
Reference in New Issue
Block a user