/// <summary> /// Handles the visit-moved event from Docplanner /// </summary> /// <param name="notification"></param> /// <returns></returns> public bool MoveVisit(Booking oldVisit, Booking newVisit, DPFacility facility, DPDoctor doctor, Address address) { var visit = _visitRepository.GetByForeignId(oldVisit.Id); if (_scheduleManager.IsSlotExist(newVisit.StartAt.LocalDateTime.ChangeTimeZone(timeZone), newVisit.EndAt.LocalDateTime.ChangeTimeZone(timeZone), visit.DoctorFacility)) { visit.ForeignVisitId = newVisit.Id; visit.StartAt = newVisit.StartAt.LocalDateTime.ChangeTimeZone(timeZone); visit.EndAt = newVisit.EndAt.LocalDateTime.ChangeTimeZone(timeZone); var oldSchedule = visit.DoctorSchedule; var newSchedule = _scheduleManager.FindDoctorSchedule(visit.DoctorFacility, visit.StartAt, visit.EndAt, newVisit.Service.Id); visit.DoctorSchedule = newSchedule; visit.DoctorScheduleId = newSchedule.Id; _scheduleManager.RestoreSchedule(oldSchedule); _scheduleManager.ArrangeSchedule(visit); return(true); } else { CancelVisit(visit, false); CancelVisitDP(visit); CancelVisitDP(facility.Id, doctor.Id, address.Id, newVisit.Id); return(false); } }
public bool RegisterDpVisit(DPFacility facility, DPDoctor doctor, Address address, Booking visitBooking) { var doctorMapping = _mappingRepo.GetByForeignAddress(address.Id); var existingVisit = _visitRepository.GetByForeignId(visitBooking.Id); var startAt = visitBooking.StartAt.LocalDateTime.ChangeTimeZone(timeZone); var endAt = visitBooking.EndAt.LocalDateTime.ChangeTimeZone(timeZone); if (existingVisit != null) { return(true); } else if (false == _scheduleManager.IsSlotExist(startAt, endAt, doctorMapping.DoctorFacility)) { return(false); } else if (doctorMapping == null) { return(false); } var patient = visitBooking.Patient; var visit = new Visit() { DoctorFacility = doctorMapping.DoctorFacility, DoctorId = doctorMapping.DoctorId, FacilityId = doctorMapping.FacilityId, StartAt = visitBooking.StartAt.LocalDateTime.ChangeTimeZone(timeZone), EndAt = visitBooking.EndAt.LocalDateTime.ChangeTimeZone(timeZone), ForeignVisitId = visitBooking.Id, VisitStatus = VisitStatus.Booked, VisitPatient = new VisitPatient() { Name = patient.Name, Surname = patient.Surname, Phone = patient.Phone, Email = patient.Email, Gender = patient.Gender == null ? Gender.NotSpecified : (patient.Gender == "m" ? Gender.Male : Gender.Female), NIN = patient.Nin, Birthdate = patient.BirthDate } }; var schedule = _scheduleManager.FindDoctorSchedule(doctorMapping.DoctorFacility, visit.StartAt, visit.EndAt, visitBooking.Service.Id); if (schedule == null || schedule.IsFullfilled) { return(false); } else { visit.DoctorSchedule = schedule; visit.DoctorScheduleId = schedule.Id; BookVisit(visit, true); return(true); } }
private bool SlotBookedEvent(DPFacility facility, DPDoctor doctor, Address address, Booking visitBooking) { bool result = _visitManager.RegisterDpVisit(facility, doctor, address, visitBooking); if (result == false) { _visitManager.CancelVisitDP(facility.Id, doctor.Id, address.Id, visitBooking.Id); } return(result); }
private bool DefaultEventHandler(DPFacility facility, DPDoctor doctor, Address address) { var mapping = _mappingRepo.GetByForeignAddress(address.Id); if (mapping == null) { return(false); } return(true); //noop }
public bool CanSlotBeBooked(DPFacility facility, DPDoctor doctor, Address address, RealtimeBooking visitBooking) { var doctorMapping = _mappingRepo.GetByForeignAddress(address.Id); var startAt = visitBooking.StartAt.LocalDateTime.ChangeTimeZone(timeZone); var endAt = visitBooking.EndAt.LocalDateTime.ChangeTimeZone(timeZone); if (doctorMapping == null) { return(false); } return(_scheduleManager.IsSlotExist(startAt, endAt, doctorMapping.DoctorFacility)); }
private static ForeignFacility CreateOrUpdateFacility(DPFacility facility) { var foreignFacility = CheckFacilityContext(facility.Id); foreignFacility.Id = facility.Id; foreignFacility.Name = facility.Name; if (db.Entry(foreignFacility).State == EntityState.Detached) { db.ForeignFacilities.Add(foreignFacility); } return(foreignFacility); }
private bool SlotBookedEvent(DPFacility facility, DPDoctor doctor, Address address, Booking visitBooking) { return(_visitManager.RegisterDpVisit(facility, doctor, address, visitBooking)); }
private bool BookingCanceled(DPFacility facility, DPDoctor doctor, Address address, Booking visitBooking) { return(_visitManager.CancelVisit(visitBooking.Id, false)); }
private bool BookingMoved(DPFacility facility, DPDoctor doctor, Address address, Booking oldVisitBooking, Booking newVisitBooking) { return(_visitManager.MoveVisit(oldVisitBooking, newVisitBooking, facility, doctor, address)); }
/// <summary> /// Given the case when overbooking a slot is not permitted. /// </summary> /// <param name="facility"></param> /// <param name="doctor"></param> /// <param name="address"></param> /// <param name="visitBooking"></param> private bool SlotOverbooked(DPFacility facility, DPDoctor doctor, Address address, Booking visitBooking) { return(_visitManager.CancelVisitDP(facility.Id, doctor.Id, address.Id, visitBooking.Id)); }
private bool SlotBookingEvent(DPFacility facility, DPDoctor doctor, Address address, RealtimeBooking visitBooking) { return(_visitManager.CanSlotBeBooked(facility, doctor, address, visitBooking)); }
private bool DefaultEventHandler(DPFacility facility, DPDoctor doctor, Address address) { return(true); }