import [Link].
*;
public class CIS129_WhitneyHenderson_Lab3v2{
static Scanner keyboard = new Scanner([Link]);
static final int EXIT = 5;
static final String [][] MEDICINE = {
{"Abilify- ", "an antipsychotic drug"},
{"Ambien- ", "to treat insomnia"},
{"Amoxi- ", "an antibiotic"},
{"Aspirin- ", "a pain reliever"},
{"Crestor- ", "a cholesterol-lowering statin drug"},
{"Placebotec- ","to treat hypochondriacs"},
{"Xanax- ", "to treat anxiety disorders"},
{"Norvasc- ", "a high blood pressure drug"},
{"Penicillin- ","an antibiotic"},
{"Plavix- ", "a blood thinner"},
{"Prilosec- ", "to treat reflux disease"},
{"Wellbe- ", "an antidepressant"},
{"Nexium- ", "an antacid drug"},
{"Zoloft- ", "an antidepressant"}
};
public static void main (String [] args){
do{
boolean [] medsPrescribed = new boolean [[Link]];
int userInput;
String yourName;
displayWelcome();
menuOptions();
//makes sure that the first value entered is 1
userInput = getValidMenu("Please enter a menu option");
while (firstInput(userInput)){
[Link]("You must sign in as a doctor first");
menuOptions();
userInput = getValidMenu("Please enter a menu option");
}// end while
yourName = [Link]("Please enter your name Doc");
//makes ure that you are entering the correct values and searches the menu
menuOptionsDoc(yourName);
userInput = getValidMenu("Please enter a menu option");
searchMenu(userInput, medsPrescribed);
while(userInput != EXIT){
[Link]("\n");
menuOptionsDoc(yourName);
userInput = getValidMenu("Please enter a menu option");
searchMenu(userInput, medsPrescribed);
}//end while
[Link]("Goodbye");
}while([Link]("Would a new doctor like to sign in? (Enter yes or no)"));
}// end main
public static void displayWelcome(){
[Link]("*************************************************************
***************************");
[Link]("Welcome to the patient portal, a one stop shop to get your job done!");
[Link]("Prescribe precriptions, check prescription history, and even reset the
prescription history");
[Link]("Here are the menu options please sign in as a doctor first to get things
started!");
[Link]("*************************************************************
***************************");
}
public static void menuOptions(){
[Link]("*********************************************");
[Link]("Welcome to Your Patient's Prescription History");
[Link]("*********************************************");
[Link]("Menu Options");
[Link]("1. Sign in as the doctor");
[Link]("2. Display prescription history");
[Link]("3. Prescribe medicine");
[Link]("4. Reset prescription history");
[Link]("5. Exit the program");
}//end menu options 1
public static void menuOptionsDoc(String yourName){
[Link]("*********************************************");
[Link]("Welcome to Your Patient's Prescription History");
[Link]("*********************************************");
[Link]("Menu Options for Dr. " +yourName);
[Link]("1. Sign in as the doctor");
[Link]("2. Display prescription history");
[Link]("3. Prescribe medicine");
[Link]("4. Reset prescription history");
[Link]("5. Exit the program");
}// end menuoptions2
// prints the main array
public static void print2Darray(String [][] MEDICINE){
for (int i = 0; i < [Link]; i++){
[Link]("Medicine #"+(i+1)+":");
for (int j = 0; j < MEDICINE[i].length; j++){
[Link](MEDICINE[i][j]+" ");
}
[Link]();
}
[Link]("\n");
}
//initializes boolean array
public static void initBoolArr(boolean[] arr){
for (int i = 0; i < [Link]; i++){
arr[i] = false;
}// end for
}//end boolean intialize
//gets a number between 1-5 from the menu
public static int getValidMenu(String msg){
int userInput = [Link](msg);
while(isInvalid(userInput)){
[Link]("Invalid value, please enter one of the menu options");
userInput = [Link](msg);
}
return userInput;
}//end getValidMenu
// makes sure first input is 1
public static boolean firstInput(int userInput){
if(userInput != 1){
return true;
}else{
return false;
}
}
//makes sure the user is entering the correct values 1-5
public static boolean isInvalid(int userInput){
if (userInput < 1){
return true;
}
if (userInput > 5){
return true;
}else{
return false;
}
}
//checks to see if the medicine prescribed is in the array
public static boolean isInArray(int userInput, boolean [] medsPrescribed){
if(medsPrescribed[userInput-1]){
return true;
}else{
return false;
}
}//end search array
//prescribes the medicine should this be a boolean?
public static void prescribe(int userInput, boolean [] medsPrescribed){
if(isInArray(userInput, medsPrescribed)){
[Link](MEDICINE[userInput-1][0]+MEDICINE[userInput-1][1]+" -already
prescribed");
}else{
medsPrescribed[userInput-1] = true;
[Link]("You have prescribed "+MEDICINE[userInput-1]
[0]+MEDICINE[userInput-1][1]);
}
}
//search menu module. searches the menu when the user inputs
public static void searchMenu(int userInput, boolean [] medsPrescribed){
if(userInput == 2){
optionTwo(userInput, medsPrescribed);
}else{
if(userInput == 3){
userInput = optionThree(userInput);
if(([Link]("Are you sure you would like to prescribe this medicine? (enter yes or
no)"))){
prescribe(userInput, medsPrescribed);
}
}else{
if(userInput == 4){
if(([Link]("Are you sure you want to erase the precription history? (enter yes or
no)"))){
optionFour(userInput, medsPrescribed);
}
}else{
if(userInput == EXIT){
[Link](" ");
}
}
}
}
}// end searchMenu
//
//
//
//option three for entering the medicine they would like to prescribe
public static int optionThree(int userInput){
userInput = [Link]("Please enter a menu option (enter 0 to see menu)");
if(userInput == 0){
print2Darray(MEDICINE);
}
while(validMenu(userInput)){
[Link]("Enter one of the menu options please");
userInput = [Link]("Please enter a menu option (enter 0 to see menu)");
if(userInput == 0){
print2Darray(MEDICINE);
}
}
return userInput;
}// end optionThree
public static void optionTwo(int userInput, boolean [] medsPrescribed){
[Link]("************************************");
[Link]("Your Patient's Prescription History");
[Link]("************************************");
for (int i = 0; i < [Link]; i++){
[Link]("Medicine #"+(i+1)+":");
for (int j = 0; j < MEDICINE[i].length; j++){
[Link](MEDICINE[i][j]);
}
if(medsPrescribed[i]){
[Link]("-already prescribed");
}
[Link]();
}
[Link]("\n");
}
public static void optionFour(int userInput, boolean [] arr){
for (int i = 0; i < [Link]; i++){
arr[i] = false;
}// end for
[Link]("Prescription history reset!");
}//end boolean intialize
//makes sure that the user enters a number 1-14
public static boolean validMenu(int menuChoice){
if(menuChoice < 1){
return true;
}
if(menuChoice > 14){
return true;
}else{
return false;
}
}// end valid menu
}// end program