Exemplo n.º 1
0
        private static decimal?GetMaxofthreeAortaValues(PpAaaTestResult 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);
        }
Exemplo n.º 2
0
        public PpAaaTestResult MapXmlToDomainObject(string filePathtoXml)
        {
            var testResult = new PpAaaTestResult();
            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.PPAAA, (int)ReadingLabels.AortaSize));
            }

            bool isExceptionCaused;

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

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

            return(testResult);
        }
Exemplo n.º 3
0
        private void GetAaaSaggitalView(PpAaaTestResult 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.PPAAA, (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);
            }
        }
        public PhysicianPartnerResultExportModel SetAaaData(PhysicianPartnerResultExportModel model, PpAaaTestResult testResult)
        {
            if (testResult.Finding != null)
            {
                model.AaaResult = testResult.Finding.Label;
            }

            model.AaaLargestSagittalMeasurement = testResult.AortaSize != null ? testResult.AortaSize.Reading != null?testResult.AortaSize.Reading.ToString() : "" : "";

            model.AaaLargestSagittalLocation = string.Join(",", testResult.AortaRangeSaggitalView != null ? testResult.AortaRangeSaggitalView.Select(s => s.Label).ToArray() : new[] { "" });


            model.AaaLargestTransverseMeasurement1 = testResult.TransverseView != null ? testResult.TransverseView.FirstValue != null?testResult.TransverseView.FirstValue.Reading.ToString() : "" : "";

            model.AaaLargestTransverseMeasurement2 = testResult.TransverseView != null ? testResult.TransverseView.SecondValue != null?testResult.TransverseView.SecondValue.Reading.ToString() : "" : "";


            model.AaaLargestMeasurementTransverseLocation = string.Join(",", testResult.AortaRangeTransverseView != null ? testResult.AortaRangeTransverseView.Select(s => s.Label).ToArray() : new[] { "" });


            model.AaaAorticDissection = testResult.AorticDissection != null ? PhysicianPartnerResultExportHelper.YesString : PhysicianPartnerResultExportHelper.NoString;

            model.AaaPlaque = testResult.Plaque != null ? PhysicianPartnerResultExportHelper.YesString : PhysicianPartnerResultExportHelper.NoString;

            model.AaaThrombus = testResult.Thrombus != null ? PhysicianPartnerResultExportHelper.YesString : PhysicianPartnerResultExportHelper.NoString;

            if (testResult.IncidentalFindings != null && testResult.IncidentalFindings.Count > 0)
            {
                model.AaaAorticStenosis = PhysicianPartnerResultExportHelper.YesString;
            }
            else
            {
                model.AaaAorticStenosis = PhysicianPartnerResultExportHelper.NoString;
            }

            model.AaaTechnicallyLimitedButReadable = PhysicianPartnerResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.TechnicallyLimitedbutReadable);
            model.AaaRepeatStudyUnreadable         = PhysicianPartnerResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.RepeatStudy);

            model.AaaUnabletoScreen = testResult.UnableScreenReason != null && testResult.UnableScreenReason.Count > 0 ? PhysicianPartnerResultExportHelper.YesString : PhysicianPartnerResultExportHelper.NoString;

            if ((testResult.ResultStatus != null && testResult.ResultStatus.SelfPresent) || (testResult.PhysicianInterpretation != null && testResult.PhysicianInterpretation.IsCritical))
            {
                model.AaaCritical = PhysicianPartnerResultExportHelper.YesString;
            }
            else
            {
                model.AaaCritical = PhysicianPartnerResultExportHelper.NoString;
            }

            if (testResult.PhysicianInterpretation != null)
            {
                model.AaaPhysicianNotes = testResult.PhysicianInterpretation.Remarks;
            }

            var aaaDiagnosisCodes = new System.Collections.Generic.List <OrderedPair <string, string> >();

            if (testResult.DiagnosisCode != null)
            {
                foreach (var diagnosisCode in PhysicianPartnerResultExportHelper.AaaDiagnosisCodes)
                {
                    if (testResult.DiagnosisCode.Reading.Contains(diagnosisCode))
                    {
                        aaaDiagnosisCodes.Add(new OrderedPair <string, string>(diagnosisCode, PhysicianPartnerResultExportHelper.YesString));
                    }
                    else
                    {
                        aaaDiagnosisCodes.Add(new OrderedPair <string, string>(diagnosisCode, PhysicianPartnerResultExportHelper.NoString));
                    }
                }
            }
            else
            {
                aaaDiagnosisCodes.AddRange(PhysicianPartnerResultExportHelper.AaaDiagnosisCodes.Select(diagnosisCode => new OrderedPair <string, string>(diagnosisCode, PhysicianPartnerResultExportHelper.NoString)));
            }

            model.AaaDiagnosisCodes = aaaDiagnosisCodes;

            return(model);
        }
Exemplo n.º 5
0
        private void GetAaaTransverseViewValues(PpAaaTestResult 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.PPAAA, (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);
            }
        }
Exemplo n.º 6
0
        public override TestResult CreateActualTestResult(CustomerEventScreeningTestsEntity customerEventScreeningTestsEntity)
        {
            var customerEventReadingEntities = customerEventScreeningTestsEntity.CustomerEventReading.ToList();
            var testResult = new PpAaaTestResult(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.DiagnosisCode = CreateResultReadingforInputValues((int)ReadingLabels.DiagnosisCode, 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);

            var aortaValue = GetMaxofthreeAortaValues(testResult);

            if (aortaValue != null)
            {
                testResult.Finding = new StandardFinding <decimal?>(Convert.ToInt64((new TestResultService()).GetCalculatedStandardFinding(aortaValue, (int)TestType.PPAAA, (int)ReadingLabels.AortaSize)));
            }

            if (testResult.Finding != null)
            {
                testResult.Finding = new TestResultService().GetAllStandardFindings <decimal?>((int)TestType.PPAAA, (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.PPAAA, (int)ReadingLabels.AortaRangeSaggitalView);
            var aortaRangeTransverseViewFindings = testResultService.GetAllStandardFindings <int?>((int)TestType.PPAAA, (int)ReadingLabels.AortaRangeTransverseView);
            var aortaValueFindings = testResultService.GetAllStandardFindings <int?>((int)TestType.PPAAA, (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);
        }