Questa è una vecchia versione del documento!
<!DOCTYPE html>
<html lang=“it”>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Programma NPT Neonatale v3.0 - Versione Unificata</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
background-color: #f5f5f5;
}
.container {
max-width: 1200px;
margin: 0 auto;
background: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
h1 {
text-align: center;
color: #2c3e50;
border-bottom: 3px solid #3498db;
padding-bottom: 10px;
}
.version-info {
text-align: center;
font-size: 12px;
color: #7f8c8d;
margin-bottom: 20px;
}
.section {
margin: 20px 0;
padding: 15px;
border: 1px solid #ddd;
border-radius: 5px;
background-color: #f9f9f9;
}
.section h2 {
color: #34495e;
margin-top: 0;
border-bottom: 2px solid #3498db;
padding-bottom: 5px;
}
.input-group {
margin: 10px 0;
display: flex;
align-items: center;
}
.input-group label {
display: inline-block;
width: 220px;
font-weight: bold;
color: #2c3e50;
}
.input-group input, .input-group select {
padding: 8px;
border: 1px solid #ddd;
border-radius: 4px;
width: 150px;
font-size: 14px;
}
.input-group input:focus, .input-group select:focus {
outline: none;
border-color: #3498db;
box-shadow: 0 0 5px rgba(52, 152, 219, 0.3);
}
.button {
background-color: #3498db;
color: white;
padding: 12px 24px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
margin: 10px 5px;
transition: background-color 0.3s;
}
.button:hover {
background-color: #2980b9;
}
.button.secondary {
background-color: #95a5a6;
}
.button.secondary:hover {
background-color: #7f8c8d;
}
.results {
margin-top: 20px;
padding: 15px;
background-color: #e8f6f3;
border-left: 4px solid #27ae60;
border-radius: 5px;
}
.results h3 {
color: #27ae60;
margin-top: 0;
}
.results-table {
width: 100%;
border-collapse: collapse;
margin: 10px 0;
}
.results-table th, .results-table td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}
.results-table th {
background-color: #3498db;
color: white;
}
.results-table tr:nth-child(even) {
background-color: #f2f2f2;
}
.warning {
background-color: #fff3cd;
color: #856404;
padding: 15px;
border-radius: 5px;
border-left: 4px solid #ffc107;
margin: 10px 0;
font-weight: bold;
}
.error {
background-color: #f8d7da;
color: #721c24;
padding: 10px;
border-radius: 5px;
border-left: 4px solid #dc3545;
margin: 10px 0;
}
.info {
background-color: #d1ecf1;
color: #0c5460;
padding: 10px;
border-radius: 5px;
border-left: 4px solid #17a2b8;
margin: 10px 0;
}
.phase-indicator {
display: inline-block;
padding: 5px 10px;
border-radius: 15px;
font-size: 12px;
font-weight: bold;
margin-left: 10px;
}
.phase-transizione {
background-color: #fff3cd;
color: #856404;
}
.phase-stabilizzazione {
background-color: #d1ecf1;
color: #0c5460;
}
.phase-crescita {
background-color: #d4edda;
color: #155724;
}
.nutrition-table {
width: 100%;
border-collapse: collapse;
margin: 15px 0;
font-size: 13px;
}
.nutrition-table th, .nutrition-table td {
border: 1px solid #ddd;
padding: 8px;
text-align: center;
}
.nutrition-table th {
background-color: #34495e;
color: white;
}
.day-column {
background-color: #ecf0f1;
font-weight: bold;
}
.day-column.energy-highlight {
background-color: #3498db !important;
color: white !important;
font-weight: bold;
}
.hidden {
display: none;
}
/* CSS TAB ORIZZONTALI CORRETTI */
.tabs {
display: flex;
margin-bottom: 20px;
border-bottom: 1px solid #ddd;
gap: 5px;
}
.tab {
padding: 10px 20px;
background-color: #ecf0f1;
border: 1px solid #ddd;
border-bottom: none;
cursor: pointer;
border-radius: 5px 5px 0 0;
transition: all 0.3s ease;
text-align: center;
min-width: 120px;
flex: 1;
max-width: 200px;
}
.tab:hover {
background-color: #d5dbdb;
}
.tab.active {
background-color: #3498db;
color: white;
border-color: #3498db;
border-bottom: 1px solid #3498db;
}
.tab-content {
display: none;
}
.tab-content.active {
display: block;
}
.form-row {
display: flex;
flex-wrap: wrap;
gap: 20px;
margin: 15px 0;
}
.form-col {
flex: 1;
min-width: 300px;
}
.highlight {
background-color: #e8f6f3;
font-weight: bold;
}
.energy-highlight {
background-color: #2c3e50 !important;
color: white !important;
font-weight: bold;
}
.load-defaults-pending {
background-color: #3498db;
}
.load-defaults-completed {
background-color: #27ae60 !important;
}
.calculate-nutrition-pending {
background-color: #e74c3c;
}
.calculate-nutrition-completed {
background-color: #27ae60 !important;
}
.calculate-phase-pending {
background-color: #e74c3c;
}
.config-update-pending {
background-color: #e74c3c !important;
color: white !important;
}
.config-update-completed {
background-color: #27ae60 !important;
color: white !important;
}
.config-table {
width: 100%;
border-collapse: collapse;
margin: 15px 0;
font-size: 12px;
}
.config-table th, .config-table td {
border: 1px solid #ddd;
padding: 6px;
text-align: center;
}
.config-table th {
background-color: #34495e;
color: white;
}
.config-table input {
width: 60px;
padding: 3px;
border: 1px solid #ddd;
border-radius: 3px;
}
.component-name {
font-weight: bold;
background-color: #f8f9fa;
text-align: left !important;
}
/* SEZIONE NUOVA PER TAB 5 CONFIGURAZIONE AVANZATA */
.config-advanced {
background-color: #f8f9fa;
border: 2px solid #17a2b8;
border-radius: 10px;
padding: 20px;
margin: 20px 0;
}
.config-advanced h3 {
color: #0c5460;
margin-top: 0;
border-bottom: 2px solid #17a2b8;
padding-bottom: 10px;
}
.monitoring-table {
width: 100%;
border-collapse: collapse;
margin: 15px 0;
font-size: 12px;
}
.monitoring-table th, .monitoring-table td {
border: 1px solid #17a2b8;
padding: 8px;
text-align: left;
}
.monitoring-table th {
background-color: #17a2b8;
color: white;
}
.alert-critical {
background-color: #721c24;
color: white;
padding: 15px;
border-radius: 5px;
margin: 15px 0;
font-weight: bold;
}
/* REPORT SECTION */
.report-output {
border: 2px solid #3498db;
border-radius: 10px;
padding: 30px;
margin-top: 30px;
background-color: white;
font-family: 'Times New Roman', serif;
line-height: 1.6;
}
.medical-header {
text-align: center;
border-bottom: 3px solid #2c3e50;
padding-bottom: 15px;
margin-bottom: 25px;
}
.medical-header h1 {
font-size: 24px;
color: #2c3e50;
margin: 5px 0;
}
.medical-header h2 {
font-size: 18px;
color: #34495e;
margin: 3px 0;
}
.medical-header p {
font-size: 14px;
color: #7f8c8d;
margin: 2px 0;
}
.no-print {
display: block;
}
@media print {
.no-print {
display: none !important;
}
body {
background: white;
}
.container {
box-shadow: none;
}
}
</style>
</head>
<body>
<h1>Programma NPT Neonatale v3.0 - Versione Unificata</h1>
<div class="version-info">
<strong>Versione:</strong> 3.0 UNIFIED | <strong>Data creazione:</strong> 02 Agosto 2025 | <strong>Ora:</strong> 20:00 | <strong>Sistema:</strong> NPT Calculator Advanced UNIFIED
</div>
<!-- TAB ORIZZONTALI CORRETTI -->
<div class="tabs">
<div class="tab active" onclick="showTab('patient-data')">
<span style="font-size: 18px;">1</span><br>Dati Paziente
</div>
<div class="tab" onclick="showTab('enteral')">
<span style="font-size: 18px;">2</span><br>Nutrizione Enterale
</div>
<div class="tab" onclick="showTab('nutrition-calc')">
<span style="font-size: 18px;">3</span><br>Calcolo Fabbisogni
</div>
<div class="tab" onclick="showTab('parenteral')">
<span style="font-size: 18px;">4</span><br>Nutrizione Parenterale
</div>
<div class="tab" onclick="showTab('config')">
<span style="font-size: 18px;">5</span><br>Configurazione
</div>
<div class="tab" onclick="showTab('report')">
<span style="font-size: 18px;">6</span><br>Report Finale
</div>
</div>
<!-- TAB 1: DATI PAZIENTE (VERSIONE 17 ORIGINALE) -->
<div id="patient-data" class="tab-content active">
<div class="info">
<strong>PASSO 1 - DATI PAZIENTE</strong><br>
<strong>Obiettivo:</strong> Inserire i dati antropometrici ed ematochimici del neonato
</div>
<div class="section">
<h2>Dati Prescrizione</h2>
<div class="form-row">
<div class="form-col">
<div class="input-group">
<label for="prescriptionDate">Data di prescrizione:</label>
<input type="date" id="prescriptionDate" style="width: 180px;">
</div>
<div class="input-group">
<label for="prescribingDoctor">Medico prescrittore:</label>
<select id="prescribingDoctor" style="width: 200px;">
<!-- Popolato dinamicamente -->
</select>
</div>
</div>
<div class="form-col">
<div class="info" style="margin-top: 0; font-size: 13px;">
<strong>Info Prescrizione:</strong><br>
• La data viene impostata automaticamente ad oggi<br>
• Selezionare il medico responsabile della prescrizione<br>
• Questi dati appariranno nel riepilogo finale
</div>
</div>
</div>
</div>
<div class="section">
<h2>Dati Paziente</h2>
<div class="form-row">
<div class="form-col">
<div class="input-group">
<label for="medicalRecord">N° Cartella Clinica:</label>
<input type="text" id="medicalRecord" maxlength="10" placeholder="2025000001" style="width: 120px; font-family: monospace;">
</div>
<div class="input-group">
<label for="birthWeight">Peso alla nascita (g):</label>
<input type="number" id="birthWeight" min="400" max="5000" value="1000">
</div>
<div class="input-group">
<label for="currentWeight">Peso attuale (g):</label>
<input type="number" id="currentWeight" min="400" max="5000" value="1000">
</div>
<div class="input-group">
<label for="daysOfLife">Giorni di vita:</label>
<input type="number" id="daysOfLife" min="1" max="365" value="9">
</div>
</div>
<div class="form-col">
<div class="input-group">
<label for="bun">BUN - Azotemia (mg/dL):</label>
<input type="number" id="bun" min="5" max="100" step="1" placeholder="8-25 normale">
</div>
<div class="input-group">
<label for="glucose">Glicemia (mg/dL):</label>
<input type="number" id="glucose" min="40" max="400" step="1" placeholder="70-110 normale">
</div>
<div class="input-group">
<label for="sodium">Natremia (mEq/L):</label>
<input type="number" id="sodium" min="120" max="160" step="1" placeholder="135-145 normale">
</div>
<div class="input-group">
<label for="ph">pH ematico:</label>
<input type="number" id="ph" min="7.0" max="7.6" step="0.01" placeholder="7.35-7.45 normale">
</div>
<div class="input-group">
<label for="baseExcess">BE - Base Excess (mEq/L):</label>
<input type="number" id="baseExcess" min="-15" max="10" step="0.1" placeholder="-4 +2 normale">
</div>
<div class="input-group">
<label for="diuresis">Diuresi (mL/kg/die):</label>
<input type="number" id="diuresis" min="0" max="10" step="0.1" placeholder="1-3 normale">
</div>
<div class="info">
<strong>Range Normali:</strong><br>
<strong>BUN:</strong> 9-14 mg/dL<br>
<strong>Glicemia:</strong> 70-110 mg/dL<br>
<strong>Natremia:</strong> 135-145 mEq/L<br>
<strong>pH:</strong> 7.35-7.45<br>
<strong>BE:</strong> -4 a +2 mEq/L<br>
<strong>Diuresi:</strong> 1-3 mL/kg/die
</div>
</div>
</div>
<button id="calculatePhaseBtn" class="button calculate-phase-pending" onclick="calculatePhase()">CALCOLA FASE NUTRIZIONALE</button>
</div>
<div id="phaseResults" class="results hidden">
<h3>Fase Nutrizionale Attuale</h3>
<div id="phaseInfo"></div>
</div>
</div>
<!-- TAB 2: NUTRIZIONE ENTERALE (VERSIONE 17 ORIGINALE) -->
<div id="enteral" class="tab-content">
<div class="info">
<strong>PASSO 2 - NUTRIZIONE ENTERALE E LIQUIDI</strong><br>
<strong>Obiettivo:</strong> Calcolare i nutrienti e liquidi forniti dalla nutrizione enterale e altri apporti
</div>
<div class="section">
<h2>Altri Liquidi per Via Parenterale o Enterale</h2>
<div class="warning">
<strong>💧 LIQUIDI AGGIUNTIVI:</strong> Inserire qui liquidi diversi dal latte (soluzioni, farmaci, flebo)
</div>
<div class="form-row">
<div class="form-col">
<div class="input-group">
<label for="additionalFluids">Volume altri liquidi (ml/die):</label>
<input type="number" id="additionalFluids" min="0" max="500" value="0" step="5">
</div>
<div class="input-group">
<label for="fluidType">Tipo di liquido:</label>
<select id="fluidType">
<option value="saline">Soluzione fisiologica</option>
<option value="glucose5">Glucosio 5%</option>
<option value="glucose10">Glucosio 10%</option>
<option value="drugs">Farmaci in soluzione</option>
<option value="other">Altri liquidi</option>
</select>
</div>
</div>
<div class="form-col">
<div class="input-group">
<label for="fluidRoute">Via di somministrazione:</label>
<select id="fluidRoute">
<option value="iv">Endovenosa</option>
<option value="oral">Orale</option>
<option value="ng">Sonda nasogastrica</option>
</select>
</div>
<div class="info" style="margin-top: 10px; font-size: 12px;">
<strong>Esempi:</strong><br>
• Antibiotici in soluzione<br>
• Flebo di mantenimento<br>
• Soluzioni elettrolitiche
</div>
</div>
</div>
</div>
<div class="section">
<h2>Tipo di Latte e Volume</h2>
<div class="form-row">
<div class="form-col">
<div class="input-group">
<label for="formulaType">Tipo di latte:</label>
<select id="formulaType" onchange="updateFortifierOptions()">
<option value="none">Nessun apporto enterale</option>
<option value="maternal">Latte materno</option>
<option value="maternal_fortified">Latte materno + Prenidina FM85</option>
<option value="nan_supreme">Nestle NAN Supreme Pro 1</option>
<option value="humana1">Humana 1</option>
<option value="bbmilk_zero">BBmilk Zero</option>
<option value="bbmilk_pdf">BBmilk PDF</option>
<option value="prenan">Nestle PreNan POST</option>
<option value="alfare">Alfare</option>
<option value="infatrini">Infatrini</option>
</select>
</div>
<div class="input-group">
<label for="dailyVolume">Volume giornaliero (ml):</label>
<input type="number" id="dailyVolume" min="0" max="300" value="0">
</div>
</div>
<div class="form-col">
<div id="fortifierSection" class="hidden">
<h4>Fortificazione Aggiuntiva</h4>
<div class="input-group">
<label for="fortifierType">Tipo fortificante:</label>
<select id="fortifierType">
<option value="none">Nessun fortificante</option>
</select>
</div>
<div class="input-group">
<label for="fortifierConcentration">Concentrazione (%):</label>
<input type="range" id="fortifierConcentration" min="2" max="6" step="1" value="2" oninput="updateConcentrationDisplay()">
<span id="concentrationValue" style="margin-left: 10px; font-weight: bold;">2%</span>
</div>
</div>
</div>
</div>
<button id="calculateEnteralBtn" class="button calculate-nutrition-pending" onclick="calculateEnteral()">Calcola Apporti Enterali</button>
</div>
<div id="enteralResults" class="results hidden">
<h3>Apporti Nutrizionali da Nutrizione Enterale</h3>
<div id="enteralTable"></div>
</div>
</div>
<!-- TAB 3: CALCOLO FABBISOGNI (VERSIONE 17 ORIGINALE COMPLETA) -->
<div id="nutrition-calc" class="tab-content">
<div class="info">
<strong>PASSO 3 - DETERMINAZIONE FABBISOGNI</strong><br>
<strong>Obiettivo:</strong> Determinare i fabbisogni nutrizionali totali del neonato
</div>
<div class="section">
<h2>Determinazione Fabbisogni</h2>
<div class="form-row">
<div class="form-col">
<div class="input-group">
<label for="targetDay">Giornata di vita:</label>
<input type="number" id="targetDay" min="1" max="30" value="9" readonly style="background-color: #f0f0f0;">
</div>
<button id="loadDefaultsBtn" class="button load-defaults-pending" onclick="loadNutritionDefaults()">Carica Valori Standard</button>
</div>
<div class="form-col">
<div class="input-group">
<label for="weightCategory">Categoria peso:</label>
<select id="weightCategory" onchange="updateWeightCategory()">
<option value="">Seleziona categoria</option>
<option value="≤1500g">≤1500g (ELBW/VLBW)</option>
<option value=">1500g">>1500g (Peso normale)</option>
</select>
</div>
<button id="calculateNutritionBtn" class="button calculate-nutrition-pending" onclick="calculateNutrition()">CALCOLA FABBISOGNI</button>
</div>
</div>
<div class="form-row">
<div class="form-col">
<div class="input-group">
<label for="reqLiquids">Liquidi (ml/kg/die):</label>
<input type="number" id="reqLiquids" min="0" max="250" step="5" value="120">
</div>
<div class="input-group">
<label for="reqProtein">Proteine (g/kg/die):</label>
<input type="number" id="reqProtein" min="0" max="8" step="0.1" value="3.0">
</div>
<div class="input-group">
<label for="carbUnit">Unità glucidi:</label>
<select id="carbUnit" onchange="updateCarbUnit()">
<option value="g">g/kg/die</option>
<option value="mg">mg/kg/min</option>
</select>
</div>
<div class="input-group">
<label for="reqCarbs" id="carbLabel">Glucidi (g/kg/die):</label>
<input type="number" id="reqCarbs" min="0" max="20" step="0.1" value="6.0">
</div>
<div class="input-group">
<label for="reqLipids">Lipidi (g/kg/die):</label>
<input type="number" id="reqLipids" min="0" max="5" step="0.1" value="1.0">
</div>
</div>
<div class="form-col">
<div class="input-group">
<label for="reqCalcium">Calcio elementare (mg/kg/die):</label>
<input type="number" id="reqCalcium" min="0" max="200" step="5" value="0">
</div>
<div class="input-group">
<label for="reqPhosphorus">Fosforo (mg/kg/die):</label>
<input type="number" id="reqPhosphorus" min="0" max="100" step="2" value="0">
</div>
<div class="input-group">
<label for="reqMagnesium">Magnesio (mEq/kg/die):</label>
<input type="number" id="reqMagnesium" min="0" max="10" step="0.1" value="0">
</div>
<div class="input-group">
<label for="reqSodium">Sodio (mEq/kg/die):</label>
<input type="number" id="reqSodium" min="0" max="10" step="0.1" value="0">
</div>
<div class="input-group">
<label for="sodiumType">Tipo di sodio:</label>
<select id="sodiumType" onchange="updateSodiumChoice()">
<option value="nacl">Sodio Cloruro (NaCl)</option>
<option value="sodium_acetate">Sodio Acetato (alcalinizzante)</option>
</select>
</div>
<div id="sodiumRecommendation" class="hidden" style="margin-top: 5px;">
<!-- Popolato dinamicamente -->
</div>
<div class="input-group">
<label for="reqPotassium">Potassio (mEq/kg/die):</label>
<input type="number" id="reqPotassium" min="0" max="5" step="0.1" value="0">
</div>
</div>
</div>
<div class="form-row">
<div class="form-col">
<h4>Vitamine e Oligoelementi (dal 3° giorno)</h4>
<div class="input-group">
<label for="reqVitalipid">Vitalipid (ml/kg/die):</label>
<input type="number" id="reqVitalipid" min="0" max="10" step="0.5" value="0">
</div>
<div class="input-group">
<label for="reqSoluvit">Soluvit (ml/kg/die):</label>
<input type="number" id="reqSoluvit" min="0" max="5" step="0.5" value="0">
</div>
<div class="input-group">
<label for="reqPeditrace">Peditrace (ml/kg/die):</label>
<input type="number" id="reqPeditrace" min="0" max="10" step="0.5" value="0">
</div>
<div class="input-group">
<label for="reqCarnitine">Carnitina (mg/kg/die):</label>
<input type="number" id="reqCarnitine" min="0" max="20" step="1" value="0">
</div>
</div>
<div class="form-col">
<div class="info" style="margin-top: 0; font-size: 13px;">
<strong>Regole Vitamine/Oligoelementi:</strong><br>
<strong>• Dal 3° giorno:</strong> Vitalipid 4 ml/kg/die, Soluvit 1 ml/kg/die, Peditrace 1 ml/kg/die<br>
<strong>• Sospensione automatica:</strong> Se enterale ≥100 ml/kg/die<br>
<strong>• Modificabili manualmente:</strong> Campi editabili per personalizzazione<br><br>
<strong>Regole Carnitina:</strong><br>
<strong>• NPT > 1 mese:</strong> Carnitina 5 mg/kg/die<br>
<strong>• NPT < 1 mese:</strong> Non necessaria<br>
<strong>• Fonte:</strong> Carnitene (100 mg/ml)
</div>
</div>
</div>
</div>
<div id="nutritionResults" class="results hidden">
<h3>Fabbisogni Nutrizionali Totali vs Enterali</h3>
<div id="nutritionTable"></div>
</div>
</div>
<!-- TAB 4: NUTRIZIONE PARENTERALE (VERSIONE 17 ORIGINALE) -->
<div id="parenteral" class="tab-content">
<div class="info">
<strong>PASSO 4 - NUTRIZIONE PARENTERALE (FINALE)</strong><br>
<strong>Obiettivo:</strong> Definire la composizione della sacca NPT
</div>
<div class="section">
<h2>Composizione NPT Automatica</h2>
<div class="form-row">
<div class="form-col">
<div class="input-group">
<label for="calculatedTotalVolume">Volume totale (ml):</label>
<input type="text" id="calculatedTotalVolume" readonly style="background-color: #e8f6f3; font-weight: bold;" value="Premere 'Calcola NPT'">
</div>
<div class="input-group">
<label for="suggestedGlucose">Glucosio (%):</label>
<input type="text" id="suggestedGlucose" readonly style="background-color: #e8f6f3; font-weight: bold;" value="Premere 'Calcola NPT'">
</div>
</div>
<div class="form-col">
<div class="input-group">
<label for="calculatedProteinVol">Trophamine (ml):</label>
<input type="text" id="calculatedProteinVol" readonly style="background-color: #f0f0f0;" value="--">
</div>
<div class="input-group">
<label for="calculatedLipidVol">Intralipid (ml):</label>
<input type="text" id="calculatedLipidVol" readonly style="background-color: #f0f0f0;" value="--">
</div>
</div>
</div>
<button id="calculateParenteralBtn" class="button" onclick="calculateParenteral()">CALCOLA NPT AUTOMATICA</button>
</div>
<div id="parenteralResults" class="results hidden">
<h3>Prescrizione parenterale</h3>
<div id="parenteralTable"></div>
<h3 style="margin-top: 30px;">Ricetta per Preparazione (include volume deflussore)</h3>
<div id="preparationTable"></div>
<div style="margin-top: 20px;">
<button class="button" onclick="generatePDF('foglio_lavoro')">📄 Genera PDF - FOGLIO DI LAVORO</button>
<button class="button" onclick="generatePDF('report_parenterale')" style="margin-left: 10px;">📄 Genera PDF - REPORT PARENTERALE</button>
</div>
</div>
</div>
<!-- TAB 5: CONFIGURAZIONE (VERSIONE 17 + NOVITÀ TAB 5) -->
<div id="config" class="tab-content">
<div class="info">
<strong>CONFIGURAZIONE COMPLETA</strong><br>
<strong>Sistema:</strong> NPT Calculator v3.0 - Database completo componenti + configurazione clinica avanzata
</div>
<!-- SEZIONE CONFIGURAZIONE COMPONENTI (DA VERSIONE 17) -->
<div class="section">
<h2>Parametri Sistema</h2>
<div class="form-row">
<div class="form-col">
<div class="input-group">
<label for="deflectorVolume">Volume deflussore (ml):</label>
<input type="number" id="deflectorVolume" min="0" max="100" step="5" value="30" oninput="markConfigChanged('system')">
</div>
<div class="info" style="margin-top: 10px; font-size: 12px;">
<strong>Info Volume Deflussore:</strong><br>
• Volume perso nel deflussore durante la preparazione<br>
• Viene aggiunto automaticamente alla ricetta di preparazione<br>
• Valore standard: 30 ml (modificabile)
</div>
</div>
<div class="form-col">
<button id="updateSystemBtn" class="button" onclick="updateSystemConfig()">Aggiorna Parametri Sistema</button>
</div>
</div>
</div>
<div class="section">
<h2>Formule Enterali (Valori per 100ml)</h2>
<div style="overflow-x: auto;">
<table class="config-table">
<thead>
<tr>
<th style="min-width: 180px;">Formula</th>
<th>Proteine<br>(g)</th>
<th>Carboidrati<br>(g)</th>
<th>Lipidi<br>(g)</th>
<th>Sodio<br>(mEq)</th>
<th>Potassio<br>(mEq)</th>
<th>Calcio<br>(mg)</th>
<th>Fosforo<br>(mg)</th>
<th>Magnesio<br>(mg)</th>
<th>Energia<br>(kcal)</th>
<th>Azioni</th>
</tr>
</thead>
<tbody id="enteralConfigTable">
<!-- Popolato dinamicamente -->
</tbody>
</table>
</div>
<div class="form-row">
<div class="form-col">
<button id="updateEnteralBtn" class="button" onclick="updateEnteralConfig()">Aggiorna Formule Enterali</button>
</div>
<div class="form-col">
<button class="button secondary" onclick="showAddEnteralForm()">Aggiungi Nuova Formula</button>
</div>
</div>
</div>
<div class="section">
<h2>Fortificanti in Polvere (Valori per 100g)</h2>
<div style="overflow-x: auto;">
<table class="config-table">
<thead>
<tr>
<th style="min-width: 180px;">Fortificante</th>
<th>Proteine<br>(g)</th>
<th>Carboidrati<br>(g)</th>
<th>Lipidi<br>(g)</th>
<th>Sodio<br>(mEq)</th>
<th>Potassio<br>(mEq)</th>
<th>Calcio<br>(mg)</th>
<th>Fosforo<br>(mg)</th>
<th>Magnesio<br>(mg)</th>
<th>Energia<br>(kcal)</th>
<th style="min-width: 200px;">Note</th>
<th>Azioni</th>
</tr>
</thead>
<tbody id="fortifierConfigTable">
<tr>
<td class="component-name">Prenidina FM85</td>
<td><input type="number" id="fortifier_prenidina_fm85_protein" value="14" step="0.1" oninput="markConfigChanged('fortifier')"></td>
<td><input type="number" id="fortifier_prenidina_fm85_carbs" value="4" step="0.1" oninput="markConfigChanged('fortifier')"></td>
<td><input type="number" id="fortifier_prenidina_fm85_lipids" value="2.5" step="0.1" oninput="markConfigChanged('fortifier')"></td>
<td><input type="number" id="fortifier_prenidina_fm85_sodium" value="2" step="0.1" oninput="markConfigChanged('fortifier')"></td>
<td><input type="number" id="fortifier_prenidina_fm85_potassium" value="15" step="0.1" oninput="markConfigChanged('fortifier')"></td>
<td><input type="number" id="fortifier_prenidina_fm85_calcium" value="3500" step="1" oninput="markConfigChanged('fortifier')"></td>
<td><input type="number" id="fortifier_prenidina_fm85_phosphorus" value="2000" step="1" oninput="markConfigChanged('fortifier')"></td>
<td><input type="number" id="fortifier_prenidina_fm85_magnesium" value="150" step="1" oninput="markConfigChanged('fortifier')"></td>
<td><input type="number" id="fortifier_prenidina_fm85_energy" value="400" step="1" oninput="markConfigChanged('fortifier')"></td>
<td style="font-size: 11px; color: #7f8c8d;">Fortificante latte materno<br><em>Dose: 1-4g/100ml</em></td>
<td><button class="button secondary" onclick="removeFortifier('prenidina_fm85')" style="padding: 5px 10px; font-size: 12px;">Rimuovi</button></td>
</tr>
</tbody>
</table>
</div>
<div class="form-row">
<div class="form-col">
<button id="updateFortifierBtn" class="button" onclick="updateFortifierConfig()">Aggiorna Fortificanti</button>
</div>
<div class="form-col">
<button class="button secondary" onclick="showAddFortifierForm()">Aggiungi Nuovo Fortificante</button>
</div>
</div>
</div>
<div class="section">
<h2>Componenti Parenterali (Valori per 100ml)</h2>
<div style="overflow-x: auto;">
<table class="config-table">
<thead>
<tr>
<th style="min-width: 180px;">Componente</th>
<th>Proteine<br>(g)</th>
<th>Carboidrati<br>(g)</th>
<th>Lipidi<br>(g)</th>
<th>Sodio<br>(mEq)</th>
<th>Potassio<br>(mEq)</th>
<th>Calcio<br>(mg)</th>
<th>Fosforo<br>(mg)</th>
<th>Magnesio<br>(mEq)</th>
<th>Energia<br>(kcal)</th>
<th>Acqua<br>(ml)</th>
<th style="min-width: 200px;">Descrizione e Note</th>
<th>Azioni</th>
</tr>
</thead>
<tbody id="parenteralConfigTable">
<!-- Popolato dinamicamente -->
</tbody>
</table>
</div>
<div class="form-row">
<div class="form-col">
<button id="updateParenteralBtn" class="button" onclick="updateParenteralConfig()">Aggiorna Componenti Parenterali</button>
</div>
<div class="form-col">
<button class="button secondary" onclick="showAddParenteralForm()">Aggiungi Nuovo Componente</button>
</div>
</div>
</div>
<div class="section">
<h2>Lista Medici Prescrittori</h2>
<div class="info" style="margin-bottom: 15px;">
<strong>🩺 CONFIGURAZIONE MEDICI</strong><br>
Gestisci la lista dei medici prescrittori. Le modifiche si applicano automaticamente alla dropdown del TAB 1.
</div>
<div style="overflow-x: auto;">
<table class="config-table">
<thead>
<tr>
<th style="min-width: 120px;">Nome</th>
<th style="min-width: 120px;">Cognome</th>
<th style="min-width: 80px;">Titolo</th>
<th style="min-width: 250px;">Nome Completo (Visualizzato)</th>
<th>Azioni</th>
</tr>
</thead>
<tbody id="doctorsConfigTable">
<!-- Popolato dinamicamente -->
</tbody>
</table>
</div>
<div class="form-row">
<div class="form-col">
<button id="updateDoctorsBtn" class="button" onclick="updateDoctorsConfig()">Aggiorna Lista Medici</button>
</div>
<div class="form-col">
<button class="button secondary" onclick="showAddDoctorForm()">Aggiungi Nuovo Medico</button>
</div>
</div>
</div>
<!-- SEZIONE CONFIGURAZIONE CLINICA AVANZATA (NOVITÀ) -->
<div class="config-advanced">
<h3>🔬 CONFIGURAZIONE CLINICA AVANZATA</h3>
<div class="section">
<h2>Parametri Elettroliti e Controlli</h2>
<div class="form-row">
<div class="form-col">
<div class="input-group">
<label for="calciumReq">Calcio standard (mg/kg/die):</label>
<input type="number" id="calciumReq" min="0" max="200" value="160">
<span style="margin-left: 10px; font-size: 12px; color: #666;">Range: 120-200</span>
</div>
<div class="input-group">
<label for="phosphorusReq">Fosforo standard (mg/kg/die):</label>
<input type="number" id="phosphorusReq" min="0" max="100" value="84">
<span style="margin-left: 10px; font-size: 12px; color: #666;">Range: 60-120</span>
</div>
<div class="input-group">
<label for="magnesiumReq">Magnesio standard (mEq/kg/die):</label>
<input type="number" id="magnesiumReq" min="0" max="2" step="0.1" value="0.6">
<span style="margin-left: 10px; font-size: 12px; color: #666;">Range: 0.3-1.0</span>
</div>
</div>
<div class="form-col">
<div class="input-group">
<label for="maxGIR">GIR massimo (mg/kg/min):</label>
<input type="number" id="maxGIR" min="5" max="20" step="0.1" value="12.0">
<span style="margin-left: 10px; font-size: 12px; color: #666;">Limite sicurezza</span>
</div>
<div class="input-group">
<label for="maxLipids">Lipidi massimi (g/kg/die):</label>
<input type="number" id="maxLipids" min="1" max="4" step="0.1" value="3.0">
<span style="margin-left: 10px; font-size: 12px; color: #666;">Limite sicurezza</span>
</div>
<div class="input-group">
<label for="maxProtein">Proteine massime (g/kg/die):</label>
<input type="number" id="maxProtein" min="3" max="6" step="0.1" value="4.5">
<span style="margin-left: 10px; font-size: 12px; color: #666;">Limite sicurezza</span>
</div>
</div>
</div>
<button class="button" onclick="updateClinicalConfig()">AGGIORNA PARAMETRI CLINICI</button>
</div>
<div class="section">
<h2>Piano di Monitoraggio Automatico</h2>
<table class="monitoring-table">
<thead>
<tr>
<th>Controllo</th>
<th>Frequenza</th>
<th>Range Normale</th>
<th>Azione se Fuori Range</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Glicemia</strong></td>
<td>Ogni 6-8h</td>
<td>70-110 mg/dL</td>
<td>Aggiustare velocità glucosio</td>
</tr>
<tr>
<td><strong>Elettroliti</strong></td>
<td>Ogni 24-48h</td>
<td>Na: 135-145, K: 3.5-5.0</td>
<td>Modificare apporti NPT</td>
</tr>
<tr>
<td><strong>BUN/Creatinina</strong></td>
<td>Ogni 48h</td>
<td>BUN: 9-14 mg/dL</td>
<td>Aggiustare proteine</td>
</tr>
<tr>
<td><strong>Trigliceridi</strong></td>
<td>2 volte/settimana</td>
<td>< 150 mg/dL</td>
<td>Ridurre lipidi se > 200</td>
</tr>
<tr>
<td><strong>Funzione epatica</strong></td>
<td>Settimanale</td>
<td>AST/ALT normali</td>
<td>Valutare sospensione NPT</td>
</tr>
</tbody>
</table>
</div>
<div class="section">
<h2>⚠️ ALERT AUTOMATICI</h2>
<div class="alert-critical">
<strong>INTERRUZIONE IMMEDIATA NPT SE:</strong><br>
• Glicemia > 250 mg/dL o < 40 mg/dL<br>
• Trigliceridi > 400 mg/dL<br>
• AST/ALT > 3x valore normale<br>
• Segni di sepsi cateter-correlata<br>
• Edema importante con bilancio positivo > 20 ml/kg/die
</div>
<div class="warning">
<strong>AGGIUSTAMENTI NECESSARI SE:</strong><br>
• GIR > 12 mg/kg/min → Ridurre glucosio<br>
• BUN > 20 mg/dL → Ridurre proteine<br>
• BUN < 5 mg/dL → Aumentare proteine<br>
• Trigliceridi 200-400 mg/dL → Ridurre/sospendere lipidi<br>
• Ipernatremia → Ridurre sodio, aumentare liquidi liberi
</div>
</div>
<div class="section">
<h2>Impostazioni Ospedale</h2>
<div class="form-row">
<div class="form-col">
<div class="input-group">
<label for="hospitalName">Nome Ospedale:</label>
<input type="text" id="hospitalName" value="ASST LECCO" style="width: 250px;">
</div>
<div class="input-group">
<label for="departmentName">Dipartimento:</label>
<input type="text" id="departmentName" value="S.C. Neonatologia e TIN" style="width: 250px;">
</div>
<div class="input-group">
<label for="directorName">Direttore:</label>
<input type="text" id="directorName" value="Dott. Roberto Bellù" style="width: 250px;">
</div>
</div>
<div class="form-col">
<div class="input-group">
<label for="autoSave">Salvataggio automatico:</label>
<select id="autoSave">
<option value="true">Attivo</option>
<option value="false">Disattivo</option>
</select>
</div>
<div class="input-group">
<label for="decimalPlaces">Cifre decimali:</label>
<select id="decimalPlaces">
<option value="1">1 cifra</option>
<option value="2" selected>2 cifre</option>
<option value="3">3 cifre</option>
</select>
</div>
</div>
</div>
<button class="button secondary" onclick="resetConfiguration()">RESET CONFIGURAZIONE</button>
<button class="button" onclick="saveConfiguration()">SALVA CONFIGURAZIONE</button>
</div>
</div>
<div id="configResults" class="results hidden">
<h3>Stato Configurazione v3.0</h3>
<div id="configInfo"></div>
</div>
</div>
<!-- TAB 6: REPORT FINALE (NUOVO) -->
<div id="report" class="tab-content">
<div class="info">
<strong>PASSO 6 - REPORT FINALE</strong><br>
<strong>Obiettivo:</strong> Generare la documentazione completa per prescrizione e preparazione
</div>
<div class="section no-print">
<h2>Genera Documentazione</h2>
<button class="button" onclick="generatePrescription()">Genera Prescrizione Medica</button>
<button class="button" onclick="generateWorksheet()">Genera Ricetta Preparazione</button>
<button class="button secondary" onclick="window.print()">Stampa Pagina</button>
</div>
<div id="reportOutput"></div>
</div>
<script>
DATI NUTRIZIONALI COMPLETI (DA VERSIONE 17)
const formulaData = {
maternal: { name: “Latte Materno”, protein: 1.2, carbs: 7.0, lipids: 4.0, sodium: 0.007, potassium: 0.035, calcium: 28.0, phosphorus: 15.0, magnesium: 3.0, energy: 67 },
maternal_fortified: { name: “Latte Materno + Prenidina FM85”, protein: 2.6, carbs: 7.4, lipids: 4.25, sodium: 0.009, potassium: 0.050, calcium: 63.0, phosphorus: 35.0, magnesium: 4.5, energy: 87 },
nan_supreme: { name: “Nestle NAN Supreme Pro 1”, protein: 1.3, carbs: 7.6, lipids: 3.5, sodium: 0.024, potassium: 0.0745, calcium: 44.1, phosphorus: 24.4, magnesium: 6.56, energy: 67 },
humana1: { name: “Humana 1”, protein: 1.4, carbs: 7.6, lipids: 3.2, sodium: 0.020, potassium: 0.070, calcium: 59.0, phosphorus: 33.0, magnesium: 5.0, energy: 67 },
bbmilk_zero: { name: “BBmilk Zero”, protein: 1.8, carbs: 7.8, lipids: 3.6, sodium: 0.022, potassium: 0.075, calcium: 65.0, phosphorus: 36.0, magnesium: 6.0, energy: 70 },
bbmilk_pdf: { name: “BBmilk PDF”, protein: 1.7, carbs: 7.9, lipids: 3.7, sodium: 0.025, potassium: 0.078, calcium: 68.0, phosphorus: 38.0, magnesium: 6.5, energy: 71 },
prenan: { name: “Nestle PreNan POST”, protein: 2.0, carbs: 8.2, lipids: 4.0, sodium: 0.030, potassium: 0.085, calcium: 75.0, phosphorus: 42.0, magnesium: 7.5, energy: 73 },
alfare: { name: “Alfare”, protein: 1.9, carbs: 7.1, lipids: 3.4, sodium: 0.015, potassium: 0.050, calcium: 52.0, phosphorus: 35.0, magnesium: 5.5, energy: 67 },
infatrini: { name: “Infatrini”, protein: 2.6, carbs: 10.8, lipids: 5.4, sodium: 0.028, potassium: 0.082, calcium: 85.0, phosphorus: 58.0, magnesium: 9.2, energy: 101 }
};
CONFIGURAZIONI PARENTERALI COMPLETE (DA VERSIONE 17)
const parenteralConfig = {
trophamine: {
name: "Trophamine 6%",
protein: 6.0, carbs: 0, lipids: 0, sodium: 0, potassium: 0,
calcium: 0, phosphorus: 0, magnesium: 0, energy: 24, water: 94,
description: "Soluzione di aminoacidi pediatrica",
notes: "Soluzione sterile per uso endovenoso. Osmolarità: ~360 mOsm/L"
},
intralipid: {
name: "Intralipid 20%",
protein: 0, carbs: 0, lipids: 20.0, sodium: 0, potassium: 0,
calcium: 0, phosphorus: 0, magnesium: 0, energy: 200, water: 80,
description: "Emulsione lipidica endovenosa",
notes: "Fornisce acidi grassi essenziali. Max 4g/kg/die"
},
glucose50: {
name: "Glucosio 50%",
protein: 0, carbs: 50.0, lipids: 0, sodium: 0, potassium: 0,
calcium: 0, phosphorus: 0, magnesium: 0, energy: 200, water: 50,
description: "Soluzione glucosata molto ipertonica",
notes: "Osmolarità: ~2800 mOsm/L. Solo per alte concentrazioni"
},
ca_gluconato: {
name: "Calcio Gluconato 10% (1g/10mL, 0.44 mEq/mL)",
protein: 0, carbs: 0, lipids: 0, sodium: 0, potassium: 0,
calcium: 840, phosphorus: 0, magnesium: 0, energy: 0, water: 90,
description: "Sale di calcio organico",
notes: "8.4 mg Ca/ml. Non precipita con fosfati"
},
esafosfina: {
name: "Esafosfina (5g/50mL)",
protein: 0, carbs: 0, lipids: 0, sodium: 130, potassium: 0,
calcium: 0, phosphorus: 1600, magnesium: 0, energy: 0, water: 98,
description: "Glicerofosfato di sodio",
notes: "16 mg P/ml + 1.3 mEq Na/ml. Fosforo organico"
},
mg_sulfate: {
name: "Magnesio Solfato (2g/10ml, 1.6 mEq/mL)",
protein: 0, carbs: 0, lipids: 0, sodium: 0, potassium: 0,
calcium: 0, phosphorus: 0, magnesium: 800, energy: 0, water: 99,
description: "Elettrolita essenziale",
notes: "8 mEq Mg/ml. Cofattore enzimatico"
},
nacl: {
name: "Sodio Cloruro (3mEq/mL)",
protein: 0, carbs: 0, lipids: 0, sodium: 1000, potassium: 0,
calcium: 0, phosphorus: 0, magnesium: 0, energy: 0, water: 99,
description: "Elettrolita essenziale",
notes: "10 mEq Na/ml. Prima scelta per supplementazione sodio"
},
sodium_acetate: {
name: "Sodio Acetato (2 mEq/mL)",
protein: 0, carbs: 0, lipids: 0, sodium: 667, potassium: 0,
calcium: 0, phosphorus: 0, magnesium: 0, energy: 0, water: 99,
description: "Elettrolita alcalinizzante",
notes: "6.67 mEq Na/ml. Per acidosi: pH < 7.25 o BE < -4"
},
kcl: {
name: "Potassio Cloruro (2 mEq/mL)",
protein: 0, carbs: 0, lipids: 0, sodium: 0, potassium: 1000,
calcium: 0, phosphorus: 0, magnesium: 0, energy: 0, water: 99,
description: "Elettrolita essenziale",
notes: "10 mEq K/ml. Max velocità infusione: 0.5 mEq/kg/h"
},
carnitene: {
name: "Carnitene (100 mg/ml)",
protein: 0, carbs: 0, lipids: 0, sodium: 0, potassium: 0,
calcium: 0, phosphorus: 0, magnesium: 0, energy: 0, water: 99,
carnitine: 10000, // 100 mg/ml = 10000 mg/100ml
description: "L-Carnitina per NPT prolungata",
notes: "100 mg/ml. Indicata per NPT > 1 mese. Dose: 5 mg/kg/die"
}
};
Database fortificanti dinamico
let fortifierData = {
prenidina_fm85: {
name: “Prenidina FM85”,
protein: 14, carbs: 4, lipids: 2.5, sodium: 2, potassium: 15,
calcium: 3500, phosphorus: 2000, magnesium: 150, energy: 400,
dose: “1-4g/100ml”
}
};
Database medici dinamico
let doctorsData = {
dr_bellu: { name: "Roberto", surname: "Bellù", title: "Dr.", fullName: "Dr. Roberto Bellù" },
dr_condo: { name: "Manuela", surname: "Condò", title: "Dr.ssa", fullName: "Dr.ssa Manuela Condò" },
dr_maccioni: { name: "Carla", surname: "Maccioni", title: "Dr.ssa", fullName: "Dr.ssa Carla Maccioni" },
dr_meroni: { name: "Federica", surname: "Meroni", title: "Dr.ssa", fullName: "Dr.ssa Federica Meroni" },
dr_calzatini: { name: "Francesco", surname: "Calzatini", title: "Dr.", fullName: "Dr. Francesco Calzatini" },
dr_ferrari: { name: "Elisabetta", surname: "Ferrari", title: "Dr.ssa", fullName: "Dr.ssa Elisabetta Ferrari" },
dr_ferendeles: { name: "Francesca", surname: "Ferendeles", title: "Dr.ssa", fullName: "Dr.ssa Francesca Ferendeles" },
dr_fumagalli_l: { name: "Letizia", surname: "Fumagalli", title: "Dr.ssa", fullName: "Dr.ssa Letizia Fumagalli" },
dr_fumagalli_m: { name: "Mara", surname: "Fumagalli", title: "Dr.ssa", fullName: "Dr.ssa Mara Fumagalli" },
dr_corno: { name: "Federica", surname: "Corno", title: "Dr.ssa", fullName: "Dr.ssa Federica Corno" },
dr_evasi: { name: "Veronica", surname: "Evasi", title: "Dr.ssa", fullName: "Dr.ssa Veronica Evasi" },
dr_cereda: { name: "Lidia", surname: "Cereda", title: "Dr.ssa", fullName: "Dr.ssa Lidia Cereda" },
dr_ceccon: { name: "Chiara", surname: "Ceccon", title: "Dr.ssa", fullName: "Dr.ssa Chiara Ceccon" },
dr_nava: { name: "Chiara", surname: "Nava", title: "Dr.ssa", fullName: "Dr.ssa Chiara Nava" },
dr_terenzi: { name: "Francesca", surname: "Terenzi", title: "Dr.ssa", fullName: "Dr.ssa Francesca Terenzi" },
dr_raffa: { name: "Milena", surname: "Raffa", title: "Dr.ssa", fullName: "Dr.ssa Milena Raffa" },
dr_aquisti: { name: "Giulia", surname: "Aquisti", title: "Dr.ssa", fullName: "Dr.ssa Giulia Aquisti" }
};
VARIABILI GLOBALI
let patientData = {};
let enteralData = null;
let currentRequirements = null;
CONFIGURAZIONE CLINICA AVANZATA (NUOVO)
let clinicalConfig = {
calciumReq: 160,
phosphorusReq: 84,
magnesiumReq: 0.6,
maxGIR: 12.0,
maxLipids: 3.0,
maxProtein: 4.5,
hospitalName: "ASST LECCO",
departmentName: "S.C. Neonatologia e TIN",
directorName: "Dott. Roberto Bellù"
};
FUNZIONE RESET PULSANTE FABBISOGNI
function resetNutritionButton() {
const nutritionBtn = document.getElementById('calculateNutritionBtn');
if (nutritionBtn) {
nutritionBtn.className = 'button calculate-nutrition-pending';
nutritionBtn.innerHTML = 'RICALCOLA FABBISOGNI';
Nascondi i risultati precedenti
const nutritionResults = document.getElementById('nutritionResults');
if (nutritionResults) {
nutritionResults.classList.add('hidden');
}
// Reset anche il pulsante NPT perché i fabbisogni sono cambiati
resetParenteralButton();
}
}
FUNZIONE RESET PULSANTE PARENTERALE
function resetParenteralButton() {
const parenteralBtn = document.getElementById('calculateParenteralBtn');
if (parenteralBtn) {
parenteralBtn.className = 'button';
parenteralBtn.innerHTML = 'CALCOLA NPT AUTOMATICA';
Reset anche i campi visualizzati
document.getElementById('calculatedTotalVolume').value = "Premere 'Calcola NPT'";
document.getElementById('suggestedGlucose').value = "Premere 'Calcola NPT'";
document.getElementById('calculatedProteinVol').value = "--";
document.getElementById('calculatedLipidVol').value = "--";
// Nascondi i risultati precedenti
const parenteralResults = document.getElementById('parenteralResults');
if (parenteralResults) {
parenteralResults.classList.add('hidden');
}
}
}
FUNZIONE CORRETTA PER CAMBIO TAB
function showTab(tabId) {
Nascondi tutti i contenuti dei tab
document.querySelectorAll('.tab-content').forEach(content => {
content.classList.remove('active');
});
// Rimuovi classe active da tutti i tab
document.querySelectorAll('.tab').forEach(tab => {
tab.classList.remove('active');
});
// Mostra il contenuto del tab selezionato
const targetContent = document.getElementById(tabId);
if (targetContent) {
targetContent.classList.add('active');
}
// Trova e attiva il tab cliccato
const clickedTab = event.target.closest('.tab');
if (clickedTab) {
clickedTab.classList.add('active');
}
// Popola le tabelle di configurazione quando si apre il TAB 5
if (tabId === 'config') {
setTimeout(() => {
populateEnteralConfigTable();
populateParenteralConfigTable();
populateDoctorsConfigTable();
}, 100);
}
}
FUNZIONE GESTIONE CARTELLA CLINICA
function setupMedicalRecordField() {
const medicalRecordInput = document.getElementById('medicalRecord');
const currentYear = new Date().getFullYear().toString();
Imposta il valore iniziale con l'anno corrente
if (!medicalRecordInput.value) {
medicalRecordInput.value = currentYear;
}
// Gestisce l'input per mantenere sempre l'anno all'inizio
medicalRecordInput.addEventListener('input', function(e) {
let value = e.target.value.replace(/\D/g, ''); // Solo numeri
// Se l'utente cerca di cancellare l'anno, lo ripristina
if (value.length < 4 || !value.startsWith(currentYear)) {
value = currentYear + value.slice(4);
}
// Limita a 10 cifre totali
if (value.length > 10) {
value = value.slice(0, 10);
}
e.target.value = value;
});
// Quando il campo ottiene il focus, posiziona il cursore dopo l'anno
medicalRecordInput.addEventListener('focus', function(e) {
if (e.target.value === currentYear) {
// Posiziona il cursore alla fine
setTimeout(() => {
e.target.setSelectionRange(4, 4);
}, 0);
}
});
// Suggerimento visivo
medicalRecordInput.addEventListener('blur', function(e) {
if (e.target.value === currentYear) {
e.target.placeholder = currentYear + '000001';
}
});
}
function updateDoctorsDropdown() {
const prescribingDoctorSelect = document.getElementById('prescribingDoctor');
if (!prescribingDoctorSelect) return;
const currentValue = prescribingDoctorSelect.value;
prescribingDoctorSelect.innerHTML = '<option value="">Seleziona medico</option>';
Object.keys(doctorsData).forEach(function(key) {
const doctor = doctorsData[key];
const option = document.createElement('option');
option.value = key;
option.textContent = doctor.fullName;
prescribingDoctorSelect.appendChild(option);
});
// Ripristina il valore precedente se esiste ancora
if (currentValue && doctorsData[currentValue]) {
prescribingDoctorSelect.value = currentValue;
}
}
FUNZIONE CALCOLO FASE NUTRIZIONALE (DA VERSIONE 17)
function calculatePhase() {
const medicalRecord = document.getElementById('medicalRecord').value;
const phaseBirthWeight = parseInt(document.getElementById('birthWeight').value);
const phaseCurrentWeight = parseInt(document.getElementById('currentWeight').value);
const daysOfLife = parseInt(document.getElementById('daysOfLife').value);
const bun = document.getElementById('bun').value;
const glucose = document.getElementById('glucose').value;
const sodium = document.getElementById('sodium').value;
const ph = document.getElementById('ph').value;
const baseExcess = document.getElementById('baseExcess').value;
const diuresis = document.getElementById('diuresis').value;
const prescriptionDate = document.getElementById('prescriptionDate').value;
const prescribingDoctor = document.getElementById('prescribingDoctor').value;
patientData = {
medicalRecord: medicalRecord,
birthWeight: phaseBirthWeight,
currentWeight: phaseCurrentWeight,
daysOfLife: daysOfLife,
bun: bun,
glucose: glucose,
sodium: sodium,
ph: ph,
baseExcess: baseExcess,
diuresis: diuresis,
prescriptionDate: prescriptionDate,
prescribingDoctor: prescribingDoctor
};
document.getElementById('targetDay').value = daysOfLife;
let phase = daysOfLife ⇐ 5 ? 'Transizione' : daysOfLife ⇐ 14 ? 'Stabilizzazione' : 'Crescita';
let bunStatus = ;
let bunWarning =
;
Analisi BUN
if (bun && bun !== '') {
const bunValue = parseFloat(bun);
if (bunValue < 9) {
bunStatus = 'Basso - Aumentare proteine';
bunWarning = 'BUN basso: considerare aumento fortificazione proteica (+1%)';
} else if (bunValue > 14) {
bunStatus = 'Elevato - Ridurre proteine';
bunWarning = 'BUN elevato: ridurre fortificazione proteica (-1%)';
} else {
bunStatus = 'Normale (9-14 mg/dL)';
}
} else {
bunStatus = 'Non inserito';
}
// Analisi altri parametri
let otherWarnings = [];
if (glucose && glucose !== '') {
const glucoseValue = parseFloat(glucose);
if (glucoseValue < 70) {
otherWarnings.push('⚠️ Ipoglicemia: considerare riduzione velocità glucosio');
} else if (glucoseValue > 150) {
otherWarnings.push('⚠️ Iperglicemia: ridurre concentrazione glucosio NPT');
}
}
if (sodium && sodium !== '') {
const sodiumValue = parseFloat(sodium);
if (sodiumValue < 135) {
otherWarnings.push('⚠️ Iponatremia: aumentare sodio in NPT');
} else if (sodiumValue > 145) {
otherWarnings.push('⚠️ Ipernatremia: ridurre sodio, aumentare liquidi');
}
}
if (ph && ph !== '') {
const phValue = parseFloat(ph);
if (phValue < 7.35) {
otherWarnings.push('⚠️ Acidosi: valutare bicarbonato o ridurre cloruri');
} else if (phValue > 7.45) {
otherWarnings.push('⚠️ Alcalosi: ridurre bicarbonato, aumentare cloruri');
}
}
if (baseExcess && baseExcess !== '') {
const beValue = parseFloat(baseExcess);
if (beValue < -4) {
otherWarnings.push('⚠️ BE < -4: Acidosi metabolica - Considera Sodio Acetato in NPT');
} else if (beValue > 2) {
otherWarnings.push('⚠️ BE > +2: Alcalosi metabolica - Ridurre bicarbonato');
}
}
// Raccomandazione combinata pH + BE per Sodio Acetato
if (ph && baseExcess) {
const phValue = parseFloat(ph);
const beValue = parseFloat(baseExcess);
if (phValue < 7.25 || beValue < -4) {
otherWarnings.push('🧪 RACCOMANDAZIONE: Usa Sodio Acetato invece di NaCl in NPT');
}
}
if (diuresis && diuresis !== '') {
const diuresisValue = parseFloat(diuresis);
if (diuresisValue < 1) {
otherWarnings.push('⚠️ Oliguria: ridurre liquidi, controllare funzione renale');
} else if (diuresisValue > 3) {
otherWarnings.push('⚠️ Poliuria: aumentare liquidi, controllare osmolarità');
}
}
let phaseInfoHtml = '<div class="phase-indicator phase-' + phase.toLowerCase() + '">' + phase + '</div>';
phaseInfoHtml += '<div class="form-row" style="margin-top: 15px;">';
phaseInfoHtml += '<div class="form-col">';
phaseInfoHtml += '<h4>Dati Paziente</h4>';
if (medicalRecord) {
phaseInfoHtml += '<p><strong>Cartella:</strong> ' + medicalRecord + '</p>';
}
phaseInfoHtml += '<p><strong>Peso:</strong> ' + phaseCurrentWeight + 'g (nascita: ' + phaseBirthWeight + 'g)</p>';
phaseInfoHtml += '<p><strong>Giorni di vita:</strong> ' + daysOfLife + '</p>';
phaseInfoHtml += '<p><strong>Fase nutrizionale:</strong> ' + phase + '</p>';
phaseInfoHtml += '</div>';
phaseInfoHtml += '<div class="form-col">';
phaseInfoHtml += '<h4>Esami Ematochimici</h4>';
if (patientData.bun) {
phaseInfoHtml += '<p><strong>BUN:</strong> ' + patientData.bun + ' mg/dL (' + bunStatus + ')</p>';
}
if (patientData.glucose) {
const gluStatus = parseFloat(patientData.glucose) >= 70 && parseFloat(patientData.glucose) <= 110 ? 'Normale' : 'Fuori range';
phaseInfoHtml += '<p><strong>Glicemia:</strong> ' + patientData.glucose + ' mg/dL (' + gluStatus + ')</p>';
}
if (patientData.sodium) {
const naStatus = parseFloat(patientData.sodium) >= 135 && parseFloat(patientData.sodium) <= 145 ? 'Normale' : 'Fuori range';
phaseInfoHtml += '<p><strong>Natremia:</strong> ' + patientData.sodium + ' mEq/L (' + naStatus + ')</p>';
}
if (patientData.ph) {
const phStatus = parseFloat(patientData.ph) >= 7.35 && parseFloat(patientData.ph) <= 7.45 ? 'Normale' : 'Fuori range';
phaseInfoHtml += '<p><strong>pH:</strong> ' + patientData.ph + ' (' + phStatus + ')</p>';
}
if (patientData.baseExcess) {
const beStatus = parseFloat(patientData.baseExcess) >= -4 && parseFloat(patientData.baseExcess) <= 2 ? 'Normale' : 'Fuori range';
phaseInfoHtml += '<p><strong>BE:</strong> ' + patientData.baseExcess + ' mEq/L (' + beStatus + ')</p>';
}
if (patientData.diuresis) {
const diuStatus = parseFloat(patientData.diuresis) >= 1 && parseFloat(patientData.diuresis) <= 3 ? 'Normale' : 'Fuori range';
phaseInfoHtml += '<p><strong>Diuresi:</strong> ' + patientData.diuresis + ' mL/kg/die (' + diuStatus + ')</p>';
}
phaseInfoHtml += '</div>';
phaseInfoHtml += '</div>';
if (bunWarning) {
phaseInfoHtml += '<div class="info"><strong>Nota BUN:</strong> ' + bunWarning + '</div>';
}
if (otherWarnings.length > 0) {
phaseInfoHtml += '<div class="warning"><strong>Avvertenze Cliniche:</strong><br>' + otherWarnings.join('<br>') + '</div>';
}
phaseInfoHtml += '<div class="info"><strong>Prossimo passo:</strong> Vai al TAB 2 per la nutrizione enterale</div>';
document.getElementById('phaseInfo').innerHTML = phaseInfoHtml;
document.getElementById('phaseResults').classList.remove('hidden');
document.getElementById('calculatePhaseBtn').className = 'button config-update-completed';
document.getElementById('calculatePhaseBtn').innerHTML = 'FASE CALCOLATA ✓';
// Aggiorna il suggerimento sodio se il TAB 3 è già stato visitato
updateSodiumRecommendation();
// RESET anche il pulsante NPT
resetParenteralButton();
}
FUNZIONE AGGIORNAMENTO OPZIONI FORTIFICANTE
function updateFortifierOptions() {
const formulaType = document.getElementById('formulaType').value;
const fortifierSection = document.getElementById('fortifierSection');
const fortifierSelect = document.getElementById('fortifierType');
if (formulaType === 'maternal') {
fortifierSection.classList.remove('hidden');
fortifierSelect.innerHTML = '<option value=“none”>Nessun fortificante</option>';
Object.keys(fortifierData).forEach(function(key) {
const option = document.createElement('option');
option.value = key;
option.textContent = fortifierData[key].name;
fortifierSelect.appendChild(option);
});
} else {
fortifierSection.classList.add('hidden');
fortifierSelect.value = 'none';
}
}
FUNZIONE AGGIORNAMENTO DISPLAY CONCENTRAZIONE
function updateConcentrationDisplay() {
const concentration = document.getElementById('fortifierConcentration').value;
document.getElementById('concentrationValue').textContent = concentration + '%';
}
FUNZIONE CALCOLO NUTRIZIONE ENTERALE (DA VERSIONE 17)
function calculateEnteral() {
Controlla se i dati di base sono presenti
const enteralCurrentWeight = parseInt(document.getElementById('currentWeight').value);
const enteralBirthWeight = parseInt(document.getElementById('birthWeight').value);
if (!enteralCurrentWeight || !enteralBirthWeight) {
alert('Prima inserire peso attuale e peso alla nascita nel TAB 1');
return;
}
// Aggiorna patientData se non è stato ancora fatto
if (!patientData.currentWeight) {
patientData.currentWeight = enteralCurrentWeight;
patientData.birthWeight = enteralBirthWeight;
}
const formulaType = document.getElementById('formulaType').value;
const dailyVolume = parseFloat(document.getElementById('dailyVolume').value);
const additionalFluids = parseFloat(document.getElementById('additionalFluids').value) || 0;
const currentWeight = patientData.currentWeight;
const totalFluids = dailyVolume + additionalFluids;
const totalFluidsPerKg = (totalFluids / currentWeight) * 1000;
if (formulaType === 'none' || dailyVolume === 0) {
enteralData = {
volume: dailyVolume,
additionalFluids: additionalFluids,
totalFluids: totalFluids,
protein: 0, carbs: 0, lipids: 0, energy: 0,
sodium: 0, potassium: 0, calcium: 0, phosphorus: 0, magnesium: 0
};
let tableHtml = '<div class="info">';
if (additionalFluids > 0) {
tableHtml += '<strong>⚠️ Solo liquidi aggiuntivi:</strong> ' + additionalFluids + ' ml (' + ((additionalFluids/currentWeight)*1000).toFixed(1) + ' ml/kg/die)<br>';
tableHtml += '<strong>Nessun apporto nutrizionale dal latte</strong>';
} else {
tableHtml += 'Nessun apporto enterale';
}
tableHtml += '</div>';
document.getElementById('enteralTable').innerHTML = tableHtml;
} else {
const formula = formulaData[formulaType];
const volumePerKg = (dailyVolume / currentWeight) * 1000;
// Calcoli finali per kg di peso
enteralData = {
volume: dailyVolume,
additionalFluids: additionalFluids,
totalFluids: totalFluids,
protein: (dailyVolume * formula.protein / 100) / (currentWeight / 1000),
carbs: (dailyVolume * formula.carbs / 100) / (currentWeight / 1000),
lipids: (dailyVolume * formula.lipids / 100) / (currentWeight / 1000),
energy: (dailyVolume * formula.energy / 100) / (currentWeight / 1000),
sodium: (dailyVolume * formula.sodium / 100) / (currentWeight / 1000),
potassium: (dailyVolume * formula.potassium / 100) / (currentWeight / 1000),
calcium: (dailyVolume * formula.calcium / 100) / (currentWeight / 1000),
phosphorus: (dailyVolume * formula.phosphorus / 100) / (currentWeight / 1000),
magnesium: (dailyVolume * formula.magnesium / 100) / (currentWeight / 1000)
};
let tableHtml = '<div class="info">';
tableHtml += '<strong>Formula:</strong> ' + formula.name + '<br>';
tableHtml += '<strong>Volume latte:</strong> ' + dailyVolume + ' ml (' + volumePerKg.toFixed(1) + ' ml/kg/die)<br>';
if (additionalFluids > 0) {
tableHtml += '<strong>Altri liquidi:</strong> ' + additionalFluids + ' ml (' + ((additionalFluids/currentWeight)*1000).toFixed(1) + ' ml/kg/die)<br>';
tableHtml += '<strong>💧 TOTALE LIQUIDI:</strong> ' + totalFluids + ' ml (' + totalFluidsPerKg.toFixed(1) + ' ml/kg/die)';
} else {
tableHtml += '<strong>Liquidi totali:</strong> ' + totalFluids + ' ml (' + totalFluidsPerKg.toFixed(1) + ' ml/kg/die)';
}
tableHtml += '</div>';
tableHtml += '<table class="results-table">';
tableHtml += '<tr><th>Nutriente</th><th>Per 100ml</th><th>Per kg/die</th><th>Unita</th></tr>';
tableHtml += '<tr><td>Proteine</td><td>' + formula.protein.toFixed(1) + '</td><td>' + enteralData.protein.toFixed(1) + '</td><td>g</td></tr>';
tableHtml += '<tr><td>Carboidrati</td><td>' + formula.carbs.toFixed(1) + '</td><td>' + enteralData.carbs.toFixed(1) + '</td><td>g</td></tr>';
tableHtml += '<tr><td>Lipidi</td><td>' + formula.lipids.toFixed(1) + '</td><td>' + enteralData.lipids.toFixed(1) + '</td><td>g</td></tr>';
tableHtml += '<tr class="energy-highlight"><td><strong>Energia</strong></td><td><strong>' + formula.energy.toFixed(0) + '</strong></td><td><strong>' + enteralData.energy.toFixed(0) + '</strong></td><td><strong>kcal</strong></td></tr>';
tableHtml += '</table>';
document.getElementById('enteralTable').innerHTML = tableHtml;
}
document.getElementById('enteralResults').classList.remove('hidden');
// Aggiorna il pulsante a verde
const enteralBtn = document.getElementById('calculateEnteralBtn');
if (enteralBtn) {
enteralBtn.className = 'button config-update-completed';
enteralBtn.innerHTML = 'Apporti Enterali Calcolati ✓';
}
// RESET del pulsante Fabbisogni quando si modificano gli apporti enterali
resetNutritionButton();
}
FUNZIONE CARICAMENTO VALORI STANDARD (DA VERSIONE 17)
function loadNutritionDefaults() {
Controlla se i dati di base sono presenti
const defaultsCurrentWeight = parseInt(document.getElementById('currentWeight').value);
const defaultsBirthWeight = parseInt(document.getElementById('birthWeight').value);
const defaultsDaysOfLife = parseInt(document.getElementById('daysOfLife').value);
if (!defaultsCurrentWeight || !defaultsBirthWeight || !defaultsDaysOfLife) {
alert('Prima inserire peso attuale, peso alla nascita e giorni di vita nel TAB 1');
return;
}
// Aggiorna patientData se non è stato ancora fatto
if (!patientData.currentWeight) {
patientData.currentWeight = defaultsCurrentWeight;
patientData.birthWeight = defaultsBirthWeight;
patientData.daysOfLife = defaultsDaysOfLife;
}
const targetDay = parseInt(document.getElementById('targetDay').value);
const patientBirthWeightForCalculation = patientData.birthWeight;
const weightCategorySelect = document.getElementById('weightCategory');
let selectedCategory = weightCategorySelect.value || (patientBirthWeightForCalculation <= 1500 ? '≤1500g' : '>1500g');
weightCategorySelect.value = selectedCategory;
let plan = {};
if (selectedCategory === '≤1500g') {
plan = targetDay <= 3 ? {liquids: 100, protein: 3.5, carbs: 8.0, lipids: 1.0} :
{liquids: 140, protein: 4.0, carbs: 10.0, lipids: 2.0};
} else {
plan = targetDay <= 3 ? {liquids: 120, protein: 3.0, carbs: 8.0, lipids: 2.0} :
{liquids: 150, protein: 3.5, carbs: 12.0, lipids: 3.0};
}
// Aggiustamento BUN
if (patientData.bun && patientData.bun !== '') {
const bunValue = parseFloat(patientData.bun);
if (bunValue < 9) {
plan.protein = Math.min(6.0, plan.protein + 1.0);
} else if (bunValue > 14) {
plan.protein = Math.max(2.0, plan.protein - 1.0);
}
}
document.getElementById('reqLiquids').value = plan.liquids;
document.getElementById('reqProtein').value = plan.protein;
document.getElementById('reqCarbs').value = plan.carbs;
document.getElementById('reqLipids').value = plan.lipids;
// Usa configurazione clinica per elettroliti
document.getElementById('reqCalcium').value = targetDay > 3 ? clinicalConfig.calciumReq : 0;
document.getElementById('reqPhosphorus').value = targetDay > 3 ? clinicalConfig.phosphorusReq : 0;
document.getElementById('reqMagnesium').value = targetDay > 3 ? clinicalConfig.magnesiumReq : 0;
document.getElementById('reqSodium').value = targetDay > 2 ? 2.0 : 0;
document.getElementById('reqPotassium').value = targetDay > 2 ? 1.5 : 0;
// Gestione automatica tipo di sodio basata sui parametri clinici
const sodiumSelect = document.getElementById('sodiumType');
if (patientData.ph || patientData.baseExcess) {
const ph = patientData.ph ? parseFloat(patientData.ph) : null;
const be = patientData.baseExcess ? parseFloat(patientData.baseExcess) : null;
// Auto-seleziona Sodio Acetato se acidosi
if ((ph && ph < 7.30) || (be && be < -4)) {
sodiumSelect.value = 'sodium_acetate';
} else {
sodiumSelect.value = 'nacl';
}
}
// Aggiorna il suggerimento sodio
updateSodiumRecommendation();
// Gestione vitamine/oligoelementi con controllo enterale
const patientCurrentWeight = patientData.currentWeight;
const enteralVolumePerKg = enteralData ? (enteralData.totalFluids / patientCurrentWeight * 1000) : 0;
if (targetDay >= 3 && enteralVolumePerKg < 100) {
document.getElementById('reqVitalipid').value = 4.0;
document.getElementById('reqSoluvit').value = 1.0;
document.getElementById('reqPeditrace').value = 1.0;
} else {
// Mantieni i valori a zero se prima del 3° giorno o se enterale ≥100 ml/kg/die
document.getElementById('reqVitalipid').value = 0;
document.getElementById('reqSoluvit').value = 0;
document.getElementById('reqPeditrace').value = 0;
}
document.getElementById('reqCarnitine').value = 0; // La carnitina verrà gestita separatamente
document.getElementById('loadDefaultsBtn').className = 'button load-defaults-completed';
document.getElementById('loadDefaultsBtn').innerHTML = 'Valori Caricati ✓';
// RESET del pulsante Fabbisogni quando si modificano i valori standard
resetNutritionButton();
}
FUNZIONE AGGIORNAMENTO UNITÀ CARBOIDRATI
function updateCarbUnit() {
const unit = document.getElementById('carbUnit').value;
const carbLabel = document.getElementById('carbLabel');
const carbInput = document.getElementById('reqCarbs');
if (unit === 'mg') {
carbLabel.textContent = 'Glucidi (mg/kg/min):';
carbInput.setAttribute('max', '15');
carbInput.setAttribute('step', '0.1');
} else {
carbLabel.textContent = 'Glucidi (g/kg/die):';
carbInput.setAttribute('max', '20');
carbInput.setAttribute('step', '0.1');
}
Reset fabbisogni quando si cambia unità
resetNutritionButton();
}
FUNZIONE AGGIORNAMENTO CATEGORIA PESO
function updateWeightCategory() {
Reset fabbisogni quando si cambia categoria peso
resetNutritionButton();
}
FUNZIONE AGGIORNAMENTO TIPO SODIO
function updateSodiumChoice() {
Resetta i fabbisogni quando si cambia il tipo di sodio
resetNutritionButton();
}
FUNZIONE AGGIORNAMENTO SUGGERIMENTO SODIO
function updateSodiumRecommendation() {
const sodiumSelect = document.getElementById('sodiumType');
const recommendationDiv = document.getElementById('sodiumRecommendation');
if (!patientData.ph && !patientData.baseExcess) {
Nessun dato clinico disponibile
recommendationDiv.classList.add('hidden');
return;
}
const ph = patientData.ph ? parseFloat(patientData.ph) : null;
const be = patientData.baseExcess ? parseFloat(patientData.baseExcess) : null;
// Logica di raccomandazione
let needsAcetate = false;
let reason = '';
if (ph && ph < 7.30) {
needsAcetate = true;
reason = 'pH < 7.30 (acidosi)';
} else if (be && be < -4) {
needsAcetate = true;
reason = 'BE < -4 mEq/L (acidosi metabolica)';
} else if (ph && be && (ph < 7.30 || be < -4)) {
needsAcetate = true;
reason = 'pH < 7.30 o BE < -4 (acidosi)';
}
if (needsAcetate) {
// Suggerisci Sodio Acetato
if (sodiumSelect.value === 'nacl') {
// L'utente ha selezionato NaCl ma dovrebbe usare Acetato
recommendationDiv.innerHTML = '<div class="warning" style="padding: 8px; font-size: 12px;">' +
'<strong>⚠️ RACCOMANDAZIONE CLINICA:</strong><br>' +
'In base ai parametri clinici (' + reason + '), si raccomanda <strong>Sodio Acetato</strong> invece di Sodio Cloruro per effetto alcalinizzante.' +
'</div>';
recommendationDiv.classList.remove('hidden');
} else {
// L'utente ha già selezionato Acetato - mostra conferma
recommendationDiv.innerHTML = '<div class="info" style="padding: 8px; font-size: 12px;">' +
'<strong>✅ SCELTA APPROPRIATA:</strong><br>' +
'Sodio Acetato è indicato per i parametri clinici attuali (' + reason + ').' +
'</div>';
recommendationDiv.classList.remove('hidden');
}
} else {
// Parametri normali
if (sodiumSelect.value === 'sodium_acetate') {
// L'utente ha selezionato Acetato ma i parametri sono normali
recommendationDiv.innerHTML = '<div class="info" style="padding: 8px; font-size: 12px;">' +
'<strong>ℹ️ NOTA:</strong><br>' +
'I parametri clinici sono nella norma. Sodio Cloruro potrebbe essere sufficiente, ma Sodio Acetato è comunque sicuro.' +
'</div>';
recommendationDiv.classList.remove('hidden');
} else {
// Tutto normale
recommendationDiv.classList.add('hidden');
}
}
}
FUNZIONE CALCOLO FABBISOGNI NUTRIZIONALI (DA VERSIONE 17)
function calculateNutrition() {
Controlla se i dati di base sono presenti
const nutritionCurrentWeight = parseInt(document.getElementById('currentWeight').value);
const nutritionBirthWeight = parseInt(document.getElementById('birthWeight').value);
if (!nutritionCurrentWeight || !nutritionBirthWeight) {
alert('Prima inserire peso attuale e peso alla nascita nel TAB 1');
return;
}
// Aggiorna patientData se non è stato ancora fatto
if (!patientData.currentWeight) {
patientData.currentWeight = nutritionCurrentWeight;
patientData.birthWeight = nutritionBirthWeight;
}
const requirements = {
liquids: parseFloat(document.getElementById('reqLiquids').value),
protein: parseFloat(document.getElementById('reqProtein').value),
carbs: parseFloat(document.getElementById('reqCarbs').value),
carbUnit: document.getElementById('carbUnit').value,
lipids: parseFloat(document.getElementById('reqLipids').value),
calcium: parseFloat(document.getElementById('reqCalcium').value),
phosphorus: parseFloat(document.getElementById('reqPhosphorus').value),
magnesium: parseFloat(document.getElementById('reqMagnesium').value),
sodium: parseFloat(document.getElementById('reqSodium').value),
potassium: parseFloat(document.getElementById('reqPotassium').value),
vitalipid: parseFloat(document.getElementById('reqVitalipid').value) || 0,
soluvit: parseFloat(document.getElementById('reqSoluvit').value) || 0,
peditrace: parseFloat(document.getElementById('reqPeditrace').value) || 0,
carnitine: parseFloat(document.getElementById('reqCarnitine').value) || 0
};
// Converti carboidrati sempre in g/kg/die per i calcoli
const carbsGPerKgDay = requirements.carbUnit === 'mg' ?
(requirements.carbs * 1440 / 1000) : requirements.carbs;
const patientCurrentWeight = patientData.currentWeight;
const enteralVolumePerKg = enteralData ? (enteralData.totalFluids / patientCurrentWeight * 1000) : 0;
const enteralProtein = enteralData ? enteralData.protein : 0;
const enteralCarbs = enteralData ? enteralData.carbs : 0;
const enteralLipids = enteralData ? enteralData.lipids : 0;
const enteralEnergy = enteralData ? enteralData.energy : 0;
const residualProtein = Math.max(0, requirements.protein - enteralProtein);
const residualCarbs = Math.max(0, carbsGPerKgDay - enteralCarbs);
const residualLipids = Math.max(0, requirements.lipids - enteralLipids);
const totalEnergyRequirement = (requirements.protein * 4) + (carbsGPerKgDay * 4) + (requirements.lipids * 9);
const residualEnergy = Math.max(0, totalEnergyRequirement - enteralEnergy);
// Calcoli micronutrienti enterali
const enteralCalcium = enteralData ? enteralData.calcium : 0;
const enteralPhosphorus = enteralData ? enteralData.phosphorus : 0;
const enteralMagnesium = enteralData ? enteralData.magnesium : 0;
const enteralSodium = enteralData ? enteralData.sodium : 0;
const enteralPotassium = enteralData ? enteralData.potassium : 0;
// Calcoli residui micronutrienti
const residualCalcium = Math.max(0, requirements.calcium - enteralCalcium);
const residualPhosphorus = Math.max(0, requirements.phosphorus - enteralPhosphorus);
const residualMagnesium = Math.max(0, requirements.magnesium - enteralMagnesium);
const residualSodium = Math.max(0, requirements.sodium - enteralSodium);
const residualPotassium = Math.max(0, requirements.potassium - enteralPotassium);
window.residualNeeds = {
liquids: requirements.liquids - (enteralData ? enteralData.totalFluids/patientData.currentWeight*1000 : 0),
protein: residualProtein,
carbs: residualCarbs,
lipids: residualLipids,
calcium: residualCalcium,
phosphorus: residualPhosphorus,
magnesium: residualMagnesium,
sodium: residualSodium,
potassium: residualPotassium,
vitalipid: requirements.vitalipid,
soluvit: requirements.soluvit,
peditrace: requirements.peditrace,
carnitine: requirements.carnitine,
energy: residualEnergy,
totalEnergyRequirement: totalEnergyRequirement
};
// Calcola mg/kg/min per la tabella
const carbsMgPerKgMin = (carbsGPerKgDay * 1000) / 1440;
const enteralCarbsMgPerKgMin = (enteralCarbs * 1000) / 1440;
const residualCarbsMgPerKgMin = (residualCarbs * 1000) / 1440;
let tableHtml = '<table class="nutrition-table">';
tableHtml += '<tr><th>Componente</th><th>Fabbisogno</th><th>Da Enterale</th><th>Da NPT</th><th>Unità</th></tr>';
tableHtml += '<tr><td><strong>Liquidi</strong></td><td><strong>' + requirements.liquids + '</strong></td><td><strong>' + (enteralData ? (enteralData.totalFluids/patientData.currentWeight*1000).toFixed(1) : '0') + '</strong></td><td class="highlight"><strong>' + Math.max(0, requirements.liquids - (enteralData ? enteralData.totalFluids/patientData.currentWeight*1000 : 0)).toFixed(1) + '</strong></td><td><strong>ml/kg/die</strong></td></tr>';
tableHtml += '<tr><td>Proteine</td><td>' + requirements.protein + '</td><td>' + enteralProtein.toFixed(1) + '</td><td class="highlight">' + residualProtein.toFixed(1) + '</td><td>g/kg/die</td></tr>';
tableHtml += '<tr><td>Glucidi (g/kg/die)</td><td>' + carbsGPerKgDay.toFixed(1) + '</td><td>' + enteralCarbs.toFixed(1) + '</td><td class="highlight">' + residualCarbs.toFixed(1) + '</td><td>g/kg/die</td></tr>';
tableHtml += '<tr><td>Glucidi (mg/kg/min)</td><td>' + carbsMgPerKgMin.toFixed(1) + '</td><td>' + enteralCarbsMgPerKgMin.toFixed(1) + '</td><td class="highlight">' + residualCarbsMgPerKgMin.toFixed(1) + '</td><td>mg/kg/min</td></tr>';
tableHtml += '<tr><td>Lipidi</td><td>' + requirements.lipids + '</td><td>' + enteralLipids.toFixed(1) + '</td><td class="highlight">' + residualLipids.toFixed(1) + '</td><td>g/kg/die</td></tr>';
tableHtml += '<tr><td>Calcio elementare</td><td>' + requirements.calcium + '</td><td>' + enteralCalcium.toFixed(1) + '</td><td class="highlight">' + residualCalcium.toFixed(1) + '</td><td>mg/kg/die</td></tr>';
tableHtml += '<tr><td>Fosforo</td><td>' + requirements.phosphorus + '</td><td>' + enteralPhosphorus.toFixed(1) + '</td><td class="highlight">' + residualPhosphorus.toFixed(1) + '</td><td>mg/kg/die</td></tr>';
tableHtml += '<tr><td>Magnesio</td><td>' + requirements.magnesium + '</td><td>' + enteralMagnesium.toFixed(2) + '</td><td class="highlight">' + residualMagnesium.toFixed(2) + '</td><td>mEq/kg/die</td></tr>';
tableHtml += '<tr><td>Sodio</td><td>' + requirements.sodium + '</td><td>' + enteralSodium.toFixed(2) + '</td><td class="highlight">' + residualSodium.toFixed(2) + '</td><td>mEq/kg/die</td></tr>';
tableHtml += '<tr><td>Potassio</td><td>' + requirements.potassium + '</td><td>' + enteralPotassium.toFixed(2) + '</td><td class="highlight">' + residualPotassium.toFixed(2) + '</td><td>mEq/kg/die</td></tr>';
tableHtml += '<tr><td>Vitalipid</td><td>' + requirements.vitalipid + '</td><td>0</td><td class="highlight">' + requirements.vitalipid + '</td><td>ml/kg/die</td></tr>';
tableHtml += '<tr><td>Soluvit</td><td>' + requirements.soluvit + '</td><td>0</td><td class="highlight">' + requirements.soluvit + '</td><td>ml/kg/die</td></tr>';
tableHtml += '<tr><td>Peditrace</td><td>' + requirements.peditrace + '</td><td>0</td><td class="highlight">' + requirements.peditrace + '</td><td>ml/kg/die</td></tr>';
tableHtml += '<tr><td>Carnitina</td><td>' + requirements.carnitine + '</td><td>0</td><td class="highlight">' + requirements.carnitine + '</td><td>mg/kg/die</td></tr>';
tableHtml += '<tr class="day-column"><td><strong>ENERGIA TOTALE</strong></td><td><strong>' + totalEnergyRequirement.toFixed(0) + '</strong></td><td><strong>' + enteralEnergy.toFixed(0) + '</strong></td><td class="energy-highlight">' + residualEnergy.toFixed(0) + '</td><td><strong>kcal/kg/die</strong></td></tr>';
tableHtml += '</table>';
document.getElementById('nutritionTable').innerHTML = tableHtml;
document.getElementById('nutritionResults').classList.remove('hidden');
document.getElementById('calculateNutritionBtn').className = 'button calculate-nutrition-completed';
document.getElementById('calculateNutritionBtn').innerHTML = 'FABBISOGNI CALCOLATI ✓';
// RESET del pulsante NPT quando si modificano i fabbisogni
resetParenteralButton();
}
FUNZIONE CALCOLO ELETTROLITI AGGIUNTIVI (DA VERSIONE 17)
function calculateElectrolyteAdditions(calciumNeeded, phosphorusNeeded, magnesiumNeeded, sodiumNeeded, potassiumNeeded, currentWeightKg) {
const additions = {
ca_gluconato: 0,
esafosfina: 0,
mg_sulfate: 0,
nacl: 0,
sodium_acetate: 0,
kcl: 0,
totalVolume: 0,
sodiumSource: 'nacl'
};
Determina il tipo di sodio da utilizzare
const sodiumTypeSelect = document.getElementById('sodiumType');
const selectedSodiumType = sodiumTypeSelect ? sodiumTypeSelect.value : 'nacl';
additions.sodiumSource = selectedSodiumType;
// Calcola fabbisogni totali per paziente
const totalCalciumNeeded = calciumNeeded * currentWeightKg; // mg
const totalPhosphorusNeeded = phosphorusNeeded * currentWeightKg; // mg
const totalMagnesiumNeeded = magnesiumNeeded * currentWeightKg; // mEq
const totalSodiumNeeded = sodiumNeeded * currentWeightKg; // mEq
const totalPotassiumNeeded = potassiumNeeded * currentWeightKg; // mEq
// Calcio Gluconato 10% (840 mg Ca/100ml)
if (totalCalciumNeeded > 0) {
additions.ca_gluconato = totalCalciumNeeded / (parenteralConfig.ca_gluconato.calcium / 100);
}
// Esafosfina (1600 mg P/100ml + 130 mEq Na/100ml)
let sodiumFromEsafosfina = 0;
if (totalPhosphorusNeeded > 0) {
additions.esafosfina = totalPhosphorusNeeded / (parenteralConfig.esafosfina.phosphorus / 100);
sodiumFromEsafosfina = (additions.esafosfina * parenteralConfig.esafosfina.sodium / 100);
}
// Magnesio Solfato (800 mEq Mg/100ml)
if (totalMagnesiumNeeded > 0) {
additions.mg_sulfate = totalMagnesiumNeeded / (parenteralConfig.mg_sulfate.magnesium / 100);
}
// Sodio rimanente (dopo quello da Esafosfina)
const remainingSodium = Math.max(0, totalSodiumNeeded - sodiumFromEsafosfina);
if (remainingSodium > 0) {
if (selectedSodiumType === 'sodium_acetate') {
const concentrationSodiumAcetate = parenteralConfig.sodium_acetate.sodium / 100;
additions.sodium_acetate = remainingSodium / concentrationSodiumAcetate;
} else {
const concentrationNaCl = parenteralConfig.nacl.sodium / 100;
additions.nacl = remainingSodium / concentrationNaCl;
}
}
// Potassio Cloruro (1000 mEq K/100ml)
if (totalPotassiumNeeded > 0) {
additions.kcl = totalPotassiumNeeded / (parenteralConfig.kcl.potassium / 100);
}
// Volume totale degli elettroliti
additions.totalVolume = additions.ca_gluconato + additions.esafosfina + additions.mg_sulfate + additions.nacl + additions.sodium_acetate + additions.kcl;
return additions;
}
FUNZIONE CALCOLO NPT PARENTERALE (DA VERSIONE 17 CON CONTROLLI CLINICI)
function calculateParenteral() {
if (!window.residualNeeds) {
alert('Prima calcolare i fabbisogni nel TAB 3');
return;
}
const parentCurrentWeight = patientData.currentWeight;
const currentWeightKg = parentCurrentWeight / 1000;
const residualNeeds = window.residualNeeds;
CONTROLLI DI SICUREZZA BASATI SU CONFIGURAZIONE CLINICA
const gir = (residualNeeds.carbs * 1000) / 1440; // mg/kg/min
let alerts = [];
if (gir > clinicalConfig.maxGIR) {
alerts.push('⚠️ GIR > ' + clinicalConfig.maxGIR + ' mg/kg/min - Rischio iperglicemia');
}
if (residualNeeds.lipids > clinicalConfig.maxLipids) {
alerts.push('⚠️ Lipidi > ' + clinicalConfig.maxLipids + ' g/kg/die - Monitorare trigliceridi');
}
if (residualNeeds.protein > clinicalConfig.maxProtein) {
alerts.push('⚠️ Proteine > ' + clinicalConfig.maxProtein + ' g/kg/die - Monitorare BUN');
}
// Volume totale residuo richiesto
const totalVolume = Math.round(residualNeeds.liquids * currentWeightKg);
// CALCOLA ELETTROLITI AGGIUNTIVI
const electrolyteAdditions = calculateElectrolyteAdditions(
residualNeeds.calcium,
residualNeeds.phosphorus,
residualNeeds.magnesium,
residualNeeds.sodium,
residualNeeds.potassium,
currentWeightKg
);
// Volume proteine (Trophamine 6%)
const proteinVolume = Math.round((residualNeeds.protein * currentWeightKg * 100) / 6);
// Volume lipidi (Intralipid 20%)
const lipidVolume = Math.round((residualNeeds.lipids * currentWeightKg * 100) / 20);
// Volume vitamine/oligoelementi/carnitina
const vitaminsVolume = (residualNeeds.vitalipid * currentWeightKg) + (residualNeeds.soluvit * currentWeightKg) + (residualNeeds.peditrace * currentWeightKg);
const carnitineVolume = residualNeeds.carnitine > 0 ? (residualNeeds.carnitine * currentWeightKg) / 100 : 0;
// CALCOLO CON GLUCOSIO 50% + ACQUA BIDISTILLATA
const neededGlucose = residualNeeds.carbs * currentWeightKg; // grammi totali di glucosio
const glucose50Volume = (neededGlucose * 100) / 50; // ml di glucosio 50% necessari
// Volume utilizzato
const usedVolume = proteinVolume + lipidVolume + vitaminsVolume + carnitineVolume + glucose50Volume + electrolyteAdditions.totalVolume;
// Volume rimanente = Acqua Bidistillata
const waterVolume = totalVolume - usedVolume;
document.getElementById('calculatedTotalVolume').value = totalVolume + ' ml';
document.getElementById('suggestedGlucose').value = 'Glucosio 50% + Acqua + Elettroliti';
document.getElementById('calculatedProteinVol').value = proteinVolume + ' ml';
document.getElementById('calculatedLipidVol').value = lipidVolume + ' ml';
let resultHtml = '<div class="info">';
resultHtml += '<strong>NPT v3.0 UNIFIED - SISTEMA COMPLETO CON CONTROLLI CLINICI</strong><br>';
resultHtml += '<strong>Peso:</strong> ' + parentCurrentWeight + 'g<br>';
resultHtml += '<strong>GIR:</strong> ' + gir.toFixed(1) + ' mg/kg/min<br>';
resultHtml += '<strong>Enterale:</strong> ' + (enteralData ? enteralData.totalFluids : 0) + ' ml (' + (enteralData ? (enteralData.totalFluids/currentWeightKg).toFixed(1) : 0) + ' ml/kg/die)<br>';
if (enteralData && enteralData.additionalFluids > 0) {
resultHtml += '<strong>→ Latte:</strong> ' + (enteralData.volume || 0) + ' ml, <strong>Altri liquidi:</strong> ' + enteralData.additionalFluids + ' ml<br>';
}
resultHtml += '</div>';
// MOSTRA ALERT CLINICI SE PRESENTI
if (alerts.length > 0) {
resultHtml += '<div class="alert-critical"><strong>ALERT CLINICI:</strong><br>' + alerts.join('<br>') + '</div>';
}
resultHtml += '<table class="results-table">';
resultHtml += '<tr><th>Componente</th><th>Volume (ml)</th></tr>';
if (neededGlucose > 0) {
resultHtml += '<tr><td><strong>Glucosio 50%</strong></td><td><strong>' + glucose50Volume.toFixed(1) + '</strong></td></tr>';
}
resultHtml += '<tr><td><strong>Trophamine 6%</strong></td><td><strong>' + proteinVolume.toFixed(1) + '</strong></td></tr>';
resultHtml += '<tr><td><strong>Intralipid 20%</strong></td><td><strong>' + lipidVolume.toFixed(1) + '</strong></td></tr>';
// ELETTROLITI AGGIUNTIVI
if (electrolyteAdditions.ca_gluconato > 0) {
resultHtml += '<tr><td><strong>Calcio Gluconato 10% (1g/10mL, 0.44 mEq/mL)</strong></td><td><strong>' + electrolyteAdditions.ca_gluconato.toFixed(1) + '</strong></td></tr>';
}
if (electrolyteAdditions.esafosfina > 0) {
resultHtml += '<tr><td><strong>Esafosfina (5g/50mL)</strong></td><td><strong>' + electrolyteAdditions.esafosfina.toFixed(1) + '</strong></td></tr>';
}
if (electrolyteAdditions.mg_sulfate > 0) {
resultHtml += '<tr><td><strong>Magnesio Solfato (2g/10ml, 1.6 mEq/mL)</strong></td><td><strong>' + electrolyteAdditions.mg_sulfate.toFixed(1) + '</strong></td></tr>';
}
if (electrolyteAdditions.nacl > 0) {
resultHtml += '<tr><td><strong>Sodio Cloruro (3mEq/mL)</strong></td><td><strong>' + electrolyteAdditions.nacl.toFixed(1) + '</strong></td></tr>';
}
if (electrolyteAdditions.sodium_acetate > 0) {
resultHtml += '<tr><td><strong>Sodio Acetato (2 mEq/mL) - Alcalinizzante</strong></td><td><strong>' + electrolyteAdditions.sodium_acetate.toFixed(1) + '</strong></td></tr>';
}
if (electrolyteAdditions.kcl > 0) {
resultHtml += '<tr><td><strong>Potassio Cloruro (2 mEq/mL)</strong></td><td><strong>' + electrolyteAdditions.kcl.toFixed(1) + '</strong></td></tr>';
}
// VITAMINE
if (residualNeeds.vitalipid > 0) {
const vitalipidVolume = residualNeeds.vitalipid * currentWeightKg;
resultHtml += '<tr><td><strong>Vitalipid N Infant</strong></td><td><strong>' + vitalipidVolume.toFixed(1) + '</strong></td></tr>';
}
if (residualNeeds.soluvit > 0) {
const soluvitVolume = residualNeeds.soluvit * currentWeightKg;
resultHtml += '<tr><td><strong>Soluvit N</strong></td><td><strong>' + soluvitVolume.toFixed(1) + '</strong></td></tr>';
}
if (residualNeeds.peditrace > 0) {
const peditraceVolume = residualNeeds.peditrace * currentWeightKg;
resultHtml += '<tr><td><strong>Peditrace</strong></td><td><strong>' + peditraceVolume.toFixed(1) + '</strong></td></tr>';
}
// CARNITINA
if (residualNeeds.carnitine > 0) {
resultHtml += '<tr><td><strong>Carnitene (100 mg/ml)</strong></td><td><strong>' + carnitineVolume.toFixed(1) + '</strong></td></tr>';
}
// ACQUA BIDISTILLATA
if (waterVolume > 0) {
resultHtml += '<tr><td><strong>Acqua Bidistillata</strong></td><td><strong>' + waterVolume.toFixed(1) + '</strong></td></tr>';
}
resultHtml += '<tr class="energy-highlight"><td><strong>TOTALE NPT</strong></td><td><strong>' + totalVolume.toFixed(1) + ' ml</strong></td></tr>';
resultHtml += '</table>';
document.getElementById('parenteralTable').innerHTML = resultHtml;
// CREAZIONE RICETTA PER PREPARAZIONE
const deflectorVolume = parseInt(document.getElementById('deflectorVolume').value) || 30;
const totalVolumeWithDeflector = totalVolume + deflectorVolume;
const ratio = totalVolumeWithDeflector / totalVolume;
let preparationHtml = '<div class="info">';
preparationHtml += '<strong>📋 RICETTA PER PREPARAZIONE (Volume deflussore: ' + deflectorVolume + ' ml)</strong><br>';
preparationHtml += '• <strong>Volume prescrizione:</strong> ' + totalVolume + ' ml<br>';
preparationHtml += '• <strong>Volume deflussore:</strong> +' + deflectorVolume + ' ml<br>';
preparationHtml += '• <strong>Volume totale preparazione:</strong> ' + totalVolumeWithDeflector + ' ml';
preparationHtml += '</div>';
preparationHtml += '<table class="results-table">';
preparationHtml += '<tr><th>Componente</th><th>Volume Prescrizione (ml)</th><th>Volume Preparazione (ml)</th></tr>';
if (neededGlucose > 0) {
preparationHtml += '<tr><td><strong>Glucosio 50%</strong></td><td>' + glucose50Volume.toFixed(1) + '</td><td><strong>' + (glucose50Volume * ratio).toFixed(1) + '</strong></td></tr>';
}
preparationHtml += '<tr><td><strong>Trophamine 6%</strong></td><td>' + proteinVolume.toFixed(1) + '</td><td><strong>' + (proteinVolume * ratio).toFixed(1) + '</strong></td></tr>';
preparationHtml += '<tr><td><strong>Intralipid 20%</strong></td><td>' + lipidVolume.toFixed(1) + '</td><td><strong>' + (lipidVolume * ratio).toFixed(1) + '</strong></td></tr>';
if (electrolyteAdditions.ca_gluconato > 0) {
preparationHtml += '<tr><td><strong>Calcio Gluconato 10% (1g/10mL, 0.44 mEq/mL)</strong></td><td>' + electrolyteAdditions.ca_gluconato.toFixed(1) + '</td><td><strong>' + (electrolyteAdditions.ca_gluconato * ratio).toFixed(1) + '</strong></td></tr>';
}
if (electrolyteAdditions.esafosfina > 0) {
preparationHtml += '<tr><td><strong>Esafosfina (5g/50mL)</strong></td><td>' + electrolyteAdditions.esafosfina.toFixed(1) + '</td><td><strong>' + (electrolyteAdditions.esafosfina * ratio).toFixed(1) + '</strong></td></tr>';
}
if (electrolyteAdditions.mg_sulfate > 0) {
preparationHtml += '<tr><td><strong>Magnesio Solfato (2g/10ml, 1.6 mEq/mL)</strong></td><td>' + electrolyteAdditions.mg_sulfate.toFixed(1) + '</td><td><strong>' + (electrolyteAdditions.mg_sulfate * ratio).toFixed(1) + '</strong></td></tr>';
}
if (electrolyteAdditions.nacl > 0) {
preparationHtml += '<tr><td><strong>Sodio Cloruro (3mEq/mL)</strong></td><td>' + electrolyteAdditions.nacl.toFixed(1) + '</td><td><strong>' + (electrolyteAdditions.nacl * ratio).toFixed(1) + '</strong></td></tr>';
}
if (electrolyteAdditions.sodium_acetate > 0) {
preparationHtml += '<tr><td><strong>Sodio Acetato (2 mEq/mL) - Alcalinizzante</strong></td><td>' + electrolyteAdditions.sodium_acetate.toFixed(1) + '</td><td><strong>' + (electrolyteAdditions.sodium_acetate * ratio).toFixed(1) + '</strong></td></tr>';
}
if (electrolyteAdditions.kcl > 0) {
preparationHtml += '<tr><td><strong>Potassio Cloruro (2 mEq/mL)</strong></td><td>' + electrolyteAdditions.kcl.toFixed(1) + '</td><td><strong>' + (electrolyteAdditions.kcl * ratio).toFixed(1) + '</strong></td></tr>';
}
// VITAMINE con denominazioni complete
if (residualNeeds.vitalipid > 0) {
const vitalipidVolume = residualNeeds.vitalipid * currentWeightKg;
preparationHtml += '<tr><td><strong>Vitalipid N Infant</strong></td><td>' + vitalipidVolume.toFixed(1) + '</td><td><strong>' + (vitalipidVolume * ratio).toFixed(1) + '</strong></td></tr>';
}
if (residualNeeds.soluvit > 0) {
const soluvitVolume = residualNeeds.soluvit * currentWeightKg;
preparationHtml += '<tr><td><strong>Soluvit N</strong></td><td>' + soluvitVolume.toFixed(1) + '</td><td><strong>' + (soluvitVolume * ratio).toFixed(1) + '</strong></td></tr>';
}
if (residualNeeds.peditrace > 0) {
const peditraceVolume = residualNeeds.peditrace * currentWeightKg;
preparationHtml += '<tr><td><strong>Peditrace</strong></td><td>' + peditraceVolume.toFixed(1) + '</td><td><strong>' + (peditraceVolume * ratio).toFixed(1) + '</strong></td></tr>';
}
// CARNITINA con denominazione completa
if (residualNeeds.carnitine > 0) {
preparationHtml += '<tr><td><strong>Carnitene (100 mg/ml)</strong></td><td>' + carnitineVolume.toFixed(1) + '</td><td><strong>' + (carnitineVolume * ratio).toFixed(1) + '</strong></td></tr>';
}
if (waterVolume > 0) {
preparationHtml += '<tr><td><strong>Acqua Bidistillata</strong></td><td>' + waterVolume.toFixed(1) + '</td><td><strong>' + (waterVolume * ratio).toFixed(1) + '</strong></td></tr>';
}
preparationHtml += '<tr class="energy-highlight"><td><strong>TOTALE</strong></td><td><strong>' + totalVolume + ' ml</strong></td><td><strong>' + totalVolumeWithDeflector + ' ml</strong></td></tr>';
preparationHtml += '</table>';
document.getElementById('preparationTable').innerHTML = preparationHtml;
document.getElementById('parenteralResults').classList.remove('hidden');
document.getElementById('calculateParenteralBtn').className = 'button config-update-completed';
document.getElementById('calculateParenteralBtn').innerHTML = 'NPT CALCOLATA ✓';
// Salva i dati per il report
window.nptCalculation = {
totalVolume: totalVolume,
waterVolume: waterVolume,
glucose50Volume: glucose50Volume,
proteinVolume: proteinVolume,
lipidVolume: lipidVolume,
gir: gir,
neededGlucose: neededGlucose,
electrolyteAdditions: electrolyteAdditions,
vitaminsVolume: vitaminsVolume,
carnitineVolume: carnitineVolume,
deflectorVolume: deflectorVolume
};
}
FUNZIONI CONFIGURAZIONE (DA VERSIONE 17)
function populateEnteralConfigTable() {
const tbody = document.getElementById('enteralConfigTable');
if (!tbody) return;
tbody.innerHTML = ;
Object.keys(formulaData).forEach(key ⇒ {
const formula = formulaData[key];
const row = tbody.insertRow();
row.innerHTML = '<td class=“component-name”>' + formula.name + '</td>' +
'<td><input type=“number” id=“config_' + key + '_protein” value=“' + formula.protein + '” step=“0.1” oninput=“markConfigChanged(\'enteral\')”></td>' +
'<td><input type=“number” id=“config_' + key + '_carbs” value=“' + formula.carbs + '” step=“0.1” oninput=“markConfigChanged(\'enteral\')”></td>' +
'<td><input type=“number” id=“config_' + key + '_lipids” value=“' + formula.lipids + '” step=“0.1” oninput=“markConfigChanged(\'enteral\')”></td>' +
'<td><input type=“number” id=“config_' + key + '_sodium” value=“' + formula.sodium + '” step=“0.001” oninput=“markConfigChanged(\'enteral\')”></td>' +
'<td><input type=“number” id=“config_' + key + '_potassium” value=“' + formula.potassium + '” step=“0.001” oninput=“markConfigChanged(\'enteral\')”></td>' +
'<td><input type=“number” id=“config_' + key + '_calcium” value=“' + formula.calcium + '” step=“0.1” oninput=“markConfigChanged(\'enteral\')”></td>' +
'<td><input type=“number” id=“config_' + key + '_phosphorus” value=“' + formula.phosphorus + '” step=“0.1” oninput=“markConfigChanged(\'enteral\')”></td>' +
'<td><input type=“number” id=“config_' + key + '_magnesium” value=“' + formula.magnesium + '” step=“0.1” oninput=“markConfigChanged(\'enteral\')”></td>' +
'<td><input type=“number” id=“config_' + key + '_energy” value=“' + formula.energy + '” step=“1” oninput=“markConfigChanged(\'enteral\')”></td>' +
'<td><button class=“button secondary” onclick=“removeEnteralFormula(\
+ key + '\')” style=“padding: 5px 10px; font-size: 12px;”>Rimuovi</button></td>';
});
}
function populateParenteralConfigTable() {
const tbody = document.getElementById('parenteralConfigTable');
if (!tbody) return;
tbody.innerHTML = ;
Object.keys(parenteralConfig).forEach(function(key) {
const component = parenteralConfig[key];
const row = tbody.insertRow();
row.innerHTML = '<td class=“component-name”>' + component.name + '</td>' +
'<td><input type=“number” id=“config_' + key + '_protein” value=“' + component.protein + '” step=“0.1” oninput=“markConfigChanged(\'parenteral\')”></td>' +
'<td><input type=“number” id=“config_' + key + '_carbs” value=“' + component.carbs + '” step=“0.1” oninput=“markConfigChanged(\'parenteral\')”></td>' +
'<td><input type=“number” id=“config_' + key + '_lipids” value=“' + component.lipids + '” step=“0.1” oninput=“markConfigChanged(\'parenteral\')”></td>' +
'<td><input type=“number” id=“config_' + key + '_sodium” value=“' + component.sodium + '” step=“0.1” oninput=“markConfigChanged(\'parenteral\')”></td>' +
'<td><input type=“number” id=“config_' + key + '_potassium” value=“' + component.potassium + '” step=“0.1” oninput=“markConfigChanged(\'parenteral\')”></td>' +
'<td><input type=“number” id=“config_' + key + '_calcium” value=“' + component.calcium + '” step=“1” oninput=“markConfigChanged(\'parenteral\')”></td>' +
'<td><input type=“number” id=“config_' + key + '_phosphorus” value=“' + component.phosphorus + '” step=“1” oninput=“markConfigChanged(\'parenteral\')”></td>' +
'<td><input type=“number” id=“config_' + key + '_magnesium” value=“' + component.magnesium + '” step=“0.1” oninput=“markConfigChanged(\'parenteral\')”></td>' +
'<td><input type=“number” id=“config_' + key + '_energy” value=“' + component.energy + '” step=“1” oninput=“markConfigChanged(\'parenteral\')”></td>' +
'<td><input type=“number” id=“config_' + key + '_water” value=“' + component.water + '” step=“1” oninput=“markConfigChanged(\'parenteral\')”></td>' +
'<td style=“font-size: 11px; color: #7f8c8d; max-width: 200px;”>' + (component.description || 'Componente') + '<br><em>' + (component.notes || 'Note') + '</em></td>' +
'<td><button class=“button secondary” onclick=“removeParenteralComponent(\
+ key + '\')” style=“padding: 5px 10px; font-size: 12px;”>Rimuovi</button></td>';
});
}
function populateDoctorsConfigTable() {
const tbody = document.getElementById('doctorsConfigTable');
if (!tbody) return;
tbody.innerHTML = ;
Object.keys(doctorsData).forEach(key ⇒ {
const doctor = doctorsData[key];
const row = tbody.insertRow();
row.innerHTML = '<td><input type=“text” id=“doctor_' + key + '_name” value=“' + doctor.name + '” style=“width: 100px;” oninput=“markConfigChanged(\'doctors\')”></td>' +
'<td><input type=“text” id=“doctor_' + key + '_surname” value=“' + doctor.surname + '” style=“width: 100px;” oninput=“markConfigChanged(\'doctors\')”></td>' +
'<td><select id=“doctor_' + key + '_title” style=“width: 70px;” oninput=“markConfigChanged(\'doctors\')”>' +
'<option value=“Dr.”' + (doctor.title === 'Dr.' ? ' selected' :
) + '>Dr.</option>' +
'<option value=“Dr.ssa”' + (doctor.title === 'Dr.ssa' ? ' selected' : ) + '>Dr.ssa</option>' +
'<option value=“Prof.”' + (doctor.title === 'Prof.' ? ' selected' :
) + '>Prof.</option>' +
'<option value=“Prof.ssa”' + (doctor.title === 'Prof.ssa' ? ' selected' : ) + '>Prof.ssa</option>' +
'</select></td>' +
'<td style=“font-weight: bold; color: #2c3e50;”>' + doctor.fullName + '</td>' +
'<td><button class=“button secondary” onclick=“removeDoctor(\
+ key + '\')” style=“padding: 5px 10px; font-size: 12px;”>Rimuovi</button></td>';
});
}
function markConfigChanged(configType) {
let buttonId = ;
let buttonText =
;
switch(configType) {
case 'enteral':
buttonId = 'updateEnteralBtn';
buttonText = 'SALVA MODIFICHE ENTERALI';
break;
case 'parenteral':
buttonId = 'updateParenteralBtn';
buttonText = 'SALVA MODIFICHE PARENTERALI';
break;
case 'fortifier':
buttonId = 'updateFortifierBtn';
buttonText = 'SALVA MODIFICHE FORTIFICANTI';
break;
case 'doctors':
buttonId = 'updateDoctorsBtn';
buttonText = 'SALVA MODIFICHE MEDICI';
break;
case 'system':
buttonId = 'updateSystemBtn';
buttonText = 'SALVA PARAMETRI SISTEMA';
break;
}
const button = document.getElementById(buttonId);
if (button) {
button.className = 'button config-update-pending';
button.innerHTML = buttonText;
}
}
function updateEnteralConfig() {
let changesCount = 0;
Object.keys(formulaData).forEach(key ⇒ {
const oldValues = Object.assign({}, formulaData[key]);
const proteinEl = document.getElementById('config_' + key + '_protein');
if (proteinEl) {
formulaData[key].protein = parseFloat(proteinEl.value);
formulaData[key].carbs = parseFloat(document.getElementById('config_' + key + '_carbs').value);
formulaData[key].lipids = parseFloat(document.getElementById('config_' + key + '_lipids').value);
formulaData[key].sodium = parseFloat(document.getElementById('config_' + key + '_sodium').value);
formulaData[key].potassium = parseFloat(document.getElementById('config_' + key + '_potassium').value);
formulaData[key].calcium = parseFloat(document.getElementById('config_' + key + '_calcium').value);
formulaData[key].phosphorus = parseFloat(document.getElementById('config_' + key + '_phosphorus').value);
formulaData[key].magnesium = parseFloat(document.getElementById('config_' + key + '_magnesium').value);
formulaData[key].energy = parseFloat(document.getElementById('config_' + key + '_energy').value);
if (JSON.stringify(oldValues) !== JSON.stringify(formulaData[key])) {
changesCount++;
}
}
});
const button = document.getElementById('updateEnteralBtn');
if (button) {
button.className = 'button config-update-completed';
button.innerHTML = 'ENTERALI SALVATE ✓ (' + changesCount + ' modifiche)';
setTimeout1)