-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbabyfluid.html
655 lines (592 loc) · 20.3 KB
/
babyfluid.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<style type="text/css">
input[type=text] {
width: 4em;
text-align: right;
padding: 2px;
}
input.op {
border: 1px solid #bbb;
}
body {
font-size: 14px;
font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif;
}
h1 {
text-align: center;
color: #039;
}
footer {
text-align: center;
color: #666;
font-size: 10px;
}
footer a {
color: #666;
}
#maintable {
border-collapse: collapse;
font-size: 14px;
}
#maintable td {
padding: 4px;
padding-left: 15px;
padding-right: 15px;
min-width: 330px;
}
#maintable td b {
color: #039;
}
#maintable th {
font-size: 16px;
font-weight: normal;
color: #039;
padding: 10px 8px;
background: #f2f2ff;
}
#maintable tr {
border-bottom: 1px solid #ccc;
}
#maintable {
border: 0px;
}
#maintable td:nth-child(3) {
background-color: #f2fff2;
min-width: 260px;
}
</style>
<script language="JavaScript">
//This function taken from http://www.mediacollege.com/internet/javascript/number/round.html
function roundNumber(number, decimals) {
// Arguments: number to round, number of decimal places
var newnumber = new Number(number + '').toFixed(parseInt(decimals));
return parseFloat(newnumber);
}
function failWith(msg) {
var ops = document.getElementsByClassName("op")
for(var i = 0; i < ops.length; i++) {
ops[i].style.backgroundColor = "red";
}
alert(msg);
}
function resetOutputs() {
var ops = document.getElementsByClassName("op")
for(var i = 0; i < ops.length; i++) {
ops[i].value = "";
ops[i].style.backgroundColor = "white";
}
}
function calc() {
resetOutputs();
var W = document.fluidcalc.W.value * 1;
var TFR = document.fluidcalc.TFR.value * 1;
var SC = document.fluidcalc.SC.value * 1;
var TF = TFR * W; //total fluid to be given
// First remove other fluid infusions from TF:
TF -= document.fluidcalc.In.value * 24;
TF -= document.fluidcalc.Sd.value * 24;
TF -= document.fluidcalc.Pg.value * 24;
TF -= document.fluidcalc.MS.value * 24;
TF -= document.fluidcalc.Ot.value * 24;
if (TF < 0) {
failWith("Other infusions exceed Total Fluid Requirement!");
return;
}
// Lipids:
var L = document.fluidcalc.L.value * 1;
var hrs = document.fluidcalc.hrs.value * 1;
if (L > 0) {
if (hrs < 18) {
failWith("Lipids must be given for a minimum of 18 hours!");
return;
}
var L_conc;
if (document.getElementById('lipid_10').checked)
L_conc = .1;
else
L_conc = .2;
// Display lipid answers, and subtract from TF
document.fluidcalc.L_out.value = roundNumber(L * W / L_conc, 0);
TF -= L * W / L_conc;
// Add the multivitamins
var mvi_L = 0;
var mvi_L_con = document.fluidcalc.mvi_L_con.value;
if (document.fluidcalc.MVI_L.checked == true) {
mvi_L = roundNumber(TF * mvi_L_con / 50, 1);
document.fluidcalc.mvi_L_ans.value = mvi_L;
}
document.fluidcalc.L_rate.value = roundNumber((L * W / L_conc + mvi_L) / hrs, 1);
}
if (TF < 0) {
failWith("Infusions + Lipids exceed Total Fluid Requirement!");
return;
}
// Display total fluid to be given by drip:
document.fluidcalc.totalvol.value = roundNumber(TF, 0);
//correct the values of S,N,K for SC ml:
var S = document.fluidcalc.S.value * SC / (TF);
var N = document.fluidcalc.N.value * SC / (TF);
var N2 = document.fluidcalc.N2.value * SC / (TF); // TODO use symbolic solution and unify N/N2
var K = document.fluidcalc.K.value * SC / (TF);
var Mg = document.fluidcalc.Mg.value * SC / (TF);
var AA = document.fluidcalc.AA.value * SC / (TF);
// Amino acids: cant give unless SC = TF!
if (AA > 0 && roundNumber(SC, 0) != roundNumber(TF, 0)) {
failWith("Cannot give amino acids unless Syringe Capacity = Total Fluid to be given per day!");
return;
}
var sug10_con = document.fluidcalc.sug10_con.value * 1; // gm/ml
var sug50_con = document.fluidcalc.sug50_con.value * 1; // gm/ml
var nacl_con = document.fluidcalc.nacl_con.value * 1; // mEq/ml
var nahco3_con = document.fluidcalc.nahco3_con.value * 1;
var kcl_con = document.fluidcalc.kcl_con.value * 1; // mEq/ml
var ca_con = document.fluidcalc.ca_con.value * 1;
var mvi_con = document.fluidcalc.mvi_con.value * 1;
// Start filling the syringe:
var vol = SC;
//calculate vol of N,K etc:
var n = roundNumber(N * W / nacl_con, 1);
var n2 = roundNumber(N2 * W / nahco3_con, 1);
var k = roundNumber(K * W / kcl_con, 1);
var m = roundNumber(Mg * W, 2);
var aa = roundNumber(AA * W / .1, 0);
var mvi = 0, ca = 0, hep = 0;
if (document.fluidcalc.Ca.checked == true) {
if (N2 > 0) {
failWith("Cannot give both Calcium and NaHCO3; will cause precipitation!");
return;
}
ca = roundNumber(SC * ca_con / 50, 1);
}
if (document.fluidcalc.MVI.checked == true) {
mvi = roundNumber(SC * mvi_con / 50, 1);
}
//depending on type of vein, add heparin:
if (document.fluidcalc.VEIN[1].checked == true) {
hep = roundNumber(2.5 * SC / 50, 1);
}
vol -= n + n2 + k + m + aa + mvi + ca + hep;
// Trace elements is per SC ml, so just subtract that from vol here
vol -= document.fluidcalc.Tr.value * 1;
// assert vol > 0?
if (vol < 0) {
failWith("Requirements too much for this volume!");
return;
}
//now calculate the sugar solution:
var V = vol; // V is vol of sugar soln
var s = S * W; // s is gms of sugar needed in V ml
var a, b, h; // a mls of 1 %, b mls of 5%, h mls of H2O
if (s <= sug10_con * V) { //smaller conc than just 1 %
var s1 = Math.floor(s * 10) / 10, s2 = roundNumber(s - s1, 2); //This is accuracy of measurement of 1% is 1ml, 5 % is .1 ml
// alert("s :"+s+" s1: "+s1+" s2: "+s2);
a = roundNumber(s1 / sug10_con, 0); b = roundNumber(s2 / sug50_con, 1); h = roundNumber(V - a - b, 1);
} else if (s <= sug50_con * V) { //doable with 1% & 5%
var a1 = ((sug50_con * V) - (S * W)) / (sug50_con - sug10_con); //again due to inaccurate measurement, solve assuming perfect measurement
a = Math.floor(a1);
//Now make up the rest using 5 % and H2O:
var ss = s - (a * sug10_con); V -= a;
b = roundNumber(ss / sug50_con, 1); h = roundNumber(V - b, 1);
} else {
failWith("Sugar requirement too high to be made with the solutions at hand!");
return;
}
// all flags:
var sug_con_col = "white";
var osm_col = "white";
var npcn_col = "white";
//calculate sugar perc and flag if wrong vein:
var sug_con = roundNumber(((a * sug10_con) + (b * sug50_con)) * 100 / SC, 2);
if (sug_con > 12.5 && document.fluidcalc.VEIN[0].checked == true) {
alert("Sugar concentration too high for Peripheral vein!!");
sug_con_col = "red";
}
if (sug_con > 25 && document.fluidcalc.VEIN[1].checked == true) {
alert("Sugar concentration too high for Central vein!!");
sug_con_col = "red";
}
// Display all the answers:
document.fluidcalc.nacl_ans.value = n;
document.fluidcalc.nahco3_ans.value = n2;
document.fluidcalc.kcl_ans.value = k;
document.fluidcalc.mg_ans.value = m;
document.fluidcalc.ca_ans.value = ca;
document.fluidcalc.aa_ans.value = aa;
document.fluidcalc.mvi_ans.value = mvi;
document.fluidcalc.hep.value = hep;
document.fluidcalc.sug10_ans.value = a;
document.fluidcalc.sug50_ans.value = b;
document.fluidcalc.h2o.value = h;
document.fluidcalc.fin_sug_conc.value = sug_con;
// Display syringe flow rate:
document.fluidcalc.S_rate.value = roundNumber((TF) / 24, 1);
// Calculate total calories:
var cal = 3.4 * document.fluidcalc.S.value;
if (L > 0) {
if (document.getElementById('lipid_10').checked)
cal += L * 9;
else
cal += L * 10;
}
var npc = cal;
cal += 4 * document.fluidcalc.AA.value;
document.fluidcalc.cal_ans.value = roundNumber(cal, 0);
// Calculate osmolarity:
// TODO how does nahco3 contribute to osmolarity?
var osm = 55 * sug_con + 100 * (aa * .1 * 100 / SC)
+ 340 * (n * nacl_con * 23 * 100 / (SC * 1000));
if (n2 > 0) {
alert("Warning: osmolarity of NaHCO3 unknown. Ignoring NaHCO3 while calculating whether osmolarity is too high for peripheral vein.")
// do {
// var n2osm = parseFloat(prompt("Enter the osmolarity of " + n2 + " ml of NaHCO3"));
// } while (isNaN(n2osm) || n2osm < 0);
// osm += n2osm;
}
document.fluidcalc.osm_ans.value = roundNumber(osm, 0);
if (osm > 900 && document.fluidcalc.VEIN[0].checked == true) {
alert("Osmolarity too high for Peripheral vein!!");
osm_col = "red";
}
// Calculate NPC:N ratio
if (aa > 0) {
var npcn = npc / (document.fluidcalc.AA.value * 0.16);
document.fluidcalc.npcn_ans.value = roundNumber(npcn, 0);
if (npcn < 150 || npcn > 250) {
alert("NPC:N ratio should ideally be between 150 and 250!");
npcn_col = "red";
}
} else
document.fluidcalc.npcn_ans.value = 0;
// Display all flags:
document.fluidcalc.fin_sug_conc.style.backgroundColor = sug_con_col;
document.fluidcalc.osm_ans.style.backgroundColor = osm_col;
document.fluidcalc.npcn_ans.style.backgroundColor = npcn_col;
}
</script>
</head>
<body>
<h1> Baby Fluid Calculator </h1>
<br>
<form name=fluidcalc>
<center>
<table id="maintable">
<thead>
<tr>
<th> <b>Inputs </b></th>
<th> <b>Concentration of Solutions </b></th>
<th> <b>Final Recipe </b></th>
</tr>
</thead>
<tbody>
<tr>
<td> Baby Weight:
<span style="float:right">
<input type=text name=W tabindex="1"> kg
</span>
</td>
<td></td>
<td>
Total fluid:
<span style="float:right">
<input type=text name=totalvol readonly="read-only" class=op> ml per day
</span>
</td>
</tr>
<tr>
<td> Total Fluid Requirement:
<span style="float:right">
<input type=text name=TFR tabindex="2"> ml/kg/day
</span>
</td>
<td></td>
<td>Calories:
<span style="float:right">
<input type=text name=cal_ans readonly="read-only" class=op> kcal/kg/day
</span>
</td>
</tr>
<tr>
<td> <b>Other fluid infusions:</b></td>
<td></td>
<td>Osmolarity:
<span style="float:right">
<input type=text name=osm_ans readonly="read-only" class=op> mOsm/L
</span>
</td>
</tr>
<tr>
<td> Inotropes:
<span style="float:right">
<input type=text name=In tabindex="2"> ml/hr
</span>
</td>
<td></td>
<td>NPC:N ratio:
<span style="float:right">
<input type=text name=npcn_ans readonly="read-only" class=op>
</span>
</td>
</tr>
<tr>
<td> Sedation:
<span style="float:right">
<input type=text name=Sd tabindex="2"> ml/hr
</span>
</td>
<td></td>
<td>Sugar % of final soln:
<span style="float:right">
<input type=text name=fin_sug_conc readonly="read-only" class=op> %
</span>
</td>
</tr>
<tr>
<td> Prostaglandin:
<span style="float:right">
<input type=text name=Pg tabindex="2"> ml/hr
</span>
</td>
<td></td>
<td></td>
</tr>
<tr>
<td> Magnesium Sulphate:
<span style="float:right">
<input type=text name=MS tabindex="2"> ml/hr
</span>
</td>
<td></td>
<td>
Drip rate:
<span style="float:right">
<input type=text name=S_rate readonly="read-only" class=op> ml/hr
</span>
</td>
</tr>
<tr>
<td> Others:
<span style="float:right">
<input type=text name=Ot tabindex="2"> ml/hr
</span>
</td>
<td></td>
<td></td>
</tr>
<tr>
<td> <b>Lipids:</b></td>
<td></td>
<td></td>
</tr>
<tr>
<td> Lipid Requirement:
<span style="float:right">
<input type=text name=L tabindex="2"> gm/kg/day
</span>
</td>
<td><input type="radio" name="conc" id="lipid_10" value="10" tabindex="3">10 % solution</td>
<td>Amount to give:
<span style="float:right">
<input type=text name=L_out readonly="read-only" class=op> ml
</span>
</td>
</tr>
<tr>
<td> Hours:
<span style="float:right">
<input type=text name=hrs tabindex="2"> hrs
</span>
</td>
<td><input type="radio" name="conc" id="lipid_20" value="20" tabindex="3">20 % solution</td>
<td>Rate:
<span style="float:right">
<input type=text name=L_rate readonly="read-only" class=op> ml/hr
</span>
</td>
</tr>
<tr>
<td> Multivitamins: <input type=checkbox name=MVI_L tabindex="2"> </td>
<td> <input type=text name=mvi_L_con value="0.5" size=5> ml for every 50 ml </td>
<td> Add:
<span style="float:right">
<input type=text name=mvi_L_ans readonly="read-only" class=op> m
</span>
</td>
</tr>
<tr>
<td> <b>In the syringe:</b></td>
<td></td>
<td></td>
</tr>
<tr>
<td> Syringe Capacity
<span style="float:right">
<input type=text name=SC value=50 tabindex="3"> ml
</span>
</td>
<td></td>
<td>Sterile Water:
<span style="float:right">
<input type=text name=h2o readonly="read-only" class=op> ml
</span>
</td>
</tr>
<tr>
<td rowspan="2"> Sugar:
<span style="float:right">
<input type=text name=S tabindex="3"> gm/kg/day
</span>
</td>
<td>
10 % Dextrose: <input type=text name=sug10_con value="0.1"> gm/ml
</td>
<td>
Add:
<span style="float:right">
<input type=text name=sug10_ans readonly="read-only" class=op> ml
</span>
</td>
</tr>
<tr>
<td style="display: none;"></td>
<td>
50 % Dextrose: <input type=text name=sug50_con value="0.5"> gm/ml
</td>
<td>
Add:
<span style="float:right">
<input type=text name=sug50_ans readonly="read-only" class=op> ml
</span>
</td>
</tr>
<tr>
<td> Sodium:
<span style="float:right">
<input type=text name=N tabindex="4"> mEq/kg/day
</span>
</td>
<td>
3 % NaCl: <input type=text name=nacl_con value="0.5"> mEq/ml
</td>
<td>
Add:
<span style="float:right">
<input type=text name=nacl_ans readonly="read-only" class=op> ml
</span>
</td>
</tr>
<tr>
<td> Sodium:
<span style="float:right">
<input type=text name=N2 tabindex="4"> mEq/kg/day
</span>
</td>
<td>
7.5 % NaHCO<sub>3</sub>: <input type=text name=nahco3_con value="1"> mEq/ml
</td>
<td>
Add:
<span style="float:right">
<input type=text name=nahco3_ans readonly="read-only" class=op> ml
</span>
</td>
</tr>
<tr>
<td> Potassium:
<span style="float:right">
<input type=text name=K tabindex="5"> mEq/kg/day
</span>
</td>
<td> 15 % KCl: <input type=text name=kcl_con value="2"> mEq/ml</td>
<td> Add:
<span style="float:right">
<input type=text name=kcl_ans readonly="read-only" class=op> ml
</span>
</td>
</tr>
<tr>
<td> Magnesium:
<span style="float:right">
<input type=text name=Mg tabindex="6"> ml/kg/day
</span>
</td>
<td> 50 % Magnesium Sulphate</td>
<td> Add:
<span style="float:right">
<input type=text name=mg_ans readonly="read-only" class=op> ml
</span>
</td>
</tr>
<tr>
<td> Trace Elements:
<span style="float:right">
<input type=text name=Tr tabindex="6"> ml per syringe
</span>
</td>
<td></td>
<td></td>
</tr>
<tr>
<td> Amino Acids:
<span style="float:right">
<input type=text name=AA tabindex="6"> gm/kg/da
</span>
</td>
<td> 10 % Soln</td>
<td> Add:
<span style="float:right">
<input type=text name=aa_ans readonly="read-only" class=op> ml
</span>
</td>
</tr>
<tr>
<td> Calcium: <input type=checkbox name=Ca tabindex="7"> </td>
<td> 10 % Calcium Gluconate: <input type=text name=ca_con value=1 size=5> ml Ca / 50 ml</td>
<td> Add:
<span style="float:right">
<input type=text name=ca_ans readonly="read-only" class=op> ml
</span>
</td>
</tr>
<tr>
<td> Multivitamins: <input type=checkbox name=MVI tabindex="8"> </td>
<td> <input type=text name=mvi_con value="0.5" size=5> ml for every 50 ml </td>
<td> Add:
<span style="float:right">
<input type=text name=mvi_ans readonly="read-only" class=op> ml
</span>
</td>
</tr>
<tr>
<td> Vein:
<span style="float:right">
<input type=radio name=VEIN value="Peripheral" checked tabindex="9">
Peripheral <br>
<input type=radio name=VEIN value="Central"> Central
</span>
</td>
<td></td>
<td> Heparin
<span style="float:right">
<input type=text name=hep readonly="read-only" class=op> ml
</span>
</td>
</tr>
<tr>
<td>
<input type=button value="Calculate!" onclick="calc()" tabindex="11">
<input type=reset name=reset value="Reset" tabindex="11" style="float: right;">
</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</center>
</form>
<footer>
Copyright 2020, Siddharth Krishna</a>.
</footer>
</body>