Ejemplo n.º 1
0
        internal async Task AddAppointmentAsync(int doctorId, int patientId, DateTime dateTime)
        {
            Doctor  doctor  = null;
            Patient patient = null;

            using (var doctorController = new DoctorController())
                await Task.Run(() => doctor = doctorController.GetDoctor(doctorId));
            if (doctor == null)
            {
                throw new KeyNotFoundException("Doctor with the specified id doesn't exist.");
            }

            using (var patientController = new PatientController())
                await Task.Run(() => patient = patientController.GetPatient(patientId));
            if (patient == null)
            {
                throw new KeyNotFoundException("Patient with the specified id doesn't exist.");
            }


            Appointment appointment = new Appointment(doctor, patient, dateTime);

            using (_controller = new AppointmentController())
                await Task.Run(() => _controller.AddAppointment(appointment));

            await UpdateAppointmentsAsync();
        }
        private void Add_Form_Click(object sender, RoutedEventArgs e)
        {
            if (!checkIfSomethingLeft())
            {
                ErrorMessage.Visibility = Visibility.Visible;
            }
            else
            {
                Appointment appointment = new Appointment();
                if ((bool)Surgery.IsChecked)
                {
                    appointment.TypeOfAppointment = TypeOfAppointment.examination;
                }
                else if ((bool)Exam.IsChecked)
                {
                    appointment.TypeOfAppointment = TypeOfAppointment.surgery;
                }

                appointment.MedicalRecord = medicalRecordController.GetRecordByPatient(selectedPatient);
                string[] timeparts = ((string)TimeBox.SelectedItem).Split(":");
                appointment.StartTime        = new DateTime(((DateTime)SelectedDate.SelectedDate).Year, ((DateTime)SelectedDate.SelectedDate).Month, ((DateTime)SelectedDate.SelectedDate).Day, int.Parse(timeparts[0]), int.Parse(timeparts[1]), 0);
                appointment.Room             = MainWindow.doctor.ExaminationRoom;
                appointment.ShortDescription = ShortDescr.Text;

                if ((bool)Urgent.IsChecked)
                {
                    appointment.Urgent = true;
                }
                else if ((bool)NotUrgent.IsChecked)
                {
                    appointment.Urgent = false;
                }
                else
                {
                    appointment.Urgent = true;
                }

                appointment.Doctor  = MainWindow.doctor;
                appointment.Deleted = false;

                try
                {
                    appointmentController.AddAppointment(appointment, false);
                    MyEvents.CloseAddFormHandler.RaiseMyCustomEvent(this, new MyEvents.CloseAddForm());
                } catch (PatientAlreadyHasAnAppointment)
                {
                    Error.Text = "Pacijent već ima zakazan pregled u budućnosti!";
                    ErrorMessage.Visibility = Visibility.Visible;
                } catch (SimsProjekat.Exceptions.NotValidTimeForScheduling)
                {
                    Error.Text = "Vreme termina nije validno!";
                    ErrorMessage.Visibility = Visibility.Visible;
                } catch (SimsProjekat.Exceptions.AlreadyScheduled)
                {
                    Error.Text = "Termin se već zakazao!";
                    ErrorMessage.Visibility = Visibility.Visible;
                }
            }
        }
        private void Add_Form_Click(object sender, RoutedEventArgs e)
        {
            if (!checkIfSomethingLeft())
            {
                ErrorMessage.Visibility = Visibility.Visible;
            }
            else
            {
                if ((bool)Yes.IsChecked)
                {
                    EmergencyRequest emergencyRequest = new EmergencyRequest();
                    emergencyRequest.MedicalRecord     = medicalRecordController.GetMedicalRecord(Informations.currentRecord.MedicalRecord.IdRecord);
                    emergencyRequest.Scheduled         = false;
                    emergencyRequest.SideNotes         = ShortDescr.Text;
                    emergencyRequest.Specialization    = doctor.Specializations[0];
                    emergencyRequest.TypeOfAppointment = TypeOfAppointment.examination;
                    emergencyRequestController.CreateEmergencyRequest(emergencyRequest);

                    MyEvents.CloseAddFormHandler.RaiseMyCustomEvent(this, new MyEvents.CloseAddForm());
                    NavigationService.Navigate(new Uri("/Pages/MedicalRecord/Informations.xaml", UriKind.Relative));
                }
                else
                {
                    Appointment a = new Appointment();
                    a.Doctor           = doctor;
                    a.ShortDescription = ShortDescr.Text;
                    string[] parts = ((string)TimeBox.SelectedItem).Split(":");
                    a.MedicalRecord = medicalRecordController.GetMedicalRecord(Informations.currentRecord.MedicalRecord.IdRecord);

                    a.TypeOfAppointment = TypeOfAppointment.examination;
                    a.Room = doctor.ExaminationRoom;
                    DateTime date = (DateTime)DateSelected.SelectedDate;
                    a.StartTime = new DateTime(date.Year, date.Month, date.Day, int.Parse(parts[0]), int.Parse(parts[1]), 0);
                    a.Urgent    = false;
                    try
                    {
                        appointemntController.AddAppointment(a, false);

                        MyEvents.CloseAddFormHandler.RaiseMyCustomEvent(this, new MyEvents.CloseAddForm());
                        NavigationService.Navigate(new Uri("/Pages/MedicalRecord/Informations.xaml", UriKind.Relative));
                    }
                    catch (PatientAlreadyHasAnAppointment)
                    {
                        Error.Text = "Pacijent već ima zakazan pregled u budućnosti";
                        ErrorMessage.Visibility = Visibility.Visible;
                    }
                    catch (AlreadyScheduled)
                    {
                        Error.Text = "U međuvremenu, termin se zakazao!";
                        ErrorMessage.Visibility = Visibility.Visible;
                    }
                    catch (NotValidTimeForScheduling)
                    {
                        Error.Text = "Vreme je nevalidno za zakazivanje";
                        ErrorMessage.Visibility = Visibility.Visible;
                    }
                }
            }
        }
        public void AddAppointment_ShouldAdd()
        {
            Patient     patient  = new Patient("Foo", "Patient to add");
            Doctor      doctor   = new Doctor("Foo", "Doctor to add", "Numb");
            Appointment expected = new Appointment(doctor, patient);

            _controller.AddAppointment(expected);

            Appointment actual = _controller.GetAppointment(expected.Id);

            Assert.Equal(expected, actual);
        }
        private void btnComplateAppointment_Click(object sender, EventArgs e)
        {
            bool result = appointmentController.AddAppointment(session, patient);

            if (result)
            {
                MessageBox.Show("kayıt başarılı");
                pnlAnAppointmentInfos.Visible = false;
            }
            else
            {
                MessageBox.Show("kayıt başarısız!!!!");
            }
        }
Ejemplo n.º 6
0
        public void AddAppointment_Success()
        {
            // Arrange
            var appointment = new AppointmentViewModel
            {
                ContactID            = 1,
                ProgramID            = 153,
                ServicesID           = 172,
                ServiceStatusID      = 1,
                AppointmentTypeID    = 1,
                AppointmentDate      = DateTime.UtcNow,
                AppointmentStartTime = 800,
                AppointmentLength    = 30,
                NonMHMRAppointment   = "nonMHMR appointment"
            };

            // Act
            var result   = controller.AddAppointment(appointment);
            var response = result as Response <AppointmentViewModel>;

            // Assert
            Assert.IsTrue(response != null, "Response can't be null");
            Assert.IsTrue(response.ResultCode == 0, "Appointment could not be created.");
        }
 private void btnSaveAppointment_Click(object sender, EventArgs e)
 {
     if (SessionTimeId == 0)
     {
         MessageBox.Show("Lütfen bir seans seçiniz.");
     }
     else
     {
         Session session = new Session()
         {
             RendezvousTimeId = SessionTimeId,
             DoctorId         = doctor.DoctorId,
             SessionDate      = Convert.ToDateTime(shortDate)
         };
         if (appointmentController.AddAppointment(session, patient))
         {
             MessageBox.Show("Kayıt başarılı.");
         }
         else
         {
             MessageBox.Show("Kayıt anında bir hata oluştu.");
         }
     }
 }