public virtual BreachesInfo GetBreaches()
        {
            var eventMilestones =
                _eventMilestoneRepository.Get(
                    eventMilestone => eventMilestone.CompletedEvent.IsActive &&
                    eventMilestone.IsMandatory &&
                    eventMilestone.CompletedEvent.Period.ShouldCountForBreaches,
                    eventMilestone => eventMilestone.Name,
                    eventMilestone => eventMilestone.CompletedEvent.Period.CompletedEvents,
                    eventMilestone => eventMilestone.CompletedEvent.Period.Pathway.Patient).ToArray();
            var completedEvents = _completedEventRepository.Get(
                completedEvent => completedEvent.IsActive &&
                completedEvent.Period.ShouldCountForBreaches,
                completedEvent => completedEvent.Name,
                completedEvent => completedEvent.Period.CompletedEvents,
                completedEvent => completedEvent.Period.Pathway.Patient).ToArray();

            var eventBreachesInfo = GetEventBreachesInfo(eventMilestones, 0)
                                    .Concat(GetEventBreachesInfo(eventMilestones, 1))
                                    .Concat(GetEventBreachesInfo(eventMilestones, 2))
                                    .Concat(GetEventBreachesInfo(eventMilestones, 3))
                                    .Concat(GetEventBreachesInfo(eventMilestones, -1))
                                    .ToArray();
            var periodBreachedInfo = GetPeriodBreachesInfo(completedEvents, 0)
                                     .Concat(GetPeriodBreachesInfo(completedEvents, 1))
                                     .Concat(GetPeriodBreachesInfo(completedEvents, 2))
                                     .Concat(GetPeriodBreachesInfo(completedEvents, 3))
                                     .ToArray();

            return(new BreachesInfo
            {
                EventsBreaches = eventBreachesInfo,
                PeriodsBreaches = periodBreachedInfo
            });
        }
Пример #2
0
        public EventBreachesInfo GetEventBreachesReport(int daysToBreach, BreachFilterInputInfo filterInputInfo, ListInputInfo listInputInfo)
        {
            var eventMilestones = _eventMilestoneRepository
                                  .Get(_eventBreachesReportService.GetCriteria(filterInputInfo),
                                       filterInputInfo.PeriodType,
                                       e => e.Name,
                                       e => e.CompletedEvent.Period.CompletedEvents.Select(completedEvent => completedEvent.Name),
                                       e => e.CompletedEvent.Period.Pathway.Patient,
                                       e => e.CompletedEvent.Clinician.Specialty)
                                  .Where(_eventBreachesReportService.GetFilter(daysToBreach, filterInputInfo.AdvancementOrDelay)).ToList();

            var totalNumberOfEventBreaches = eventMilestones.Count;

            eventMilestones = _eventBreachesReportService.ApplyPaginationAndOrdering(eventMilestones, listInputInfo).ToList();

            var eventBreachesList = (
                from eventMilestone in eventMilestones
                let postBreachDays = eventMilestone.GetDaysToBreachAt(_clock.Today)
                                     let daysRemaining = eventMilestone.CompletedEvent.Period.GetDaysRemainingAt(_clock.Today)
                                                         where postBreachDays != null
                                                         select new EventBreachInfo
            {
                EventDescription = eventMilestone.Name.Description,
                PatientNHSNumber = eventMilestone.CompletedEvent.Period.Pathway.Patient.NHSNumber,
                PatientName = eventMilestone.CompletedEvent.Period.Pathway.Patient.Name,
                PPINumber = eventMilestone.CompletedEvent.Period.Pathway.PPINumber,
                Clinician = eventMilestone.CompletedEvent.Clinician.Name,
                Specialty = eventMilestone.CompletedEvent.Clinician.Specialty.Name,
                PostBreachDays = Math.Abs((int)postBreachDays),
                DaysInPeriod = eventMilestone.CompletedEvent.Period.GetDaysSpentAt(_clock.Today),
                DaysRemainingInPeriod = daysRemaining < 0 ? 0 : daysRemaining,
                DelayOrAdvancementDays = eventMilestone.CompletedEvent.Period.GetDelayOrAdvancementDays(_clock.Today),
                PeriodType = eventMilestone.CompletedEvent.Period.GetType().Name,
                EventType = eventMilestone.CompletedEvent.GetType().Name,
                PeriodId = eventMilestone.CompletedEvent.Period.Id
            }).ToArray();

            return(new EventBreachesInfo
            {
                EventBreaches = eventBreachesList,
                TotalNumberOfEventBreaches = totalNumberOfEventBreaches
            });
        }
Пример #3
0
        public virtual IEnumerable <LiteEventBreachInfo> GetLiteEventBreaches(int periodId)
        {
            var allEventMilestones = _eventMilestoneRepository
                                     .Get(GetCriteriaForPeriodEventMilestones(periodId),
                                          e => e.CompletedEvent.Period,
                                          e => e.Name)
                                     .Where(eventMilestone => eventMilestone.BreachDate != null)
                                     .ToArray();

            var allCompletedEvents = _completedEventRepository.Get(GetCriteriaForPeriodCompletedEvents(periodId), null, null, e => e.Name).ToArray();

            return(allEventMilestones
                   .Where(eventMilestone =>
                          eventMilestone.GetDaysToBreachAt(_clock.TodayDate) != null &&
                          eventMilestone.GetDaysToBreachAt(_clock.TodayDate) <= ThreeDaysToBreach)
                   .Select(eventMilestone =>
            {
                var daysToBreachAt = eventMilestone.GetDaysToBreachAt(_clock.TodayDate);
                var eventBreachStatus = eventMilestone.BreachStatusAt(_clock.TodayDate);
                if (daysToBreachAt != null && eventBreachStatus != null)
                {
                    return new LiteEventBreachInfo
                    {
                        EventDescription = eventMilestone.Name.Description,
                        DaysForStatus = Math.Abs(daysToBreachAt.Value),
                        Status = eventBreachStatus.Value
                    };
                }
                return null;
            })
                   .Concat(allCompletedEvents.Select(completedEvent =>
                                                     new LiteEventBreachInfo
            {
                EventDescription = completedEvent.Name.Description,
                DaysForStatus = (int)completedEvent.PostBreachDays,
                Status = EventBreachStatus.Breached
            }))
                   .ToArray());
        }