diff --git a/frontend/js/chartManager.js b/frontend/js/chartManager.js index c595d0d..68de37b 100644 --- a/frontend/js/chartManager.js +++ b/frontend/js/chartManager.js @@ -30,19 +30,17 @@ export function updateChartAnnotations(chart, mode, currentYMax) { } export function adjustChartYScale(chart, mode, datasets) { - const defaultMax = CLINICAL_THRESHOLDS[mode].maxScale; let highestValue = 0; + // Recherche de la valeur maximale atteinte parmi tous les modèles affichés datasets.forEach(ds => { ds.data.forEach(val => { if (val > highestValue) highestValue = val; }); }); - let targetYMax = defaultMax; - if (highestValue > defaultMax) { - targetYMax = Math.ceil(highestValue * 1.1); - } + // Ajustement dynamique à 110 % de la valeur pic (ou plancher à 50 ng/mL si vide) + let targetYMax = highestValue > 0 ? Math.ceil(highestValue * 1.1) : 50; chart.options.scales.y.max = targetYMax; updateChartAnnotations(chart, mode, targetYMax); diff --git a/frontend/js/pkCore.js b/frontend/js/pkCore.js index 7745d3d..141db72 100644 --- a/frontend/js/pkCore.js +++ b/frontend/js/pkCore.js @@ -94,24 +94,24 @@ export function calculate5MinInfusionDose(rate, unit, weight) { } /** - * Calcul d'un bolus unique à l'instant t + * Calcul d'un bolus unique à l'instant t avec prise en compte de refDose */ export function calculateBolusCp(model, doseMg, weightKg, timeElapsedMin) { - if (timeElapsedMin < 0 || weightKg <= 0) return 0; + if (timeElapsedMin < 0 || weightKg <= 0 || !model.refDose) return 0; const dosePerKg = doseMg / weightKg; - const { A, alpha, B, beta, C, gamma } = model; + const { A, alpha, B, beta, C, gamma, refDose } = model; const termA = A * Math.exp(-alpha * timeElapsedMin); const termB = B * Math.exp(-beta * timeElapsedMin); const termC = C * (gamma ? Math.exp(-gamma * timeElapsedMin) : 0); - return dosePerKg * (termA + termB + termC); + // Division par refDose pour respecter la formule exacte de l'Excel + return (dosePerKg / refDose) * (termA + termB + termC); } /** * Propage la perfusion active sur la timeline (pas de 5 min) - * Indique si chaque pas de temps possède une consigne explicite (isExplicit) ou héritée. */ export function processTimelineEvents(timelineInputs, weightKg, infusionUnit) { let currentRate = 0;