/* package whatever; // don't place package name! */
<meta charset="utf-8">
<script>;
function checkTrue(vari, stringName){vari = prompt(stringName);
while(isNaN(vari) == true || vari < 0 || vari > 10) {
if(isNaN(vari) == true || vari < 0 || vari > 10){
vari = prompt("Wrong input in " + stringName + " dose, try again:")
}else{break
}
}
vari = parseFloat(vari)
return vari
}
alert("Welcome blah-blah")
var INR = checkTrue(INR, "INR")
alert("INR =" + INR);
var SameDose;
SameDose = prompt("Does the patient take the same dose every day? (y/n)");
if (SameDose == "y") {
var Dose = checkTrue(Dose, "Daily Dose (ALL IN TABLETS!")*7;
} else {
var DoseMon = checkTrue(DoseMon, "Monday (ALL IN TABLETS!");
var DoseTue = checkTrue(DoseTue, "Tuesday");
var DoseWed = checkTrue(DoseWed, "Wednesday");
var DoseThur = checkTrue(DoseThur, "Thursday");
var DoseFri = checkTrue(DoseFri, "Friday");
var DoseSat = checkTrue(DoseSat, "Saturday");
var DoseSun = checkTrue(DoseSun, "Sunday");
var Dose =(DoseSun + DoseSat + DoseFri + DoseThur + DoseWed + DoseTue + DoseMon);
}
if (SameDose == "y") {
alert("Weekly Dose =" + Dose)
} else {
alert("Weekle Dose =" + DoseMon + "+" + DoseTue + "+" + DoseWed + "+" + DoseThur + "+" + DoseFri + "+" + DoseSat + "+" + DoseSun + "=" + Dose)
}
var DoseCalc=Dose*4
var Alg;
if (INR >= 2.0 && INR <=3.0) {
Alg = 3
} else if (INR <= 1.5) {
Alg = 1
} else if (INR > 1.5 && INR < 2.0){
Alg = 2
} else if (INR > 3.0 && INR < 4) {
Alg = 4
}else if (INR >= 4.0 && INR < 5.0){
Alg = 5
}else if (INR >= 5.0 && INR <= 10.0){
Alg = 6
} else {
Alg = 7
}
if (Alg == 1) {
DoseCalc = DoseCalc*1.15
} else if (Alg == 2) {
DoseCalc = DoseCalc*1.1
} else if (Alg == 3) {
DoseCalc = DoseCalc
} else if (Alg == 4) {
DoseCalc = DoseCalc*0.9
}else if (Alg == 5) {
DoseCalc = DoseCalc*0.9
}else if (Alg == 6) {
DoseCalc = DoseCalc*0.85
}else {
DoseCalc = DoseCalc*0.75
}
DoseCalcRounded = parseInt(DoseCalc)
if(DoseCalc == DoseCalcRounded && INR >= 2.5){
DoseCalcRounded = DoseCalcRounded
} else if (DoseCalc == DoseCalcRounded && INR < 2.5) {
DoseCalcRounded = DoseCalcRounded
} else if (DoseCalc != DoseCalcRounded && INR >= 2.5) {
DoseCalcRounded = DoseCalcRounded
} else {
DoseCalcRounded = DoseCalcRounded+1
}
var Resid = DoseCalcRounded%7;
var NewDailyD = (DoseCalcRounded - Resid)/7
var NewMon;
var NewTue;
var NewWed;
var NewThur;
var NewFri;
var NewSat;
var NewSun;
if (Resid == 0) {
NewMon = parseFloat(NewDailyD)/4;
NewTue = parseFloat(NewDailyD)/4;
NewWed = parseFloat(NewDailyD)/4;
NewThur = parseFloat(NewDailyD)/4;
NewFri = parseFloat(NewDailyD)/4;
NewSat = parseFloat(NewDailyD)/4;
NewSun = parseFloat(NewDailyD)/4;
} else if (Resid == 1) {
NewMon = (parseFloat(NewDailyD)+1)/4;
NewTue = parseFloat(NewDailyD)/4;
NewWed = parseFloat(NewDailyD)/4;
NewThur = parseFloat(NewDailyD)/4;
NewFri = parseFloat(NewDailyD)/4;
NewSat = parseFloat(NewDailyD)/4;
NewSun = parseFloat(NewDailyD)/4
} else if(Resid == 2){
NewMon = (parseFloat(NewDailyD)+1)/4;
NewTue = parseFloat(NewDailyD)/4;
NewWed = parseFloat(NewDailyD)/4;
NewThur = parseFloat(NewDailyD)/4;
NewFri = (parseFloat(NewDailyD)+1)/4;
NewSat = parseFloat(NewDailyD)/4;
NewSun = parseFloat(NewDailyD)/4
}else if(Resid == 3){
NewMon = (parseFloat(NewDailyD)+1)/4;
NewTue = parseFloat(NewDailyD)/4;
NewWed = parseFloat(NewDailyD)/4;
NewThur = (parseFloat(NewDailyD)+1)/4;
NewFri = parseFloat(NewDailyD)/4;
NewSat = (parseFloat(NewDailyD)+1)/4;
NewSun = parseFloat(NewDailyD)/4
}else if (Resid == 4) {
NewMon = (parseFloat(NewDailyD)+1)/4;
NewTue = parseFloat(NewDailyD)/4;
NewWed = (parseFloat(NewDailyD)+1)/4;
NewThur = (parseFloat(NewDailyD)+1)/4;
NewFri = parseFloat(NewDailyD)/4;
NewSat = (parseFloat(NewDailyD)+1)/4;
NewSun = parseFloat(NewDailyD)/4
} else if (Resid == 5){
NewMon = (parseFloat(NewDailyD)+1)/4;
NewTue = (parseFloat(NewDailyD)+1)/4;
NewWed = parseFloat(NewDailyD)/4;
NewThur = (parseFloat(NewDailyD)+1)/4;
NewFri = (parseFloat(NewDailyD)+1)/4;
NewSat = (parseFloat(NewDailyD)+1)/4;
NewSun = parseFloat(NewDailyD)/4
}else{
NewMon = (parseFloat(NewDailyD)+1)/4;
NewTue = (parseFloat(NewDailyD)+1)/4;
NewWed = (parseFloat(NewDailyD)+1)/4;
NewThur = (parseFloat(NewDailyD)+1)/4;
NewFri = (parseFloat(NewDailyD)+1)/4;
NewSat = (parseFloat(NewDailyD)+1)/4;
NewSun = parseFloat(NewDailyD)/4
}
alert("New dosage \n Monday - " + NewMon + "\n Tuesday - " + NewTue + "\n Wednesday - " + NewWed + "\n Thursday - " + NewThur + "\n Friday - " + NewFri + "\n Saturday - " + NewSat + "\n Sunday - " + NewSun);
</script>