-
Notifications
You must be signed in to change notification settings - Fork 0
/
babyfluid-isolyteP.html
426 lines (379 loc) · 12.6 KB
/
babyfluid-isolyteP.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
<!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: 8px;
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.Ot.value * 24;
if (TF < 0) {
failWith("Other infusions 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 and W:
var S = document.fluidcalc.S.value * W * SC / (TF);
var N = document.fluidcalc.N.value * W * SC / (TF);
var K = document.fluidcalc.K.value * W * SC / (TF);
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 kcl_con = document.fluidcalc.kcl_con.value * 1; // mEq/ml
// TODO assert that concentrations are what we expect/make the inputs read-only
if (!(sug10_con === 0.1 && sug50_con === 0.5 && nacl_con === 0.5 && kcl_con === 2)) {
failWith("This program doesn't yet support other concentrations.")
return;
}
// Start filling the syringe:
var vol = SC;
// Depending on type of vein, add heparin:
var hep = 0;
if (document.fluidcalc.VEIN[1].checked == true) {
hep = roundNumber(2.5 * SC / 50, 1);
}
// Final mixture:
// i ml of Isolyte P
// s ml of 50% Dextrose
// n ml of NaCl
// k ml of KCl
// h ml of H2O
// To solve using matlab:
// syms i s n k h Is In Ik Cs Cn Ck V S N K
// [soli, sols, soln, solk, solh, params, conds] = solve([i >= 0, s >= 0, n >= 0, k >= 0, h >= 0, Is >= 0, In >= 0, Ik >= 0, Cs >= 0, Cn >= 0, Ck >= 0, V >= 0, S >= 0, N >= 0, K >= 0, i + s + n + k + h == V, i * Is + s * Cs == S, i * In + n * Cn == N, i * Ik + k * Ck == K], [i, s, n, k, h], 'ReturnConditions', true)
// syms i s n k h V S N K
// [soli, sols, soln, solk, solh, params, conds] = solve([i >= 0, s >= 0, n >= 0, k >= 0, h >= 0, V >= 0, S >= 0, N >= 0, K >= 0, i + s + n + k + h == V, i * .05 + s * .5 == S, i * .023 + n * .5 == N, i * .02 + k * 2 == K], [i, s, n, k, h], 'ReturnConditions', true)
// Solution according to matlab:
lower_bd = Math.max(
0,
(427*K + 20*N + 20*S - 10*vol) / 10,
(4853*K - 4220*N) / 115,
(1055*K - 422*S) / 25,
);
upper_bd = 211*K / 5;
if (upper_bd < lower_bd) {
failWith("These input constraints have no solution.");
return;
}
var x = lower_bd;
var isp = 50*K - (250*x)/211
var s50 = 2*S - 5*K + (25*x)/211
var n = 2*N - (23*K)/10 + (23*x)/422
var k = (5*x)/422
var h = vol - 2*N - 2*S - (427*K)/10 + x
// TODO verify results?
// Round the outputs appropriately
// TODO how many decimals for isp and s50?
var isp = roundNumber(isp, 2);
var s50 = roundNumber(s50, 1);
var n = roundNumber(n, 1);
var k = roundNumber(k, 1);
var h = roundNumber(h, 1);
// all flags:
var sug_con_col = "white";
var osm_col = "white";
// TODO for now assuming 10% Dextrose unused
var s10 = 0;
// calculate sugar perc and flag if wrong vein:
var sug_con = ((isp * 0.05) + (s10 * sug10_con) + (s50 * sug50_con)) * 100 / SC;
sug_con = roundNumber(sug_con, 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.isp_ans.value = isp;
document.fluidcalc.nacl_ans.value = n;
document.fluidcalc.kcl_ans.value = k;
document.fluidcalc.hep.value = hep;
document.fluidcalc.sug10_ans.value = s10;
document.fluidcalc.sug50_ans.value = s50;
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;
document.fluidcalc.cal_ans.value = roundNumber(cal, 0);
// TODO Calculate osmolarity:
document.fluidcalc.osm_ans.value = "???";
document.fluidcalc.osm_ans.style.backgroundColor = "yellow";
// Display all flags:
document.fluidcalc.fin_sug_conc.style.backgroundColor = sug_con_col;
}
</script>
</head>
<body>
<h1> Baby Fluid Calculator </h1>
<center>(simplified version with Isolyte P)</center><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></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> Others:
<span style="float:right">
<input type=text name=Ot 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> <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>Isolyte P</td>
<td>Sugar .05 g/ml, Na .023 mEq/ml, K .02 mEq/ml</td>
<td>
Add:
<span style="float:right">
<input type=text name=isp_ans 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> 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> 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>