示例#1
0
        public override CustomerEventScreeningTestsEntity CreateActualTestResultEntity(TestResult testResult, List <Core.OrderedPair <int, int> > testReadingReadingPairs)
        {
            var pulmonaryFunctionTestResult       = testResult as PulmonaryFunctionTestResult;
            var customerEventScreeningTestsEntity = new CustomerEventScreeningTestsEntity(testResult.Id)
            {
                TestId = (int)TestType.PulmonaryFunction
            };

            testResult.ResultInterpretation = null;
            if (pulmonaryFunctionTestResult.Finding != null)
            {
                var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity
                {
                    StandardFindingTestReadingId =
                        (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding
                            ((int)TestType.PulmonaryFunction, null, Convert.ToInt64(pulmonaryFunctionTestResult.Finding.Id)),

                    CustomerEventTestStandardFindingId = pulmonaryFunctionTestResult.Finding.CustomerEventStandardFindingId,
                    CustomerEventScreeningTestId       = testResult.Id
                };

                var finding = GetSelectedStandardFinding((int)TestType.PulmonaryFunction, null, pulmonaryFunctionTestResult.Finding.Id);

                if (testResult.ResultStatus.StateNumber == (int)TestResultStateNumber.Evaluated || testResult.ResultStatus.StateNumber == (int)NewTestResultStateNumber.Evaluated)
                {
                    testResult.ResultInterpretation  = finding.ResultInterpretation;
                    testResult.PathwayRecommendation = finding.PathwayRecommendation;
                }

                customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
            }

            return(customerEventScreeningTestsEntity);
        }
示例#2
0
        public override CustomerEventScreeningTestsEntity CreateActualTestResultEntity(TestResult testResult, List <OrderedPair <int, int> > testReadingReadingPairs)
        {
            var medicareTestResult = testResult as MedicareTestResult;
            var customerEventScreeningTestsEntity = new CustomerEventScreeningTestsEntity(testResult.Id)
            {
                TestId = (int)TestType.Medicare
            };
            var customerEventReadingEntities = new List <CustomerEventReadingEntity>();

            testResult.ResultInterpretation = null;
            if (medicareTestResult.Finding != null)
            {
                var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity
                {
                    StandardFindingTestReadingId =
                        (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding
                            ((int)TestType.Medicare, null, Convert.ToInt64(medicareTestResult.Finding.Id)),

                    CustomerEventTestStandardFindingId = medicareTestResult.Finding.CustomerEventStandardFindingId,
                    CustomerEventScreeningTestId       = testResult.Id
                };

                var finding = GetSelectedStandardFinding((int)TestType.Medicare, null, medicareTestResult.Finding.Id);

                if (testResult.ResultStatus.StateNumber == (int)TestResultStateNumber.Evaluated || testResult.ResultStatus.StateNumber == (int)NewTestResultStateNumber.Evaluated)
                {
                    testResult.ResultInterpretation  = finding.ResultInterpretation;
                    testResult.PathwayRecommendation = finding.PathwayRecommendation;
                }

                customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
            }

            if (medicareTestResult.TechnicallyLimitedbutReadable != null)
            {
                var customerEventReadingEntity = CreateEventReadingEntity(medicareTestResult.TechnicallyLimitedbutReadable, (int)ReadingLabels.TechnicallyLimitedbutReadable, testReadingReadingPairs);
                if (customerEventReadingEntity != null)
                {
                    customerEventReadingEntities.Add(customerEventReadingEntity);
                }
            }

            if (medicareTestResult.RepeatStudy != null)
            {
                var customerEventReadingEntity = CreateEventReadingEntity(medicareTestResult.RepeatStudy, (int)ReadingLabels.RepeatStudy, testReadingReadingPairs);
                if (customerEventReadingEntity != null)
                {
                    customerEventReadingEntities.Add(customerEventReadingEntity);
                }
            }

            if (customerEventReadingEntities.Count > 0)
            {
                customerEventScreeningTestsEntity.CustomerEventReading.AddRange(customerEventReadingEntities);
            }

            return(customerEventScreeningTestsEntity);
        }
示例#3
0
        public override CustomerEventScreeningTestsEntity CreateActualTestResultEntity(TestResult testResult, List <Core.OrderedPair <int, int> > testReadingReadingPairs)
        {
            var imtTestResult = testResult as ImtTestResult;
            var customerEventScreeningTestsEntity = new CustomerEventScreeningTestsEntity(testResult.Id)
            {
                TestId = (int)TestType.IMT
            };
            var customerEventReadingEntities = new List <CustomerEventReadingEntity>();

            if (imtTestResult.VascularAge != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(imtTestResult.VascularAge, (int)ReadingLabels.VascularAge, testReadingReadingPairs));
            }

            if (imtTestResult.QimtLeft != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(imtTestResult.QimtLeft, (int)ReadingLabels.QimtLeft, testReadingReadingPairs));
            }

            if (imtTestResult.QimtRight != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(imtTestResult.QimtRight, (int)ReadingLabels.QimtRight, testReadingReadingPairs));
            }

            if (imtTestResult.ExpectedQimt != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(imtTestResult.ExpectedQimt, (int)ReadingLabels.ExpectedQimt, testReadingReadingPairs));
            }

            testResult.ResultInterpretation = null;
            if (imtTestResult.Finding != null)
            {
                var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity()
                {
                    StandardFindingTestReadingId =
                        (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding
                            ((int)TestType.IMT, null, Convert.ToInt64(imtTestResult.Finding.Id)),

                    CustomerEventTestStandardFindingId = imtTestResult.Finding.CustomerEventStandardFindingId,
                    CustomerEventScreeningTestId       = testResult.Id
                };

                var finding = GetSelectedStandardFinding((int)TestType.IMT, null, imtTestResult.Finding.Id);

                if (testResult.ResultStatus.StateNumber == (int)TestResultStateNumber.Evaluated || testResult.ResultStatus.StateNumber == (int)NewTestResultStateNumber.Evaluated)
                {
                    testResult.ResultInterpretation  = finding.ResultInterpretation;
                    testResult.PathwayRecommendation = finding.PathwayRecommendation;
                }

                customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
            }

            customerEventScreeningTestsEntity.CustomerEventReading.AddRange(customerEventReadingEntities);
            return(customerEventScreeningTestsEntity);
        }
        public override CustomerEventScreeningTestsEntity CreateActualTestResultEntity(TestResult testResult, List <OrderedPair <int, int> > testReadingReadingPairs)
        {
            var awvAaaTestResult = testResult as AwvAaaTestResult;
            var customerEventScreeningTestsEntity = new CustomerEventScreeningTestsEntity(testResult.Id)
            {
                TestId = (int)TestType.AwvAAA
            };
            var customerEventReadingEntities = new List <CustomerEventReadingEntity>();

            int? standardFindingTestReadingId = null;
            long findingId  = 0;
            var  aortaValue = GetMaxofthreeAortaValues(awvAaaTestResult);

            if (aortaValue != null)
            {
                findingId = (new TestResultService()).GetCalculatedStandardFinding(EventId, CustomerId, aortaValue, (int)TestType.AwvAAA, (int)ReadingLabels.AortaSize);

                if (awvAaaTestResult.Finding != null && awvAaaTestResult.Finding.Id != findingId)
                {
                    findingId = awvAaaTestResult.Finding.Id;
                    standardFindingTestReadingId = (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding((int)TestType.AwvAAA, (int)ReadingLabels.AortaSize, awvAaaTestResult.Finding.Id);
                }
            }
            else if (awvAaaTestResult.Finding != null)
            {
                findingId = awvAaaTestResult.Finding.Id;
                standardFindingTestReadingId = (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding((int)TestType.AwvAAA, (int)ReadingLabels.AortaSize, awvAaaTestResult.Finding.Id);
            }

            if (findingId > 0)
            {
                var finding = GetSelectedStandardFinding((int)TestType.AwvAAA, (int)ReadingLabels.AortaSize, findingId);
                if (testResult.ResultStatus.StateNumber == (int)TestResultStateNumber.Evaluated || testResult.ResultStatus.StateNumber == (int)NewTestResultStateNumber.Evaluated)
                {
                    testResult.ResultInterpretation  = finding.ResultInterpretation;
                    testResult.PathwayRecommendation = finding.PathwayRecommendation;
                }
            }

            if (standardFindingTestReadingId != null)
            {
                customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(
                    new CustomerEventTestStandardFindingEntity(awvAaaTestResult.Finding.CustomerEventStandardFindingId)
                {
                    StandardFindingTestReadingId = standardFindingTestReadingId.Value
                });
            }

            if (awvAaaTestResult.AortaSize != null)
            {
                var customerEventReading = CreateEventReadingEntity(awvAaaTestResult.AortaSize, (int)ReadingLabels.AortaSize, testReadingReadingPairs);
                customerEventReadingEntities.Add(customerEventReading);
            }

            if (awvAaaTestResult.TransverseView != null)
            {
                if (awvAaaTestResult.TransverseView.FirstValue != null)
                {
                    var customerEventReading = CreateEventReadingEntity(awvAaaTestResult.TransverseView.FirstValue, (int)ReadingLabels.TransverseViewDataPointOne, testReadingReadingPairs);
                    customerEventReadingEntities.Add(customerEventReading);
                }

                if (awvAaaTestResult.TransverseView.SecondValue != null)
                {
                    var customerEventReading = CreateEventReadingEntity(awvAaaTestResult.TransverseView.SecondValue, (int)ReadingLabels.TransverseViewDataPointTwo, testReadingReadingPairs);
                    customerEventReadingEntities.Add(customerEventReading);
                }
            }

            if (awvAaaTestResult.ResidualLumenStandardFindings != null)
            {
                if (awvAaaTestResult.ResidualLumenStandardFindings.FirstValue != null)
                {
                    var customerEventReading = CreateEventReadingEntity(awvAaaTestResult.ResidualLumenStandardFindings.FirstValue, (int)ReadingLabels.ResidualLumenTransverseViewDataPointOne, testReadingReadingPairs);
                    customerEventReadingEntities.Add(customerEventReading);
                }

                if (awvAaaTestResult.ResidualLumenStandardFindings.SecondValue != null)
                {
                    var customerEventReading = CreateEventReadingEntity(awvAaaTestResult.ResidualLumenStandardFindings.SecondValue, (int)ReadingLabels.ResidualLumenTransverseViewDataPointTwo, testReadingReadingPairs);
                    customerEventReadingEntities.Add(customerEventReading);
                }
            }

            if (awvAaaTestResult.PeakSystolicVelocity != null)
            {
                var customerEventReading = CreateEventReadingEntity(awvAaaTestResult.PeakSystolicVelocity, (int)ReadingLabels.PeakSystolicVelocity, testReadingReadingPairs);

                customerEventReadingEntities.Add(customerEventReading);
            }


            if (awvAaaTestResult.AorticDissection != null)
            {
                var customerEventReading = CreateEventReadingEntity(awvAaaTestResult.AorticDissection, (int)ReadingLabels.AorticDissection, testReadingReadingPairs);

                customerEventReadingEntities.Add(customerEventReading);
            }

            if (awvAaaTestResult.Plaque != null)
            {
                var customerEventReading = CreateEventReadingEntity(awvAaaTestResult.Plaque, (int)ReadingLabels.Plaque, testReadingReadingPairs);

                customerEventReadingEntities.Add(customerEventReading);
            }

            if (awvAaaTestResult.TechnicallyLimitedbutReadable != null)
            {
                var customerEventReading = CreateEventReadingEntity(awvAaaTestResult.TechnicallyLimitedbutReadable, (int)ReadingLabels.TechnicallyLimitedbutReadable, testReadingReadingPairs);

                customerEventReadingEntities.Add(customerEventReading);
            }

            if (awvAaaTestResult.RepeatStudy != null)
            {
                var customerEventReading = CreateEventReadingEntity(awvAaaTestResult.RepeatStudy, (int)ReadingLabels.RepeatStudy, testReadingReadingPairs);

                customerEventReadingEntities.Add(customerEventReading);
            }

            if (awvAaaTestResult.Thrombus != null)
            {
                var customerEventReading = CreateEventReadingEntity(awvAaaTestResult.Thrombus, (int)ReadingLabels.Thrombus, testReadingReadingPairs);

                customerEventReadingEntities.Add(customerEventReading);
            }

            if (awvAaaTestResult.AortaRangeSaggitalView != null)
            {
                awvAaaTestResult.AortaRangeSaggitalView.ForEach(finding =>
                {
                    var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity()
                    {
                        StandardFindingTestReadingId =
                            (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding
                                ((int)TestType.AwvAAA, (int)ReadingLabels.AortaRangeSaggitalView, Convert.ToInt64(finding.Id)),
                        CustomerEventTestStandardFindingId = finding.CustomerEventStandardFindingId,
                        CustomerEventScreeningTestId       = testResult.Id
                    };
                    customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
                });
            }

            if (awvAaaTestResult.AortaRangeTransverseView != null)
            {
                awvAaaTestResult.AortaRangeTransverseView.ForEach(finding =>
                {
                    var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity()
                    {
                        StandardFindingTestReadingId =
                            (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding
                                ((int)TestType.AwvAAA, (int)ReadingLabels.AortaRangeTransverseView, Convert.ToInt64(finding.Id)),
                        CustomerEventTestStandardFindingId = finding.CustomerEventStandardFindingId,
                        CustomerEventScreeningTestId       = testResult.Id
                    };
                    customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
                });
            }

            if (awvAaaTestResult.PeakSystolicVelocityStandardFindings != null)
            {
                awvAaaTestResult.PeakSystolicVelocityStandardFindings.ForEach(finding =>
                {
                    var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity()
                    {
                        StandardFindingTestReadingId =
                            (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding
                                ((int)TestType.AwvAAA, (int)ReadingLabels.PeakSystolicVelocitySaggitalView, Convert.ToInt64(finding.Id)),
                        CustomerEventTestStandardFindingId = finding.CustomerEventStandardFindingId,
                        CustomerEventScreeningTestId       = testResult.Id
                    };
                    customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
                });
            }

            if (customerEventReadingEntities.Count > 0)
            {
                customerEventScreeningTestsEntity.CustomerEventReading.AddRange(customerEventReadingEntities);
            }

            return(customerEventScreeningTestsEntity);
        }
        public override CustomerEventScreeningTestsEntity CreateActualTestResultEntity(TestResult testResult, List <OrderedPair <int, int> > testReadingReadingPairs)
        {
            var echoTestResult = testResult as PpEchocardiogramTestResult;
            var customerEventScreeningTestsEntity = new CustomerEventScreeningTestsEntity(testResult.Id)
            {
                TestId = (int)TestType.PPEcho
            };
            var customerEventReadingEntities = new List <CustomerEventReadingEntity>();

            if (echoTestResult.Aortic != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.Aortic, (int)ReadingLabels.Aortic, testReadingReadingPairs));
            }

            if (echoTestResult.Mitral != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.Mitral, (int)ReadingLabels.Mitral, testReadingReadingPairs));
            }

            if (echoTestResult.Pulmonic != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.Pulmonic, (int)ReadingLabels.Pulmonic, testReadingReadingPairs));
            }

            if (echoTestResult.Tricuspid != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.Tricuspid, (int)ReadingLabels.Tricuspid, testReadingReadingPairs));
            }

            if (echoTestResult.DiagnosisCode != null)
            {
                var customerEventReading = CreateEventReadingEntity(echoTestResult.DiagnosisCode, (int)ReadingLabels.DiagnosisCode, testReadingReadingPairs);
                customerEventReadingEntities.Add(customerEventReading);
            }

            if (echoTestResult.VentricularEnlargement != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.VentricularEnlargement, (int)ReadingLabels.VentricularEnlargement, testReadingReadingPairs));
            }

            if (echoTestResult.LeftVentricularEnlargment != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.LeftVentricularEnlargment, (int)ReadingLabels.LeftVentricularEnlargment, testReadingReadingPairs));
            }

            if (echoTestResult.RightVentricularEnlargment != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.RightVentricularEnlargment, (int)ReadingLabels.RightVentricularEnlargment, testReadingReadingPairs));
            }

            if (echoTestResult.LeftVentricularEnlargmentValue != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.LeftVentricularEnlargmentValue, (int)ReadingLabels.LeftVentricularEnlargmentValue, testReadingReadingPairs));
            }

            if (echoTestResult.RightVentricularEnlargmentValue != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.RightVentricularEnlargmentValue, (int)ReadingLabels.RightVentricularEnlargmentValue, testReadingReadingPairs));
            }

            if (echoTestResult.DiastolicDysfunction != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.DiastolicDysfunction, (int)ReadingLabels.DiastolicDysfunction, testReadingReadingPairs));
            }

            if (echoTestResult.PericardialEffusion != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.PericardialEffusion, (int)ReadingLabels.PericardialEffusion, testReadingReadingPairs));
            }


            if (echoTestResult.AorticRoot != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.AorticRoot, (int)ReadingLabels.AorticRoot, testReadingReadingPairs));
            }

            if (echoTestResult.Sclerotic != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.Sclerotic, (int)ReadingLabels.Sclerotic, testReadingReadingPairs));
            }

            if (echoTestResult.Calcified != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.Calcified, (int)ReadingLabels.Calcified, testReadingReadingPairs));
            }

            if (echoTestResult.Enlarged != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.Enlarged, (int)ReadingLabels.Enlarged, testReadingReadingPairs));
            }

            if (echoTestResult.EnlargedValue != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.EnlargedValue, (int)ReadingLabels.EnlargedValue, testReadingReadingPairs));
            }

            if (echoTestResult.VentricularHypertrophy != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.VentricularHypertrophy, (int)ReadingLabels.VentricularHypertrophy, testReadingReadingPairs));
            }

            if (echoTestResult.LeftVHypertrophyValue != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.LeftVHypertrophyValue, (int)ReadingLabels.LeftVHypertrophyValue, testReadingReadingPairs));
            }

            if (echoTestResult.RightVHypertrophyValue != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.RightVHypertrophyValue, (int)ReadingLabels.RightVHypertrophyValue, testReadingReadingPairs));
            }

            if (echoTestResult.IvshHypertrophyValue != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.IvshHypertrophyValue, (int)ReadingLabels.IVSHHypertrophyValue, testReadingReadingPairs));
            }

            if (echoTestResult.LeftVHypertrophy != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.LeftVHypertrophy, (int)ReadingLabels.LeftVHypertrophy, testReadingReadingPairs));
            }

            if (echoTestResult.RightVHypertrophy != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.RightVHypertrophy, (int)ReadingLabels.RightVHypertrophy, testReadingReadingPairs));
            }

            if (echoTestResult.IvshHypertrophy != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.IvshHypertrophy, (int)ReadingLabels.IVSHHypertrophy, testReadingReadingPairs));
            }


            if (echoTestResult.TechnicallyLimitedbutReadable != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.TechnicallyLimitedbutReadable, (int)ReadingLabels.TechnicallyLimitedbutReadable, testReadingReadingPairs));
            }

            if (echoTestResult.RepeatStudyUnreadable != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.RepeatStudyUnreadable, (int)ReadingLabels.RepeatStudy, testReadingReadingPairs));
            }


            if (echoTestResult.AtrialEnlargement != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.AtrialEnlargement, (int)ReadingLabels.AtrialEnlargement, testReadingReadingPairs));
            }

            if (echoTestResult.LeftAtrialEnlargmentValue != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.LeftAtrialEnlargmentValue, (int)ReadingLabels.LeftAtrialEnlargmentValue, testReadingReadingPairs));
            }

            if (echoTestResult.RightAtrialEnlargmentValue != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.RightAtrialEnlargmentValue, (int)ReadingLabels.RightAtrialEnlargmentValue, testReadingReadingPairs));
            }

            if (echoTestResult.LeftAtrialEnlargment != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.LeftAtrialEnlargment, (int)ReadingLabels.LeftAtrialEnlargment, testReadingReadingPairs));
            }

            if (echoTestResult.RightAtrialEnlargment != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.RightAtrialEnlargment, (int)ReadingLabels.RightAtrialEnlargment, testReadingReadingPairs));
            }



            if (echoTestResult.ASD != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.ASD, (int)ReadingLabels.ASD, testReadingReadingPairs));
            }

            if (echoTestResult.PFO != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.PFO, (int)ReadingLabels.PFO, testReadingReadingPairs));
            }

            if (echoTestResult.VSD != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.VSD, (int)ReadingLabels.VSD, testReadingReadingPairs));
            }

            if (echoTestResult.FlailAS != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.FlailAS, (int)ReadingLabels.FlailAS, testReadingReadingPairs));
            }

            if (echoTestResult.Arrythmia != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.Arrythmia, (int)ReadingLabels.Arrythmia, testReadingReadingPairs));
            }

            if (echoTestResult.AFib != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.AFib, (int)ReadingLabels.AFib, testReadingReadingPairs));
            }

            if (echoTestResult.AFlutter != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.AFlutter, (int)ReadingLabels.AFlutter, testReadingReadingPairs));
            }

            if (echoTestResult.PAC != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.PAC, (int)ReadingLabels.PAC, testReadingReadingPairs));
            }

            if (echoTestResult.PVC != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.PVC, (int)ReadingLabels.PVC, testReadingReadingPairs));
            }


            if (echoTestResult.RestrictedLeafletMotion != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.RestrictedLeafletMotion, (int)ReadingLabels.RestrictedLeafletMotion, testReadingReadingPairs));
            }

            if (echoTestResult.RestrictedLeafletMotionAortic != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.RestrictedLeafletMotionAortic, (int)ReadingLabels.RestrictedLeafletMotionAortic, testReadingReadingPairs));
            }

            if (echoTestResult.RestrictedLeafletMotionMitral != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.RestrictedLeafletMotionMitral, (int)ReadingLabels.RestrictedLeafletMotionMitral, testReadingReadingPairs));
            }

            if (echoTestResult.RestrictedLeafletMotionPulmonic != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.RestrictedLeafletMotionPulmonic, (int)ReadingLabels.RestrictedLeafletMotionPulmonic, testReadingReadingPairs));
            }

            if (echoTestResult.RestrictedLeafletMotionTricuspid != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.RestrictedLeafletMotionTricuspid, (int)ReadingLabels.RestrictedLeafletMotionTricuspid, testReadingReadingPairs));
            }


            if (echoTestResult.SAM != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.SAM, (int)ReadingLabels.SAM, testReadingReadingPairs));
            }

            if (echoTestResult.LVOTO != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.LVOTO, (int)ReadingLabels.LVOTO, testReadingReadingPairs));
            }

            if (echoTestResult.MitralAnnularCa != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.MitralAnnularCa, (int)ReadingLabels.MitralAnnularCa, testReadingReadingPairs));
            }

            if (echoTestResult.Hypokinetic != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.Hypokinetic, (int)ReadingLabels.Hypokinetic, testReadingReadingPairs));
            }

            if (echoTestResult.Akinetic != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.Akinetic, (int)ReadingLabels.Akinetic, testReadingReadingPairs));
            }

            if (echoTestResult.Dyskinetic != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.Dyskinetic, (int)ReadingLabels.Dyskinetic, testReadingReadingPairs));
            }

            if (echoTestResult.Anterior != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.Anterior, (int)ReadingLabels.Anterior, testReadingReadingPairs));
            }

            if (echoTestResult.Posterior != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.Posterior, (int)ReadingLabels.Posterior, testReadingReadingPairs));
            }

            if (echoTestResult.Apical != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.Apical, (int)ReadingLabels.Apical, testReadingReadingPairs));
            }

            if (echoTestResult.Septal != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.Septal, (int)ReadingLabels.Septal, testReadingReadingPairs));
            }

            if (echoTestResult.Lateral != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.Lateral, (int)ReadingLabels.Lateral, testReadingReadingPairs));
            }

            if (echoTestResult.Inferior != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.Inferior, (int)ReadingLabels.Inferior, testReadingReadingPairs));
            }

            if (echoTestResult.AoticVelocity != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.AoticVelocity, (int)ReadingLabels.AoticVelocity, testReadingReadingPairs));
            }

            if (echoTestResult.MitralPT != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.MitralPT, (int)ReadingLabels.MitralPT, testReadingReadingPairs));
            }

            if (echoTestResult.PulmonicVelocity != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.PulmonicVelocity, (int)ReadingLabels.PulmonicVelocity, testReadingReadingPairs));
            }

            if (echoTestResult.TricuspidVelocity != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.TricuspidVelocity, (int)ReadingLabels.TricuspidVelocity, testReadingReadingPairs));
            }

            if (echoTestResult.TricuspidPap != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.TricuspidPap, (int)ReadingLabels.TricuspidPap, testReadingReadingPairs));
            }

            if (echoTestResult.MorphologyTricuspidHighOrGreater != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.MorphologyTricuspidHighOrGreater, (int)ReadingLabels.High35MmHgOrGreater, testReadingReadingPairs));
            }

            if (echoTestResult.MorphologyTricuspidNormal != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(echoTestResult.MorphologyTricuspidNormal, (int)ReadingLabels.Normal, testReadingReadingPairs));
            }

            testResult.ResultInterpretation = null;
            if (echoTestResult.Finding != null)
            {
                var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity()
                {
                    StandardFindingTestReadingId =
                        (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding
                            ((int)TestType.PPEcho, null, Convert.ToInt64(echoTestResult.Finding.Id)),
                    CustomerEventTestStandardFindingId = echoTestResult.Finding.CustomerEventStandardFindingId,
                    CustomerEventScreeningTestId       = testResult.Id
                };
                customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);

                var finding = GetSelectedStandardFinding((int)TestType.PPEcho, null, echoTestResult.Finding.Id);

                if (testResult.ResultStatus.StateNumber == (int)TestResultStateNumber.Evaluated || testResult.ResultStatus.StateNumber == (int)NewTestResultStateNumber.Evaluated)
                {
                    testResult.ResultInterpretation  = finding.ResultInterpretation;
                    testResult.PathwayRecommendation = finding.PathwayRecommendation;
                }
            }

            if (echoTestResult.EstimatedEjactionFraction != null)
            {
                var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity()
                {
                    StandardFindingTestReadingId =
                        (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding
                            ((int)TestType.PPEcho, (int)ReadingLabels.EstimatedEjactionFraction, Convert.ToInt64(echoTestResult.EstimatedEjactionFraction.Id)),
                    CustomerEventTestStandardFindingId = echoTestResult.EstimatedEjactionFraction.CustomerEventStandardFindingId,
                    CustomerEventScreeningTestId       = testResult.Id
                };
                customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
            }
            if (echoTestResult.AorticRegurgitation != null)
            {
                var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity()
                {
                    StandardFindingTestReadingId =
                        (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding
                            ((int)TestType.PPEcho, (int)ReadingLabels.Aortic, Convert.ToInt64(echoTestResult.AorticRegurgitation.Id)),
                    CustomerEventTestStandardFindingId = echoTestResult.AorticRegurgitation.CustomerEventStandardFindingId,
                    CustomerEventScreeningTestId       = testResult.Id
                };
                customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
            }

            if (echoTestResult.AorticMorphology != null)
            {
                echoTestResult.AorticMorphology.ForEach(finding =>
                {
                    var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity()
                    {
                        StandardFindingTestReadingId =
                            (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding
                                ((int)TestType.PPEcho, (int)ReadingLabels.AorticMorphology, Convert.ToInt64(finding.Id)),
                        CustomerEventTestStandardFindingId = finding.CustomerEventStandardFindingId,
                        CustomerEventScreeningTestId       = testResult.Id
                    };
                    customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
                });
            }

            if (echoTestResult.MitralRegurgitation != null)
            {
                var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity()
                {
                    StandardFindingTestReadingId =
                        (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding
                            ((int)TestType.PPEcho, (int)ReadingLabels.Mitral, Convert.ToInt64(echoTestResult.MitralRegurgitation.Id)),
                    CustomerEventTestStandardFindingId = echoTestResult.MitralRegurgitation.CustomerEventStandardFindingId,
                    CustomerEventScreeningTestId       = testResult.Id
                };
                customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
            }

            if (echoTestResult.MitralMorphology != null)
            {
                echoTestResult.MitralMorphology.ForEach(finding =>
                {
                    var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity()
                    {
                        StandardFindingTestReadingId =
                            (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding
                                ((int)TestType.PPEcho, (int)ReadingLabels.MitralMorphology, Convert.ToInt64(finding.Id)),
                        CustomerEventTestStandardFindingId = finding.CustomerEventStandardFindingId,
                        CustomerEventScreeningTestId       = testResult.Id
                    };
                    customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
                });
            }

            if (echoTestResult.PulmonicRegurgitation != null)
            {
                var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity()
                {
                    StandardFindingTestReadingId =
                        (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding
                            ((int)TestType.PPEcho, (int)ReadingLabels.Pulmonic, Convert.ToInt64(echoTestResult.PulmonicRegurgitation.Id)),
                    CustomerEventTestStandardFindingId = echoTestResult.PulmonicRegurgitation.CustomerEventStandardFindingId,
                    CustomerEventScreeningTestId       = testResult.Id
                };
                customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
            }

            if (echoTestResult.PulmonicMorphology != null)
            {
                echoTestResult.PulmonicMorphology.ForEach(finding =>
                {
                    var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity()
                    {
                        StandardFindingTestReadingId =
                            (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding
                                ((int)TestType.PPEcho, (int)ReadingLabels.PulmonicMorphology, Convert.ToInt64(finding.Id)),
                        CustomerEventTestStandardFindingId = finding.CustomerEventStandardFindingId,
                        CustomerEventScreeningTestId       = testResult.Id
                    };
                    customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
                });
            }

            if (echoTestResult.TricuspidRegurgitation != null)
            {
                var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity()
                {
                    StandardFindingTestReadingId =
                        (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding
                            ((int)TestType.PPEcho, (int)ReadingLabels.Tricuspid, Convert.ToInt64(echoTestResult.TricuspidRegurgitation.Id)),
                    CustomerEventTestStandardFindingId = echoTestResult.TricuspidRegurgitation.CustomerEventStandardFindingId,
                    CustomerEventScreeningTestId       = testResult.Id
                };
                customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
            }

            if (echoTestResult.TricuspidMorphology != null)
            {
                echoTestResult.TricuspidMorphology.ForEach(finding =>
                {
                    var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity()
                    {
                        StandardFindingTestReadingId =
                            (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding
                                ((int)TestType.PPEcho, (int)ReadingLabels.TricuspidMorphology, Convert.ToInt64(finding.Id)),
                        CustomerEventTestStandardFindingId = finding.CustomerEventStandardFindingId,
                        CustomerEventScreeningTestId       = testResult.Id
                    };
                    customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
                });
            }

            if (echoTestResult.DistolicDysfunctionFinding != null)
            {
                var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity()
                {
                    StandardFindingTestReadingId =
                        (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding
                            ((int)TestType.PPEcho, (int)ReadingLabels.DiastolicDysfunction, Convert.ToInt64(echoTestResult.DistolicDysfunctionFinding.Id)),
                    CustomerEventTestStandardFindingId = echoTestResult.DistolicDysfunctionFinding.CustomerEventStandardFindingId,
                    CustomerEventScreeningTestId       = testResult.Id
                };
                customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
            }

            if (echoTestResult.PericardialEffusionFinding != null)
            {
                echoTestResult.PericardialEffusionFinding.ForEach(finding =>
                {
                    var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity()
                    {
                        StandardFindingTestReadingId =
                            (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding
                                ((int)TestType.PPEcho, (int)ReadingLabels.PericardialEffusion, Convert.ToInt64(finding.Id)),
                        CustomerEventTestStandardFindingId = finding.CustomerEventStandardFindingId,
                        CustomerEventScreeningTestId       = testResult.Id
                    };
                    customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
                });
            }

            customerEventScreeningTestsEntity.CustomerEventReading.AddRange(customerEventReadingEntities);
            return(customerEventScreeningTestsEntity);
        }
        public override CustomerEventScreeningTestsEntity CreateActualTestResultEntity(TestResult testResult, List <OrderedPair <int, int> > testReadingReadingPairs)
        {
            var qualityMeasuresTestResult         = testResult as QualityMeasuresTestResult;
            var customerEventScreeningTestsEntity = new CustomerEventScreeningTestsEntity(testResult.Id)
            {
                TestId = (int)TestType.QualityMeasures
            };
            var customerEventReadingEntities = new List <CustomerEventReadingEntity>();

            testResult.ResultInterpretation = null;

            if (qualityMeasuresTestResult.MemoryRecallScore != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(qualityMeasuresTestResult.MemoryRecallScore, (int)ReadingLabels.MemoryRecallScore, testReadingReadingPairs));
            }

            if (qualityMeasuresTestResult.ClockPass != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(qualityMeasuresTestResult.ClockPass, (int)ReadingLabels.ClockPass, testReadingReadingPairs));
            }

            if (qualityMeasuresTestResult.ClockFail != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(qualityMeasuresTestResult.ClockFail, (int)ReadingLabels.ClockFail, testReadingReadingPairs));
            }

            if (qualityMeasuresTestResult.GaitPass != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(qualityMeasuresTestResult.GaitPass, (int)ReadingLabels.GaitPass, testReadingReadingPairs));
            }

            if (qualityMeasuresTestResult.GaitFail != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(qualityMeasuresTestResult.GaitFail, (int)ReadingLabels.GaitFail, testReadingReadingPairs));
            }

            if (qualityMeasuresTestResult.FunctionalAssessmentScore != null)
            {
                var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity
                {
                    StandardFindingTestReadingId = (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding((int)TestType.QualityMeasures, (int)ReadingLabels.FunctionalAssessmentScore, Convert.ToInt64(qualityMeasuresTestResult.FunctionalAssessmentScore.Id)),

                    CustomerEventTestStandardFindingId = qualityMeasuresTestResult.FunctionalAssessmentScore.CustomerEventStandardFindingId,
                    CustomerEventScreeningTestId       = testResult.Id
                };

                customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
            }

            if (qualityMeasuresTestResult.PainAssessmentScore != null)
            {
                var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity
                {
                    StandardFindingTestReadingId =
                        (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding((int)TestType.QualityMeasures,
                                                                                                        (int)ReadingLabels.PainAssessmentScore, Convert.ToInt64(qualityMeasuresTestResult.PainAssessmentScore.Id)),

                    CustomerEventTestStandardFindingId = qualityMeasuresTestResult.PainAssessmentScore.CustomerEventStandardFindingId,
                    CustomerEventScreeningTestId       = testResult.Id
                };

                customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
            }

            if (qualityMeasuresTestResult.TechnicallyLimitedbutReadable != null)
            {
                var customerEventReadingEntity = CreateEventReadingEntity(qualityMeasuresTestResult.TechnicallyLimitedbutReadable, (int)ReadingLabels.TechnicallyLimitedbutReadable, testReadingReadingPairs);
                if (customerEventReadingEntity != null)
                {
                    customerEventReadingEntities.Add(customerEventReadingEntity);
                }
            }

            if (qualityMeasuresTestResult.RepeatStudy != null)
            {
                var customerEventReadingEntity = CreateEventReadingEntity(qualityMeasuresTestResult.RepeatStudy, (int)ReadingLabels.RepeatStudy, testReadingReadingPairs);
                if (customerEventReadingEntity != null)
                {
                    customerEventReadingEntities.Add(customerEventReadingEntity);
                }
            }

            if (customerEventReadingEntities.Count > 0)
            {
                customerEventScreeningTestsEntity.CustomerEventReading.AddRange(customerEventReadingEntities);
            }

            return(customerEventScreeningTestsEntity);
        }
        public override CustomerEventScreeningTestsEntity CreateActualTestResultEntity(TestResult testResult, List <OrderedPair <int, int> > testReadingReadingPairs)
        {
            var hcpCarotidTestResult = testResult as HcpCarotidTestResult;
            var customerEventScreeningTestsEntity = new CustomerEventScreeningTestsEntity(testResult.Id)
            {
                TestId = (int)TestType.HCPCarotid
            };
            var customerEventReadingEntities = new List <CustomerEventReadingEntity>();

            var resultInterpretations  = new List <long>();
            var pathwayRecommendations = new List <long>();

            if (hcpCarotidTestResult.LeftResultReadings != null)
            {
                var customerEventReading = CreateEventReadingEntity(hcpCarotidTestResult.LeftResultReadings.ICAPSV, (int)ReadingLabels.LICAPSV, testReadingReadingPairs);
                if (customerEventReading != null)
                {
                    customerEventReadingEntities.Add(customerEventReading);
                }

                customerEventReading = CreateEventReadingEntity(hcpCarotidTestResult.LeftResultReadings.ICAEDV, (int)ReadingLabels.LICAEDV, testReadingReadingPairs);
                if (customerEventReading != null)
                {
                    customerEventReadingEntities.Add(customerEventReading);
                }

                customerEventReading = CreateEventReadingEntity(hcpCarotidTestResult.LeftResultReadings.CCAPSV, (int)ReadingLabels.LCCAPSV, testReadingReadingPairs);
                if (customerEventReading != null)
                {
                    customerEventReadingEntities.Add(customerEventReading);
                }

                if (hcpCarotidTestResult.LeftResultReadings.Finding != null)
                {
                    //TODO: Service methods being caled from the factory. need to Refactor and Revise it.
                    var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity
                    {
                        StandardFindingTestReadingId =
                            (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding((int)TestType.HCPCarotid, (int)ReadingLabels.Left, Convert.ToInt64(hcpCarotidTestResult.LeftResultReadings.Finding.Id)),
                        CustomerEventTestStandardFindingId = hcpCarotidTestResult.LeftResultReadings.Finding.CustomerEventStandardFindingId,
                        CustomerEventScreeningTestId       = testResult.Id
                    };

                    var finding = GetSelectedStandardFinding((int)TestType.HCPCarotid, (int)ReadingLabels.Left, hcpCarotidTestResult.LeftResultReadings.Finding.Id);

                    if (finding.ResultInterpretation != null)
                    {
                        resultInterpretations.Add(finding.ResultInterpretation.Value);
                    }
                    if (finding.PathwayRecommendation != null)
                    {
                        pathwayRecommendations.Add(finding.PathwayRecommendation.Value);
                    }

                    customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
                }
            }

            var reading = CreateEventReadingEntity(hcpCarotidTestResult.VelocityElevatedOnLeft, (int)ReadingLabels.VelocityElevatedOnLeft, testReadingReadingPairs);

            if (reading != null)
            {
                customerEventReadingEntities.Add(reading);
            }

            reading = CreateEventReadingEntity(hcpCarotidTestResult.VelocityElevatedOnRight, (int)ReadingLabels.VelocityElevatedOnRight, testReadingReadingPairs);
            if (reading != null)
            {
                customerEventReadingEntities.Add(reading);
            }

            if (hcpCarotidTestResult.RightResultReadings != null)
            {
                var customerEventReading = CreateEventReadingEntity(hcpCarotidTestResult.RightResultReadings.ICAPSV, (int)ReadingLabels.RICAPSV, testReadingReadingPairs);
                if (customerEventReading != null)
                {
                    customerEventReadingEntities.Add(customerEventReading);
                }

                customerEventReading = CreateEventReadingEntity(hcpCarotidTestResult.RightResultReadings.ICAEDV, (int)ReadingLabels.RICAEDV, testReadingReadingPairs);
                if (customerEventReading != null)
                {
                    customerEventReadingEntities.Add(customerEventReading);
                }

                customerEventReading = CreateEventReadingEntity(hcpCarotidTestResult.RightResultReadings.CCAPSV, (int)ReadingLabels.RCCAPSV, testReadingReadingPairs);
                if (customerEventReading != null)
                {
                    customerEventReadingEntities.Add(customerEventReading);
                }

                if (hcpCarotidTestResult.RightResultReadings.Finding != null)
                {
                    //TODO: Service methods being caled from the factory. need to Refactor and Revise it.
                    var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity()
                    {
                        StandardFindingTestReadingId =
                            (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding
                                ((int)TestType.HCPCarotid, (int)ReadingLabels.Right, Convert.ToInt64(hcpCarotidTestResult.RightResultReadings.Finding.Id)),
                        CustomerEventTestStandardFindingId = hcpCarotidTestResult.RightResultReadings.Finding.CustomerEventStandardFindingId,
                        CustomerEventScreeningTestId       = testResult.Id
                    };

                    var finding = GetSelectedStandardFinding((int)TestType.HCPCarotid, (int)ReadingLabels.Right, hcpCarotidTestResult.RightResultReadings.Finding.Id);

                    if (finding.ResultInterpretation != null)
                    {
                        resultInterpretations.Add(finding.ResultInterpretation.Value);
                    }
                    if (finding.PathwayRecommendation != null)
                    {
                        pathwayRecommendations.Add(finding.PathwayRecommendation.Value);
                    }

                    customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
                }
            }


            if (hcpCarotidTestResult.LowVelocityLica != null)
            {
                //TODO: Service methods being caled from the factory. need to Refactor and Revise it.
                var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity()
                {
                    StandardFindingTestReadingId =
                        (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding
                            ((int)TestType.HCPCarotid, (int)ReadingLabels.LICAPSV, Convert.ToInt64(hcpCarotidTestResult.LowVelocityLica.Id)),
                    CustomerEventTestStandardFindingId = hcpCarotidTestResult.LowVelocityLica.CustomerEventStandardFindingId,
                    CustomerEventScreeningTestId       = testResult.Id
                };

                customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
            }

            if (hcpCarotidTestResult.LowVelocityRica != null)
            {
                //TODO: Service methods being caled from the factory. need to Refactor and Revise it.
                var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity()
                {
                    StandardFindingTestReadingId =
                        (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding
                            ((int)TestType.HCPCarotid, (int)ReadingLabels.RICAPSV, Convert.ToInt64(hcpCarotidTestResult.LowVelocityRica.Id)),
                    CustomerEventTestStandardFindingId = hcpCarotidTestResult.LowVelocityRica.CustomerEventStandardFindingId,
                    CustomerEventScreeningTestId       = testResult.Id
                };

                customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
            }

            if (hcpCarotidTestResult.TechnicallyLimitedbutReadable != null)
            {
                var customerEventReadingEntity = CreateEventReadingEntity(hcpCarotidTestResult.TechnicallyLimitedbutReadable, (int)ReadingLabels.TechnicallyLimitedbutReadable, testReadingReadingPairs);
                if (customerEventReadingEntity != null)
                {
                    customerEventReadingEntities.Add(customerEventReadingEntity);
                }
            }

            if (hcpCarotidTestResult.RepeatStudy != null)
            {
                var customerEventReadingEntity = CreateEventReadingEntity(hcpCarotidTestResult.RepeatStudy, (int)ReadingLabels.RepeatStudy, testReadingReadingPairs);
                if (customerEventReadingEntity != null)
                {
                    customerEventReadingEntities.Add(customerEventReadingEntity);
                }
            }

            if (testResult.ResultStatus.StateNumber == (int)TestResultStateNumber.Evaluated || testResult.ResultStatus.StateNumber == (int)NewTestResultStateNumber.Evaluated)
            {
                testResult.ResultInterpretation  = null;
                testResult.PathwayRecommendation = null;

                if (resultInterpretations.Count > 0)
                {
                    testResult.ResultInterpretation = ResultInterpretation.Normal.GetMax(resultInterpretations);
                }

                if (pathwayRecommendations.Count > 0)
                {
                    testResult.PathwayRecommendation = PathwayRecommendation.None.GetMax(pathwayRecommendations);
                }
            }

            if (customerEventReadingEntities.Count > 0)
            {
                customerEventScreeningTestsEntity.CustomerEventReading.AddRange(customerEventReadingEntities);
            }

            return(customerEventScreeningTestsEntity);
        }
        public override CustomerEventScreeningTestsEntity CreateActualTestResultEntity(TestResult testResult, List <OrderedPair <int, int> > testReadingReadingPairs)
        {
            var diabeticRetinopathyTestResult     = testResult as DiabeticRetinopathyTestResult;
            var customerEventScreeningTestsEntity = new CustomerEventScreeningTestsEntity(testResult.Id)
            {
                TestId = (int)TestType.DiabeticRetinopathy
            };
            var customerEventReadingEntities = new List <CustomerEventReadingEntity>();

            if (diabeticRetinopathyTestResult.SuspectedVeinOcclusion != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(diabeticRetinopathyTestResult.SuspectedVeinOcclusion, (int)ReadingLabels.DiabeticRetinopathySuspectedVeinOcclusion, testReadingReadingPairs));
            }

            if (diabeticRetinopathyTestResult.SuspectedWetAmd != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(diabeticRetinopathyTestResult.SuspectedWetAmd, (int)ReadingLabels.DiabeticRetinopathySuspectedWetAmd, testReadingReadingPairs));
            }

            if (diabeticRetinopathyTestResult.SuspectedHtnRetinopathy != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(diabeticRetinopathyTestResult.SuspectedHtnRetinopathy, (int)ReadingLabels.DiabeticRetinopathySuspectedHtnRetinopathy, testReadingReadingPairs));
            }

            if (diabeticRetinopathyTestResult.SuspectedEpiretinalMembrane != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(diabeticRetinopathyTestResult.SuspectedEpiretinalMembrane, (int)ReadingLabels.DiabeticRetinopathySuspectedEpiretinalMembrane, testReadingReadingPairs));
            }

            if (diabeticRetinopathyTestResult.SuspectedMacularHole != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(diabeticRetinopathyTestResult.SuspectedMacularHole, (int)ReadingLabels.DiabeticRetinopathySuspectedMacularHole, testReadingReadingPairs));
            }

            if (diabeticRetinopathyTestResult.SuspectedCataract != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(diabeticRetinopathyTestResult.SuspectedCataract, (int)ReadingLabels.DiabeticRetinopathySuspectedCataract, testReadingReadingPairs));
            }

            if (diabeticRetinopathyTestResult.SuspectedOtherDisease != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(diabeticRetinopathyTestResult.SuspectedOtherDisease, (int)ReadingLabels.DiabeticRetinopathySuspectedOtherDisease, testReadingReadingPairs));
            }

            if (diabeticRetinopathyTestResult.SuspectedGlaucoma != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(diabeticRetinopathyTestResult.SuspectedGlaucoma, (int)ReadingLabels.DiabeticRetinopathySuspectedGlaucoma, testReadingReadingPairs));
            }

            if (diabeticRetinopathyTestResult.SuspectedDryAmd != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(diabeticRetinopathyTestResult.SuspectedDryAmd, (int)ReadingLabels.DiabeticRetinopathySuspectedDryAmd, testReadingReadingPairs));
            }

            if (diabeticRetinopathyTestResult.DiabeticRetinopathyHighestLevelOfSpecificity != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(diabeticRetinopathyTestResult.DiabeticRetinopathyHighestLevelOfSpecificity, (int)ReadingLabels.DiabeticRetinopathyHighestLevelOfSpecificity, testReadingReadingPairs));
            }


            if (diabeticRetinopathyTestResult.MacularEdemaHighestLevelOfSpecificity != null)
            {
                customerEventReadingEntities.Add(CreateEventReadingEntity(diabeticRetinopathyTestResult.MacularEdemaHighestLevelOfSpecificity, (int)ReadingLabels.MacularEdemaHighestLevelOfSpecificity, testReadingReadingPairs));
            }


            testResult.ResultInterpretation = null;
            if (diabeticRetinopathyTestResult.Finding != null)
            {
                var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity
                {
                    StandardFindingTestReadingId = (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding((int)TestType.DiabeticRetinopathy, null, Convert.ToInt64(diabeticRetinopathyTestResult.Finding.Id)),

                    CustomerEventTestStandardFindingId = diabeticRetinopathyTestResult.Finding.CustomerEventStandardFindingId,
                    CustomerEventScreeningTestId       = testResult.Id
                };

                var finding = GetSelectedStandardFinding((int)TestType.DiabeticRetinopathy, null, diabeticRetinopathyTestResult.Finding.Id);

                if (testResult.ResultStatus.StateNumber == (int)TestResultStateNumber.Evaluated || testResult.ResultStatus.StateNumber == (int)NewTestResultStateNumber.Evaluated)
                {
                    testResult.ResultInterpretation  = finding.ResultInterpretation;
                    testResult.PathwayRecommendation = finding.PathwayRecommendation;
                }

                customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
            }

            if (diabeticRetinopathyTestResult.DiabeticRetinopathyLevel != null)
            {
                var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity()
                {
                    StandardFindingTestReadingId =
                        (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding
                            ((int)TestType.DiabeticRetinopathy, (int)ReadingLabels.DiabeticRetinopathyHighestLevelOfSpecificity, Convert.ToInt64(diabeticRetinopathyTestResult.DiabeticRetinopathyLevel.Id)),
                    CustomerEventTestStandardFindingId = diabeticRetinopathyTestResult.DiabeticRetinopathyLevel.CustomerEventStandardFindingId,
                    CustomerEventScreeningTestId       = testResult.Id
                };
                customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
            }

            if (diabeticRetinopathyTestResult.MacularEdemaLevel != null)
            {
                var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity()
                {
                    StandardFindingTestReadingId =
                        (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding
                            ((int)TestType.DiabeticRetinopathy, (int)ReadingLabels.MacularEdemaHighestLevelOfSpecificity, Convert.ToInt64(diabeticRetinopathyTestResult.MacularEdemaLevel.Id)),
                    CustomerEventTestStandardFindingId = diabeticRetinopathyTestResult.MacularEdemaLevel.CustomerEventStandardFindingId,
                    CustomerEventScreeningTestId       = testResult.Id
                };
                customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
            }

            if (diabeticRetinopathyTestResult.TechnicallyLimitedbutReadable != null)
            {
                var customerEventReadingEntity = CreateEventReadingEntity(diabeticRetinopathyTestResult.TechnicallyLimitedbutReadable, (int)ReadingLabels.TechnicallyLimitedbutReadable, testReadingReadingPairs);
                if (customerEventReadingEntity != null)
                {
                    customerEventReadingEntities.Add(customerEventReadingEntity);
                }
            }

            if (diabeticRetinopathyTestResult.RepeatStudy != null)
            {
                var customerEventReadingEntity = CreateEventReadingEntity(diabeticRetinopathyTestResult.RepeatStudy, (int)ReadingLabels.RepeatStudy, testReadingReadingPairs);
                if (customerEventReadingEntity != null)
                {
                    customerEventReadingEntities.Add(customerEventReadingEntity);
                }
            }

            if (customerEventReadingEntities.Count > 0)
            {
                customerEventScreeningTestsEntity.CustomerEventReading.AddRange(customerEventReadingEntities);
            }

            return(customerEventScreeningTestsEntity);
        }
示例#9
0
        public override CustomerEventScreeningTestsEntity CreateActualTestResultEntity(TestResult testResult, List <OrderedPair <int, int> > testReadingReadingPairs)
        {
            var leadTestResult = testResult as LeadTestResult;
            var customerEventScreeningTestsEntity = new CustomerEventScreeningTestsEntity(testResult.Id)
            {
                TestId = (int)TestType.Lead
            };
            var customerEventReadingEntities = new List <CustomerEventReadingEntity>();

            var resultInterpretations  = new List <long>();
            var pathwayRecommendations = new List <long>();

            if (leadTestResult.LeftResultReadings != null)
            {
                var customerEventReading = CreateEventReadingEntity(leadTestResult.LeftResultReadings.CFAPSV, (int)ReadingLabels.LeftCFAPSV, testReadingReadingPairs);
                if (customerEventReading != null)
                {
                    customerEventReadingEntities.Add(customerEventReading);
                }

                customerEventReading = CreateEventReadingEntity(leadTestResult.LeftResultReadings.PSFAPSV, (int)ReadingLabels.LeftPSFAPSV, testReadingReadingPairs);
                if (customerEventReading != null)
                {
                    customerEventReadingEntities.Add(customerEventReading);
                }

                customerEventReading = CreateEventReadingEntity(leadTestResult.LeftResultReadings.NoVisualPlaque, (int)ReadingLabels.LeftNoVisualPlaque, testReadingReadingPairs);
                if (customerEventReading != null)
                {
                    customerEventReadingEntities.Add(customerEventReading);
                }

                customerEventReading = CreateEventReadingEntity(leadTestResult.LeftResultReadings.VisuallyDemonstratedPlaque, (int)ReadingLabels.LeftVisuallyDemonstratedPlaque, testReadingReadingPairs);
                if (customerEventReading != null)
                {
                    customerEventReadingEntities.Add(customerEventReading);
                }

                customerEventReading = CreateEventReadingEntity(leadTestResult.LeftResultReadings.ModerateStenosis, (int)ReadingLabels.LeftModerateStenosis, testReadingReadingPairs);
                if (customerEventReading != null)
                {
                    customerEventReadingEntities.Add(customerEventReading);
                }

                customerEventReading = CreateEventReadingEntity(leadTestResult.LeftResultReadings.PossibleOcclusion, (int)ReadingLabels.LeftPossibleOcclusion, testReadingReadingPairs);
                if (customerEventReading != null)
                {
                    customerEventReadingEntities.Add(customerEventReading);
                }



                if (leadTestResult.LeftResultReadings.Finding != null)
                {
                    //TODO: Service methods being caled from the factory. need to Refactor and Revise it.
                    var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity
                    {
                        StandardFindingTestReadingId =
                            (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding((int)TestType.Lead, (int)ReadingLabels.Left, Convert.ToInt64(leadTestResult.LeftResultReadings.Finding.Id)),
                        CustomerEventTestStandardFindingId = leadTestResult.LeftResultReadings.Finding.CustomerEventStandardFindingId,
                        CustomerEventScreeningTestId       = testResult.Id
                    };

                    var finding = GetSelectedStandardFinding((int)TestType.Lead, (int)ReadingLabels.Left, leadTestResult.LeftResultReadings.Finding.Id);

                    if (finding.ResultInterpretation != null)
                    {
                        resultInterpretations.Add(finding.ResultInterpretation.Value);
                    }
                    if (finding.PathwayRecommendation != null)
                    {
                        pathwayRecommendations.Add(finding.PathwayRecommendation.Value);
                    }

                    customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
                }
            }

            if (leadTestResult.RightResultReadings != null)
            {
                var customerEventReading = CreateEventReadingEntity(leadTestResult.RightResultReadings.CFAPSV, (int)ReadingLabels.RightCFAPSV, testReadingReadingPairs);
                if (customerEventReading != null)
                {
                    customerEventReadingEntities.Add(customerEventReading);
                }

                customerEventReading = CreateEventReadingEntity(leadTestResult.RightResultReadings.PSFAPSV, (int)ReadingLabels.RightPSFAPSV, testReadingReadingPairs);
                if (customerEventReading != null)
                {
                    customerEventReadingEntities.Add(customerEventReading);
                }

                customerEventReading = CreateEventReadingEntity(leadTestResult.RightResultReadings.NoVisualPlaque, (int)ReadingLabels.RightNoVisualPlaque, testReadingReadingPairs);
                if (customerEventReading != null)
                {
                    customerEventReadingEntities.Add(customerEventReading);
                }

                customerEventReading = CreateEventReadingEntity(leadTestResult.RightResultReadings.VisuallyDemonstratedPlaque, (int)ReadingLabels.RightVisuallyDemonstratedPlaque, testReadingReadingPairs);
                if (customerEventReading != null)
                {
                    customerEventReadingEntities.Add(customerEventReading);
                }

                customerEventReading = CreateEventReadingEntity(leadTestResult.RightResultReadings.ModerateStenosis, (int)ReadingLabels.RightModerateStenosis, testReadingReadingPairs);
                if (customerEventReading != null)
                {
                    customerEventReadingEntities.Add(customerEventReading);
                }

                customerEventReading = CreateEventReadingEntity(leadTestResult.RightResultReadings.PossibleOcclusion, (int)ReadingLabels.RightPossibleOcclusion, testReadingReadingPairs);
                if (customerEventReading != null)
                {
                    customerEventReadingEntities.Add(customerEventReading);
                }

                if (leadTestResult.RightResultReadings.Finding != null)
                {
                    //TODO: Service methods being caled from the factory. need to Refactor and Revise it.
                    var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity()
                    {
                        StandardFindingTestReadingId =
                            (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding
                                ((int)TestType.Lead, (int)ReadingLabels.Right, Convert.ToInt64(leadTestResult.RightResultReadings.Finding.Id)),
                        CustomerEventTestStandardFindingId = leadTestResult.RightResultReadings.Finding.CustomerEventStandardFindingId,
                        CustomerEventScreeningTestId       = testResult.Id
                    };

                    var finding = GetSelectedStandardFinding((int)TestType.Lead, (int)ReadingLabels.Right, leadTestResult.RightResultReadings.Finding.Id);

                    if (finding.ResultInterpretation != null)
                    {
                        resultInterpretations.Add(finding.ResultInterpretation.Value);
                    }
                    if (finding.PathwayRecommendation != null)
                    {
                        pathwayRecommendations.Add(finding.PathwayRecommendation.Value);
                    }

                    customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
                }
            }


            if (leadTestResult.LowVelocityLeft != null)
            {
                //TODO: Service methods being caled from the factory. need to Refactor and Revise it.
                var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity()
                {
                    StandardFindingTestReadingId =
                        (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding
                            ((int)TestType.Lead, (int)ReadingLabels.LeftCFAPSV, Convert.ToInt64(leadTestResult.LowVelocityLeft.Id)),
                    CustomerEventTestStandardFindingId = leadTestResult.LowVelocityLeft.CustomerEventStandardFindingId,
                    CustomerEventScreeningTestId       = testResult.Id
                };

                customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
            }

            if (leadTestResult.LowVelocityRight != null)
            {
                //TODO: Service methods being caled from the factory. need to Refactor and Revise it.
                var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity()
                {
                    StandardFindingTestReadingId =
                        (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding
                            ((int)TestType.Lead, (int)ReadingLabels.RightCFAPSV, Convert.ToInt64(leadTestResult.LowVelocityRight.Id)),
                    CustomerEventTestStandardFindingId = leadTestResult.LowVelocityRight.CustomerEventStandardFindingId,
                    CustomerEventScreeningTestId       = testResult.Id
                };

                customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
            }

            if (leadTestResult.TechnicallyLimitedbutReadable != null)
            {
                var customerEventReadingEntity = CreateEventReadingEntity(leadTestResult.TechnicallyLimitedbutReadable, (int)ReadingLabels.TechnicallyLimitedbutReadable, testReadingReadingPairs);
                if (customerEventReadingEntity != null)
                {
                    customerEventReadingEntities.Add(customerEventReadingEntity);
                }
            }

            if (leadTestResult.RepeatStudy != null)
            {
                var customerEventReadingEntity = CreateEventReadingEntity(leadTestResult.RepeatStudy, (int)ReadingLabels.RepeatStudy, testReadingReadingPairs);
                if (customerEventReadingEntity != null)
                {
                    customerEventReadingEntities.Add(customerEventReadingEntity);
                }
            }

            if (leadTestResult.DiagnosisCode != null)
            {
                var customerEventReadingEntity = CreateEventReadingEntity(leadTestResult.DiagnosisCode, (int)ReadingLabels.DiagnosisCode, testReadingReadingPairs);
                if (customerEventReadingEntity != null)
                {
                    customerEventReadingEntities.Add(customerEventReadingEntity);
                }
            }

            if (testResult.ResultStatus.StateNumber == (int)TestResultStateNumber.Evaluated || testResult.ResultStatus.StateNumber == (int)NewTestResultStateNumber.Evaluated)
            {
                testResult.ResultInterpretation  = null;
                testResult.PathwayRecommendation = null;

                if (resultInterpretations.Count > 0)
                {
                    testResult.ResultInterpretation = ResultInterpretation.Normal.GetMax(resultInterpretations);
                }

                if (pathwayRecommendations.Count > 0)
                {
                    testResult.PathwayRecommendation = PathwayRecommendation.None.GetMax(pathwayRecommendations);
                }
            }

            if (customerEventReadingEntities.Count > 0)
            {
                customerEventScreeningTestsEntity.CustomerEventReading.AddRange(customerEventReadingEntities);
            }

            return(customerEventScreeningTestsEntity);
        }
        public override CustomerEventScreeningTestsEntity CreateActualTestResultEntity(TestResult testResult, List <OrderedPair <int, int> > testReadingReadingPairs)
        {
            var awvEkgIppeTestResult = testResult as AwvEkgIppeTestResult;

            var customerEventScreeningTestEntity = new CustomerEventScreeningTestsEntity(testResult.Id)
            {
                TestId = (int)TestType.AwvEkgIPPE
            };
            var customerEventReadingEntities = new List <CustomerEventReadingEntity>();

            if (awvEkgIppeTestResult != null)
            {
                CustomerEventReadingEntity customerEventTestReadingEntity;
                if (awvEkgIppeTestResult.PRInterval != null)
                {
                    customerEventTestReadingEntity = CreateEventReadingEntity(awvEkgIppeTestResult.PRInterval, (int)ReadingLabels.PRInterval, testReadingReadingPairs);
                    customerEventReadingEntities.Add(customerEventTestReadingEntity);
                }

                if (awvEkgIppeTestResult.QRSDuration != null)
                {
                    customerEventTestReadingEntity = CreateEventReadingEntity(awvEkgIppeTestResult.QRSDuration, (int)ReadingLabels.QRSDuration, testReadingReadingPairs);
                    customerEventReadingEntities.Add(customerEventTestReadingEntity);
                }

                if (awvEkgIppeTestResult.PRTAxis != null)
                {
                    if (awvEkgIppeTestResult.PRTAxis.PFront != null)
                    {
                        customerEventTestReadingEntity = CreateEventReadingEntity(awvEkgIppeTestResult.PRTAxis.PFront, (int)ReadingLabels.PRTAxisPFront, testReadingReadingPairs);
                        customerEventReadingEntities.Add(customerEventTestReadingEntity);
                    }

                    if (awvEkgIppeTestResult.PRTAxis.QRSFront != null)
                    {
                        customerEventTestReadingEntity = CreateEventReadingEntity(awvEkgIppeTestResult.PRTAxis.QRSFront, (int)ReadingLabels.PRTAxisQRSFront, testReadingReadingPairs);
                        customerEventReadingEntities.Add(customerEventTestReadingEntity);
                    }

                    if (awvEkgIppeTestResult.PRTAxis.TFront != null)
                    {
                        customerEventTestReadingEntity = CreateEventReadingEntity(awvEkgIppeTestResult.PRTAxis.TFront, (int)ReadingLabels.PRTAxisTFront, testReadingReadingPairs);
                        customerEventReadingEntities.Add(customerEventTestReadingEntity);
                    }
                }

                if (awvEkgIppeTestResult.QTcInterval != null)
                {
                    customerEventTestReadingEntity = CreateEventReadingEntity(awvEkgIppeTestResult.QTcInterval, (int)ReadingLabels.QTcInterval, testReadingReadingPairs);
                    customerEventReadingEntities.Add(customerEventTestReadingEntity);
                }

                if (awvEkgIppeTestResult.QTDispersion != null)
                {
                    customerEventTestReadingEntity = CreateEventReadingEntity(awvEkgIppeTestResult.QTDispersion, (int)ReadingLabels.QTDispersion, testReadingReadingPairs);
                    customerEventReadingEntities.Add(customerEventTestReadingEntity);
                }

                if (awvEkgIppeTestResult.QTInterval != null)
                {
                    customerEventTestReadingEntity = CreateEventReadingEntity(awvEkgIppeTestResult.QTInterval, (int)ReadingLabels.QTInterval, testReadingReadingPairs);
                    customerEventReadingEntities.Add(customerEventTestReadingEntity);
                }

                if (awvEkgIppeTestResult.RRInterval != null)
                {
                    customerEventTestReadingEntity = CreateEventReadingEntity(awvEkgIppeTestResult.RRInterval, (int)ReadingLabels.RRInterval, testReadingReadingPairs);
                    customerEventReadingEntities.Add(customerEventTestReadingEntity);
                }

                if (awvEkgIppeTestResult.VentRate != null)
                {
                    customerEventTestReadingEntity = CreateEventReadingEntity(awvEkgIppeTestResult.VentRate, (int)ReadingLabels.VentRate, testReadingReadingPairs);
                    customerEventReadingEntities.Add(customerEventTestReadingEntity);
                }

                testResult.ResultInterpretation = null;
                if (awvEkgIppeTestResult.Finding != null)
                {
                    var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity
                    {
                        StandardFindingTestReadingId =
                            (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding((int)TestType.AwvEkgIPPE, null, Convert.ToInt64(awvEkgIppeTestResult.Finding.Id)),
                        CustomerEventTestStandardFindingId = awvEkgIppeTestResult.Finding.CustomerEventStandardFindingId,
                        CustomerEventScreeningTestId       = testResult.Id,
                    };

                    var finding = GetSelectedStandardFinding((int)TestType.AwvEkgIPPE, null, awvEkgIppeTestResult.Finding.Id);

                    if (testResult.ResultStatus.StateNumber == (int)TestResultStateNumber.Evaluated || testResult.ResultStatus.StateNumber == (int)NewTestResultStateNumber.Evaluated)
                    {
                        testResult.ResultInterpretation  = finding.ResultInterpretation;
                        testResult.PathwayRecommendation = finding.PathwayRecommendation;
                    }
                    customerEventScreeningTestEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
                }

                if (awvEkgIppeTestResult.BundleBranchBlockFinding != null && awvEkgIppeTestResult.BundleBranchBlockFinding.Count > 0)
                {
                    awvEkgIppeTestResult.BundleBranchBlockFinding.ForEach(finding =>
                    {
                        var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity
                        {
                            StandardFindingTestReadingId       = (int?)new TestResultService().GetStandardFindingTestReadingIdForStandardFinding((int)TestType.AwvEkgIPPE, (int)ReadingLabels.BundleBranchBlock, Convert.ToInt64(finding.Id)),
                            CustomerEventTestStandardFindingId = finding.CustomerEventStandardFindingId,
                            CustomerEventScreeningTestId       = testResult.Id,
                        };

                        customerEventScreeningTestEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
                    });
                }

                if (awvEkgIppeTestResult.InfarctionPatternFinding != null && awvEkgIppeTestResult.InfarctionPatternFinding.Count > 0)
                {
                    awvEkgIppeTestResult.InfarctionPatternFinding.ForEach(finding =>
                    {
                        var customerEventTestStandardFindingEntity = new CustomerEventTestStandardFindingEntity
                        {
                            StandardFindingTestReadingId =
                                (int?)
                                new TestResultService().
                                GetStandardFindingTestReadingIdForStandardFinding
                                    ((int)TestType.AwvEkgIPPE, (int)ReadingLabels.InfarctionPattern,
                                    Convert.ToInt64(finding.Id)),
                            CustomerEventTestStandardFindingId = finding.CustomerEventStandardFindingId,
                            CustomerEventScreeningTestId       = testResult.Id,
                        };

                        customerEventScreeningTestEntity.CustomerEventTestStandardFinding.Add(customerEventTestStandardFindingEntity);
                    });
                }

                if (awvEkgIppeTestResult.SinusRythm != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.SinusRythm, (int)ReadingLabels.SinusRythm, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.SinusArrythmia != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.SinusArrythmia, (int)ReadingLabels.SinusArrythmia, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.SinusBradycardia != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.SinusBradycardia, (int)ReadingLabels.SinusBradycardia, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.Mild != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.Mild, (int)ReadingLabels.Mild, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.Marked != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.Marked, (int)ReadingLabels.Marked, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.SinusTachycardia != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.SinusTachycardia, (int)ReadingLabels.SinusTachycardia, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.AtrialFibrillation != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.AtrialFibrillation, (int)ReadingLabels.AtrialFibrillation, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.AtrialFlutter != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.AtrialFlutter, (int)ReadingLabels.AtrialFlutter, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.SVT != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.SVT, (int)ReadingLabels.SVT, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.PACs != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.PACs, (int)ReadingLabels.PACs, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.PVCs != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.PVCs, (int)ReadingLabels.PVCs, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.QRSWidening != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.QRSWidening, (int)ReadingLabels.QRSWidening, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.LeftAxis != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.LeftAxis, (int)ReadingLabels.LeftAxis, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.RightAxis != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.RightAxis, (int)ReadingLabels.RightAxis, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.AbnormalAxis != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.AbnormalAxis, (int)ReadingLabels.AbnormalAxis, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.Left != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.Left, (int)ReadingLabels.Left, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.Right != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.Right, (int)ReadingLabels.Right, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.HeartBlock != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.HeartBlock, (int)ReadingLabels.HeartBlock, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.TypeI != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.TypeI, (int)ReadingLabels.TypeI, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.TypeII != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.TypeII, (int)ReadingLabels.TypeII, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.FirstDegreeBlock != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.FirstDegreeBlock, (int)ReadingLabels.FirstDegreeBlock, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.SecondDegreeBlock != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.SecondDegreeBlock, (int)ReadingLabels.SecondDegreeBlock, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.ThirdDegreeCompleteHeartBlock != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.ThirdDegreeCompleteHeartBlock, (int)ReadingLabels.ThirdDegreeCompleteHeartBlock, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.Artifact != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.Artifact, (int)ReadingLabels.Artifact, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.SupraventricularArrythmia != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.SupraventricularArrythmia, (int)ReadingLabels.SupraventricularArrythmia, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.PacerRythm != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.PacerRythm, (int)ReadingLabels.PacerRythm, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.BundleBranchBlock != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.BundleBranchBlock, (int)ReadingLabels.BundleBranchBlock, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.LeftAnteriorFasicularBlock != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.LeftAnteriorFasicularBlock, (int)ReadingLabels.LeftAnteriorFasicularBlock, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.VentricularHypertrophy != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.VentricularHypertrophy, (int)ReadingLabels.VentricularHypertrophy, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.LeftVentricularHypertrophy != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.LeftVentricularHypertrophy, (int)ReadingLabels.LeftVHypertrophy, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.RightVentricularHypertrophy != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.RightVentricularHypertrophy, (int)ReadingLabels.RightVHypertrophy, testReadingReadingPairs));
                }


                if (awvEkgIppeTestResult.IschemicSTTChanges != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.IschemicSTTChanges, (int)ReadingLabels.IschemicSTTChanges, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.NonSpecificSTTChanges != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.NonSpecificSTTChanges, (int)ReadingLabels.NonSpecificSTTChanges, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.PoorRWaveProgression != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.PoorRWaveProgression, (int)ReadingLabels.PoorRWaveProgression, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.ProlongedQTInterval != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.ProlongedQTInterval, (int)ReadingLabels.ProlongedQTInterval, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.InfarctionPattern != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.InfarctionPattern, (int)ReadingLabels.InfarctionPattern, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.AtypicalQWaveLead != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.AtypicalQWaveLead, (int)ReadingLabels.AtypicalQWaveLead, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.AtrialEnlargement != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.AtrialEnlargement, (int)ReadingLabels.AtrialEnlargement, testReadingReadingPairs));
                }


                if (awvEkgIppeTestResult.LeftAtrialEnlargement != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.LeftAtrialEnlargement, (int)ReadingLabels.LeftAtrialEnlargment, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.RightAtrialEnlargement != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.RightAtrialEnlargement, (int)ReadingLabels.RightAtrialEnlargment, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.RepolarizationVariant != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.RepolarizationVariant, (int)ReadingLabels.RepolarizationVariant, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.ReversedLeads != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.ReversedLeads, (int)ReadingLabels.ReversedLeads, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.RepeatStudy != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.RepeatStudy, (int)ReadingLabels.RepeatStudy, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.ComparetoEkg != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.ComparetoEkg, (int)ReadingLabels.ComparetoEkg, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.LowVoltage != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.LowVoltage, (int)ReadingLabels.LowVoltage, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.LimbLeads != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.LimbLeads, (int)ReadingLabels.LimbLeads, testReadingReadingPairs));
                }

                if (awvEkgIppeTestResult.PrecordialLeads != null)
                {
                    customerEventReadingEntities.Add(CreateEventReadingEntity(awvEkgIppeTestResult.PrecordialLeads, (int)ReadingLabels.PrecordialLeads, testReadingReadingPairs));
                }
            }

            customerEventScreeningTestEntity.CustomerEventReading.AddRange(customerEventReadingEntities);
            return(customerEventScreeningTestEntity);
        }