/** * Prints all staff */ public static void printAllStaff() { List <Staff> staff = DataSearching.getStaff(); DentistNurse practitioner; try { for (int i = 0; i < staff.Count; i++) { Console.Write($"{staff[i].getUsername()}: {staff[i].getName()} - "); if (staff[i] is Receptionist) { Console.WriteLine("Receptionist"); } else { practitioner = (DentistNurse)staff[i]; Console.WriteLine(practitioner.getPractitionerType()); } } } catch (Exception e) { GeneralFunctions.errorHandler(e); } }
/** * Prints staff at a given Practice. */ public static void printStaffAtPractice(DentalPractice practice) { List <Staff> staff = DataSearching.getStaff(); List <Staff> staffAtPractice = new List <Staff>(); DentistNurse denNurseToPrint; try { staffAtPractice = staff.FindAll(staffMem => (staffMem.getPractice() is DentalPractice) && (staffMem.getPractice().Equals(practice))); //Returns a list of all staff with the given location. Console.WriteLine("Staff at {0}:", practice.getLocation()); for (int i = 0; i < staffAtPractice.Count; i++) { Console.Write("{0}: {1} - ", staffAtPractice[i].getUsername(), staffAtPractice[i].getName()); //Printing role if (staffAtPractice[i] is Receptionist) { Console.WriteLine("Receptionist"); } else { denNurseToPrint = (DentistNurse)staffAtPractice[i]; //Shortened version to select practioner type & write it Console.WriteLine(denNurseToPrint.getPractitionerType()); } ; } } catch (Exception e) { GeneralFunctions.errorHandler(e); } }
/** * Prints all staff */ public static void printAllStaff() { List <Staff> staff = DataSearching.getStaff(); //Return a list the user objects that are staff DentistNurse dentistNurse; try { for (int i = 0; i < staff.Count; i++) { Console.WriteLine(staff[i].getUsername()); for (int locLen = 0; locLen < staff[i].getUsername().Length; locLen++) //Underlines the ussername with "=" { Console.Write("="); } Console.WriteLine("\nName: {0}", staff[i].getName()); //writes staff name if (staff[i].getPractice() is DentalPractice) { Console.WriteLine("Practice: : {0}", staff[i].getPractice().getLocation()); //gets practice info and writes its location } Console.Write("Role: ");//writes staff role depenedant on prationer type if (staff[i] is Receptionist) { Console.WriteLine("Receptionist"); } else { dentistNurse = (DentistNurse)staff[i]; if (dentistNurse.getPractitionerType() == "Dentist") //if equal to dentist write this otherwise it will be nurse { Console.WriteLine("Dentist"); } else { Console.WriteLine("Nurse"); } } Console.WriteLine(); } } catch (Exception e) { GeneralFunctions.errorHandler(e); } }
/** * Loads notes for an appointment. */ private static void loadAppointmentNotes(Appointment appt) { string notesPath = $"{patientPath}\\{appt.getPatient().getId()}\\Appointments\\{appt.getId()}\\Notes"; //Gets the file path to the folder containing the given appointments notes. StreamReader apptmtNoteFile; string[] noteFiles; string username; DentistNurse author; string date; string time; string content; try { if (!Directory.Exists(notesPath)) { Directory.CreateDirectory(notesPath); //finds if not creates } noteFiles = Directory.GetFiles(notesPath); for (int i = 0; i < noteFiles.Length; i++) { apptmtNoteFile = new StreamReader(noteFiles[i]); //Opens a note file username = apptmtNoteFile.ReadLine(); //first line will be the username of the author. if (DataSearching.userExists(username)) { author = (DentistNurse)DataSearching.findUser(username); } else { author = new DentistNurse(username, "", "Unknown user", "", ""); } date = apptmtNoteFile.ReadLine(); //second line will be the date time = apptmtNoteFile.ReadLine(); //third the time content = apptmtNoteFile.ReadToEnd(); // Content will be the rest of the file. this allows for line breaks (not that the input will). apptmtNoteFile.Close(); appt.getNotes().Add(new AppointmentNote(date, time, appt, author, content)); } } catch (Exception e) { GeneralFunctions.errorHandler(e); } }
/** * Loads patients from file. */ public static void loadPatients() { DentalPractice practiceToAddTo; StreamReader patientFile; string[] patientDirectories; Patient patientToAdd; string id; string name; string location; int gender; string address; string contactNo; try { if (!Directory.Exists(patientPath)) //if exists do nothing if not create the directory { Directory.CreateDirectory(patientPath); } patientDirectories = Directory.GetDirectories(patientPath); for (int i = 0; i < patientDirectories.Length; i++) { patientFile = new StreamReader(patientDirectories[i] + "\\info.txt"); id = patientFile.ReadLine(); //First line of patient file will be ID. name = patientFile.ReadLine(); //Second will be name. location = patientFile.ReadLine(); //third will be name of practice. int.TryParse(patientFile.ReadLine(), out gender); //fourth will be gender. this needs converting from string to int. address = patientFile.ReadLine(); //fifth will be address. contactNo = patientFile.ReadLine(); //Sixth will be contact number. patientFile.Close(); if (DataSearching.practiceExists(location)) //Should always be the case. just a little extra error trapping. { practiceToAddTo = DataSearching.findPractice(location); //References the DentalPractice with the given location. patientToAdd = new Patient(id, name, practiceToAddTo, gender, address, contactNo); //Creates a Patient object to hold information about the new patient. practiceToAddTo.getPatients().Add(patientToAdd); //Adds the patient to the practice. loadAppointments(patientToAdd); //loads the patients appointments. } } } catch (Exception e) { GeneralFunctions.errorHandler(e); } }
public static void printPractitionerAppointments(DentistNurse practitioner) { List <Appointment> appointments = DataSearching.getPractitionerAppointments(practitioner); try { for (int i = 0; i < appointments.Count; i++) //iterates appointments { Console.WriteLine($"{appointments[i].getId()} - {appointments[i].getPatient().getName()}: {appointments[i].getDate()} {appointments[i].getTime()}"); //displays apmnt ID, patient name and date and time. } } catch (Exception e) { GeneralFunctions.errorHandler(e); } }
/** * Prints all appointments at a location for the current day. */ public static void printDailyLocationAppointments(DentalPractice location) { List <Appointment> appointments = DataSearching.getDailyLocationAppointments(location); //gets the list of appointments for the given location try { for (int i = 0; i < appointments.Count; i++) //iterate over the the appointments { Console.WriteLine($"{appointments[i].getId()}: {appointments[i].getPatient().getName()} - Room {appointments[i].getRoom().getRoomNumber()} {appointments[i].getTime()}"); //prints appointments out ID, patient, name, Room no. and time } } catch (Exception e) { GeneralFunctions.errorHandler(e); } }
/** * Prints all appointments for a practitioner on the current day. */ public static void printDailyPractitionerAppointments(DentistNurse practitioner) { List <Appointment> appointments = DataSearching.getDailyPractitionerAppointments(practitioner); //gets the list of daily appointments for the given practioner try { for (int i = 0; i < appointments.Count; i++) //iterates over the appointmens { Console.WriteLine($"{appointments[i].getId()}: {appointments[i].getPatient().getName()} - {appointments[i].getTime()}"); //Prints them out in format: ID, Patient And naem + time } } catch (Exception e) { GeneralFunctions.errorHandler(e); } }
/** * prints all receptionists */ public static void printReceptionists() { List <Receptionist> receptionists = DataSearching.getReceptionists(); try { for (int i = 0; i < receptionists.Count; i++) { if (receptionists[i].getPractice() is DentalPractice) { Console.WriteLine("{0}: {1} - {2}", receptionists[i].getUsername(), receptionists[i].getName(), receptionists[i].getPractice().getLocation());//if assigned write this } else { Console.WriteLine("{0}: {1}", receptionists[i].getUsername(), receptionists[i].getName()); //if unassigned this is what is written } } } catch (Exception e) { GeneralFunctions.errorHandler(e); } }