示例#1
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Welcome to Front Line Hospital!!");
            Console.WriteLine();
            loginSystem login = new loginSystem();

            login.loginUser();

            patientInfo p = new patientInfo();

            p.patient_info();

            Departments d = new Departments();

            d.displayDepartment();
        }
示例#2
0
        public void patient_info()
        {
            //Create Patient and contact  objects
            Patient         patient    = new Patient();
            Contact         contact    = new Contact();
            ResidentPatient inpatient  = new ResidentPatient();
            OutPatient      outpatient = new OutPatient();

            Console.Write("Welcome to Front Line Hospital!\n");

            //Loop over the app
            while (true)
            {
                Console.Write("Enter data about a patient\n");

                //Prompt for patient type and get user input
                do
                {
                    Console.Write("Patient type: O(ut), R(esident)?: ");
                    patient.PatientType = Console.ReadLine();

                    //check if empty field given
                    if (string.IsNullOrEmpty(patient.PatientType))
                    {
                        Console.WriteLine("Patient Type is empty!");
                    }
                    //check if a valid symbol/word is given
                    else if (patient.PatientType.ToLower() != "o" &&
                             patient.PatientType.ToLower() != "out" && patient.PatientType.ToLower() != "resident" &&
                             patient.PatientType.ToLower() != "r")
                    {
                        Console.WriteLine("Enter a valid patient type!");
                    }
                    else
                    {
                        break;
                    }
                } while (true);

                do
                {
                    //Prompt and obtain user input
                    //get first name
                    Console.Write("First Name: ");
                    patient.FirstName = Console.ReadLine();

                    //check if user entered empty string as Firstname
                    if (string.IsNullOrEmpty(patient.FirstName))
                    {
                        Console.WriteLine("First Name is empty!");
                    }
                    //Check if name consists of letters only
                    else if (!patient.FirstName.ToLower().All(char.IsLetter))
                    {
                        Console.WriteLine("First name must consist of letters only!");
                    }
                    else
                    {
                        //end do while Loop
                        break;
                    }

                    //Ask the user to repeatedly enter the value until a valid value has been entered
                } while (true);
                do
                {
                    //Prompt and obtain user input
                    //get last name
                    Console.Write("Last Name: ");
                    patient.LastName = Console.ReadLine();

                    //check if user entered empty string as lastname
                    if (string.IsNullOrEmpty(patient.LastName))
                    {
                        Console.WriteLine("Last Name is empty!");
                    }
                    //Check if name consists of letters only
                    else if (!patient.LastName.ToLower().All(char.IsLetter))
                    {
                        Console.WriteLine("Last name must consist of letters only!");
                    }
                    else
                    {
                        //end do while Loop
                        break;
                    }

                    //Ask the user to repeatedly enter the value until a valid value has been entered
                } while (true);
                do
                {
                    //Prompt and obtain user input
                    //get Gender
                    Console.Write("Gender (M/F): ");
                    // set input string to uppercase
                    patient.Gender = Console.ReadLine().ToUpper();

                    //validate gender field empty
                    if (String.IsNullOrEmpty(patient.Gender))
                    {
                        Console.WriteLine("Gender field is Empty!");
                    }
                    //validate if gender is male or female
                    else if (patient.Gender.ToUpper() != "M" && patient.Gender.ToUpper() != "F")
                    {
                        Console.WriteLine("Gender must be M or F!");
                    }
                    else
                    {
                        //end do while Loop
                        break;
                    }

                    //Ask the user to repeatedly enter the value until a valid value has been entered
                } while (true);
                do
                {
                    //Prompt and obtain user input
                    //get Married status
                    Console.Write("Married? (Y/N): ");

                    // set input string to uppercase
                    patient.Married = Console.ReadLine().ToUpper();

                    //validate input if empty
                    if (String.IsNullOrEmpty(patient.Married))
                    {
                        Console.WriteLine("Married field is Empty!");
                    }
                    //check if input is Yes or No
                    else if (patient.Married.ToUpper() != "Y" && patient.Married.ToUpper() != "N")
                    {
                        Console.WriteLine("Marriage status must be Y or N!");
                    }
                    else
                    {
                        //end do while Loop
                        break;
                    }

                    //Ask the user to repeatedly enter the value until a valid value has been entered
                } while (true);
                do
                {
                    //Prompt and obtain user input
                    //get Date of Birth
                    Console.Write("Date of Birth: (dd/mm/yyyy): ");
                    patient.BirthDate = Console.ReadLine();

                    //validate date input if empty and if satisfies formatting conditions
                    if (!string.IsNullOrEmpty(patient.BirthDate) && DateCheck(patient.BirthDate))
                    {
                        //end loop
                        break;
                    }

                    //Ask the user to repeatedly enter the value until a valid value has been entered
                } while (true);

                do
                {
                    //Prompt user to enter input
                    //For their street address
                    Console.Write("Street Address: ");

                    patient.StreetAddress = Console.ReadLine();

                    //validate if the input field is empty
                    if (!string.IsNullOrEmpty(patient.StreetAddress))
                    {
                        //end do while Loop
                        break;
                    }

                    //Ask the user to repeatedly enter the value until a valid value has been entered
                } while (true);
                do
                {
                    //Prompt and obtain user input
                    //get City
                    Console.Write("City: ");

                    patient.City = Console.ReadLine();

                    //validate if the entered value field is empty
                    if (string.IsNullOrEmpty(patient.City))
                    {
                        Console.WriteLine("City Field is empty!");
                    }
                    //validate if the city name atleast has a string character
                    else if (patient.City.All(char.IsNumber))
                    {
                        Console.WriteLine("Enter a valid city name!");
                    }
                    else
                    {
                        //end do while Loop
                        break;
                    }

                    //Ask the user to repeatedly enter the value until a valid value has been entered
                } while (true);
                do
                {
                    //Prompt and obtain user input
                    //get State
                    Console.Write("State: ");
                    patient.State = Console.ReadLine();

                    //Check if the field is empty
                    if (string.IsNullOrEmpty(patient.State))
                    {
                        Console.WriteLine("State field is empty!");
                    }

                    //An array containing all 50 states in the U.S
                    string[] UsStates =
                    {
                        "Delhi", "Karnataka", "Kerala", "Tamil Nadu", "Mumbai", "Goa", "Punjab", "Kolkata", "Andhra pradesh", "Orissa", "Gujarat", "Jammu & Kashmir", "J&K",
                        "Bihar", "Assam",     "Andhra"
                    };

                    //Boolean variable to mark a user entry as a valid state or not
                    bool isValidState = false;

                    //Loop through all possible states checking if a given city is valid
                    for (int i = 0; i < UsStates.Length; i++)
                    {
                        if (patient.State.ToString().ToUpper() != UsStates[i].ToUpper())
                        {
                            isValidState = false;
                        }
                        else
                        {
                            //If the user input is a valid state, mark state as valid and break out of the for loop
                            isValidState = true;
                            break;
                        }
                    }

                    //If the user input is a valid state, break out of the do-while loop
                    if (isValidState)
                    {
                        break;
                    }
                    else
                    {
                        //If the user input is a invalid state, give error message and continue executing the do-while loop
                        Console.WriteLine(patient.State + " is not an Indian state");
                        continue;
                    }

                    //Ask the user to repeatedly enter the value until a valid value has been entered
                } while (true);
                do
                {
                    //Prompt and obtain user input
                    //get Zip code
                    Console.Write("Zip: ");
                    patient.Zip = Console.ReadLine();

                    //validate if input field is empty
                    if (string.IsNullOrEmpty(patient.Zip))
                    {
                        Console.WriteLine("Zip field is empty!");
                    }
                    //check if the code contains only number characters
                    else if (!patient.Zip.All(char.IsNumber))
                    {
                        Console.WriteLine("Zip code must be a number!");
                    }
                    //Validate the length of the zip code to 5 digits only
                    else if (patient.Zip.Length != 6)
                    {
                        Console.WriteLine("Zip should consist of 6 digits");
                    }
                    else
                    {
                        //end do while Loop
                        break;
                    }

                    //Ask the user to repeatedly enter the value until a valid value has been entered
                } while (true);
                do
                {
                    //Prompt and obtain user input
                    //get Home phone
                    Console.Write("Home Phone: ");
                    contact.HomeNumber = Console.ReadLine();

                    //call function to validate number
                    bool validNumber = checkPhoneNumber(contact.HomeNumber);
                    //if valid, break out of the do-while loop else, keep looping
                    if (validNumber)
                    {
                        break;
                    }
                    else
                    {
                        continue;
                    }

                    //Ask the user to repeatedly enter the value until a valid value has been entered
                } while (true);
                do
                {
                    //Prompt and obtain user input
                    //get Mobile number
                    Console.Write("Mobile Phone: ");
                    contact.MobileNumber = Console.ReadLine();

                    //Call function to validate entered number
                    bool validNumber = checkPhoneNumber(contact.MobileNumber);

                    //if valid, break out of loop
                    if (validNumber)
                    {
                        break;
                    }
                    else
                    {
                        continue;
                    }

                    //Ask the user to repeatedly enter the value until a valid value has been entered
                } while (true);

                //Boolean variable to track if a patient is a resident or out patient
                bool patientresident = false;

                //Check if the entered value is "out" or "o"
                if (patient.PatientType.ToLower() == "out" || patient.PatientType.ToLower() == "o")
                {
                    //Set current patient to non-resident
                    patientresident = false;
                    do
                    {
                        //Get user input on contact information
                        //Input contact first name
                        Console.Write("Contact First Name: ");
                        outpatient.ContactFirstName = Console.ReadLine();

                        //Check if name field empty
                        if (string.IsNullOrEmpty(outpatient.ContactFirstName))
                        {
                            Console.WriteLine("Contact First Name is empty!");
                        }
                        //Check if name consists of letters only
                        else if (!outpatient.ContactFirstName.ToLower().All(char.IsLetter))
                        {
                            Console.WriteLine("Contact First name must consist of letters only!");
                        }
                        else
                        {
                            //end do while Loop
                            break;
                        }
                    } while (true);
                    do
                    {
                        //input last name
                        Console.Write("Contact Last Name: ");
                        outpatient.ContactLastName = Console.ReadLine();
                        //check if field empty
                        if (string.IsNullOrEmpty(outpatient.ContactLastName))
                        {
                            Console.WriteLine("Last Name is empty!");
                        }
                        //check if name consists of letters only
                        else if (!outpatient.ContactLastName.ToLower().All(char.IsLetter))
                        {
                            Console.WriteLine("Contact Last name must consist of letters only!");
                        }
                        else
                        {
                            //end do while Loop
                            break;
                        }
                    } while (true);
                    do
                    {
                        //Input contact phone number
                        Console.Write("Contact Phone: ");
                        contact.ContactPhone = Console.ReadLine();

                        //call function to validate the number
                        bool validNumber = checkPhoneNumber(contact.ContactPhone);
                        if (validNumber)
                        {
                            //end do while Loop
                            break;
                        }
                        else
                        {
                            continue;
                        }
                    } while (true);
                }

                //check if the resident type is "resident" or "r"
                if (patient.PatientType.ToLower() == "resident" || patient.PatientType.ToLower() == "r")
                {
                    //Set patient to resident
                    patientresident = true;
                    do
                    {
                        //Prompt for hospital details
                        //Input hospital name
                        Console.Write("Problem: ");
                        inpatient.ProblemName = Console.ReadLine();

                        //check if name field is empty
                        if (string.IsNullOrEmpty(inpatient.ProblemName))
                        {
                            Console.WriteLine("Problem name is empty!");
                        }
                        //check if the field only contains number characters
                        else if (inpatient.ProblemName.All(char.IsNumber))
                        {
                            Console.WriteLine("Enter a valid problem!");
                        }
                        else
                        {
                            //break out of loop if all conditions satisfied
                            break;
                        }
                    } while (true);
                }
                display_patient_info(patient, contact, inpatient, outpatient);
                do

                {
                    Console.Write("Do you want to continue (Y/N)?: ");
                    patient.check = Console.ReadLine().ToUpper();

                    // set input string to uppercase
                    //validate input if Yes or No
                    if (patient.check == "N" || patient.check == "Y")
                    {
                        //end do while Loop,  return to the main while loop
                        break;
                    }

                    //loop until a valid value has been entered
                } while (patient.check != "Y" || patient.check != "N");

                if (patient.check == "Y")
                {
                    //end user input prompt
                    return;
                }
                if (patient.check == "N")
                {
                    //end user input prompt
                    loginSystem login = new loginSystem();
                    login.loginUser();
                }
            }
        }