public bool DoctorWouldExceedMaxConsecutiveShifts(Slot slot, Doctor doctor) { if (MaxConsecutiveShifts == 0) return false; var list = GetSlotsByDoctorAndRotation(doctor, slot).ToList(); list.Add(slot); return CalcMaxConsecutiveShifts(list.OrderBy(x => x.week)) > MaxConsecutiveShifts; }
public bool DoctorHasExceededMaxDaysThisRotation(Slot slot, Doctor doctor) { if (MaxShiftsPerRotation == 0) return false; var list = GetSlotsByDoctorAndRotation(doctor, slot).ToList(); list.Add(slot); return CountShifts(list) > MaxShiftsPerRotation; }
public IEnumerable<Doctor> GetEligibleDoctors(Slot slot) { return GetRankedDoctorList(slot.is24) .Where(x => !x.HasVacation(slot)) .Where(x => x.Rotations[slot.rotationNumber] == slot.location); }
public IEnumerable<Doctor> GetCrossCallDoctors(Slot slot) { return GetRankedDoctorList(slot.is24) .Where(x => !x.HasVacation(slot)) .Where(x => x.Rotations[slot.rotationNumber] != "NA" && x.Rotations[slot.rotationNumber] != slot.location); }
public bool DoctorHasExceededHisPersonalMaxShifts(Slot slot, Doctor doctor) { return doctor.TotalShiftCount + (slot.is24 ? 2 : 1) > doctor.MaxShifts; }
private string GetDoctorName(Slot slot) { return slot.doctor != null ? string.Format(",{0}{1}", slot.doctor.Name, slot.crossCall ? " (C)" : string.Empty) : ",<blank>"; }
private IEnumerable<Slot> GetSlotsByDoctorAndRotation(Doctor doctor, Slot slot) { return Schedule.Where(x => x.doctor == doctor && x.rotationNumber == slot.rotationNumber); }
private bool DoctorHasExceededMaxWeekendsPerRotation(Slot slot, Doctor doctor) { if (MaxWeekends == 0) return false; return GetSlotsByDoctorAndRotation(doctor, slot).Count() >= MaxWeekends; }
private bool DoctorHasExceededMaxSameShiftsPerRotation(Slot slot, Doctor doctor) { if (MaxSameShifts == 0) return false; return GetSlotsByDoctorAndRotation(doctor, slot).Where(x => x.shift == slot.shift).Count() >= MaxSameShifts; }
private bool DoctorHasExceededMaxLifetime(Slot slot, Doctor doctor) { if (MaxShiftsPerLifetime == 0) return false; return doctor.TotalShiftCount + (slot.is24 ? 2 : 1) > MaxShiftsPerLifetime; }
private bool DoctorAlreadyWorkingThisWeekend(Slot slot, Doctor doctor) { return Schedule.Where(x => x.week == slot.week).Where(x => x.doctor == doctor).Any(); }
private bool CanWork(Slot slot, Doctor doctor) { if (DoctorAlreadyWorkingThisWeekend(slot, doctor)) { return false; } if (DoctorHasExceededMaxDaysThisRotation(slot, doctor)) { return false; } if (DoctorHasExceededMaxLifetime(slot, doctor)) { return false; } if (DoctorHasExceededMaxSameShiftsPerRotation(slot, doctor)) { return false; } if (DoctorWouldExceedMaxConsecutiveShifts(slot, doctor)) { return false; } if (DoctorHasExceededMaxWeekendsPerRotation(slot, doctor)) { return false; } if (DoctorHasExceededHisPersonalMaxShifts(slot, doctor)) { return false; } return true; }