예제 #1
0
        public void addAppointment()
        {
            datePickerString  = AppointmentDatePicker.ToShortDateString();
            datePickerString += " ";
            datePickerString += AppointmentTimePicker.ToShortTimeString();
            Appointment newAppointment = new Appointment
            {
                Patient  = (AppointmentPatient)Hospital.Patients[PatientNameComboBox.Key],
                Doctor   = (Doctor)Hospital.Employees[DoctorNameComboBox.Key],
                Duration = Int32.Parse(AppointmentDuration),
                Date     = DateTime.Parse(datePickerString),
                Bill     = ((double.Parse(AppointmentDuration) / 60.0)) * Hospital.Config.AppointmentHourPrice
            };

            if (!(((Doctor)Hospital.Employees[DoctorNameComboBox.Key]).isAvailable(newAppointment)))
            {
                textValidation = "Doctor is not available at this time";
                return;
            }
            Appointments.Add(
                new AppointmentCardViewModel
            {
                ID              = newAppointment.ID,
                PatientName     = newAppointment.Patient.Name,
                DoctorName      = newAppointment.Doctor.Name,
                Duration        = newAppointment.Duration.ToString(),
                AppointmentDate = newAppointment.Date.ToString(),
                appointmentBill = newAppointment.Bill.ToString("0.00") + '$'
            });
            FilteredAppointments.Add(
                new AppointmentCardViewModel
            {
                ID              = newAppointment.ID,
                PatientName     = newAppointment.Patient.Name,
                DoctorName      = newAppointment.Doctor.Name,
                Duration        = newAppointment.Duration.ToString(),
                AppointmentDate = newAppointment.Date.ToString(),
                appointmentBill = newAppointment.Bill.ToString("0.00") + '$'
            });
            Hospital.Appointments.Add(newAppointment.ID, newAppointment);
            Hospital.Appointments[newAppointment.ID].Patient.addAppointment(newAppointment);
            Hospital.Appointments[newAppointment.ID].Doctor.addAppointment(newAppointment);
            Hospital.Appointments[newAppointment.ID].Doctor.addPatient(newAppointment.Patient);
            HospitalDB.InsertAppointment(newAppointment);
            Home.ViewModel.CloseRootDialog();
        }
예제 #2
0
        public void DeleteAppointment(String ID)
        {
            Hospital.Appointments[ID].Doctor.removePatient(Hospital.Appointments[ID].Patient.ID);
            Hospital.DeleteAppointment(ID);
            for (int i = 0; i < FilteredAppointments.Count; ++i)
            {
                if (FilteredAppointments[i].ID == ID)
                {
                    FilteredAppointments.RemoveAt(i);
                    break;
                }
            }

            for (int i = 0; i < Appointments.Count; ++i)
            {
                if (Appointments[i].ID == ID)
                {
                    Appointments.RemoveAt(i);
                    break;
                }
            }
            HospitalDB.DeleteAppointment(ID);
        }