Example #1
0
        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         selectedPatient  = (Patient)PatientComboBox.SelectedItem;
            global::Doctor  selectedDoctor   = (global::Doctor)DoctorComboBox.SelectedItem;
            Room            selectedRoom     = (Room)RoomComboBox.SelectedItem;
            String          selectedTime     = AppointmentTime.SelectedItem.ToString();
            String          selectedDate     = DatePicker.Text;
            DateTime        selectedDateTime = DateTime.Parse(selectedDate + " " + selectedTime);
            AppointmentType appointmentType  = (AppointmentType)AppointmentTypeComboBox.SelectedIndex;
            int             id       = _appointmentController.GetAll().Count + 1;
            int             duration = Int32.Parse(AppointmentDuration.Text);

            if (selectedPatient.IsAvailable(selectedDateTime, selectedDateTime.AddMinutes(duration)))
            {
                Appointment newAppointment = new Appointment(id, selectedDateTime, duration, appointmentType, AppointmentStatus.scheduled, selectedPatient, selectedDoctor, selectedRoom);
                if (selectedDateTime < DateTime.Now)
                {
                    MessageBox.Show("Nije moguće zakazati pregled u prošlosti", "Greška u zakazivanju", MessageBoxButton.OK);
                    return;
                }

                _appointmentController.Add(newAppointment);
                this.Close();
            }
            else
            {
                MessageBox.Show("Pacijentu ne odgovara ovako dugo trajanje termina, preklapa se sa drugim obavezama", "Patient zauzet", MessageBoxButton.OK);
            }
        }
        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);
            }
        }
    public bool IsAvailable(DateTime start, DateTime end) // proverava da li je DoctorComboBox slobodan izmedju neka dva trenutka u vremenu
    {
        if (start.Equals(end))
        {
            return(true);
        }
        if (IsWithinVacations(start))
        {
            return(false);
        }
        if (!IsWithinWorkHours(start))
        {
            return(false);
        }

        foreach (Appointment appointment in _appointmentController.GetAll())
        {
            if (appointment.Doctor.Equals(this) && appointment.AppointmentStatus == AppointmentStatus.scheduled)
            {
                if (IsStartWithinAppointmentDuration(start, appointment))
                {
                    return(false);
                }
                if (IsEndWithinAppointmentDuration(end, appointment))
                {
                    return(false);
                }
                if (IsPeriodWithinApppointmentDuration(start, end, appointment))
                {
                    return(false);
                }
            }
        }
        return(true);
    }
        public void UpdateTable()
        {
            List <Appointment> appointments = new List <Appointment>();

            foreach (Appointment appointment in _appointmentController.GetAll())
            {
                if (appointment.AppointmentStatus == AppointmentStatus.scheduled)
                {
                    if (Filter == null)
                    {
                        appointments.Add(appointment);
                    }
                    else
                    {
                        if (appointment.AppointmentDate.Date == ((DateTime)Filter).Date)
                        {
                            appointments.Add(appointment);
                        }
                    }
                }
            }
            appointments.Sort((x, y) => DateTime.Compare(x.AppointmentDate, y.AppointmentDate));
            Appointments = new ObservableCollection <Appointment>(appointments);
            OnPropertyChanged("Appointments");
        }
        private void MakeAppointment()
        {
            SlobodniTermini selektovanTermin = (SlobodniTermini)PrikazSlobodnihTermina.SelectedItem;
            String          d     = date.Text;
            String          t     = selektovanTermin.AvailableTimes;
            DateTime        start = DateTime.Parse(d + " " + t);
            AppointmentType tipt;

            if (selektovanTermin.Ljekar.doctorType.Equals(DoctorType.generalPractitioner))
            {
                tipt = AppointmentType.generalPractitionerCheckup;
            }
            else if (selektovanTermin.Ljekar.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, parent.Patient, selektovanTermin.Ljekar, prvaDostupnaProstorija);

            _appointmentController.Add(appointment);
            PatientExaminesAppointmentPage ptp = new PatientExaminesAppointmentPage(parent);

            updateVisibility();
            parent.startWindow.Content = ptp;
            ptp.updateTable();
        }
Example #6
0
        public RecommendAppointment()
        {
            InitializeComponent();
            this.DataContext      = this;
            doctorController      = new DoctorController();
            appointmentController = new AppointmentController();
            operationController   = new OperationController();
            patientController     = new PatientController();

            List <ListaDoktoriCeloIme> mojaLista = new List <ListaDoktoriCeloIme>();

            listAppointments = appointmentController.GetAll();
            listPatients     = new List <PatientUser>();
            listPatients     = patientController.GetAll();
            listDoctors      = doctorController.GetAll();
            listOperations   = operationController.GetAll();

            foreach (DoctorUser d in listDoctors)
            {
                if (d.isSpecialist == false)
                {
                    StringBuilder l = new StringBuilder();
                    l.Append(d.firstName + " ");
                    l.Append(d.secondName + " ");
                    l.Append(d.id);
                    ListaDoktoriCeloIme a = new ListaDoktoriCeloIme();
                    a.DoctorName = l.ToString();
                    mojaLista.Add(a);
                }
            }

            doctorCombo.ItemsSource = mojaLista;
        }
Example #7
0
        private void UpdateAvailableTimes()
        {
            DateTime date;

            if (DatePicker.SelectedDate != null)
            {
                date = DateTime.Parse(DatePicker.Text);
            }
            else
            {
                date = DateTime.Now;
            }


            List <Appointment> appointments = new List <Appointment>();

            foreach (Appointment appointment in _appointmentController.GetAll())
            {
                if (appointment.OccursOn(date) && appointment.InvolvesEither((Patient)PatientComboBox.SelectedItem, (global::Doctor)DoctorComboBox.SelectedItem) && appointment.AppointmentStatus == AppointmentStatus.scheduled)
                {
                    appointments.Add(appointment);
                }
            }
            AppointmentTime.ItemsSource = _appointmentTimesController.GetAvailableAppointmentTimes(appointments, (Doctor)DoctorComboBox.SelectedItem);
        }
Example #8
0
        private void BtnAppointmentList_Click(object sender, EventArgs e)
        {
            if (dtpAppointmentDate.Value == DateTime.Today)
            {
                btnAddExamination.Enabled = true;
            }
            else
            {
                btnAddExamination.Enabled = false;
            }
            lstAppointment.Items.Clear();
            appointmentController = new AppointmentController();
            List <Appointment> appointments = appointmentController.GetAll();

            foreach (var item in appointments)
            {
                if (item.AppointmentDate.Date == dtpAppointmentDate.Value.Date & item.DoctorId == Homepage.userID)
                {
                    ListViewItem listViewItems = new ListViewItem(item.AppointmentId.ToString());
                    listViewItems.SubItems.Add(item.Patient.FirstName);
                    listViewItems.SubItems.Add(item.Patient.LastName);
                    listViewItems.SubItems.Add(item.Hour.HourInfo);
                    listViewItems.SubItems.Add(item.AppointmentDate.Date.ToString());
                    lstAppointment.Items.Add(listViewItems);
                }
            }
        }
        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);
            }
        }
Example #10
0
 public PatientEditsAppointmentPage(Appointment selektovan, StartPatientWindow prozor)
 {
     this.selektovan = selektovan;
     this.parent     = prozor;
     brojac          = 0;
     InitializeComponent();
     parent.titleLabel.Content    = "Pomeranje termina";
     parent.titleLabel.Visibility = Visibility.Visible;
     availableTimes   = new List <string>();
     termini          = _appointmentController.GetAll();
     time.ItemsSource = availableTimes;
     prostorije       = _roomController.GetAllRooms();
     LoadTimes();
     BlackOutDates();
     date.SelectedDate = selektovan.AppointmentDate;
     time.SelectedItem = selektovan.AppointmentDate.ToString("HH:mm");
     lekari            = new List <global::Doctor>();
     FillDoctorsComboBox();
     SetSelectedDoctor();
 }
        private void PostponeButton_Click(object sender, RoutedEventArgs e)
        {
            if (AppointmentData.SelectedIndex == -1)
            {
                return;
            }

            Appointment selectedAppointment = (Appointment)AppointmentData.SelectedItem;
            int         id             = _appointmentController.GetAll().Count + 1;
            Appointment newAppointment = new Appointment(id, selectedAppointment.AppointmentDate, _appointmentDuration, _appointmentType, AppointmentStatus.scheduled, _patient, selectedAppointment.Doctor, selectedAppointment.Room);

            foreach (Appointment appointment in _appointmentsForPostponing)
            {
                Postpone(appointment);
            }

            _appointmentController.Add(newAppointment);

            _parent.Close();
            Close();
        }
Example #12
0
        public void GetAll_Test()
        {
            // Arrange
            var mockService = new Mock <IAppointmentService>();
            var controller  = new AppointmentController(mockService.Object);

            // Act
            IQueryable <AppointmentModel> response = controller.GetAll();

            // Assert
            Assert.IsNotNull(response);
        }
 private void LoadRemindersForAppointment()
 {
     _statusOfAppointmentController.CheckMissedAppointments();
     foreach (Appointment a in _appointmentController.GetAll())
     {
         if (_statusOfAppointmentController.IsAppointmentTomorrow(a) &&
             a.PatientUsername.Equals(loggedInPatient.Username))
         {
             notifications.Add("Imate zakazan termin u " +
                               a.AppointmentDate.ToShortTimeString() + ".");
         }
     }
 }
Example #14
0
        public void UpdateTable()
        {
            List <Appointment> appointments = new List <Appointment>();

            foreach (Appointment appointment in _appointmentController.GetAll())
            {
                if (appointment.AppointmentStatus == AppointmentStatus.scheduled && appointment.AppointmentDate <= To && appointment.AppointmentDate >= From)
                {
                    appointments.Add(appointment);
                }
            }
            appointments.Sort((x, y) => DateTime.Compare(x.AppointmentDate, y.AppointmentDate));
            AppointmentPreview.ItemsSource = appointments;
            FromLabel.Content      = From.ToString("dd/MM/yyyy");
            ToLabel.Content        = To.ToString("dd/MM/yyyy");
            DateOfPrinting.Content = DateTime.Now.ToString("dd/MM/yyyy");
        }
        private int getNextid()
        {
            AppointmentController    rp    = new AppointmentController();
            List <DoctorAppointment> lista = rp.GetAll();

            int number = 0;

            foreach (DoctorAppointment r in lista)
            {
                if (r.id > number)
                {
                    number = r.id;
                }
            }

            number += 1;
            return(number);
        }
Example #16
0
        public Boolean doesPatientHaveAnAppointmentAtSpecificTime(TimeSpan time, string date, PatientUser patient)
        {
            AppointmentController    appointmentController = new AppointmentController();
            List <DoctorAppointment> listOfAppointments    = appointmentController.GetAll();

            if (listOfAppointments == null)
            {
                listOfAppointments = new List <DoctorAppointment>();
            }

            foreach (DoctorAppointment appointment in listOfAppointments)
            {
                if (arePatientsEquals(patient, appointment.patient) && appointment.date.Equals(date) && compareTimeForAppointment(time, appointment))
                {
                    return(true);
                }
            }
            return(false);
        }
Example #17
0
        public bool doesPatientHaveAnAppointmentAtSpecificPeriod(TimeSpan start, TimeSpan end, string dateToString, PatientUser patient)
        {
            bool busy = false;
            AppointmentController    appointmentController = new AppointmentController();
            List <DoctorAppointment> listOfAppointments    = appointmentController.GetAll();

            foreach (DoctorAppointment appointment in listOfAppointments)
            {
                PatientUser patientUser = appointment.patient;
                if (arePatientsEquals(patientUser, patient) && appointment.date.Equals(dateToString))
                {
                    busy = compareTimeForAppointment(start, appointment);
                    if (!busy)
                    {
                        busy = compareTimeForAppointment(end, appointment);
                    }
                }
            }
            return(busy);
        }
        private void Termini_Click(object sender, RoutedEventArgs e)
        {
            String m = bingPathToAppDir(@"JsonFiles\doctors.json");
            AppointmentController apcon = new AppointmentController();

            List <DoctorAppointment> pregledi  = apcon.GetAll();
            OperationController      opcon     = new OperationController();
            List <Operation>         operacije = opcon.GetAll();
            DoctorRepository         docRepo   = new DoctorRepository(m);
            List <DoctorUser>        doktori   = docRepo.GetAll();
            DoctorUser drOvaj = new DoctorUser();
            String     poruka = "";

            foreach (DoctorUser d1 in doktori)
            {
                if (d1.email.Equals(emailLekarBox.Text.ToString()))
                {
                    drOvaj = d1;
                }
            }
            EmployeesScheduleController schCon   = new EmployeesScheduleController();
            List <Schedule>             raspored = schCon.GetAll();
            Boolean duznost = false;

            foreach (Schedule rasp in raspored)
            {
                if (rasp.employeeid.Equals(drOvaj.id.ToString()))
                {
                    if (DatumBox.Text.Equals(rasp.date))
                    {
                        duznost = true;
                        poruka += "Lekar datuma " + rasp.date + " radi od " + rasp.shift.startTime + " do " + rasp.shift.endTime + ".\n";
                    }
                }
            }
            if (duznost == false)
            {
                poruka += "Lekar nije da duznosti trazenog datuma.";
            }
            if (duznost == true)
            {
                poruka += "Zauzeti termini su: \n";
                foreach (DoctorAppointment d in pregledi)
                {
                    TimeSpan kraj = d.time + new TimeSpan(0, 15, 0);
                    if (d.doctor.id.ToString().Equals(drOvaj.id.ToString()))
                    {
                        if (d.date.Equals(DatumBox.Text))
                        {
                            poruka += " " + d.time + " - " + kraj + "\n";
                        }
                    }
                }
                foreach (Operation d in operacije)
                {
                    if (d.isResponiable.id.ToString().Equals(drOvaj.id.ToString()))
                    {
                        if (d.date.Equals(DatumBox.Text))
                        {
                            poruka += " " + d.start + " - " + d.end + "\n";
                        }
                    }
                }
            }
            MessageBox.Show(poruka, "Raspored lekara za trazeni datum", MessageBoxButton.OK, MessageBoxImage.Information);
        }