public static Clinician CreateFakeClinician(ClinicianType type) { var faker = new Faker("en"); var o = new Clinician() { FirstName = faker.Name.FirstName(), LastName = faker.Name.LastName(), AssignedBirths = new List <Birth>(), Role = type }; return(o); }
public static IEnumerable <Clinician> FindAvailableClinicians(DbSet <Clinician> clinicians, Birth Birth, ClinicianType Role) { int RequiredDelta = 0; int AllowedOccurences = 0; switch (Role) { case ClinicianType.DOCTOR: RequiredDelta = 12; AllowedOccurences = 4; break; case ClinicianType.HEALTH_ASSISTANT: RequiredDelta = 4; AllowedOccurences = 2; break; case ClinicianType.MIDWIFE: RequiredDelta = 120; AllowedOccurences = 8; break; case ClinicianType.NURSE: RequiredDelta = 136; AllowedOccurences = 9; break; case ClinicianType.SECRETARY: // Secretary only has to check in the birth, so she is freed up immediately, but still associated. AllowedOccurences = 50000; break; } return(clinicians.Where(clinician => //search for conflicts clinician.Role == Role && clinician.AssignedBirths.Where(b => EF.Functions.DateDiffMinute(b.BirthDate, Birth.BirthDate) >= RequiredDelta * 60).Count() <= AllowedOccurences )); }