-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNEWS2.html
More file actions
754 lines (703 loc) · 49.4 KB
/
NEWS2.html
File metadata and controls
754 lines (703 loc) · 49.4 KB
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
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>NEWS2 Checker & Triage (Offline)</title>
<style>
:root{
--bg:#0b1220; --card:#121a2b; --ink:#e7eefb; --muted:#9fb3d9;
--ok:#2e7d32; --warn:#f9a825; --med:#ef6c00; --high:#c62828; --brand:#4f8cff;
}
html,body{height:100%}
body{margin:0;font-family:system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,"Helvetica Neue",Arial;background:var(--bg);color:var(--ink)}
.wrap{max-width:980px;margin:0 auto;padding:18px}
.title{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.lang{margin-left:auto;display:flex;gap:8px;align-items:center}
.card{background:var(--card);border:1px solid #1d2a44;border-radius:16px;padding:16px;box-shadow:0 6px 20px rgba(0,0,0,.25)}
.grid{display:grid;gap:12px}
.g2{grid-template-columns:repeat(2,minmax(0,1fr))}
.g3{grid-template-columns:repeat(3,minmax(0,1fr))}
@media (max-width:900px){.g2,.g3{grid-template-columns:1fr}}
label{font-size:.9rem;color:var(--muted)}
input,select,button{width:100%;box-sizing:border-box;padding:12px;border-radius:12px;border:1px solid #2a3b61;background:#0f1727;color:var(--ink);outline:none}
input::placeholder{color:#6c86bd}
.row{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.pill{padding:6px 10px;border-radius:999px;font-size:.8rem;background:#0f1727;border:1px solid #283659;color:var(--muted)}
.score{font-size:56px;font-weight:800;letter-spacing:1px}
.badge{display:inline-block;padding:6px 10px;border-radius:999px;font-weight:600}
.low{background:rgba(46,125,50,.15);color:#b6f0b8;border:1px solid #2e7d32}
.medium{background:rgba(239,108,0,.15);color:#ffd3b5;border:1px solid #ef6c00}
.high{background:rgba(198,40,40,.15);color:#ffc4c4;border:1px solid #c62828}
.daycare{background:rgba(249,168,37,.15);color:#ffe6b0;border:1px solid #f9a825}
.muted{color:var(--muted)}
.hint{font-size:.9rem;color:var(--muted)}
.btn{cursor:pointer;background:linear-gradient(180deg,#5a96ff,#467df1);border:none}
.btn:active{transform:translateY(1px)}
.btn-ghost{background:#0f1727;border:1px solid #2a3b61}
.footer{opacity:.8;font-size:.85rem}
details{background:#0f1727;border:1px solid #223459;border-radius:12px;padding:10px}
summary{cursor:pointer;font-weight:600}
.table{width:100%;border-collapse:collapse;font-size:.9rem}
.table th,.table td{border:1px solid #23365e;padding:8px;text-align:center}
.danger{color:#ffc7c7}
.no-print{ }
.print-only{ display:none }
.mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace}
@media print{
.no-print{ display:none !important }
.print-only{ display:block !important }
.wrap{max-width:100%}
.title, #t_intro { display:none !important; }
/* Print only the Results card (PDF should contain exactly the Results block) */
#inputsCard, #refCard, #footerBlock{ display:none !important }
body{ background:#ffffff !important; color:#000000 !important }
.card{ box-shadow:none !important; border:1px solid #999 !important; background:#ffffff !important; color:#000000 !important }
.pill{ background:#ffffff !important; color:#000000 !important; border:1px solid #999 !important }
.muted{ color:#000000 !important; opacity:0.75 }
.table th,.table td{ border:1px solid #999 !important; color:#000000 !important }
}
</style>
</head>
<body>
<div class="wrap">
<div class="title">
<svg width="34" height="34" viewBox="0 0 24 24" fill="none" aria-hidden="true">
<path d="M12 21c4.97 0 9-4.03 9-9s-4.03-9-9-9-9 4.03-9 9 4.03 9 9 9Z" stroke="#4f8cff" stroke-width="1.5"/>
<path d="M5 12h3l2-4 4 8 2-4h3" stroke="#4f8cff" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
<h1 id="t_title" style="margin:0">NEWS2 Checker & Triage</h1>
<span class="pill" id="t_offline">Offline • Mobile-friendly</span>
<div class="lang">
<label for="langSel" class="muted" id="t_lang">Language</label>
<select id="langSel" style="width:auto">
<option value="en">English</option>
<option value="hi">हिन्दी</option>
<option value="bn">বাংলা</option>
</select>
</div>
<!-- Cancer-care header lines (no duplicate IDs) -->
<div style="flex-basis:100%;margin-top:6px">
<h6 style="margin:0">हर मिनट मायने रखता है। कैंसर रोगियों में तीव्र गंभीर बीमारियों की शुरुआती पहचान और हस्तक्षेप तत्काल जीवन रक्षा के लिए ज़रूरी है।</h6>
<h6 style="margin:0">Every minute counts. Early identification and intervention in acute critical illnesses in cancer patients is the key to short-term survival.</h6>
<h6 style="margin:0">প্রতিটি মিনিট গুরুত্বপূর্ণ। ক্যান্সার রোগীদের তীব্র জটিল অসুস্থতার প্রাথমিক সনাক্তকরণ এবং হস্তক্ষেপ তাৎক্ষণিক জীবন রক্ষার মূল ভিত্তি।</h6>
</div>
</div>
<p class="hint" id="t_intro">For adults (≥16 yr). Designed for patients, families, and nurses to estimate the National Early Warning Score (NEWS2) and get a location-of-care prompt (Home / Day Care / IPD / ICU). This tool does not replace clinical judgment or emergency care.</p>
<div class="grid g2">
<div class="card" id="inputsCard">
<h3 style="margin-top:6px" id="t_inputs">Patient Inputs</h3>
<div class="grid g2">
<!-- Meta -->
<div>
<label id="t_case_lbl">Case number</label>
<input type="text" id="caseNo" placeholder="e.g., C-12345"/>
</div>
<div>
<label id="t_first_lbl">First name</label>
<input type="text" id="firstName" placeholder="e.g., Asha"/>
</div>
<!-- Clinical inputs -->
<div>
<label id="t_rr">Respiratory rate (breaths/min)</label>
<input type="number" id="rr" min="0" step="1" placeholder="e.g., 16"/>
</div>
<div>
<label id="t_o2">On supplemental oxygen?</label>
<select id="oxygen">
<option id="t_o2_no" value="no">No (air)</option>
<option id="t_o2_yes" value="yes">Yes (any device)</option>
</select>
</div>
<div>
<label id="t_spo2">SpO₂ (%)</label>
<input type="number" id="spo2" min="0" max="100" step="1" placeholder="e.g., 97"/>
</div>
<div>
<label id="t_spo2scale">SpO₂ scale</label>
<select id="spo2scale">
<option id="t_sc1" value="1">Scale 1 (default – most patients)</option>
<option id="t_sc2" value="2">Scale 2 (target 88–92% – use only if advised)</option>
</select>
</div>
<div>
<label id="t_sbp">Systolic BP (mmHg)</label>
<input type="number" id="sbp" min="0" step="1" placeholder="e.g., 120"/>
</div>
<div>
<label id="t_hr">Pulse / Heart rate (beats/min)</label>
<input type="number" id="hr" min="0" step="1" placeholder="e.g., 84"/>
</div>
<div>
<label id="t_temp">Temperature (°F)</label>
<input type="number" id="temp" min="77" max="113" step="0.1" placeholder="e.g., 98.6"/>
</div>
<div>
<label id="t_avpu">Level of consciousness</label>
<select id="avpu">
<option id="t_A" value="A">Alert</option>
<option id="t_C" value="C">New Confusion (C)</option>
<option id="t_V" value="V">Responds to Voice (V)</option>
<option id="t_P" value="P">Responds to Pain (P)</option>
<option id="t_U" value="U">Unresponsive (U)</option>
</select>
</div>
</div>
<div class="row" style="margin-top:12px">
<button class="btn no-print" id="calc" type="button"><span id="t_calc">Calculate NEWS2</span></button>
<button class="btn-ghost no-print" id="reset" type="button"><span id="t_reset">Reset</span></button>
<button class="btn-ghost no-print" id="print" type="button"><span id="t_print">Print / Save PDF</span></button>
<button class="btn-ghost no-print" id="saveTxt" type="button">Save TXT</button>
</div>
<p class="hint" style="margin-top:10px" id="t_scale_hint">
Only use SpO₂ <b>Scale 2</b> when a qualified clinician has told you that the target saturation range is 88–92% (e.g., chronic hypercapnic respiratory failure).
</p>
</div>
<div class="card" id="out">
<h3 style="margin-top:6px" id="t_results">Results</h3>
<div class="row" style="margin-bottom:8px">
<span class="pill" id="metaCase">Case #: —</span>
<span class="pill" id="metaName">Name: —</span>
<span class="pill no-print" id="metaStampLive">Generated: —</span>
<span class="pill print-only" id="metaStamp">Generated: —</span>
</div>
<!-- PRINT-ONLY summary block (matches requested PDF/TXT structure) -->
<div class="print-only" id="printSummary" style="margin:10px 0 12px 0">
<!-- Filled by JS -->
</div>
<div class="row" style="justify-content:space-between">
<div>
<div class="muted" id="t_total_lbl">TOTAL NEWS2</div>
<div class="score" id="total">–</div>
</div>
<div style="text-align:right">
<div class="muted" id="t_risk_lbl">Risk band</div>
<div id="risk" class="badge">–</div>
</div>
</div>
<div class="grid g2" style="margin-top:12px">
<div>
<div class="muted" id="t_triage_lbl">Triage prompt</div>
<div id="triage" class="badge">–</div>
</div>
<div>
<div class="muted" id="t_red_lbl">Red flag (any score of 3)?</div>
<div id="redflag" class="badge">–</div>
</div>
</div>
<div style="margin-top:14px">
<table class="table" id="breakdown">
<thead><tr><th id="t_col_param">Parameter</th><th id="t_col_value">Value</th><th id="t_col_score">Score</th></tr></thead>
<tbody></tbody>
</table>
</div>
<!-- Hidden live TXT cache (not shown; used for Save TXT) -->
<textarea id="txtCache" class="no-print" style="position:absolute;left:-9999px;top:-9999px;height:1px;width:1px" aria-hidden="true"></textarea>
<details style="margin-top:12px" class="no-print">
<summary id="t_bands_title">What the bands mean (and what to do next)</summary>
<ul id="bands_list">
<li id="t_band_low"><b>Low (0–1)</b>: Home care with advice and re-check in 6–12 h if still unwell. Seek help sooner if worse.</li>
<li id="t_band_lomed"><b>Low-moderate (2–4)</b>: Day-care/observation area & nurse review; repeat NEWS2 in 1–2 h.</li>
<li id="t_band_med"><b>Medium (5–6) or any single score of 3</b>: IPD admission & urgent clinician review (within 1 h).</li>
<li id="t_band_high"><b>High (≥7)</b>: Call ICU/critical care team immediately. Prepare for transfer to ICU.</li>
</ul>
<p class="hint" id="t_emerg_hint">
If at any time there is severe breathlessness, blue/grey lips, severe chest pain, seizures, or the person is very difficult to wake,
<b class="danger">treat as emergency</b> and go to the nearest emergency department.
</p>
</details>
</div>
</div>
<div class="card" style="margin-top:12px" id="refCard">
<details open>
<summary id="t_ref_title">Scoring reference (concise)</summary>
<div class="grid g3" style="margin-top:10px">
<div>
<b id="t_rr_head">Respiratory rate (breaths/min)</b>
<p class="hint" id="t_rr_bins">≤8:3 | 9–11:1 | 12–20:0 | 21–24:2 | ≥25:3</p>
<b id="t_o2_head">Supplemental oxygen</b>
<p class="hint" id="t_o2_bins">No:0 | Yes:2</p>
<b id="t_avpu_head">Consciousness (AVPU/C)</b>
<p class="hint" id="t_avpu_bins">Alert:0 | New Confusion or V/P/U:3</p>
</div>
<div>
<b id="t_sbp_head">Systolic BP (mmHg)</b>
<p class="hint" id="t_sbp_bins">≤90:3 | 91–100:2 | 101–110:1 | 111–219:0 | ≥220:3</p>
<b id="t_hr_head">Pulse (beats/min)</b>
<p class="hint" id="t_hr_bins">≤40:3 | 41–50:1 | 51–90:0 | 91–110:1 | 111–130:2 | ≥131:3</p>
</div>
<div>
<b id="t_temp_head">Temperature – thresholds use °C internally</b>
<p class="hint" id="t_temp_bins"><!-- filled via JS with °C + °F --></p>
<b id="t_sp1_head">SpO₂ – Scale 1</b>
<p class="hint" id="t_sp1_bins">≤91:3 | 92–93:2 | 94–95:1 | 96–100:0</p>
<b id="t_sp2_head">SpO₂ – Scale 2*</b>
<p class="hint" id="t_sp2_bins">≤83:3 | 84–85:2 | 86–87:1 | 88–92:0 | 93–94:1 | 95–96:2 | ≥97:3</p>
<p class="hint" id="t_sp2_hint">*Use only if clinician has advised target 88–92% (e.g., hypercapnic respiratory failure).</p>
</div>
</div>
</details>
</div>
<div class="footer no-print" style="margin-top:14px" id="footerBlock">
<p id="t_priv">For offline use. No data leaves your device. Print or save as PDF to share with clinicians.</p>
<p class="hint" id="t_copyright">NEWS2 © Royal College of Physicians. This app implements the scoring rules referenced from the official NEWS2 observation chart (Dec 2022). Built by Prof. (Dr.) Jyotirmay Kirtania (ORCID ID 0000-0002-4426-6877), adapted for cancer patients.</p>
<p><b id="t_refs_lbl">References:</b></p>
<ol class="hint">
<li>Smith GB, Redfern OC, Pimentel MA, Gerry S, Collins GS, Malycha J, Prytherch D, Schmidt PE, Watkinson PJ. The National Early Warning Score 2 (NEWS2). <i>Clin Med (Lond)</i>. 2019 May;19(3):260. doi: 10.7861/clinmedicine.19-3-260. PMID: 31092526; PMCID: PMC6542226.</li>
<li>Welch J, Dean J, Hartin J. Using NEWS2: an essential component of reliable clinical assessment. <i>Clin Med (Lond)</i>. 2022 Nov;22(6):509-513. doi: 10.7861/clinmed.2022-0435. PMID: 36427875; PMCID: PMC9761428.</li>
</ol>
</div>
</div>
<script>
(function(){
/* ---------- tiny helpers ---------- */
function $(id){ return document.getElementById(id); }
function setText(id, val){ var el=$(id); if(el!=null){ el.textContent = val; } }
function setHTML(id, val){ var el=$(id); if(el!=null && val!=null){ el.innerHTML = val; } }
/* ---------- scoring ---------- */
function scoreRR(rr){ if(rr<=8) return 3; if(rr<=11) return 1; if(rr<=20) return 0; if(rr<=24) return 2; return 3; }
function scoreOxygen(onO2){ return onO2?2:0; }
function scoreSpO2(s, scale){
if(isNaN(s)) return 0;
if(scale===2){ if(s<=83) return 3; if(s<=85) return 2; if(s<=87) return 1; if(s<=92) return 0; if(s<=94) return 1; if(s<=96) return 2; return 3; }
else { if(s<=91) return 3; if(s<=93) return 2; if(s<=95) return 1; return 0; }
}
function scoreSBP(s){ if(s<=90) return 3; if(s<=100) return 2; if(s<=110) return 1; if(s<=219) return 0; return 3; }
function scoreHR(h){ if(h<=40) return 3; if(h<=50) return 1; if(h<=90) return 0; if(h<=110) return 1; if(h<=130) return 2; return 3; }
function fToC(f){ return (f-32)*(5/9); }
function scoreTempF(f){
var t = fToC(f);
if(t<=35.0) return 3;
if(t<=36.0) return 1;
if(t<=38.0) return 0;
if(t<=39.0) return 1;
return 2;
}
function scoreAVPU(v){ return (v==='A')?0:3; }
/* ---------- bands ---------- */
function riskBand(total, any3){
if(total>=7) return {band:i18n[currentLang].band_high_txt, cls:'high'};
if(total>=5 || any3) return {band:i18n[currentLang].band_med_txt, cls:'medium'};
if(total>=2) return {band:i18n[currentLang].band_lomed_txt, cls:'daycare'};
return {band:i18n[currentLang].band_low_txt, cls:'low'};
}
function triageFrom(total, any3){
if(total>=7) return {text:i18n[currentLang].tri_high, cls:'high'};
if(total>=5 || any3) return {text:i18n[currentLang].tri_med, cls:'medium'};
if(total>=2) return {text:i18n[currentLang].tri_lomed, cls:'daycare'};
return {text:i18n[currentLang].tri_low, cls:'low'};
}
/* ---------- meta ---------- */
function updateMeta(){
var cn = $('caseNo').value.trim();
var fn = $('firstName').value.trim();
setText('metaCase', i18n[currentLang].meta_case + ' ' + (cn || '—'));
setText('metaName', i18n[currentLang].meta_name + ' ' + (fn || '—'));
try{ localStorage.setItem('news2_meta', JSON.stringify({caseNo:cn, firstName:fn})); }catch(e){}
}
function stampNow(){
var txt;
try{
var fmt = new Intl.DateTimeFormat('en-GB', {
timeZone:'Asia/Kolkata', year:'numeric', month:'short', day:'2-digit',
hour:'2-digit', minute:'2-digit', second:'2-digit', hour12:false
});
txt = i18n[currentLang].generated + ' ' + fmt.format(new Date()) + ' IST';
}catch(e){
txt = i18n[currentLang].generated + ' ' + new Date().toLocaleString();
}
setText('metaStamp', txt); // print-only
setText('metaStampLive', txt); // on-screen
return txt;
}
var stampTimer = null;
function startStampTicker(){
if(stampTimer){ clearInterval(stampTimer); }
stampTimer = setInterval(stampNow, 60000);
}
/* ---------- temp bins (°C+°F) ---------- */
function cToF(c){ return (c*9/5+32).toFixed(1); }
function renderTempBins(){
var bins = [
'≤35.0°C (≤' + cToF(35.0) + '°F):3',
'35.1–36.0°C (' + cToF(35.1) + '–' + cToF(36.0) + '°F):1',
'36.1–38.0°C (' + cToF(36.1) + '–' + cToF(38.0) + '°F):0',
'38.1–39.0°C (' + cToF(38.1) + '–' + cToF(39.0) + '°F):1',
'≥39.1°C (≥' + cToF(39.1) + '°F):2'
];
setHTML('t_temp_bins', bins.join(' | '));
}
/* ---------- TXT + PRINT summary builders ---------- */
var lastTxt = '';
function safeStr(x){ return (x===undefined || x===null) ? '' : String(x); }
function getISTFilenameStamp(){
try{
var d = new Date();
// Use en-GB parts in Asia/Kolkata
var parts = new Intl.DateTimeFormat('en-GB', {
timeZone:'Asia/Kolkata',
year:'numeric', month:'short', day:'2-digit',
hour:'2-digit', minute:'2-digit',
hour12:false
}).formatToParts(d);
var obj = {};
for(var i=0;i<parts.length;i++){
if(parts[i].type !== 'literal') obj[parts[i].type] = parts[i].value;
}
// ddMMMyyyyHHmm (e.g., 15Jan20261706)
return (obj.day||'') + (obj.month||'') + (obj.year||'') + (obj.hour||'') + (obj.minute||'');
}catch(e){
return String(Date.now());
}
}
function buildTxtOutput(metaCase, metaName, generatedLine, total, riskBandTxt, triageTxt, redFlagYesNo, parts){
var lines = [];
lines.push('Results');
lines.push('Case #: ' + (metaCase || '—'));
lines.push('Name: ' + (metaName || '—'));
lines.push('Generated: ' + (generatedLine || '—'));
lines.push('TOTAL NEWS2');
lines.push(String(total));
lines.push('Risk band');
lines.push(riskBandTxt);
lines.push('Triage prompt');
lines.push(triageTxt);
lines.push('Red flag (any score of 3)?');
lines.push(redFlagYesNo);
lines.push('Parameter\tValue\tScore');
for(var i=0;i<parts.length;i++){
lines.push(parts[i].name + '\t' + parts[i].value + '\t' + parts[i].score);
}
return lines.join('\n');
}
function buildPrintSummaryHTML(metaCase, metaName, generatedLine, total, riskBandTxt, triageTxt, redFlagYesNo){
// Keep structure exactly as requested (PDF will include this + the table below)
var h = '';
h += '<div class="mono" style="font-size:12px;line-height:1.35">';
h += '<div style="font-weight:700;font-size:14px;margin-bottom:6px">Results</div>';
h += '<div>Case #: ' + safeStr(metaCase || '—') + '</div>';
h += '<div>Name: ' + safeStr(metaName || '—') + '</div>';
h += '<div>Generated: ' + safeStr(generatedLine || '—') + '</div>';
h += '<div style="margin-top:8px;font-weight:700">TOTAL NEWS2</div>';
h += '<div>' + safeStr(total) + '</div>';
h += '<div style="margin-top:8px;font-weight:700">Risk band</div>';
h += '<div>' + safeStr(riskBandTxt) + '</div>';
h += '<div style="margin-top:8px;font-weight:700">Triage prompt</div>';
h += '<div>' + safeStr(triageTxt) + '</div>';
h += '<div style="margin-top:8px;font-weight:700">Red flag (any score of 3)?</div>';
h += '<div>' + safeStr(redFlagYesNo) + '</div>';
h += '</div>';
return h;
}
function saveTxtToFile(txt){
try{
var cn = $('caseNo').value.trim();
var base = (cn ? cn : 'news2').toLowerCase().replace(/\s+/g,'');
var stamp = getISTFilenameStamp();
var filename = base + '_' + stamp + '.txt';
var blob = new Blob([txt], {type:'text/plain;charset=utf-8'});
var url = URL.createObjectURL(blob);
var a = document.createElement('a');
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
setTimeout(function(){
try{ URL.revokeObjectURL(url); }catch(e){}
try{ document.body.removeChild(a); }catch(e){}
}, 0);
}catch(e){
// fallback: copy to clipboard prompt
try{
window.prompt('Copy TXT output:', txt);
}catch(_e){}
}
}
/* ---------- calculation ---------- */
function calculate(){
var rr = parseFloat($('rr').value);
var onO2 = $('oxygen').value==='yes';
var spo2 = parseFloat($('spo2').value);
var scale= parseInt($('spo2scale').value,10);
var sbp = parseFloat($('sbp').value);
var hr = parseFloat($('hr').value);
var tempF= parseFloat($('temp').value);
var avpu = $('avpu').value;
var parts = [
{name:i18n[currentLang].p_rr, value:isNaN(rr)?'—':rr, score:isNaN(rr)?0:scoreRR(rr)},
{name:i18n[currentLang].p_spo2+' (Scale '+scale+')', value:isNaN(spo2)?'—':(spo2+'%'), score:isNaN(spo2)?0:scoreSpO2(spo2, scale)},
{name:i18n[currentLang].p_o2, value:onO2?i18n[currentLang].yes:i18n[currentLang].no, score:scoreOxygen(onO2)},
{name:i18n[currentLang].p_sbp, value:isNaN(sbp)?'—':(sbp+' mmHg'),score:isNaN(sbp)?0:scoreSBP(sbp)},
{name:i18n[currentLang].p_hr, value:isNaN(hr)?'—':(hr+' bpm'), score:isNaN(hr)?0:scoreHR(hr)},
{name:i18n[currentLang].p_temp, value:isNaN(tempF)?'—':(tempF+' °F'), score:isNaN(tempF)?0:scoreTempF(tempF)},
{name:i18n[currentLang].p_avpu, value:translateAVPU(avpu), score:scoreAVPU(avpu)}
];
var total = 0, any3=false, i;
for(i=0;i<parts.length;i++){ total += parts[i].score; if(parts[i].score===3) any3=true; }
setText('total', isNaN(total)?'–':String(total));
var rb = riskBand(total, any3);
var tri= triageFrom(total, any3);
var riskEl=$('risk'); if(riskEl){ riskEl.textContent=rb.band; riskEl.className='badge '+rb.cls; }
var triEl=$('triage'); if(triEl){ triEl.textContent=tri.text; triEl.className='badge '+tri.cls; }
var rfEl=$('redflag'); if(rfEl){ rfEl.textContent= any3? i18n[currentLang].yes : i18n[currentLang].no; rfEl.className='badge '+(any3?'high':'low'); }
var tb = document.querySelector('#breakdown tbody');
if(!tb){
var table = $('breakdown');
if(table){ tb = document.createElement('tbody'); table.appendChild(tb); }
}
if(tb){ tb.innerHTML=''; }
for(i=0;i<parts.length;i++){
var p = parts[i];
var tr=document.createElement('tr');
var td1=document.createElement('td'); td1.textContent=p.name; tr.appendChild(td1);
var td2=document.createElement('td'); td2.textContent=p.value; tr.appendChild(td2);
var td3=document.createElement('td'); td3.textContent=p.score; if(p.score===3) td3.style.color='#ff9e9e'; tr.appendChild(td3);
if(tb){ tb.appendChild(tr); }
}
try{ localStorage.setItem('news2_saved', JSON.stringify({rr:rr, onO2:onO2, spo2:spo2, scale:scale, sbp:sbp, hr:hr, tempF:tempF, avpu:avpu})); }catch(e){}
updateMeta();
var genLine = stampNow(); // includes "Generated: ..."
// Extract the timestamp portion for the requested block (without repeated prefix)
var genValue = genLine.replace((i18n[currentLang].generated + ' '), '');
// Build TXT + PRINT summary to match required structure
var cn = $('caseNo').value.trim();
var fn = $('firstName').value.trim();
var txt = buildTxtOutput(
cn || '—',
fn || '—',
genValue || '—',
isNaN(total)?'–':String(total),
rb.band,
tri.text,
any3 ? i18n[currentLang].yes : i18n[currentLang].no,
parts
);
lastTxt = txt;
var cache = $('txtCache'); if(cache){ cache.value = txt; }
var ps = $('printSummary');
if(ps){
ps.innerHTML = buildPrintSummaryHTML(
cn || '—',
fn || '—',
genValue || '—',
isNaN(total)?'–':String(total),
rb.band,
tri.text,
any3 ? i18n[currentLang].yes : i18n[currentLang].no
);
}
}
function resetForm(){
var ids=['rr','spo2','sbp','hr','temp'];
for(var i=0;i<ids.length;i++){ var el=$(ids[i]); if(el) el.value=''; }
$('oxygen').value='no';
$('spo2scale').value='1';
$('avpu').value='A';
$('caseNo').value='';
$('firstName').value='';
setText('total','–');
var risk=$('risk'); if(risk){ risk.textContent='–'; risk.className='badge'; }
var tri=$('triage'); if(tri){ tri.textContent='–'; tri.className='badge'; }
var rf=$('redflag'); if(rf){ rf.textContent='–'; rf.className='badge'; }
var tb=document.querySelector('#breakdown tbody'); if(tb){ tb.innerHTML=''; }
setText('metaCase', i18n[currentLang].meta_case + ' —');
setText('metaName', i18n[currentLang].meta_name + ' —');
setText('metaStamp', i18n[currentLang].generated + ' —');
setText('metaStampLive', i18n[currentLang].generated + ' —');
var ps = $('printSummary'); if(ps){ ps.innerHTML=''; }
lastTxt = '';
var cache = $('txtCache'); if(cache){ cache.value=''; }
try{ localStorage.removeItem('news2_saved'); localStorage.removeItem('news2_meta'); }catch(e){}
}
/* ---------- i18n ---------- */
var i18n={
en:{ title:'NEWS2 Checker & Triage', offline:'Offline • Mobile-friendly', lang:'Language',
intro:'For adults (≥16 yr). Designed for patients, families, and nurses to estimate the National Early Warning Score (NEWS2) and get a location-of-care prompt (Home / Day Care / IPD / ICU). This tool does not replace clinical judgment or emergency care.',
inputs:'Patient Inputs', case_lbl:'Case number', first_lbl:'First name',
rr:'Respiratory rate (breaths/min)', o2:'On supplemental oxygen?', o2_no:'No (air)', o2_yes:'Yes (any device)',
spo2:'SpO₂ (%)', spo2scale:'SpO₂ scale', sc1:'Scale 1 (default – most patients)', sc2:'Scale 2 (target 88–92% – use only if advised)',
sbp:'Systolic BP (mmHg)', hr:'Pulse / Heart rate (beats/min)', temp:'Temperature (°F)', avpu:'Level of consciousness',
optA:'Alert', optC:'New Confusion (C)', optV:'Responds to Voice (V)', optP:'Responds to Pain (P)', optU:'Unresponsive (U)',
calc:'Calculate NEWS2', reset:'Reset', print:'Print / Save PDF',
scale_hint:'Only use SpO₂ <b>Scale 2</b> when a qualified clinician has told you that the target saturation range is 88–92% (e.g., chronic hypercapnic respiratory failure).',
results:'Results', total_lbl:'TOTAL NEWS2', risk_lbl:'Risk band', triage_lbl:'Triage prompt', red_lbl:'Red flag (any score of 3)?',
col_param:'Parameter', col_value:'Value', col_score:'Score',
bands_title:'What the bands mean (and what to do next)',
band_low:'<b>Low (0–1)</b>: Home care with advice and re-check in 6–12 h if still unwell. Seek help sooner if worse.',
band_lomed:'<b>Low-moderate (2–4)</b>: Day-care/observation area & nurse review; repeat NEWS2 in 1–2 h.',
band_med:'<b>Medium (5–6) or any single score of 3</b>: IPD admission & urgent clinician review (within 1 h).',
band_high:'<b>High (≥7)</b>: Call ICU/critical care team immediately. Prepare for transfer to ICU.',
band_low_txt:'Low (0–1)', band_lomed_txt:'Low-moderate (2–4)', band_med_txt:'Medium (5–6) or Red-flag (any 3)', band_high_txt:'High (≥7)',
tri_low:'Home care with safety-net advice', tri_lomed:'Day Care / Observation & nurse review', tri_med:'IPD admission & urgent doctor review', tri_high:'ICU (call critical care team NOW)',
emerg_hint:'If at any time there is severe breathlessness, blue/grey lips, severe chest pain, seizures, or the person is very difficult to wake, <b class="danger">treat as emergency</b> and go to the nearest emergency department.',
ref_title:'Scoring reference (concise)', rr_head:'Respiratory rate (breaths/min)',
rr_bins:'≤8:3 | 9–11:1 | 12–20:0 | 21–24:2 | ≥25:3', o2_head:'Supplemental oxygen', o2_bins:'No:0 | Yes:2',
avpu_head:'Consciousness (AVPU/C)', avpu_bins:'Alert:0 | New Confusion or V/P/U:3',
sbp_head:'Systolic BP (mmHg)', sbp_bins:'≤90:3 | 91–100:2 | 101–110:1 | 111–219:0 | ≥220:3',
hr_head:'Pulse (beats/min)', hr_bins:'≤40:3 | 41–50:1 | 51–90:0 | 91–110:1 | 111–130:2 | ≥131:3',
temp_head:'Temperature – thresholds use °C internally', temp_bins:'',
sp1_head:'SpO₂ – Scale 1', sp1_bins:'≤91:3 | 92–93:2 | 94–95:1 | 96–100:0',
sp2_head:'SpO₂ – Scale 2*', sp2_bins:'≤83:3 | 84–85:2 | 86–87:1 | 88–92:0 | 93–94:1 | 95–96:2 | ≥97:3',
sp2_hint:'*Use only if clinician has advised target 88–92% (e.g., hypercapnic respiratory failure).',
priv:'Built by Prof. (Dr.) Jyotirmay Kirtania (ORCID ID 0000-0002-4426-6877), for offline use. No data leaves your device. Print or save as PDF to share with clinicians.',
refs_lbl:'References:', yes:'Yes', no:'No',
p_rr:'Respiratory rate', p_spo2:'SpO₂', p_o2:'Supplemental oxygen', p_sbp:'Systolic BP', p_hr:'Pulse', p_temp:'Temperature (°F)', p_avpu:'Consciousness (AVPU/C)',
meta_case:'Case #:', meta_name:'Name:', generated:'Generated:'
},
hi:{ title:'NEWS2 जांच व ट्रायेज', offline:'ऑफ़लाइन • मोबाइल-अनुकूल', lang:'भाषा',
intro:'वयस्कों (≥16 वर्ष) के लिए। रोगियों, परिजनों और नर्सों हेतु NEWS2 का अनुमान लगाने और देखभाल-स्थान (होम / डे-केयर / आईपीडी / आईसीयू) का संकेत देने के लिए बनाया गया। यह उपकरण चिकित्सकीय निर्णय या आपातकालीन देखभाल का विकल्प नहीं है।',
inputs:'रोगी इनपुट', case_lbl:'केस संख्या', first_lbl:'पहला नाम',
rr:'श्वसन दर (सांस/मिनट)', o2:'पूरक ऑक्सीजन पर?', o2_no:'नहीं (रूम-एयर)', o2_yes:'हाँ (कोई भी उपकरण)',
spo2:'SpO₂ (%)', spo2scale:'SpO₂ स्केल', sc1:'स्केल 1 (डिफ़ॉल्ट – अधिकांश रोगी)', sc2:'स्केल 2 (लक्ष्य 88–92% – केवल सलाह मिलने पर)',
sbp:'सिस्टोलिक BP (mmHg)', hr:'नाड़ी / हृदय दर (धड़कन/मिनट)', temp:'तापमान (°F)', avpu:'होश का स्तर',
optA:'सचेत', optC:'नया भ्रम (C)', optV:'आवाज़ पर प्रतिक्रिया (V)', optP:'दर्द पर प्रतिक्रिया (P)', optU:'प्रतिक्रिया नहीं (U)',
calc:'NEWS2 गणना करें', reset:'रीसेट', print:'प्रिंट / PDF',
scale_hint:'SpO₂ का <b>स्केल 2</b> तभी प्रयोग करें जब किसी योग्य चिकित्सक ने 88–92% संतृप्ति लक्ष्य बताया हो (जैसे हाइपरकैप्निक श्वसन विफलता)।',
results:'परिणाम', total_lbl:'कुल NEWS2', risk_lbl:'जोखिम स्तर', triage_lbl:'ट्रायेज सुझाव', red_lbl:'रेड-फ्लैग (किसी एक का स्कोर 3)?',
col_param:'पैरामीटर', col_value:'मान', col_score:'स्कोर',
bands_title:'स्तरों का अर्थ (अगला कदम)',
band_low:'<b>लो (0–1)</b>: घर पर देखभाल, 6–12 घंटे में पुनः जाँच। बिगड़ने पर तुरंत सहायता लें।',
band_lomed:'<b>लो-मॉडरेट (2–4)</b>: डे-केयर/ऑब्जर्वेशन व नर्स समीक्षा; 1–2 घं. में NEWS2 दोहराएँ।',
band_med:'<b>मध्यम (5–6) या किसी एक का स्कोर 3</b>: IPD में भर्ती व तुरंत चिकित्सकीय समीक्षा (1 घं. में)।',
band_high:'<b>उच्च (≥7)</b>: ICU/क्रिटिकल केयर टीम को तुरंत बुलाएँ; ICU ट्रांसफर की तैयारी करें।',
band_low_txt:'लो (0–1)', band_lomed_txt:'लो-मॉडरेट (2–4)', band_med_txt:'मध्यम (5–6) या रेड-फ्लैग (कोई 3)', band_high_txt:'उच्च (≥7)',
tri_low:'घरेलू देखभाल व सुरक्षा-सलाह', tri_lomed:'डे-केयर/ऑब्जर्वेशन व नर्स समीक्षा', tri_med:'IPD भर्ती व तत्काल डॉक्टर समीक्षा', tri_high:'ICU (क्रिटिकल केयर टीम को अभी बुलाएँ)',
emerg_hint:'यदि तीव्र साँस फूलना, नीले/स्लेटी होंठ, तेज सीने में दर्द, दौरे या जगाने में कठिनाई हो तो <b class="danger">इसे आपातकाल</b> मानें और नज़दीकी आपातकालीन विभाग जाएँ।',
ref_title:'स्कोरिंग संदर्भ (संक्षेप)', rr_head:'श्वसन दर (सांस/मिनट)',
rr_bins:'≤8:3 | 9–11:1 | 12–20:0 | 21–24:2 | ≥25:3', o2_head:'पूरक ऑक्सीजन', o2_bins:'नहीं:0 | हाँ:2',
avpu_head:'होश (AVPU/C)', avpu_bins:'सचेत:0 | नया भ्रम या V/P/U:3',
sbp_head:'सिस्टोलिक BP (mmHg)', sbp_bins:'≤90:3 | 91–100:2 | 101–110:1 | 111–219:0 | ≥220:3',
hr_head:'नाड़ी (धड़कन/मिनट)', hr_bins:'≤40:3 | 41–50:1 | 51–90:0 | 91–110:1 | 111–130:2 | ≥131:3',
temp_head:'तापमान – थ्रेशोल्ड °C पर आधारित', temp_bins:'',
sp1_head:'SpO₂ – स्केल 1', sp1_bins:'≤91:3 | 92–93:2 | 94–95:1 | 96–100:0',
sp2_head:'SpO₂ – स्केल 2*', sp2_bins:'≤83:3 | 84–85:2 | 86–87:1 | 88–92:0 | 93–94:1 | 95–96:2 | ≥97:3',
sp2_hint:'*केवल तब जब चिकित्सक ने 88–92% लक्ष्य बताया हो।',
priv:'यह ऐप ऑफ़लाइन काम करता है। कोई डेटा आपके डिवाइस से बाहर नहीं जाता। प्रिन्ट/PDF कर के डॉक्टर को दिखाएँ।',
refs_lbl:'संदर्भ:', yes:'हाँ', no:'नहीं',
p_rr:'श्वसन दर', p_spo2:'SpO₂', p_o2:'पूरक ऑक्सीजन', p_sbp:'सिस्टोलिक BP', p_hr:'नाड़ी', p_temp:'तापमान (°F)', p_avpu:'होश (AVPU/C)',
meta_case:'केस #:', meta_name:'नाम:', generated:'निर्मित:'
},
bn:{ title:'NEWS2 পরীক্ষক ও ট্রায়াজ', offline:'অফলাইন • মোবাইল-বান্ধব', lang:'ভাষা',
intro:'প্রাপ্তবয়স্কদের জন্য (≥16 বছর)। রোগী, পরিবার ও নার্সদের NEWS2 গণনা করতে এবং পরিচর্যার স্থান (বাড়ি / ডে-কেয়ার / আইপিডি / আইসিইউ) নির্ধারণে সহায়তার জন্য। এটি ক্লিনিক্যাল বিচার বা জরুরি চিকিৎসার বিকল্প নয়।',
inputs:'রোগীর তথ্য', case_lbl:'কেস নম্বর', first_lbl:'নাম (প্রথম)',
rr:'শ্বাস-প্রশ্বাসের হার (বার/মিনিট)', o2:'অতিরিক্ত অক্সিজেন চলছে?', o2_no:'না (এয়ার)', o2_yes:'হ্যাঁ (যে কোনো ডিভাইস)',
spo2:'SpO₂ (%)', spo2scale:'SpO₂ স্কেল', sc1:'স্কেল 1 (ডিফল্ট – অধিকাংশ রোগী)', sc2:'স্কেল 2 (লক্ষ্য 88–92% – কেবল পরামর্শে)',
sbp:'সিস্টোলিক BP (mmHg)', hr:'পালস / হার্ট রেট (বিট/মিনিট)', temp:'তাপমাত্রা (°F)', avpu:'চেতনাস্থা',
optA:'সচেতন', optC:'নতুন বিভ্রান্তি (C)', optV:'ডাকে সাড়া (V)', optP:'ব্যথায় সাড়া (P)', optU:'অসাড় (U)',
calc:'NEWS2 গণনা করুন', reset:'রিসেট', print:'প্রিন্ট / PDF',
scale_hint:'SpO₂-এর <b>স্কেল 2</b> কেবল তখনই ব্যবহার করুন যখন চিকিৎসক 88–92% লক্ষ্য বলেছেন (যেমন হাইপারক্যাপনিক রেসপিরেটরি ফেলিওর)।',
results:'ফলাফল', total_lbl:'মোট NEWS2', risk_lbl:'ঝুঁকির স্তর', triage_lbl:'ট্রায়াজ পরামর্শ', red_lbl:'রেড ফ্ল্যাগ (কোনো একটি স্কোর 3)?',
col_param:'প্যারামিটার', col_value:'মান', col_score:'স্কোর',
bands_title:'স্তরগুলোর মানে (পরবর্তী পদক্ষেপ)',
band_low:'<b>লো (0–1)</b>: বাড়িতে পরিচর্যা; 6–12 ঘণ্টায় পুনঃপরীক্ষা। খারাপ হলে তাড়াতাড়ি সাহায্য নিন।',
band_lomed:'<b>লো-মডারেট (2–4)</b>: ডে-কেয়ার/অবজারভেশন ও নার্স রিভিউ; 1–2 ঘণ্টায় NEWS2 পুনরাবৃত্তি।',
band_med:'<b>মিডিয়াম (5–6) বা কোনো একটিতে স্কোর 3</b>: IPD ভর্তি ও দ্রুত চিকিৎসক রিভিউ (1 ঘণ্টার মধ্যে)।',
band_high:'<b>হাই (≥7)</b>: সঙ্গে সঙ্গে ICU/ক্রিটিক্যাল কেয়ার টিমকে ডাকুন; ICU ট্রান্সফারের প্রস্তুতি নিন।',
band_low_txt:'লো (0–1)', band_lomed_txt:'লো-মডারেট (2–4)', band_med_txt:'মিডিয়াম (5–6) বা রেড-ফ্ল্যাগ (কোনো 3)', band_high_txt:'হাই (≥7)',
tri_low:'বাড়িতে পরিচর্যা ও সেফটি-নেট', tri_lomed:'ডে-কেয়ার/অবজারভেশন ও নার্স রিভিউ', tri_med:'IPD ভর্তি ও দ্রুত চিকিৎসক রিভিউ', tri_high:'ICU (ক্রিটিক্যাল কেয়ার টিমকে এখনই ডাকুন)',
emerg_hint:'যদি তীব্র শ্বাসকষ্ট, নীলচে ঠোঁট, তীব্র বুকব্যথা, খিঁচুনি বা জাগানো কঠিন হয়, <b class="danger">জরুরি</b> ধরে নিন এবং নিকটস্থ জরুরি বিভাগে যান।',
ref_title:'স্কোরিং রেফারেন্স (সংক্ষিপ্ত)', rr_head:'শ্বাস-প্রশ্বাসের হার (বার/মিনিট)',
rr_bins:'≤8:3 | 9–11:1 | 12–20:0 | 21–24:2 | ≥25:3', o2_head:'অতিরিক্ত অক্সিজেন', o2_bins:'না:0 | হ্যাঁ:2',
avpu_head:'চেতনাস্থা (AVPU/C)', avpu_bins:'সচেতন:0 | নতুন বিভ্রান্তি বা V/P/U:3',
sbp_head:'সিস্টোলিক BP (mmHg)', sbp_bins:'≤90:3 | 91–100:2 | 101–110:1 | 111–219:0 | ≥220:3',
hr_head:'পালস (বিট/মিনিট)', hr_bins:'≤40:3 | 41–50:1 | 51–90:0 | 91–110:1 | 111–130:2 | ≥131:3',
temp_head:'তাপমাত্রা – থ্রেশোল্ড °C অনুযায়ী', temp_bins:'',
sp1_head:'SpO₂ – স্কেল 1', sp1_bins:'≤91:3 | 92–93:2 | 94–95:1 | 96–100:0',
sp2_head:'SpO₂ – স্কেল 2*', sp2_bins:'≤83:3 | 84–85:2 | 86–87:1 | 88–92:0 | 93–94:1 | 95–96:2 | ≥97:3',
sp2_hint:'*শুধু তখনই যখন চিকিৎসক 88–92% লক্ষ্য বলেছেন।',
priv:'অফলাইনেই কাজ করে। আপনার ডিভাইস থেকে কোনো ডেটা বাইরে যায় না। প্রিন্ট/PDF করে চিকিৎসককে দেখান।',
refs_lbl:'রেফারেন্স:', yes:'হ্যাঁ', no:'না',
p_rr:'শ্বাস-প্রশ্বাসের হার', p_spo2:'SpO₂', p_o2:'অতিরিক্ত অক্সিজেন', p_sbp:'সিস্টোলিক BP', p_hr:'পালস', p_temp:'তাপমাত্রা (°F)', p_avpu:'চেতনাস্থা (AVPU/C)',
meta_case:'কেস #:', meta_name:'নাম:', generated:'তৈরি সময়:'
}
};
var currentLang='en';
function translateAVPU(v){
var map={A:{en:'Alert',hi:'सचेत',bn:'সচেতন'},
C:{en:'New Confusion (C)',hi:'नया भ्रम (C)',bn:'নতুন বিভ্রান্তি (C)'},
V:{en:'Responds to Voice (V)',hi:'आवाज़ पर प्रतिक्रिया (V)',bn:'ডাকে সাড়া (V)'},
P:{en:'Responds to Pain (P)',hi:'दर्द पर प्रतिक्रिया (P)',bn:'ব্যথায় সাড়া (P)'},
U:{en:'Unresponsive (U)',hi:'प्रतिक्रिया नहीं (U)',bn:'অসাড় (U)'}};
return (map[v] && map[v][currentLang]) || v;
}
function setLang(lang){
currentLang=lang; var t=i18n[lang];
var ids=['t_title','t_offline','t_lang','t_intro','t_inputs','t_rr','t_o2','t_o2_no','t_o2_yes','t_spo2','t_spo2scale','t_sc1','t_sc2','t_sbp','t_hr','t_temp','t_avpu','t_A','t_C','t_V','t_P','t_U','t_calc','t_reset','t_print','t_results','t_total_lbl','t_risk_lbl','t_triage_lbl','t_red_lbl','t_col_param','t_col_value','t_col_score','t_bands_title','t_band_low','t_band_lomed','t_band_med','t_band_high','t_emerg_hint','t_ref_title','t_rr_head','t_rr_bins','t_o2_head','t_o2_bins','t_avpu_head','t_avpu_bins','t_sbp_head','t_sbp_bins','t_hr_head','t_hr_bins','t_temp_head','t_sp1_head','t_sp1_bins','t_sp2_head','t_sp2_bins','t_sp2_hint','t_priv','t_refs_lbl','t_case_lbl','t_first_lbl'];
var map={
t_title:t.title, t_offline:t.offline, t_lang:t.lang, t_intro:t.intro, t_inputs:t.inputs,
t_rr:t.rr, t_o2:t.o2, t_o2_no:t.o2_no, t_o2_yes:t.o2_yes, t_spo2:t.spo2, t_spo2scale:t.spo2scale,
t_sc1:t.sc1, t_sc2:t.sc2, t_sbp:t.sbp, t_hr:t.hr, t_temp:t.temp, t_avpu:t.avpu,
t_A:t.optA, t_C:t.optC, t_V:t.optV, t_P:t.optP, t_U:t.optU, t_calc:t.calc, t_reset:t.reset, t_print:t.print,
t_results:t.results, t_total_lbl:t.total_lbl, t_risk_lbl:t.risk_lbl, t_triage_lbl:t.triage_lbl, t_red_lbl:t.red_lbl,
t_col_param:t.col_param, t_col_value:t.col_value, t_col_score:t.col_score,
t_bands_title:t.bands_title, t_band_low:t.band_low, t_band_lomed:t.band_lomed, t_band_med:t.band_med, t_band_high:t.band_high,
t_emerg_hint:t.emerg_hint, t_ref_title:t.ref_title, t_rr_head:t.rr_head, t_rr_bins:t.rr_bins, t_o2_head:t.o2_head, t_o2_bins:t.o2_bins,
t_avpu_head:t.avpu_head, t_avpu_bins:t.avpu_bins, t_sbp_head:t.sbp_head, t_sbp_bins:t.sbp_bins, t_hr_head:t.hr_head, t_hr_bins:t.hr_bins,
t_temp_head:t.temp_head, t_sp1_head:t.sp1_head, t_sp1_bins:t.sp1_bins, t_sp2_head:t.sp2_head, t_sp2_bins:t.sp2_bins,
t_sp2_hint:t.sp2_hint, t_priv:t.priv, t_refs_lbl:t.refs_lbl, t_case_lbl:t.case_lbl, t_first_lbl:t.first_lbl
};
for(var i=0;i<ids.length;i++){ var id=ids[i]; setHTML(id, map[id]); }
renderTempBins();
updateMeta();
stampNow();
}
/* ---------- init ---------- */
function init(){
// preload persisted inputs
try{
var raw = localStorage.getItem('news2_saved');
if(raw){
var s = JSON.parse(raw)||{};
if(s.rr!==undefined) $('rr').value = s.rr;
$('oxygen').value = s.onO2?'yes':'no';
if(s.spo2!==undefined) $('spo2').value = s.spo2;
if(s.scale!==undefined) $('spo2scale').value = s.scale;
if(s.sbp!==undefined) $('sbp').value = s.sbp;
if(s.hr!==undefined) $('hr').value = s.hr;
if(s.tempF!==undefined) $('temp').value = s.tempF;
if(s.temp!==undefined) $('temp').value = s.temp;
if(s.avpu!==undefined) $('avpu').value = s.avpu;
}
var m = JSON.parse(localStorage.getItem('news2_meta')||'null');
if(m){
if(m.caseNo) $('caseNo').value = m.caseNo;
if(m.firstName) $('firstName').value = m.firstName;
}
}catch(e){}
updateMeta();
renderTempBins();
stampNow();
startStampTicker();
// events
$('calc').addEventListener('click', calculate, false);
$('reset').addEventListener('click', resetForm, false);
$('print').addEventListener('click', function(){ if(!lastTxt){ calculate(); } stampNow(); window.print(); }, false);
window.addEventListener('beforeprint', function(){ if(!lastTxt){ calculate(); } stampNow(); }, false);
$('saveTxt').addEventListener('click', function(){
if(!lastTxt){ calculate(); }
saveTxtToFile(lastTxt || '');
}, false);
$('caseNo').addEventListener('input', function(){ updateMeta(); if(lastTxt){ calculate(); } }, false);
$('firstName').addEventListener('input', function(){ updateMeta(); if(lastTxt){ calculate(); } }, false);
$('langSel').addEventListener('change', function(e){ setLang(e.target.value); calculate(); }, false);
document.addEventListener('visibilitychange', function(){ if(!document.hidden){ stampNow(); } }, false);
setLang('en'); // initial language text fill
}
if(document.readyState==='loading'){
document.addEventListener('DOMContentLoaded', init, false);
}else{
init();
}
})();
</script>
<details class="no-print">
<summary class="hint">License and Medical Disclaimer</summary>
<section class="card">
<small>
Software License: GNU GPL v3. Copyright (C) [2025] [Prof. Jyotirmay Kirtania]. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
Medical Disclaimer (Cognitive Assist & Record Keeping). IMPORTANT: PLEASE READ CAREFULLY BEFORE USE. NOT A MEDICAL DEVICE: This tool is a Clinical Decision Support System (CDSS) intended for educational and cognitive assistance purposes only. It has not been cleared or approved by the FDA, EMA, or any other regulatory body for use as a primary medical device. NO SUBSTITUTE FOR CLINICAL JUDGMENT: This tool is designed to assist, not replace, the clinical judgment of qualified healthcare professionals. All calculations and logic must be independently verified against institutional standards before clinical application. DATA PRIVACY: This tool is designed to run locally on the user's device. No data is transmitted to external servers by the software. The user is solely responsible for ensuring that the use of this tool complies with local patient data privacy laws (e.g., HIPAA, GDPR) and institutional IT policies. LIMITATION OF LIABILITY: In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software.
</small>
</section>
</details>
</body>
</html>