mirror of
https://github.com/gauvainboiche/ketapk.git
synced 2026-09-02 11:13:11 +02:00
fix: Fixing dose calculus + small display changes
This commit is contained in:
@@ -30,19 +30,17 @@ export function updateChartAnnotations(chart, mode, currentYMax) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function adjustChartYScale(chart, mode, datasets) {
|
export function adjustChartYScale(chart, mode, datasets) {
|
||||||
const defaultMax = CLINICAL_THRESHOLDS[mode].maxScale;
|
|
||||||
let highestValue = 0;
|
let highestValue = 0;
|
||||||
|
|
||||||
|
// Recherche de la valeur maximale atteinte parmi tous les modèles affichés
|
||||||
datasets.forEach(ds => {
|
datasets.forEach(ds => {
|
||||||
ds.data.forEach(val => {
|
ds.data.forEach(val => {
|
||||||
if (val > highestValue) highestValue = val;
|
if (val > highestValue) highestValue = val;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
let targetYMax = defaultMax;
|
// Ajustement dynamique à 110 % de la valeur pic (ou plancher à 50 ng/mL si vide)
|
||||||
if (highestValue > defaultMax) {
|
let targetYMax = highestValue > 0 ? Math.ceil(highestValue * 1.1) : 50;
|
||||||
targetYMax = Math.ceil(highestValue * 1.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
chart.options.scales.y.max = targetYMax;
|
chart.options.scales.y.max = targetYMax;
|
||||||
updateChartAnnotations(chart, mode, targetYMax);
|
updateChartAnnotations(chart, mode, targetYMax);
|
||||||
|
|||||||
@@ -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) {
|
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 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 termA = A * Math.exp(-alpha * timeElapsedMin);
|
||||||
const termB = B * Math.exp(-beta * timeElapsedMin);
|
const termB = B * Math.exp(-beta * timeElapsedMin);
|
||||||
const termC = C * (gamma ? Math.exp(-gamma * timeElapsedMin) : 0);
|
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)
|
* 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) {
|
export function processTimelineEvents(timelineInputs, weightKg, infusionUnit) {
|
||||||
let currentRate = 0;
|
let currentRate = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user