fork(1) download
  1. /* package whatever; // don't place package name! */
  2. <meta charset="utf-8">
  3. <script>;
  4.  
  5. function checkTrue(vari, stringName){vari = prompt(stringName);
  6. while(isNaN(vari) == true || vari < 0 || vari > 10) {
  7. if(isNaN(vari) == true || vari < 0 || vari > 10){
  8. vari = prompt("Wrong input in " + stringName + " dose, try again:")
  9. }else{break
  10. }
  11. }
  12. vari = parseFloat(vari)
  13. return vari
  14. }
  15. alert("Welcome blah-blah")
  16. var INR = checkTrue(INR, "INR")
  17.  
  18. alert("INR =" + INR);
  19.  
  20.  
  21.  
  22. var SameDose;
  23. SameDose = prompt("Does the patient take the same dose every day? (y/n)");
  24. if (SameDose == "y") {
  25. var Dose = checkTrue(Dose, "Daily Dose (ALL IN TABLETS!")*7;
  26. } else {
  27. var DoseMon = checkTrue(DoseMon, "Monday (ALL IN TABLETS!");
  28. var DoseTue = checkTrue(DoseTue, "Tuesday");
  29. var DoseWed = checkTrue(DoseWed, "Wednesday");
  30. var DoseThur = checkTrue(DoseThur, "Thursday");
  31. var DoseFri = checkTrue(DoseFri, "Friday");
  32. var DoseSat = checkTrue(DoseSat, "Saturday");
  33. var DoseSun = checkTrue(DoseSun, "Sunday");
  34.  
  35. var Dose =(DoseSun + DoseSat + DoseFri + DoseThur + DoseWed + DoseTue + DoseMon);
  36.  
  37. }
  38. if (SameDose == "y") {
  39. alert("Weekly Dose =" + Dose)
  40. } else {
  41. alert("Weekle Dose =" + DoseMon + "+" + DoseTue + "+" + DoseWed + "+" + DoseThur + "+" + DoseFri + "+" + DoseSat + "+" + DoseSun + "=" + Dose)
  42. }
  43.  
  44. var DoseCalc=Dose*4
  45.  
  46. var Alg;
  47. if (INR >= 2.0 && INR <=3.0) {
  48. Alg = 3
  49. } else if (INR <= 1.5) {
  50. Alg = 1
  51. } else if (INR > 1.5 && INR < 2.0){
  52. Alg = 2
  53. } else if (INR > 3.0 && INR < 4) {
  54. Alg = 4
  55. }else if (INR >= 4.0 && INR < 5.0){
  56. Alg = 5
  57. }else if (INR >= 5.0 && INR <= 10.0){
  58. Alg = 6
  59. } else {
  60. Alg = 7
  61. }
  62.  
  63. if (Alg == 1) {
  64. DoseCalc = DoseCalc*1.15
  65. } else if (Alg == 2) {
  66. DoseCalc = DoseCalc*1.1
  67. } else if (Alg == 3) {
  68. DoseCalc = DoseCalc
  69. } else if (Alg == 4) {
  70. DoseCalc = DoseCalc*0.9
  71. }else if (Alg == 5) {
  72. DoseCalc = DoseCalc*0.9
  73. }else if (Alg == 6) {
  74. DoseCalc = DoseCalc*0.85
  75. }else {
  76. DoseCalc = DoseCalc*0.75
  77. }
  78.  
  79.  
  80. DoseCalcRounded = parseInt(DoseCalc)
  81.  
  82.  
  83. if(DoseCalc == DoseCalcRounded && INR >= 2.5){
  84. DoseCalcRounded = DoseCalcRounded
  85. } else if (DoseCalc == DoseCalcRounded && INR < 2.5) {
  86. DoseCalcRounded = DoseCalcRounded
  87. } else if (DoseCalc != DoseCalcRounded && INR >= 2.5) {
  88. DoseCalcRounded = DoseCalcRounded
  89. } else {
  90. DoseCalcRounded = DoseCalcRounded+1
  91. }
  92.  
  93.  
  94. var Resid = DoseCalcRounded%7;
  95. var NewDailyD = (DoseCalcRounded - Resid)/7
  96.  
  97.  
  98. var NewMon;
  99. var NewTue;
  100. var NewWed;
  101. var NewThur;
  102. var NewFri;
  103. var NewSat;
  104. var NewSun;
  105. if (Resid == 0) {
  106. NewMon = parseFloat(NewDailyD)/4;
  107. NewTue = parseFloat(NewDailyD)/4;
  108. NewWed = parseFloat(NewDailyD)/4;
  109. NewThur = parseFloat(NewDailyD)/4;
  110. NewFri = parseFloat(NewDailyD)/4;
  111. NewSat = parseFloat(NewDailyD)/4;
  112. NewSun = parseFloat(NewDailyD)/4;
  113. } else if (Resid == 1) {
  114. NewMon = (parseFloat(NewDailyD)+1)/4;
  115. NewTue = parseFloat(NewDailyD)/4;
  116. NewWed = parseFloat(NewDailyD)/4;
  117. NewThur = parseFloat(NewDailyD)/4;
  118. NewFri = parseFloat(NewDailyD)/4;
  119. NewSat = parseFloat(NewDailyD)/4;
  120. NewSun = parseFloat(NewDailyD)/4
  121. } else if(Resid == 2){
  122. NewMon = (parseFloat(NewDailyD)+1)/4;
  123. NewTue = parseFloat(NewDailyD)/4;
  124. NewWed = parseFloat(NewDailyD)/4;
  125. NewThur = parseFloat(NewDailyD)/4;
  126. NewFri = (parseFloat(NewDailyD)+1)/4;
  127. NewSat = parseFloat(NewDailyD)/4;
  128. NewSun = parseFloat(NewDailyD)/4
  129. }else if(Resid == 3){
  130. NewMon = (parseFloat(NewDailyD)+1)/4;
  131. NewTue = parseFloat(NewDailyD)/4;
  132. NewWed = parseFloat(NewDailyD)/4;
  133. NewThur = (parseFloat(NewDailyD)+1)/4;
  134. NewFri = parseFloat(NewDailyD)/4;
  135. NewSat = (parseFloat(NewDailyD)+1)/4;
  136. NewSun = parseFloat(NewDailyD)/4
  137. }else if (Resid == 4) {
  138. NewMon = (parseFloat(NewDailyD)+1)/4;
  139. NewTue = parseFloat(NewDailyD)/4;
  140. NewWed = (parseFloat(NewDailyD)+1)/4;
  141. NewThur = (parseFloat(NewDailyD)+1)/4;
  142. NewFri = parseFloat(NewDailyD)/4;
  143. NewSat = (parseFloat(NewDailyD)+1)/4;
  144. NewSun = parseFloat(NewDailyD)/4
  145. } else if (Resid == 5){
  146. NewMon = (parseFloat(NewDailyD)+1)/4;
  147. NewTue = (parseFloat(NewDailyD)+1)/4;
  148. NewWed = parseFloat(NewDailyD)/4;
  149. NewThur = (parseFloat(NewDailyD)+1)/4;
  150. NewFri = (parseFloat(NewDailyD)+1)/4;
  151. NewSat = (parseFloat(NewDailyD)+1)/4;
  152. NewSun = parseFloat(NewDailyD)/4
  153. }else{
  154. NewMon = (parseFloat(NewDailyD)+1)/4;
  155. NewTue = (parseFloat(NewDailyD)+1)/4;
  156. NewWed = (parseFloat(NewDailyD)+1)/4;
  157. NewThur = (parseFloat(NewDailyD)+1)/4;
  158. NewFri = (parseFloat(NewDailyD)+1)/4;
  159. NewSat = (parseFloat(NewDailyD)+1)/4;
  160. NewSun = parseFloat(NewDailyD)/4
  161. }
  162.  
  163. alert("New dosage \n Monday - " + NewMon + "\n Tuesday - " + NewTue + "\n Wednesday - " + NewWed + "\n Thursday - " + NewThur + "\n Friday - " + NewFri + "\n Saturday - " + NewSat + "\n Sunday - " + NewSun);
  164. </script>
Runtime error #stdin #stdout #stderr 0.17s 323136KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
js: "prog.js", line 5: syntax error
js: function checkTrue(vari, stringName){vari = prompt(stringName);
js: ..............................................................^
js: "prog.js", line 13: invalid return
js: 	return vari
js: .......^
js: "prog.js", line 14: syntax error
js: }
js: ^
js: "prog.js", line 164: illegally formed XML syntax
js: </script>
js: .^
js: "prog.js", line 164: syntax error
js: </script>
js: .^
js: "prog.js", line 1: Compilation produced 5 syntax errors.