public override bool SaveTestResults(TestResult currentTestResult, long customerId, long eventId, long technicianId) { TestResult synchronizedTestResult = null; if (currentTestResult.IsNewResultFlow) { if (SaveNewTestResult(currentTestResult, customerId, eventId, ref synchronizedTestResult)) { return(true); } } else { if (SaveOldTestResult(currentTestResult, customerId, eventId, ref synchronizedTestResult)) { return(true); } } CustomerEventScreeningTestsEntity customerEventScreeningEntity = _testResultFactory.CreateTestResultEntity(synchronizedTestResult, GetListOfTestReadingAndReadingId((int)TestType.AAA)); using (var scope = new TransactionScope()) { var result = PersistTestResults(customerEventScreeningEntity, (int)TestType.AAA, customerId, eventId, technicianId); var eventCustomerResultRepository = new EventCustomerResultRepository(); var eventCustomerResult = eventCustomerResultRepository.GetByCustomerIdAndEventId(customerId, eventId); var customerEventScreeningTestId = GetCustomerEventScreeningTestId((int)TestType.AAA, eventCustomerResult.Id); SaveTestMedia(((AAATestResult)synchronizedTestResult).ResultImages, customerEventScreeningTestId, synchronizedTestResult.DataRecorderMetaData); scope.Complete(); return(result); } }
private EventCustomerResult SaveEventCustomerResult(long eventId, long customerId) { var eventCustomerResultRepository = new EventCustomerResultRepository(); var eventCustomerResult = eventCustomerResultRepository.GetByCustomerIdAndEventId(customerId, eventId); return(eventCustomerResult); }
private static void SaveEventCustomerResult(long eventId, long customerId, long uploadedBy) { var eventCustomerResultRepository = new EventCustomerResultRepository(); var eventCustomerResult = eventCustomerResultRepository.GetByCustomerIdAndEventId(customerId, eventId); if (eventCustomerResult == null) { eventCustomerResult = new EventCustomerResult { CustomerId = customerId, EventId = eventId, DataRecorderMetaData = new DataRecorderMetaData(uploadedBy, DateTime.Now, null) }; eventCustomerResultRepository.Save(eventCustomerResult); } }
public override bool SaveTestResults(TestResult currentTestResult, long customerId, long eventId, long orgRoleUserId) { var customer = new CustomerRepository().GetCustomer(customerId); _testResultFactory = new CsTestResultFactory(customer.Gender == Gender.Female ? false : true); TestResult synchronizedTestResult = null; if (currentTestResult.IsNewResultFlow) { if (SaveNewTestResult(currentTestResult, customerId, eventId, ref synchronizedTestResult)) { return(true); } } else { if (SaveOldTestResult(currentTestResult, customerId, eventId, ref synchronizedTestResult)) { return(true); } } var customerEventScreeningEntity = _testResultFactory.CreateTestResultEntity(synchronizedTestResult, GetListOfTestReadingAndReadingId((int)TestType.Cs)); using (var scope = new TransactionScope()) { var result = PersistTestResults(customerEventScreeningEntity, (int)TestType.Cs, customerId, eventId, orgRoleUserId); var eventCustomerResultRepository = new EventCustomerResultRepository(); var eventCustomerResult = eventCustomerResultRepository.GetByCustomerIdAndEventId(customerId, eventId); var customerEventScreeningTestId = GetCustomerEventScreeningTestId((int)TestType.Cs, eventCustomerResult.Id); var resultMedia = new List <ResultMedia>(); if (((CsTestResult)synchronizedTestResult).ResultImage != null) { resultMedia.Add(((CsTestResult)synchronizedTestResult).ResultImage); } SaveTestMedia(resultMedia, customerEventScreeningTestId, synchronizedTestResult.DataRecorderMetaData); scope.Complete(); return(result); } }
private void Save(IEnumerable <EventCustomerScreeningAggregate> eventCustomerScreeningAggregates, long uploadedBy) { if (eventCustomerScreeningAggregates == null) { return; } var eventids = eventCustomerScreeningAggregates.Select(x => x.EventId).ToArray(); var events = _eventRepository.GetEvents(eventids); foreach (var eventCustomerScreeningAggregate in eventCustomerScreeningAggregates) { var eventCustomerResultRepository = new EventCustomerResultRepository(); var eventCustomerResult = eventCustomerResultRepository.GetByCustomerIdAndEventId(eventCustomerScreeningAggregate.EventId, eventCustomerScreeningAggregate.CustomerId); var eventData = events.First(x => x.Id == eventCustomerScreeningAggregate.EventId); var isNewResultFlow = eventData.EventDate >= _settings.ResultFlowChangeDate; if (eventCustomerResult != null && ((isNewResultFlow && eventCustomerResult.ResultState >= (int)NewTestResultStateNumber.PostAuditNew) || (!isNewResultFlow && eventCustomerResult.ResultState >= (int)TestResultStateNumber.PostAudit))) { _logger.Info(string.Format("Customer Result is on or beyond Post-Audit state for CustomerID : {0} and EventID : {1}", eventCustomerScreeningAggregate.CustomerId, eventCustomerScreeningAggregate.EventId)); continue; } eventCustomerResult = SaveEventCustomerResult(eventCustomerScreeningAggregate.EventId, eventCustomerScreeningAggregate.CustomerId, uploadedBy, eventCustomerResult); SaveEventCustomerResultBloodLab(eventCustomerResult.Id, true); foreach (var testResult in eventCustomerScreeningAggregate.TestResults) { testResult.IsNewResultFlow = isNewResultFlow; SaveTestResult(testResult, eventCustomerScreeningAggregate.EventId, eventCustomerScreeningAggregate.CustomerId, uploadedBy, eventCustomerResult.ResultState, eventCustomerResult.IsPartial, isNewResultFlow); } } }