private void ParseCsv(string csvFilePath, List <EventCustomerScreeningAggregate> eventCustomerAggregates) { var dtCardiovision = ParseCsvintoDatatable(csvFilePath); var isColumnsForPadValid = CardiovisionPadParser.IsDatatableConversionfromCsvValid(dtCardiovision); var isColumnsForAsiValid = CardiovisionAsiParser.IsDatatableConversionfromCsvValid(dtCardiovision); var isColumnsForAwvAbiValid = CardiovisionAwvAbiParser.IsDatatableConversionfromCsvValid(dtCardiovision); if (!dtCardiovision.Columns.Contains(ColumnforCustomerId) || (!isColumnsForAsiValid && !isColumnsForPadValid && !isColumnsForAwvAbiValid)) { _logger.Error("Cardiovision File provided is an Invalid File!"); return; } foreach (DataRow dr in dtCardiovision.Rows) { long customerId = 0; if (dr[ColumnforCustomerId] != null && dr[ColumnforCustomerId] != DBNull.Value && !string.IsNullOrEmpty(dr[ColumnforCustomerId].ToString())) { long.TryParse(dr[ColumnforCustomerId].ToString(), out customerId); } if (customerId < 1) { _logger.Error("Customer Id not found in the row number " + (dtCardiovision.Rows.IndexOf(dr) + 1)); continue; } if (isColumnsForPadValid || isColumnsForAwvAbiValid) { _logger.Info("\n\n ===================> PAD Parsing for CustomerId : " + customerId + "\n"); var isPadTestPurchasedByCustomer = false; try { isPadTestPurchasedByCustomer = _testResultService.IsTestPurchasedByCustomer(_eventId, customerId, (long)TestType.PAD); var isAwvAbiTestPurchasedByCustomer = _testResultService.IsTestPurchasedByCustomer(_eventId, customerId, (long)TestType.AwvABI); if (!isPadTestPurchasedByCustomer && !isAwvAbiTestPurchasedByCustomer) { _logger.Info("PAD is not availed by CustomerId[" + customerId + "]. \n"); } else if (isPadTestPurchasedByCustomer) { var testResult = _padParser.Parse(dr); AddTestResulttoEventCustomerAggregate(eventCustomerAggregates, customerId, testResult); AddResultArchiveLog(_padParser.ErrorSummary, TestType.PAD, customerId); } else if (isAwvAbiTestPurchasedByCustomer) { var testResult = _awvAbiParser.Parse(dr); AddTestResulttoEventCustomerAggregate(eventCustomerAggregates, customerId, testResult); AddResultArchiveLog(_awvAbiParser.ErrorSummary, TestType.AwvABI, customerId); } } catch (Exception ex) { _logger.Error("System Failure! Error: " + ex.Message + "\n\t" + ex.StackTrace); AddResultArchiveLog(ex.Message, (isPadTestPurchasedByCustomer ? TestType.PAD : TestType.AwvABI), customerId, false); } } _bloodPressureSynchronizer = new BloodPressureSynchronizer(_logger, customerId, _eventId, 0, _isNewResultFlow); if (isColumnsForAsiValid) { _logger.Info("\n\n ===================> ASI Parsing for CustomerId : " + customerId + "\n"); try { bool isTestPurchasedByCustomer = _testResultService.IsTestPurchasedByCustomer(_eventId, customerId, (long)TestType.ASI); if (!isTestPurchasedByCustomer) { _logger.Info("ASI is not availed by CustomerId[" + customerId + "]. \n"); } else { var testResult = _asiParser.Parse(dr); var pressureReadings = _bloodPressureSynchronizer.GetReadingsinDb(); if (testResult != null && pressureReadings != null && testResult is ASITestResult) { var asiTestResult = (testResult as ASITestResult); if (asiTestResult.PressureReadings == null) { asiTestResult.PressureReadings = pressureReadings; } } AddTestResulttoEventCustomerAggregate(eventCustomerAggregates, customerId, testResult); AddResultArchiveLog(_asiParser.ErrorSummary, TestType.ASI, customerId); } } catch (Exception ex) { _logger.Error("System Failure! Error: " + ex.Message + "\n\t" + ex.StackTrace); AddResultArchiveLog(ex.Message, TestType.ASI, customerId, false); } } } }
public IEnumerable <EventCustomerScreeningAggregate> Parse() { var eventCustomerAggregates = new List <EventCustomerScreeningAggregate>(); _resultArchiveLogs = new List <ResultArchiveLog>(); var filePath = GetFolderPathfor(_resultOutputPath); if (string.IsNullOrEmpty(filePath)) { return(null); } var dtBloodworks = ParseCsvintoDatatable(filePath); var isColumnsForLipidValid = BloodworksLipidParser.IsDatatableConversionfromCsvValid(dtBloodworks); if (!dtBloodworks.Columns.Contains(ColumnforCustomerId) || !isColumnsForLipidValid) { _logger.Error("Bloodworks File provided is an Invalid File!"); return(null); } foreach (DataRow dr in dtBloodworks.Rows) { long customerId = 0; if (dr[ColumnforCustomerId] != null && dr[ColumnforCustomerId] != DBNull.Value && !string.IsNullOrEmpty(dr[ColumnforCustomerId].ToString())) { long.TryParse(dr[ColumnforCustomerId].ToString(), out customerId); } if (customerId < 1) { _logger.Error("Customer Id not found in the row number " + (dtBloodworks.Rows.IndexOf(dr) + 1)); continue; } _logger.Info("\n\n ===================> Lipid Parsing for CustomerId : " + customerId + "\n"); try { bool isTestPurchasedByCustomer = _testResultService.IsTestPurchasedByCustomer(_eventId, customerId, (long)TestType.Lipid); if (!isTestPurchasedByCustomer) { _logger.Info("Lipid is not availed by CustomerId[" + customerId + "].\n"); } else { var testResult = _lipidParser.Parse(dr); AddTestResulttoEventCustomerAggregate(eventCustomerAggregates, customerId, testResult); AddResultArchiveLog(_lipidParser.ErrorSummary, TestType.Lipid, customerId); } } catch (Exception ex) { _logger.Error("System Failure! Error: " + ex.Message + "\n\t" + ex.StackTrace); AddResultArchiveLog(ex.Message, TestType.Lipid, customerId, false); } _logger.Info("\n\n ===================> Blood Pressure Parsing for CustomerId : " + customerId + "\n"); try { _bloodPressureSynchronizer = new BloodPressureSynchronizer(_logger, customerId, _eventId, _updatedBy, _isNewResultFlow); var testResults = _bloodPressureSynchronizer.Parse(dr); if (testResults != null) { foreach (var testResult in testResults) { AddTestResulttoEventCustomerAggregate(eventCustomerAggregates, customerId, testResult); AddResultArchiveLog(_bloodPressureSynchronizer.ErrorSummary, testResult is ASITestResult ? TestType.ASI : TestType.PAD, customerId); } } } catch (Exception ex) { _logger.Error("System Failure! Error: " + ex.Message + "\n\t" + ex.StackTrace); } _logger.Info("\n\n ===================> Hba1c Parsing for CustomerId : " + customerId + "\n"); try { bool isTestPurchasedByCustomer = _testResultService.IsTestPurchasedByCustomer(_eventId, customerId, (long)TestType.A1C); if (!isTestPurchasedByCustomer) { _logger.Info("Hba1c is not availed by CustomerId[" + customerId + "]. \n"); } else { var testResult = _hba1CParser.Parse(dr); AddTestResulttoEventCustomerAggregate(eventCustomerAggregates, customerId, testResult); AddResultArchiveLog(_hba1CParser.ErrorSummary, TestType.A1C, customerId); } } catch (Exception ex) { _logger.Error("System Failure! Error: " + ex.Message + "\n\t" + ex.StackTrace); AddResultArchiveLog(ex.Message, TestType.A1C, customerId, false); } try { _logger.Info("\n\n ===================> Section for Not Recordable, but Performed Tests - for CustomerId : " + customerId + "\n"); AddTestResultListforOtherRecordables(ColumnforTshPerformed, customerId, TestType.Thyroid, dr, eventCustomerAggregates); AddTestResultListforOtherRecordables(ColumnforPsaPerformed, customerId, TestType.Psa, dr, eventCustomerAggregates); AddTestResultListforOtherRecordables(ColumnforCrpPerformed, customerId, TestType.Crp, dr, eventCustomerAggregates); AddTestResultListforOtherRecordables(ColumnforColorectalPerformed, customerId, TestType.Colorectal, dr, eventCustomerAggregates); AddTestResultListforOtherRecordables(ColumnforKynPerformed, customerId, TestType.Kyn, dr, eventCustomerAggregates); var testResult = GetTestResultforRecordables(customerId, ColumnforEchoNotPerformed, ColumnforEchoNotes, dr, TestType.Echocardiogram); AddTestResulttoEventCustomerAggregate(eventCustomerAggregates, customerId, testResult); testResult = GetTestResultforRecordables(customerId, ColumnforAaaNotPerformed, ColumnforAaaNotes, dr, TestType.AAA); AddTestResulttoEventCustomerAggregate(eventCustomerAggregates, customerId, testResult); testResult = GetTestResultforRecordables(customerId, ColumnforAsiNotPerformed, ColumnforAsiNotes, dr, TestType.ASI); AddTestResulttoEventCustomerAggregate(eventCustomerAggregates, customerId, testResult); testResult = GetTestResultforRecordables(customerId, ColumnforEkgNotPerformed, ColumnforEkgNotes, dr, TestType.EKG); AddTestResulttoEventCustomerAggregate(eventCustomerAggregates, customerId, testResult); testResult = GetTestResultforRecordables(customerId, ColumnforPadNotPerformed, ColumnforPadNotes, dr, TestType.PAD); AddTestResulttoEventCustomerAggregate(eventCustomerAggregates, customerId, testResult); testResult = GetTestResultforRecordables(customerId, ColumnforStrokeNotPerformed, ColumnforStrokeNotes, dr, TestType.Stroke); AddTestResulttoEventCustomerAggregate(eventCustomerAggregates, customerId, testResult); } catch (Exception ex) { _logger.Error("System Failure! Error: " + ex.Message + "\n\t" + ex.StackTrace); } } return(eventCustomerAggregates); }