private void RemoveAppointment(int key) { Appointment appointment = _appointmentLookup[key]; Appointment emptyAppointment; int doctorColumn = 0; string colour; for (int i = 0; i < DoctorsOnShiftCount; i++) { if (DoctorsOnShift.ElementAt(i).DoctorName.Equals(appointment.DoctorName)) { doctorColumn = i; } } colour = DoctorsOnShift.ElementAt(doctorColumn).Colour; emptyAppointment = new Appointment() { DateTime = DateTime.Today, Type = "", Height = "35", Margin = "0,1,0,0", Patient = "", Colour = colour, Cursor = "Hand", RowSpan = "1", Opacity = "0" }; InsertAppointment(doctorColumn, emptyAppointment); }
public int FindDrColumnForDrName(string name) { for (int i = 0; i < DoctorsOnShiftCount; i++) { if (DoctorsOnShift.ElementAt(i).DoctorName.Equals(name)) { return(i); } } return(-1); }
public int FindDrColumnForAppointment(Appointment appointment) { for (int i = 0; i < DoctorsOnShiftCount; i++) { if (DoctorsOnShift.ElementAt(i).DoctorName.Equals(appointment.DoctorName)) { return(i); } } return(-1); }
// All appointments - even empty - are stored in the mock database. // Since empty appointments also have a unique key, you need to construct that key to use this function. // The key for an appt on December 01, 2017 @ 14:45:00 with Dr. Specter is constructed as follows: // - set the appointment's DateTime property. // newAppt.DateTime = new DateTime(2017, 12, 01, 14, 45, 0); // - get the hash code of the DateTime property. // hashCode = newAppt.DateTime.GetHashCode(); // - add the doctor column corresponding to Dr. Specter (which is 1) to the hash code. This value can be obtained // using the function in this class with signature "public int FindDrColumnForDrName(string name)", // or by manually entering the value -- Dr. Pearson = 0 Dr. Specter = 1 Dr. Paulsen = 2. // - Example using function. // DayInformationViewModel DIVM = this.DataContext as DayInformationViewModel; // hashCode = hashCode + DIVM.AVM.FindDrColumnForDrName("Dr. Specter"); // - Example using hardcoded value. // hashCode = hashCode + 1; -- This may not be possible depending on how the view is set up. // -- One possible way could be to make sure the Dr. Combo Box in the // new appt sidebar an ordering coinciding with the Dr columns. // Then when the appt is created add the value of DrComboBox.SelectedIndex // to the hash code. // - Set the values of the appointment. // - Use this function with "hashCode" as the key and "newAppt" as the appointment. // - See the "Appointment" class for some comments on creating a new appointment since there are a ton of fields. // and not all of them are necessary, some are not accessible, and some are crucial. // // The appointment is the appointment you would like to place in that slot. // If the appointment is a standard appointment and the slot is not empty, it returns false and does not effect the database. // If the appointment is a consultation and two contiguous slots are not empty, it returns false and does not effect the database. public bool AddAppointment(Appointment appointment, int key) { if (!(_appointmentLookup[key].Type != "")) { Console.WriteLine("Appointment Slot Not Empty, type is: " + _appointmentLookup[key].Type); return(false); } if (appointment.Type == "Consultation") { Appointment apptThatFollows = FindAppointmentThatFollows(appointment); if (apptThatFollows.Type != "") { Console.WriteLine("Consultations require 30 mins, only 15 available from appointment start time."); return(false); } } _appointmentLookup[key] = appointment; int doctorColumn = 0; for (int i = 0; i < DoctorsOnShiftCount; i++) { if (DoctorsOnShift.ElementAt(i).DoctorName.Equals(appointment.DoctorName)) { doctorColumn = i; } } InsertAppointment(doctorColumn, appointment); return(true); }
private void PopulateAppointmentDatabase(int startTime) { DateTime date; List <Appointment>[] listOfAppointmentsArray; List <Appointment> listOfAppointments; int hashCode; int time; string bindingCode = ""; for (int i = 0; i < DoctorsOnShiftCount; i++) { listOfAppointmentsArray = _appointmentDictionary[i]; for (int j = 0; j < _numDaysPopulated; j++) { listOfAppointments = listOfAppointmentsArray[j]; date = _beginningOfAllTime.AddDays(j); time = startTime; for (int k = 0; k < listOfAppointments.Count; k++) { listOfAppointments[k].StartTime = time; listOfAppointments[k].DateTime = new DateTime(date.Year, date.Month, date.Day, time / 100, time % 100, 0); hashCode = listOfAppointments[k].DateTime.GetHashCode(); time += 15; if (time % 100 >= 60) { time += 40; } if (listOfAppointments[k].Type.Equals("Consultation")) { int bigTime = time + 15; if (bigTime % 100 >= 60) { bigTime += 40; } listOfAppointments[k].EndTime = bigTime; } else { listOfAppointments[k].EndTime = time; } listOfAppointments[k].ID = (hashCode + i).ToString(); int st = listOfAppointments[k].StartTime; int end = listOfAppointments[k].EndTime; Doctor d = DoctorsOnShift.ElementAt(i); if (st < d.ShiftStart || end > d.ShiftEnd) { listOfAppointments[k].IsClickable = "false"; listOfAppointments[k].Colour = "SlateGray"; listOfAppointments[k].Opacity = "0.5"; } else { listOfAppointments[k].IsClickable = "true"; } _appointmentLookup.Add(hashCode + i, listOfAppointments[k]); } bindingCode = (i + 1).ToString() + date.Day.ToString() + date.Month.ToString() + date.Year.ToString(); _drScheduleMap.Add(Int32.Parse(bindingCode), listOfAppointments); Console.WriteLine("Binding Code in dictionary: " + bindingCode); } } }