|
| 1 | +// Clinical Global Impressions Scale Calculator |
| 2 | +// Javascript to load a bootstrap-styled calculator on a page |
| 3 | +// created 24/Oct/2017 Dean Jenkins |
| 4 | + |
| 5 | +// Since I don't like the way some websites covet these trivial algorithms |
| 6 | +// and try to monetize them by licensing them or pushing adverts this |
| 7 | +// code has been released under the following license. |
| 8 | +// Creative Commons Attribution 4.0 International (CC BY 4.0) |
| 9 | +// https://creativecommons.org/licenses/by/4.0/ |
| 10 | + |
| 11 | + |
| 12 | +function CGIS() |
| 13 | +{ |
| 14 | + |
| 15 | + var CGIS=getvaluefromradio("tblable_calc_form_CGIS"); |
| 16 | + |
| 17 | + var score = parseFloat(CGIS); |
| 18 | + document.getElementById("tblable_calc_form_score").innerHTML = score.toString(); |
| 19 | + |
| 20 | + var summaryhtml=""; |
| 21 | + var source=". from Busner & Targum (2007, table 1)."; |
| 22 | + |
| 23 | + if (score==1) { |
| 24 | + summaryhtml = summaryhtml + "Normal" + source; |
| 25 | + $('#result').removeClass(); |
| 26 | + $('#result').addClass("alert alert-success"); |
| 27 | + } |
| 28 | + if (score>1 && score <5) { |
| 29 | + $('#result').removeClass(); |
| 30 | + $('#result').addClass("alert alert-warning"); |
| 31 | + } |
| 32 | + if (score>4) { |
| 33 | + $('#result').removeClass(); |
| 34 | + $('#result').addClass("alert alert-danger"); |
| 35 | + } |
| 36 | + |
| 37 | + if (score==2) { |
| 38 | + summaryhtml = summaryhtml + "Borderline mentally ill" + source; |
| 39 | + } |
| 40 | + |
| 41 | + if (score==3) { |
| 42 | + summaryhtml = summaryhtml + "Mildly ill" + source; |
| 43 | + } |
| 44 | + |
| 45 | + if (score==4) { |
| 46 | + summaryhtml = summaryhtml + "Moderately ill" + source; |
| 47 | + } |
| 48 | + |
| 49 | + if (score==5) { |
| 50 | + summaryhtml = summaryhtml + "Markedly ill" + source; |
| 51 | + } |
| 52 | + |
| 53 | + if (score==6) { |
| 54 | + summaryhtml = summaryhtml + " Severely ill" + source; |
| 55 | + } |
| 56 | + |
| 57 | + if (score==7) { |
| 58 | + summaryhtml = summaryhtml + " Among the most extremely ill patients" + source; |
| 59 | + } |
| 60 | + |
| 61 | + |
| 62 | + document.getElementById("tblable_calc_form_comment").innerHTML = summaryhtml; |
| 63 | +} |
| 64 | + |
| 65 | +function resetCalc() { |
| 66 | + uncheckradio("tblable_calc_form_CGIS"); |
| 67 | + checkradio("tblable_calc_form_CGIS1"); // CGIS normal is 1 |
| 68 | +} |
| 69 | + |
| 70 | + |
| 71 | +var calculatorHTML = '' + |
| 72 | +'<div class="calculator" id="tblable_calc">' + |
| 73 | + |
| 74 | +' <div name="hform" id="tblable_calc_form">' + |
| 75 | + |
| 76 | +headerBlurb("CGI-Severity","Clinical Global Impressions Scale for mental illness","Select the most appropriate") + |
| 77 | + |
| 78 | + |
| 79 | +simpleradio("tblable_calc_form_CGIS1","tblable_calc_form_CGIS","1","<b>Normal</b> (1). not at all ill, symptoms of disorder not present past seven days","CGIS();") + |
| 80 | +simpleradio("tblable_calc_form_CGIS2","tblable_calc_form_CGIS","2","<b>Borderline mentally ill</b> (2). subtle or suspected pathology","CGIS();") + |
| 81 | +simpleradio("tblable_calc_form_CGIS3","tblable_calc_form_CGIS","3","<b>Mildly ill</b> (3). clearly established symptoms with minimal, if any, distress or difficulty in social and occupational function","CGIS();") + |
| 82 | +simpleradio("tblable_calc_form_CGIS4","tblable_calc_form_CGIS","4","<b>Moderately ill</b> (4). overt symptoms causing noticeable, but modest, functional impairment or distress; symptom level may warrant medication","CGIS();") + |
| 83 | +simpleradio("tblable_calc_form_CGIS5","tblable_calc_form_CGIS","5","<b>Markedly ill</b> (5). intrusive symptoms that distinctly impair social/occupational function or cause intrusive levels of distress","CGIS();") + |
| 84 | +simpleradio("tblable_calc_form_CGIS6","tblable_calc_form_CGIS","6","<b>Severely ill</b> (6). disruptive pathology, behavior and function are frequently influenced by symptoms, may require assistance from others","CGIS();") + |
| 85 | +simpleradio("tblable_calc_form_CGIS7","tblable_calc_form_CGIS","7","<b>Among the most extremely ill patients</b> (7). pathology drastically interferes in many life functions; may be hospitalized","CGIS();") + |
| 86 | + |
| 87 | + |
| 88 | +' <div id="result" class="alert alert-success">' + |
| 89 | +' <div><b>CGI-S Scale = <span id="tblable_calc_form_score"></span></b>. ' + |
| 90 | +' <span id="tblable_calc_form_comment"></span></div>' + |
| 91 | +' </div>' + |
| 92 | + |
| 93 | +' <div class="reset">' + |
| 94 | +' <input value="Reset" class="btn btn-secondary" onclick="resetCalc(); CGIS(); return false;" type="reset">' + |
| 95 | +' </div>' + |
| 96 | + |
| 97 | +' </div><!-- end hform -->' + |
| 98 | + |
| 99 | +'</div><!-- end calculator -->' + |
| 100 | +'<p class="small">Source <a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2880930/">Busner & Targum (2007)</a></p>' + |
| 101 | +''; |
| 102 | + |
| 103 | +function calcHTML() { |
| 104 | + document.write('<div id="calc"></div>'); |
| 105 | + |
| 106 | + document.getElementById("calc").innerHTML = calculatorHTML; |
| 107 | +} |
| 108 | + |
| 109 | +calcHTML(); |
| 110 | +resetCalc(); // required to set the default radio button |
| 111 | +CGIS(); |
0 commit comments