Differenze
Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.
| Prossima revisione | Revisione precedente | ||
| docuneo:programma_npt [2025/07/29 17:47] – creata - modifica esterna 127.0.0.1 | docuneo:programma_npt [2025/08/11 15:34] (versione attuale) – neoadmin | ||
|---|---|---|---|
| Linea 3: | Linea 3: | ||
| <meta charset=" | <meta charset=" | ||
| <meta name=" | <meta name=" | ||
| - | < | + | < |
| + | <script src=" | ||
| + | <script src=" | ||
| + | |||
| + | < | ||
| + | // Simple Barcode Generator - CODE128 - Versione Embedded | ||
| + | window.SimpleBarcode = (function() { | ||
| + | |||
| + | // Patterns per CODE128 | ||
| + | const patterns = { | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | }; | ||
| + | |||
| + | function generateCode128(text) { | ||
| + | // START B (per caratteri ASCII normali) | ||
| + | let result = patterns[' | ||
| + | let checksum = 104; | ||
| + | |||
| + | // Aggiungi ogni carattere | ||
| + | for (let i = 0; i < text.length; | ||
| + | const charCode = text.charCodeAt(i) - 32; // ASCII offset | ||
| + | if (patterns[charCode.toString()]) { | ||
| + | result += patterns[charCode.toString()]; | ||
| + | checksum += charCode * (i + 1); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | // Calcola e aggiungi checksum | ||
| + | checksum = checksum % 103; | ||
| + | result += patterns[checksum.toString()]; | ||
| + | |||
| + | // Aggiungi STOP | ||
| + | result += patterns[' | ||
| + | |||
| + | return result; | ||
| + | } | ||
| + | |||
| + | function drawBarcode(canvas, | ||
| + | const ctx = canvas.getContext(' | ||
| + | const data = generateCode128(text); | ||
| + | |||
| + | // Opzioni default | ||
| + | const opts = { | ||
| + | width: options.width || 2, | ||
| + | height: options.height || 60, | ||
| + | margin: options.margin || 5, | ||
| + | background: options.background || '# | ||
| + | lineColor: options.lineColor || '# | ||
| + | }; | ||
| + | |||
| + | // Calcola dimensioni | ||
| + | const barWidth = opts.width; | ||
| + | const totalWidth = data.length * barWidth + (opts.margin * 2); | ||
| + | const totalHeight = opts.height + (opts.margin * 2); | ||
| + | |||
| + | // Imposta dimensioni canvas | ||
| + | canvas.width = totalWidth; | ||
| + | canvas.height = totalHeight; | ||
| + | |||
| + | // Pulisci canvas | ||
| + | ctx.clearRect(0, | ||
| + | |||
| + | // Background | ||
| + | ctx.fillStyle = opts.background; | ||
| + | ctx.fillRect(0, | ||
| + | |||
| + | // Disegna le barre | ||
| + | ctx.fillStyle = opts.lineColor; | ||
| + | let x = opts.margin; | ||
| + | |||
| + | for (let i = 0; i < data.length; | ||
| + | if (data[i] === ' | ||
| + | ctx.fillRect(x, | ||
| + | } | ||
| + | x += barWidth; | ||
| + | } | ||
| + | |||
| + | console.log(' | ||
| + | } | ||
| + | |||
| + | return { | ||
| + | generate: drawBarcode | ||
| + | }; | ||
| + | })(); | ||
| + | </ | ||
| + | | ||
| < | < | ||
| + | * { | ||
| + | font-family: | ||
| + | } | ||
| body { | body { | ||
| - | | + | |
| - | margin: 0; | + | margin: 0; |
| - | padding: 20px; | + | padding: 20px; |
| - | background-color: | + | background-color: |
| - | } | + | } |
| .container { | .container { | ||
| Linea 22: | Linea 131: | ||
| h1 { | h1 { | ||
| + | |||
| + | text-align: center; | ||
| + | color: white; | ||
| + | background: linear-gradient(135deg, | ||
| + | border: none; | ||
| + | padding: 20px; | ||
| + | border-radius: | ||
| + | margin-bottom: | ||
| + | text-shadow: | ||
| + | position: relative; | ||
| + | overflow: hidden; | ||
| + | } | ||
| + | |||
| + | h1::before { | ||
| + | content: " | ||
| + | font-size: 30px; | ||
| + | position: absolute; | ||
| + | left: 20px; | ||
| + | top: 50%; | ||
| + | transform: translateY(-50%); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | .version-info { | ||
| text-align: center; | text-align: center; | ||
| - | | + | |
| - | | + | |
| - | | + | |
| } | } | ||
| Linea 165: | Linea 298: | ||
| } | } | ||
| - | .phase-transition | + | .phase-transizione |
| background-color: | background-color: | ||
| color: #856404; | color: #856404; | ||
| } | } | ||
| - | .phase-stabilization | + | .phase-stabilizzazione |
| background-color: | background-color: | ||
| color: #0c5460; | color: #0c5460; | ||
| } | } | ||
| - | .phase-growth | + | .phase-crescita |
| background-color: | background-color: | ||
| color: #155724; | color: #155724; | ||
| Linea 213: | Linea 346: | ||
| } | } | ||
| - | /* CSS TAB ORIZZONTALI | + | /* CSS TAB ORIZZONTALI |
| .tabs { | .tabs { | ||
| display: flex; | display: flex; | ||
| Linea 222: | Linea 355: | ||
| .tab { | .tab { | ||
| - | padding: | + | padding: |
| background-color: | background-color: | ||
| border: 1px solid #ddd; | border: 1px solid #ddd; | ||
| Linea 230: | Linea 363: | ||
| transition: all 0.3s ease; | transition: all 0.3s ease; | ||
| text-align: center; | text-align: center; | ||
| - | min-width: | + | min-width: |
| flex: 1; | flex: 1; | ||
| - | max-width: | + | max-width: |
| + | font-size: 14px; | ||
| + | font-weight: | ||
| + | } | ||
| + | .config-tab { | ||
| + | min-width: 50px !important; | ||
| + | max-width: 50px !important; | ||
| + | width: 50px !important; | ||
| + | flex: 0 0 50px !important; | ||
| + | font-size: 24px !important; | ||
| + | padding: 12px 8px !important; | ||
| + | transform: none !important; | ||
| + | } | ||
| + | |||
| + | .config-tab: | ||
| + | background-color: | ||
| + | transform: none !important; | ||
| + | } | ||
| + | |||
| + | .config-tab.active { | ||
| + | background-color: | ||
| + | color: white; | ||
| + | transform: none !important; | ||
| } | } | ||
| Linea 337: | Linea 492: | ||
| text-align: left !important; | text-align: left !important; | ||
| } | } | ||
| + | |||
| + | /* SEZIONE NUOVA PER TAB 5 CONFIGURAZIONE AVANZATA */ | ||
| + | .config-advanced { | ||
| + | background-color: | ||
| + | border: 2px solid #17a2b8; | ||
| + | border-radius: | ||
| + | padding: 20px; | ||
| + | margin: 20px 0; | ||
| + | } | ||
| + | |||
| + | .config-advanced h3 { | ||
| + | color: #0c5460; | ||
| + | margin-top: 0; | ||
| + | border-bottom: | ||
| + | padding-bottom: | ||
| + | } | ||
| + | |||
| + | .monitoring-table { | ||
| + | width: 100%; | ||
| + | border-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: | ||
| + | color: white; | ||
| + | } | ||
| + | |||
| + | .alert-critical { | ||
| + | background-color: | ||
| + | color: white; | ||
| + | padding: 15px; | ||
| + | border-radius: | ||
| + | margin: 15px 0; | ||
| + | font-weight: | ||
| + | } | ||
| + | |||
| + | /* REPORT SECTION */ | ||
| + | .report-output { | ||
| + | border: 2px solid #3498db; | ||
| + | border-radius: | ||
| + | padding: 30px; | ||
| + | margin-top: 30px; | ||
| + | background-color: | ||
| + | font-family: | ||
| + | line-height: | ||
| + | } | ||
| + | |||
| + | .medical-header { | ||
| + | text-align: center; | ||
| + | border-bottom: | ||
| + | padding-bottom: | ||
| + | margin-bottom: | ||
| + | } | ||
| + | |||
| + | .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; | ||
| + | } | ||
| + | | ||
| + | | ||
| + | } | ||
| + | |||
| + | /* NUOVA INTESTAZIONE MEDICA ASST LECCO */ | ||
| + | .medical-header-table { | ||
| + | width: 100%; | ||
| + | border-collapse: | ||
| + | border: 2px solid #2c3e50; | ||
| + | margin-bottom: | ||
| + | } | ||
| + | |||
| + | .medical-header-table td { | ||
| + | border: 1px solid #2c3e50; | ||
| + | padding: 10px; | ||
| + | vertical-align: | ||
| + | } | ||
| + | |||
| + | .medical-header-left { | ||
| + | width: 45%; | ||
| + | background-color: | ||
| + | } | ||
| + | |||
| + | .medical-header-center { | ||
| + | width: 30%; | ||
| + | text-align: center; | ||
| + | background-color: | ||
| + | } | ||
| + | |||
| + | .medical-header-right { | ||
| + | width: 25%; | ||
| + | text-align: center; | ||
| + | background-color: | ||
| + | } | ||
| + | |||
| + | .medical-header-left h2 { | ||
| + | font-size: 14px; | ||
| + | font-weight: | ||
| + | color: #2c3e50; | ||
| + | margin: 0 0 5px 0; | ||
| + | } | ||
| + | |||
| + | .medical-header-left h3 { | ||
| + | font-size: 12px; | ||
| + | color: #34495e; | ||
| + | margin: 0 0 5px 0; | ||
| + | } | ||
| + | |||
| + | .medical-header-left p { | ||
| + | font-size: 11px; | ||
| + | color: #7f8c8d; | ||
| + | margin: 0; | ||
| + | } | ||
| + | |||
| + | /* NUOVA INTESTAZIONE MEDICA ASST LECCO */ | ||
| + | .medical-header-table { | ||
| + | width: 100%; | ||
| + | border-collapse: | ||
| + | border: 2px solid #2c3e50; | ||
| + | margin-bottom: | ||
| + | } | ||
| + | |||
| + | .medical-header-table td { | ||
| + | border: 1px solid #2c3e50; | ||
| + | padding: 10px; | ||
| + | vertical-align: | ||
| + | } | ||
| + | |||
| + | .medical-header-left { | ||
| + | width: 45%; | ||
| + | background-color: | ||
| + | } | ||
| + | |||
| + | .medical-header-center { | ||
| + | width: 30%; | ||
| + | text-align: center; | ||
| + | background-color: | ||
| + | } | ||
| + | |||
| + | .medical-header-right { | ||
| + | width: 25%; | ||
| + | text-align: center; | ||
| + | background-color: | ||
| + | } | ||
| + | |||
| + | .medical-header-left h2 { | ||
| + | font-size: 14px; | ||
| + | font-weight: | ||
| + | color: #2c3e50; | ||
| + | margin: 0 0 5px 0; | ||
| + | } | ||
| + | |||
| + | .medical-header-left h3 { | ||
| + | font-size: 12px; | ||
| + | color: #34495e; | ||
| + | margin: 0 0 5px 0; | ||
| + | } | ||
| + | |||
| + | .medical-header-left p { | ||
| + | font-size: 11px; | ||
| + | color: #7f8c8d; | ||
| + | margin: 0; | ||
| + | } | ||
| + | |||
| + | /* STILI KNOWLEDGE BASE */ | ||
| + | .knowledge-section { | ||
| + | display: none; | ||
| + | } | ||
| + | |||
| + | .knowledge-section.active { | ||
| + | display: block; | ||
| + | } | ||
| + | |||
| + | .knowledge-tooltip { | ||
| + | position: absolute; | ||
| + | background-color: | ||
| + | color: white; | ||
| + | padding: 10px; | ||
| + | border-radius: | ||
| + | font-size: 12px; | ||
| + | max-width: 300px; | ||
| + | z-index: 1000; | ||
| + | box-shadow: 0 2px 10px rgba(0, | ||
| + | animation: fadeIn 0.3s ease-in-out; | ||
| + | } | ||
| + | |||
| + | @keyframes fadeIn { | ||
| + | from { opacity: 0; transform: translateY(-10px); | ||
| + | to { opacity: 1; transform: translateY(0); | ||
| + | } | ||
| + | |||
| + | .knowledge-section h3 { | ||
| + | color: #2c3e50; | ||
| + | border-bottom: | ||
| + | padding-bottom: | ||
| + | margin-bottom: | ||
| + | } | ||
| + | |||
| + | .knowledge-section h4 { | ||
| + | color: #34495e; | ||
| + | margin-top: 20px; | ||
| + | margin-bottom: | ||
| + | } | ||
| + | |||
| + | /* STILI SPECIFICI PER ETICHETTA SACCA */ | ||
| + | .label-section { | ||
| + | border: 3px solid #2c3e50; | ||
| + | background-color: | ||
| + | padding: 15px; | ||
| + | margin: 15px 0; | ||
| + | border-radius: | ||
| + | } | ||
| + | |||
| + | .label-patient-id { | ||
| + | border: 4px solid #d32f2f; | ||
| + | background-color: | ||
| + | padding: 15px; | ||
| + | margin: 15px 0; | ||
| + | text-align: center; | ||
| + | border-radius: | ||
| + | } | ||
| + | |||
| + | .label-content { | ||
| + | border: 3px solid #388e3c; | ||
| + | background-color: | ||
| + | padding: 15px; | ||
| + | margin: 15px 0; | ||
| + | border-radius: | ||
| + | } | ||
| + | |||
| + | .label-header { | ||
| + | text-align: center; | ||
| + | border-bottom: | ||
| + | padding-bottom: | ||
| + | margin-bottom: | ||
| + | } | ||
| + | |||
| + | .label-volume-total { | ||
| + | background-color: | ||
| + | color: white; | ||
| + | font-weight: | ||
| + | font-size: 16px; | ||
| + | } | ||
| + | |||
| </ | </ | ||
| </ | </ | ||
| Linea 342: | Linea 775: | ||
| <div class=" | <div class=" | ||
| - | <h1>Programma NPT Neonatale v2.0</ | + | <h1>Gestione della Nutrizione del Neonato (GNN v3.0)</h1> |
| + | < | ||
| + | < | ||
| + | </div> | ||
| | | ||
| <!-- TAB ORIZZONTALI CORRETTI --> | <!-- TAB ORIZZONTALI CORRETTI --> | ||
| <div class=" | <div class=" | ||
| - | | + | |
| - | <span style=" | + | <span style=" |
| - | </ | + | </ |
| - | <div class=" | + | |
| - | <span style=" | + | <!-- SEZIONE CONFIGURAZIONE COMPONENTI (DA VERSIONE 17) --> |
| - | </ | + | |
| - | <div class=" | + | <span style=" |
| - | <span style=" | + | </ |
| - | </ | + | <div class=" |
| - | <div class=" | + | <span style=" |
| - | <span style=" | + | </ |
| - | </ | + | <div class=" |
| - | <div class=" | + | <span style=" |
| - | <span style=" | + | </ |
| - | </ | + | <div class=" |
| + | <span style=" | ||
| + | </ | ||
| + | <div class=" | ||
| + | | ||
| + | </ | ||
| + | <div class=" | ||
| + | <span style=" | ||
| + | | ||
| </ | </ | ||
| - | <!-- TAB 1: DATI PAZIENTE --> | + | <!-- TAB 1: DATI PAZIENTE |
| <div id=" | <div id=" | ||
| - | | + | <div class=" |
| - | < | + | < |
| - | < | + | < |
| + | | ||
| + | </ | ||
| + | <div class=" | ||
| + | < | ||
| + | <div class=" | ||
| + | <div class=" | ||
| + | <div class=" | ||
| + | <label for=" | ||
| + | <input type=" | ||
| + | </ | ||
| + | <div class=" | ||
| + | <label for=" | ||
| + | <select id=" | ||
| + | <!-- Popolato dinamicamente --> | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | <div class=" | ||
| + | <div class=" | ||
| + | < | ||
| + | • La data viene impostata automaticamente ad oggi< | ||
| + | • Selezionare il medico responsabile della prescrizione< | ||
| + | • Questi dati appariranno nel riepilogo finale | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| </ | </ | ||
| + | | ||
| <div class=" | <div class=" | ||
| < | < | ||
| <div class=" | <div class=" | ||
| <div class=" | <div class=" | ||
| + | <div class=" | ||
| + | <label for=" | ||
| + | <input type=" | ||
| + | </ | ||
| <div class=" | <div class=" | ||
| <label for=" | <label for=" | ||
| Linea 385: | Linea 860: | ||
| <input type=" | <input type=" | ||
| </ | </ | ||
| + | |||
| + | <div class=" | ||
| + | <label for=" | ||
| + | <div style=" | ||
| + | <input type=" | ||
| + | < | ||
| + | <input type=" | ||
| + | < | ||
| + | <span style=" | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | <div class=" | ||
| + | <label for=" | ||
| + | <div style=" | ||
| + | <input type=" | ||
| + | <span style=" | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| </ | </ | ||
| <div class=" | <div class=" | ||
| Linea 402: | Linea 901: | ||
| <label for=" | <label for=" | ||
| <input type=" | <input type=" | ||
| + | </ | ||
| + | <div class=" | ||
| + | <label for=" | ||
| + | <input type=" | ||
| </ | </ | ||
| <div class=" | <div class=" | ||
| Linea 413: | Linea 916: | ||
| < | < | ||
| < | < | ||
| + | < | ||
| < | < | ||
| </ | </ | ||
| Linea 427: | Linea 931: | ||
| </ | </ | ||
| - | <!-- TAB 2: NUTRIZIONE ENTERALE --> | + | <!-- TAB 2: NUTRIZIONE ENTERALE |
| <div id=" | <div id=" | ||
| <div class=" | <div class=" | ||
| Linea 517: | Linea 1021: | ||
| </ | </ | ||
| - | <button id=" | + | <button id=" |
| </ | </ | ||
| Linea 526: | Linea 1030: | ||
| </ | </ | ||
| - | <!-- TAB 3: CALCOLO FABBISOGNI --> | + | <!-- TAB 3: CALCOLO FABBISOGNI |
| <div id=" | <div id=" | ||
| <div class=" | <div class=" | ||
| Linea 566: | Linea 1070: | ||
| </ | </ | ||
| <div class=" | <div class=" | ||
| - | <label for=" | + | |
| + | <select id=" | ||
| + | <option value=" | ||
| + | <option value=" | ||
| + | </ | ||
| + | </ | ||
| + | <div class=" | ||
| + | | ||
| <input type=" | <input type=" | ||
| </ | </ | ||
| Linea 576: | Linea 1087: | ||
| <div class=" | <div class=" | ||
| <div class=" | <div class=" | ||
| - | <label for=" | + | <label for=" |
| <input type=" | <input type=" | ||
| </ | </ | ||
| Linea 584: | Linea 1095: | ||
| </ | </ | ||
| <div class=" | <div class=" | ||
| - | <label for=" | + | <label for=" |
| - | <input type=" | + | <input type=" |
| </ | </ | ||
| <div class=" | <div class=" | ||
| <label for=" | <label for=" | ||
| <input type=" | <input type=" | ||
| + | </ | ||
| + | <div class=" | ||
| + | <label for=" | ||
| + | <select id=" | ||
| + | <option value=" | ||
| + | <option value=" | ||
| + | </ | ||
| + | </ | ||
| + | <div id=" | ||
| + | <!-- Popolato dinamicamente --> | ||
| </ | </ | ||
| <div class=" | <div class=" | ||
| Linea 600: | Linea 1121: | ||
| <div class=" | <div class=" | ||
| <div class=" | <div class=" | ||
| - | < | + | < |
| <div class=" | <div class=" | ||
| - | <label for=" | + | <label for=" |
| <input type=" | <input type=" | ||
| </ | </ | ||
| <div class=" | <div class=" | ||
| - | <label for=" | + | <label for=" |
| <input type=" | <input type=" | ||
| </ | </ | ||
| <div class=" | <div class=" | ||
| - | <label for=" | + | <label for=" |
| <input type=" | <input type=" | ||
| + | </ | ||
| + | <div class=" | ||
| + | <label for=" | ||
| + | <input type=" | ||
| </ | </ | ||
| </ | </ | ||
| Linea 617: | Linea 1142: | ||
| <div class=" | <div class=" | ||
| < | < | ||
| - | < | + | < |
| < | < | ||
| - | < | + | < |
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| </ | </ | ||
| </ | </ | ||
| Linea 631: | Linea 1160: | ||
| </ | </ | ||
| - | <!-- TAB 4: NUTRIZIONE PARENTERALE --> | + | <!-- TAB 4: NUTRIZIONE PARENTERALE |
| <div id=" | <div id=" | ||
| <div class=" | <div class=" | ||
| Linea 667: | Linea 1196: | ||
| <div id=" | <div id=" | ||
| - | <h3>Composizione NPT Finale</h3> | + | <h3>Prescrizione parenterale</h3> |
| <div id=" | <div id=" | ||
| + | | ||
| + | <h3 style=" | ||
| + | <div id=" | ||
| + | | ||
| + | |||
| + | <div style=" | ||
| + | <button class=" | ||
| + | <button class=" | ||
| + | <button class=" | ||
| + | </ | ||
| </ | </ | ||
| </ | </ | ||
| - | <!-- TAB 5: CONFIGURAZIONE --> | + | |
| + | <!-- TAB 5: REPORT FINALE (SPOSTATO DA TAB 6) --> | ||
| + | <div id=" | ||
| + | <div class=" | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | <!-- Banner stato prescrizione --> | ||
| + | <div id=" | ||
| + | <!-- Popolato dinamicamente --> | ||
| + | </ | ||
| + | <div class=" | ||
| + | < | ||
| + | <button class=" | ||
| + | <button class=" | ||
| + | <button class=" | ||
| + | <button class=" | ||
| + | <!-- Report appare subito qui sotto i pulsanti --> | ||
| + | <div id=" | ||
| + | </ | ||
| + | |||
| + | <!-- SEZIONE 2A: VALIDAZIONE FARMACISTA --> | ||
| + | <div class=" | ||
| + | < | ||
| + | <div class=" | ||
| + | < | ||
| + | Il farmacista deve validare la prescrizione medica prima dell' | ||
| + | </ | ||
| + | |||
| + | <div class=" | ||
| + | <div class=" | ||
| + | <div class=" | ||
| + | <label for=" | ||
| + | <select id=" | ||
| + | <option value=""> | ||
| + | <!-- Popolato dinamicamente da pharmacistsData --> | ||
| + | </ | ||
| + | </ | ||
| + | <div class=" | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | <div class=" | ||
| + | <button class=" | ||
| + | 📝 VALIDA PRESCRIZIONE | ||
| + | </ | ||
| + | <div id=" | ||
| + | <!-- Status validazione --> | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | <!-- SEZIONE 2B: ALLESTIMENTO TECNICI --> | ||
| + | <div class=" | ||
| + | < | ||
| + | <div class=" | ||
| + | < | ||
| + | Due tecnici qualificati preparano la sacca NPT secondo protocolli GMP con controllo incrociato. | ||
| + | </ | ||
| + | |||
| + | <div class=" | ||
| + | <div class=" | ||
| + | <div class=" | ||
| + | <label for=" | ||
| + | <select id=" | ||
| + | <option value=""> | ||
| + | <!-- Popolato dinamicamente da technicianData --> | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | <div class=" | ||
| + | <label for=" | ||
| + | <select id=" | ||
| + | <option value=""> | ||
| + | <!-- Popolato dinamicamente da technicianData --> | ||
| + | </ | ||
| + | </ | ||
| + | <div class=" | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | <div class=" | ||
| + | <button class=" | ||
| + | 🧪 CONFERMA ALLESTIMENTO | ||
| + | </ | ||
| + | < | ||
| + | 💾 ARCHIVIA PREPARAZIONE (JSON) | ||
| + | </ | ||
| + | <button class=" | ||
| + | 🔒 BLOCCA PRESCRIZIONE | ||
| + | </ | ||
| + | <div id=" | ||
| + | <!-- Status preparazione --> | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | <!-- SEZIONE ARCHIVIAZIONE MENSILE --> | ||
| + | |||
| + | | ||
| + | < | ||
| + | <div class=" | ||
| + | < | ||
| + | Genera report Excel mensile con tutte le preparazioni NPT archiviate come JSON. | ||
| + | </ | ||
| + | |||
| + | <div class=" | ||
| + | <div class=" | ||
| + | <div class=" | ||
| + | <label for=" | ||
| + | <input type=" | ||
| + | </ | ||
| + | <div class=" | ||
| + | <label for=" | ||
| + | <input type=" | ||
| + | </ | ||
| + | <div class=" | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | <div class=" | ||
| + | <button class=" | ||
| + | 📊 GENERA EXCEL MENSILE | ||
| + | </ | ||
| + | <button class=" | ||
| + | 👁️ ANTEPRIMA DATI | ||
| + | </ | ||
| + | |||
| + | <div id=" | ||
| + | <!-- Statistiche mensili popolate dinamicamente --> | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | |||
| + | </ | ||
| + | |||
| + | |||
| + | <!-- TAB 6: KNOWLEDGE BASE --> | ||
| + | <div id=" | ||
| + | <div class=" | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | <!-- NAVIGAZIONE INTERNA KNOWLEDGE BASE --> | ||
| + | <div class=" | ||
| + | <div class=" | ||
| + | 🧮 Regole Calcolo | ||
| + | </ | ||
| + | <div class=" | ||
| + | 👩⚕️ Linee Guida | ||
| + | </ | ||
| + | <div class=" | ||
| + | 🚨 Sistema Alert | ||
| + | </ | ||
| + | <div class=" | ||
| + | 📖 Evidenze | ||
| + | </ | ||
| + | <div class=" | ||
| + | 🎯 Decision Support | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | <!-- SEZIONE 1: REGOLE DI CALCOLO --> | ||
| + | <div id=" | ||
| + | <div class=" | ||
| + | < | ||
| + | |||
| + | <div class=" | ||
| + | < | ||
| + | |||
| + | <div class=" | ||
| + | <div class=" | ||
| + | < | ||
| + | <div class=" | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | <div class=" | ||
| + | < | ||
| + | < | ||
| + | • < 600 mOsm/L: Accesso periferico possibile< | ||
| + | • 600-900 mOsm/L: CVC raccomandato< | ||
| + | • > 900 mOsm/L: Solo CVC (soluzione ipertonica) | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | <div class=" | ||
| + | < | ||
| + | <div class=" | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | <div class=" | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | <div class=" | ||
| + | < | ||
| + | <div style=" | ||
| + | <table class=" | ||
| + | < | ||
| + | < | ||
| + | <th style=" | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | <!-- SEZIONE 2: LINEE GUIDA CLINICHE (placeholder per ora) --> | ||
| + | <div id=" | ||
| + | <div class=" | ||
| + | < | ||
| + | <div class=" | ||
| + | < | ||
| + | Questa sezione conterrà protocolli per età, patologie e tempistiche. | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | <!-- SEZIONE 3: SISTEMA ALERT (placeholder per ora) --> | ||
| + | <div id=" | ||
| + | <div class=" | ||
| + | < | ||
| + | <div class=" | ||
| + | < | ||
| + | Questa sezione spiegherà soglie di allarme e azioni consigliate. | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | <!-- SEZIONE 4: EVIDENZE (placeholder per ora) --> | ||
| + | <div id=" | ||
| + | <div class=" | ||
| + | < | ||
| + | <div class=" | ||
| + | < | ||
| + | Questa sezione conterrà bibliografia e riferimenti scientifici. | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | <!-- SEZIONE | ||
| + | <div id=" | ||
| + | <div class=" | ||
| + | < | ||
| + | <div class=" | ||
| + | < | ||
| + | Questa sezione conterrà configurazione regole e simulatore. | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | </ | ||
| + | |||
| + | <!-- TAB 6: CONFIGURAZIONE | ||
| <div id=" | <div id=" | ||
| <div class=" | <div class=" | ||
| - | < | + | < |
| - | < | + | < |
| + | </ | ||
| + | <div class=" | ||
| + | < | ||
| + | <div class=" | ||
| + | <div class=" | ||
| + | <div class=" | ||
| + | <label for=" | ||
| + | <input type=" | ||
| + | </ | ||
| + | <div class=" | ||
| + | < | ||
| + | • Volume perso nel deflussore durante la preparazione< | ||
| + | • Viene aggiunto automaticamente alla ricetta di preparazione< | ||
| + | • Valore standard: 30 ml (modificabile) | ||
| + | </ | ||
| + | </ | ||
| + | <div class=" | ||
| + | <button id=" | ||
| + | </ | ||
| + | </ | ||
| </ | </ | ||
| | | ||
| Linea 709: | Linea 1590: | ||
| <div class=" | <div class=" | ||
| <button class=" | <button class=" | ||
| - | </ | ||
| - | </ | ||
| - | | ||
| - | <!-- Form per aggiungere nuova formula enterale --> | ||
| - | <div id=" | ||
| - | < | ||
| - | <div class=" | ||
| - | <div class=" | ||
| - | <div class=" | ||
| - | <label for=" | ||
| - | <input type=" | ||
| - | </ | ||
| - | <div class=" | ||
| - | <label for=" | ||
| - | <input type=" | ||
| - | </ | ||
| - | <div class=" | ||
| - | <label for=" | ||
| - | <input type=" | ||
| - | </ | ||
| - | <div class=" | ||
| - | <label for=" | ||
| - | <input type=" | ||
| - | </ | ||
| - | <div class=" | ||
| - | <label for=" | ||
| - | <input type=" | ||
| - | </ | ||
| - | </ | ||
| - | <div class=" | ||
| - | <div class=" | ||
| - | <label for=" | ||
| - | <input type=" | ||
| - | </ | ||
| - | <div class=" | ||
| - | <label for=" | ||
| - | <input type=" | ||
| - | </ | ||
| - | <div class=" | ||
| - | <label for=" | ||
| - | <input type=" | ||
| - | </ | ||
| - | <div class=" | ||
| - | <label for=" | ||
| - | <input type=" | ||
| - | </ | ||
| - | <div class=" | ||
| - | <label for=" | ||
| - | <input type=" | ||
| - | </ | ||
| - | <div class=" | ||
| - | <label for=" | ||
| - | <input type=" | ||
| - | </ | ||
| - | </ | ||
| - | </ | ||
| - | <div class=" | ||
| - | <div class=" | ||
| - | <button class=" | ||
| - | <button class=" | ||
| - | </ | ||
| </ | </ | ||
| </ | </ | ||
| Linea 827: | Linea 1647: | ||
| <table class=" | <table class=" | ||
| < | < | ||
| - | | + | |
| - | <th style=" | + | <th style=" |
| - | < | + | < |
| - | < | + | < |
| - | < | + | < |
| - | < | + | < |
| - | < | + | < |
| - | < | + | < |
| - | < | + | < |
| - | < | + | < |
| - | < | + | < |
| - | < | + | < |
| - | <th style=" | + | < |
| - | < | + | |
| - | </ | + | < |
| - | </ | + | </ |
| + | </ | ||
| <tbody id=" | <tbody id=" | ||
| <!-- Popolato dinamicamente --> | <!-- Popolato dinamicamente --> | ||
| Linea 859: | Linea 1680: | ||
| <div class=" | <div class=" | ||
| - | <h2>Vitamine e Oligoelementi</h2> | + | <h2>Lista Medici Prescrittori</h2> |
| + | <div class=" | ||
| + | < | ||
| + | Gestisci la lista dei medici prescrittori. Le modifiche si applicano automaticamente alla dropdown del TAB 1. | ||
| + | </div> | ||
| <div style=" | <div style=" | ||
| <table class=" | <table class=" | ||
| < | < | ||
| <tr> | <tr> | ||
| - | <th style=" | + | <th style=" |
| - | <th>Dose Pediatrica</ | + | < |
| - | <th>Dose Max</ | + | < |
| - | < | + | <th style=" |
| - | <th style=" | + | < |
| </tr> | </tr> | ||
| </ | </ | ||
| - | < | + | < |
| + | <!-- Popolato dinamicamente --> | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | <div class=" | ||
| + | <div class=" | ||
| + | <button id=" | ||
| + | </ | ||
| + | <div class=" | ||
| + | <button class=" | ||
| + | </ | ||
| + | </ | ||
| + | <div class=" | ||
| + | < | ||
| + | <div class=" | ||
| + | < | ||
| + | Gestisci la lista delle infermiere del reparto. Le modifiche si applicano automaticamente. | ||
| + | </ | ||
| + | <div style=" | ||
| + | <table class=" | ||
| + | <thead> | ||
| <tr> | <tr> | ||
| - | <td class="component-name">Vitalipid N Infant</td> | + | <th style="min-width: 120px;">Nome</th> |
| - | <td>4 ml/ | + | <th style=" |
| - | < | + | <th style="min-width: 80px;">Titolo</th> |
| - | <td>9 ml H₂O/ | + | <th style=" |
| - | < | + | <th>Azioni</th> |
| - | </ | + | |
| - | <tr> | + | |
| - | <td class="component-name">Soluvit N</td> | + | |
| - | <td>5 ml/ | + | |
| - | <td>5 ml/ | + | |
| - | < | + | |
| - | < | + | |
| - | </ | + | |
| - | <tr> | + | |
| - | <td class=" | + | |
| - | <td>1 ml/ | + | |
| - | < | + | |
| - | < | + | |
| - | <td style=" | + | |
| </tr> | </tr> | ||
| + | </ | ||
| + | <tbody id=" | ||
| + | <!-- Popolato dinamicamente --> | ||
| </ | </ | ||
| </ | </ | ||
| + | </ | ||
| + | <div class=" | ||
| + | <div class=" | ||
| + | <button id=" | ||
| + | </ | ||
| + | <div class=" | ||
| + | <button class=" | ||
| + | </ | ||
| </ | </ | ||
| </ | </ | ||
| <div class=" | <div class=" | ||
| - | <h2>Gestione Configurazioni</h2> | + | <h2>Lista Farmacisti</h2> |
| + | <div class=" | ||
| + | < | ||
| + | Gestisci la lista dei farmacisti ospedalieri. Le modifiche si applicano automaticamente. | ||
| + | </ | ||
| + | <div style=" | ||
| + | <table class=" | ||
| + | < | ||
| + | < | ||
| + | <th style=" | ||
| + | <th style=" | ||
| + | <th style=" | ||
| + | <th style=" | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | <tbody id=" | ||
| + | <!-- Popolato dinamicamente --> | ||
| + | </ | ||
| + | </ | ||
| + | </div> | ||
| <div class=" | <div class=" | ||
| <div class=" | <div class=" | ||
| - | <button class=" | + | < |
| - | <p style=" | + | |
| </ | </ | ||
| <div class=" | <div class=" | ||
| - | | + | <button class=" |
| - | | + | |
| - | <p style=" | + | |
| </ | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | <div class=" | ||
| + | < | ||
| + | <div class=" | ||
| + | < | ||
| + | Gestisci la lista dei tecnici di farmacia. Le modifiche si applicano automaticamente. | ||
| + | </ | ||
| + | <div style=" | ||
| + | <table class=" | ||
| + | < | ||
| + | <tr> | ||
| + | <th style=" | ||
| + | <th style=" | ||
| + | <th style=" | ||
| + | <th style=" | ||
| + | < | ||
| + | </tr> | ||
| + | </ | ||
| + | <tbody id=" | ||
| + | <!-- Popolato dinamicamente --> | ||
| + | </ | ||
| + | </ | ||
| </ | </ | ||
| <div class=" | <div class=" | ||
| <div class=" | <div class=" | ||
| - | < | + | < |
| - | <p style=" | + | |
| </ | </ | ||
| <div class=" | <div class=" | ||
| - | <div id="storageStatus" style=" | + | <button class=" |
| - | <strong>💾 Salvataggio | + | </div> |
| - | | + | </ |
| + | </ | ||
| + | </ | ||
| + | |||
| + | <!-- SEZIONE CONFIGURAZIONE CLINICA AVANZATA (NOVITÀ) --> | ||
| + | <div class=" | ||
| + | < | ||
| + | |||
| + | <div class=" | ||
| + | < | ||
| + | <div class=" | ||
| + | <div class=" | ||
| + | <div class=" | ||
| + | <label for=" | ||
| + | <input type=" | ||
| + | < | ||
| + | </ | ||
| + | <div class=" | ||
| + | <label for=" | ||
| + | <input type=" | ||
| + | <span style=" | ||
| + | </div> | ||
| + | <div class=" | ||
| + | <label for=" | ||
| + | <input type=" | ||
| + | <span style=" | ||
| + | </ | ||
| + | </ | ||
| + | <div class=" | ||
| + | <div class=" | ||
| + | <label for=" | ||
| + | <input type=" | ||
| + | <span style=" | ||
| + | </ | ||
| + | <div class=" | ||
| + | <label for=" | ||
| + | <input type=" | ||
| + | <span style=" | ||
| + | </ | ||
| + | <div class=" | ||
| + | <label for=" | ||
| + | <input type=" | ||
| + | <span style=" | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | <button class=" | ||
| + | </ | ||
| + | |||
| + | <div class=" | ||
| + | < | ||
| + | <table class=" | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | <td>2 volte/ | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | <div class=" | ||
| + | < | ||
| + | <div class=" | ||
| + | < | ||
| + | • Glicemia > 250 mg/dL o < 40 mg/ | ||
| + | • Trigliceridi > 400 mg/ | ||
| + | • AST/ALT > 3x valore normale< | ||
| + | • Segni di sepsi cateter-correlata< | ||
| + | • Edema importante con bilancio positivo > 20 ml/kg/die | ||
| + | </ | ||
| + | |||
| + | <div class=" | ||
| + | < | ||
| + | • GIR > 12 mg/kg/min → Ridurre glucosio< | ||
| + | • BUN > 20 mg/dL → Ridurre proteine< | ||
| + | • BUN < 5 mg/dL → Aumentare proteine< | ||
| + | • Trigliceridi 200-400 mg/dL → Ridurre/ | ||
| + | • Ipernatremia → Ridurre sodio, aumentare liquidi liberi | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | <div class=" | ||
| + | < | ||
| + | <div class=" | ||
| + | <div class=" | ||
| + | | ||
| + | <label for=" | ||
| + | <input type=" | ||
| + | </ | ||
| + | <div class=" | ||
| + | <label for=" | ||
| + | <input type=" | ||
| + | </ | ||
| + | <div class=" | ||
| + | <label for=" | ||
| + | <input type=" | ||
| + | </ | ||
| + | </ | ||
| + | <div class=" | ||
| + | <div class=" | ||
| + | <label for=" | ||
| + | <select id=" | ||
| + | <option value=" | ||
| + | <option value=" | ||
| + | </ | ||
| + | </ | ||
| + | <div class=" | ||
| + | <label for=" | ||
| + | <select id=" | ||
| + | <option value=" | ||
| + | <option value=" | ||
| + | <option value=" | ||
| + | </ | ||
| + | </ | ||
| </ | </ | ||
| </ | </ | ||
| + | <button class=" | ||
| + | <button class=" | ||
| </ | </ | ||
| </ | </ | ||
| <div id=" | <div id=" | ||
| - | < | + | < |
| <div id=" | <div id=" | ||
| </ | </ | ||
| Linea 933: | Linea 1966: | ||
| < | < | ||
| - | // DATI NUTRIZIONALI COMPLETI | + | // DATI NUTRIZIONALI COMPLETI |
| const formulaData = { | const formulaData = { | ||
| maternal: { name: "Latte Materno", | maternal: { name: "Latte Materno", | ||
| Linea 946: | Linea 1979: | ||
| }; | }; | ||
| - | // CONFIGURAZIONI PARENTERALI COMPLETE | + | // CONFIGURAZIONI PARENTERALI COMPLETE |
| const parenteralConfig = { | const parenteralConfig = { | ||
| trophamine: { | trophamine: { | ||
| Linea 952: | Linea 1985: | ||
| protein: 6.0, carbs: 0, lipids: 0, sodium: 0, potassium: 0, | protein: 6.0, carbs: 0, lipids: 0, sodium: 0, potassium: 0, | ||
| calcium: 0, phosphorus: 0, magnesium: 0, energy: 24, water: 94, | calcium: 0, phosphorus: 0, magnesium: 0, energy: 24, water: 94, | ||
| + | osmolarity: 360, // mOsm/L | ||
| description: | description: | ||
| notes: " | notes: " | ||
| Linea 959: | Linea 1993: | ||
| protein: 0, carbs: 0, lipids: 20.0, sodium: 0, potassium: 0, | protein: 0, carbs: 0, lipids: 20.0, sodium: 0, potassium: 0, | ||
| calcium: 0, phosphorus: 0, magnesium: 0, energy: 200, water: 80, | calcium: 0, phosphorus: 0, magnesium: 0, energy: 200, water: 80, | ||
| + | osmolarity: 280, // mOsm/L | ||
| description: | description: | ||
| - | notes: " | + | notes: " |
| - | }, | + | |
| - | glucose10: { | + | |
| - | name: " | + | |
| - | protein: 0, carbs: 10.0, lipids: 0, sodium: 0, potassium: 0, | + | |
| - | calcium: 0, phosphorus: 0, magnesium: 0, energy: 40, water: 90, | + | |
| - | description: | + | |
| - | notes: "Osmolarità: | + | |
| - | }, | + | |
| - | glucose20: { | + | |
| - | name: " | + | |
| - | protein: 0, carbs: 20.0, lipids: 0, sodium: 0, potassium: 0, | + | |
| - | calcium: 0, phosphorus: 0, magnesium: 0, energy: 80, water: 80, | + | |
| - | description: | + | |
| - | notes: " | + | |
| - | }, | + | |
| - | glucose33: { | + | |
| - | name: " | + | |
| - | protein: 0, carbs: 33.0, lipids: 0, sodium: 0, potassium: 0, | + | |
| - | calcium: 0, phosphorus: 0, magnesium: 0, energy: 132, water: 67, | + | |
| - | description: | + | |
| - | notes: " | + | |
| }, | }, | ||
| glucose50: { | glucose50: { | ||
| Linea 987: | Linea 2001: | ||
| protein: 0, carbs: 50.0, lipids: 0, sodium: 0, potassium: 0, | protein: 0, carbs: 50.0, lipids: 0, sodium: 0, potassium: 0, | ||
| calcium: 0, phosphorus: 0, magnesium: 0, energy: 200, water: 50, | calcium: 0, phosphorus: 0, magnesium: 0, energy: 200, water: 50, | ||
| + | osmolarity: 2780, // mOsm/L | ||
| description: | description: | ||
| - | notes: " | + | notes: " |
| }, | }, | ||
| ca_gluconato: | ca_gluconato: | ||
| Linea 994: | Linea 2009: | ||
| protein: 0, carbs: 0, lipids: 0, sodium: 0, potassium: 0, | protein: 0, carbs: 0, lipids: 0, sodium: 0, potassium: 0, | ||
| calcium: 840, phosphorus: 0, magnesium: 0, energy: 0, water: 90, | calcium: 840, phosphorus: 0, magnesium: 0, energy: 0, water: 90, | ||
| + | osmolarity: 320, // mOsm/L | ||
| description: | description: | ||
| - | notes: "8.4 mg Ca/ml. Non precipita con fosfati" | + | notes: "8.4 mg Ca/ml. Non precipita con fosfati. Osmolarità: |
| }, | }, | ||
| esafosfina: { | esafosfina: { | ||
| Linea 1001: | Linea 2017: | ||
| protein: 0, carbs: 0, lipids: 0, sodium: 130, potassium: 0, | protein: 0, carbs: 0, lipids: 0, sodium: 130, potassium: 0, | ||
| calcium: 0, phosphorus: 1600, magnesium: 0, energy: 0, water: 98, | calcium: 0, phosphorus: 1600, magnesium: 0, energy: 0, water: 98, | ||
| + | osmolarity: 450, // mOsm/L | ||
| description: | description: | ||
| - | notes: "16 mg P/ml + 1.3 mEq Na/ml. Fosforo organico" | + | notes: "16 mg P/ml + 1.3 mEq Na/ml. Fosforo organico. Osmolarità: |
| }, | }, | ||
| mg_sulfate: { | mg_sulfate: { | ||
| Linea 1008: | Linea 2025: | ||
| protein: 0, carbs: 0, lipids: 0, sodium: 0, potassium: 0, | protein: 0, carbs: 0, lipids: 0, sodium: 0, potassium: 0, | ||
| calcium: 0, phosphorus: 0, magnesium: 800, energy: 0, water: 99, | calcium: 0, phosphorus: 0, magnesium: 800, energy: 0, water: 99, | ||
| + | osmolarity: 1620, // mOsm/L | ||
| description: | description: | ||
| - | notes: "8 mEq Mg/ml. Cofattore enzimatico" | + | notes: "8 mEq Mg/ml. Cofattore enzimatico. Osmolarità: |
| }, | }, | ||
| nacl: { | nacl: { | ||
| Linea 1015: | Linea 2033: | ||
| protein: 0, carbs: 0, lipids: 0, sodium: 1000, potassium: 0, | protein: 0, carbs: 0, lipids: 0, sodium: 1000, potassium: 0, | ||
| calcium: 0, phosphorus: 0, magnesium: 0, energy: 0, water: 99, | calcium: 0, phosphorus: 0, magnesium: 0, energy: 0, water: 99, | ||
| + | osmolarity: 2050, // mOsm/L | ||
| description: | description: | ||
| - | notes: "10 mEq Na/ml. Prima scelta per supplementazione sodio" | + | notes: "10 mEq Na/ml. Prima scelta per supplementazione sodio. Osmolarità: |
| + | }, | ||
| + | sodium_acetate: | ||
| + | name: "Sodio Acetato (3 mEq/ | ||
| + | protein: 0, carbs: 0, lipids: 0, sodium: 667, potassium: 0, | ||
| + | calcium: 0, phosphorus: 0, magnesium: 0, energy: 0, water: 99, | ||
| + | osmolarity: 1340, // mOsm/L | ||
| + | description: | ||
| + | notes: "6.67 mEq Na/ml. Per acidosi: pH < 7.25 o BE < -4. Osmolarità: | ||
| }, | }, | ||
| kcl: { | kcl: { | ||
| Linea 1022: | Linea 2049: | ||
| protein: 0, carbs: 0, lipids: 0, sodium: 0, potassium: 1000, | protein: 0, carbs: 0, lipids: 0, sodium: 0, potassium: 1000, | ||
| calcium: 0, phosphorus: 0, magnesium: 0, energy: 0, water: 99, | calcium: 0, phosphorus: 0, magnesium: 0, energy: 0, water: 99, | ||
| + | osmolarity: 2050, // mOsm/L | ||
| description: | description: | ||
| - | notes: "10 mEq K/ml. Max velocità infusione: 0.5 mEq/ | + | notes: "10 mEq K/ml. Max velocità infusione: 0.5 mEq/kg/h. Osmolarità: |
| + | }, | ||
| + | carnitene: { | ||
| + | name: " | ||
| + | protein: 0, carbs: 0, lipids: 0, sodium: 0, potassium: 0, | ||
| + | calcium: 0, phosphorus: 0, magnesium: 0, energy: 0, water: 99, | ||
| + | osmolarity: 280, // mOsm/L | ||
| + | carnitine: 10000, // 100 mg/ml = 10000 mg/100ml | ||
| + | description: | ||
| + | notes: "100 mg/ml. Indicata per NPT > 1 mese. Dose: 5 mg/kg/die. Osmolarità: | ||
| } | } | ||
| }; | }; | ||
| Linea 1036: | Linea 2073: | ||
| } | } | ||
| }; | }; | ||
| + | |||
| + | // Database medici dinamico | ||
| + | let doctorsData = { | ||
| + | dr_bellu: { name: " | ||
| + | dr_condo: { name: " | ||
| + | dr_maccioni: | ||
| + | dr_meroni: { name: " | ||
| + | dr_calzatini: | ||
| + | dr_ferrari: { name: " | ||
| + | dr_ferendeles: | ||
| + | dr_fumagalli_l: | ||
| + | dr_fumagalli_m: | ||
| + | dr_corno: { name: " | ||
| + | dr_evasi: { name: " | ||
| + | dr_cereda: { name: " | ||
| + | dr_ceccon: { name: " | ||
| + | dr_nava: { name: " | ||
| + | dr_terenzi: { name: " | ||
| + | dr_raffa: { name: " | ||
| + | dr_aquisti: { name: " | ||
| + | }; | ||
| + | |||
| + | // Database infermiere dinamico | ||
| + | let nursesData = { | ||
| + | inf_rossi: { name: " | ||
| + | inf_bianchi: | ||
| + | inf_verdi: { name: " | ||
| + | inf_ferrari: | ||
| + | inf_moretti: | ||
| + | inf_conti: { name: " | ||
| + | }; | ||
| + | |||
| + | // Database farmacisti dinamico | ||
| + | let pharmacistsData = { | ||
| + | farm_lombardi: | ||
| + | farm_ricci: { name: " | ||
| + | farm_marino: | ||
| + | farm_greco: { name: " | ||
| + | farm_bruno: { name: " | ||
| + | }; | ||
| + | |||
| + | // Database tecnici di farmacia dinamico | ||
| + | let technicianData = { | ||
| + | tec_russo: { name: " | ||
| + | tec_gallo: { name: " | ||
| + | tec_costa: { name: " | ||
| + | tec_rizzo: { name: " | ||
| + | tec_longo: { name: " | ||
| + | tec_giordano: | ||
| + | }; | ||
| + | |||
| + | |||
| // VARIABILI GLOBALI | // VARIABILI GLOBALI | ||
| Linea 1042: | Linea 2131: | ||
| let currentRequirements = null; | let currentRequirements = null; | ||
| - | // FUNZIONI DI SALVATAGGIO PERSISTENTE | + | // CONFIGURAZIONE CLINICA AVANZATA |
| - | function saveToStorage() { | + | let clinicalConfig |
| - | const configData | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | localStorage.setItem(' | + | |
| - | | + | |
| - | | + | }; |
| - | console.error(' | + | |
| - | | + | |
| - | } | + | |
| - | function | + | // FUNZIONE RESET PULSANTE FABBISOGNI |
| - | | + | function |
| - | | + | const nutritionBtn |
| - | if (savedData) { | + | if (nutritionBtn) { |
| - | const configData | + | |
| - | + | nutritionBtn.innerHTML = ' | |
| - | // Aggiorna | + | |
| - | if (configData.formulaData) { | + | // Nascondi |
| - | Object.assign(formulaData, | + | const nutritionResults = document.getElementById(' |
| - | } | + | if (nutritionResults) { |
| - | | + | |
| - | Object.assign(parenteralConfig, | + | |
| - | | + | |
| - | if (configData.fortifierData) { | + | |
| - | Object.assign(fortifierData, | + | |
| - | } | + | |
| - | + | ||
| - | console.log('Configurazione caricata dal localStorage: | + | |
| - | return true; | + | |
| } | } | ||
| - | } catch (error) { | + | |
| - | | + | // Reset anche il pulsante NPT perché i fabbisogni sono cambiati |
| + | | ||
| } | } | ||
| - | return false; | ||
| } | } | ||
| - | function | + | // FUNZIONE RESET PULSANTE PARENTERALE |
| - | if (confirm('Sei sicuro di voler ripristinare tutti i valori di default? Tutte le modifiche verranno perse.' | + | function |
| - | | + | const parenteralBtn = document.getElementById(' |
| - | | + | if (parenteralBtn) { |
| + | parenteralBtn.className = 'button'; | ||
| + | parenteralBtn.innerHTML = ' | ||
| + | |||
| + | // Reset anche i campi visualizzati | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | | ||
| + | | ||
| + | |||
| + | // Nascondi i risultati precedenti | ||
| + | const parenteralResults = document.getElementById(' | ||
| + | if (parenteralResults) { | ||
| + | parenteralResults.classList.add(' | ||
| + | } | ||
| } | } | ||
| } | } | ||
| - | // FUNZIONE CALCOLO ELETTROLITI AGGIUNTIVI | + | |
| - | function | + | // SISTEMA PROTEZIONE CONFIGURAZIONE |
| - | const additions | + | function |
| - | ca_gluconato: | + | // Password predefinita (modificabile) |
| - | esafosfina: 0, | + | const ADMIN_PASSWORD |
| - | mg_sulfate: 0, | + | |
| - | nacl: 0, | + | |
| - | kcl: 0, | + | |
| - | totalVolume: | + | |
| - | providedCalcium: | + | |
| - | providedPhosphorus: | + | |
| - | providedMagnesium: | + | |
| - | providedSodium: | + | |
| - | providedPotassium: | + | |
| - | }; | + | |
| | | ||
| - | // Calcola fabbisogni totali per paziente | + | // Controlla se l' |
| - | | + | |
| - | const totalPhosphorusNeeded | + | |
| - | const totalMagnesiumNeeded | + | |
| - | const totalSodiumNeeded = sodiumNeeded * currentWeightKg; | + | |
| - | const totalPotassiumNeeded = potassiumNeeded * currentWeightKg; | + | |
| - | + | ||
| - | // Calcio Gluconato 10% (840 mg Ca/100ml) | + | |
| - | if (totalCalciumNeeded > 0) { | + | |
| - | | + | |
| - | additions.providedCalcium = totalCalciumNeeded; | + | |
| } | } | ||
| | | ||
| - | // Esafosfina (1600 mg P/100ml + 130 mEq Na/100ml) | + | // Richiedi password |
| - | | + | |
| - | | + | |
| - | | + | |
| - | // Esafosfina fornisce anche sodio | + | ); |
| - | additions.providedSodium += (additions.esafosfina * parenteralConfig.esafosfina.sodium / 100); | + | |
| - | } | + | |
| | | ||
| - | // Magnesio Solfato (800 mEq Mg/100ml) | + | // Se utente cancella |
| - | if (totalMagnesiumNeeded > 0) { | + | if (userPassword === null) { |
| - | | + | |
| - | additions.providedMagnesium = totalMagnesiumNeeded; | + | |
| } | } | ||
| | | ||
| - | // Sodio rimanente (dopo quello da Esafosfina) | + | // Verifica password |
| - | | + | |
| - | | + | window.configAccessGranted = true; |
| - | | + | alert("✅ Accesso autorizzato!\n\nBenvenuto nella configurazione avanzata NPT Calculator v3.0"); |
| - | | + | return true; |
| + | | ||
| + | | ||
| + | | ||
| } | } | ||
| - | | ||
| - | // Potassio Cloruro (1000 mEq K/100ml) | ||
| - | if (totalPotassiumNeeded > 0) { | ||
| - | additions.kcl = totalPotassiumNeeded / (parenteralConfig.kcl.potassium / 100); | ||
| - | additions.providedPotassium = totalPotassiumNeeded; | ||
| - | } | ||
| - | | ||
| - | // Volume totale degli elettroliti | ||
| - | additions.totalVolume = additions.ca_gluconato + additions.esafosfina + additions.mg_sulfate + additions.nacl + additions.kcl; | ||
| - | | ||
| - | return additions; | ||
| } | } | ||
| + | |||
| + | // Funzione per logout configurazione | ||
| + | function logoutConfig() { | ||
| + | window.configAccessGranted = false; | ||
| + | alert(" | ||
| + | // Torna al TAB 1 | ||
| + | showTab(' | ||
| + | } | ||
| + | |||
| // FUNZIONE CORRETTA PER CAMBIO TAB | // FUNZIONE CORRETTA PER CAMBIO TAB | ||
| Linea 1177: | Linea 2249: | ||
| } | } | ||
| | | ||
| - | // Popola le tabelle | + | // Sistema |
| if (tabId === ' | if (tabId === ' | ||
| + | if (!checkConfigAccess()) { | ||
| + | return; // Blocca l' | ||
| + | } | ||
| setTimeout(() => { | setTimeout(() => { | ||
| populateEnteralConfigTable(); | populateEnteralConfigTable(); | ||
| populateParenteralConfigTable(); | populateParenteralConfigTable(); | ||
| - | | + | |
| + | populateNursesConfigTable(); | ||
| + | populatePharmacistsConfigTable(); | ||
| + | populateTechniciansConfigTable(); | ||
| }, 100); | }, 100); | ||
| } | } | ||
| + | |||
| + | // Popola le dropdown del personale quando si apre il TAB 5 (report) | ||
| + | if (tabId === ' | ||
| + | setTimeout(() => { | ||
| + | updatePreparationStaffDropdowns(); | ||
| + | }, 100); | ||
| } | } | ||
| - | // FUNZIONE CALCOLO FASE NUTRIZIONALE | + | } |
| + | |||
| + | // FUNZIONE GESTIONE CARTELLA CLINICA | ||
| + | function setupMedicalRecordField() { | ||
| + | const medicalRecordInput = document.getElementById(' | ||
| + | const currentYear = new Date().getFullYear().toString(); | ||
| + | |||
| + | // Imposta il valore iniziale con l'anno corrente | ||
| + | if (!medicalRecordInput.value) { | ||
| + | medicalRecordInput.value = currentYear; | ||
| + | } | ||
| + | |||
| + | // Gestisce l' | ||
| + | medicalRecordInput.addEventListener(' | ||
| + | let value = e.target.value.replace(/ | ||
| + | |||
| + | // Se l' | ||
| + | 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, | ||
| + | } | ||
| + | |||
| + | e.target.value = value; | ||
| + | }); | ||
| + | |||
| + | // Quando il campo ottiene il focus, posiziona il cursore dopo l' | ||
| + | medicalRecordInput.addEventListener(' | ||
| + | if (e.target.value === currentYear) { | ||
| + | // Posiziona il cursore alla fine | ||
| + | setTimeout(() => { | ||
| + | e.target.setSelectionRange(4, | ||
| + | }, 0); | ||
| + | } | ||
| + | }); | ||
| + | |||
| + | // Suggerimento visivo | ||
| + | medicalRecordInput.addEventListener(' | ||
| + | if (e.target.value === currentYear) { | ||
| + | e.target.placeholder = currentYear + ' | ||
| + | } | ||
| + | }); | ||
| + | } | ||
| + | |||
| + | function updateDoctorsDropdown() { | ||
| + | console.log(' | ||
| + | const prescribingDoctorSelect = document.getElementById(' | ||
| + | console.log(' | ||
| + | |||
| + | if (!prescribingDoctorSelect) { | ||
| + | console.error(' | ||
| + | return; | ||
| + | } | ||
| + | |||
| + | console.log(' | ||
| + | console.log(' | ||
| + | |||
| + | const currentValue = prescribingDoctorSelect.value; | ||
| + | prescribingDoctorSelect.innerHTML = '< | ||
| + | |||
| + | Object.keys(doctorsData).forEach(function(key) { | ||
| + | const doctor = doctorsData[key]; | ||
| + | console.log(' | ||
| + | const option = document.createElement(' | ||
| + | option.value = key; | ||
| + | option.textContent = doctor.fullName; | ||
| + | prescribingDoctorSelect.appendChild(option); | ||
| + | }); | ||
| + | |||
| + | // Ripristina il valore precedente se esiste ancora | ||
| + | if (currentValue && doctorsData[currentValue]) { | ||
| + | prescribingDoctorSelect.value = currentValue; | ||
| + | } | ||
| + | |||
| + | console.log(' | ||
| + | } | ||
| + | |||
| + | // FUNZIONE CALCOLO ETÀ POST-CONCEZIONALE | ||
| + | function calculatePostConceptionalAge() { | ||
| + | const gestWeeks = parseInt(document.getElementById(' | ||
| + | const gestDays = parseInt(document.getElementById(' | ||
| + | const daysOfLife = parseInt(document.getElementById(' | ||
| + | |||
| + | if (gestWeeks === 0 || daysOfLife === 0) { | ||
| + | document.getElementById(' | ||
| + | return null; | ||
| + | } | ||
| + | |||
| + | // Calcola età post-concezionale | ||
| + | const totalGestationalDays = (gestWeeks * 7) + gestDays; | ||
| + | const totalPostConceptionalDays = totalGestationalDays + daysOfLife; | ||
| + | |||
| + | // Converti in settimane+giorni | ||
| + | const pcWeeks = Math.floor(totalPostConceptionalDays / 7); | ||
| + | const pcDays = totalPostConceptionalDays % 7; | ||
| + | |||
| + | const pcAge = pcWeeks + ' | ||
| + | document.getElementById(' | ||
| + | |||
| + | return { weeks: pcWeeks, days: pcDays, format: pcAge }; | ||
| + | } | ||
| + | |||
| + | // FUNZIONE CALCOLO FASE NUTRIZIONALE | ||
| function calculatePhase() { | function calculatePhase() { | ||
| - | const birthWeight | + | const medicalRecord = document.getElementById(' |
| - | const currentWeight | + | const phaseBirthWeight |
| + | const phaseCurrentWeight | ||
| const daysOfLife = parseInt(document.getElementById(' | const daysOfLife = parseInt(document.getElementById(' | ||
| const bun = document.getElementById(' | const bun = document.getElementById(' | ||
| Linea 1196: | Linea 2386: | ||
| const sodium = document.getElementById(' | const sodium = document.getElementById(' | ||
| const ph = document.getElementById(' | const ph = document.getElementById(' | ||
| + | const baseExcess = document.getElementById(' | ||
| const diuresis = document.getElementById(' | const diuresis = document.getElementById(' | ||
| + | const prescriptionDate = document.getElementById(' | ||
| + | const prescribingDoctorValue = document.getElementById(' | ||
| | | ||
| - | patientData = { | + | |
| - | | + | const doctorFullName = prescribingDoctorValue && doctorsData[prescribingDoctorValue] ? |
| - | currentWeight: | + | doctorsData[prescribingDoctorValue].fullName : ''; |
| - | daysOfLife: daysOfLife, | + | |
| - | bun: bun, | + | |
| - | glucose: glucose, | + | // Recupera età gestazionale per i report |
| - | sodium: sodium, | + | const gestationalWeeks = parseInt(document.getElementById(' |
| - | ph: ph, | + | const gestationalDays = parseInt(document.getElementById(' |
| - | diuresis: diuresis | + | |
| - | }; | + | // Calcola età post-concezionale |
| + | const postConceptionalAge = calculatePostConceptionalAge(); | ||
| + | |||
| + | patientData = { | ||
| + | | ||
| + | | ||
| + | currentWeight: | ||
| + | daysOfLife: daysOfLife, | ||
| + | | ||
| + | gestationalDays: | ||
| + | postConceptionalAge: | ||
| + | | ||
| + | glucose: glucose, | ||
| + | sodium: sodium, | ||
| + | ph: ph, | ||
| + | | ||
| + | | ||
| + | | ||
| + | prescribingDoctor: | ||
| + | prescribingDoctorName: | ||
| + | }; | ||
| | | ||
| document.getElementById(' | document.getElementById(' | ||
| Linea 1258: | Linea 2471: | ||
| } else if (phValue > 7.45) { | } else if (phValue > 7.45) { | ||
| otherWarnings.push(' | otherWarnings.push(' | ||
| + | } | ||
| + | } | ||
| + | | ||
| + | if (baseExcess && baseExcess !== '' | ||
| + | const beValue = parseFloat(baseExcess); | ||
| + | if (beValue < -4) { | ||
| + | otherWarnings.push(' | ||
| + | } else if (beValue > 2) { | ||
| + | otherWarnings.push(' | ||
| + | } | ||
| + | } | ||
| + | | ||
| + | // 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(' | ||
| } | } | ||
| } | } | ||
| Linea 1274: | Linea 2505: | ||
| phaseInfoHtml += '< | phaseInfoHtml += '< | ||
| phaseInfoHtml += '< | phaseInfoHtml += '< | ||
| - | phaseInfoHtml += '< | + | |
| + | phaseInfoHtml += '< | ||
| + | } | ||
| + | | ||
| phaseInfoHtml += '< | phaseInfoHtml += '< | ||
| + | | ||
| + | if (gestationalWeeks && gestationalWeeks > 0) { | ||
| + | const gestDaysDisplay = gestationalDays || 0; | ||
| + | phaseInfoHtml += '< | ||
| + | if (postConceptionalAge && postConceptionalAge.format) { | ||
| + | phaseInfoHtml += '< | ||
| + | } | ||
| + | } | ||
| phaseInfoHtml += '< | phaseInfoHtml += '< | ||
| phaseInfoHtml += '</ | phaseInfoHtml += '</ | ||
| Linea 1294: | Linea 2536: | ||
| const phStatus = parseFloat(patientData.ph) >= 7.35 && parseFloat(patientData.ph) <= 7.45 ? ' | const phStatus = parseFloat(patientData.ph) >= 7.35 && parseFloat(patientData.ph) <= 7.45 ? ' | ||
| phaseInfoHtml += '< | phaseInfoHtml += '< | ||
| + | } | ||
| + | if (patientData.baseExcess) { | ||
| + | const beStatus = parseFloat(patientData.baseExcess) >= -4 && parseFloat(patientData.baseExcess) <= 2 ? ' | ||
| + | phaseInfoHtml += '< | ||
| } | } | ||
| if (patientData.diuresis) { | if (patientData.diuresis) { | ||
| Linea 1317: | Linea 2563: | ||
| document.getElementById(' | document.getElementById(' | ||
| document.getElementById(' | document.getElementById(' | ||
| - | } | + | |
| - | + | // Aggiorna il suggerimento sodio se il TAB 3 è già stato visitato | |
| - | // FUNZIONE AGGIORNAMENTO DISPLAY CONCENTRAZIONE | + | |
| - | function updateConcentrationDisplay() { | + | |
| - | | + | // RESET anche il pulsante NPT |
| - | | + | resetParenteralButton(); |
| } | } | ||
| Linea 1347: | Linea 2593: | ||
| } | } | ||
| - | // FUNZIONE CALCOLO NUTRIZIONE ENTERALE | + | // FUNZIONE AGGIORNAMENTO DISPLAY CONCENTRAZIONE |
| + | function updateConcentrationDisplay() { | ||
| + | const concentration = document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | } | ||
| + | |||
| + | // FUNZIONE CALCOLO NUTRIZIONE ENTERALE | ||
| function calculateEnteral() { | function calculateEnteral() { | ||
| - | | + | |
| - | alert(' | + | const enteralCurrentWeight = parseInt(document.getElementById(' |
| + | const enteralBirthWeight = parseInt(document.getElementById(' | ||
| + | |||
| + | if (!enteralCurrentWeight || !enteralBirthWeight) { | ||
| + | alert(' | ||
| return; | return; | ||
| + | } | ||
| + | | ||
| + | // Aggiorna patientData se non è stato ancora fatto | ||
| + | if (!patientData.currentWeight) { | ||
| + | patientData.currentWeight = enteralCurrentWeight; | ||
| + | patientData.birthWeight = enteralBirthWeight; | ||
| } | } | ||
| | | ||
| Linea 1357: | Linea 2619: | ||
| const dailyVolume = parseFloat(document.getElementById(' | const dailyVolume = parseFloat(document.getElementById(' | ||
| const additionalFluids = parseFloat(document.getElementById(' | const additionalFluids = parseFloat(document.getElementById(' | ||
| - | const fortifierType = document.getElementById(' | ||
| - | const fortifierConcentration = parseFloat(document.getElementById(' | ||
| | | ||
| const currentWeight = patientData.currentWeight; | const currentWeight = patientData.currentWeight; | ||
| Linea 1386: | Linea 2646: | ||
| const formula = formulaData[formulaType]; | const formula = formulaData[formulaType]; | ||
| const volumePerKg = (dailyVolume / currentWeight) * 1000; | const volumePerKg = (dailyVolume / currentWeight) * 1000; | ||
| - | | ||
| - | // Calcoli base della formula | ||
| - | let totalProtein = formula.protein; | ||
| - | let totalCarbs = formula.carbs; | ||
| - | let totalLipids = formula.lipids; | ||
| - | let totalSodium = formula.sodium; | ||
| - | let totalPotassium = formula.potassium; | ||
| - | let totalCalcium = formula.calcium; | ||
| - | let totalPhosphorus = formula.phosphorus; | ||
| - | let totalMagnesium = formula.magnesium; | ||
| - | let totalEnergy = formula.energy; | ||
| - | | ||
| - | let fortifierInfo = ''; | ||
| - | | ||
| - | // Aggiunta fortificante se selezionato | ||
| - | if (formulaType === ' | ||
| - | const fortifier = fortifierData[fortifierType]; | ||
| - | const fortifierGramsPer100ml = fortifierConcentration; | ||
| - | | ||
| - | const fortifierProteinPer100ml = (fortifier.protein * fortifierGramsPer100ml) / 100; | ||
| - | const fortifierCarbsPer100ml = (fortifier.carbs * fortifierGramsPer100ml) / 100; | ||
| - | const fortifierLipidsPer100ml = (fortifier.lipids * fortifierGramsPer100ml) / 100; | ||
| - | const fortifierSodiumPer100ml = (fortifier.sodium * fortifierGramsPer100ml) / 100; | ||
| - | const fortifierPotassiumPer100ml = (fortifier.potassium * fortifierGramsPer100ml) / 100; | ||
| - | const fortifierCalciumPer100ml = (fortifier.calcium * fortifierGramsPer100ml) / 100; | ||
| - | const fortifierPhosphorusPer100ml = (fortifier.phosphorus * fortifierGramsPer100ml) / 100; | ||
| - | const fortifierMagnesiumPer100ml = (fortifier.magnesium * fortifierGramsPer100ml) / 100; | ||
| - | const fortifierEnergyPer100ml = (fortifier.energy * fortifierGramsPer100ml) / 100; | ||
| - | | ||
| - | totalProtein += fortifierProteinPer100ml; | ||
| - | totalCarbs += fortifierCarbsPer100ml; | ||
| - | totalLipids += fortifierLipidsPer100ml; | ||
| - | totalSodium += fortifierSodiumPer100ml; | ||
| - | totalPotassium += fortifierPotassiumPer100ml; | ||
| - | totalCalcium += fortifierCalciumPer100ml; | ||
| - | totalPhosphorus += fortifierPhosphorusPer100ml; | ||
| - | totalMagnesium += fortifierMagnesiumPer100ml; | ||
| - | totalEnergy += fortifierEnergyPer100ml; | ||
| - | | ||
| - | fortifierInfo = '< | ||
| - | } | ||
| | | ||
| // Calcoli finali per kg di peso | // Calcoli finali per kg di peso | ||
| Linea 1433: | Linea 2652: | ||
| additionalFluids: | additionalFluids: | ||
| totalFluids: | totalFluids: | ||
| - | protein: (dailyVolume * totalProtein | + | protein: (dailyVolume * formula.protein |
| - | carbs: (dailyVolume * totalCarbs | + | carbs: (dailyVolume * formula.carbs |
| - | lipids: (dailyVolume * totalLipids | + | lipids: (dailyVolume * formula.lipids |
| - | energy: (dailyVolume * totalEnergy | + | energy: (dailyVolume * formula.energy |
| - | sodium: (dailyVolume * totalSodium | + | sodium: (dailyVolume * formula.sodium |
| - | potassium: (dailyVolume * totalPotassium | + | potassium: (dailyVolume * formula.potassium |
| - | calcium: (dailyVolume * totalCalcium | + | calcium: (dailyVolume * formula.calcium |
| - | phosphorus: (dailyVolume * totalPhosphorus | + | phosphorus: (dailyVolume * formula.phosphorus |
| - | magnesium: (dailyVolume * totalMagnesium | + | magnesium: (dailyVolume * formula.magnesium |
| }; | }; | ||
| | | ||
| let tableHtml = '< | let tableHtml = '< | ||
| - | tableHtml += '< | + | tableHtml += '< |
| tableHtml += '< | tableHtml += '< | ||
| if (additionalFluids > 0) { | if (additionalFluids > 0) { | ||
| Linea 1457: | Linea 2676: | ||
| tableHtml += '< | tableHtml += '< | ||
| tableHtml += '< | tableHtml += '< | ||
| - | tableHtml += '< | + | tableHtml += '< |
| - | tableHtml += '< | + | tableHtml += '< |
| - | tableHtml += '< | + | tableHtml += '< |
| - | tableHtml += '< | + | tableHtml += '< |
| tableHtml += '</ | tableHtml += '</ | ||
| - | | ||
| - | if (fortifierType !== ' | ||
| - | tableHtml += '< | ||
| - | tableHtml += '< | ||
| - | tableHtml += '• < | ||
| - | tableHtml += '• < | ||
| - | tableHtml += '• < | ||
| - | tableHtml += '• < | ||
| - | tableHtml += '</ | ||
| - | } | ||
| | | ||
| document.getElementById(' | document.getElementById(' | ||
| Linea 1484: | Linea 2693: | ||
| enteralBtn.innerHTML = ' | enteralBtn.innerHTML = ' | ||
| } | } | ||
| + | | ||
| + | // RESET del pulsante Fabbisogni quando si modificano gli apporti enterali | ||
| + | resetNutritionButton(); | ||
| } | } | ||
| - | // FUNZIONE CARICAMENTO VALORI STANDARD | + | // FUNZIONE CARICAMENTO VALORI STANDARD |
| function loadNutritionDefaults() { | function loadNutritionDefaults() { | ||
| - | | + | |
| - | alert(' | + | const defaultsCurrentWeight = parseInt(document.getElementById(' |
| + | const defaultsBirthWeight = parseInt(document.getElementById(' | ||
| + | const defaultsDaysOfLife = parseInt(document.getElementById(' | ||
| + | |||
| + | if (!defaultsCurrentWeight || !defaultsBirthWeight || !defaultsDaysOfLife) { | ||
| + | alert(' | ||
| return; | 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(' | const targetDay = parseInt(document.getElementById(' | ||
| - | const birthWeight | + | const patientBirthWeightForCalculation |
| | | ||
| const weightCategorySelect = document.getElementById(' | const weightCategorySelect = document.getElementById(' | ||
| - | let selectedCategory = weightCategorySelect.value || (birthWeight | + | let selectedCategory = weightCategorySelect.value || (patientBirthWeightForCalculation |
| weightCategorySelect.value = selectedCategory; | weightCategorySelect.value = selectedCategory; | ||
| | | ||
| Linea 1523: | Linea 2747: | ||
| document.getElementById(' | document.getElementById(' | ||
| document.getElementById(' | document.getElementById(' | ||
| - | document.getElementById(' | + | |
| - | document.getElementById(' | + | // Usa configurazione clinica per elettroliti |
| - | document.getElementById(' | + | |
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| document.getElementById(' | document.getElementById(' | ||
| document.getElementById(' | document.getElementById(' | ||
| | | ||
| - | | + | |
| - | | + | |
| - | document.getElementById(' | + | |
| - | | + | const ph = patientData.ph ? parseFloat(patientData.ph) : null; |
| - | } | + | const be = patientData.baseExcess ? parseFloat(patientData.baseExcess) : null; |
| - | + | ||
| - | // FUNZIONE AGGIORNAMENTO VITAMINE | + | // Auto-seleziona Sodio Acetato se acidosi |
| - | function updateVitaminsAndTrace() { | + | if ((ph && ph < 7.30) || (be && be < -4)) { |
| - | | + | sodiumSelect.value = ' |
| - | | + | } else { |
| + | sodiumSelect.value = ' | ||
| + | } | ||
| } | } | ||
| | | ||
| - | | + | |
| - | | + | |
| - | const enteralVolumePerKg = enteralData ? (enteralData.totalFluids / currentWeight * 1000) : 0; | + | |
| | | ||
| - | | + | |
| - | | + | |
| - | | + | |
| | | ||
| - | if (targetDay >= 4) { | + | if (targetDay >= 3 && |
| - | if (enteralVolumePerKg < 100) { | + | |
| - | | + | |
| - | | + | |
| - | | + | } else { |
| - | } | + | // Mantieni i valori a zero se prima del 3° giorno o se enterale ≥100 ml/kg/die |
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| } | } | ||
| | | ||
| - | | + | |
| - | | + | |
| - | document.getElementById(' | + | document.getElementById(' |
| - | | + | document.getElementById(' |
| - | | + | |
| - | document.getElementById(' | + | |
| - | | + | resetNutritionButton(); |
| - | if (document.getElementById('reqPeditrace').value == 0) { | + | } |
| - | | + | |
| + | // FUNZIONE AGGIORNAMENTO UNITÀ CARBOIDRATI | ||
| + | function updateCarbUnit() { | ||
| + | const unit = document.getElementById(' | ||
| + | const carbLabel | ||
| + | const carbInput = document.getElementById(' | ||
| + | |||
| + | if (unit === ' | ||
| + | carbLabel.textContent = ' | ||
| + | carbInput.setAttribute(' | ||
| + | carbInput.setAttribute(' | ||
| + | } else { | ||
| + | | ||
| + | carbInput.setAttribute(' | ||
| + | carbInput.setAttribute(' | ||
| } | } | ||
| | | ||
| - | | + | |
| - | | + | |
| - | soluvit: parseFloat(document.getElementById(' | + | |
| - | peditrace: parseFloat(document.getElementById(' | + | |
| - | enteralVolumePerKg: | + | |
| - | }; | + | |
| } | } | ||
| // FUNZIONE AGGIORNAMENTO CATEGORIA PESO | // FUNZIONE AGGIORNAMENTO CATEGORIA PESO | ||
| function updateWeightCategory() { | function updateWeightCategory() { | ||
| - | | + | |
| - | | + | |
| } | } | ||
| - | // FUNZIONE CALCOLO FABBISOGNI NUTRIZIONALI | + | // 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(' | ||
| + | const recommendationDiv = document.getElementById(' | ||
| + | |||
| + | if (!patientData.ph && !patientData.baseExcess) { | ||
| + | // Nessun dato clinico disponibile | ||
| + | recommendationDiv.classList.add(' | ||
| + | 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 === ' | ||
| + | // L' | ||
| + | recommendationDiv.innerHTML = '< | ||
| + | '< | ||
| + | 'In base ai parametri clinici (' + reason + '), si raccomanda < | ||
| + | '</ | ||
| + | recommendationDiv.classList.remove(' | ||
| + | } else { | ||
| + | // L' | ||
| + | recommendationDiv.innerHTML = '< | ||
| + | '< | ||
| + | 'Sodio Acetato è indicato per i parametri clinici attuali (' + reason + ' | ||
| + | '</ | ||
| + | recommendationDiv.classList.remove(' | ||
| + | } | ||
| + | } else { | ||
| + | // Parametri normali | ||
| + | if (sodiumSelect.value === ' | ||
| + | // L' | ||
| + | recommendationDiv.innerHTML = '< | ||
| + | '< | ||
| + | 'I parametri clinici sono nella norma. Sodio Cloruro potrebbe essere sufficiente, | ||
| + | '</ | ||
| + | recommendationDiv.classList.remove(' | ||
| + | } else { | ||
| + | // Tutto normale | ||
| + | recommendationDiv.classList.add(' | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | // FUNZIONE CALCOLO FABBISOGNI NUTRIZIONALI | ||
| function calculateNutrition() { | function calculateNutrition() { | ||
| - | | + | |
| - | alert(' | + | const nutritionCurrentWeight = parseInt(document.getElementById(' |
| + | const nutritionBirthWeight = parseInt(document.getElementById(' | ||
| + | |||
| + | if (!nutritionCurrentWeight || !nutritionBirthWeight) { | ||
| + | alert(' | ||
| return; | return; | ||
| + | } | ||
| + | | ||
| + | // Aggiorna patientData se non è stato ancora fatto | ||
| + | if (!patientData.currentWeight) { | ||
| + | patientData.currentWeight = nutritionCurrentWeight; | ||
| + | patientData.birthWeight = nutritionBirthWeight; | ||
| } | } | ||
| | | ||
| Linea 1593: | Linea 2911: | ||
| protein: parseFloat(document.getElementById(' | protein: parseFloat(document.getElementById(' | ||
| carbs: parseFloat(document.getElementById(' | carbs: parseFloat(document.getElementById(' | ||
| + | carbUnit: document.getElementById(' | ||
| lipids: parseFloat(document.getElementById(' | lipids: parseFloat(document.getElementById(' | ||
| calcium: parseFloat(document.getElementById(' | calcium: parseFloat(document.getElementById(' | ||
| Linea 1599: | Linea 2918: | ||
| sodium: parseFloat(document.getElementById(' | sodium: parseFloat(document.getElementById(' | ||
| potassium: parseFloat(document.getElementById(' | potassium: parseFloat(document.getElementById(' | ||
| - | vitalipid: parseFloat(document.getElementById(' | + | vitalipid: parseFloat(document.getElementById(' |
| - | soluvit: parseFloat(document.getElementById(' | + | soluvit: parseFloat(document.getElementById(' |
| - | peditrace: parseFloat(document.getElementById(' | + | peditrace: parseFloat(document.getElementById(' |
| + | carnitine: parseFloat(document.getElementById(' | ||
| }; | }; | ||
| | | ||
| - | | + | |
| - | requirements.vitalipid | + | |
| - | | + | (requirements.carbs * 1440 / 1000) : requirements.carbs; |
| - | | + | |
| + | const patientCurrentWeight | ||
| + | | ||
| | | ||
| const enteralProtein = enteralData ? enteralData.protein : 0; | const enteralProtein = enteralData ? enteralData.protein : 0; | ||
| Linea 1615: | Linea 2937: | ||
| | | ||
| const residualProtein = Math.max(0, requirements.protein - enteralProtein); | const residualProtein = Math.max(0, requirements.protein - enteralProtein); | ||
| - | const residualCarbs = Math.max(0, | + | const residualCarbs = Math.max(0, |
| const residualLipids = Math.max(0, requirements.lipids - enteralLipids); | const residualLipids = Math.max(0, requirements.lipids - enteralLipids); | ||
| - | const totalEnergyRequirement = (requirements.protein * 4) + (requirements.carbs | + | const totalEnergyRequirement = (requirements.protein * 4) + (carbsGPerKgDay |
| const residualEnergy = Math.max(0, totalEnergyRequirement - enteralEnergy); | const residualEnergy = Math.max(0, totalEnergyRequirement - enteralEnergy); | ||
| | | ||
| Linea 1633: | Linea 2955: | ||
| const residualSodium = Math.max(0, requirements.sodium - enteralSodium); | const residualSodium = Math.max(0, requirements.sodium - enteralSodium); | ||
| const residualPotassium = Math.max(0, requirements.potassium - enteralPotassium); | const residualPotassium = Math.max(0, requirements.potassium - enteralPotassium); | ||
| - | | ||
| - | let bunNote = ''; | ||
| - | if (patientData.bun && patientData.bun !== '' | ||
| - | const bunValue = parseFloat(patientData.bun); | ||
| - | if (bunValue < 9) { | ||
| - | bunNote = '< | ||
| - | } else if (bunValue > 14) { | ||
| - | bunNote = '< | ||
| - | } | ||
| - | } | ||
| - | | ||
| - | let vitaminsNote = ''; | ||
| - | if (vitaminsInfo.enteralVolumePerKg >= 100) { | ||
| - | vitaminsNote = '< | ||
| - | } else if (patientData.daysOfLife >= 4 && requirements.vitalipid > 0) { | ||
| - | vitaminsNote = '< | ||
| - | } else if (patientData.daysOfLife < 4) { | ||
| - | vitaminsNote = '< | ||
| - | } | ||
| | | ||
| window.residualNeeds = { | window.residualNeeds = { | ||
| Linea 1666: | Linea 2969: | ||
| soluvit: requirements.soluvit, | soluvit: requirements.soluvit, | ||
| peditrace: requirements.peditrace, | peditrace: requirements.peditrace, | ||
| + | carnitine: requirements.carnitine, | ||
| energy: residualEnergy, | 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 = '< | let tableHtml = '< | ||
| - | tableHtml += '< | + | tableHtml += '< |
| tableHtml += '< | tableHtml += '< | ||
| tableHtml += '< | tableHtml += '< | ||
| - | tableHtml += '< | + | tableHtml += '< |
| + | tableHtml += '< | ||
| tableHtml += '< | tableHtml += '< | ||
| - | | + | tableHtml += '< |
| - | | + | |
| tableHtml += '< | tableHtml += '< | ||
| - | tableHtml += '< | + | tableHtml += '< |
| tableHtml += '< | tableHtml += '< | ||
| tableHtml += '< | tableHtml += '< | ||
| - | tableHtml += '< | + | tableHtml += '< |
| - | tableHtml += '< | + | tableHtml += '< |
| - | tableHtml += '< | + | tableHtml += '< |
| - | tableHtml += '< | + | tableHtml += '< |
| + | tableHtml += '< | ||
| tableHtml += '</ | tableHtml += '</ | ||
| - | | ||
| - | tableHtml += vitaminsNote; | ||
| - | tableHtml += bunNote; | ||
| | | ||
| document.getElementById(' | document.getElementById(' | ||
| document.getElementById(' | document.getElementById(' | ||
| document.getElementById(' | document.getElementById(' | ||
| - | document.getElementById(' | + | document.getElementById(' |
| + | |||
| + | // RESET del pulsante NPT quando si modificano i fabbisogni | ||
| + | resetParenteralButton(); | ||
| + | } | ||
| + | |||
| + | // FUNZIONE CALCOLO ELETTROLITI AGGIUNTIVI (DA VERSIONE 17) | ||
| + | function calculateElectrolyteAdditions(calciumNeeded, | ||
| + | const additions = { | ||
| + | ca_gluconato: | ||
| + | esafosfina: 0, | ||
| + | mg_sulfate: 0, | ||
| + | nacl: 0, | ||
| + | sodium_acetate: | ||
| + | kcl: 0, | ||
| + | totalVolume: | ||
| + | sodiumSource: | ||
| + | }; | ||
| + | |||
| + | // Determina il tipo di sodio da utilizzare | ||
| + | const sodiumTypeSelect = document.getElementById(' | ||
| + | const selectedSodiumType = sodiumTypeSelect ? sodiumTypeSelect.value : ' | ||
| + | additions.sodiumSource = selectedSodiumType; | ||
| + | |||
| + | // Calcola fabbisogni totali per paziente | ||
| + | const totalCalciumNeeded = calciumNeeded * currentWeightKg; | ||
| + | const totalPhosphorusNeeded = phosphorusNeeded * currentWeightKg; | ||
| + | const totalMagnesiumNeeded = magnesiumNeeded * currentWeightKg; | ||
| + | const totalSodiumNeeded = sodiumNeeded * currentWeightKg; | ||
| + | const totalPotassiumNeeded = potassiumNeeded * currentWeightKg; | ||
| + | |||
| + | // 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 === ' | ||
| + | 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 OSMOLARITÀ NPT (MIGLIORATA) | ||
| + | function calculateNPTOsmolarity(calc, | ||
| + | let totalOsmolarity = 0; | ||
| + | let osmolarityBreakdown = {}; | ||
| + | let componentDetails = []; | ||
| + | |||
| + | // Glucosio 50% - osmolarità molto alta | ||
| + | if (calc.neededGlucose > 0) { | ||
| + | const glucoseOsmol = (calc.glucose50Volume * parenteralConfig.glucose50.osmolarity) / calc.totalVolume; | ||
| + | osmolarityBreakdown.glucose = glucoseOsmol; | ||
| + | totalOsmolarity += glucoseOsmol; | ||
| + | componentDetails.push({ | ||
| + | name: ' | ||
| + | volume: calc.glucose50Volume, | ||
| + | concentration: | ||
| + | contribution: | ||
| + | }); | ||
| + | } | ||
| + | |||
| + | // Trophamine 6% | ||
| + | const proteinOsmol = (calc.proteinVolume * parenteralConfig.trophamine.osmolarity) / calc.totalVolume; | ||
| + | osmolarityBreakdown.protein = proteinOsmol; | ||
| + | totalOsmolarity += proteinOsmol; | ||
| + | componentDetails.push({ | ||
| + | name: ' | ||
| + | volume: calc.proteinVolume, | ||
| + | concentration: | ||
| + | contribution: | ||
| + | }); | ||
| + | |||
| + | // Intralipid 20% | ||
| + | const lipidOsmol = (calc.lipidVolume * parenteralConfig.intralipid.osmolarity) / calc.totalVolume; | ||
| + | osmolarityBreakdown.lipid = lipidOsmol; | ||
| + | totalOsmolarity += lipidOsmol; | ||
| + | componentDetails.push({ | ||
| + | name: ' | ||
| + | volume: calc.lipidVolume, | ||
| + | concentration: | ||
| + | contribution: | ||
| + | }); | ||
| + | |||
| + | // Elettroliti | ||
| + | if (calc.electrolyteAdditions.ca_gluconato > 0) { | ||
| + | const caOsmol = (calc.electrolyteAdditions.ca_gluconato * parenteralConfig.ca_gluconato.osmolarity) / calc.totalVolume; | ||
| + | osmolarityBreakdown.calcium = caOsmol; | ||
| + | totalOsmolarity += caOsmol; | ||
| + | componentDetails.push({ | ||
| + | name: ' | ||
| + | volume: calc.electrolyteAdditions.ca_gluconato, | ||
| + | concentration: | ||
| + | contribution: | ||
| + | }); | ||
| + | } | ||
| + | |||
| + | if (calc.electrolyteAdditions.esafosfina > 0) { | ||
| + | const pOsmol = (calc.electrolyteAdditions.esafosfina * parenteralConfig.esafosfina.osmolarity) / calc.totalVolume; | ||
| + | osmolarityBreakdown.phosphorus = pOsmol; | ||
| + | totalOsmolarity += pOsmol; | ||
| + | componentDetails.push({ | ||
| + | name: ' | ||
| + | volume: calc.electrolyteAdditions.esafosfina, | ||
| + | concentration: | ||
| + | contribution: | ||
| + | }); | ||
| + | } | ||
| + | |||
| + | if (calc.electrolyteAdditions.mg_sulfate > 0) { | ||
| + | const mgOsmol = (calc.electrolyteAdditions.mg_sulfate * parenteralConfig.mg_sulfate.osmolarity) / calc.totalVolume; | ||
| + | osmolarityBreakdown.magnesium = mgOsmol; | ||
| + | totalOsmolarity += mgOsmol; | ||
| + | componentDetails.push({ | ||
| + | name: ' | ||
| + | volume: calc.electrolyteAdditions.mg_sulfate, | ||
| + | concentration: | ||
| + | contribution: | ||
| + | }); | ||
| + | } | ||
| + | |||
| + | if (calc.electrolyteAdditions.nacl > 0) { | ||
| + | const naclOsmol = (calc.electrolyteAdditions.nacl * parenteralConfig.nacl.osmolarity) / calc.totalVolume; | ||
| + | osmolarityBreakdown.nacl = naclOsmol; | ||
| + | totalOsmolarity += naclOsmol; | ||
| + | componentDetails.push({ | ||
| + | name: 'Sodio Cloruro', | ||
| + | volume: calc.electrolyteAdditions.nacl, | ||
| + | concentration: | ||
| + | contribution: | ||
| + | }); | ||
| + | } | ||
| + | |||
| + | if (calc.electrolyteAdditions.sodium_acetate > 0) { | ||
| + | const naAcetOsmol = (calc.electrolyteAdditions.sodium_acetate * parenteralConfig.sodium_acetate.osmolarity) / calc.totalVolume; | ||
| + | osmolarityBreakdown.sodium_acetate = naAcetOsmol; | ||
| + | totalOsmolarity += naAcetOsmol; | ||
| + | componentDetails.push({ | ||
| + | name: 'Sodio Acetato', | ||
| + | volume: calc.electrolyteAdditions.sodium_acetate, | ||
| + | concentration: | ||
| + | contribution: | ||
| + | }); | ||
| + | } | ||
| + | |||
| + | if (calc.electrolyteAdditions.kcl > 0) { | ||
| + | const kclOsmol = (calc.electrolyteAdditions.kcl * parenteralConfig.kcl.osmolarity) / calc.totalVolume; | ||
| + | osmolarityBreakdown.kcl = kclOsmol; | ||
| + | totalOsmolarity += kclOsmol; | ||
| + | componentDetails.push({ | ||
| + | name: ' | ||
| + | volume: calc.electrolyteAdditions.kcl, | ||
| + | concentration: | ||
| + | contribution: | ||
| + | }); | ||
| + | } | ||
| + | |||
| + | // Vitamine e Carnitina (osmolarità bassa) | ||
| + | let vitaminsOsmol = 0; | ||
| + | if (residualNeeds.vitalipid > 0) { | ||
| + | const vitalipidVolume = residualNeeds.vitalipid * currentWeightKg; | ||
| + | const vitOsmol = (vitalipidVolume * 280) / calc.totalVolume; | ||
| + | vitaminsOsmol += vitOsmol; | ||
| + | componentDetails.push({ | ||
| + | name: ' | ||
| + | volume: vitalipidVolume, | ||
| + | concentration: | ||
| + | contribution: | ||
| + | }); | ||
| + | } | ||
| + | |||
| + | if (residualNeeds.soluvit > 0) { | ||
| + | const soluvitVolume = residualNeeds.soluvit * currentWeightKg; | ||
| + | const solOsmol = (soluvitVolume * 300) / calc.totalVolume; | ||
| + | vitaminsOsmol += solOsmol; | ||
| + | componentDetails.push({ | ||
| + | name: ' | ||
| + | volume: soluvitVolume, | ||
| + | concentration: | ||
| + | contribution: | ||
| + | }); | ||
| + | } | ||
| + | |||
| + | if (residualNeeds.peditrace > 0) { | ||
| + | const peditraceVolume = residualNeeds.peditrace * currentWeightKg; | ||
| + | const pedOsmol = (peditraceVolume * 350) / calc.totalVolume; | ||
| + | vitaminsOsmol += pedOsmol; | ||
| + | componentDetails.push({ | ||
| + | name: ' | ||
| + | volume: peditraceVolume, | ||
| + | concentration: | ||
| + | contribution: | ||
| + | }); | ||
| + | } | ||
| + | |||
| + | if (vitaminsOsmol > 0) { | ||
| + | osmolarityBreakdown.vitamins = vitaminsOsmol; | ||
| + | totalOsmolarity += vitaminsOsmol; | ||
| + | } | ||
| + | |||
| + | if (residualNeeds.carnitine > 0) { | ||
| + | const carnitineVolume = (residualNeeds.carnitine * currentWeightKg) / 100; | ||
| + | const carOsmol = (carnitineVolume * parenteralConfig.carnitene.osmolarity) / calc.totalVolume; | ||
| + | osmolarityBreakdown.carnitine = carOsmol; | ||
| + | totalOsmolarity += carOsmol; | ||
| + | componentDetails.push({ | ||
| + | name: ' | ||
| + | volume: carnitineVolume, | ||
| + | concentration: | ||
| + | contribution: | ||
| + | }); | ||
| + | } | ||
| + | |||
| + | return { | ||
| + | total: Math.round(totalOsmolarity), | ||
| + | breakdown: osmolarityBreakdown, | ||
| + | details: componentDetails, | ||
| + | isHypertonic: | ||
| + | requiresCVC: | ||
| + | }; | ||
| } | } | ||
| - | // FUNZIONE CALCOLO NPT PARENTERALE | + | // FUNZIONE CALCOLO NPT PARENTERALE |
| function calculateParenteral() { | function calculateParenteral() { | ||
| if (!window.residualNeeds) { | if (!window.residualNeeds) { | ||
| Linea 1704: | Linea 3260: | ||
| } | } | ||
| | | ||
| - | const currentWeight | + | const parentCurrentWeight |
| - | const currentWeightKg = currentWeight | + | const currentWeightKg = parentCurrentWeight |
| const residualNeeds = window.residualNeeds; | 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(' | ||
| + | } | ||
| + | if (residualNeeds.lipids > clinicalConfig.maxLipids) { | ||
| + | alerts.push(' | ||
| + | } | ||
| + | if (residualNeeds.protein > clinicalConfig.maxProtein) { | ||
| + | alerts.push(' | ||
| + | } | ||
| | | ||
| // Volume totale residuo richiesto | // Volume totale residuo richiesto | ||
| const totalVolume = Math.round(residualNeeds.liquids * currentWeightKg); | const totalVolume = Math.round(residualNeeds.liquids * currentWeightKg); | ||
| | | ||
| - | // Calcola elettroliti aggiuntivi necessari | + | // CALCOLA ELETTROLITI AGGIUNTIVI |
| const electrolyteAdditions = calculateElectrolyteAdditions( | const electrolyteAdditions = calculateElectrolyteAdditions( | ||
| residualNeeds.calcium, | residualNeeds.calcium, | ||
| Linea 1727: | Linea 3297: | ||
| const lipidVolume = Math.round((residualNeeds.lipids * currentWeightKg * 100) / 20); | const lipidVolume = Math.round((residualNeeds.lipids * currentWeightKg * 100) / 20); | ||
| | | ||
| - | // Volume vitamine/ | + | // Volume vitamine/ |
| - | const vitaminsVolume = residualNeeds.vitalipid + residualNeeds.soluvit + residualNeeds.peditrace; | + | const vitaminsVolume = (residualNeeds.vitalipid |
| + | const carnitineVolume = residualNeeds.carnitine > 0 ? (residualNeeds.carnitine * currentWeightKg) / 100 : 0; | ||
| | | ||
| - | // Volume utilizzato da proteine, lipidi, elettroliti e vitamine | + | // CALCOLO CON GLUCOSIO 50% + ACQUA BIDISTILLATA |
| - | const usedVolume | + | const neededGlucose |
| + | const glucose50Volume = (neededGlucose * 100) / 50; // ml di glucosio 50% necessari | ||
| | | ||
| - | // Volume | + | // Volume |
| - | const glucoseVolume | + | const usedVolume |
| | | ||
| - | // Calcolo concentrazione glucosio necessaria | + | // Volume rimanente = Acqua Bidistillata |
| - | const neededGlucose | + | const waterVolume |
| - | + | ||
| - | let glucoseConc = 10; | + | |
| - | let glucoseMessage = ''; | + | |
| - | + | ||
| - | if (glucoseVolume <= 0) { | + | |
| - | glucoseMessage = '< | + | |
| - | '• Volume totale richiesto: ' + totalVolume | + | |
| - | '• Volume proteine + lipidi: ' + (proteinVolume + lipidVolume) + ' ml< | + | |
| - | '• Volume elettroliti: | + | |
| - | '• Volume vitamine: ' + vitaminsVolume + ' ml< | + | |
| - | '• Volume glucosio risultante: ' + glucoseVolume + ' ml (NEGATIVO!)< | + | |
| - | '< | + | |
| - | + | ||
| - | document.getElementById(' | + | |
| - | document.getElementById(' | + | |
| - | document.getElementById(' | + | |
| - | document.getElementById(' | + | |
| - | + | ||
| - | document.getElementById(' | + | |
| - | document.getElementById(' | + | |
| - | return; | + | |
| - | } | + | |
| - | + | ||
| - | if (neededGlucose <= 0) { | + | |
| - | glucoseMessage = '< | + | |
| - | '• Tutto il glucosio necessario (' + (residualNeeds.carbs * currentWeightKg).toFixed(1) + 'g) proviene dall\' | + | |
| - | '• Apporto enterale: ' + (enteralData ? enteralData.carbs.toFixed(1) : 0) + ' g/ | + | |
| - | '• Non necessario glucosio in NPT</ | + | |
| - | + | ||
| - | glucoseConc = 0; | + | |
| - | document.getElementById(' | + | |
| - | } else { | + | |
| - | const requiredConcentration = (neededGlucose * 100) / glucoseVolume; | + | |
| - | + | ||
| - | if (requiredConcentration <= 12) { | + | |
| - | glucoseConc = 10; | + | |
| - | } else if (requiredConcentration <= 25) { | + | |
| - | glucoseConc = 20; | + | |
| - | } else if (requiredConcentration <= 40) { | + | |
| - | glucoseConc = 33; | + | |
| - | } else { | + | |
| - | glucoseConc = 50; | + | |
| - | } | + | |
| - | + | ||
| - | glucoseMessage = '< | + | |
| - | '• Glucosio necessario: ' + neededGlucose.toFixed(1) + ' | + | |
| - | '• Volume disponibile: | + | |
| - | '• Concentrazione richiesta: ' + requiredConcentration.toFixed(1) + ' | + | |
| - | '• Concentrazione selezionata: | + | |
| - | + | ||
| - | document.getElementById(' | + | |
| - | } | + | |
| - | + | ||
| - | // Calcoli finali | + | |
| - | const actualGlucose = (glucoseVolume * glucoseConc) / 100; | + | |
| - | const actualProtein = (proteinVolume * 6) / 100; | + | |
| - | const actualLipids = (lipidVolume * 20) / 100; | + | |
| - | + | ||
| - | const glucosePerKg = actualGlucose / currentWeightKg; | + | |
| - | const proteinPerKg = actualProtein / currentWeightKg; | + | |
| - | const lipidsPerKg = actualLipids / currentWeightKg; | + | |
| - | const totalKcal = (glucosePerKg * 4) + (proteinPerKg * 4) + (lipidsPerKg * 9); | + | |
| - | const glucoseRate = (glucosePerKg * 1000) / (24 * 60); | + | |
| | | ||
| document.getElementById(' | document.getElementById(' | ||
| + | document.getElementById(' | ||
| document.getElementById(' | document.getElementById(' | ||
| document.getElementById(' | document.getElementById(' | ||
| | | ||
| - | let resultHtml | + | let resultHtml = '< |
| - | + | resultHtml += '< | |
| - | resultHtml += '< | + | resultHtml += '< |
| - | resultHtml += '< | + | resultHtml += '< |
| resultHtml += '< | resultHtml += '< | ||
| if (enteralData && enteralData.additionalFluids > 0) { | if (enteralData && enteralData.additionalFluids > 0) { | ||
| resultHtml += '< | resultHtml += '< | ||
| - | } | ||
| - | resultHtml += '< | ||
| - | if (patientData.bun) { | ||
| - | const bunVal = parseFloat(patientData.bun); | ||
| - | if (bunVal < 9) { | ||
| - | resultHtml += ' | ||
| - | } else if (bunVal > 14) { | ||
| - | resultHtml += ' | ||
| - | } else { | ||
| - | resultHtml += ' | ||
| - | } | ||
| } | } | ||
| resultHtml += '</ | resultHtml += '</ | ||
| + | | ||
| + | // MOSTRA ALERT CLINICI SE PRESENTI | ||
| + | if (alerts.length > 0) { | ||
| + | resultHtml += '< | ||
| + | } | ||
| | | ||
| resultHtml += '< | resultHtml += '< | ||
| resultHtml += '< | resultHtml += '< | ||
| | | ||
| - | if (glucoseConc | + | if (neededGlucose |
| - | resultHtml += '< | + | resultHtml += '< |
| - | } else { | + | |
| - | resultHtml += '< | + | |
| } | } | ||
| | | ||
| - | resultHtml += '< | + | resultHtml += '< |
| - | resultHtml += '< | + | resultHtml += '< |
| | | ||
| - | // Elettroliti aggiuntivi | + | // ELETTROLITI AGGIUNTIVI |
| if (electrolyteAdditions.ca_gluconato > 0) { | if (electrolyteAdditions.ca_gluconato > 0) { | ||
| resultHtml += '< | resultHtml += '< | ||
| Linea 1851: | Linea 3353: | ||
| if (electrolyteAdditions.nacl > 0) { | if (electrolyteAdditions.nacl > 0) { | ||
| resultHtml += '< | resultHtml += '< | ||
| + | } | ||
| + | if (electrolyteAdditions.sodium_acetate > 0) { | ||
| + | resultHtml += '< | ||
| } | } | ||
| if (electrolyteAdditions.kcl > 0) { | if (electrolyteAdditions.kcl > 0) { | ||
| resultHtml += '< | resultHtml += '< | ||
| } | } | ||
| - | | + | |
| + | // VITAMINE | ||
| if (residualNeeds.vitalipid > 0) { | if (residualNeeds.vitalipid > 0) { | ||
| - | resultHtml += '< | + | |
| + | | ||
| } | } | ||
| if (residualNeeds.soluvit > 0) { | if (residualNeeds.soluvit > 0) { | ||
| - | resultHtml += '< | + | |
| + | | ||
| } | } | ||
| if (residualNeeds.peditrace > 0) { | if (residualNeeds.peditrace > 0) { | ||
| - | resultHtml += '< | + | |
| + | | ||
| } | } | ||
| | | ||
| - | resultHtml += '< | + | |
| + | // CARNITINA | ||
| + | if (residualNeeds.carnitine > 0) { | ||
| + | resultHtml += '< | ||
| + | } | ||
| + | |||
| + | // ACQUA BIDISTILLATA | ||
| + | if (waterVolume > 0) { | ||
| + | resultHtml += '< | ||
| + | } | ||
| + | |||
| + | | ||
| resultHtml += '</ | resultHtml += '</ | ||
| | | ||
| document.getElementById(' | document.getElementById(' | ||
| - | document.getElementById(' | ||
| | | ||
| - | // Aggiorna il pulsante a verde | + | // CALCOLO OSMOLARITÀ |
| - | const parenteralBtn | + | const osmolarityData |
| - | if (parenteralBtn) { | + | totalVolume: |
| - | | + | waterVolume: |
| - | | + | glucose50Volume: |
| + | proteinVolume: | ||
| + | lipidVolume: | ||
| + | electrolyteAdditions: | ||
| + | }, currentWeightKg, | ||
| + | |||
| + | // AGGIUNGI SEZIONE OSMOLARITÀ | ||
| + | let osmolarityHtml = '<div style=" | ||
| + | if (osmolarityData.isHypertonic) { | ||
| + | osmolarityHtml += '# | ||
| + | } else if (osmolarityData.requiresCVC) { | ||
| + | | ||
| + | } else { | ||
| + | osmolarityHtml += '# | ||
| + | } | ||
| + | osmolarityHtml += '">'; | ||
| + | osmolarityHtml += '< | ||
| + | osmolarityHtml += '< | ||
| + | osmolarityHtml += '< | ||
| + | osmolarityHtml += '< | ||
| + | |||
| + | if (osmolarityData.isHypertonic) { | ||
| + | | ||
| + | } else if (osmolarityData.requiresCVC) { | ||
| + | osmolarityHtml += '<p style=" | ||
| + | } else { | ||
| + | osmolarityHtml += '<p style=" | ||
| + | } | ||
| + | |||
| + | osmolarityHtml += '</ | ||
| + | osmolarityHtml += '< | ||
| + | osmolarityHtml += '< | ||
| + | osmolarityData.details.forEach(function(detail) { | ||
| + | if (detail.contribution > 30) { // Mostra contributi > 30 mOsm/L | ||
| + | osmolarityHtml += '<p style=" | ||
| } | } | ||
| + | }); | ||
| + | osmolarityHtml += '</ | ||
| + | osmolarityHtml += '</ | ||
| + | osmolarityHtml += '</ | ||
| + | |||
| + | document.getElementById(' | ||
| + | |||
| + | // CREAZIONE RICETTA PER PREPARAZIONE | ||
| + | const deflectorVolume = parseInt(document.getElementById(' | ||
| + | const totalVolumeWithDeflector = totalVolume + deflectorVolume; | ||
| + | const ratio = totalVolumeWithDeflector / totalVolume; | ||
| + | | ||
| + | let preparationHtml = '< | ||
| + | preparationHtml += '< | ||
| + | preparationHtml += '• < | ||
| + | preparationHtml += '• < | ||
| + | preparationHtml += '• < | ||
| + | preparationHtml += '</ | ||
| + | | ||
| + | preparationHtml += '< | ||
| + | preparationHtml += '< | ||
| + | | ||
| + | if (neededGlucose > 0) { | ||
| + | preparationHtml += '< | ||
| + | } | ||
| + | | ||
| + | preparationHtml += '< | ||
| + | preparationHtml += '< | ||
| + | | ||
| + | if (electrolyteAdditions.ca_gluconato > 0) { | ||
| + | preparationHtml += '< | ||
| + | } | ||
| + | if (electrolyteAdditions.esafosfina > 0) { | ||
| + | preparationHtml += '< | ||
| + | } | ||
| + | if (electrolyteAdditions.mg_sulfate > 0) { | ||
| + | preparationHtml += '< | ||
| + | } | ||
| + | if (electrolyteAdditions.nacl > 0) { | ||
| + | preparationHtml += '< | ||
| + | } | ||
| + | if (electrolyteAdditions.sodium_acetate > 0) { | ||
| + | preparationHtml += '< | ||
| + | } | ||
| + | if (electrolyteAdditions.kcl > 0) { | ||
| + | preparationHtml += '< | ||
| + | } | ||
| + | | ||
| + | // VITAMINE con denominazioni complete | ||
| + | if (residualNeeds.vitalipid > 0) { | ||
| + | const vitalipidVolume = residualNeeds.vitalipid * currentWeightKg; | ||
| + | preparationHtml += '< | ||
| + | } | ||
| + | if (residualNeeds.soluvit > 0) { | ||
| + | const soluvitVolume = residualNeeds.soluvit * currentWeightKg; | ||
| + | preparationHtml += '< | ||
| + | } | ||
| + | if (residualNeeds.peditrace > 0) { | ||
| + | const peditraceVolume = residualNeeds.peditrace * currentWeightKg; | ||
| + | preparationHtml += '< | ||
| + | } | ||
| + | | ||
| + | // CARNITINA con denominazione completa | ||
| + | if (residualNeeds.carnitine > 0) { | ||
| + | preparationHtml += '< | ||
| + | } | ||
| + | | ||
| + | if (waterVolume > 0) { | ||
| + | preparationHtml += '< | ||
| + | } | ||
| + | | ||
| + | preparationHtml += '< | ||
| + | preparationHtml += '< | ||
| + | preparationHtml += '< | ||
| + | |||
| + | // Aggiungi avvertenze osmolarità nella tabella di preparazione | ||
| + | if (osmolarityData.isHypertonic) { | ||
| + | preparationHtml += '< | ||
| + | } else if (osmolarityData.requiresCVC) { | ||
| + | preparationHtml += '< | ||
| + | } else { | ||
| + | preparationHtml += '< | ||
| + | } | ||
| + | preparationHtml += '</ | ||
| + | | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | | ||
| + | // Salva i dati per il report | ||
| + | window.nptCalculation = { | ||
| + | totalVolume: | ||
| + | waterVolume: | ||
| + | glucose50Volume: | ||
| + | proteinVolume: | ||
| + | lipidVolume: | ||
| + | gir: gir, | ||
| + | neededGlucose: | ||
| + | electrolyteAdditions: | ||
| + | vitaminsVolume: | ||
| + | carnitineVolume: | ||
| + | deflectorVolume: | ||
| + | osmolarityData: | ||
| + | }; | ||
| } | } | ||
| - | // FUNZIONI CONFIGURAZIONE | + | // FUNZIONI CONFIGURAZIONE |
| function populateEnteralConfigTable() { | function populateEnteralConfigTable() { | ||
| const tbody = document.getElementById(' | const tbody = document.getElementById(' | ||
| Linea 1922: | Linea 3581: | ||
| '< | '< | ||
| '< | '< | ||
| + | '< | ||
| '< | '< | ||
| '< | '< | ||
| Linea 1927: | Linea 3587: | ||
| } | } | ||
| - | function | + | function |
| - | const tbody = document.getElementById(' | + | const tbody = document.getElementById(' |
| if (!tbody) return; | if (!tbody) return; | ||
| | | ||
| - | | + | |
| - | const existingRows | + | |
| - | // Rimuovi tutte le righe tranne la prima (Prenidina FM85) | + | |
| - | | + | const row = tbody.insertRow(); |
| - | | + | row.innerHTML = '< |
| - | | + | '< |
| + | '< | ||
| + | '< | ||
| + | '< | ||
| + | '< | ||
| + | '< | ||
| + | '</ | ||
| + | '< | ||
| + | '< | ||
| + | }); | ||
| + | } | ||
| + | |||
| + | function populateNursesConfigTable() { | ||
| + | const tbody = document.getElementById(' | ||
| + | | ||
| | | ||
| - | | + | |
| - | Object.keys(fortifierData).forEach(function(key) { | + | Object.keys(nursesData).forEach(key |
| - | | + | const nurse = nursesData[key]; |
| - | | + | const row = tbody.insertRow(); |
| - | const row = tbody.insertRow(); | + | row.innerHTML = '< |
| - | row.innerHTML = '< | + | '< |
| - | | + | '< |
| - | '< | + | '< |
| - | '< | + | '< |
| - | '< | + | '< |
| - | '< | + | '</ |
| - | '< | + | '< |
| - | '< | + | '< |
| - | '< | + | }); |
| - | '< | + | } |
| - | '< | + | |
| - | '< | + | function populatePharmacistsConfigTable() { |
| - | } | + | const tbody = document.getElementById(' |
| + | if (!tbody) return; | ||
| + | |||
| + | tbody.innerHTML = ''; | ||
| + | Object.keys(pharmacistsData).forEach(key => { | ||
| + | const pharmacist = pharmacistsData[key]; | ||
| + | const row = tbody.insertRow(); | ||
| + | row.innerHTML = '< | ||
| + | '< | ||
| + | '< | ||
| + | '< | ||
| + | '< | ||
| + | '< | ||
| + | '</ | ||
| + | '< | ||
| + | '< | ||
| + | }); | ||
| + | } | ||
| + | |||
| + | function populateTechniciansConfigTable() { | ||
| + | const tbody = document.getElementById(' | ||
| + | if (!tbody) return; | ||
| + | |||
| + | tbody.innerHTML = ''; | ||
| + | Object.keys(technicianData).forEach(key => { | ||
| + | const technician = technicianData[key]; | ||
| + | const row = tbody.insertRow(); | ||
| + | row.innerHTML = '< | ||
| + | '< | ||
| + | '< | ||
| + | '< | ||
| + | '< | ||
| + | '< | ||
| + | '</ | ||
| + | '< | ||
| + | '< | ||
| }); | }); | ||
| } | } | ||
| - | // FUNZIONE PER MARCARE LE MODIFICHE NELLA CONFIGURAZIONE | ||
| function markConfigChanged(configType) { | function markConfigChanged(configType) { | ||
| let buttonId = ''; | let buttonId = ''; | ||
| Linea 1976: | Linea 3684: | ||
| buttonId = ' | buttonId = ' | ||
| buttonText = 'SALVA MODIFICHE FORTIFICANTI'; | buttonText = 'SALVA MODIFICHE FORTIFICANTI'; | ||
| + | break; | ||
| + | case ' | ||
| + | buttonId = ' | ||
| + | buttonText = 'SALVA MODIFICHE MEDICI'; | ||
| + | break; | ||
| + | case ' | ||
| + | buttonId = ' | ||
| + | buttonText = 'SALVA MODIFICHE INFERMIERE'; | ||
| + | break; | ||
| + | case ' | ||
| + | buttonId = ' | ||
| + | buttonText = 'SALVA MODIFICHE FARMACISTI'; | ||
| + | break; | ||
| + | case ' | ||
| + | buttonId = ' | ||
| + | buttonText = 'SALVA MODIFICHE TECNICI'; | ||
| + | break; | ||
| + | case ' | ||
| + | buttonId = ' | ||
| + | buttonText = 'SALVA PARAMETRI SISTEMA'; | ||
| break; | break; | ||
| } | } | ||
| Linea 1986: | Linea 3714: | ||
| } | } | ||
| - | // FUNZIONI CONFIGURAZIONE COMPLETE | + | |
| function updateEnteralConfig() { | function updateEnteralConfig() { | ||
| let changesCount = 0; | let changesCount = 0; | ||
| Linea 1993: | Linea 3721: | ||
| const oldValues = Object.assign({}, | const oldValues = Object.assign({}, | ||
| | | ||
| - | | + | |
| - | formulaData[key].carbs = parseFloat(document.getElementById(' | + | if (proteinEl) { |
| - | formulaData[key].lipids = parseFloat(document.getElementById(' | + | formulaData[key].protein = parseFloat(proteinEl.value); |
| - | formulaData[key].sodium = parseFloat(document.getElementById(' | + | formulaData[key].carbs = parseFloat(document.getElementById(' |
| - | formulaData[key].potassium = parseFloat(document.getElementById(' | + | formulaData[key].lipids = parseFloat(document.getElementById(' |
| - | formulaData[key].calcium = parseFloat(document.getElementById(' | + | formulaData[key].sodium = parseFloat(document.getElementById(' |
| - | formulaData[key].phosphorus = parseFloat(document.getElementById(' | + | formulaData[key].potassium = parseFloat(document.getElementById(' |
| - | formulaData[key].magnesium = parseFloat(document.getElementById(' | + | formulaData[key].calcium = parseFloat(document.getElementById(' |
| - | formulaData[key].energy = parseFloat(document.getElementById(' | + | formulaData[key].phosphorus = parseFloat(document.getElementById(' |
| - | + | formulaData[key].magnesium = parseFloat(document.getElementById(' | |
| - | if (JSON.stringify(oldValues) !== JSON.stringify(formulaData[key])) { | + | formulaData[key].energy = parseFloat(document.getElementById(' |
| - | changesCount++; | + | |
| + | if (JSON.stringify(oldValues) !== JSON.stringify(formulaData[key])) { | ||
| + | changesCount++; | ||
| + | } | ||
| } | } | ||
| }); | }); | ||
| - | | ||
| - | // SALVA NEL LOCALSTORAGE | ||
| - | saveToStorage(); | ||
| | | ||
| const button = document.getElementById(' | const button = document.getElementById(' | ||
| Linea 2020: | Linea 3748: | ||
| }, 3000); | }, 3000); | ||
| } | } | ||
| - | | ||
| - | console.log(' | ||
| } | } | ||
| Linea 2030: | Linea 3756: | ||
| const oldValues = Object.assign({}, | const oldValues = Object.assign({}, | ||
| | | ||
| - | | + | |
| - | parenteralConfig[key].carbs = parseFloat(document.getElementById(' | + | if (proteinEl) { |
| - | parenteralConfig[key].lipids = parseFloat(document.getElementById(' | + | parenteralConfig[key].protein = parseFloat(proteinEl.value); |
| - | parenteralConfig[key].sodium = parseFloat(document.getElementById(' | + | parenteralConfig[key].carbs = parseFloat(document.getElementById(' |
| - | parenteralConfig[key].potassium = parseFloat(document.getElementById(' | + | parenteralConfig[key].lipids = parseFloat(document.getElementById(' |
| - | parenteralConfig[key].calcium = parseFloat(document.getElementById(' | + | parenteralConfig[key].sodium = parseFloat(document.getElementById(' |
| - | parenteralConfig[key].phosphorus = parseFloat(document.getElementById(' | + | parenteralConfig[key].potassium = parseFloat(document.getElementById(' |
| - | parenteralConfig[key].magnesium = parseFloat(document.getElementById(' | + | parenteralConfig[key].calcium = parseFloat(document.getElementById(' |
| - | parenteralConfig[key].energy = parseFloat(document.getElementById(' | + | parenteralConfig[key].phosphorus = parseFloat(document.getElementById(' |
| - | parenteralConfig[key].water = parseFloat(document.getElementById(' | + | parenteralConfig[key].magnesium = parseFloat(document.getElementById(' |
| - | + | parenteralConfig[key].energy = parseFloat(document.getElementById(' | |
| - | if (JSON.stringify(oldValues) !== JSON.stringify(parenteralConfig[key])) { | + | parenteralConfig[key].water = parseFloat(document.getElementById(' |
| - | changesCount++; | + | |
| + | |||
| + | | ||
| + | changesCount++; | ||
| + | } | ||
| } | } | ||
| }); | }); | ||
| - | | ||
| - | // SALVA NEL LOCALSTORAGE | ||
| - | saveToStorage(); | ||
| | | ||
| const button = document.getElementById(' | const button = document.getElementById(' | ||
| Linea 2058: | Linea 3785: | ||
| }, 3000); | }, 3000); | ||
| } | } | ||
| - | | ||
| - | console.log(' | ||
| } | } | ||
| function updateFortifierConfig() { | function updateFortifierConfig() { | ||
| // Aggiorna Prenidina FM85 predefinita | // Aggiorna Prenidina FM85 predefinita | ||
| - | | + | |
| - | fortifierData.prenidina_fm85.carbs = parseFloat(document.getElementById(' | + | if (proteinEl) { |
| - | fortifierData.prenidina_fm85.lipids = parseFloat(document.getElementById(' | + | fortifierData.prenidina_fm85.protein = parseFloat(proteinEl.value); |
| - | fortifierData.prenidina_fm85.sodium = parseFloat(document.getElementById(' | + | fortifierData.prenidina_fm85.carbs = parseFloat(document.getElementById(' |
| - | fortifierData.prenidina_fm85.potassium = parseFloat(document.getElementById(' | + | fortifierData.prenidina_fm85.lipids = parseFloat(document.getElementById(' |
| - | fortifierData.prenidina_fm85.calcium = parseFloat(document.getElementById(' | + | fortifierData.prenidina_fm85.sodium = parseFloat(document.getElementById(' |
| - | fortifierData.prenidina_fm85.phosphorus = parseFloat(document.getElementById(' | + | fortifierData.prenidina_fm85.potassium = parseFloat(document.getElementById(' |
| - | fortifierData.prenidina_fm85.magnesium = parseFloat(document.getElementById(' | + | fortifierData.prenidina_fm85.calcium = parseFloat(document.getElementById(' |
| - | fortifierData.prenidina_fm85.energy = parseFloat(document.getElementById(' | + | fortifierData.prenidina_fm85.phosphorus = parseFloat(document.getElementById(' |
| + | fortifierData.prenidina_fm85.magnesium = parseFloat(document.getElementById(' | ||
| + | fortifierData.prenidina_fm85.energy = parseFloat(document.getElementById(' | ||
| + | } | ||
| | | ||
| - | | + | |
| - | let changesCount = 1; // Prenidina sempre aggiornata | + | if (button) { |
| - | Object.keys(fortifierData).forEach(function(key) { | + | button.className = ' |
| - | | + | button.innerHTML = ' |
| - | const proteinEl | + | setTimeout(() => { |
| - | if (proteinEl) { | + | button.className = ' |
| - | | + | button.innerHTML = 'Aggiorna |
| - | | + | }, 3000); |
| - | | + | } |
| - | | + | } |
| - | | + | |
| - | | + | function updateDoctorsConfig() { |
| - | | + | let changesCount = 0; |
| - | | + | |
| - | fortifierData[key].energy = parseFloat(document.getElementById(' | + | Object.keys(doctorsData).forEach(key |
| + | | ||
| + | |||
| + | | ||
| + | if (nameEl) { | ||
| + | const newName | ||
| + | const newSurname | ||
| + | const newTitle | ||
| + | |||
| + | doctorsData[key].name = newName; | ||
| + | | ||
| + | | ||
| + | | ||
| + | |||
| + | if (JSON.stringify(oldValues) !== JSON.stringify(doctorsData[key])) | ||
| changesCount++; | changesCount++; | ||
| } | } | ||
| Linea 2094: | Linea 3836: | ||
| }); | }); | ||
| | | ||
| - | | + | |
| - | | + | |
| | | ||
| - | const button = document.getElementById(' | + | const button = document.getElementById(' |
| if (button) { | if (button) { | ||
| button.className = ' | button.className = ' | ||
| - | button.innerHTML = 'FORTIFICANTI SALVATE | + | button.innerHTML = 'MEDICI SALVATI |
| setTimeout(() => { | setTimeout(() => { | ||
| button.className = ' | button.className = ' | ||
| - | button.innerHTML = ' | + | button.innerHTML = ' |
| }, 3000); | }, 3000); | ||
| } | } | ||
| + | } | ||
| + | |||
| + | function updateNursesConfig() { | ||
| + | let changesCount = 0; | ||
| | | ||
| - | | + | |
| + | const oldValues = Object.assign({}, | ||
| + | |||
| + | const nameEl = document.getElementById('nurse_' | ||
| + | if (nameEl) { | ||
| + | const newName = nameEl.value.trim(); | ||
| + | const newSurname = document.getElementById(' | ||
| + | const newTitle = document.getElementById(' | ||
| + | |||
| + | nursesData[key].name = newName; | ||
| + | nursesData[key].surname = newSurname; | ||
| + | nursesData[key].title = newTitle; | ||
| + | nursesData[key].fullName = newTitle + ' ' + newName + ' ' + newSurname; | ||
| + | |||
| + | if (JSON.stringify(oldValues) !== JSON.stringify(nursesData[key])) { | ||
| + | changesCount++; | ||
| + | } | ||
| + | } | ||
| + | }); | ||
| + | |||
| + | populateNursesConfigTable(); | ||
| + | |||
| + | const button = document.getElementById(' | ||
| + | if (button) { | ||
| + | button.className = ' | ||
| + | button.innerHTML = ' | ||
| + | setTimeout(() => { | ||
| + | button.className = ' | ||
| + | button.innerHTML = ' | ||
| + | }, 3000); | ||
| + | } | ||
| } | } | ||
| - | function | + | |
| + | function | ||
| + | let changesCount = 0; | ||
| + | |||
| + | Object.keys(pharmacistsData).forEach(key => { | ||
| + | const oldValues = Object.assign({}, | ||
| + | |||
| + | const nameEl = document.getElementById(' | ||
| + | if (nameEl) { | ||
| + | const newName = nameEl.value.trim(); | ||
| + | const newSurname = document.getElementById(' | ||
| + | const newTitle = document.getElementById(' | ||
| + | |||
| + | pharmacistsData[key].name = newName; | ||
| + | pharmacistsData[key].surname = newSurname; | ||
| + | pharmacistsData[key].title = newTitle; | ||
| + | pharmacistsData[key].fullName = newTitle + ' ' + newName + ' ' + newSurname; | ||
| + | |||
| + | if (JSON.stringify(oldValues) !== JSON.stringify(pharmacistsData[key])) { | ||
| + | changesCount++; | ||
| + | } | ||
| + | } | ||
| + | }); | ||
| + | |||
| + | populatePharmacistsConfigTable(); | ||
| + | |||
| + | const button = document.getElementById(' | ||
| + | if (button) { | ||
| + | button.className = ' | ||
| + | button.innerHTML = ' | ||
| + | setTimeout(() => { | ||
| + | button.className = ' | ||
| + | button.innerHTML = ' | ||
| + | }, 3000); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function updateTechniciansConfig() { | ||
| + | let changesCount = 0; | ||
| + | |||
| + | Object.keys(technicianData).forEach(key => { | ||
| + | const oldValues = Object.assign({}, | ||
| + | |||
| + | const nameEl = document.getElementById(' | ||
| + | if (nameEl) { | ||
| + | const newName = nameEl.value.trim(); | ||
| + | const newSurname = document.getElementById(' | ||
| + | const newTitle = document.getElementById(' | ||
| + | |||
| + | technicianData[key].name = newName; | ||
| + | technicianData[key].surname = newSurname; | ||
| + | technicianData[key].title = newTitle; | ||
| + | technicianData[key].fullName = newTitle + ' ' + newName + ' ' + newSurname; | ||
| + | |||
| + | if (JSON.stringify(oldValues) !== JSON.stringify(technicianData[key])) { | ||
| + | changesCount++; | ||
| + | } | ||
| + | } | ||
| + | }); | ||
| + | |||
| + | populateTechniciansConfigTable(); | ||
| + | |||
| + | const button = document.getElementById(' | ||
| + | if (button) { | ||
| + | button.className = ' | ||
| + | button.innerHTML = ' | ||
| + | setTimeout(() => { | ||
| + | button.className = ' | ||
| + | button.innerHTML = ' | ||
| + | }, 3000); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function updateSystemConfig() { | ||
| + | const button = document.getElementById(' | ||
| + | if (button) { | ||
| + | button.className = ' | ||
| + | button.innerHTML = ' | ||
| + | setTimeout(() => { | ||
| + | button.className = ' | ||
| + | button.innerHTML = ' | ||
| + | }, 3000); | ||
| + | } | ||
| + | |||
| + | resetParenteralButton(); | ||
| + | } | ||
| + | |||
| + | // FUNZIONI CONFIGURAZIONE CLINICA AVANZATA (NUOVE) | ||
| + | function updateClinicalConfig() { | ||
| + | clinicalConfig.calciumReq = parseFloat(document.getElementById(' | ||
| + | clinicalConfig.phosphorusReq = parseFloat(document.getElementById(' | ||
| + | clinicalConfig.magnesiumReq = parseFloat(document.getElementById(' | ||
| + | clinicalConfig.maxGIR = parseFloat(document.getElementById(' | ||
| + | clinicalConfig.maxLipids = parseFloat(document.getElementById(' | ||
| + | clinicalConfig.maxProtein = parseFloat(document.getElementById(' | ||
| + | |||
| + | alert(' | ||
| + | '• Calcio standard: ' + clinicalConfig.calciumReq + ' mg/ | ||
| + | '• Fosforo standard: ' + clinicalConfig.phosphorusReq + ' mg/ | ||
| + | '• GIR massimo: ' + clinicalConfig.maxGIR + ' mg/ | ||
| + | '• Lipidi massimi: ' + clinicalConfig.maxLipids + ' g/ | ||
| + | } | ||
| + | |||
| + | function resetConfiguration() { | ||
| + | // Reset configurazione clinica | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | |||
| + | // Reset configurazione sistema | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | |||
| + | // Reset configurazione clinica globale | ||
| + | clinicalConfig = { | ||
| + | calciumReq: 160, | ||
| + | phosphorusReq: | ||
| + | magnesiumReq: | ||
| + | maxGIR: 12.0, | ||
| + | maxLipids: 3.0, | ||
| + | maxProtein: 4.5, | ||
| + | hospitalName: | ||
| + | departmentName: | ||
| + | directorName: | ||
| + | }; | ||
| + | |||
| + | alert(' | ||
| + | } | ||
| + | |||
| + | function saveConfiguration() { | ||
| const config = { | const config = { | ||
| - | | + | |
| - | | + | |
| - | | + | departmentName: |
| - | | + | directorName: |
| - | | + | autoSave: document.getElementById(' |
| - | | + | decimalPlaces: |
| + | clinicalConfig: | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| }; | }; | ||
| | | ||
| - | | + | // Aggiorna configurazione clinica |
| - | const dataBlob = new Blob([dataStr], | + | |
| - | | + | |
| - | const link = document.createElement(' | + | |
| - | | + | |
| - | | + | |
| - | link.click(); | + | |
| - | URL.revokeObjectURL(url); | + | |
| | | ||
| - | | + | |
| + | window.savedConfig = config; | ||
| + | alert(' | ||
| + | ' | ||
| + | '• ' + Object.keys(doctorsData).length + ' medici\n' | ||
| + | '• ' + Object.keys(nursesData).length + ' infermiere\n' | ||
| + | '• ' + Object.keys(pharmacistsData).length + ' farmacisti\n' | ||
| + | '• ' + Object.keys(technicianData).length + ' tecnici di farmacia'); | ||
| } | } | ||
| - | function | + | function |
| - | | + | |
| - | if (!file) | + | alert('Prima completare tutti i calcoli precedenti'); |
| + | return; | ||
| + | } | ||
| | | ||
| - | const reader | + | const currentDate |
| - | | + | |
| - | | + | const prescriptionPatientWeightKg |
| - | const config | + | const calc = window.nptCalculation; |
| - | + | ||
| - | if (config.enteralFormulas) { | + | if (!calc) { |
| - | | + | alert(' |
| - | | + | return; |
| + | } | ||
| + | |||
| + | const birthDate = new Date(); | ||
| + | birthDate.setDate(birthDate.getDate() - patientData.daysOfLife); | ||
| + | |||
| + | // Genera ID prescrizione univoco (una sola volta per sessione) | ||
| + | if (!window.currentPrescriptionID) { | ||
| + | window.currentPrescriptionID = generatePreparationID(); | ||
| + | } | ||
| + | const prescriptionID = window.currentPrescriptionID; | ||
| + | |||
| + | // Recupera il medico attualmente selezionato | ||
| + | const currentPrescribingDoctor = document.getElementById(' | ||
| + | const doctorName = currentPrescribingDoctor && doctorsData[currentPrescribingDoctor] ? | ||
| + | doctorsData[currentPrescribingDoctor].fullName : | ||
| + | (patientData.prescribingDoctorName || 'Non specificato' | ||
| + | |||
| + | let html = '< | ||
| + | |||
| + | // INTESTAZIONE MEDICA (già OK secondo le tue indicazioni) | ||
| + | html += '< | ||
| + | |||
| + | // PARTE SINISTRA - INFO OSPEDALE | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '<p style=" | ||
| + | html += '</ | ||
| + | |||
| + | // PARTE DESTRA - LOGO ASST | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '</ | ||
| + | |||
| + | html += '</ | ||
| + | |||
| + | // TITOLO DOCUMENTO | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '</ | ||
| + | |||
| + | // INFO PAZIENTE (con cartella clinica e ID prescrizione) | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | if (prescriptionID) { | ||
| + | | ||
| + | } | ||
| + | |||
| + | |||
| + | html += '< | ||
| + | html += '< | ||
| + | |||
| + | if (patientData.gestationalWeeks && patientData.gestationalWeeks > 0) { | ||
| + | const gestDays = patientData.gestationalDays || 0; | ||
| + | html += '< | ||
| + | if (patientData.postConceptionalAge && patientData.postConceptionalAge.format) { | ||
| + | html += '< | ||
| + | } | ||
| + | } | ||
| + | html += '< | ||
| + | html += '</ | ||
| + | html += '</ | ||
| + | |||
| + | // LISTA DEGLI APPORTI PER LA GIORNATA CORRENTE | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | |||
| + | // Apporti enterali | ||
| + | if (enteralData && enteralData.volume > 0) { | ||
| + | const formulaType = document.getElementById(' | ||
| + | const formulaName = formulaData[formulaType] ? formulaData[formulaType].name : ' | ||
| + | html += '< | ||
| + | } | ||
| + | |||
| + | // Altri liquidi | ||
| + | if (enteralData && enteralData.additionalFluids > 0) { | ||
| + | const fluidType = document.getElementById(' | ||
| + | let fluidName = 'Altri liquidi'; | ||
| + | switch(fluidType) | ||
| + | | ||
| + | case ' | ||
| + | case ' | ||
| + | case ' | ||
| + | } | ||
| + | html += '< | ||
| + | } | ||
| + | |||
| + | // Se nessun apporto enterale | ||
| + | if (!enteralData || (enteralData.volume === 0 && enteralData.additionalFluids === 0)) { | ||
| + | html += '< | ||
| + | } | ||
| + | |||
| + | html += '</ | ||
| + | html += '</ | ||
| + | |||
| + | // COMPOSIZIONE PARENTERALE (con deflussore) | ||
| + | | ||
| + | const totalVolumeWithDeflector = calc.totalVolume + deflectorVolume; | ||
| + | const ratio = totalVolumeWithDeflector / calc.totalVolume; | ||
| + | |||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | |||
| + | // Componenti nell' | ||
| + | html += '< | ||
| + | |||
| + | if (calc.neededGlucose > 0) { | ||
| + | html += '< | ||
| + | } | ||
| + | |||
| + | if (calc.electrolyteAdditions.ca_gluconato > 0) { | ||
| + | html += '< | ||
| + | } | ||
| + | |||
| + | html += '< | ||
| + | if (calc.electrolyteAdditions.nacl > 0) { | ||
| + | html += '< | ||
| + | } else if (calc.electrolyteAdditions.sodium_acetate > 0) { | ||
| + | html += '< | ||
| + | } else { | ||
| + | html += '</ | ||
| + | } | ||
| + | |||
| + | if (calc.electrolyteAdditions.kcl > 0) { | ||
| + | html += '< | ||
| + | } | ||
| + | |||
| + | if (calc.electrolyteAdditions.mg_sulfate > 0) { | ||
| + | html += '< | ||
| + | } | ||
| + | |||
| + | html += '< | ||
| + | if (window.residualNeeds.carnitine > 0) { | ||
| + | const carnitineVolume = (window.residualNeeds.carnitine * prescriptionPatientWeightKg) / 100; | ||
| + | html += '< | ||
| + | } else { | ||
| + | html += '< | ||
| + | } | ||
| + | |||
| + | html += '< | ||
| + | |||
| + | if (calc.electrolyteAdditions.esafosfina > 0) { | ||
| + | html += '< | ||
| + | } | ||
| + | |||
| + | if (window.residualNeeds.peditrace > 0) { | ||
| + | const peditraceVolume = window.residualNeeds.peditrace * prescriptionPatientWeightKg; | ||
| + | html += '< | ||
| + | } else { | ||
| + | html += '< | ||
| + | } | ||
| + | |||
| + | if (window.residualNeeds.soluvit > 0) { | ||
| + | const soluvitVolume = window.residualNeeds.soluvit * prescriptionPatientWeightKg; | ||
| + | html += '< | ||
| + | } else { | ||
| + | html += '< | ||
| + | } | ||
| + | |||
| + | if (window.residualNeeds.vitalipid > 0) { | ||
| + | const vitalipidVolume = window.residualNeeds.vitalipid * prescriptionPatientWeightKg; | ||
| + | html += '< | ||
| + | } else { | ||
| + | html += '< | ||
| + | } | ||
| + | |||
| + | html += '< | ||
| + | |||
| + | // TOTALI | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '</ | ||
| + | html += '</ | ||
| + | |||
| + | // TOTALE ELEMENTI PRO KILO | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | |||
| + | // Calcola valori totali (enterali + parenterali) per kg | ||
| + | const totalLiquidsPerKg = window.residualNeeds.liquids; | ||
| + | const totalProteinPerKg = (enteralData ? enteralData.protein : 0) + window.residualNeeds.protein; | ||
| + | const totalLipidsPerKg = (enteralData ? enteralData.lipids : 0) + window.residualNeeds.lipids; | ||
| + | const totalCarbsPerKg = (enteralData ? enteralData.carbs : 0) + window.residualNeeds.carbs; | ||
| + | const totalCalciumPerKg = (enteralData ? enteralData.calcium : 0) + window.residualNeeds.calcium; | ||
| + | const totalPhosphorusPerKg = (enteralData ? enteralData.phosphorus : 0) + window.residualNeeds.phosphorus; | ||
| + | const totalSodiumPerKg = (enteralData ? enteralData.sodium : 0) + window.residualNeeds.sodium; | ||
| + | const totalPotassiumPerKg = (enteralData ? enteralData.potassium : 0) + window.residualNeeds.potassium; | ||
| + | const totalMagnesiumPerKg = (enteralData ? enteralData.magnesium : 0) + window.residualNeeds.magnesium; | ||
| + | const totalCarnitinePerKg = window.residualNeeds.carnitine; | ||
| + | const totalOligoelementsPerKg = window.residualNeeds.peditrace; | ||
| + | const totalVitLiposolubiliPerKg = window.residualNeeds.vitalipid; | ||
| + | const totalVitIdrosolubiliPerKg = window.residualNeeds.soluvit; | ||
| + | |||
| + | // Energia totale | ||
| + | const totalEnergyPerKg = window.residualNeeds.totalEnergyRequirement; | ||
| + | const nonProteinEnergyPerKg = totalEnergyPerKg - (totalProteinPerKg * 4); | ||
| + | |||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '</ | ||
| + | html += '</ | ||
| + | |||
| + | html += '</ | ||
| + | |||
| + | document.getElementById(' | ||
| + | } | ||
| + | |||
| + | function generateWorksheet() { | ||
| + | if (!window.residualNeeds || !patientData.currentWeight) { | ||
| + | alert(' | ||
| + | return; | ||
| + | } | ||
| + | |||
| + | const currentDate = new Date().toLocaleDateString(' | ||
| + | const calc = window.nptCalculation; | ||
| + | |||
| + | if (!calc) { | ||
| + | alert(' | ||
| + | return; | ||
| + | } | ||
| + | |||
| + | const birthDate = new Date(); | ||
| + | birthDate.setDate(birthDate.getDate() - patientData.daysOfLife); | ||
| + | |||
| + | // Recupera il medico attualmente selezionato | ||
| + | const currentPrescribingDoctor = document.getElementById(' | ||
| + | const doctorName = currentPrescribingDoctor && doctorsData[currentPrescribingDoctor] ? | ||
| + | doctorsData[currentPrescribingDoctor].fullName : | ||
| + | (patientData.prescribingDoctorName || ' | ||
| + | |||
| + | // Genera ID prescrizione per il foglio di lavoro | ||
| + | // Usa lo stesso ID prescrizione della sessione | ||
| + | if (!window.currentPrescriptionID) { | ||
| + | | ||
| + | } | ||
| + | const worksheetPreparationID = window.currentPrescriptionID; | ||
| + | |||
| + | let html = '< | ||
| + | |||
| + | // INTESTAZIONE ASST LECCO | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '</ | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '</ | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '</ | ||
| + | html += '</ | ||
| + | html += '</ | ||
| + | |||
| + | // TITOLO E DATA | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '</ | ||
| + | html += '</ | ||
| + | |||
| + | html += '< | ||
| + | |||
| + | // INFO PAZIENTE | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | if (worksheetPreparationID) { | ||
| + | html += '< | ||
| + | } | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | |||
| + | if (patientData.gestationalWeeks && patientData.gestationalWeeks > 0) { | ||
| + | const gestDays = patientData.gestationalDays || 0; | ||
| + | html += '< | ||
| + | if (patientData.postConceptionalAge && patientData.postConceptionalAge.format) { | ||
| + | html += '< | ||
| + | } | ||
| + | } | ||
| + | html += '< | ||
| + | html += '</ | ||
| + | html += '</ | ||
| + | |||
| + | // COMPOSIZIONE PARENTERALE - FORMATO FOGLIO DI LAVORO | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | |||
| + | // Ordine esatto come nel PDF del foglio di lavoro | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | |||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | |||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | |||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '</ | ||
| + | html += '</ | ||
| + | |||
| + | html += '</ | ||
| + | |||
| + | document.getElementById(' | ||
| + | } | ||
| + | |||
| + | function generateLabel() { | ||
| + | if (!window.residualNeeds || !patientData.currentWeight) { | ||
| + | alert(' | ||
| + | return; | ||
| + | } | ||
| + | |||
| + | const currentDate = new Date().toLocaleDateString(' | ||
| + | const currentTime = new Date().toLocaleTimeString(' | ||
| + | const calc = window.nptCalculation; | ||
| + | |||
| + | if (!calc) { | ||
| + | alert(' | ||
| + | return; | ||
| + | } | ||
| + | |||
| + | const birthDate = new Date(); | ||
| + | birthDate.setDate(birthDate.getDate() - patientData.daysOfLife); | ||
| + | |||
| + | // Recupera il medico attualmente selezionato | ||
| + | const currentPrescribingDoctor = document.getElementById(' | ||
| + | const doctorName = currentPrescribingDoctor && doctorsData[currentPrescribingDoctor] ? | ||
| + | doctorsData[currentPrescribingDoctor].fullName : | ||
| + | (patientData.prescribingDoctorName || ' | ||
| + | |||
| + | // Usa lo stesso ID prescrizione della sessione | ||
| + | if (!window.currentPrescriptionID) { | ||
| + | window.currentPrescriptionID = generatePreparationID(); | ||
| + | } | ||
| + | const labelPreparationID = window.currentPrescriptionID; | ||
| + | |||
| + | let html = '< | ||
| + | |||
| + | // INTESTAZIONE COMPATTA PER ETICHETTA | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '</ | ||
| + | |||
| + | |||
| + | // SEZIONE IDENTIFICAZIONE PAZIENTE - GRANDE E VISIBILE | ||
| + | html += '< | ||
| + | html += '< | ||
| + | |||
| + | // CODICE A BARRE per cartella clinica | ||
| + | if (patientData.medicalRecord && patientData.medicalRecord.trim() !== '' | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '</ | ||
| + | } | ||
| + | |||
| + | html += '< | ||
| + | html += '< | ||
| + | |||
| + | if (labelPreparationID) { | ||
| + | html += '< | ||
| + | } | ||
| + | |||
| + | html += '< | ||
| + | html += '< | ||
| + | |||
| + | if (patientData.gestationalWeeks && patientData.gestationalWeeks > 0) { | ||
| + | const gestDays = patientData.gestationalDays || 0; | ||
| + | html += '< | ||
| + | if (patientData.postConceptionalAge && patientData.postConceptionalAge.format) { | ||
| + | | ||
| + | } | ||
| + | } | ||
| + | |||
| + | html += '< | ||
| + | html += '</ | ||
| + | html += '</ | ||
| + | |||
| + | // SEZIONE PRESCRIZIONE | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '</ | ||
| + | html += '</ | ||
| + | |||
| + | // SEZIONE CONTENUTO SACCA - COMPATTA | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | |||
| + | // Solo componenti principali per l' | ||
| + | | ||
| + | html += '< | ||
| + | } | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | |||
| + | // Elettroliti principali | ||
| + | if (calc.electrolyteAdditions.ca_gluconato > 0) { | ||
| + | html += '< | ||
| + | } | ||
| + | if (calc.electrolyteAdditions.esafosfina > 0) { | ||
| + | html += '< | ||
| + | } | ||
| + | |||
| + | html += '< | ||
| + | html += '</ | ||
| + | html += '</ | ||
| + | |||
| + | html += '</ | ||
| + | |||
| + | document.getElementById(' | ||
| + | // Genera il codice a barre se presente la cartella clinica | ||
| + | if (patientData.medicalRecord && patientData.medicalRecord.trim() !== '' | ||
| + | setTimeout(() => { | ||
| + | const canvas = document.getElementById(' | ||
| + | if (canvas && window.SimpleBarcode) { | ||
| + | try { | ||
| + | | ||
| + | width: 2, | ||
| + | height: 60, | ||
| + | margin: 5, | ||
| + | background: "# | ||
| + | lineColor: "# | ||
| + | }); | ||
| + | | ||
| + | } catch (error) { | ||
| + | console.error(' | ||
| + | // Fallback: mostra solo il testo | ||
| + | const ctx = canvas.getContext(' | ||
| + | ctx.fillStyle = '# | ||
| + | ctx.font = '14px monospace'; | ||
| + | ctx.textAlign = ' | ||
| + | ctx.fillText(patientData.medicalRecord, | ||
| } | } | ||
| - | | + | } else { |
| - | if (config.parenteralComponents) { | + | |
| - | | + | } |
| - | | + | }, 100); |
| + | } | ||
| + | |||
| + | |||
| + | // Genera il codice a barre se presente la cartella clinica | ||
| + | if (patientData.medicalRecord && patientData.medicalRecord.trim() !== '' | ||
| + | setTimeout(() => { | ||
| + | const canvas = document.getElementById(' | ||
| + | if (canvas && window.JsBarcode) { | ||
| + | try { | ||
| + | | ||
| + | format: " | ||
| + | displayValue: | ||
| + | width: 2, | ||
| + | height: 60, | ||
| + | margin: 5, | ||
| + | background: "# | ||
| + | lineColor: "# | ||
| + | }); | ||
| + | | ||
| + | } catch (error) { | ||
| + | console.error(' | ||
| + | canvas.style.display = ' | ||
| } | } | ||
| + | } | ||
| + | }, 100); | ||
| + | } | ||
| + | |||
| + | } | ||
| + | |||
| + | // FUNZIONE GENERAZIONE PDF COMPLETA | ||
| + | function generatePDF(type) { | ||
| + | if (!window.residualNeeds || !patientData.currentWeight) { | ||
| + | alert(' | ||
| + | return; | ||
| + | } | ||
| + | |||
| + | const { jsPDF } = window.jspdf; | ||
| + | const doc = new jsPDF(); | ||
| + | | ||
| + | // INTESTAZIONE COMUNE | ||
| + | doc.setFontSize(10); | ||
| + | doc.text(clinicalConfig.departmentName, | ||
| + | doc.text(' | ||
| + | | ||
| + | // Logo ASST (posizionamento approssimativo) | ||
| + | doc.text(clinicalConfig.hospitalName, | ||
| + | | ||
| + | const currentDate = new Date().toLocaleDateString(' | ||
| + | doc.text(' | ||
| + | | ||
| + | if (type === ' | ||
| + | generateWorksheetPDFContent(doc); | ||
| + | } else if (type === ' | ||
| + | generatePrescriptionPDFContent(doc); | ||
| + | } else if (type === ' | ||
| + | generateLabelPDFContent(doc); | ||
| + | } | ||
| + | | ||
| + | // Salva il PDF | ||
| + | let fileName = ''; | ||
| + | switch(type) { | ||
| + | case ' | ||
| + | fileName = ' | ||
| + | break; | ||
| + | case ' | ||
| + | fileName = ' | ||
| + | break; | ||
| + | case ' | ||
| + | fileName = ' | ||
| + | break; | ||
| + | default: | ||
| + | fileName = ' | ||
| + | } | ||
| + | | ||
| + | doc.save(fileName); | ||
| + | } | ||
| + | // CONTENUTO PDF PRESCRIZIONE MEDICA | ||
| + | function generatePrescriptionPDFContent(doc) { | ||
| + | const currentDate = new Date().toLocaleDateString(' | ||
| + | const calc = window.nptCalculation; | ||
| + | const prescriptionPatientWeightKg = patientData.currentWeight / 1000; | ||
| + | | ||
| + | // Recupera il medico attualmente selezionato | ||
| + | const currentPrescribingDoctor = document.getElementById(' | ||
| + | const doctorName = currentPrescribingDoctor && doctorsData[currentPrescribingDoctor] ? | ||
| + | doctorsData[currentPrescribingDoctor].fullName : | ||
| + | (patientData.prescribingDoctorName || 'Non specificato' | ||
| + | | ||
| + | const birthDate = new Date(); | ||
| + | birthDate.setDate(birthDate.getDate() - patientData.daysOfLife); | ||
| + | | ||
| + | if (!window.currentPrescriptionID) { | ||
| + | window.currentPrescriptionID = generatePreparationID(); | ||
| + | } | ||
| + | const prescriptionID = window.currentPrescriptionID; | ||
| + | | ||
| + | let yPos = 50; | ||
| + | | ||
| + | doc.setFontSize(12); | ||
| + | doc.text(' | ||
| + | yPos += 20; | ||
| + | | ||
| + | doc.setFontSize(10); | ||
| + | doc.text(' | ||
| + | yPos += 10; | ||
| + | doc.text(' | ||
| + | yPos += 10; | ||
| + | doc.text(' | ||
| + | yPos += 10; | ||
| + | doc.text(' | ||
| + | yPos += 20; | ||
| + | | ||
| + | if (prescriptionID) { | ||
| + | doc.text(' | ||
| + | yPos += 10; | ||
| + | } | ||
| + | | ||
| + | // COMPOSIZIONE NPT | ||
| + | doc.text(' | ||
| + | yPos += 15; | ||
| + | | ||
| + | doc.text(' | ||
| + | yPos += 10; | ||
| + | doc.text(' | ||
| + | yPos += 10; | ||
| + | doc.text(' | ||
| + | yPos += 10; | ||
| + | | ||
| + | if (calc.osmolarityData) { | ||
| + | doc.text(' | ||
| + | yPos += 10; | ||
| + | } | ||
| + | | ||
| + | // Componenti principali | ||
| + | yPos += 10; | ||
| + | doc.text(' | ||
| + | yPos += 15; | ||
| + | | ||
| + | if (calc.neededGlucose > 0) { | ||
| + | doc.text(' | ||
| + | yPos += 8; | ||
| + | } | ||
| + | | ||
| + | doc.text(' | ||
| + | yPos += 8; | ||
| + | doc.text(' | ||
| + | yPos += 8; | ||
| + | doc.text(' | ||
| + | yPos += 15; | ||
| + | | ||
| + | // Fabbisogni per kg | ||
| + | const totalProteinPerKg = (enteralData ? enteralData.protein : 0) + window.residualNeeds.protein; | ||
| + | const totalLipidsPerKg = (enteralData ? enteralData.lipids : 0) + window.residualNeeds.lipids; | ||
| + | const totalCarbsPerKg = (enteralData ? enteralData.carbs : 0) + window.residualNeeds.carbs; | ||
| + | const totalEnergyPerKg = window.residualNeeds.totalEnergyRequirement; | ||
| + | | ||
| + | doc.text(' | ||
| + | yPos += 15; | ||
| + | doc.text(' | ||
| + | yPos += 8; | ||
| + | doc.text(' | ||
| + | yPos += 8; | ||
| + | doc.text(' | ||
| + | yPos += 8; | ||
| + | doc.text(' | ||
| + | } | ||
| + | |||
| + | // CONTENUTO PDF FOGLIO DI LAVORO | ||
| + | function generateWorksheetPDFContent(doc) { | ||
| + | const calc = window.nptCalculation; | ||
| + | | ||
| + | let yPos = 50; | ||
| + | | ||
| + | doc.setFontSize(12); | ||
| + | doc.text(' | ||
| + | yPos += 20; | ||
| + | | ||
| + | doc.setFontSize(10); | ||
| + | doc.text(' | ||
| + | yPos += 10; | ||
| + | doc.text(' | ||
| + | yPos += 10; | ||
| + | doc.text(' | ||
| + | yPos += 20; | ||
| + | | ||
| + | doc.text(' | ||
| + | yPos += 15; | ||
| + | | ||
| + | const deflectorVolume = parseInt(document.getElementById(' | ||
| + | const ratio = (calc.totalVolume + deflectorVolume) / calc.totalVolume; | ||
| + | | ||
| + | doc.text(' | ||
| + | yPos += 8; | ||
| + | doc.text(' | ||
| + | yPos += 8; | ||
| + | doc.text(' | ||
| + | yPos += 15; | ||
| + | | ||
| + | doc.text(' | ||
| + | yPos += 15; | ||
| + | | ||
| + | if (calc.neededGlucose > 0) { | ||
| + | doc.text(' | ||
| + | yPos += 8; | ||
| + | } | ||
| + | | ||
| + | doc.text(' | ||
| + | yPos += 8; | ||
| + | doc.text(' | ||
| + | yPos += 8; | ||
| + | doc.text(' | ||
| + | yPos += 15; | ||
| + | | ||
| + | if (calc.electrolyteAdditions.ca_gluconato > 0) { | ||
| + | doc.text(' | ||
| + | yPos += 8; | ||
| + | } | ||
| + | | ||
| + | if (calc.electrolyteAdditions.esafosfina > 0) { | ||
| + | doc.text(' | ||
| + | yPos += 8; | ||
| + | } | ||
| + | | ||
| + | doc.text(' | ||
| + | yPos += 8; | ||
| + | | ||
| + | if (calc.osmolarityData) { | ||
| + | doc.text(' | ||
| + | if (calc.osmolarityData.isHypertonic) { | ||
| + | yPos += 8; | ||
| + | doc.text(' | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | // CONTENUTO PDF ETICHETTA SACCA | ||
| + | function generateLabelPDFContent(doc) { | ||
| + | const currentDate = new Date().toLocaleDateString(' | ||
| + | const currentTime = new Date().toLocaleTimeString(' | ||
| + | const calc = window.nptCalculation; | ||
| + | | ||
| + | const birthDate = new Date(); | ||
| + | birthDate.setDate(birthDate.getDate() - patientData.daysOfLife); | ||
| + | | ||
| + | // Recupera il medico attualmente selezionato | ||
| + | const currentPrescribingDoctor = document.getElementById(' | ||
| + | const doctorName = currentPrescribingDoctor && doctorsData[currentPrescribingDoctor] ? | ||
| + | doctorsData[currentPrescribingDoctor].fullName : | ||
| + | (patientData.prescribingDoctorName || ' | ||
| + | | ||
| + | if (!window.currentPrescriptionID) { | ||
| + | window.currentPrescriptionID = generatePreparationID(); | ||
| + | } | ||
| + | const labelPreparationID = window.currentPrescriptionID; | ||
| + | | ||
| + | let yPos = 50; | ||
| + | | ||
| + | doc.setFontSize(14); | ||
| + | doc.setFont(undefined, | ||
| + | doc.text(' | ||
| + | yPos += 20; | ||
| + | | ||
| + | // IDENTIFICAZIONE PAZIENTE | ||
| + | doc.setFontSize(12); | ||
| + | doc.setFont(undefined, | ||
| + | doc.text(' | ||
| + | yPos += 15; | ||
| + | | ||
| + | doc.setFontSize(10); | ||
| + | doc.setFont(undefined, | ||
| + | doc.text(' | ||
| + | yPos += 10; | ||
| + | | ||
| + | if (labelPreparationID) { | ||
| + | doc.text(' | ||
| + | yPos += 10; | ||
| + | } | ||
| + | | ||
| + | doc.text(' | ||
| + | yPos += 10; | ||
| + | doc.text(' | ||
| + | yPos += 10; | ||
| + | | ||
| + | if (patientData.gestationalWeeks && patientData.gestationalWeeks > 0) { | ||
| + | const gestDays = patientData.gestationalDays || 0; | ||
| + | doc.text(' | ||
| + | yPos += 10; | ||
| + | if (patientData.postConceptionalAge && patientData.postConceptionalAge.format) { | ||
| + | doc.text(' | ||
| + | yPos += 10; | ||
| + | } | ||
| + | } | ||
| + | | ||
| + | doc.text(' | ||
| + | yPos += 20; | ||
| + | | ||
| + | // DATI PRESCRIZIONE | ||
| + | doc.setFontSize(12); | ||
| + | doc.setFont(undefined, | ||
| + | doc.text(' | ||
| + | yPos += 15; | ||
| + | | ||
| + | doc.setFontSize(10); | ||
| + | doc.setFont(undefined, | ||
| + | doc.text(' | ||
| + | yPos += 8; | ||
| + | doc.text(' | ||
| + | yPos += 8; | ||
| + | doc.text(' | ||
| + | yPos += 8; | ||
| + | doc.text(' | ||
| + | yPos += 20; | ||
| + | | ||
| + | // CONTENUTO SACCA | ||
| + | doc.setFontSize(12); | ||
| + | doc.setFont(undefined, | ||
| + | doc.text(' | ||
| + | yPos += 15; | ||
| + | | ||
| + | doc.setFontSize(10); | ||
| + | doc.setFont(undefined, | ||
| + | | ||
| + | if (calc.neededGlucose > 0) { | ||
| + | doc.text(' | ||
| + | yPos += 8; | ||
| + | } | ||
| + | | ||
| + | doc.text(' | ||
| + | yPos += 8; | ||
| + | doc.text(' | ||
| + | yPos += 8; | ||
| + | doc.text(' | ||
| + | yPos += 15; | ||
| + | | ||
| + | doc.setFont(undefined, | ||
| + | doc.text(' | ||
| + | yPos += 10; | ||
| + | doc.text(' | ||
| + | | ||
| + | // Osmolarità se disponibile | ||
| + | if (calc.osmolarityData) { | ||
| + | yPos += 15; | ||
| + | doc.setFontSize(11); | ||
| + | doc.text(' | ||
| + | | ||
| + | if (calc.osmolarityData.isHypertonic) { | ||
| + | yPos += 10; | ||
| + | doc.setTextColor(255, | ||
| + | doc.text(' | ||
| + | doc.setTextColor(0, | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | |||
| + | |||
| + | // FUNZIONI PLACEHOLDER | ||
| + | function showAddEnteralForm() { | ||
| + | alert(' | ||
| + | } | ||
| + | |||
| + | function showAddFortifierForm() { | ||
| + | alert(' | ||
| + | } | ||
| + | |||
| + | function showAddParenteralForm() { | ||
| + | alert(' | ||
| + | } | ||
| + | |||
| + | |||
| + | function showAddDoctorForm() { | ||
| + | const name = prompt(' | ||
| + | if (!name || name.trim() === '' | ||
| + | | ||
| + | const surname = prompt(' | ||
| + | if (!surname || surname.trim() === '' | ||
| + | | ||
| + | const title = prompt(' | ||
| + | if (!title || title.trim() === '' | ||
| + | | ||
| + | const key = ' | ||
| + | const fullName = title.trim() + ' ' + name.trim() + ' ' + surname.trim(); | ||
| + | | ||
| + | doctorsData[key] = { | ||
| + | name: name.trim(), | ||
| + | surname: surname.trim(), | ||
| + | title: title.trim(), | ||
| + | fullName: fullName | ||
| + | }; | ||
| + | | ||
| + | populateDoctorsConfigTable(); | ||
| + | updateDoctorsDropdown(); | ||
| + | alert(' | ||
| + | } | ||
| + | |||
| + | function showAddNurseForm() { | ||
| + | const name = prompt(' | ||
| + | if (!name || name.trim() === '' | ||
| + | | ||
| + | const surname = prompt(' | ||
| + | if (!surname || surname.trim() === '' | ||
| + | | ||
| + | const title = prompt(' | ||
| + | if (!title || title.trim() === '' | ||
| + | | ||
| + | const key = ' | ||
| + | const fullName = title.trim() + ' ' + name.trim() + ' ' + surname.trim(); | ||
| + | | ||
| + | nursesData[key] = { | ||
| + | name: name.trim(), | ||
| + | surname: surname.trim(), | ||
| + | title: title.trim(), | ||
| + | fullName: fullName | ||
| + | }; | ||
| + | | ||
| + | populateNursesConfigTable(); | ||
| + | alert(' | ||
| + | } | ||
| + | |||
| + | function showAddPharmacistForm() { | ||
| + | const name = prompt(' | ||
| + | if (!name || name.trim() === '' | ||
| + | | ||
| + | const surname = prompt(' | ||
| + | if (!surname || surname.trim() === '' | ||
| + | | ||
| + | const title = prompt(' | ||
| + | if (!title || title.trim() === '' | ||
| + | | ||
| + | const key = ' | ||
| + | const fullName = title.trim() + ' ' + name.trim() + ' ' + surname.trim(); | ||
| + | | ||
| + | pharmacistsData[key] = { | ||
| + | name: name.trim(), | ||
| + | surname: surname.trim(), | ||
| + | title: title.trim(), | ||
| + | fullName: fullName | ||
| + | }; | ||
| + | | ||
| + | populatePharmacistsConfigTable(); | ||
| + | alert(' | ||
| + | } | ||
| + | |||
| + | function showAddTechnicianForm() { | ||
| + | const name = prompt(' | ||
| + | if (!name || name.trim() === '' | ||
| + | | ||
| + | const surname = prompt(' | ||
| + | if (!surname || surname.trim() === '' | ||
| + | | ||
| + | const title = prompt(' | ||
| + | if (!title || title.trim() === '' | ||
| + | | ||
| + | const key = ' | ||
| + | const fullName = title.trim() + ' ' + name.trim() + ' ' + surname.trim(); | ||
| + | | ||
| + | technicianData[key] = { | ||
| + | name: name.trim(), | ||
| + | surname: surname.trim(), | ||
| + | title: title.trim(), | ||
| + | fullName: fullName | ||
| + | }; | ||
| + | | ||
| + | populateTechniciansConfigTable(); | ||
| + | alert(' | ||
| + | } | ||
| + | |||
| + | |||
| + | function removeEnteralFormula(key) { | ||
| + | if (confirm(' | ||
| + | alert(' | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function removeParenteralComponent(key) { | ||
| + | if (confirm(' | ||
| + | alert(' | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function removeFortifier(key) { | ||
| + | if (confirm(' | ||
| + | alert(' | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function removeDoctor(key) { | ||
| + | if (confirm(' | ||
| + | delete doctorsData[key]; | ||
| + | populateDoctorsConfigTable(); | ||
| + | updateDoctorsDropdown(); | ||
| + | alert(' | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function removeNurse(key) { | ||
| + | if (confirm(' | ||
| + | delete nursesData[key]; | ||
| + | populateNursesConfigTable(); | ||
| + | alert(' | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function removePharmacist(key) { | ||
| + | if (confirm(' | ||
| + | delete pharmacistsData[key]; | ||
| + | populatePharmacistsConfigTable(); | ||
| + | alert(' | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function removeTechnician(key) { | ||
| + | if (confirm(' | ||
| + | delete technicianData[key]; | ||
| + | populateTechniciansConfigTable(); | ||
| + | alert(' | ||
| + | } | ||
| + | } | ||
| + | |||
| + | // FUNZIONI VALIDAZIONE E ARCHIVIAZIONE PREPARAZIONE | ||
| + | function updatePreparationStaffDropdowns() { | ||
| + | console.log(' | ||
| + | | ||
| + | // Farmacisti | ||
| + | const pharmacistSelect = document.getElementById(' | ||
| + | if (pharmacistSelect) { | ||
| + | pharmacistSelect.innerHTML = '< | ||
| + | Object.keys(pharmacistsData).forEach(key => { | ||
| + | const option = document.createElement(' | ||
| + | option.value = key; | ||
| + | option.textContent = pharmacistsData[key].fullName; | ||
| + | pharmacistSelect.appendChild(option); | ||
| + | }); | ||
| + | console.log(' | ||
| + | } | ||
| + | | ||
| + | // Tecnici (per entrambe le dropdown) | ||
| + | [' | ||
| + | const select = document.getElementById(selectId); | ||
| + | if (select) { | ||
| + | select.innerHTML = '< | ||
| + | Object.keys(technicianData).forEach(key => { | ||
| + | const option = document.createElement(' | ||
| + | option.value = key; | ||
| + | option.textContent = technicianData[key].fullName; | ||
| + | select.appendChild(option); | ||
| + | }); | ||
| + | } | ||
| + | }); | ||
| + | console.log(' | ||
| + | } | ||
| + | |||
| + | // ===================================================== | ||
| + | // SISTEMA VALIDAZIONE E PREPARAZIONE IN DUE FASI | ||
| + | // ===================================================== | ||
| + | |||
| + | // FASE 1: Validazione Farmacista | ||
| + | function validatePrescription() { | ||
| + | const pharmacist = document.getElementById(' | ||
| + | | ||
| + | if (!pharmacist) { | ||
| + | alert(' | ||
| + | return; | ||
| + | } | ||
| + | | ||
| + | if (!window.residualNeeds || !window.nptCalculation || !patientData.currentWeight) { | ||
| + | alert(' | ||
| + | return; | ||
| + | } | ||
| + | | ||
| + | // Validazione completata | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | | ||
| + | // Mostra status validazione | ||
| + | const pharmacistName = pharmacistsData[pharmacist].fullName; | ||
| + | const validationHtml = '< | ||
| + | '< | ||
| + | '< | ||
| + | '< | ||
| + | '< | ||
| + | '</ | ||
| + | | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | | ||
| + | // Abilita fase 2 - Allestimento | ||
| + | enablePreparationPhase(); | ||
| + | | ||
| + | alert(' | ||
| + | } | ||
| + | |||
| + | // Abilita la fase di allestimento tecnici | ||
| + | function enablePreparationPhase() { | ||
| + | const tech1Select = document.getElementById(' | ||
| + | const tech2Select = document.getElementById(' | ||
| + | | ||
| + | // Abilita le dropdown tecnici | ||
| + | tech1Select.disabled = false; | ||
| + | tech2Select.disabled = false; | ||
| + | | ||
| + | // Popola le dropdown tecnici | ||
| + | [tech1Select, | ||
| + | select.innerHTML = '< | ||
| + | Object.keys(technicianData).forEach(key => { | ||
| + | const option = document.createElement(' | ||
| + | option.value = key; | ||
| + | option.textContent = technicianData[key].fullName; | ||
| + | select.appendChild(option); | ||
| + | }); | ||
| + | }); | ||
| + | | ||
| + | // Abilita il pulsante conferma (ma ancora non attivo finché non si selezionano i tecnici) | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | | ||
| + | // Event listeners per controllare quando entrambi i tecnici sono selezionati | ||
| + | [tech1Select, | ||
| + | select.addEventListener(' | ||
| + | }); | ||
| + | } | ||
| + | |||
| + | // Controlla se entrambi i tecnici sono selezionati | ||
| + | function checkTechniciansSelection() { | ||
| + | const tech1 = document.getElementById(' | ||
| + | const tech2 = document.getElementById(' | ||
| + | const confirmBtn = document.getElementById(' | ||
| + | | ||
| + | if (tech1 && tech2 && tech1 !== tech2) { | ||
| + | confirmBtn.className = ' | ||
| + | confirmBtn.innerHTML = '🧪 CONFERMA ALLESTIMENTO'; | ||
| + | } else if (tech1 === tech2 && tech1 !== '' | ||
| + | confirmBtn.className = ' | ||
| + | confirmBtn.innerHTML = ' | ||
| + | } else { | ||
| + | confirmBtn.className = ' | ||
| + | confirmBtn.innerHTML = '🧪 CONFERMA ALLESTIMENTO (seleziona tecnici)'; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | // FASE 2: Conferma Allestimento | ||
| + | function confirmPreparation() { | ||
| + | const tech1 = document.getElementById(' | ||
| + | const tech2 = document.getElementById(' | ||
| + | | ||
| + | if (!tech1 || !tech2) { | ||
| + | alert(' | ||
| + | return; | ||
| + | } | ||
| + | | ||
| + | if (tech1 === tech2) { | ||
| + | alert(' | ||
| + | return; | ||
| + | } | ||
| + | | ||
| + | // Allestimento confermato | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | | ||
| + | // Mostra status preparazione | ||
| + | const tech1Name = technicianData[tech1].fullName; | ||
| + | const tech2Name = technicianData[tech2].fullName; | ||
| + | const preparationHtml = '< | ||
| + | '< | ||
| + | '< | ||
| + | '< | ||
| + | '< | ||
| + | '< | ||
| + | '</ | ||
| + | | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | | ||
| + | // Abilita download JSON | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | |||
| + | // Abilita pulsante blocco prescrizione | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | |||
| + | // Genera e salva l'ID preparazione per il sistema di blocco | ||
| + | if (!window.currentPrescriptionID) { | ||
| + | window.currentPrescriptionID = generatePreparationID(); | ||
| + | } | ||
| + | window.lastPreparationID = window.currentPrescriptionID; | ||
| + | |||
| + | console.log(' | ||
| + | |||
| + | |||
| + | |||
| + | alert(' | ||
| + | } | ||
| + | |||
| + | // ===================================================== | ||
| + | // SISTEMA BLOCCO PRESCRIZIONE | ||
| + | // ===================================================== | ||
| + | |||
| + | // Variabile globale per stato blocco | ||
| + | window.prescriptionLocked = false; | ||
| + | |||
| + | // Funzione per bloccare la prescrizione | ||
| + | function lockPrescription() { | ||
| + | const confirmed = confirm( | ||
| + | '🔒 ATTENZIONE: BLOCCO PRESCRIZIONE\n\n' | ||
| + | ' | ||
| + | '• Non sarà più possibile modificare i dati\n' | ||
| + | '• La preparazione sarà considerata FINALIZZATA\n' | ||
| + | '• Per modifiche servirà una NUOVA prescrizione\n\n' | ||
| + | 'Sei sicuro di voler procedere?' | ||
| + | ); | ||
| + | | ||
| + | if (!confirmed) { | ||
| + | return; | ||
| + | } | ||
| + | | ||
| + | // Blocca la prescrizione | ||
| + | window.prescriptionLocked = true; | ||
| + | | ||
| + | // Aggiorna interfaccia | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | |||
| + | // Assicurati che l'ID preparazione sia disponibile per il banner | ||
| + | if (!window.lastPreparationID && window.currentPrescriptionID) { | ||
| + | window.lastPreparationID = window.currentPrescriptionID; | ||
| + | } | ||
| + | // Mostra banner di stato | ||
| + | showPrescriptionLockedBanner(); | ||
| + | | ||
| + | // Disabilita tutti i controlli di input | ||
| + | disableAllInputs(); | ||
| + | | ||
| + | alert(' | ||
| + | 'La prescrizione NPT è ora finalizzata e non può essere modificata.\n' | ||
| + | 'Per eventuali modifiche sarà necessaria una nuova prescrizione.' | ||
| + | } | ||
| + | |||
| + | // Mostra banner di prescrizione bloccata | ||
| + | function showPrescriptionLockedBanner() { | ||
| + | const currentDateTime = new Date().toLocaleString(' | ||
| + | const preparationID = window.lastPreparationID || window.currentPrescriptionID || ' | ||
| + | const bannerHtml = '< | ||
| + | '< | ||
| + | '< | ||
| + | '< | ||
| + | '< | ||
| + | '< | ||
| + | '</ | ||
| + | | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | } | ||
| + | |||
| + | // Disabilita tutti gli input quando prescrizione è bloccata | ||
| + | function disableAllInputs() { | ||
| + | // Disabilita TAB 2-4, mantieni TAB 1 accessibile per consultazione | ||
| + | const tabButtons = document.querySelectorAll(' | ||
| + | tabButtons.forEach((tab, | ||
| + | if (index > 0 && index < 4) { // Solo TAB 2-4, NON TAB 1 (index 0) | ||
| + | tab.style.opacity = ' | ||
| + | tab.style.pointerEvents = ' | ||
| + | tab.style.cursor = ' | ||
| + | } | ||
| + | }); | ||
| + | | ||
| + | // Disabilita input solo nei TAB 2-4, mantieni TAB 1 consultabile | ||
| + | const inputElements = document.querySelectorAll('# | ||
| + | '# | ||
| + | '# | ||
| + | |||
| + | inputElements.forEach(element => { | ||
| + | element.disabled = true; | ||
| + | element.style.opacity = ' | ||
| + | }); | ||
| + | |||
| + | // TAB 1: disabilita solo i pulsanti di modifica, mantieni visibili i dati | ||
| + | const tab1Buttons = document.querySelectorAll('# | ||
| + | tab1Buttons.forEach(button => { | ||
| + | button.disabled = true; | ||
| + | button.style.opacity = ' | ||
| + | }); | ||
| + | | ||
| + | // Mostra overlay sui TAB bloccati | ||
| + | addLockedOverlay(); | ||
| + | } | ||
| + | |||
| + | // Aggiunge overlay visivo sui TAB bloccati | ||
| + | function addLockedOverlay() { | ||
| + | const lockedTabs = [' | ||
| + | lockedTabs.forEach(tabId => { | ||
| + | const tabElement = document.getElementById(tabId); | ||
| + | if (tabElement && !tabElement.querySelector(' | ||
| + | const overlay = document.createElement(' | ||
| + | overlay.className = ' | ||
| + | overlay.style.cssText = ` | ||
| + | position: absolute; | ||
| + | top: 0; | ||
| + | left: 0; | ||
| + | width: 100%; | ||
| + | height: 100%; | ||
| + | background-color: | ||
| + | z-index: 1000; | ||
| + | display: flex; | ||
| + | align-items: | ||
| + | justify-content: | ||
| + | font-size: 24px; | ||
| + | font-weight: | ||
| + | color: #e74c3c; | ||
| + | pointer-events: | ||
| + | `; | ||
| + | overlay.innerHTML = '🔒 PRESCRIZIONE BLOCCATA'; | ||
| | | ||
| - | if (config.fortifierData) { | + | |
| - | | + | tabElement.appendChild(overlay); |
| - | | + | } |
| + | }); | ||
| + | } | ||
| + | |||
| + | // Funzione per iniziare nuova prescrizione | ||
| + | function startNewPrescription() { | ||
| + | const confirmed = confirm( | ||
| + | '📋 NUOVA PRESCRIZIONE NPT\n\n' | ||
| + | ' | ||
| + | '• Resetterà tutti i dati correnti\n' | ||
| + | '• Permetterà di iniziare una nuova prescrizione\n' | ||
| + | '• La prescrizione precedente rimarrà archiviata\n\n' | ||
| + | 'Vuoi procedere?' | ||
| + | ); | ||
| + | |||
| + | | ||
| + | return; | ||
| + | } | ||
| + | |||
| + | // Reset completo dell' | ||
| + | resetToNewPrescription(); | ||
| + | } | ||
| + | |||
| + | // Reset per nuova prescrizione | ||
| + | function resetToNewPrescription() { | ||
| + | // Reset variabili globali | ||
| + | window.prescriptionLocked = false; | ||
| + | window.residualNeeds = null; | ||
| + | window.nptCalculation = null; | ||
| + | window.monthlyPreparations = []; | ||
| + | window.currentPrescriptionID = null; | ||
| + | patientData = {}; | ||
| + | enteralData = null; | ||
| + | currentRequirements = null; | ||
| + | |||
| + | // Riabilita tutti gli input | ||
| + | enableAllInputs(); | ||
| + | |||
| + | // Reset tutti i form | ||
| + | resetAllForms(); | ||
| + | |||
| + | // Nascondi banner | ||
| + | document.getElementById(' | ||
| + | |||
| + | // Vai al TAB 1 | ||
| + | showTab(' | ||
| + | |||
| + | // Imposta nuova data | ||
| + | const today = new Date().toISOString().split(' | ||
| + | document.getElementById(' | ||
| + | |||
| + | alert(' | ||
| + | } | ||
| + | |||
| + | // Funzioni di supporto per reset completo | ||
| + | function enableAllInputs() { | ||
| + | // Riabilita tutti i TAB | ||
| + | const tabButtons = document.querySelectorAll(' | ||
| + | tabButtons.forEach(tab => { | ||
| + | tab.style.opacity = ' | ||
| + | tab.style.pointerEvents = ' | ||
| + | tab.style.cursor = ' | ||
| + | }); | ||
| + | |||
| + | // Riabilita tutti gli input | ||
| + | const inputElements = document.querySelectorAll('# | ||
| + | '# | ||
| + | '# | ||
| + | '# | ||
| + | |||
| + | inputElements.forEach(element => { | ||
| + | element.disabled = false; | ||
| + | element.style.opacity = ' | ||
| + | }); | ||
| + | |||
| + | // Rimuovi overlay bloccati | ||
| + | removeLockedOverlays(); | ||
| + | } | ||
| + | |||
| + | function removeLockedOverlays() { | ||
| + | const overlays = document.querySelectorAll(' | ||
| + | overlays.forEach(overlay => { | ||
| + | overlay.remove(); | ||
| + | }); | ||
| + | } | ||
| + | |||
| + | function resetAllForms() { | ||
| + | // Reset TAB 1 - Dati Paziente | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | |||
| + | // Reset pulsanti TAB 1 | ||
| + | const phaseBtn = document.getElementById(' | ||
| + | if (phaseBtn) { | ||
| + | phaseBtn.className = ' | ||
| + | phaseBtn.innerHTML = ' | ||
| + | phaseBtn.disabled = false; | ||
| + | } | ||
| + | |||
| + | // Nascondi risultati fase | ||
| + | const phaseResults = document.getElementById(' | ||
| + | if (phaseResults) { | ||
| + | phaseResults.classList.add(' | ||
| + | } | ||
| + | |||
| + | // Reset TAB 2 - Nutrizione Enterale | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | |||
| + | // Reset pulsanti TAB 2 | ||
| + | const enteralBtn = document.getElementById(' | ||
| + | if (enteralBtn) { | ||
| + | enteralBtn.className = ' | ||
| + | enteralBtn.innerHTML = ' | ||
| + | } | ||
| + | |||
| + | // Nascondi risultati enterali | ||
| + | const enteralResults = document.getElementById(' | ||
| + | if (enteralResults) { | ||
| + | enteralResults.classList.add(' | ||
| + | } | ||
| + | |||
| + | // Reset TAB 3 - Fabbisogni | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | resetNutritionFields(); | ||
| + | |||
| + | // Reset pulsanti TAB 3 | ||
| + | const loadBtn = document.getElementById(' | ||
| + | const nutritionBtn = document.getElementById(' | ||
| + | if (loadBtn) { | ||
| + | loadBtn.className = ' | ||
| + | loadBtn.innerHTML = ' | ||
| + | } | ||
| + | if (nutritionBtn) { | ||
| + | nutritionBtn.className = ' | ||
| + | nutritionBtn.innerHTML = ' | ||
| + | } | ||
| + | |||
| + | // Nascondi risultati nutrizione | ||
| + | const nutritionResults = document.getElementById(' | ||
| + | if (nutritionResults) { | ||
| + | nutritionResults.classList.add(' | ||
| + | } | ||
| + | |||
| + | // Reset TAB 4 - Parenterale | ||
| + | resetParenteralFields(); | ||
| + | |||
| + | // Reset TAB 5 - Report | ||
| + | resetReportFields(); | ||
| + | |||
| + | updateFortifierOptions(); | ||
| + | } | ||
| + | |||
| + | function resetNutritionFields() { | ||
| + | const nutritionFields = [ | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ]; | ||
| + | |||
| + | nutritionFields.forEach(fieldId => { | ||
| + | const field = document.getElementById(fieldId); | ||
| + | if (field) { | ||
| + | field.value = ' | ||
| + | } | ||
| + | }); | ||
| + | |||
| + | // Reset unità carboidrati | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | |||
| + | // Reset tipo sodio | ||
| + | document.getElementById(' | ||
| + | |||
| + | // Nascondi raccomandazione sodio | ||
| + | const sodiumRec = document.getElementById(' | ||
| + | if (sodiumRec) { | ||
| + | sodiumRec.classList.add(' | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function resetParenteralFields() { | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | |||
| + | const parenteralBtn = document.getElementById(' | ||
| + | if (parenteralBtn) { | ||
| + | parenteralBtn.className = ' | ||
| + | parenteralBtn.innerHTML = ' | ||
| + | } | ||
| + | |||
| + | const parenteralResults = document.getElementById(' | ||
| + | if (parenteralResults) { | ||
| + | parenteralResults.classList.add(' | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function resetReportFields() { | ||
| + | // Reset dropdown personale | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | |||
| + | // Reset pulsanti validazione/ | ||
| + | const validateBtn = document.getElementById(' | ||
| + | const confirmBtn = document.getElementById(' | ||
| + | const downloadBtn = document.getElementById(' | ||
| + | const lockBtn = document.getElementById(' | ||
| + | |||
| + | if (validateBtn) { | ||
| + | validateBtn.className = ' | ||
| + | validateBtn.innerHTML = '✅ VALIDA PRESCRIZIONE'; | ||
| + | validateBtn.disabled = false; | ||
| + | } | ||
| + | |||
| + | if (confirmBtn) { | ||
| + | confirmBtn.className = ' | ||
| + | confirmBtn.innerHTML = '🧪 CONFERMA ALLESTIMENTO'; | ||
| + | confirmBtn.disabled = true; | ||
| + | } | ||
| + | |||
| + | if (downloadBtn) { | ||
| + | downloadBtn.className = ' | ||
| + | downloadBtn.innerHTML = '💾 ARCHIVIA PREPARAZIONE (JSON)'; | ||
| + | downloadBtn.disabled = true; | ||
| + | } | ||
| + | |||
| + | if (lockBtn) { | ||
| + | lockBtn.className = ' | ||
| + | lockBtn.innerHTML = '🔒 BLOCCA PRESCRIZIONE'; | ||
| + | lockBtn.disabled = true; | ||
| + | lockBtn.style.backgroundColor = '# | ||
| + | } | ||
| + | |||
| + | // Nascondi status | ||
| + | const validationStatus = document.getElementById(' | ||
| + | const preparationStatus = document.getElementById(' | ||
| + | if (validationStatus) validationStatus.style.display = ' | ||
| + | if (preparationStatus) preparationStatus.style.display = ' | ||
| + | |||
| + | // Reset area report | ||
| + | document.getElementById(' | ||
| + | } | ||
| + | |||
| + | |||
| + | // SISTEMA DI ARCHIVIAZIONE JSON | ||
| + | function generatePreparationID() { | ||
| + | const medicalRecord = patientData.medicalRecord; | ||
| + | let prescriptionDate = patientData.prescriptionDate; | ||
| + | |||
| + | if (!medicalRecord || medicalRecord.trim() === '' | ||
| + | return null; | ||
| + | } | ||
| + | |||
| + | if (!prescriptionDate || prescriptionDate.trim() === '' | ||
| + | // Usa data odierna se non specificata | ||
| + | const today = new Date().toISOString().split(' | ||
| + | prescriptionDate = today; // ✅ Ora funziona correttamente | ||
| + | } | ||
| + | |||
| + | // Converte la data da YYYY-MM-DD a DDMMYYYY | ||
| + | const dateObj = new Date(prescriptionDate); | ||
| + | const day = dateObj.getDate().toString().padStart(2, | ||
| + | const month = (dateObj.getMonth() + 1).toString().padStart(2, | ||
| + | const year = dateObj.getFullYear().toString(); | ||
| + | const formattedDate = day + month + year; | ||
| + | |||
| + | // Crea chiave univoca per cartella + data | ||
| + | const counterKey = medicalRecord + ' | ||
| + | |||
| + | // Inizializza il contatore se non esiste | ||
| + | if (!window.preparationCounter) { | ||
| + | window.preparationCounter = {}; | ||
| + | } | ||
| + | |||
| + | if (!window.preparationCounter[counterKey]) { | ||
| + | window.preparationCounter[counterKey] = 0; | ||
| + | } | ||
| + | |||
| + | // Incrementa il contatore | ||
| + | window.preparationCounter[counterKey]++; | ||
| + | |||
| + | // Genera l'ID con formato: CARTELLA_DDMMYYYY_NN | ||
| + | const counter = window.preparationCounter[counterKey].toString().padStart(2, | ||
| + | const preparationID = medicalRecord + ' | ||
| + | |||
| + | return preparationID; | ||
| + | } | ||
| + | function createPreparationJSON() { | ||
| + | if (!window.residualNeeds || !window.nptCalculation || !patientData.currentWeight) { | ||
| + | alert(' | ||
| + | return null; | ||
| + | } | ||
| + | |||
| + | // Genera ID preparazione | ||
| + | const preparationID = generatePreparationID(); | ||
| + | if (!preparationID) { | ||
| + | alert(' | ||
| + | return null; | ||
| + | } | ||
| + | |||
| + | // Recupera dati personale | ||
| + | const pharmacistKey = document.getElementById(' | ||
| + | const tech1Key = document.getElementById(' | ||
| + | const tech2Key = document.getElementById(' | ||
| + | |||
| + | const pharmacistName = pharmacistKey ? pharmacistsData[pharmacistKey].fullName : 'NON SPECIFICATO'; | ||
| + | const tech1Name = tech1Key ? technicianData[tech1Key].fullName : 'NON SPECIFICATO'; | ||
| + | const tech2Name = tech2Key ? technicianData[tech2Key].fullName : 'NON SPECIFICATO'; | ||
| + | |||
| + | // Crea oggetto JSON completo | ||
| + | const preparationData = { | ||
| + | // IDENTIFICAZIONE | ||
| + | preparationID: | ||
| + | cartellaClinica: | ||
| + | dataPrescrizione: | ||
| + | dataCreazione: | ||
| + | |||
| + | // DATI PAZIENTE | ||
| + | paziente: { | ||
| + | pesoAttuale: | ||
| + | pesoNascita: | ||
| + | giorniVita: patientData.daysOfLife || 0, | ||
| + | etaGestazionale: | ||
| + | settimane: patientData.gestationalWeeks || null, | ||
| + | giorni: patientData.gestationalDays || null, | ||
| + | formato: patientData.gestationalWeeks && patientData.gestationalWeeks > 0 ? | ||
| + | patientData.gestationalWeeks + ' | ||
| } | } | ||
| + | }, | ||
| + | | ||
| + | // DATI CLINICI | ||
| + | parametriClinici: | ||
| + | bun: patientData.bun || null, | ||
| + | glicemia: patientData.glucose || null, | ||
| + | natremia: patientData.sodium || null, | ||
| + | ph: patientData.ph || null, | ||
| + | baseExcess: patientData.baseExcess || null, | ||
| + | diuresi: patientData.diuresis || null | ||
| + | }, | ||
| + | | ||
| + | // COMPOSIZIONE NPT | ||
| + | npt: { | ||
| + | volumeTotale: | ||
| + | energia: window.residualNeeds.energy.toFixed(1), | ||
| + | proteine: window.residualNeeds.protein.toFixed(2), | ||
| + | lipidi: window.residualNeeds.lipids.toFixed(2), | ||
| + | glucidi: window.residualNeeds.carbs.toFixed(2), | ||
| + | gir: window.nptCalculation.gir.toFixed(1), | ||
| + | osmolarita: window.nptCalculation.osmolarityData ? window.nptCalculation.osmolarityData.total : 0, | ||
| + | velocitaInfusione: | ||
| + | }, | ||
| + | | ||
| + | // COMPONENTI DETTAGLIATI | ||
| + | componenti: { | ||
| + | glucosio50: window.nptCalculation.glucose50Volume.toFixed(1), | ||
| + | trophamine: window.nptCalculation.proteinVolume.toFixed(1), | ||
| + | intralipid: window.nptCalculation.lipidVolume.toFixed(1), | ||
| + | acquaBidistillata: | ||
| + | elettroliti: | ||
| + | }, | ||
| + | | ||
| + | // PERSONALE | ||
| + | personale: { | ||
| + | medicoPrescrittore: | ||
| + | farmacistValidatore: | ||
| + | tecnico1: tech1Name, | ||
| + | tecnico2: tech2Name | ||
| + | }, | ||
| + | | ||
| + | // METADATA | ||
| + | sistema: { | ||
| + | versione: "NPT Calculator v3.0 UNIFIED", | ||
| + | dataCalcolo: | ||
| + | } | ||
| + | }; | ||
| + | | ||
| + | return preparationData; | ||
| + | } | ||
| + | |||
| + | function downloadPreparationJSON() { | ||
| + | console.log(' | ||
| + | | ||
| + | const preparationData = createPreparationJSON(); | ||
| + | if (!preparationData) { | ||
| + | return; // Errore già mostrato in createPreparationJSON | ||
| + | } | ||
| + | | ||
| + | try { | ||
| + | // Crea il file JSON | ||
| + | const jsonString = JSON.stringify(preparationData, | ||
| + | const blob = new Blob([jsonString], | ||
| + | | ||
| + | // Nome file: NPT_[ID].json | ||
| + | const filename = `NPT_${preparationData.preparationID}.json`; | ||
| + | | ||
| + | // Download automatico | ||
| + | const url = URL.createObjectURL(blob); | ||
| + | const a = document.createElement(' | ||
| + | a.href = url; | ||
| + | a.download = filename; | ||
| + | document.body.appendChild(a); | ||
| + | a.click(); | ||
| + | document.body.removeChild(a); | ||
| + | URL.revokeObjectURL(url); | ||
| + | | ||
| + | // Feedback successo | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | | ||
| + | alert(`✅ Preparazione archiviata con successo!\n\n` + | ||
| + | `📋 ID: ${preparationData.preparationID}\n` + | ||
| + | `📁 File: ${filename}\n` + | ||
| + | `📊 Dati: ${Object.keys(preparationData).length} sezioni salvate`); | ||
| + | // Salva ID per il sistema di blocco | ||
| + | window.lastPreparationID = preparationData.preparationID; | ||
| + | | ||
| + | console.log(' | ||
| + | | ||
| + | } catch (error) { | ||
| + | console.error(' | ||
| + | alert(' | ||
| + | } | ||
| + | } | ||
| + | |||
| + | |||
| + | // ===================================================== | ||
| + | // SISTEMA ARCHIVIAZIONE MENSILE EXCEL | ||
| + | // ===================================================== | ||
| + | |||
| + | // Variabile globale per i dati mensili | ||
| + | window.monthlyPreparations = []; | ||
| + | |||
| + | // Funzione per inizializzare il mese corrente | ||
| + | function initializeMonthlySection() { | ||
| + | const now = new Date(); | ||
| + | const currentMonth = now.getFullYear() + ' | ||
| + | document.getElementById(' | ||
| + | } | ||
| + | |||
| + | // Funzione anteprima dati mensili | ||
| + | function previewMonthlyData() { | ||
| + | const fileInput = document.getElementById(' | ||
| + | const files = fileInput.files; | ||
| + | | ||
| + | if (!files || files.length === 0) { | ||
| + | alert(' | ||
| + | return; | ||
| + | } | ||
| + | | ||
| + | // Reset dati precedenti | ||
| + | window.monthlyPreparations = []; | ||
| + | | ||
| + | let processedFiles = 0; | ||
| + | const totalFiles = files.length; | ||
| + | | ||
| + | // Processa tutti i file JSON | ||
| + | Array.from(files).forEach((file, | ||
| + | const reader = new FileReader(); | ||
| + | | ||
| + | reader.onload = function(e) { | ||
| + | try { | ||
| + | const jsonData = JSON.parse(e.target.result); | ||
| + | | ||
| + | // Valida che sia un file NPT valido | ||
| + | if (validateNPTJson(jsonData)) { | ||
| + | window.monthlyPreparations.push(jsonData); | ||
| + | } else { | ||
| + | console.warn(' | ||
| + | } | ||
| + | | ||
| + | processedFiles++; | ||
| + | | ||
| + | // Quando tutti i file sono processati, mostra l' | ||
| + | if (processedFiles === totalFiles) { | ||
| + | showMonthlyPreview(); | ||
| + | } | ||
| + | | ||
| + | } catch (error) { | ||
| + | console.error(' | ||
| + | processedFiles++; | ||
| + | | ||
| + | if (processedFiles === totalFiles) { | ||
| + | showMonthlyPreview(); | ||
| + | } | ||
| + | } | ||
| + | }; | ||
| + | | ||
| + | reader.readAsText(file); | ||
| + | }); | ||
| + | } | ||
| + | |||
| + | // Funzione di validazione JSON NPT | ||
| + | function validateNPTJson(data) { | ||
| + | return data && | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | } | ||
| + | |||
| + | // Funzione per mostrare l' | ||
| + | function showMonthlyPreview() { | ||
| + | const statsDiv = document.getElementById(' | ||
| + | const selectedMonth = document.getElementById(' | ||
| + | const monthName = new Date(selectedMonth + ' | ||
| + | year: ' | ||
| + | month: ' | ||
| + | }); | ||
| + | | ||
| + | if (window.monthlyPreparations.length === 0) { | ||
| + | statsDiv.innerHTML = '< | ||
| + | statsDiv.style.display = ' | ||
| + | return; | ||
| + | } | ||
| + | | ||
| + | // Calcola statistiche | ||
| + | const stats = calculateMonthlyStats(window.monthlyPreparations); | ||
| + | | ||
| + | let html = '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '< | ||
| + | html += '</ | ||
| + | | ||
| + | html += '< | ||
| + | html += '< | ||
| + | window.monthlyPreparations.forEach(prep => { | ||
| + | html += '• ' + prep.preparationID + ' (Cartella: ' + prep.cartellaClinica + ' | ||
| + | }); | ||
| + | html += '</ | ||
| + | | ||
| + | statsDiv.innerHTML = html; | ||
| + | statsDiv.style.display = ' | ||
| + | | ||
| + | // Abilita il pulsante Excel | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | } | ||
| + | |||
| + | // Funzione per calcolare statistiche mensili | ||
| + | function calculateMonthlyStats(preparations) { | ||
| + | const uniquePatients = new Set(preparations.map(p => p.cartellaClinica)).size; | ||
| + | const totalWeight = preparations.reduce((sum, | ||
| + | const totalGIR = preparations.reduce((sum, | ||
| + | const totalVolume = preparations.reduce((sum, | ||
| + | | ||
| + | return { | ||
| + | uniquePatients: | ||
| + | averageWeight: | ||
| + | averageGIR: totalGIR / preparations.length, | ||
| + | averageVolume: | ||
| + | }; | ||
| + | } | ||
| + | |||
| + | // Funzione principale per generare Excel mensile | ||
| + | function generateMonthlyExcel() { | ||
| + | if (!window.monthlyPreparations || window.monthlyPreparations.length === 0) { | ||
| + | alert(' | ||
| + | return; | ||
| + | } | ||
| + | | ||
| + | try { | ||
| + | // Crea un nuovo workbook | ||
| + | const wb = XLSX.utils.book_new(); | ||
| + | | ||
| + | // FOGLIO 1: Riepilogo Mensile | ||
| + | const summaryData = createSummarySheet(window.monthlyPreparations); | ||
| + | const ws_summary = XLSX.utils.aoa_to_sheet(summaryData); | ||
| + | XLSX.utils.book_append_sheet(wb, | ||
| + | | ||
| + | // FOGLIO 2: Dettaglio Preparazioni | ||
| + | const detailData = createDetailSheet(window.monthlyPreparations); | ||
| + | const ws_detail = XLSX.utils.aoa_to_sheet(detailData); | ||
| + | XLSX.utils.book_append_sheet(wb, | ||
| + | | ||
| + | // FOGLIO 3: Statistiche Cliniche | ||
| + | const statsData = createStatsSheet(window.monthlyPreparations); | ||
| + | const ws_stats = XLSX.utils.aoa_to_sheet(statsData); | ||
| + | XLSX.utils.book_append_sheet(wb, | ||
| + | | ||
| + | // FOGLIO 4: Componenti NPT | ||
| + | const componentsData = createComponentsSheet(window.monthlyPreparations); | ||
| + | const ws_components = XLSX.utils.aoa_to_sheet(componentsData); | ||
| + | XLSX.utils.book_append_sheet(wb, | ||
| + | | ||
| + | // Genera nome file | ||
| + | const selectedMonth = document.getElementById(' | ||
| + | const monthYear = selectedMonth.replace(' | ||
| + | const fileName = `NPT_Consolidato_${monthYear}.xlsx`; | ||
| + | | ||
| + | // Salva il file | ||
| + | XLSX.writeFile(wb, | ||
| + | | ||
| + | // Feedback successo | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | | ||
| + | alert(`✅ Excel generato con successo!\n\n` + | ||
| + | `📁 File: ${fileName}\n` + | ||
| + | `📊 Preparazioni: | ||
| + | `📋 Fogli: 4 (Riepilogo, Dettaglio, Statistiche, | ||
| + | | ||
| + | } catch (error) { | ||
| + | console.error(' | ||
| + | alert(' | ||
| + | } | ||
| + | } | ||
| + | |||
| + | // Crea foglio riepilogo mensile | ||
| + | function createSummarySheet(preparations) { | ||
| + | const selectedMonth = document.getElementById(' | ||
| + | const monthName = new Date(selectedMonth + ' | ||
| + | year: ' | ||
| + | month: ' | ||
| + | }); | ||
| + | | ||
| + | const stats = calculateMonthlyStats(preparations); | ||
| + | | ||
| + | const data = [ | ||
| + | [`REPORT MENSILE NPT - ${monthName.toUpperCase()}`, | ||
| + | [`Generato il: ${new Date().toLocaleDateString(' | ||
| + | [`Sistema: NPT Calculator v3.0 UNIFIED`, '', | ||
| + | ['', | ||
| + | [' | ||
| + | [' | ||
| + | [' | ||
| + | ['Peso medio pazienti:', | ||
| + | ['GIR medio:', | ||
| + | [' | ||
| + | ['', | ||
| + | [' | ||
| + | ['ELBW (≤1000g):', | ||
| + | ['VLBW (1001-1500g):', | ||
| + | ['LBW (1501-2500g):', | ||
| + | ['NBW (> | ||
| + | ['', | ||
| + | [' | ||
| + | ['0-7 giorni:', | ||
| + | ['8-14 giorni:', | ||
| + | [' | ||
| + | ['> | ||
| + | ]; | ||
| + | | ||
| + | return data; | ||
| + | } | ||
| + | |||
| + | // Crea foglio dettaglio preparazioni | ||
| + | function createDetailSheet(preparations) { | ||
| + | const header = [ | ||
| + | 'ID Preparazione', | ||
| + | 'Peso (g)', ' | ||
| + | ' | ||
| + | ' | ||
| + | ]; | ||
| + | | ||
| + | const data = [header]; | ||
| + | | ||
| + | preparations.forEach(prep => { | ||
| + | const row = [ | ||
| + | prep.preparationID || '', | ||
| + | prep.cartellaClinica || '', | ||
| + | prep.dataPrescrizione || '', | ||
| + | prep.personale? | ||
| + | prep.paziente? | ||
| + | prep.paziente? | ||
| + | prep.npt? | ||
| + | prep.npt? | ||
| + | prep.npt? | ||
| + | prep.npt? | ||
| + | prep.npt? | ||
| + | prep.npt? | ||
| + | prep.personale? | ||
| + | prep.personale? | ||
| + | prep.personale? | ||
| + | ]; | ||
| + | data.push(row); | ||
| + | }); | ||
| + | | ||
| + | return data; | ||
| + | } | ||
| + | |||
| + | // Crea foglio statistiche cliniche | ||
| + | function createStatsSheet(preparations) { | ||
| + | const header = [ | ||
| + | ' | ||
| + | ]; | ||
| + | | ||
| + | const data = [ | ||
| + | [' | ||
| + | ['', | ||
| + | header | ||
| + | ]; | ||
| + | | ||
| + | // Calcola statistiche per ogni parametro clinico | ||
| + | const parameters = [ | ||
| + | { name: 'Peso (g)', values: preparations.map(p => p.paziente.pesoAttuale).filter(v => v > 0) }, | ||
| + | { name: ' | ||
| + | { name: ' | ||
| + | { name: 'GIR (mg/ | ||
| + | { name: ' | ||
| + | { name: ' | ||
| + | { name: ' | ||
| + | { name: ' | ||
| + | ]; | ||
| + | | ||
| + | parameters.forEach(param => { | ||
| + | if (param.values.length > 0) { | ||
| + | const avg = param.values.reduce((a, | ||
| + | const min = Math.min(...param.values); | ||
| + | const max = Math.max(...param.values); | ||
| + | const variance = param.values.reduce((acc, | ||
| + | const stdDev = Math.sqrt(variance); | ||
| | | ||
| - | // SALVA LE MODIFICHE IMPORTATE | + | |
| - | | + | param.name, |
| - | + | avg.toFixed(2), | |
| - | | + | min.toFixed(2), |
| + | max.toFixed(2), | ||
| + | stdDev.toFixed(2), | ||
| + | param.values.length | ||
| + | ]); | ||
| + | } | ||
| + | }); | ||
| + | |||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | |||
| + | const bloodParams = [ | ||
| + | { name: ' | ||
| + | { name: 'Glicemia (mg/ | ||
| + | { name: 'Natremia (mEq/L)', values: preparations.map(p => parseFloat(p.parametriClinici? | ||
| + | { name: 'pH', values: preparations.map(p => parseFloat(p.parametriClinici? | ||
| + | ]; | ||
| + | |||
| + | bloodParams.forEach(param => { | ||
| + | if (param.values.length > 0) { | ||
| + | const avg = param.values.reduce((a, | ||
| + | const min = Math.min(...param.values); | ||
| + | const max = Math.max(...param.values); | ||
| + | const variance = param.values.reduce((acc, | ||
| + | const stdDev = Math.sqrt(variance); | ||
| | | ||
| - | } catch (error) { | + | data.push([ |
| - | | + | param.name, |
| + | avg.toFixed(2), | ||
| + | | ||
| + | max.toFixed(2), | ||
| + | stdDev.toFixed(2), | ||
| + | param.values.length | ||
| + | ]); | ||
| } | } | ||
| - | }; | + | }); |
| - | | + | |
| + | return data; | ||
| } | } | ||
| - | function | + | // Crea foglio componenti NPT |
| - | const resultsDiv | + | function |
| - | const configInfo = document.getElementById('configInfo'); | + | const header |
| + | 'ID Preparazione', | ||
| + | ' | ||
| + | 'Mg Solfato (ml)', 'NaCl (ml)', 'Na Acetato (ml)', 'KCl (ml)', | ||
| + | ' | ||
| + | ]; | ||
| | | ||
| - | | + | |
| - | | + | ['DETTAGLIO COMPONENTI NPT', '' |
| - | | + | ['' |
| + | header | ||
| + | ]; | ||
| | | ||
| - | | + | |
| - | | + | const comp = prep.componenti || {}; |
| - | | + | const row = [ |
| - | }, 8000); | + | prep.preparationID || '' |
| + | prep.cartellaClinica || '', | ||
| + | comp.glucosio50 || ' | ||
| + | comp.trophamine || ' | ||
| + | comp.intralipid || ' | ||
| + | comp.acquaBidistillata || ' | ||
| + | comp.elettroliti? | ||
| + | comp.elettroliti? | ||
| + | comp.elettroliti? | ||
| + | comp.elettroliti? | ||
| + | comp.elettroliti? | ||
| + | comp.elettroliti? | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | | ||
| + | data.push(row); | ||
| + | }); | ||
| + | |||
| + | // Aggiungi statistiche componenti | ||
| + | data.push(['', | ||
| + | data.push([' | ||
| + | data.push(['', | ||
| + | |||
| + | // Calcola medie componenti | ||
| + | const avgGlucose = preparations.reduce((sum, | ||
| + | const avgProtein = preparations.reduce((sum, | ||
| + | const avgLipid = preparations.reduce((sum, | ||
| + | const avgWater = preparations.reduce((sum, | ||
| + | |||
| + | data.push([' | ||
| + | data.push([' | ||
| + | data.push([' | ||
| + | data.push([' | ||
| + | data.push([' | ||
| + | |||
| + | return data; | ||
| + | } | ||
| + | |||
| + | // ===================================================== | ||
| + | // SISTEMA KNOWLEDGE BASE | ||
| + | // ===================================================== | ||
| + | |||
| + | // Funzione per mostrare sezioni Knowledge Base | ||
| + | function | ||
| + | // Nascondi tutte le sezioni knowledge | ||
| + | document.querySelectorAll(' | ||
| + | section.classList.remove(' | ||
| + | section.classList.add(' | ||
| + | }); | ||
| + | |||
| + | // Rimuovi classe active da tutti i tab knowledge | ||
| + | const knowledgeTabs = document.querySelectorAll('# | ||
| + | knowledgeTabs.forEach(tab => { | ||
| + | | ||
| + | | ||
| + | |||
| + | // Mostra la sezione selezionata | ||
| + | const targetSection = document.getElementById(sectionId); | ||
| + | if (targetSection) { | ||
| + | targetSection.classList.remove(' | ||
| + | targetSection.classList.add(' | ||
| } | } | ||
| + | | ||
| + | // Attiva il tab cliccato | ||
| + | const clickedTab = event.target.closest(' | ||
| + | if (clickedTab) { | ||
| + | clickedTab.classList.add(' | ||
| + | } | ||
| + | | ||
| + | console.log(' | ||
| } | } | ||
| - | // INIZIALIZZAZIONE | + | // Database delle regole di calcolo (expandibile) |
| - | document.addEventListener(' | + | const knowledgeBase = { |
| - | | + | calculationRules: |
| + | gir: { | ||
| + | name: " | ||
| + | formula: "(Glucidi g/kg/die × 1000) ÷ 1440", | ||
| + | unit: " | ||
| + | normalRange: | ||
| + | alerts: [ | ||
| + | | ||
| + | { condition: "> 15", action: " | ||
| + | ], | ||
| + | rationale: "Il GIR elevato può causare iperglicemia | ||
| + | }, | ||
| + | osmolarity: { | ||
| + | name: " | ||
| + | formula: " | ||
| + | unit: " | ||
| + | thresholds: [ | ||
| + | { range: "< 600", access: " | ||
| + | { range: " | ||
| + | { range: "> 900", access: "Solo CVC (ipertonica)", | ||
| + | ], | ||
| + | rationale: "L'osmolarità determina la via di accesso vascolare per evitare flebiti" | ||
| + | }, | ||
| + | proteinAdjustment: | ||
| + | name: " | ||
| + | rules: [ | ||
| + | { bun: "< 9 mg/ | ||
| + | { bun: "9-14 mg/ | ||
| + | { bun: "> 14 mg/ | ||
| + | ], | ||
| + | monitoring: " | ||
| + | } | ||
| + | }, | ||
| | | ||
| - | | + | |
| - | const configLoaded = loadFromStorage(); | + | |
| - | if (configLoaded) | + | elbw: { name: "ELBW ≤1000g", |
| - | | + | vlbw: { name: "VLBW 1001-1500g", |
| - | // Aggiorna status | + | |
| - | const statusDiv = document.getElementById(' | + | |
| - | if (statusDiv) | + | |
| - | | + | |
| - | statusDiv.style.background = '# | + | |
| } | } | ||
| - | } else { | + | }, |
| - | | + | |
| + | alerts: | ||
| + | | ||
| + | warning: [], | ||
| + | info: [] | ||
| } | } | ||
| + | }; | ||
| + | |||
| + | // Funzione per ottenere spiegazione di una regola | ||
| + | function getCalculationExplanation(parameter, | ||
| + | const rules = knowledgeBase.calculationRules; | ||
| + | let explanation = ""; | ||
| + | | ||
| + | switch(parameter) { | ||
| + | case ' | ||
| + | if (value > 12) { | ||
| + | explanation = " | ||
| + | } else if (value < 4) { | ||
| + | explanation = " | ||
| + | } else { | ||
| + | explanation = "✅ GIR ottimale: Range di sicurezza per neonati."; | ||
| + | } | ||
| + | break; | ||
| + | | ||
| + | case ' | ||
| + | if (value > 900) { | ||
| + | explanation = "🔴 Osmolarità ipertonica: OBBLIGATORIO accesso venoso centrale."; | ||
| + | } else if (value > 600) { | ||
| + | explanation = "🟠 Osmolarità elevata: Raccomandato accesso venoso centrale."; | ||
| + | } else { | ||
| + | explanation = "🟢 Osmolarità normale: Compatibile con accesso periferico."; | ||
| + | } | ||
| + | break; | ||
| + | | ||
| + | default: | ||
| + | explanation = " | ||
| + | } | ||
| + | | ||
| + | return explanation; | ||
| + | } | ||
| + | |||
| + | // Funzione per mostrare tooltip informativi | ||
| + | function showKnowledgeTooltip(element, | ||
| + | // Crea tooltip dinamico | ||
| + | const tooltip = document.createElement(' | ||
| + | tooltip.className = ' | ||
| + | tooltip.innerHTML = content; | ||
| + | tooltip.style.cssText = ` | ||
| + | position: absolute; | ||
| + | background-color: | ||
| + | color: white; | ||
| + | padding: 10px; | ||
| + | border-radius: | ||
| + | font-size: 12px; | ||
| + | max-width: 300px; | ||
| + | z-index: 1000; | ||
| + | box-shadow: 0 2px 10px rgba(0, | ||
| + | `; | ||
| + | | ||
| + | document.body.appendChild(tooltip); | ||
| + | | ||
| + | // Posiziona tooltip | ||
| + | const rect = element.getBoundingClientRect(); | ||
| + | tooltip.style.left = rect.left + ' | ||
| + | tooltip.style.top = (rect.bottom + 5) + ' | ||
| + | | ||
| + | // Rimuovi dopo 3 secondi | ||
| + | setTimeout(() => { | ||
| + | if (tooltip.parentNode) { | ||
| + | tooltip.remove(); | ||
| + | } | ||
| + | }, 3000); | ||
| + | } | ||
| + | |||
| + | // Aggiorna la funzione showTab esistente per gestire il knowledge base | ||
| + | function showTabOriginal(tabId) { | ||
| + | // Funzione originale già esistente - non modificare | ||
| + | // Questa è solo per referenza | ||
| + | } | ||
| + | |||
| + | // INIZIALIZZAZIONE | ||
| + | document.addEventListener(' | ||
| + | console.log(' | ||
| + | | ||
| + | // Imposta la data odierna come default | ||
| + | const today = new Date().toISOString().split(' | ||
| + | document.getElementById(' | ||
| + | | ||
| + | // Configura il campo cartella clinica | ||
| + | setupMedicalRecordField(); | ||
| | | ||
| document.getElementById(' | document.getElementById(' | ||
| Linea 2204: | Linea 6393: | ||
| }); | }); | ||
| | | ||
| + | // Event listeners per resettare Fabbisogni e NPT quando si modificano i valori manualmente | ||
| + | const requirementFields = [ | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ]; | ||
| + | | ||
| + | requirementFields.forEach(fieldId => { | ||
| + | const field = document.getElementById(fieldId); | ||
| + | if (field) { | ||
| + | field.addEventListener(' | ||
| + | resetNutritionButton(); | ||
| + | }); | ||
| + | field.addEventListener(' | ||
| + | resetNutritionButton(); | ||
| + | }); | ||
| + | } | ||
| + | }); | ||
| + | | ||
| + | // Event listener per il tipo di sodio | ||
| + | const sodiumTypeSelect = document.getElementById(' | ||
| + | if (sodiumTypeSelect) { | ||
| + | sodiumTypeSelect.addEventListener(' | ||
| + | updateSodiumChoice(); | ||
| + | updateSodiumRecommendation(); | ||
| + | }); | ||
| + | } | ||
| + | | ||
| + | // Event listener per il volume del deflussore | ||
| + | const deflectorVolumeInput = document.getElementById(' | ||
| + | if (deflectorVolumeInput) { | ||
| + | deflectorVolumeInput.addEventListener(' | ||
| + | resetParenteralButton(); | ||
| + | }); | ||
| + | } | ||
| + | | ||
| + | // Inizializza configurazione clinica avanzata | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| + | |||
| updateFortifierOptions(); | updateFortifierOptions(); | ||
| - | | + | // Inizializza tutte le dropdown e tabelle |
| + | updateDoctorsDropdown(); | ||
| + | console.log(' | ||
| + | // Test per verificare che la dropdown sia stata popolata | ||
| + | setTimeout(() => { | ||
| + | const prescribingDoctorSelect = document.getElementById(' | ||
| + | if (prescribingDoctorSelect) { | ||
| + | console.log(' | ||
| + | } | ||
| + | }, 500); | ||
| + | |||
| + | // Inizializza sezione mensile | ||
| + | initializeMonthlySection(); | ||
| + | | ||
| }); | }); | ||
| </ | </ | ||