Пример #1
0
        public static SummaryCategoryViewModel ConvertToIndexCategoryView(this ecom_Categories category)
        {
            SummaryCategoryViewModel categoryView = new SummaryCategoryViewModel()
            {
                Id = category.Id,
                Name = category.Name,
                SortOrder = category.SortOrder,
                Status = EnumHelper.GetDescriptionFromEnum((Define.Status)category.Status)
            };

            return categoryView;
        }
        protected override DataTemplate SelectTemplateCore(object item)
        {
            SummaryCategoryViewModel main = item as SummaryCategoryViewModel;

            if (main != null)
            {
                return(Category);
            }

            SummaryTotalViewModel summary = item as SummaryTotalViewModel;

            if (summary != null)
            {
                return(Total);
            }

            return(base.SelectTemplateCore(item));
        }
        public List <SummaryCategoryViewModel> GetSummaryCategories(string summaryType)
        {
            List <SummaryCategoryViewModel> result = new List <SummaryCategoryViewModel>();

            List <string> categoryNames = null;
            Dictionary <string, List <string> > summaryLabelMap = null;

            using (var summaryMappingManager = new SummaryMappingManager())
            {
                categoryNames   = summaryMappingManager.GetAllCategoryNamesBySummaryType(summaryType);
                summaryLabelMap = summaryMappingManager.GetSummaryLabelMapBySummaryType(summaryType);
            }

            if (categoryNames == null)
            {
                return(result);
            }

            foreach (var summaryCategoryName in categoryNames)
            {
                SummaryCategoryViewModel sumCategoryViewModel = new SummaryCategoryViewModel(summaryCategoryName);

                if (summaryCategoryName.Contains("Gastrointestinal Health"))
                {
                    sumCategoryViewModel.Highlight = true;
                }

                foreach (var summary in Participant.Summaries)
                {
                    if (summary != null && summary.PHSEventID.Equals(Event.PHSEventID))
                    {
                        if (SummaryHelper.IsFieldNameAndCategoryFoundInSummaryMap(summaryLabelMap, summaryCategoryName, summary.Label))
                        {
                            if (summary.SummaryValue == null || summary.SummaryValue.Count() <= 0)
                            {
                                continue;
                            }

                            SummaryViewModel sumview = new SummaryViewModel(summary);

                            if (sumCategoryViewModel.Highlight != true)
                            {
                                // summary.TemplateFieldID;
                                if (SummaryHelper.IsHighlightCategoryRequired(summaryCategoryName, summary.TemplateField.SummaryFieldName, summary.SummaryValue))
                                {
                                    sumCategoryViewModel.Highlight = true;
                                }
                            }


                            if (summary.StandardReferenceID != null && summary.StandardReferenceID > 0 &&
                                summary.SummaryValue != null)
                            {
                                if (SummaryHelper.IsJson(summary.SummaryValue))
                                {
                                    //if (summary.StandardReferenceID == 1) //Systolic Blood Pressure
                                    //{
                                    //    sumview.SummaryValue = summary.SummaryValue;
                                    //    sumview.SummaryInnerValue = summary.SummaryValue;
                                    //}else if (summary.StandardReferenceID == 2) //Diastolic Blood Pressure
                                    //{
                                    //        sumview.SummaryValue = summary.SummaryValue;
                                    //        sumview.SummaryInnerValue = summary.SummaryValue;
                                    //}else if (summary.StandardReferenceID == 3) //Sugar
                                    //{
                                    //    sumview.SummaryValue = summary.SummaryValue;
                                    //    sumview.SummaryInnerValue = summary.SummaryValue;
                                    //}else

                                    if (summary.StandardReferenceID == 4) //BMI
                                    {
                                        JavaScriptSerializer serializer = new JavaScriptSerializer();
                                        BMIViewModel         bmi        = serializer.Deserialize <BMIViewModel>(summary.SummaryValue as string);
                                        if (bmi.BodyMassIndex != null)
                                        {
                                            //Weight: 50, Height: 180, BodyMassIndex: 15.43  (UNDERWEIGHT)
                                            sumview.SummaryValue      = "Weight: " + bmi.Weight + ", Height: " + bmi.Height + ", BodyMassIndex: " + bmi.BodyMassIndex;
                                            sumview.SummaryInnerValue = bmi.BodyMassIndex;
                                        }
                                    }
                                }
                                else
                                {
                                    sumview.SummaryInnerValue = summary.SummaryValue;
                                }

                                ReferenceRange referenceRange = null;

                                using (var StandardReferenceManager = new StandardReferenceManager())
                                {
                                    string message = string.Empty;
                                    referenceRange = StandardReferenceManager.GetReferenceRange(summary.StandardReferenceID.GetValueOrDefault(),
                                                                                                sumview.SummaryInnerValue, out message);
                                }

                                if (referenceRange != null)
                                {
                                    sumview.Result    = referenceRange.Result;
                                    sumview.Highlight = referenceRange.Highlight;
                                }
                            }

                            if (sumview != null)
                            {
                                sumCategoryViewModel.AddSummary(sumview);
                            }
                        }
                    }
                }

                result.Add(sumCategoryViewModel);
            }

            return(result);
        }