Exemplo n.º 1
0
        public ActionResult GetReferenceRange(int standardReferenceId, string value)
        {
            string message = string.Empty;

            using (var stdReferenceManager = new StandardReferenceManager())
            {
                var referenceRange = stdReferenceManager.GetReferenceRange(standardReferenceId, value, out message);

                if (referenceRange == null)
                {
                    Response.StatusCode = (int)HttpStatusCode.BadRequest;
                    return(Json(new { Error = message }));
                }

                return(Json(new { Status = referenceRange.Result, Highlight = referenceRange.Highlight }));
            }
        }
        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);
        }