public IEnumerable <PeriodPerformanceInfo> GetPeriodPerformanceReport(string hospitalId) { var id = Int32.Parse(hospitalId); var specialties = _specialtyRepository .Get(specialty => specialty.Hospitals.Any(hospital => hospital.Id == id), specialty => specialty.Hospitals) .ToArray(); var specialtyCodes = specialties.Select(specialty => specialty.Code); var allCompletedEvents = _completedEventRepository .Get(completedEvent => specialtyCodes.Contains(completedEvent.Clinician.Specialty.Code) && completedEvent.Clinician.Hospital.Id == id && completedEvent.Period.ShouldCountForBreaches, null, null, completedEvent => completedEvent.Period, completedEvent => completedEvent.Clinician.Specialty) .ToArray(); return(from specialtyId in specialtyCodes let completedEventsForSpecialty = allCompletedEvents .Where(completedEventForSpecialty => completedEventForSpecialty.Clinician.Specialty.Code == specialtyId) .ToList() let periodBreachesCounter = _periodBreachesCounterReportService .GetPeriodBreachesCounterInfo(completedEventsForSpecialty, specialties.Single(specialty => specialty.Code == specialtyId).Name, specialtyId) where periodBreachesCounter != null select periodBreachesCounter); }
public virtual IEnumerable <SpecialtyInfo> GetSpecialties(int?hospitalId) { return (_specialtyRepository.Get( specialty => hospitalId == null || (specialty.Hospitals.Any(hospital => hospital.Id == hospitalId) && specialty.Clinicians.Any(clinician => clinician.Hospital.Id == hospitalId))) .Select(specialty => _specialtyToSpecialtyInfoMapper.Map(specialty))); }