Skip to content

Commit 1a6bd1c

Browse files
Update IACS-v3.html
Signed-off-by: Prof. J Kirtania <hodanesthtmcvns@gmail.com>
1 parent 2f19194 commit 1a6bd1c

1 file changed

Lines changed: 61 additions & 4 deletions

File tree

IACS-v3.html

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,14 @@
388388
.age-child { background:#dcfce7; color:#166534; }
389389
.age-adult { background:var(--tint2); color:var(--accent-deep); }
390390
.age-elderly { background:#ede9fe; color:#5b21b6; }
391+
392+
.co2-link-btn {
393+
font-size:10px; font-weight:600; padding:2px 7px; border-radius:5px;
394+
border:1px solid var(--accent-pale); background:var(--tint2);
395+
color:var(--accent-deep); cursor:pointer; font-family:var(--sans);
396+
transition:all 0.15s; white-space:nowrap;
397+
}
398+
.co2-link-btn.manual { background:#fee2e2; border-color:#fca5a5; color:#991b1b; }
391399
</style>
392400
</head>
393401
<body>
@@ -746,9 +754,12 @@ <h1>Inhalational Anaesthesia Cost Simulator - IACS-v3</h1>
746754
<span class="hint" id="slVolHint">Standard India hospital pack = 5 L</span>
747755
</div>
748756
<div class="ig">
749-
<label>Patient CO&#8322; (mL/min)</label>
750-
<input type="number" autocomplete="off" id="co2Rate" value="200" min="50" max="600" step="10">
751-
<span class="hint">Adult ~200 &middot; Paediatric ~100&ndash;150</span>
757+
<label style="display:flex;align-items:center;gap:6px;">
758+
Patient VCO₂ (mL/min)
759+
<button class="co2-link-btn" id="co2LinkBtn">🔗 auto</button>
760+
</label>
761+
<input type="number" autocomplete="off" id="co2Rate" value="200" min="10" max="800" step="5">
762+
<span class="hint" id="co2Hint">← VCO₂ = VO₂ × RQ 0.82 · edit to override</span>
752763
</div>
753764
<div class="ig">
754765
<label>Can life (derived)</label>
@@ -1469,6 +1480,7 @@ <h1>Inhalational Anaesthesia Cost Simulator - IACS-v3</h1>
14691480
const vco2v=vo2_up*0.82;
14701481
const vo2b=g('vo2Badge'); if(vo2b) vo2b.textContent=vo2_up.toFixed(0);
14711482
const vco2b=g('vco2Badge'); if(vco2b) vco2b.textContent=vco2v.toFixed(0);
1483+
if (typeof window._co2UpdateAuto==='function') window._co2UpdateAuto(vco2v);
14721484
const mmb=g('macMultBadge'); if(mmb) mmb.textContent=macMult.toFixed(3)+'×';
14731485
const mao=g('macAgeOut');
14741486
if(mao) mao.value=mac.toFixed(3)+'% | N₂O MAC: '+MAC_N2O_age.toFixed(1)+'%';
@@ -1635,7 +1647,9 @@ <h1>Inhalational Anaesthesia Cost Simulator - IACS-v3</h1>
16351647
update();
16361648
}
16371649
});
1638-
document.querySelectorAll('input[type=number]').forEach(inp=>inp.addEventListener('input',update));
1650+
document.querySelectorAll('input[type=number]').forEach(inp=>{
1651+
if(inp.id!=='co2Rate') inp.addEventListener('input',update); /* co2Rate handled by IIFE */
1652+
});
16391653
const ct=g('cylType');
16401654
if(ct){
16411655
ct.addEventListener('change',()=>{const p=CYL[ct.value];if(p){g('cylKg').value=p.kg;g('cylRefill').value=p.refill;}updateCylinder();update();});
@@ -1650,6 +1664,49 @@ <h1>Inhalational Anaesthesia Cost Simulator - IACS-v3</h1>
16501664
buildTable();
16511665
setAgent('sevo');
16521666

1667+
/* co2Rate auto-link to VCO2 */
1668+
(function(){
1669+
var co2Auto = true;
1670+
var co2El = document.getElementById('co2Rate');
1671+
var btnEl = document.getElementById('co2LinkBtn');
1672+
var hintEl = document.getElementById('co2Hint');
1673+
1674+
function setCo2Mode(auto, vco2val) {
1675+
co2Auto = auto;
1676+
if (btnEl) {
1677+
btnEl.textContent = auto ? '🔗 auto' : '✎ manual';
1678+
btnEl.className = auto ? 'co2-link-btn' : 'co2-link-btn manual';
1679+
}
1680+
if (hintEl) hintEl.textContent = auto
1681+
? '← VCO₂ = VO₂ × RQ 0.82 · edit to override'
1682+
: 'Manual override — click button to re-link';
1683+
if (auto && vco2val != null && co2El) {
1684+
co2El.value = Math.round(vco2val);
1685+
update();
1686+
}
1687+
}
1688+
1689+
if (co2El) co2El.addEventListener('input', function() {
1690+
if (co2Auto) { co2Auto = false; setCo2Mode(false, null); }
1691+
update(); /* always recalculate sodalime with new value */
1692+
});
1693+
1694+
if (btnEl) btnEl.addEventListener('click', function() {
1695+
var wEl = document.getElementById('ptWt');
1696+
var wKg = wEl ? (parseFloat(wEl.value)||70) : 70;
1697+
var vco2 = typeof brodyVO2==='function' ? brodyVO2(wKg)*0.82 : 163;
1698+
setCo2Mode(true, vco2);
1699+
});
1700+
1701+
window._co2UpdateAuto = function(vco2val) {
1702+
if (co2Auto && co2El) { co2El.value = Math.round(vco2val); }
1703+
};
1704+
/* initialise on load */
1705+
var initWt = document.getElementById('ptWt');
1706+
var initVco2 = typeof brodyVO2==='function' ? brodyVO2(parseFloat(initWt&&initWt.value)||70)*0.82 : 198;
1707+
if (co2El) co2El.value = Math.round(initVco2);
1708+
})();
1709+
16531710
/* ── capnograph button wiring ────────────────────────────── */
16541711
(function(){
16551712
const capBar = document.getElementById('capnoBar');

0 commit comments

Comments
 (0)