Esempio n. 1
0
        private static decimal?GetMaxofthreeAortaValues(AAATestResult testResult)
        {
            var aortaValues = new decimal[3];
            int index       = 0;

            if (testResult.AortaSize != null && testResult.AortaSize.Reading != null)
            {
                aortaValues[index++] = testResult.AortaSize.Reading.Value;
            }

            if (testResult.TransverseView != null)
            {
                if (testResult.TransverseView.FirstValue != null && testResult.TransverseView.FirstValue.Reading != null)
                {
                    aortaValues[index++] = testResult.TransverseView.FirstValue.Reading.Value;
                }

                if (testResult.TransverseView.SecondValue != null && testResult.TransverseView.SecondValue.Reading != null)
                {
                    aortaValues[index++] = testResult.TransverseView.SecondValue.Reading.Value;
                }
            }

            var aortaValue = aortaValues.Max();

            if (aortaValue > 0)
            {
                return(aortaValue);
            }

            return(null);
        }
Esempio n. 2
0
        public TestResult Parse()
        {
            _errorSummary = string.Empty;

            var testResult = new AAATestResult();
            var xDoc       = XDocument.Load(_pathToReportXmlFile);

            testResult.AortaSize = GetAaaAortaValues(xDoc);

            var aortaValue = testResult.AortaSize != null ? testResult.AortaSize.Reading : null;

            if (aortaValue != null)
            {
                testResult.Finding =
                    new StandardFinding <decimal?>(_testResultService.GetCalculatedStandardFinding(aortaValue.Value, (int)TestType.AAA, (int)ReadingLabels.AortaSize));
            }

            bool isExceptionCaused;

            testResult.ResultImages = _mediaHelper.GetMediaforTest(Directory.GetParent(_pathToReportXmlFile).Parent.FullName, _mediaLocation, TestType.AAA.ToString(), out isExceptionCaused).ToList();

            if (isExceptionCaused)
            {
                _errorSummary += "Media Extraction Failed. ";
            }

            if (testResult.AortaSize == null && (testResult.ResultImages.Count() < 1))
            {
                return(null);
            }

            return(testResult);
        }
Esempio n. 3
0
        public AAATestResult MapXmlToDomainObject(string filePathtoXml)
        {
            var testResult = new AAATestResult();
            var xDoc       = XDocument.Load(filePathtoXml);

            GetAaaSaggitalView(testResult, xDoc);

            GetAaaTransverseViewValues(testResult, xDoc);

            var aortaValue = GetMaxofthreeAortaValues(testResult);

            if (aortaValue != null)
            {
                testResult.Finding =
                    new StandardFinding <decimal?>(_testResultService.GetCalculatedStandardFinding(aortaValue.Value, (int)TestType.AAA, (int)ReadingLabels.AortaSize));
            }

            bool isExceptionCaused;

            testResult.ResultImages = _mediaHelper.GetMediaforTest(Directory.GetParent(filePathtoXml).Parent.FullName, _mediaLocation, TestType.AAA.ToString(), out isExceptionCaused).ToList();

            if (isExceptionCaused)
            {
                _errorSummary += "Media Extraction Failed. ";
            }

            return(testResult);
        }
Esempio n. 4
0
        private void GetAaaSaggitalView(AAATestResult testResult, XDocument xDoc)
        {
            try
            {
                var aoProxSag = GetValuefromXmlDoc(xDoc, ViewLocProx, ViewtypeSag);
                var aoMidSag  = GetValuefromXmlDoc(xDoc, ViewLocMid, ViewtypeSag);
                var aoDistSag = GetValuefromXmlDoc(xDoc, ViewLocDist, ViewtypeSag);

                if (aoProxSag != null || aoMidSag != null || aoDistSag != null)
                {
                    IEnumerable <string> viewLocs;
                    var aortaValue = GetMaximumOfThree(aoProxSag ?? 0, aoMidSag ?? 0, aoDistSag ?? 0, out viewLocs);

                    if (aortaValue != null)
                    {
                        if (_aaaReadings.Where(r => r.Label == ReadingLabels.AortaSize).Count() > 0)
                        {
                            testResult.AortaSize = new ResultReading <decimal?>(ReadingLabels.AortaSize)
                            {
                                Reading       = Decimal.Round(aortaValue.Value, 2),
                                ReadingSource = ReadingSource.Automatic
                            };
                        }

                        if (viewLocs != null && viewLocs.Count() > 0 && _aaaReadings.Where(r => r.Label == ReadingLabels.AortaRangeSaggitalView).Count() > 0)
                        {
                            var sagViewFindings = _testResultService.GetAllStandardFindings <int>((int)TestType.AAA, (int)ReadingLabels.AortaRangeSaggitalView);

                            testResult.AortaRangeSaggitalView = new List <StandardFinding <int> >();
                            foreach (string viewLoc in viewLocs)
                            {
                                var finding = sagViewFindings.Where(s => s.Label.ToLower().Contains(viewLoc)).SingleOrDefault();
                                if (finding != null)
                                {
                                    testResult.AortaRangeSaggitalView.Add(finding);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _errorSummary += "Measurement for Saggital View could not be extracted. ";
                _logger.Error("\n Measurement for Saggital View could not be extracted. Error: " + ex.Message + "\n\t\t" + ex.StackTrace);
            }
        }
Esempio n. 5
0
        private void GetSaggitalView(AAATestResult testResult, DataTable dtSourceFromExcel)
        {
            try
            {
                decimal?aoDistal = GetAortaValueforSaggital(dtSourceFromExcel, ConstForDist);
                decimal?aoProx   = GetAortaValueforSaggital(dtSourceFromExcel, ConstForProx);
                decimal?aoMid    = GetAortaValueforSaggital(dtSourceFromExcel, ConstForMid);

                if (aoDistal == null && aoMid == null && aoProx == null)
                {
                    _logger.Info("\n\tData for Saggital view not found.");
                    return;
                }

                IEnumerable <string> viewLocs = null;
                var value = GetMaximumOfThree(aoProx ?? 0, aoMid ?? 0, aoDistal ?? 0, out viewLocs);

                if (value == null || viewLocs == null || viewLocs.Count() < 1)
                {
                    return;
                }

                testResult.AortaSize = new ResultReading <decimal?>(ReadingLabels.AortaSize)
                {
                    Reading       = Decimal.Round(value.Value, 2),
                    ReadingSource = ReadingSource.Automatic
                };

                var sagViewFindings = _testResultService.GetAllStandardFindings <int>((int)TestType.AAA, (int)ReadingLabels.AortaRangeSaggitalView);
                testResult.AortaRangeSaggitalView = new List <StandardFinding <int> >();
                foreach (string viewLoc in viewLocs)
                {
                    var finding =
                        sagViewFindings.Where(s => s.Label.ToLower().Contains(viewLoc)).SingleOrDefault();
                    if (finding != null)
                    {
                        testResult.AortaRangeSaggitalView.Add(finding);
                    }
                }
            }
            catch (Exception ex)
            {
                _errorSummary += "Measurement for Saggital View could not be extracted. ";
                _logger.Error("\n Measurement for Saggital View could not be extracted. Error: " + ex.Message + "\n\t\t" + ex.StackTrace);
            }
        }
Esempio n. 6
0
        public TestResult Parse(DataTable dtSourceFromExcel)
        {
            var testResult = new AAATestResult();

            if (dtSourceFromExcel != null)
            {
                var isContainAllColNeededForReadings = CheckifDatatableisValidfortheTestType(dtSourceFromExcel);

                if (isContainAllColNeededForReadings)
                {
                    GetSaggitalView(testResult, dtSourceFromExcel);
                    GetTransverseView(testResult, dtSourceFromExcel);

                    if (testResult.AortaSize != null || testResult.TransverseView != null)
                    {
                        var aortaValue = GetMaxofthreeAortaValues(testResult);
                        if (aortaValue != null)
                        {
                            testResult.Finding =
                                new StandardFinding <decimal?>(
                                    _testResultService.GetCalculatedStandardFinding(aortaValue.Value, (int)TestType.AAA,
                                                                                    (int)ReadingLabels.AortaSize));
                        }
                    }
                }
            }

            testResult.ResultImages = new List <ResultMedia>();
            foreach (var path in _pathToMediaFolder)
            {
                var media = GetMediaforTest(path);
                if (media != null)
                {
                    testResult.ResultImages.AddRange(media);
                }
            }

            if (testResult.AortaSize == null && testResult.TransverseView == null && testResult.ResultImages.Count < 1)
            {
                return(null);
            }

            return(testResult);
        }
Esempio n. 7
0
        private void GetAaaTransverseViewValues(AAATestResult testResult, XDocument xDoc)
        {
            try
            {
                var aoProxTran1 = GetValuefromXmlDoc(xDoc, ViewLocProx, ViewtypeTran, "1");
                var aoMidTran1  = GetValuefromXmlDoc(xDoc, ViewLocMid, ViewtypeTran, "1");
                var aoDistTran1 = GetValuefromXmlDoc(xDoc, ViewLocDist, ViewtypeTran, "1");

                var aoProxTran2 = GetValuefromXmlDoc(xDoc, ViewLocProx, ViewtypeTran, "2");
                var aoMidTran2  = GetValuefromXmlDoc(xDoc, ViewLocMid, ViewtypeTran, "2");
                var aoDistTran2 = GetValuefromXmlDoc(xDoc, ViewLocDist, ViewtypeTran, "2");

                IEnumerable <string> viewLocs1, viewLocs2, viewLocs;
                decimal?aortaValue1, aortaValue2, aortaValue;
                aortaValue1 = aortaValue2 = null;
                viewLocs1   = viewLocs2 = null;

                if (aoProxTran1 != null || aoMidTran1 != null || aoDistTran1 != null)
                {
                    aortaValue1 = GetMaximumOfThree(aoProxTran1 ?? 0, aoMidTran1 ?? 0, aoDistTran1 ?? 0, out viewLocs1);
                }

                if (aoProxTran2 != null || aoMidTran2 != null || aoDistTran2 != null)
                {
                    aortaValue2 = GetMaximumOfThree(aoProxTran2 ?? 0, aoMidTran2 ?? 0, aoDistTran2 ?? 0, out viewLocs2);
                }

                if (aortaValue1 != null || aortaValue2 != null)
                {
                    if ((aortaValue1 ?? 0) > (aortaValue2 ?? 0))
                    {
                        aortaValue = aortaValue1;
                        viewLocs   = viewLocs1;
                    }
                    else
                    {
                        aortaValue = aortaValue2;
                        viewLocs   = viewLocs2;
                    }

                    if (aortaValue != null)
                    {
                        testResult.TransverseView = new OrderedPair <ResultReading <decimal?>, ResultReading <decimal?> >();

                        if (_aaaReadings.Where(r => r.Label == ReadingLabels.TransverseViewDataPointOne).Count() > 0)
                        {
                            testResult.TransverseView.FirstValue =
                                new ResultReading <decimal?>(ReadingLabels.TransverseViewDataPointOne)
                            {
                                ReadingSource = ReadingSource.Automatic
                            };
                        }

                        if (_aaaReadings.Where(r => r.Label == ReadingLabels.TransverseViewDataPointTwo).Count() > 0)
                        {
                            testResult.TransverseView.SecondValue =
                                new ResultReading <decimal?>(ReadingLabels.TransverseViewDataPointTwo)
                            {
                                ReadingSource = ReadingSource.Automatic
                            };
                        }
                    }

                    if (viewLocs != null && viewLocs.Count() > 0)
                    {
                        if (viewLocs.ElementAt(0) == ViewLocProx)
                        {
                            testResult.TransverseView.FirstValue.Reading  = aoProxTran1.HasValue ? (decimal?)decimal.Round(aoProxTran1.Value, 2) : null;
                            testResult.TransverseView.SecondValue.Reading = aoProxTran2.HasValue ? (decimal?)decimal.Round(aoProxTran2.Value, 2) : null;
                        }
                        else if (viewLocs.ElementAt(0) == ViewLocDist)
                        {
                            testResult.TransverseView.FirstValue.Reading  = aoDistTran1.HasValue ? (decimal?)decimal.Round(aoDistTran1.Value, 2) : null;
                            testResult.TransverseView.SecondValue.Reading = aoDistTran2.HasValue ? (decimal?)decimal.Round(aoDistTran2.Value, 2) : null;
                        }
                        else if (viewLocs.ElementAt(0) == ViewLocMid)
                        {
                            testResult.TransverseView.FirstValue.Reading  = aoMidTran1.HasValue ? (decimal?)decimal.Round(aoMidTran1.Value, 2) : null;
                            testResult.TransverseView.SecondValue.Reading = aoMidTran2.HasValue ? (decimal?)decimal.Round(aoMidTran2.Value, 2) : null;
                        }

                        if (_aaaReadings.Where(r => r.Label == ReadingLabels.AortaRangeTransverseView).Count() > 0)
                        {
                            var transViewFindings = _testResultService.GetAllStandardFindings <int>((int)TestType.AAA, (int)ReadingLabels.AortaRangeTransverseView);
                            testResult.AortaRangeTransverseView = new List <StandardFinding <int> >();

                            foreach (string viewLoc in viewLocs)
                            {
                                var finding =
                                    transViewFindings.Where(s => s.Label.ToLower().Contains(viewLoc)).SingleOrDefault();
                                if (finding != null)
                                {
                                    testResult.AortaRangeTransverseView.Add(finding);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _errorSummary += "Datapoints for Transverse View could not be extracted. ";
                _logger.Error("\n Datapoints for Transverse View could not be extracted." + ex.Message + "\n\t\t" + ex.StackTrace);
            }
        }
Esempio n. 8
0
        private void GetTransverseView(AAATestResult testResult, DataTable dtSourceFromExcel)
        {
            try
            {
                var aoDistalOp = GetAortaValueforTransverse(dtSourceFromExcel, ConstForDist);
                var aoProxOp   = GetAortaValueforTransverse(dtSourceFromExcel, ConstForProx);
                var aoMidOp    = GetAortaValueforTransverse(dtSourceFromExcel, ConstForMid);

                var aoDisDp1  = aoDistalOp != null ? aoDistalOp.FirstValue : null;
                var aoMidDp1  = aoMidOp != null ? aoMidOp.FirstValue : null;
                var aoProxDp1 = aoProxOp != null ? aoProxOp.FirstValue : null;

                var aoDisDp2  = aoDistalOp != null ? aoDistalOp.SecondValue : null;
                var aoMidDp2  = aoMidOp != null ? aoMidOp.SecondValue : null;
                var aoProxDp2 = aoProxOp != null ? aoProxOp.SecondValue : null;

                decimal?valueDp1, valueDp2;
                IEnumerable <string> viewLocsDp1 = null;
                IEnumerable <string> viewLocsDp2 = null;
                valueDp2 = valueDp1 = null;

                IEnumerable <string> viewLocs;

                if (!(aoDisDp1 == null && aoMidDp1 == null && aoProxDp1 == null))
                {
                    valueDp1 = GetMaximumOfThree(aoProxDp1 ?? 0, aoMidDp1 ?? 0, aoDisDp1 ?? 0, out viewLocsDp1);
                }

                if (!(aoDisDp2 == null && aoMidDp2 == null && aoProxDp2 == null))
                {
                    valueDp2 = GetMaximumOfThree(aoProxDp2 ?? 0, aoMidDp2 ?? 0, aoDisDp2 ?? 0, out viewLocsDp2);
                }

                if (valueDp1 == null && valueDp2 == null)
                {
                    _logger.Info("\n\tData for Transverse view not found.");
                    return;
                }

                viewLocs = (valueDp1 ?? 0) > (valueDp2 ?? 0) ? viewLocsDp1 : viewLocsDp2;

                testResult.TransverseView = new OrderedPair <ResultReading <decimal?>, ResultReading <decimal?> >
                {
                    FirstValue =
                        new ResultReading <decimal?>(ReadingLabels.TransverseViewDataPointOne)
                    {
                        ReadingSource = ReadingSource.Automatic
                    },
                    SecondValue =
                        new ResultReading <decimal?>(ReadingLabels.TransverseViewDataPointTwo)
                    {
                        ReadingSource = ReadingSource.Automatic
                    }
                };

                if (viewLocs.ElementAt(0) == ViewLocProx)
                {
                    if (aoProxDp1 != null)
                    {
                        testResult.TransverseView.FirstValue.Reading = Decimal.Round(aoProxDp1.Value, 2);
                    }
                    else
                    {
                        testResult.TransverseView.FirstValue = null;
                    }

                    if (aoProxDp2 != null)
                    {
                        testResult.TransverseView.SecondValue.Reading = Decimal.Round(aoProxDp2.Value, 2);
                    }
                    else
                    {
                        testResult.TransverseView.SecondValue = null;
                    }
                }
                else if (viewLocs.ElementAt(0) == ViewLocDist)
                {
                    if (aoDisDp1 != null)
                    {
                        testResult.TransverseView.FirstValue.Reading = Decimal.Round(aoDisDp1.Value, 2);
                    }
                    else
                    {
                        testResult.TransverseView.FirstValue = null;
                    }

                    if (aoDisDp2 != null)
                    {
                        testResult.TransverseView.SecondValue.Reading = Decimal.Round(aoDisDp2.Value, 2);
                    }
                    else
                    {
                        testResult.TransverseView.SecondValue = null;
                    }
                }
                else if (viewLocs.ElementAt(0) == ViewLocMid)
                {
                    if (aoMidDp1 != null)
                    {
                        testResult.TransverseView.FirstValue.Reading = Decimal.Round(aoMidDp1.Value, 2);
                    }
                    else
                    {
                        testResult.TransverseView.FirstValue = null;
                    }

                    if (aoMidDp2 != null)
                    {
                        testResult.TransverseView.SecondValue.Reading = Decimal.Round(aoMidDp2.Value, 2);
                    }
                    else
                    {
                        testResult.TransverseView.SecondValue = null;
                    }
                }

                var transViewFindings = _testResultService.GetAllStandardFindings <int>((int)TestType.AAA, (int)ReadingLabels.AortaRangeTransverseView);
                testResult.AortaRangeTransverseView = new List <StandardFinding <int> >();

                foreach (string viewLoc in viewLocs)
                {
                    var finding =
                        transViewFindings.Where(s => s.Label.ToLower().Contains(viewLoc)).SingleOrDefault();
                    if (finding != null)
                    {
                        testResult.AortaRangeTransverseView.Add(finding);
                    }
                }
            }
            catch (Exception ex)
            {
                _errorSummary += "Datapoints for Transverse View could not be extracted. ";
                _logger.Error("\n Datapoints for Transverse View could not be extracted. Error: " + ex.Message + "\n\t\t" + ex.StackTrace);
            }
        }
        private void GetDataImportedtoSystem(long customerId, IEnumerable <string> allImageFiles, IEnumerable <string> allXmlFiles)
        {
            bool strokeFound = false;
            bool aaaFound    = false;

            var aaaPurchased    = _testResultService.IsTestPurchasedByCustomer(_eventId, customerId, (long)TestType.AAA);
            var strokePurchased = _testResultService.IsTestPurchasedByCustomer(_eventId, customerId, (long)TestType.Stroke);

            var mediaLocation = _mediaRepository.GetResultMediaFileLocation(customerId, _eventId).PhysicalPath;

            var aaaTestResult = new AAATestResult
            {
                ResultImages = new List <ResultMedia>()
            };

            var strokeTestResult = new StrokeTestResult
            {
                ResultImages = new List <ResultMedia>()
            };

            foreach (var imageFile in allImageFiles)
            {
                var    fileName  = Path.GetFileNameWithoutExtension(imageFile);
                string imageType = string.Empty;
                string xmlFile   = "";

                if (allXmlFiles.Count() == 0)
                {
                    if (strokePurchased)
                    {
                        imageType = StrokeImageIdentifier;
                    }
                    else if (aaaPurchased)
                    {
                        imageType = AaaImageIdentifier;
                    }
                }
                else
                {
                    var startIndex = fileName.IndexOf("[");
                    var endIndex   = fileName.IndexOf("]");

                    if (startIndex < 0 || endIndex < 0)
                    {
                        continue;
                    }

                    var identifier = fileName.Substring(startIndex + 1, endIndex - (startIndex + 1)).ToLower();
                    xmlFile = allXmlFiles.Where(f => Path.GetFileNameWithoutExtension(f).ToLower().Contains(identifier)).SingleOrDefault();
                    if (string.IsNullOrEmpty(xmlFile))
                    {
                        continue;
                    }

                    imageType = GetImageTypefromXmlFile(xmlFile);
                }

                if (string.IsNullOrEmpty(imageType))
                {
                    continue;
                }

                imageType = imageType.ToLower();

                if (imageType == AaaImageIdentifier)
                {
                    aaaFound = true;
                    if (!aaaPurchased)
                    {
                        continue;
                    }

                    var resultMedia = _mediaHelper.GetfromImageFile(new FileInfo(imageFile), "Aaa", mediaLocation);
                    aaaTestResult.ResultImages.Add(resultMedia);
                }
                else if (imageType == StrokeImageIdentifier)
                {
                    strokeFound = true;
                    if (!strokePurchased)
                    {
                        continue;
                    }

                    var resultMedia = _mediaHelper.GetfromImageFile(new FileInfo(imageFile), "Stroke", mediaLocation);
                    strokeTestResult.ResultImages.Add(resultMedia);
                }
                else
                {
                    _logger.Info(string.Format("Invalid Image Identifier = [{0}] from XML = [{1}].", imageType, xmlFile));
                }
            }

            if (!aaaPurchased && aaaFound)
            {
                _logger.Info(string.Format("AAA not purchased by Customer [{0}], but files are found.", customerId));
            }
            else if (aaaPurchased && aaaFound)
            {
                _resultParserHelper.AddTestResulttoEventCustomerAggregate(_eventCustomerScreeningAggregates, _eventId, customerId, aaaTestResult);
                _resultParserHelper.AddResultArchiveLog(string.Empty, TestType.AAA, customerId, MedicalEquipmentTag.UltrasoundTransducer);
            }
            else if (aaaPurchased)
            {
                _resultParserHelper.AddResultArchiveLog(string.Empty, TestType.AAA, customerId, MedicalEquipmentTag.UltrasoundTransducer, false);
            }

            if (!strokePurchased && strokeFound)
            {
                _logger.Info(string.Format("Stroke not purchased by Customer [{0}], but files are found.", customerId));
            }
            else if (strokePurchased && strokeFound)
            {
                _resultParserHelper.AddTestResulttoEventCustomerAggregate(_eventCustomerScreeningAggregates, _eventId, customerId, strokeTestResult);
                _resultParserHelper.AddResultArchiveLog(string.Empty, TestType.Stroke, customerId, MedicalEquipmentTag.UltrasoundTransducer);
            }
            else if (strokePurchased)
            {
                _resultParserHelper.AddResultArchiveLog(string.Empty, TestType.Stroke, customerId, MedicalEquipmentTag.UltrasoundTransducer, false);
            }
        }
Esempio n. 10
0
        public override TestResult CreateActualTestResult(CustomerEventScreeningTestsEntity customerEventScreeningTestsEntity)
        {
            var customerEventReadingEntities = customerEventScreeningTestsEntity.CustomerEventReading.ToList();
            var testResult = new AAATestResult(customerEventScreeningTestsEntity.CustomerEventScreeningTestId);

            var customerEventTestStandardFindingEntities = customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.ToList();
            var standardFindingTestReadingEntities       = customerEventScreeningTestsEntity.StandardFindingTestReadingCollectionViaCustomerEventReading.ToList();

            standardFindingTestReadingEntities.AddRange(customerEventScreeningTestsEntity.StandardFindingTestReadingCollectionViaCustomerEventTestStandardFinding.ToList());

            testResult.AortaSize = CreateResultReadingforNullableDecimal((int)ReadingLabels.AortaSize, customerEventReadingEntities);

            testResult.TransverseView             = new OrderedPair <ResultReading <decimal?>, ResultReading <decimal?> >(null, null);
            testResult.TransverseView.FirstValue  = CreateResultReadingforNullableDecimal((int)ReadingLabels.TransverseViewDataPointOne, customerEventReadingEntities);
            testResult.TransverseView.SecondValue = CreateResultReadingforNullableDecimal((int)ReadingLabels.TransverseViewDataPointTwo, customerEventReadingEntities);

            testResult.ConsiderOtherModalities = CreateResultReading((int)ReadingLabels.ConsiderOtherModalities, customerEventReadingEntities);
            testResult.AdditionalImagesNeeded  = CreateResultReading((int)ReadingLabels.AdditionalImagesNeeded, customerEventReadingEntities);
            if (!((testResult.ConsiderOtherModalities != null && testResult.ConsiderOtherModalities.Reading) ||
                  (testResult.AdditionalImagesNeeded != null && testResult.AdditionalImagesNeeded.Reading)))
            {
                var aortaValue = GetMaxofthreeAortaValues(testResult);
                if (aortaValue != null)
                {
                    testResult.Finding = new StandardFinding <decimal?>(Convert.ToInt64((new TestResultService()).GetCalculatedStandardFinding(aortaValue, (int)TestType.AAA, (int)ReadingLabels.AortaSize)));
                }
            }

            if (testResult.Finding != null)
            {
                testResult.Finding = new TestResultService().GetAllStandardFindings <decimal?>((int)TestType.AAA, (int)ReadingLabels.AortaSize).Find(standardFinding => standardFinding.Id == testResult.Finding.Id);
            }

            testResult.Fusiform         = CreateResultReadingforNullableBool((int)ReadingLabels.IsFusiform, customerEventReadingEntities);
            testResult.Saccular         = CreateResultReadingforNullableBool((int)ReadingLabels.IsSaccular, customerEventReadingEntities);
            testResult.AorticDissection = CreateResultReading((int)ReadingLabels.AorticDissection, customerEventReadingEntities);
            testResult.Plaque           = CreateResultReading((int)ReadingLabels.Plaque, customerEventReadingEntities);
            testResult.Thrombus         = CreateResultReading((int)ReadingLabels.Thrombus, customerEventReadingEntities);
            testResult.TechnicallyLimitedbutReadable = CreateResultReading((int)ReadingLabels.TechnicallyLimitedbutReadable, customerEventReadingEntities);
            testResult.RepeatStudy = CreateResultReading((int)ReadingLabels.RepeatStudy, customerEventReadingEntities);

            var testResultService = new TestResultService();
            var aortaRangeSaggitalViewFindings   = testResultService.GetAllStandardFindings <int?>((int)TestType.AAA, (int)ReadingLabels.AortaRangeSaggitalView);
            var aortaRangeTransverseViewFindings = testResultService.GetAllStandardFindings <int?>((int)TestType.AAA, (int)ReadingLabels.AortaRangeTransverseView);
            var aortaValueFindings = testResultService.GetAllStandardFindings <int?>((int)TestType.AAA, (int)ReadingLabels.AortaSize);

            customerEventTestStandardFindingEntities.ForEach(customerEventTestStandardFindingEntity =>
            {
                var standardFindingTestReadingEntity = standardFindingTestReadingEntities.Find(entity => entity.StandardFindingTestReadingId == customerEventTestStandardFindingEntity.StandardFindingTestReadingId);
                if (standardFindingTestReadingEntity == null)
                {
                    return;
                }

                var finding = CreateFindingObject(customerEventTestStandardFindingEntity, aortaRangeSaggitalViewFindings, standardFindingTestReadingEntity, (int?)ReadingLabels.AortaRangeSaggitalView);
                if (finding != null)
                {
                    if (testResult.AortaRangeSaggitalView == null)
                    {
                        testResult.AortaRangeSaggitalView = new List <StandardFinding <int> >();
                    }
                    testResult.AortaRangeSaggitalView.Add(finding); return;
                }

                finding = CreateFindingObject(customerEventTestStandardFindingEntity, aortaRangeTransverseViewFindings, standardFindingTestReadingEntity, (int?)ReadingLabels.AortaRangeTransverseView);
                if (finding != null)
                {
                    if (testResult.AortaRangeTransverseView == null)
                    {
                        testResult.AortaRangeTransverseView = new List <StandardFinding <int> >();
                    }
                    testResult.AortaRangeTransverseView.Add(finding); return;
                }

                finding = CreateFindingObject(customerEventTestStandardFindingEntity, aortaValueFindings, standardFindingTestReadingEntity, (int?)ReadingLabels.AortaSize);
                if (finding != null)
                {
                    testResult.Finding = new StandardFinding <decimal?>(finding.Id)
                    {
                        CustomerEventStandardFindingId = finding.CustomerEventStandardFindingId,
                        Label       = finding.Label,
                        Description = finding.Description
                    };
                    return;
                }
            });

            var testMediaCollection  = customerEventScreeningTestsEntity.TestMedia.ToList();
            var fileEntityCollection = customerEventScreeningTestsEntity.FileCollectionViaTestMedia.ToList();

            if (testMediaCollection.Count > 0)
            {
                var resultMedia = new List <ResultMedia>();
                testMediaCollection.ForEach(testMedia => resultMedia.Add(new ResultMedia(testMedia.MediaId)
                {
                    File          = GetFileObjectfromEntity(testMedia.FileId, fileEntityCollection),
                    Thumbnail     = testMedia.ThumbnailFileId != null ? new File(testMedia.ThumbnailFileId.Value) : null,
                    ReadingSource = testMedia.IsManual ? ReadingSource.Manual : ReadingSource.Automatic
                }));

                testResult.ResultImages = resultMedia;
            }
            return(testResult);
        }