private void ConfirmButton_Click(object sender, RoutedEventArgs e) { if (!UInt64.TryParse(AppointmentDuration.Text, out var res)) { MessageBox.Show("Trajanje mora biti pozitivna celobrojna vrednost", "Nevalidan unos", MessageBoxButton.OK); return; } Patient patient = (Patient)PatientComboBox.SelectedItem; global::Doctor doctor = (global::Doctor)DoctorComboBox.SelectedItem; Room room = (Room)RoomComboBox.SelectedItem; String selectedTime = AppointmentTime.SelectedItem.ToString(); String selectedDate = DatePicker.Text; DateTime selectedDateTime = DateTime.Parse(selectedDate + " " + selectedTime); AppointmentType appointmentType = (AppointmentType)AppointmentTypeComboBox.SelectedIndex; int duration = int.Parse(AppointmentDuration.Text); if (patient.IsAvailable(selectedDateTime, selectedDateTime.AddMinutes(duration))) { Appointment appointment = new Appointment(_selectedAppointment.AppointmentID, selectedDateTime, duration, appointmentType, AppointmentStatus.scheduled, patient, doctor, room); if (selectedDateTime < DateTime.Now) { MessageBox.Show("Nije moguće zakazati pregled u prošlosti", "Greška u zakazivanju", MessageBoxButton.OK); return; } _appointmentController.Update(appointment); _confirmed = true; this.Close(); } else { MessageBox.Show("Pacijentu ne odgovara ovako dugo trajanje, preklapa se sa drugim obavezama", "Patient zauzet", MessageBoxButton.OK); } }
private void submitButton_Click(object sender, RoutedEventArgs e) { global::Doctor l = (global::Doctor)lekar.SelectedItem; Patient p = parent.Patient; if (time.SelectedIndex != -1) { var item = time.SelectedItem; String t = item.ToString(); String d = date.Text; DateTime dt = DateTime.Parse(d + " " + t); AppointmentType tt = AppointmentType.generalPractitionerCheckup; DateTime start; DateTime end; CalculateStartAndEnd(out start, out end); Room prvaDostupnaProstorija = GetAvailableRoom(start, end); Appointment appointment = new Appointment(selektovan.AppointmentID, dt, trajanjePregleda, tt, AppointmentStatus.scheduled, p, l, prvaDostupnaProstorija); _appointmentController.Update(appointment); PatientExaminesAppointmentPage ptp = new PatientExaminesAppointmentPage(parent); updateVisibility(); parent.startWindow.Content = ptp; ptp.updateTable(); ActivityLog activity = new ActivityLog(DateTime.Now, parent.Patient.Username, TypeOfActivity.editingAppointment); _activityLogController.AddActivity(activity); } }
public bool CreateNewUrgentAppointment(Patient patient, int duration, DoctorType doctorType, RoomType roomType, AppointmentType appointmentType, DateTime appointmentStart, DateTime appointmentEnd) { List <Room> availableRooms = _roomService.GetAvailableRoomList(appointmentStart, appointmentEnd); List <Doctor> availableDoctors = _doctorService.GetAvailableDoctorList(appointmentStart, appointmentEnd); List <Room> filteredRooms = _roomService.GetFilteredRooms(availableRooms, appointmentType); List <Doctor> filteredDoctors = _doctorService.GetFilteredDoctors(availableDoctors, doctorType); if (filteredRooms.Count > 0 && filteredDoctors.Count > 0) { foreach (Appointment appointmentItem in _appointmentService.GetAll()) { if (appointmentItem.AppointmentStatus == AppointmentStatus.scheduled && appointmentItem.Patient.Equals(patient) && (appointmentItem.AppointmentDate >= appointmentStart && appointmentItem.AppointmentDate <= appointmentEnd)) { _appointmentService.Remove(appointmentItem); } } Room room = filteredRooms[0]; global::Doctor doctor = filteredDoctors[0]; int id = _appointmentService.GetAll().Count + 1; Appointment appointment = new Appointment(id, appointmentStart, duration, appointmentType, AppointmentStatus.scheduled, patient, doctor, room); _appointmentService.Add(appointment); return(true); } return(false); }
private void pretraziTermine() { times.Items.Clear(); availableTimes.Clear(); termini.Clear(); global::Doctor selektovanLjekar = (global::Doctor)ljekari.SelectedItem; foreach (Appointment t in _appointmentController.GetAll()) { if (t.Doctor.JMBG.Equals(selektovanLjekar.JMBG)) { if (t.AppointmentDate.Date.Equals(date.SelectedDate) && t.AppointmentStatus == AppointmentStatus.scheduled) { termini.Add(t); } } if (parent.Patient.Username == t.Patient.Username && t.AppointmentDate.Date.Equals(date.SelectedDate)) { if (t.AppointmentStatus == AppointmentStatus.scheduled) { termini.Add(t); } } } List <Appointment> terminiBezDuplikata = termini.Distinct().ToList(); DateTime danas = DateTime.Today; for (DateTime tm = danas.AddHours(8); tm < danas.AddHours(20); tm = tm.AddMinutes(15)) { bool slobodno = true; foreach (Appointment termin in terminiBezDuplikata) { DateTime start = DateTime.Parse(termin.AppointmentDate.ToString("HH:mm")); DateTime end = DateTime.Parse(termin.AppointmentDate.AddMinutes(termin.DurationInMinutes).ToString("HH:mm")); if (tm >= start && tm < end) { slobodno = false; } } if (slobodno) { availableTimes.Add(tm.ToString("HH:mm")); } if (date.SelectedDate == danas) { if (tm < DateTime.Now.AddMinutes(30)) { availableTimes.Remove(tm.ToString("HH:mm")); } } } foreach (string time in availableTimes) { times.Items.Add(time); } }
private void LoadTimes() { DateTime datum; global::Doctor l = (global::Doctor)lekar.SelectedItem; if (date.SelectedDate != null) { datum = DateTime.Parse(date.Text); } else { datum = DateTime.Now; } availableTimes = new List <string>(); List <Appointment> termini = new List <Appointment>(); DateTime danas = DateTime.Today; for (DateTime tm = danas.AddHours(8); tm < danas.AddHours(20); tm = tm.AddMinutes(15)) { bool slobodno = true; foreach (Appointment termin in termini) { DateTime start = DateTime.Parse(termin.AppointmentDate.ToString("HH:mm")); DateTime end = DateTime.Parse(termin.AppointmentDate.AddMinutes(termin.DurationInMinutes).ToString("HH:mm")); if (tm >= start && tm < end) { slobodno = false; } } if (slobodno) { availableTimes.Add(tm.ToString("HH:mm")); } if (date.SelectedDate == danas) { if (tm < DateTime.Now.AddMinutes(30)) { availableTimes.Remove(tm.ToString("HH:mm")); } } } time.ItemsSource = availableTimes; }
private void dugmePotvrdi_Click(object sender, RoutedEventArgs e) { global::Doctor l = (global::Doctor)lekar.SelectedItem; Patient p = parent.Patient; if (time.SelectedIndex != -1) { var item = time.SelectedItem; String t = item.ToString(); String d = date.Text; DateTime dt = DateTime.Parse(d + " " + t); AppointmentType tipt; if (l.doctorType.Equals(DoctorType.generalPractitioner)) { tipt = AppointmentType.generalPractitionerCheckup; } else if (l.doctorType.Equals(DoctorType.surgeon)) { tipt = AppointmentType.operation; } else { tipt = AppointmentType.specialistCheckup; } int id = _appointmentController.GetAll().Count + 1; DateTime start; DateTime end; CalculateStartAndEnd(out start, out end); Room prvaDostupnaProstorija = GetAvailableRoom(start, end); Appointment appointment = new Appointment(id, dt, trajanjePregleda, tipt, AppointmentStatus.scheduled, p, l, prvaDostupnaProstorija); _appointmentController.Add(appointment); PatientExaminesAppointmentPage ptp = new PatientExaminesAppointmentPage(parent); updateVisibility(); parent.startWindow.Content = ptp; ptp.updateTable(); ActivityLog activity = new ActivityLog(DateTime.Now, _patient.Username, TypeOfActivity.makingAppointment); _activityLogController.AddActivity(activity); } }
private void MakeAppointment() { global::Doctor l = (global::Doctor)ljekari.SelectedItem; Patient p = parent.Patient; var item = times.SelectedItem; String t = item.ToString(); String d = date.Text; DateTime start = DateTime.Parse(d + " " + t); AppointmentType tipt; if (l.doctorType.Equals(DoctorType.generalPractitioner)) { tipt = AppointmentType.generalPractitionerCheckup; } else if (l.doctorType.Equals(DoctorType.surgeon)) { tipt = AppointmentType.operation; } else { tipt = AppointmentType.specialistCheckup; } int id = _appointmentController.GetAll().Count + 1; DateTime end = start.AddMinutes(trajanjePregleda); Room prvaDostupnaProstorija = GetAvailableRoom(start, end); Appointment appointment = new Appointment(id, start, trajanjePregleda, tipt, AppointmentStatus.scheduled, p, l, prvaDostupnaProstorija); _appointmentController.Add(appointment); PatientExaminesAppointmentPage ptp = new PatientExaminesAppointmentPage(parent); updateVisibility(); parent.startWindow.Content = ptp; ptp.updateTable(); }
public SlobodniTermini(global::Doctor ljekarNovi, string times) { this.Ljekar = ljekarNovi; this.AvailableTimes = times; }
private void CheckAvailableTimes() { DateTime datum; global::Doctor l = (global::Doctor)lekar.SelectedItem; if (date.SelectedDate != null) { datum = DateTime.Parse(date.Text); } else { datum = DateTime.Now; } availableTimes = new List <string>(); List <Appointment> termini = new List <Appointment>(); if (lekar.SelectedItem != null && date.SelectedDate != null) { foreach (Appointment termin in _appointmentController.GetAll()) { if (l.JMBG == termin.Doctor.JMBG) { if (termin.AppointmentStatus == AppointmentStatus.scheduled && termin.AppointmentDate.Date.Equals(date.SelectedDate)) { termini.Add(termin); } } if (parent.Patient.Username == termin.Patient.Username) { if (termin.AppointmentStatus == AppointmentStatus.scheduled && termin.AppointmentDate.Date.Equals(date.SelectedDate)) { termini.Add(termin); } } } } DateTime danas = DateTime.Today; for (DateTime tm = danas.AddHours(8); tm < danas.AddHours(20); tm = tm.AddMinutes(15)) { bool slobodno = true; foreach (Appointment termin in termini) { DateTime start = DateTime.Parse(termin.AppointmentDate.ToString("HH:mm")); DateTime end = DateTime.Parse(termin.AppointmentDate.AddMinutes(termin.DurationInMinutes).ToString("HH:mm")); if (tm >= start && tm < end) { slobodno = false; } } if (slobodno) { availableTimes.Add(tm.ToString("HH:mm")); } /*if (DatePicker.SelectedDate == danas) * { * if (tm < DateTime.Now.AddMinutes(30)) * { * availableTimes.Remove(tm.ToString("HH:mm")); * } * }*/ } time.ItemsSource = availableTimes; if (availableTimes.Contains(selektovan.AppointmentDate.ToString("HH:mm"))) { time.SelectedItem = selektovan.AppointmentDate.ToString("HH:mm"); } }