Esempio n. 1
0
        private CompoundResultReading <T> GetResultReading <T>(T reading, ReadingLabels label, int?readingForFinding, TestType type, ref string errorSummary)
        {
            try
            {
                var resultReading = new CompoundResultReading <T>
                {
                    Label         = label,
                    ReadingSource = ReadingSource.Automatic,
                    Reading       = reading
                };

                if (readingForFinding != null)
                {
                    resultReading.Finding = new StandardFinding <T>(_testResultService.GetCalculatedStandardFinding(readingForFinding, (int)type, (int)label));
                }

                return(resultReading);
            }
            catch (Exception ex)
            {
                string message = string.Format("Exception while extracting value for {0}. Message: {1} ", label.ToString(), ex.Message);
                _logger.Error(message);
                errorSummary += message;
            }

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

            GetAwvAaaSaggitalView(testResult, xDoc);

            GetAwvAaaTransverseViewValues(testResult, xDoc);

            var aortaValue = GetMaxofthreeAortaValues(testResult);

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

            bool isExceptionCaused;

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

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

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

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

            testResult.AortaSize = GetAaaAortaValues(xDoc);

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

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

            bool isExceptionCaused;

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

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

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

            return(testResult);
        }
        private CompoundResultReading <int?> CalculateLdlReading(decimal?hdl, decimal?tchol, decimal?triglycerides, TestType testType)
        {
            if (!hdl.HasValue || hdl.Value <= 0 || !tchol.HasValue || tchol.Value <= 0 || !triglycerides.HasValue || triglycerides.Value <= 0)
            {
                return(null);
            }
            var testResultService = new Service.TestResultService();
            var ldl = tchol.Value - hdl.Value - (triglycerides.Value / 5);

            return(new CompoundResultReading <int?>
            {
                Reading = Convert.ToInt32(ldl),
                Label = ReadingLabels.LDL,
                ReadingSource = ReadingSource.Manual,
                Finding = new StandardFinding <int?>(testResultService.GetCalculatedStandardFinding(Convert.ToInt32(ldl), (int)testType, (int)ReadingLabels.LDL))
            });
        }
Esempio n. 5
0
        public TestResult Parse(DataTable dtSourceFromExcel)
        {
            var testResult = new AAATestResult();

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

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

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

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

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

            return(testResult);
        }
        private CompoundResultReading <decimal?> CalculateTchdlRatio(decimal?totalCholesterol, decimal?hdl, TestType testType)
        {
            if (hdl == null || totalCholesterol == null)
            {
                return(null);
            }
            var testResultService = new Service.TestResultService();

            var s = totalCholesterol.Value / hdl.Value;

            s = decimal.Round(s, 2);

            return(new CompoundResultReading <decimal?>
            {
                Reading = s,
                Label = ReadingLabels.TCHDLRatio,
                ReadingSource = ReadingSource.Manual,
                Finding = new StandardFinding <decimal?>(testResultService.GetCalculatedStandardFinding(s, (int)testType, (int)ReadingLabels.TCHDLRatio))
            });
        }
Esempio n. 7
0
        private void LoadLipidFinding(HtmlDocument doc, LipidTestResult testResult, bool isMale)
        {
            var hdlFinding       = _standardFindingRepository.GetAllStandardFindings <string>((int)TestType.Lipid, (int)ReadingLabels.HDL);
            var ldlFinding       = _standardFindingRepository.GetAllStandardFindings <int?>((int)TestType.Lipid, (int)ReadingLabels.LDL);
            var glucoseFinding   = _standardFindingRepository.GetAllStandardFindings <int?>((int)TestType.Lipid, (int)ReadingLabels.Glucose);
            var trigFinding      = _standardFindingRepository.GetAllStandardFindings <string>((int)TestType.Lipid, (int)ReadingLabels.TriGlycerides);
            var totalCholFinding = _standardFindingRepository.GetAllStandardFindings <string>((int)TestType.Lipid, (int)ReadingLabels.TotalCholestrol);
            var tcHdlFinding     = _standardFindingRepository.GetAllStandardFindings <decimal?>((int)TestType.Lipid, (int)ReadingLabels.TCHDLRatio);

            hdlFinding = FilterMaleFemalRecordsontheGenderBasis(hdlFinding, isMale).ToList();

            UnableScreenReason unableScreenReason = null;

            if (testResult != null && testResult.UnableScreenReason != null && testResult.UnableScreenReason.Count > 0)
            {
                unableScreenReason = testResult.UnableScreenReason.First();
            }

            StandardFinding <string> hdlFindingForLongDescription = null;
            int t = 0;

            if (testResult != null && testResult.HDL != null && !string.IsNullOrEmpty(testResult.HDL.Reading) && int.TryParse(testResult.HDL.Reading, out t))
            {
                var findingIds = _testResultService.GetMultipleCalculatedStandardFinding(t, (int)TestType.Lipid, (int)ReadingLabels.HDL);
                if (findingIds != null && findingIds.Count() > 0)
                {
                    hdlFindingForLongDescription = hdlFinding.Where(fd => findingIds.Contains(fd.Id)).SingleOrDefault();
                }
            }
            _resultPdfHelper.SetSummaryFindings(doc, testResult != null && testResult.HDL != null ? testResult.HDL.Finding : null, hdlFinding, "FindingsHdlDiv", "longdescription-hdl", hdlFindingForLongDescription, testResult != null, unableScreenReason);
            _resultPdfHelper.SetFindingsVertical(doc, testResult != null && testResult.HDL != null ? testResult.HDL.Finding : null, hdlFinding, "hdlFinding");



            StandardFinding <int?> ldlFindingForLongDescription = null;

            if (testResult != null && testResult.LDL != null && testResult.LDL.Reading.HasValue)
            {
                var findingId = _testResultService.GetCalculatedStandardFinding(testResult.LDL.Reading, (int)TestType.Lipid, (int)ReadingLabels.LDL);
                if (findingId > 0)
                {
                    ldlFindingForLongDescription = ldlFinding.Where(fd => findingId == fd.Id).SingleOrDefault();
                }
            }
            _resultPdfHelper.SetSummaryFindings(doc, testResult != null && testResult.LDL != null ? testResult.LDL.Finding : null, ldlFinding, "FindingsLdlDiv", "longdescription-ldl", ldlFindingForLongDescription, testResult != null, unableScreenReason);
            _resultPdfHelper.SetFindingsVertical(doc, testResult != null && testResult.LDL != null ? testResult.LDL.Finding : null, ldlFinding, "ldlFinding");


            StandardFinding <int?> glucoseFindingForLongDescription = null;

            if (testResult != null && testResult.Glucose != null && testResult.Glucose.Reading.HasValue)
            {
                var findingId = _testResultService.GetCalculatedStandardFinding(testResult.Glucose.Reading, (int)TestType.Lipid, (int)ReadingLabels.Glucose);
                if (findingId > 0)
                {
                    glucoseFindingForLongDescription = glucoseFinding.Where(fd => findingId == fd.Id).SingleOrDefault();
                }
            }
            _resultPdfHelper.SetSummaryFindings(doc, testResult != null && testResult.Glucose != null ? testResult.Glucose.Finding : null, glucoseFinding, "FindingsGlucoseDiv", "longdescription-glucose", glucoseFindingForLongDescription, testResult != null, unableScreenReason);
            _resultPdfHelper.SetFindingsVertical(doc, testResult != null && testResult.Glucose != null ? testResult.Glucose.Finding : null, glucoseFinding, "glucoseFinding");

            _resultPdfHelper.SetFindingsVertical(doc, testResult != null && testResult.TriGlycerides != null ? testResult.TriGlycerides.Finding : null, trigFinding, "triglyceridesFinding");
            _resultPdfHelper.SetFindingsVertical(doc, testResult != null && testResult.TotalCholestrol != null ? testResult.TotalCholestrol.Finding : null, totalCholFinding, "totalCholestrolFinding");
            _resultPdfHelper.SetFindingsVertical(doc, testResult != null && testResult.TCHDLRatio != null ? testResult.TCHDLRatio.Finding : null, tcHdlFinding, "tchdlRatioFinding");
        }
Esempio n. 8
0
        public void LoadPadTestResults(HtmlDocument doc, PADTestResult testResult, bool removeLongDescription, IEnumerable <CustomerScreeningEvaluatinPhysicianViewModel> physicians, IEnumerable <EventPhysicianTest> eventPhysicianTests,
                                       List <OrderedPair <long, string> > technicianIdNamePairs, IEnumerable <PhysicianEvaluation> eventCustomerPhysicianEvaluations, CustomerSkipReview customerSkipReview)
        {
            var incidentalFindings = _incidentalFindingRepository.GetAllIncidentalFinding((int)TestType.PAD);

            if (testResult != null)
            {
                var selectedNode = doc.DocumentNode.SelectSingleNode("//div[@id='pad-rpp-section']");
                if (selectedNode != null && (testResult.UnableScreenReason == null || testResult.UnableScreenReason.Count == 0) && (testResult.TestNotPerformed == null || testResult.TestNotPerformed.TestNotPerformedReasonId <= 0) &&
                    (testResult.RepeatStudy == null || testResult.RepeatStudy.Reading == false))
                {
                    selectedNode.SetAttributeValue("style", "display:block;");
                }

                selectedNode = doc.DocumentNode.SelectSingleNode("//div[@id='rpp-eus-pad-div']");
                if (selectedNode != null)
                {
                    selectedNode.SetAttributeValue("style", "display:block;");
                }

                _resultPdfHelper.SetPhysicianSignature(doc, "pad-primaryEvalPhysicianSign", "pad-overreadEvalPhysicianSign", physicians, eventPhysicianTests, eventCustomerPhysicianEvaluations, customerSkipReview);

                var     readings = new TestResultRepository().GetAllReadings((int)TestType.PAD);
                decimal?leftAbi  = null;
                decimal?rightAbi = null;

                foreach (var resultReading in readings)
                {
                    switch (resultReading.Label)
                    {
                    case ReadingLabels.LeftABI:
                        if (testResult.LeftResultReadings != null)
                        {
                            _resultPdfHelper.SetInputBox(doc, "txtLeftAbi", testResult.LeftResultReadings.ABI);

                            if (testResult.LeftResultReadings.ABI != null && testResult.LeftResultReadings.ABI.Reading.HasValue)
                            {
                                leftAbi = testResult.LeftResultReadings.ABI.Reading;

                                selectedNode = doc.DocumentNode.SelectSingleNode("//span[@id='pad-at-a-glance-finding-left']");
                                if (selectedNode != null)
                                {
                                    selectedNode.InnerHtml = testResult.LeftResultReadings.ABI.Reading.Value.ToString("0.00");
                                }
                            }
                        }
                        break;

                    case ReadingLabels.SystolicLArm:
                        if (testResult.LeftResultReadings != null)
                        {
                            _resultPdfHelper.SetInputBox(doc, "txtSystolicLeftArm", testResult.LeftResultReadings.SystolicArm);
                        }
                        break;

                    case ReadingLabels.SystolicLAnkle:
                        if (testResult.LeftResultReadings != null)
                        {
                            _resultPdfHelper.SetInputBox(doc, "txtSystolicLeftAnkle", testResult.LeftResultReadings.SystolicAnkle);
                        }
                        break;

                    case ReadingLabels.RightABI:
                        if (testResult.RightResultReadings != null)
                        {
                            _resultPdfHelper.SetInputBox(doc, "txtRightAbi", testResult.RightResultReadings.ABI);
                            if (testResult.RightResultReadings.ABI != null && testResult.RightResultReadings.ABI.Reading.HasValue)
                            {
                                rightAbi = testResult.RightResultReadings.ABI.Reading;

                                selectedNode = doc.DocumentNode.SelectSingleNode("//span[@id='pad-at-a-glance-finding-right']");
                                if (selectedNode != null)
                                {
                                    selectedNode.InnerHtml = testResult.RightResultReadings.ABI.Reading.Value.ToString("0.00");
                                }
                            }
                        }
                        break;

                    case ReadingLabels.SystolicRArm:
                        if (testResult.RightResultReadings != null)
                        {
                            _resultPdfHelper.SetInputBox(doc, "txtSystolicRightArm", testResult.RightResultReadings.SystolicArm);
                        }
                        break;

                    case ReadingLabels.SystolicRAnkle:
                        if (testResult.RightResultReadings != null)
                        {
                            _resultPdfHelper.SetInputBox(doc, "txtSystolicRightAnkle", testResult.RightResultReadings.SystolicAnkle);
                        }
                        break;

                    case ReadingLabels.SystolicHighestArm:
                        _resultPdfHelper.SetInputBox(doc, "systolicHighestArm", testResult.SystolicHighestArm);
                        break;

                    case ReadingLabels.RepeatStudy:
                        _resultPdfHelper.SetCheckBox(doc, "RepeatStudyPadInputCheck", testResult.RepeatStudy);
                        break;

                    case ReadingLabels.LeftUnabletoOcclude:
                        if (testResult.LeftResultReadings != null)
                        {
                            _resultPdfHelper.SetCheckBox(doc, "leftunabletoocclude-checkbox", testResult.LeftResultReadings.UnabletoOcclude);
                        }

                        break;

                    case ReadingLabels.RightUnabletoOcclude:
                        if (testResult.RightResultReadings != null)
                        {
                            _resultPdfHelper.SetCheckBox(doc, "rightunabletoocclude-checkbox", testResult.RightResultReadings.UnabletoOcclude);
                        }

                        break;
                    }
                }

                decimal?abi;
                long    leftFindingId = 0;
                if (leftAbi != null)
                {
                    leftFindingId = _testResultService.GetCalculatedStandardFinding(leftAbi.Value, (int)TestType.PAD, null);
                }

                long rightFindingId = 0;
                if (rightAbi != null)
                {
                    rightFindingId = _testResultService.GetCalculatedStandardFinding(rightAbi.Value, (int)TestType.PAD, null);
                }

                var standardFindingList = _standardFindingRepository.GetAllStandardFindings <decimal>((int)TestType.PAD);

                long findingId = 0;

                if (leftFindingId == rightFindingId)
                {
                    findingId = leftFindingId;
                }
                else if (leftFindingId > 0 && rightFindingId > 0)
                {
                    var lf = standardFindingList.Where(f => f.Id == leftFindingId).Single();
                    var rf = standardFindingList.Where(f => f.Id == rightFindingId).Single();

                    findingId = lf.WorstCaseOrder > rf.WorstCaseOrder ? lf.Id : rf.Id;
                }
                else
                {
                    findingId = leftFindingId > rightFindingId ? leftFindingId : rightFindingId;
                }

                if (findingId > 0 && findingId == leftFindingId)
                {
                    abi = leftAbi;
                }
                else
                {
                    abi = rightAbi;
                }

                _resultPdfHelper.SetInputBox(doc, "abi-pad-summary", new ResultReading <decimal?> {
                    Reading = abi
                });
                LoadPadFindings(doc, testResult.Finding, standardFindingList, findingId, true, (testResult.UnableScreenReason != null && testResult.UnableScreenReason.Count > 0 ? testResult.UnableScreenReason.First() : null));
                _resultPdfHelper.SetTechnician(doc, testResult, "techPad", "technotespad", technicianIdNamePairs);
                _resultPdfHelper.SetIncidentalFindings(doc, incidentalFindings, testResult.IncidentalFindings, "padIncidentalFinding");
                _resultPdfHelper.SetPhysicianRemarks(doc, testResult, "followUpPad", "criticalPad", "physicianRemarksPad");
                _resultPdfHelper.SetUnableToScreenReasons(doc, TestType.PAD, "padUnableToScreen", testResult.UnableScreenReason);

                if (testResult.IncidentalFindings != null && testResult.IncidentalFindings.Count() > 0)
                {
                    selectedNode = doc.DocumentNode.SelectSingleNode("//p[@id='incidentalfinding-description-pad']");
                    if (selectedNode != null)
                    {
                        selectedNode.SetAttributeValue("style", "display:block;");
                    }
                }
                if (testResult.Finding != null)
                {
                    selectedNode = doc.DocumentNode.SelectSingleNode("//span[@id='pad-at-a-glance-result']");
                    if (selectedNode != null && testResult.ResultInterpretation.HasValue)
                    {
                        selectedNode.InnerHtml = ((ResultInterpretation)testResult.ResultInterpretation).ToString();
                    }


                    selectedNode = doc.DocumentNode.SelectSingleNode("//img[@id='pad-at-a-glance-findingImage']");
                    if (selectedNode != null)
                    {
                        if (testResult.Finding.Label.ToLower() == PadNormal.ToLower())
                        {
                            selectedNode.SetAttributeValue("src", StringforContentDirectory + "/NMMSV_N.png");
                        }
                        else if (testResult.Finding.Label.ToLower() == PadMild.ToLower())
                        {
                            selectedNode.SetAttributeValue("src", StringforContentDirectory + "/NMMSV_M.png");
                        }
                        else if (testResult.Finding.Label.ToLower() == PadModerate.ToLower())
                        {
                            selectedNode.SetAttributeValue("src", StringforContentDirectory + "/NMMSV_MD.png");
                        }
                        else if (testResult.Finding.Label.ToLower() == PadSevere.ToLower())
                        {
                            selectedNode.SetAttributeValue("src", StringforContentDirectory + "/NMMSV_S.png");
                        }
                        else
                        {
                            selectedNode.SetAttributeValue("src", StringforContentDirectory + "/NoIndication_NMMSV.png");
                        }
                    }
                }

                if (testResult.UnableScreenReason != null && testResult.UnableScreenReason.Count > 0)
                {
                    selectedNode = doc.DocumentNode.SelectSingleNode("//div[@id='pad-at-a-glance-finding']");
                    if (selectedNode != null)
                    {
                        selectedNode.SetAttributeValue("style", "display:none;");
                    }

                    selectedNode = doc.DocumentNode.SelectSingleNode("//div[@id='pad-at-a-glance-unabletoscreen']");
                    if (selectedNode != null)
                    {
                        selectedNode.SetAttributeValue("style", "display:block;");
                    }

                    selectedNode = doc.DocumentNode.SelectSingleNode("//span[@id='pad-at-a-glance-result']");
                    if (selectedNode != null)
                    {
                        selectedNode.InnerHtml = "N/A";
                    }

                    selectedNode = doc.DocumentNode.SelectSingleNode("//img[@id='pad-at-a-glance-findingImage']");
                    if (selectedNode != null)
                    {
                        selectedNode.SetAttributeValue("src", StringforContentDirectory + "/NoIndication_NMMSV.png");
                    }
                }

                selectedNode = doc.DocumentNode.SelectSingleNode("//div[@id='pad-longdescription-div']");
                if (selectedNode != null)
                {
                    selectedNode.SetAttributeValue("style", removeLongDescription ? "display:none" : "display:block");
                }
            }
            else
            {
                LoadPadFindings(doc, null, null, 0, false);
                _resultPdfHelper.SetUnableToScreenReasons(doc, TestType.PAD, "padUnableToScreen", null);
                _resultPdfHelper.SetIncidentalFindings(doc, incidentalFindings, null, "padIncidentalFinding");
            }
        }
Esempio n. 9
0
        public TestResult Parse(DataRow dr)
        {
            _errorSummary = string.Empty;
            var testResult = new LipidTestResult();

            if (!CheckifRowContainsAnyReadingData(dr))
            {
                return(null);
            }

            try
            {
                if (!IsDataRowItemEmpty(dr[ColumnGlu]))
                {
                    int s = 0;
                    if (int.TryParse(dr[ColumnGlu].ToString(), out s))
                    {
                        var findingId = _testResultService.GetCalculatedStandardFinding(s, (int)TestType.Lipid, (int)ReadingLabels.Glucose);
                        testResult.Glucose = new CompoundResultReading <int?>(ReadingLabels.Glucose)
                        {
                            ReadingSource = ReadingSource.Automatic,
                            Reading       = s,
                            Finding       = findingId > 0 ? new StandardFinding <int?>(findingId) : null
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                _errorSummary += "Data extraction for Glucose failed. ";
                _logger.Error("\n Data extraction for Glucose failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace);
            }

            try
            {
                if (!IsDataRowItemEmpty(dr[ColumnLdl]))
                {
                    int s = 0;
                    if (int.TryParse(dr[ColumnLdl].ToString(), out s))
                    {
                        var findingId = _testResultService.GetCalculatedStandardFinding(s, (int)TestType.Lipid,
                                                                                        (int)ReadingLabels.LDL);
                        testResult.LDL = new CompoundResultReading <int?>(ReadingLabels.LDL)
                        {
                            ReadingSource = ReadingSource.Automatic,
                            Reading       = s,
                            Finding       = findingId > 0 ? new StandardFinding <int?>(findingId) : null
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                _errorSummary += "Data extraction for LDL failed. ";
                _logger.Error("\n Data extraction for LDL failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace);
            }


            try
            {
                if (!IsDataRowItemEmpty(dr[ColumnTc]))
                {
                    testResult.TotalCholestrol = new CompoundResultReading <string>(ReadingLabels.TotalCholestrol)
                    {
                        ReadingSource = ReadingSource.Automatic,
                        Reading       = dr[ColumnTc].ToString()
                    };

                    int s;
                    if (int.TryParse(dr[ColumnTc].ToString(), out s))
                    {
                        var findingId = _testResultService.GetCalculatedStandardFinding(s, (int)TestType.Lipid, (int)ReadingLabels.TotalCholestrol);
                        testResult.TotalCholestrol.Finding = findingId > 0 ? new StandardFinding <string>(findingId) : null;
                    }
                }
            }
            catch (Exception ex)
            {
                _errorSummary += "Data extraction for Total Cholestrol failed. ";
                _logger.Error("\n Data extraction for Total Cholestrol failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace);
            }

            try
            {
                if (!IsDataRowItemEmpty(dr[ColumnHdl]))
                {
                    testResult.HDL = new CompoundResultReading <string>(ReadingLabels.HDL)
                    {
                        ReadingSource = ReadingSource.Automatic,
                        Reading       = dr[ColumnHdl].ToString()
                    };

                    //int s;
                    //if (int.TryParse(dr[ColumnHdl].ToString(), out s))
                    //{
                    //    var findingId = _testResultService.GetCalculatedStandardFinding(s, (int)TestType.Lipid, (int)ReadingLabels.HDL);
                    //    testResult.HDL.Finding = findingId > 0 ? new StandardFinding<string>(findingId) : null;
                    //}
                }
            }
            catch (Exception ex)
            {
                _errorSummary += "Data extraction for HDL failed. ";
                _logger.Error("\n Data extraction for HDL failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace);
            }

            try
            {
                if (!IsDataRowItemEmpty(dr[ColumnTrig]))
                {
                    testResult.TriGlycerides = new CompoundResultReading <string>(ReadingLabels.TriGlycerides)
                    {
                        ReadingSource = ReadingSource.Automatic,
                        Reading       = dr[ColumnTrig].ToString()
                    };

                    int s;
                    if (int.TryParse(dr[ColumnTrig].ToString(), out s))
                    {
                        var findingId = _testResultService.GetCalculatedStandardFinding(s, (int)TestType.Lipid, (int)ReadingLabels.TriGlycerides);
                        testResult.TriGlycerides.Finding = findingId > 0 ? new StandardFinding <string>(findingId) : null;
                    }
                }
            }
            catch (Exception ex)
            {
                _errorSummary += "Data extraction for Triglycerides failed. ";
                _logger.Error("\n Data extraction for Triglycerides failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace);
            }


            try
            {
                decimal?value = null;
                if (!IsDataRowItemEmpty(dr[ColumnTchdl]))
                {
                    decimal s = 0;
                    if (decimal.TryParse(dr[ColumnTchdl].ToString(), out s))
                    {
                        value = s;
                    }
                }
                else
                {
                    int tc  = 0;
                    int hdl = 0;
                    if (testResult.TotalCholestrol != null && int.TryParse(testResult.TotalCholestrol.Reading, out tc) && testResult.HDL != null && int.TryParse(testResult.HDL.Reading, out hdl))
                    {
                        value = ((decimal)tc / hdl);
                    }
                }

                if (value != null)
                {
                    var findingId = _testResultService.GetCalculatedStandardFinding(value, (int)TestType.Lipid, (int)ReadingLabels.TCHDLRatio);
                    testResult.TCHDLRatio = new CompoundResultReading <decimal?>(ReadingLabels.TCHDLRatio)
                    {
                        ReadingSource = ReadingSource.Automatic,
                        Reading       = value,
                        Finding       = new StandardFinding <decimal?>(findingId)
                    };
                }
            }
            catch (Exception ex)
            {
                _errorSummary += "Data extraction for TC-HDL failed. ";
                _logger.Error("\n Data extraction for TC-HDL failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace);
            }
            return(testResult);
        }
Esempio n. 10
0
        public TestResult Parse(DataRow dr)
        {
            _errorSummary = string.Empty;

            if (!CheckifRowContainsAnyReadingData(dr))
            {
                return(null);
            }
            var testResult = new ASITestResult();

            if (!IsDataRowItemEmpty(dr[ColumnPulse]) || !IsDataRowItemEmpty(dr[ColumnPulsePressure]) || !IsDataRowItemEmpty(dr[ColumnSystolic]) || !IsDataRowItemEmpty(dr[ColumnDiastolic]))
            {
                testResult.PressureReadings = new CardiovisionPressureReadings();
            }

            SetBloodPressureValues(testResult, dr);

            try
            {
                if (!IsDataRowItemEmpty(dr[ColumnAsi]))
                {
                    int s = 0;
                    if (int.TryParse(dr[ColumnAsi].ToString(), out s))
                    {
                        var findingId = _testResultService.GetCalculatedStandardFinding(s, (int)TestType.ASI,
                                                                                        (int)ReadingLabels.ASI);
                        testResult.ASI = new CompoundResultReading <int?>(ReadingLabels.ASI)
                        {
                            ReadingSource = ReadingSource.Automatic,
                            Reading       = s,
                            Finding       = findingId > 0 ? new StandardFinding <int?>(findingId) : null
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                _errorSummary += "Data extraction for ASI failed. ";
                _logger.Error("\n Data extraction for ASI failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace);
            }

            try
            {
                if (!IsDataRowItemEmpty(dr[ColumnPulse]))
                {
                    int s = 0;
                    if (int.TryParse(dr[ColumnPulse].ToString(), out s))
                    {
                        testResult.PressureReadings.Pulse = new ResultReading <int?>(ReadingLabels.Pulse)
                        {
                            ReadingSource = ReadingSource.Automatic,
                            Reading       = s
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                _errorSummary += "Data extraction for Pulse failed. ";
                _logger.Error("\n Data extraction for Pulse failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace);
            }

            try
            {
                if (!IsDataRowItemEmpty(dr[ColumnPulsePressure]))
                {
                    int s = 0;
                    if (int.TryParse(dr[ColumnPulsePressure].ToString(), out s))
                    {
                        testResult.PressureReadings.PulsePressure = new ResultReading <int?>(ReadingLabels.PulsePressure)
                        {
                            ReadingSource = ReadingSource.Automatic,
                            Reading       = s
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                _errorSummary += "Data extraction for Pulse Pressure failed. ";
                _logger.Error("\n Data extraction for Pulse Pressure failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace);
            }

            try
            {
                if (!IsDataRowItemEmpty(dr[ColumnPattern]))
                {
                    testResult.Pattern = new ResultReading <string>(ReadingLabels.Pattern)
                    {
                        ReadingSource = ReadingSource.Automatic,
                        Reading       = dr[ColumnPattern].ToString()
                    };
                }
            }
            catch (Exception ex)
            {
                _errorSummary += "Data extraction for Pattern failed. ";
                _logger.Error("\n Data extraction for Pattern failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace);
            }

            return(testResult);
        }
Esempio n. 11
0
        public TestResult Parse(DataRow dr)
        {
            _errorSummary = string.Empty;
            var testResult = new AwvAbiTestResult();

            if (CheckifRowContainsAnyLreadingData(dr))
            {
                testResult.LeftResultReadings = new PadTestReadings();
            }

            if (CheckifRowContainsAnyRreadingData(dr))
            {
                testResult.RightResultReadings = new PadTestReadings();
            }

            //SetBloodPressureValues(testResult, dr);

            if (testResult.LeftResultReadings == null && testResult.RightResultReadings == null)//&& testResult.PressureReadings == null
            {
                return(null);
            }

            long leftFindingId  = 0;
            long rightFindingId = 0;

            try
            {
                if (!IsDataRowItemEmpty(dr[ColumnRAbi]))
                {
                    decimal s;
                    if (decimal.TryParse(dr[ColumnRAbi].ToString(), out s))
                    {
                        testResult.RightResultReadings.ABI = new ResultReading <decimal?>(ReadingLabels.RightABI)
                        {
                            ReadingSource = ReadingSource.Automatic,
                            Reading       = s
                        };

                        rightFindingId = _testResultService.GetCalculatedStandardFinding(testResult.RightResultReadings.ABI.Reading, (int)TestType.AwvABI, null);
                    }
                }
            }
            catch (Exception ex)
            {
                _errorSummary += "Data extraction for Right ABI failed. ";
                _logger.Error("\n Data extraction for Right ABI failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace);
            }

            try
            {
                if (!IsDataRowItemEmpty(dr[ColumnRAnkleSystolic]))
                {
                    int s;
                    if (int.TryParse(dr[ColumnRAnkleSystolic].ToString(), out s))
                    {
                        testResult.RightResultReadings.SystolicAnkle =
                            new ResultReading <int?>(ReadingLabels.SystolicRAnkle)
                        {
                            ReadingSource = ReadingSource.Automatic,
                            Reading       = s
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                _errorSummary += "Data extraction for Right Ankle Systolic failed. ";
                _logger.Error("\n Data extraction for Right Ankle Systolic failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace);
            }

            try
            {
                if (!IsDataRowItemEmpty(dr[ColumnRArmSystolic]))
                {
                    int s;
                    if (int.TryParse(dr[ColumnRArmSystolic].ToString(), out s))
                    {
                        testResult.RightResultReadings.SystolicArm = new ResultReading <int?>(ReadingLabels.SystolicRArm)
                        {
                            ReadingSource = ReadingSource.Automatic,
                            Reading       = s
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                _errorSummary += "Data extraction for Right Arm Systolic failed. ";
                _logger.Error("\n Data extraction for Right Arm Systolic failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace);
            }

            try
            {
                if (!IsDataRowItemEmpty(dr[ColumnLAbi]))
                {
                    decimal s;
                    if (decimal.TryParse(dr[ColumnLAbi].ToString(), out s))
                    {
                        testResult.LeftResultReadings.ABI = new ResultReading <decimal?>(ReadingLabels.LeftABI)
                        {
                            ReadingSource = ReadingSource.Automatic,
                            Reading       = s
                        };

                        leftFindingId = _testResultService.GetCalculatedStandardFinding(testResult.LeftResultReadings.ABI.Reading, (int)TestType.AwvABI, null);
                    }
                }
            }
            catch (Exception ex)
            {
                _errorSummary += "Data extraction for Left ABI failed. ";
                _logger.Error("\n Data extraction for Left ABI failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace);
            }

            try
            {
                if (!IsDataRowItemEmpty(dr[ColumnLAnkleSystolic]))
                {
                    int s;
                    if (int.TryParse(dr[ColumnLAnkleSystolic].ToString(), out s))
                    {
                        testResult.LeftResultReadings.SystolicAnkle =
                            new ResultReading <int?>(ReadingLabels.SystolicLAnkle)
                        {
                            ReadingSource = ReadingSource.Automatic,
                            Reading       = s
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                _errorSummary += "Data extraction for Left Ankle Systolic failed. ";
                _logger.Error("\n Data extraction for Left Ankle Systolic failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace);
            }

            try
            {
                if (!IsDataRowItemEmpty(dr[ColumnLArmSystolic]))
                {
                    int s = 0;
                    if (int.TryParse(dr[ColumnLArmSystolic].ToString(), out s))
                    {
                        testResult.LeftResultReadings.SystolicArm = new ResultReading <int?>(ReadingLabels.SystolicLArm)
                        {
                            ReadingSource = ReadingSource.Automatic,
                            Reading       = s
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                _errorSummary += "Data extraction for Left Arm Systolic failed. ";
                _logger.Error("\n Data extraction for Left Arm Systolic failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace);
            }

            testResult.Finding = GetAwvAbiFindingToConsider(leftFindingId, rightFindingId);
            return(testResult);
        }
Esempio n. 12
0
        public TestResult Parse(DataRow dr)
        {
            _errorSummary = string.Empty;
            var testResult = new LipidTestResult();

            if (!CheckifRowContainsAnyReadingData(dr))
            {
                return(null);
            }

            try
            {
                if (!IsDataRowItemEmpty(dr[ColumnAlt]))
                {
                    int s = 0;
                    if (int.TryParse(dr[ColumnAlt].ToString(), out s))
                    {
                        var findingId = _testResultService.GetCalculatedStandardFinding(s, (int)TestType.Lipid,
                                                                                        (int)ReadingLabels.ALT);
                        testResult.ALT = new CompoundResultReading <int?>(ReadingLabels.ALT)
                        {
                            ReadingSource = ReadingSource.Automatic,
                            Reading       = s,
                            Finding       = findingId > 0 ? new StandardFinding <int?>(findingId) : null
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                _errorSummary += "Data extraction for ALT failed. ";
                _logger.Error("\n Data extraction for ALT failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace);
            }

            try
            {
                if (!IsDataRowItemEmpty(dr[ColumnGlu]))
                {
                    int s = 0;
                    if (int.TryParse(dr[ColumnGlu].ToString(), out s))
                    {
                        var findingId = _testResultService.GetCalculatedStandardFinding(s, (int)TestType.Lipid,
                                                                                        (int)ReadingLabels.Glucose);
                        testResult.Glucose = new CompoundResultReading <int?>(ReadingLabels.Glucose)
                        {
                            ReadingSource = ReadingSource.Automatic,
                            Reading       = s,
                            Finding       =
                                findingId > 0 ? new StandardFinding <int?>(findingId) : null
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                _errorSummary += "Data extraction for Glucose failed. ";
                _logger.Error("\n Data extraction for Glucose failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace);
            }

            try
            {
                if (!IsDataRowItemEmpty(dr[ColumnLdl]))
                {
                    int s = 0;
                    if (int.TryParse(dr[ColumnLdl].ToString(), out s))
                    {
                        var findingId = _testResultService.GetCalculatedStandardFinding(s, (int)TestType.Lipid,
                                                                                        (int)ReadingLabels.LDL);
                        testResult.LDL = new CompoundResultReading <int?>(ReadingLabels.LDL)
                        {
                            ReadingSource = ReadingSource.Automatic,
                            Reading       = s,
                            Finding       = findingId > 0 ? new StandardFinding <int?>(findingId) : null
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                _errorSummary += "Data extraction for LDL failed. ";
                _logger.Error("\n Data extraction for LDL failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace);
            }


            try
            {
                if (!IsDataRowItemEmpty(dr[ColumnTc]))
                {
                    testResult.TotalCholestrol = new CompoundResultReading <string>(ReadingLabels.TotalCholestrol)
                    {
                        ReadingSource = ReadingSource.Automatic,
                        Reading       = dr[ColumnTc].ToString()
                    };

                    int s;
                    if (int.TryParse(dr[ColumnTc].ToString(), out s))
                    {
                        var findingId = _testResultService.GetCalculatedStandardFinding(s, (int)TestType.Lipid,
                                                                                        (int)ReadingLabels.TotalCholestrol);
                        testResult.TotalCholestrol.Finding = findingId > 0
                                                                 ? new StandardFinding <string>(findingId)
                                                                 : null;
                    }
                }
            }
            catch (Exception ex)
            {
                _errorSummary += "Data extraction for Total Cholestrol failed. ";
                _logger.Error("\n Data extraction for Total Cholestrol failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace);
            }

            try
            {
                if (!IsDataRowItemEmpty(dr[ColumnHdl]))
                {
                    testResult.HDL = new CompoundResultReading <string>(ReadingLabels.HDL)
                    {
                        ReadingSource = ReadingSource.Automatic,
                        Reading       = dr[ColumnHdl].ToString()
                    };

                    int s;
                    if (int.TryParse(dr[ColumnHdl].ToString(), out s))
                    {
                        var findingId = _testResultService.GetCalculatedStandardFinding(s, (int)TestType.Lipid,
                                                                                        (int)ReadingLabels.HDL);
                        testResult.HDL.Finding = findingId > 0 ? new StandardFinding <string>(findingId) : null;
                    }
                }
            }
            catch (Exception ex)
            {
                _errorSummary += "Data extraction for HDL failed. ";
                _logger.Error("\n Data extraction for HDL failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace);
            }

            try
            {
                if (!IsDataRowItemEmpty(dr[ColumnTrig]))
                {
                    testResult.TriGlycerides = new CompoundResultReading <string>(ReadingLabels.TriGlycerides)
                    {
                        ReadingSource = ReadingSource.Automatic,
                        Reading       = dr[ColumnTrig].ToString()
                    };

                    int s;
                    if (int.TryParse(dr[ColumnTrig].ToString(), out s))
                    {
                        var findingId = _testResultService.GetCalculatedStandardFinding(s, (int)TestType.Lipid,
                                                                                        (int)
                                                                                        ReadingLabels.TriGlycerides);
                        testResult.TriGlycerides.Finding = findingId > 0 ? new StandardFinding <string>(findingId) : null;
                    }
                }
            }
            catch (Exception ex)
            {
                _errorSummary += "Data extraction for Triglycerides failed. ";
                _logger.Error("\n Data extraction for Triglycerides failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace);
            }

            return(testResult);
        }
Esempio n. 13
0
        private void LoadAwvAaaFindings(HtmlDocument doc, long eventId, long customerId, StandardFinding <decimal?> finding = null, IEnumerable <StandardFinding <int> > aortaRangeSaggitalView = null, IEnumerable <StandardFinding <int> > aortaRangeTransverseView = null, decimal?maxAortaSize = null, bool isTestPurchased = true, UnableScreenReason unableScreenReason = null, IEnumerable <StandardFinding <int> > peakSystolicVelocityStandardFindings = null)
        {
            List <StandardFinding <decimal?> > standardFindingList;

            if (_settings.AwvAaaFindingChangeDate.HasValue)
            {
                var eventCustomerResult = _eventCustomerResultRepository.GetByCustomerIdAndEventId(customerId, eventId);
                if (eventCustomerResult != null && eventCustomerResult.DataRecorderMetaData.DateCreated < _settings.AwvAaaFindingChangeDate.Value)
                {
                    standardFindingList = _standardFindingRepository.GetAllStandardFindings <decimal?>((int)TestType.AwvAAA, (int)ReadingLabels.AortaSize, _settings.AwvAaaFindingChangeDate.Value, true);
                }
                else
                {
                    standardFindingList = _standardFindingRepository.GetAllStandardFindings <decimal?>((int)TestType.AwvAAA, (int)ReadingLabels.AortaSize, _settings.AwvAaaFindingChangeDate.Value, false);
                }
            }
            else
            {
                standardFindingList = _standardFindingRepository.GetAllStandardFindings <decimal?>((int)TestType.AwvAAA, (int)ReadingLabels.AortaSize);
            }


            StandardFinding <decimal?> findingForLongDescription = null;

            if (maxAortaSize.HasValue)
            {
                var findingId = _testResultService.GetCalculatedStandardFinding(eventId, customerId, maxAortaSize, (int)TestType.AwvAAA, (int)ReadingLabels.AortaSize);
                if (findingId > 0)
                {
                    findingForLongDescription = standardFindingList.SingleOrDefault(sf => sf.Id == findingId);
                }
            }

            _resultPdfHelper.SetSummaryFindings(doc, finding, standardFindingList, "FindingsAwvAaaDiv", "long-description-AwvAaa", findingForLongDescription, isTestPurchased, unableScreenReason);
            _resultPdfHelper.SetFindingsVertical(doc, finding, standardFindingList, "AwvAaaFinding");

            if (finding != null)
            {
                var stdFinding = standardFindingList.Single(f => f.Id == finding.Id);

                var selectedNode = doc.DocumentNode.SelectSingleNode("//span[@id='AwvAaa-rpp-resultspan']");
                if (selectedNode != null)
                {
                    selectedNode.InnerHtml = stdFinding.Label;
                }

                selectedNode = doc.DocumentNode.SelectSingleNode("//div[@id='docletter-AwvAaa']");
                if (stdFinding.ResultInterpretation != null && stdFinding.ResultInterpretation.Value != (long)ResultInterpretation.Normal && selectedNode != null)
                {
                    selectedNode.SetAttributeValue("style", "display:block;");
                }
            }

            var sViewStandardFindingList = _standardFindingRepository.GetAllStandardFindings <int>((int)TestType.AwvAAA, (int)ReadingLabels.AortaRangeSaggitalView);

            _resultPdfHelper.SetFindingsHorizontal(doc, aortaRangeSaggitalView, sViewStandardFindingList, "AwvAaaSagitalView");

            var tViewStandardFindingList = _standardFindingRepository.GetAllStandardFindings <int>((int)TestType.AwvAAA, (int)ReadingLabels.AortaRangeTransverseView);

            _resultPdfHelper.SetFindingsHorizontal(doc, aortaRangeTransverseView, tViewStandardFindingList, "AwvAaaTransverseView");

            var peakSystolicVelocityStandardFindingsList = _standardFindingRepository.GetAllStandardFindings <int>((int)TestType.AwvAAA, (int)ReadingLabels.PeakSystolicVelocitySaggitalView);

            _resultPdfHelper.SetFindingsHorizontal(doc, peakSystolicVelocityStandardFindings, peakSystolicVelocityStandardFindingsList, "AwvAaaPeakSystolicVelocityStandardFindings");
        }