Beispiel #1
0
        public CardiovisionResultParser(string resultOutputPath, long eventId, ILogger logger, bool isNewResultFlow)
        {
            _resultOutputPath = resultOutputPath;
            _eventId          = eventId;
            _logger           = logger;

            _asiParser         = new CardiovisionAsiParser(logger);
            _padParser         = new CardiovisionPadParser(logger);
            _awvAbiParser      = new CardiovisionAwvAbiParser(logger);
            _testResultService = new Service.TestResultService();
            _isNewResultFlow   = isNewResultFlow;
        }
Beispiel #2
0
        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);
                    }
                }
            }
        }