private void ReceiveLoginMessage(StaffUser userAccount) { if (userAccount.isReceptionist()) { string firstname = userAccount.getFirstname(); ViewModelLocator.Cleanup(); CurrentToolbarViewModel = ReceptionistToolbarVM; CurrentViewModel = ReceptionistVM; MessengerInstance.Send <NotificationMessage>(new NotificationMessage(firstname)); // FROM: MainVM TO: ReceptionistToolbarVM ~ sends logged in users first name. } else if (userAccount.isDoctor()) { UserID = StaffDBConverter.GetAccountIDByUsername(userAccount.getUsername()); CurrentToolbarViewModel = DoctorToolbarVM; if (PatientDBConverter.DoctorIsInAppointment(UserID)) { CurrentViewModel = DoctorAppointmentVM; MessengerInstance.Send <int>(UserID); } else { CurrentViewModel = DoctorVM; MessengerInstance.Send <int>(UserID); } } }
// Interacts with Data Layer Model to book appointment public void BookAppointment() { if (TimeslotIndex.Equals(-1)) { Alert("No timeslot selected.", "Please select a timeslot for your appointment"); return; } if (PatientDBConverter.PatientHasAppointment(patientID, SelectedDate.ToShortDateString())) { Alert("Appointment Not Booked.", "You already have a GP appointment for this day. Please speak to the receptionist for details on your appointment or select another day."); return; } string selectedTimeslot = AvaliableTimes.Rows[(int)TimeslotIndex][1].ToString(); int reservationDoctorID = int.Parse(AvaliableTimes.Rows[(int)TimeslotIndex][0].ToString()); if (string.IsNullOrWhiteSpace(Comment)) { Comment = ""; } PatientDBConverter.BookAppointment(selectedTimeslot, reservationDoctorID, patientID, true, Comment, SelectedDate.ToShortDateString()); // Sends email Success EmailConfirmation.ReservationConfirmationEmail(patientID, SelectedDate, selectedTimeslot); var dialog = new SuccessBoxViewModel("Appointment Booked.", //MOVE THIS "Appointment has been successfully booked. Please keep an eye on your emails for updates on when we can see you."); var result = _dialogService.OpenDialog(dialog); MessengerInstance.Unregister(this); MessengerInstance.Send <string>("DecideHomeView"); }
public void BookAppointment() { if (Timeslot == null) { Alert("No Avaliability.", "No appointments are avaliable today. Please book a reservation appointment to be seen on another day."); return; } int doctorID = int.Parse(Timeslot[0].ToString()); string timeslot = Timeslot[1].ToString(); if (PatientDBConverter.PatientHasAppointment(patientID)) { Alert("Appointment not booked", "You already have an appointment booked today. Please check your emails for notificaitons or speak to the receptionist."); MessengerInstance.Unregister(this); MessengerInstance.Send <string>("DecideHomeView"); return; } PatientDBConverter.BookAppointment(timeslot, doctorID, patientID, false); AppointmentLogic.ScheduleWalkInNotification(TimeSpan.Parse(timeslot), patientID); var dialog = new SuccessBoxViewModel("Appointment Booked.", //MOVE THIS "Appointment has been successfully booked. Please keep an eye on your emails for updates on when we can see you."); var result = _dialogService.OpenDialog(dialog); MessengerInstance.Unregister(this); MessengerInstance.Send <string>("DecideHomeView"); }
public static void AlmostReadyEmail(int patientID) { _dialogService = new DialogBoxService(); // Modifies email html to input date and time in email. string text = File.ReadAllText("Assets\\appointment_email.html"); text = text.Replace("InsertDate1", DateTime.Today.ToShortDateString()); text = text.Replace("HEADING", "The doctor will see you now."); text = text.Replace("MAINBODY", "We're almost ready to see you, please return to the GP within 10 minutes."); text = text.Replace("InsertDate2", ""); File.WriteAllText("appointment_email.html", text); string patientEmail = PatientDBConverter.GetEmail(patientID); try { using (StreamReader reader = File.OpenText("appointment_email.html")) { SmtpClient client = new SmtpClient("smtp.gmail.com"); MailMessage message = new MailMessage("*****@*****.**", patientEmail); message.IsBodyHtml = true; message.Body = reader.ReadToEnd(); message.Subject = "We're ready for you."; client.UseDefaultCredentials = false; client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "mitsig-applepie-lambda2000"); client.Host = "smtp.gmail.com"; client.Port = 587; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.EnableSsl = true; //await client.SendMailAsync(message); } } catch (Exception ex) { // Saves error to error log string exePath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string logPath = exePath + @"\\logs\\log.txt"; using (StreamWriter writer = new StreamWriter(logPath, true)) { writer.WriteLine("-----------------------------------------------------------------------------"); writer.WriteLine("Date : " + DateTime.Now.ToString()); writer.WriteLine(); while (ex != null) { writer.WriteLine(ex.GetType().FullName); writer.WriteLine("Message : " + ex.Message); writer.WriteLine("StackTrace : " + ex.StackTrace); ex = ex.InnerException; } } } }
private void StartAppointment() { DataTable CheckedInPatients = PatientDBConverter.GetCheckedInAppointments(); if (CheckedInPatients.Rows.Count == 0) { Alert("No avaliable appointments.", "No patients are checked in. There are no appointments avalaible to be seen."); return; } int averageDuration = AppointmentLogic.GetAverage(); int remainingShiftInMinutes = StaffDBConverter.GetRemainingShiftInMinutes(DoctorID); if (remainingShiftInMinutes < averageDuration) { if (Confirmation("Are you sure?", "There may not be enough time in your schedule to finish the next appointment. Are you sure you would like to proceed?") == "NO") { return; } } DataRow selectedAppointment = null; // check if any patients are waiting first. if (Convert.ToBoolean(CheckedInPatients.Rows[0]["isEmergency"]) == true) { selectedAppointment = CheckedInPatients.Rows[0]; } foreach (DataRow dr in CheckedInPatients.Rows) { if (selectedAppointment == null) { if (Convert.ToBoolean(dr["isReservation"]) == false) { selectedAppointment = dr; } else if (Convert.ToBoolean(dr["isReservation"]) == true && DoctorID.Equals(int.Parse(dr["AppointmentDoctorID"].ToString()))) { selectedAppointment = dr; } } else { TimeSpan selectedAppointmentTime = TimeSpan.Parse(selectedAppointment["AppointmentTime"].ToString()); TimeSpan drAppointmentTime = TimeSpan.Parse(dr["AppointmentTime"].ToString()); if (drAppointmentTime.Subtract(selectedAppointmentTime).TotalMinutes <= 10 && (Convert.ToBoolean(dr["isReservation"]) == false)) { selectedAppointment = dr; break; } } } PatientDBConverter.StartAppointment(selectedAppointment, DoctorID); MessengerInstance.Send <string>("DoctorAppointmentView"); }
private void BookAppointment() { if (RequiredNotComplete()) { return; } PatientUser patient = new PatientUser(Firstname, Middlename, Lastname, (DateTime)DOB, int.Parse(DoorNumber), Postcode); int patientID; // Verifies if patient records existing in patient DB, if multiple records are found, below situation is handelled using // appropirate dialog boxes. string verifiedExistance = VerifyPatientDetails(patient); if (verifiedExistance.Equals("NoRecord")) { return; } // If multiple records are found, user is asked to input their patient ID to uniquely identify them. // If incorrect input format is detected i.e. non-numerical, or a patient ID not corrosponding to inputted details is entered, // the user is shown an alert message and redirected to partner with a receptionist for assistance. else if (verifiedExistance.Equals("MultipleRecords")) { Alert("Multiple Records Found.", "Multple Records were found with your details. Please type in your Patient ID or speak to the receptionist for assistance with booking an appointment."); string inputtedID = PatientIDBox(); if (string.IsNullOrWhiteSpace(inputtedID) || !inputtedID.All(char.IsDigit)) { Alert("Incorrect ID.", "Patient ID must be numerical. Please speak to a receptionist."); return; } verifiedExistance = VerifyPatientDetails(patient, int.Parse(inputtedID)); if (verifiedExistance.Equals("FoundRecord")) { patientID = int.Parse(inputtedID); } else { Alert("Could Not Find record.", "Could not find record matching details under inputted ID, please speak to a receptionist for assistance."); return; } } else { patientID = PatientDBConverter.GetPatientID(patient); } if (PatientDBConverter.PatientHasAppointment(patientID)) { Alert("Appointment Found!", "An existing appointment was found. Please cancel or check-in for your existing appointment to proceed."); return; } PatientDBConverter.BookEmergencyAppointment(patientID); Success("Appointment Booked.", "Emergency appointment has been booked. Please ask patient to be seated, the next avaliable doctor will take the session."); MessengerInstance.Send <string>("ReceptionistHomeView"); }
public void SetDoctorDetails(int msg) { DoctorID = msg; ActiveAppointment = PatientDBConverter.GetDoctorActiveAppointment(DoctorID); AppointmentTime = ActiveAppointment[2].ToString(); PatientName = PatientDBConverter.GetPatientName(int.Parse(ActiveAppointment[3].ToString())); AppointmentNotes = ActiveAppointment[4].ToString(); }
public void ShowReservationView() { if (RequiredNotComplete()) { return; } PatientUser patient = new PatientUser(Firstname, Middlename, Lastname, (DateTime)DOB, int.Parse(StreetNo), Postcode); int patientID; // Verifies if patient records existing in patient DB, if multiple records are found, below situation is handelled using // appropirate dialog boxes. string verifiedExistance = VerifyPatientDetails(patient); if (verifiedExistance.Equals("NoRecord")) { return; } // If multiple records are found, user is asked to input their patient ID to uniquely identify them. // If incorrect input format is detected i.e. non-numerical, or a patient ID not corrosponding to inputted details is entered, // the user is shown an alert message and redirected to partner with a receptionist for assistance. else if (verifiedExistance.Equals("MultipleRecords")) { Alert("Multiple Records Found.", "Multple Records were found with your details. Please type in your Patient ID or speak to the receptionist for assistance with booking an appointment."); string inputtedID = PatientIDBox(); if (string.IsNullOrWhiteSpace(inputtedID) || !inputtedID.All(char.IsDigit)) { Alert("Incorrect ID.", "Patient ID must be numerical. Please speak to a receptionist."); return; } verifiedExistance = VerifyPatientDetails(patient, int.Parse(inputtedID)); if (verifiedExistance.Equals("FoundRecord")) { patientID = int.Parse(inputtedID); } else { Alert("Could Not Find record.", "Could not find record matching details under inputted ID, please speak to a receptionist for assistance."); return; } } else { patientID = PatientDBConverter.GetPatientID(patient); } PatientDBConverter.UpdateEmail(patientID, Email); // Shows the booking view after patient details & desired reservation type verified // sends patient user details as message to view AppointmentTypeView = ReservationView; IsBookingVisible = true; BookingSubviewVisible = "Visible"; PatientCaptureWidth = "0"; MessengerInstance.Send <double>(patientID); }
// Retrieves patient email and time until they need to be notified before notifying them, process triggers // PatientContactSchedular which is a script running in a seperate process/thread in the background unavaliable // to the user. Should the current session be effected, by outsourcing patient contact to another process, this will // have no reprecussions on patients waiting to be called back. public static void ExecuteSchedular(int patientID, double minutes) { string email = PatientDBConverter.GetEmail(patientID); ProcessStartInfo processInf = new ProcessStartInfo("netcoreapp3.1\\PatientContactSchedular.exe"); processInf.Arguments = string.Format(email + " " + minutes); processInf.WindowStyle = ProcessWindowStyle.Hidden; Process run = Process.Start(processInf); }
private void CheckInPatient() { if (SelectedIndex == null) //shouldnt be able to happen but to prevent crash --> return. { return; } int index = int.Parse(SelectedIndex.ToString(), System.Globalization.CultureInfo.InvariantCulture); int appointmentID = int.Parse(FilteredAppointments.Rows[index][0].ToString(), System.Globalization.CultureInfo.InvariantCulture); PatientDBConverter.CheckInPatient(appointmentID); Success("Success!", "Patient has been checked-in."); InitialiseDataTable(); // To refresh table after adjustments --> triggering onpropertychange }
public void SaveToDB() { // Validation applies before changes are executted to Data Layer if (!EntryValidation()) { return; } PatientDBConverter.SaveChanges(Patients); // Refreshes DataGrid view UpdateDB(); Success("Database Updated.", "Changes to the database were successfully updated."); }
public DeletePatientViewModel() { _dialogService = new DialogBoxService(); Patients = PatientDBConverter.GetPatients(); Messenger.Default.Register <NotificationMessage>( this, message => { UpdateDB(); } ); DeleteCommand = new RelayCommand(DeleteFromDB); }
private void CheckIn() { if (RequiredNotComplete()) { Alert("Complete Required Fields!", "Please complete all fields to check in."); return; } DataTable patientRecords = PatientDBConverter.GetAwaitingCheckIn((DateTime)DOB, Firstname, DoorNo, Postcode); if (patientRecords.Rows.Count > 1) { Alert("Could not check in!", "More than one patient has an appointment with the same details provided. Please enter you patient ID or ask a recpetionist" + " for assistance with check-in."); string input = PatientIDBox(); if (string.IsNullOrWhiteSpace(input) || !input.All(char.IsDigit)) { Alert("Incorrect ID.", "Patient ID must be numerical. Please speak to a receptionist."); return; } DataRow[] foundPatient = patientRecords.Select("PatientID = '" + input + "'"); if (foundPatient.Length != 0) { foreach (DataRow row in foundPatient) { int appointmentID = int.Parse(row["AppointmentID"].ToString()); PatientDBConverter.CheckInPatient(appointmentID); } } else { Alert("Could not check in!", "Incorrect Patient ID has been inputted. Please speak to the receptions for assitance with check-in."); return; } } else if (patientRecords.Rows.Count == 0) { Alert("Could not check in!", "Unable to find appointment with details provided. Please confirm details or speak to receptionist. " + "If you are late another appointment may be required."); return; } else { int appointmentID = int.Parse(patientRecords.Rows[0][0].ToString()); PatientDBConverter.CheckInPatient(appointmentID); } Success("Checked-In Successfully", "Please take a seat. Your doctor will see you soon."); ShowHome(); }
public void DeleteFromDB() { // If no row was selected if (SelectedRow == null) { Alert("No Row Selected!", "No record selected. Please select a record before attempting to delete a patient record."); return; } int patientID = int.Parse(Patients.Rows[(int)SelectedRow][0].ToString(), System.Globalization.CultureInfo.InvariantCulture); PatientDBConverter.DeleteRecord(patientID); // Refreshes DataGrid view, Resets selected row to null SelectedRow = null; Success("Database Updated.", "Changes to the database were successfully updated."); UpdateDB(); }
public void InitialiseDataTable() { if (CancelledFilter == "True") { AllAppointments = PatientDBConverter.GetCancelledAppointments().Copy(); CancellationVisibility = Visibility.Visible; EditOptionsVisibility = Visibility.Collapsed; } else { AllAppointments = PatientDBConverter.GetBookedAppointments().Copy(); CancellationVisibility = Visibility.Collapsed; EditOptionsVisibility = Visibility.Visible; } FilteredAppointments = AllAppointments.Copy(); }
private void CancelAppointment() { if (SelectedIndex == null) //shouldnt be able to happen but to prevent crash --> return. { return; } int index = int.Parse(SelectedIndex.ToString(), System.Globalization.CultureInfo.InvariantCulture); int appointmentID = int.Parse(FilteredAppointments.Rows[index][0].ToString(), System.Globalization.CultureInfo.InvariantCulture); string reason = CancellationReason("Reason For Appointment Cancellation?"); if (reason == "") // If user closes dialog box, operation is cancelled and appointment remains active { return; } PatientDBConverter.DeleteAppointment(appointmentID, reason); // Appointment Moved To Cancelled Schema Success("Success!", "Patient appointment has been cancelled."); InitialiseDataTable(); // To refresh table after adjustments --> triggering onpropertychange }
private void UpdateDB() { Patients = PatientDBConverter.GetPatients(); }
public static void WalkInConfirmationEmail(int patientID) { _dialogService = new DialogBoxService(); // Modifies email html to input date and time in email. string text = File.ReadAllText("Assets\\appointment_email.html"); text = text.Replace("InsertDate1", DateTime.Today.ToShortDateString()); text = text.Replace("HEADING", "Your appointment has been booked."); text = text.Replace("MAINBODY", "Please keep an eye on your emails for updates on your wait. Should you wish to alter or cancel your appointment please contact the GP."); text = text.Replace("InsertDate2", ""); File.WriteAllText("appointment_email.html", text); string patientEmail = PatientDBConverter.GetEmail(patientID); try { using (StreamReader reader = File.OpenText("appointment_email.html")) { SmtpClient client = new SmtpClient("smtp.gmail.com"); MailMessage message = new MailMessage("*****@*****.**", patientEmail); message.IsBodyHtml = true; message.Body = reader.ReadToEnd(); message.Subject = "Your Upcoming GP Appointment."; client.UseDefaultCredentials = false; client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "mitsig-applepie-lambda2000"); client.Host = "smtp.gmail.com"; client.Port = 587; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.EnableSsl = true; //await client.SendMailAsync(message); } File.Delete("appointment_email.html"); } catch (Exception ex) { // Saves error to error log string exePath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string logPath = exePath + @"\\logs\\log.txt"; using (StreamWriter writer = new StreamWriter(logPath, true)) { writer.WriteLine("-----------------------------------------------------------------------------"); writer.WriteLine("Date : " + DateTime.Now.ToString()); writer.WriteLine(); while (ex != null) { writer.WriteLine(ex.GetType().FullName); writer.WriteLine("Message : " + ex.Message); writer.WriteLine("StackTrace : " + ex.StackTrace); ex = ex.InnerException; } } } }
public void InitialiseDataTable() { AllAppointments = PatientDBConverter.GetCheckedInAppointments(); FilteredAppointments = AllAppointments.Copy(); }