Example #1
0
        public void LoadLipidResult(HtmlDocument doc, LipidTestResult testResult, bool isMale, List <OrderedPair <long, string> > technicianIdNamePairs, IEnumerable <CustomerScreeningEvaluatinPhysicianViewModel> physicians,
                                    IEnumerable <EventPhysicianTest> eventPhysicianTests, IEnumerable <PhysicianEvaluation> eventCustomerPhysicianEvaluations, CustomerSkipReview customerSkipReview)
        {
            LoadLipidFinding(doc, testResult, isMale);

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

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

                _resultPdfHelper.SetInputBox(doc, "TotalCholestrolLipidInputText", testResult.TotalCholestrol);
                _resultPdfHelper.SetInputBox(doc, "TCHDLRatioLipidInputText", testResult.TCHDLRatio);
                _resultPdfHelper.SetInputBox(doc, "HDLLipidInputText", testResult.HDL);
                _resultPdfHelper.SetInputBox(doc, "LDLLipidInputText", testResult.LDL);
                _resultPdfHelper.SetInputBox(doc, "GlucoseLipidInputText", testResult.Glucose);
                _resultPdfHelper.SetInputBox(doc, "TriglyceridesLipidInputText", testResult.TriGlycerides);

                _resultPdfHelper.SetTechnician(doc, testResult, "techlipid", "technoteslipid", technicianIdNamePairs);
                _resultPdfHelper.SetPhysicianRemarks(doc, testResult, "followUpLipid", "criticalLipid", "physicianRemarksLipid");
                _resultPdfHelper.SetUnableToScreenReasons(doc, TestType.Lipid, "lipidUnableToScreen", testResult.UnableScreenReason);
            }
            else
            {
                _resultPdfHelper.SetUnableToScreenReasons(doc, TestType.Lipid, "lipidUnableToScreen", null);
            }
        }
        public TestResult GetLipidTestResultDomain(KynHealthAssessmentEditModel model, LipidTestResult inpersistence, long uploadedby, bool isNewResultFlow)
        {
            if (!IsLipidReadingProvided(model) && inpersistence == null)
            {
                return(inpersistence);
            }

            decimal?tchol         = null;
            decimal?hdl           = null;
            decimal?triglycerides = null;

            if (inpersistence == null)
            {
                inpersistence = new LipidTestResult
                {
                    ResultStatus = new TestResultState
                    {
                        StateNumber = isNewResultFlow ? (int)NewTestResultStateNumber.ResultEntryPartial : (int)TestResultStateNumber.ManualEntry
                    }
                };
            }

            inpersistence.TotalCholestrol = GetTotalColesterolReading(model.TotalCholesterol, ref tchol);
            inpersistence.HDL             = GetHdlReading(model.HDLCholesterol, ref hdl);
            inpersistence.TriGlycerides   = GetTriglyceridesReading(model.Triglycerides, ref triglycerides);
            inpersistence.TCHDLRatio      = CalculateTchdlRatio(tchol, hdl, TestType.Lipid);
            inpersistence.LDL             = CalculateLdlReading(hdl, tchol, triglycerides, TestType.Lipid);

            inpersistence.Glucose = GetGlucoseReading(model.Glucose);

            inpersistence.DataRecorderMetaData = SetDataRecorderMetaData(inpersistence.DataRecorderMetaData, uploadedby);
            inpersistence.ResultStatus.DataRecorderMetaData = SetDataRecorderMetaData(inpersistence.ResultStatus.DataRecorderMetaData, uploadedby);

            return(inpersistence);
        }
Example #3
0
        private LipidTestResult GetLipidTestResult(LipidTestResult testResult)
        {
            if (testResult.TotalCholestrol == null && testResult.HDL == null && testResult.TCHDLRatio == null && testResult.LDL == null &&
                testResult.Glucose == null && testResult.TriGlycerides == null)
            {
                return(null);
            }

            return(testResult);
        }
Example #4
0
        public TestResult Parse(long customerId, string xmlFilePath, TestType testType)
        {
            _lipidParserHelper.SetLogger(_logger);
            _errorSummary = string.Empty;
            _logger.Info(string.Format("------------------------------- {0} Parsing for file [{1}]", testType.ToString(), xmlFilePath));

            if (!File.Exists(xmlFilePath))
            {
                _errorSummary += "File doesn't exist.";
                _logger.Error("File doesn't exist.");
                return(null);
            }

            var doc = new XmlDocument();

            doc.Load(xmlFilePath);
            var elements = doc.GetElementsByTagName(_tagNameforBiomarker);

            if (elements.Count < 1)
            {
                _errorSummary += "Data not found in file.";
                _logger.Error("Data not found in file.");
                return(null);
            }

            var ldlValue     = GetLipidValue(LdlCholName, elements);
            var hdlValue     = GetLipidValue(HdlCholName, elements);
            var tCholValue   = GetLipidValue(TotalCholName, elements);
            var glucoseValue = GetLipidValue(GlucoseName, elements);
            var tglValue     = GetLipidValue(TriglyceridesName, elements);

            decimal?tchol = null;
            decimal?hdl   = null;
            //not in use
            decimal?tGlycerides = null;


            if (testType == TestType.Lipid)
            {
                var testResult = new LipidTestResult
                {
                    Glucose         = _lipidParserHelper.GetReading(glucoseValue, ReadingLabels.Glucose, testType, ref _errorSummary),
                    LDL             = _lipidParserHelper.GetReading(ldlValue, ReadingLabels.LDL, testType, ref _errorSummary),
                    TotalCholestrol = _lipidParserHelper.GetReading(tCholValue, ReadingLabels.TotalCholestrol, ref tchol, testType, ref _errorSummary),
                    TriGlycerides   = _lipidParserHelper.GetReading(tglValue, ReadingLabels.TriGlycerides, ref tGlycerides, testType, ref _errorSummary),
                    HDL             = _lipidParserHelper.GetHdlReading(hdlValue, customerId, ref hdl, testType, ref _errorSummary),
                    TCHDLRatio      = _lipidParserHelper.GetHdlTclRatio(hdl, tchol, testType, ref _errorSummary)
                };

                return(GetLipidTestResult(testResult));
            }

            if (testType == TestType.Cholesterol)
            {
                var testResult = new CholesterolTestResult
                {
                    LDL = _lipidParserHelper.GetReading(ldlValue, ReadingLabels.LDL, testType, ref _errorSummary),
                    TotalCholesterol = _lipidParserHelper.GetReading(tCholValue, ReadingLabels.TotalCholestrol, ref tchol, testType, ref _errorSummary),
                    TriGlycerides    = _lipidParserHelper.GetReading(tglValue, ReadingLabels.TriGlycerides, ref tGlycerides, testType, ref _errorSummary),
                    HDL        = _lipidParserHelper.GetHdlReading(hdlValue, customerId, ref hdl, testType, ref _errorSummary),
                    TCHDLRatio = _lipidParserHelper.GetHdlTclRatio(hdl, tchol, testType, ref _errorSummary)
                };

                return(GetCholesterolTestResult(testResult));
            }

            if (testType == TestType.Diabetes)
            {
                var testResult = new DiabetesTestResult
                {
                    Glucose = _lipidParserHelper.GetReading(glucoseValue, ReadingLabels.Glucose, testType, ref _errorSummary)
                };

                return(GetDiabetesTestResult(testResult));
            }

            return(null);
        }
Example #5
0
        public override TestResult CreateActualTestResult(CustomerEventScreeningTestsEntity customerEventScreeningTestsEntity)
        {
            var customerEventReadingEntities = customerEventScreeningTestsEntity.CustomerEventReading.ToList();

            var testResult = new LipidTestResult(customerEventScreeningTestsEntity.CustomerEventScreeningTestId);

            var standardFindingTestReadingEntities =
                customerEventScreeningTestsEntity.
                StandardFindingTestReadingCollectionViaCustomerEventReading.ToList();

            var totalCholesterolData = customerEventReadingEntities.
                                       Where(customerEventReading => customerEventReading.TestReading.ReadingId == (int)ReadingLabels.TotalCholestrol).
                                       SingleOrDefault();

            if (totalCholesterolData != null)
            {
                testResult.TotalCholestrol = CreateTestReadingforaIntValue(totalCholesterolData, (int)ReadingLabels.TotalCholestrol, standardFindingTestReadingEntities, totalCholesterolData.Value);
            }

            var hdlData = customerEventReadingEntities.
                          Where(customerEventReading => customerEventReading.TestReading.ReadingId == (int)ReadingLabels.HDL).
                          SingleOrDefault();

            if (hdlData != null)
            {
                testResult.HDL = CreateTestReadingforaIntValue(hdlData, (int)ReadingLabels.HDL, standardFindingTestReadingEntities, hdlData.Value);
            }

            var ldlData = customerEventReadingEntities.
                          Where(customerEventReading => customerEventReading.TestReading.ReadingId == (int)ReadingLabels.LDL).
                          SingleOrDefault();

            if (ldlData != null)
            {
                testResult.LDL = CreateTestReadingforaIntValue(ldlData, (int)ReadingLabels.LDL, standardFindingTestReadingEntities, (string.IsNullOrEmpty(ldlData.Value) ? null : (int?)Convert.ToInt32(ldlData.Value)));
            }

            var glucoseData = customerEventReadingEntities.
                              Where(customerEventReading => customerEventReading.TestReading.ReadingId == (int)ReadingLabels.Glucose).
                              SingleOrDefault();

            if (glucoseData != null)
            {
                testResult.Glucose = CreateTestReadingforaIntValue(glucoseData, (int)ReadingLabels.Glucose, standardFindingTestReadingEntities,
                                                                   (string.IsNullOrEmpty(glucoseData.Value) ? null : (int?)Convert.ToInt32(glucoseData.Value)));
            }

            var triglyceridesData = customerEventReadingEntities.
                                    Where(customerEventReading => customerEventReading.TestReading.ReadingId == (int)ReadingLabels.TriGlycerides).
                                    SingleOrDefault();

            if (triglyceridesData != null)
            {
                testResult.TriGlycerides = CreateTestReadingforaIntValue(triglyceridesData, (int)ReadingLabels.TriGlycerides, standardFindingTestReadingEntities, triglyceridesData.Value);
            }

            var altData = customerEventReadingEntities.
                          Where(customerEventReading => customerEventReading.TestReading.ReadingId == (int)ReadingLabels.ALT).
                          SingleOrDefault();

            if (altData != null)
            {
                testResult.ALT = CreateTestReadingforaIntValue(altData, (int)ReadingLabels.ALT, standardFindingTestReadingEntities, string.IsNullOrEmpty(altData.Value) ? null : (int?)Convert.ToInt32(altData.Value));
            }

            var astData = customerEventReadingEntities.Where(customerEventReading => customerEventReading.TestReading.ReadingId == (int)ReadingLabels.AST).SingleOrDefault();

            if (astData != null)
            {
                testResult.AST = CreateTestReadingforaIntValue(astData, (int)ReadingLabels.AST, standardFindingTestReadingEntities, string.IsNullOrEmpty(astData.Value) ? null : (int?)Convert.ToInt32(astData.Value));
            }

            var tchdlratioData = customerEventReadingEntities.
                                 Where(customerEventReading => customerEventReading.TestReading.ReadingId == (int)ReadingLabels.TCHDLRatio).
                                 SingleOrDefault();

            if (tchdlratioData != null)
            {
                testResult.TCHDLRatio = CreateTestReadingforaDecimalValue(tchdlratioData, (int)ReadingLabels.TCHDLRatio, standardFindingTestReadingEntities,
                                                                          (string.IsNullOrEmpty(tchdlratioData.Value) ? null : (decimal?)Convert.ToDecimal(tchdlratioData.Value)));
            }

            var hba1c = customerEventReadingEntities.
                        Where(customerEventReading => customerEventReading.TestReading.ReadingId == (int)ReadingLabels.Hba1c).
                        SingleOrDefault();

            if (hba1c != null)
            {
                testResult.HbA1c = new ResultReading <decimal?>(hba1c.CustomerEventReadingId)
                {
                    Label   = ReadingLabels.Hba1c,
                    Reading = !string.IsNullOrEmpty(hba1c.Value)
                            ? Convert.ToDecimal(hba1c.Value)
                            : default(decimal)
                };
            }

            return(testResult);
        }
Example #6
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");
        }
        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);
        }
        public void SaveLipidTestResult()
        {
            var testResult = new LipidTestResult((long)TestType.Lipid)
            {
                TotalCholestrol = new CompoundResultReading <string>((long)0)
                {
                    Finding       = new StandardFinding <string>(6),
                    Label         = ReadingLabels.TotalCholestrol,
                    Reading       = "10",
                    ReadingSource = ReadingSource.Automatic
                },
                HDL = new CompoundResultReading <string>((long)0)
                {
                    Finding       = new StandardFinding <string>(9),
                    Label         = ReadingLabels.HDL,
                    Reading       = "22",
                    ReadingSource = ReadingSource.Automatic
                },
                Glucose = new CompoundResultReading <int?>((long)0)
                {
                    Finding       = new StandardFinding <int?>(14),
                    Label         = ReadingLabels.Glucose,
                    Reading       = 33,
                    ReadingSource = ReadingSource.Automatic
                },
                LDL = new CompoundResultReading <int?>((long)0)
                {
                    Finding       = new StandardFinding <int?>(11),
                    Label         = ReadingLabels.LDL,
                    Reading       = 44,
                    ReadingSource = ReadingSource.Automatic
                },
                TriGlycerides = new CompoundResultReading <string>((long)0)
                {
                    Finding       = new StandardFinding <string>(17),
                    Label         = ReadingLabels.TriGlycerides,
                    Reading       = "55",
                    ReadingSource = ReadingSource.Automatic
                },
                TCHDLRatio = new CompoundResultReading <decimal?>((long)0)
                {
                    Finding       = new StandardFinding <decimal?>(20),
                    Label         = ReadingLabels.TCHDLRatio,
                    Reading       = 66,
                    ReadingSource = ReadingSource.Automatic
                },
                DataRecorderMetaData = new DataRecorderMetaData
                {
                    DataRecorderCreator = new OrganizationRoleUser
                    {
                        UserId         = 1058,
                        RoleId         = 8,
                        OrganizationId = 1
                    },
                    DataRecorderModifier = new OrganizationRoleUser
                    {
                        UserId         = 1058,
                        RoleId         = 8,
                        OrganizationId = 1
                    },
                    DateCreated  = DateTime.Now,
                    DateModified = DateTime.Now
                },
                ResultStatus = new TestResultState {
                    SelfPresent = true, StateNumber = (int)TestResultStateNumber.ManualEntry, Status = TestResultStatus.Incomplete
                }
            };

            Assert.IsTrue(_testResultRepository.SaveTestResults(testResult, CustomerID, EventID, 12));
        }
        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);
        }
Example #10
0
        private bool IsCompareReadingValid <X>(Func <LipidTestResult, X> _propertyToCompare, ReadingLabels _propertyType, LipidTestResult _testResultObject)
        {
            int?_valueToCompare = Convert.ToInt32(_propertyToCompare(_testResultObject)) as int?;

            if (_valueToCompare == null)
            {
                return(true);
            }

            int valueCalculated = 0;

            switch (_propertyType)
            {
            case ReadingLabels.LDL:
                valueCalculated = Convert.ToInt32(_testResultObject.TotalCholestrol.Reading)
                                  - Convert.ToInt32(_testResultObject.HDL.Reading)
                                  - Convert.ToInt32(decimal.Round((Convert.ToDecimal(_testResultObject.TriGlycerides.Reading) / 5), 0));
                break;

            case ReadingLabels.HDL:
                valueCalculated = Convert.ToInt32(_testResultObject.TotalCholestrol.Reading)
                                  - _testResultObject.LDL.Reading.Value
                                  - Convert.ToInt32(decimal.Round((Convert.ToDecimal(_testResultObject.TriGlycerides.Reading) / 5), 0));
                break;

            case ReadingLabels.TotalCholestrol:
                valueCalculated = Convert.ToInt32(_testResultObject.HDL.Reading)
                                  + _testResultObject.LDL.Reading.Value
                                  + Convert.ToInt32(decimal.Round((Convert.ToDecimal(_testResultObject.TriGlycerides.Reading) / 5), 0));
                break;

            case ReadingLabels.TriGlycerides:
                valueCalculated = (Convert.ToInt32(_testResultObject.TotalCholestrol.Reading)
                                   - Convert.ToInt32(_testResultObject.HDL.Reading)
                                   - _testResultObject.LDL.Reading.Value) * 5;
                break;
            }

            int minValue = _valueToCompare.Value - validRangeDecider;
            int maxValue = _valueToCompare.Value + validRangeDecider;

            if (valueCalculated >= minValue && valueCalculated <= maxValue)
            {
                return(true);
            }

            return(false);
        }