mirror of
https://github.com/gauvainboiche/ketapk.git
synced 2026-09-02 11:13:11 +02:00
fix: Docker deployment
This commit is contained in:
+28
-26
@@ -1,10 +1,11 @@
|
||||
import { MODES, PK_MODELS, CLINICAL_THRESHOLDS, generateSimulationData } from '../../pkCore.js';
|
||||
import { adjustChartYScale } from './chartManager.js';
|
||||
import { initCalculatorUI } from './calculator.js';
|
||||
import { generatePDFReport } from './pdfExport.js';
|
||||
|
||||
let currentMode = MODES.ESKETAMINE;
|
||||
let pkChart = null;
|
||||
|
||||
// Initialisation de la Grille Saisie (61 intervalles de 5 min)
|
||||
const timelineInputs = Array.from({ length: 61 }, (_, i) => ({
|
||||
time: i * 5,
|
||||
bolusMg: 0,
|
||||
@@ -14,13 +15,14 @@ const timelineInputs = Array.from({ length: 61 }, (_, i) => ({
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
initChart();
|
||||
renderTimelineGrid();
|
||||
initCalculatorUI(); // Initialise la modale et les événements du calculateur
|
||||
setupEventListeners();
|
||||
updateSimulation();
|
||||
});
|
||||
|
||||
function initChart() {
|
||||
const ctx = document.getElementById('pkChart').getContext('2d');
|
||||
|
||||
|
||||
pkChart = new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: {
|
||||
@@ -35,15 +37,16 @@ function initChart() {
|
||||
beginAtZero: true,
|
||||
max: CLINICAL_THRESHOLDS[currentMode].maxScale,
|
||||
title: { display: true, text: 'Cp (ng/mL)', color: '#94a3b8' },
|
||||
grid: { color: 'rgba(51, 65, 85, 0.3)' }
|
||||
grid: { color: 'rgba(51, 65, 85, 0.4)' }
|
||||
},
|
||||
x: {
|
||||
title: { display: true, text: 'Temps (minutes)', color: '#94a3b8' },
|
||||
grid: { color: 'rgba(51, 65, 85, 0.3)' }
|
||||
grid: { color: 'rgba(51, 65, 85, 0.4)' }
|
||||
}
|
||||
},
|
||||
plugins: {
|
||||
legend: { labels: { color: '#f8fafc' } }
|
||||
legend: { labels: { color: '#f8fafc' } },
|
||||
annotation: { annotations: {} }
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -51,7 +54,6 @@ function initChart() {
|
||||
|
||||
function updateSimulation() {
|
||||
const weight = parseFloat(document.getElementById('inputWeight').value) || 70;
|
||||
|
||||
const datasets = [];
|
||||
|
||||
if (document.getElementById('chkDomino').checked) {
|
||||
@@ -85,7 +87,10 @@ function updateSimulation() {
|
||||
}
|
||||
|
||||
pkChart.data.datasets = datasets;
|
||||
pkChart.options.scales.y.max = CLINICAL_THRESHOLDS[currentMode].maxScale;
|
||||
|
||||
// Ajustement dynamique de l'échelle Y à 110 % si besoin
|
||||
adjustChartYScale(pkChart, currentMode, datasets);
|
||||
|
||||
pkChart.update();
|
||||
}
|
||||
|
||||
@@ -95,16 +100,16 @@ function renderTimelineGrid() {
|
||||
|
||||
timelineInputs.forEach((item, idx) => {
|
||||
const col = document.createElement('div');
|
||||
col.className = 'flex-1 bg-slate-900 border border-slate-700/60 rounded-xl p-2 text-center text-xs flex flex-col gap-1.5';
|
||||
col.className = 'flex-1 bg-slate-900 border border-slate-700/60 rounded-xl p-2 text-center text-xs flex flex-col gap-1.5 min-w-[85px]';
|
||||
col.innerHTML = `
|
||||
<div class="font-bold text-amber-400 border-b border-slate-800 pb-1">${item.time} min</div>
|
||||
<div>
|
||||
<span class="text-[10px] text-slate-500 block">Bolus (mg)</span>
|
||||
<input type="number" data-idx="${idx}" data-field="bolusMg" value="${item.bolusMg || ''}" placeholder="0" class="w-full bg-slate-800 border border-slate-700 text-center rounded text-white py-1 outline-none">
|
||||
<span class="text-[10px] text-slate-400 block mb-0.5">Bolus (mg)</span>
|
||||
<input type="number" data-idx="${idx}" data-field="bolusMg" value="${item.bolusMg || ''}" placeholder="0" class="w-full bg-slate-800 border border-slate-700 text-center rounded text-white py-1 outline-none focus:border-amber-500">
|
||||
</div>
|
||||
<div>
|
||||
<span class="text-[10px] text-slate-500 block">Perf (mg/kg/h)</span>
|
||||
<input type="number" data-idx="${idx}" data-field="perfRateMgKgH" value="${item.perfRateMgKgH || ''}" placeholder="0" class="w-full bg-slate-800 border border-slate-700 text-center rounded text-white py-1 outline-none">
|
||||
<span class="text-[10px] text-slate-400 block mb-0.5">Perf (mg/kg/h)</span>
|
||||
<input type="number" data-idx="${idx}" data-field="perfRateMgKgH" value="${item.perfRateMgKgH || ''}" placeholder="0" class="w-full bg-slate-800 border border-slate-700 text-center rounded text-white py-1 outline-none focus:border-amber-500">
|
||||
</div>
|
||||
`;
|
||||
container.appendChild(col);
|
||||
@@ -135,16 +140,13 @@ function setupEventListeners() {
|
||||
});
|
||||
|
||||
document.getElementById('btnExportPdf').addEventListener('click', () => {
|
||||
// On rassemble les données actuelles du formulaire
|
||||
const patientData = {
|
||||
weight: document.getElementById('inputWeight').value || 70,
|
||||
age: document.getElementById('inputAge').value || 50,
|
||||
height: document.getElementById('inputHeight').value || 170
|
||||
};
|
||||
|
||||
// On lance l'exportation (pkChart et currentMode sont des variables globales de app.js)
|
||||
generatePDFReport(pkChart, patientData, currentMode);
|
||||
});
|
||||
const patientData = {
|
||||
weight: document.getElementById('inputWeight').value || 70,
|
||||
age: document.getElementById('inputAge').value || 50,
|
||||
height: document.getElementById('inputHeight').value || 170
|
||||
};
|
||||
generatePDFReport(pkChart, patientData, currentMode);
|
||||
});
|
||||
}
|
||||
|
||||
function setMode(mode) {
|
||||
@@ -154,12 +156,12 @@ function setMode(mode) {
|
||||
const concInput = document.getElementById('inputConc');
|
||||
|
||||
if (mode === MODES.ESKETAMINE) {
|
||||
btnEsk.className = 'px-4 py-1.5 rounded-lg text-sm font-semibold bg-amber-500 text-slate-950 shadow';
|
||||
btnRac.className = 'px-4 py-1.5 rounded-lg text-sm font-semibold text-slate-300 hover:text-white';
|
||||
btnEsk.className = 'px-4 py-1.5 rounded-lg text-xs font-bold bg-amber-500 text-slate-950 shadow-md shadow-amber-500/30';
|
||||
btnRac.className = 'px-4 py-1.5 rounded-lg text-xs font-bold text-slate-400 hover:text-slate-200';
|
||||
concInput.value = CLINICAL_THRESHOLDS[MODES.ESKETAMINE].defaultConcentration;
|
||||
} else {
|
||||
btnRac.className = 'px-4 py-1.5 rounded-lg text-sm font-semibold bg-fuchsia-500 text-slate-950 shadow';
|
||||
btnEsk.className = 'px-4 py-1.5 rounded-lg text-sm font-semibold text-slate-300 hover:text-white';
|
||||
btnRac.className = 'px-4 py-1.5 rounded-lg text-xs font-bold bg-fuchsia-500 text-slate-950 shadow-md shadow-fuchsia-500/30';
|
||||
btnEsk.className = 'px-4 py-1.5 rounded-lg text-xs font-bold text-slate-400 hover:text-slate-200';
|
||||
concInput.value = CLINICAL_THRESHOLDS[MODES.RACEMIQUE].defaultConcentration;
|
||||
}
|
||||
updateSimulation();
|
||||
|
||||
Reference in New Issue
Block a user