public PhysicianReviewSummaryListModel Create(IEnumerable <long> physicianIds, IEnumerable <OrderedPair <long, string> > physiciansIdNamePair, IEnumerable <OrderedPair <long, int> > physicianIdReviewCountPair,
                                                      IEnumerable <OrderedPair <long, int> > physicianIdOverReadsCountPair, IEnumerable <OrderedPair <long, int> > physicianIdAvailableEvalutionCountPair, IEnumerable <OrderedPair <long, int> > physicianIdAvaliableOverReadCountPair,
                                                      IEnumerable <OrderedPair <long, double> > physicianIdAverageReviewTimePair, IEnumerable <OrderedPair <long, int> > physicianIdReEvaluationCountPair, IEnumerable <OrderedPair <long, int> > physicianIdReOverReadsCountPair,
                                                      IEnumerable <OrderedPair <long, int> > physicianIdPriorityEvalutionCountPair, IEnumerable <OrderedPair <long, int> > physicianIdPriorityOverReadCountPair)
        {
            var model = new PhysicianReviewSummaryListModel();

            var physicianReviews = new List <PhysicianReviewSummaryViewModel>();

            physicianIds.ToList().ForEach(pid =>
            {
                var physicianName = physiciansIdNamePair.Where(p => p.FirstValue == pid).First().SecondValue;

                var reviewCount = physicianIdReviewCountPair.Where(prc => prc.FirstValue == pid).First().SecondValue;

                var reReviewCount = physicianIdReEvaluationCountPair.Where(prc => prc.FirstValue == pid).Select(prc => prc.SecondValue).FirstOrDefault();

                var overReadCount = physicianIdOverReadsCountPair.Where(poc => poc.FirstValue == pid).First().SecondValue;

                var reOverReadCount = physicianIdReOverReadsCountPair.Where(prc => prc.FirstValue == pid).Select(prc => prc.SecondValue).FirstOrDefault();

                var availableEvaluationCount = physicianIdAvailableEvalutionCountPair.Where(pae => pae.FirstValue == pid).First().SecondValue;

                var availableOverReadCount = physicianIdAvaliableOverReadCountPair.Where(pao => pao.FirstValue == pid).First().SecondValue;

                var priorityEvaluationCount = physicianIdPriorityEvalutionCountPair.First(pae => pae.FirstValue == pid).SecondValue;

                var priorityOverReadCount = physicianIdPriorityOverReadCountPair.First(pao => pao.FirstValue == pid).SecondValue;

                var averageReviewTimePair =
                    physicianIdAverageReviewTimePair.Where(
                        art => art.FirstValue == pid).FirstOrDefault();
                var averageReviewTime = averageReviewTimePair != null
                                                                              ? TimeSpan.FromSeconds(
                    averageReviewTimePair.SecondValue)
                                                                              : TimeSpan.FromSeconds(0);
                physicianReviews.Add(new PhysicianReviewSummaryViewModel
                {
                    PhysicianId                       = pid,
                    PhysicianName                     = physicianName,
                    TotalReviews                      = reviewCount + reReviewCount,
                    Reviews                           = reviewCount,
                    ReReviews                         = reReviewCount,
                    OverReads                         = overReadCount,
                    ReOverReads                       = reOverReadCount,
                    TotalOverReads                    = overReadCount + reOverReadCount,
                    PrimaryEvaluationInQueue          = availableEvaluationCount,
                    OverReadEvaluationInQueue         = availableOverReadCount,
                    PrimaryEvaluationPriorityInQueue  = priorityEvaluationCount,
                    OverReadEvaluationPriorityInQueue = priorityOverReadCount,
                    AverageReviewTime                 = string.Format("{0:D2}min {1:D2}sec", averageReviewTime.Minutes, averageReviewTime.Seconds)
                });
            });
            model.Collection = physicianReviews;

            return(model);
        }
Esempio n. 2
0
        public ActionResult PhysicianReviewSummary(PhysicianReviewSummaryListModelFilter filter = null, int pageNumber = 1)
        {
            var filterValidator = IoC.Resolve <PhysicianReviewSummaryListModelFilterValidator>();
            var result          = filterValidator.Validate(filter);

            if (result.IsValid)
            {
                int totalRecords = 0;

                var model = _physicianEvaluationService.GetPhysicianReviewSummary(pageNumber, _pageSize, filter,
                                                                                  out totalRecords);
                if (model == null)
                {
                    model = new PhysicianReviewSummaryListModel();
                }
                model.Filter = filter;

                var currentAction = ControllerContext.RouteData.Values["action"].ToString();

                Func <int, string> urlFunc =
                    pn => Url.Action(currentAction, new
                {
                    pageNumber = pn,
                    filter.EventId,
                    filter.FromDate,
                    filter.ToDate,
                    filter.DateType,
                    filter.PodId,
                    filter.IsRetailEvent,
                    filter.IsCorporateEvent,
                    filter.IsPublicEvent,
                    filter.IsPrivateEvent
                });
                model.PagingModel = new PagingModel(pageNumber, _pageSize, totalRecords, urlFunc);
                return(View(model));
            }

            var propertyNames = result.Errors.Select(e => e.PropertyName).Distinct();
            var htmlString    = propertyNames.Aggregate("", (current, property) => current + (result.Errors.Where(e => e.PropertyName == property).FirstOrDefault().ErrorMessage + "<br />"));

            return(View(new PhysicianReviewSummaryListModel {
                Filter = filter, FeedbackMessage = FeedbackMessageModel.CreateFailureMessage(htmlString)
            }));
        }