/// <summary> /// It Create a New Doctor Account. /// </summary> /// <returns>It return the Doctor Object</returns> public static Doctor CreateDoctor() { try { string id, name, specialization, availablity = ""; Doctor doctor = new Doctor(); bool flag; id = CreateId(); do { Console.WriteLine(); Console.Write("Enter the Name: "); name = Console.ReadLine(); flag = CliniqueManagementValidation.DoctorNameValidation(name); if (!flag) { Console.WriteLine("Please Input the Name"); } } while (!flag); do { Console.WriteLine(); Console.Write("Enter the Specialization: "); specialization = Console.ReadLine(); flag = CliniqueManagementValidation.DoctorSpecializationValidation(specialization); if (!flag) { Console.WriteLine("Please Input the Specialization"); } } while (!flag); do { Console.WriteLine(); Console.WriteLine("Choose the Availability: "); Console.WriteLine("1. At Morining, i.e Am"); Console.WriteLine("2. At Evening, i.e Pm"); Console.WriteLine("3. Both"); Console.Write("Enter Your Choice: "); flag = int.TryParse(Console.ReadLine(), out int choice); ErrorMessage(flag); if (flag) { switch (choice) { case 1: availablity = "Am"; break; case 2: availablity = "Pm"; break; case 3: availablity = "Both"; break; default: Console.WriteLine("Invalid Choice"); flag = false; break; } } } while (!flag); doctor.DoctorId = id; doctor.Name = name; doctor.Specialization = specialization; doctor.Availability = availablity; return(doctor); } catch (Exception e) { Console.WriteLine("Message: {0}", e.Message); return(null); } }
/// <summary> /// It Create a New Patient Account. /// </summary> /// <returns>It return the Object of Patient</returns> public static Patient CreatePatient() { try { string id, name, mobileNumber, Age; Patient patient = new Patient(); bool flag; id = CreateId(); do { Console.WriteLine(); Console.Write("Enter the Name: "); name = Console.ReadLine(); flag = CliniqueManagementValidation.PatientNameValidation(name); if (!flag) { Console.WriteLine("Please Input the Name"); } } while (!flag); do { Console.WriteLine(); Console.Write("Enter the Mobile Number: "); mobileNumber = Console.ReadLine(); flag = CliniqueManagementValidation.PatientMobileNumber(mobileNumber); if (!flag) { Console.WriteLine("Please Input the Mobile Number"); } } while (!flag); do { Console.WriteLine(); Console.Write("Enter Your Age: "); Age = Console.ReadLine(); flag = CliniqueManagementValidation.PatientAgeValidation(Age); if (!flag) { Console.WriteLine("Please Input the Age"); } } while (!flag); patient.PatientId = id; patient.Name = name; patient.MobileNumber = mobileNumber; patient.Age = Age; return(patient); } catch (Exception e) { Console.WriteLine("Message: {0}", e.Message); return(null); } }
/// <summary> /// It Create a New Appointment for Patient with doctor. /// </summary> /// <returns>It return the Doctor Object</returns> public static void CreateAppointment() { try { string appointmentId, appointmentDateTime; int doctorId, patientId; bool flag; List <Appointment> appointments = ReadAppointmentjsonFile(); Appointment appointment; List <PatientAppointment> patientAppointments; PatientAppointment patientAppointment; appointmentId = Guid.NewGuid().ToString(); do { Console.WriteLine(); Console.Write("Enter the Doctor Id: "); flag = int.TryParse(Console.ReadLine(), out doctorId); ErrorMessage(flag); } while (!flag); do { Console.WriteLine(); Console.Write("Enter the Patient Id: "); flag = int.TryParse(Console.ReadLine(), out patientId); ErrorMessage(flag); } while (!flag); do { Console.WriteLine(); Console.Write("Enter the Date for Appointment [dd/MM/yyyy]: "); appointmentDateTime = Console.ReadLine(); flag = CliniqueManagementValidation.PatientAppointmentValidation(appointmentDateTime); if (!flag) { Console.WriteLine("Please Input the Proper Time"); } else { if (appointments.Count != 0) { foreach (Appointment appointment1 in appointments) { if (appointment1.DoctorId.Equals(doctorId.ToString()) && appointment1.AppointmentDateAndTime.Equals(appointmentDateTime.ToString())) { if (appointment1.GetPatientAppointments.Count == 5) { Console.WriteLine("This Day Slot is full, Please Choose Different Day to Book an Appointment."); flag = false; break; } } } } } } while (!flag); if (appointments.Count != 0) { foreach (Appointment appointment1 in appointments) { if (appointment1.DoctorId.Equals(doctorId.ToString()) && appointment1.AppointmentDateAndTime.Equals(appointmentDateTime.ToString())) { patientAppointments = appointment1.GetPatientAppointments; patientAppointment = new PatientAppointment { AppointmentId = appointmentId, PatientId = patientId.ToString() }; patientAppointments.Add(patientAppointment); appointment1.GetPatientAppointments = patientAppointments; UpdateAppointmentToJson(appointments); return; } } } appointment = new Appointment { DoctorId = doctorId.ToString(), AppointmentDateAndTime = appointmentDateTime }; patientAppointments = new List <PatientAppointment>(); patientAppointment = new PatientAppointment { AppointmentId = appointmentId, PatientId = patientId.ToString() }; patientAppointments.Add(patientAppointment); appointment.GetPatientAppointments = patientAppointments; appointments.Add(appointment); UpdateAppointmentToJson(appointments); } catch (Exception e) { Console.WriteLine("Message: {0}", e.Message); } }