public void Create(IEnumerable <EventCustomerResultEntity> eventCustomerResultEntities, IEnumerable <OrderedPair <long, long> > orgRoleUserIdUserIdPairs, IEnumerable <UserEntity> userEntities, IEnumerable <Address> addresses, IEnumerable <CustomerProfileEntity> customerProfileEntities, IEnumerable <EventsEntity> eventsEntities, IEnumerable <CustomerHealthInfoEntity> customerHealthInfoEntities, IEnumerable <OrderedPair <long, long> > eventIdPodIdPairs, IEnumerable <PodDetailsEntity> podDetailsEntities, IEnumerable <OrderedPair <long, long> > eventIdHospitalPartnerIdPairs, IEnumerable <OrderedPair <long, string> > hospitalPartnerIdNamePairs, IEnumerable <EventCustomerBasicBioMetricEntity> basicBioMetricEntities, IEnumerable <EventCustomersEntity> eventCustomersEntities, IEnumerable <EventAppointmentEntity> eventAppointmentEntities, IEnumerable <HospitalPartnerCustomerEntity> hospitalPartnerCustomerEntities, IEnumerable <OrderedPair <long, string> > careCoordinatorIdNamePair, IEnumerable <CustomerPrimaryCarePhysicianEntity> primaryCarePhysicianEntities, string destinationPath, IEnumerable <long> hafQuestionIds) { long totalRecords = eventCustomerResultEntities.Count(); long counter = 1; PcpResultExportHelper.Questions = PcpResultExportHelper.AllQuestions.Where(aq => hafQuestionIds.Contains(aq.FirstValue)).Select(aq => aq).ToArray(); _logger.Info("Total Records : " + totalRecords); WriteCsvHeader(destinationPath); foreach (var eventCustomerResultEntity in eventCustomerResultEntities) { try { _logger.Info(string.Format("Creating Model for event {0} and customer {1}", eventCustomerResultEntity.EventId, eventCustomerResultEntity.CustomerId)); var userId = orgRoleUserIdUserIdPairs.Where(oru => oru.FirstValue == eventCustomerResultEntity.CustomerId).Select(oru => oru.SecondValue).Single(); var user = userEntities.Where(u => u.UserId == userId).Select(u => u).Single(); var address = addresses.Where(a => a.Id == user.HomeAddressId).Select(a => a).Single(); var customer = customerProfileEntities.Where(cp => cp.CustomerId == eventCustomerResultEntity.CustomerId).Select(cp => cp).Single(); var eventData = eventsEntities.Where(e => e.EventId == eventCustomerResultEntity.EventId).Select(e => e).Single(); var podIds = eventIdPodIdPairs.Where(ep => ep.FirstValue == eventData.EventId).Select(ep => ep.SecondValue).ToArray(); var podName = string.Join(",", podDetailsEntities.Where(pd => podIds.Contains(pd.PodId)).Select(pd => pd.Name).ToArray()); var hospitalPartnerId = eventIdHospitalPartnerIdPairs.Where(ehp => ehp.FirstValue == eventData.EventId).Select(ehp => ehp.SecondValue).SingleOrDefault(); var hopitalPartnerName = hospitalPartnerIdNamePairs.Where(hp => hp.FirstValue == hospitalPartnerId).Select(hp => hp.SecondValue).SingleOrDefault(); var eventCustomer = eventCustomersEntities.Where(ec => ec.EventCustomerId == eventCustomerResultEntity.EventCustomerResultId).Select(ec => ec).Single(); var eventAppointment = eventAppointmentEntities.Where(ea => ea.AppointmentId == eventCustomer.AppointmentId).Select(ea => ea).Single(); var primaryCarePhysician = primaryCarePhysicianEntities.Where(pcp => pcp.CustomerId == eventCustomerResultEntity.CustomerId).Select(pcp => pcp).FirstOrDefault(); var basicBimetric = basicBioMetricEntities.Where(bb => bb.EventCustomerId == eventCustomerResultEntity.EventCustomerResultId).Select(bb => bb).FirstOrDefault(); var hafAnswers = customerHealthInfoEntities.Where(chi => chi.EventCustomerId == eventCustomerResultEntity.EventCustomerResultId).Select(chi => chi).ToArray(); var answers = new List <OrderedPair <long, string> >(); foreach (var question in PcpResultExportHelper.Questions) { var hafAnswer = hafAnswers.Where(ha => ha.CustomerHealthQuestionId == question.FirstValue).Select(ha => ha).FirstOrDefault(); if (hafAnswer != null) { answers.Add(new OrderedPair <long, string>(question.FirstValue, hafAnswer.HealthQuestionAnswer)); } else { answers.Add(new OrderedPair <long, string>(question.FirstValue, "")); } } var age = string.Empty; if (user.Dob.HasValue) { var now = DateTime.Now; var checkCurrentLeapYear = new DateTime(now.Year, 3, 1); var birth = user.Dob.Value; var checkBirthLeapYear = new DateTime(birth.Year, 3, 1); var currentDayOfYear = now.DayOfYear; if (checkCurrentLeapYear.DayOfYear == 61 && now.Month >= checkCurrentLeapYear.Month && checkBirthLeapYear.DayOfYear != 61) { currentDayOfYear = now.DayOfYear - 1; } else if (checkCurrentLeapYear.DayOfYear != 61 && now.Month >= checkCurrentLeapYear.Month && checkBirthLeapYear.DayOfYear == 61) { currentDayOfYear = now.DayOfYear + 1; } var years = now.Year - birth.Year - ((currentDayOfYear < birth.DayOfYear) ? 1 : 0); var months = (12 + now.Month - birth.Month - ((now.Day < birth.Day) ? 1 : 0)) % 12; var days = now.Day - birth.Day; if (days < 0) { days = new DateTime(now.Year, now.Month, 1).AddDays(-1).AddDays(days).Day; } age = years.ToString(); } var ssn = "N/A"; if (!string.IsNullOrEmpty(user.Ssn)) { ssn = _cryptographyService.Decrypt(user.Ssn); if (ssn.Length >= 9) { ssn = ssn.Substring(0, 3) + "-" + ssn.Substring(3, 2) + "-" + ssn.Substring(ssn.Length - 4); } } var model = new PcpResultExportModel { CustomerId = customer.CustomerId, FirstName = user.FirstName, LastName = user.LastName, Address1 = address.StreetAddressLine1, City = address.City, State = address.State, Zip = address.ZipCode.Zip, Dob = user.Dob, Age = age, Height = customer.Height, Weight = customer.Weight > 0 ? customer.Weight.ToString() : "", Gender = customer.Gender, Race = customer.Race != "-1" ? customer.Race : "", Email = user.Email1, Phone = user.PhoneHome, Ssn = ssn, MemberId = string.IsNullOrEmpty(customer.InsuranceId) ? "" : customer.InsuranceId, Hicn = string.IsNullOrEmpty(customer.Hicn) ? "" : customer.Hicn, EventId = eventData.EventId, EventDate = eventData.EventDate, Pod = podName, HospitalPartner = hopitalPartnerName, Hipaa = ((RegulatoryState)eventCustomer.Hipaastatus).GetDescription(), CheckinTime = eventAppointment.CheckinTime.HasValue ? eventAppointment.CheckinTime.Value.ToShortTimeString() : "", CheckoutTime = eventAppointment.CheckoutTime.HasValue ? eventAppointment.CheckoutTime.Value.ToShortTimeString() : "", HealthAssesmentAnswer = answers, ResultSummary = eventCustomerResultEntity.ResultSummary.HasValue ? ((ResultInterpretation)eventCustomerResultEntity.ResultSummary).GetDescription() : "" }; if (primaryCarePhysician != null) { model.PrimaryPhysicianName = new Name(primaryCarePhysician.FirstName, primaryCarePhysician.MiddleName, primaryCarePhysician.LastName).FullName; } if (hospitalPartnerId > 0) { model.PartnerRelease = eventCustomer.PartnerRelease > 0 ? ((RegulatoryState)eventCustomer.PartnerRelease).GetDescription() : ""; var hospitalPartnerCustomer = hospitalPartnerCustomerEntities.LastOrDefault(hpc => hpc.EventId == eventCustomerResultEntity.EventId && hpc.CustomerId == eventCustomerResultEntity.CustomerId); model.CareCoordinatorStatus = hospitalPartnerCustomer != null ? ((HospitalPartnerCustomerStatus)hospitalPartnerCustomer.Status).GetDescription() : HospitalPartnerCustomerStatus.NotCalled.GetDescription(); model.CareCoordinatorOutcome = hospitalPartnerCustomer != null ? ((HospitalPartnerCustomerOutcome)hospitalPartnerCustomer.Outcome).GetDescription() : HospitalPartnerCustomerOutcome.NotScheduledNotInterested.GetDescription(); model.CareCoordinator = hospitalPartnerCustomer != null ? careCoordinatorIdNamePair.First(cc => cc.FirstValue == hospitalPartnerCustomer.CareCoordinatorOrgRoleUserId).SecondValue : "N/A"; model.CareCoordinatorNotes = hospitalPartnerCustomer != null ? hospitalPartnerCustomer.Notes : ""; } else { model.PartnerRelease = "N/A"; model.CareCoordinatorStatus = "N/A"; model.CareCoordinatorOutcome = "N/A"; model.CareCoordinator = "N/A"; model.CareCoordinatorNotes = "N/A"; } if (model.EventId > 0) { var theEvent = _eventRepository.GetById(model.EventId); if (theEvent.AccountId.HasValue && theEvent.AccountId > 0) { var organization = _organizationRepository.GetOrganizationbyId(theEvent.AccountId.Value); model.CorporateAccount = organization.Name; } if (theEvent.HostId > 0) { var host = _hostRepository.GetHostForEvent(theEvent.Id); model.EventLocation = host.OrganizationName + " @ " + host.Address; } } if (basicBimetric != null) { model.BloodPressure = (basicBimetric.SystolicPressure.HasValue ? basicBimetric.SystolicPressure.Value.ToString() : "0") + "/" + (basicBimetric.DiastolicPressure.HasValue ? basicBimetric.DiastolicPressure.Value.ToString() : "0"); model.PulseRate = basicBimetric.PulseRate.HasValue ? basicBimetric.PulseRate.Value.ToString() : ""; model.IsAbnormalBloodPressure = basicBimetric.IsBloodPressureElevated.HasValue && basicBimetric.IsBloodPressureElevated.Value ? PhysicianPartnerResultExportHelper.YesString : PhysicianPartnerResultExportHelper.NoString; } ITestResultRepository testResultRepository; var isTestPurchased = _testResultService.IsTestPurchasedByCustomer(eventData.EventId, customer.CustomerId, (long)TestType.AwvAAA); if (isTestPurchased) { _logger.Info("Setting Awv Aaa data."); testResultRepository = new AwvAaaTestRepository(); var awvAaaTestResult = testResultRepository.GetTestResults(customer.CustomerId, eventData.EventId); if (awvAaaTestResult != null) { model = _awvAaaFactory.SetAwvAaaData(model, awvAaaTestResult as AwvAaaTestResult); } } isTestPurchased = _testResultService.IsTestPurchasedByCustomer(eventData.EventId, customer.CustomerId, (long)TestType.AwvEcho); if (isTestPurchased) { _logger.Info("Setting Awv Echo data."); testResultRepository = new AwvEchocardiogramTestRepository(); var awvEchoTestResult = testResultRepository.GetTestResults(customer.CustomerId, eventData.EventId); if (awvEchoTestResult != null) { model = _awvEchoFactory.SetAwvEchoData(model, awvEchoTestResult as AwvEchocardiogramTestResult); } } isTestPurchased = _testResultService.IsTestPurchasedByCustomer(eventData.EventId, customer.CustomerId, (long)TestType.AwvCarotid); if (isTestPurchased) { _logger.Info("Setting Awv Carotid data."); testResultRepository = new AwvCarotidTestRepository(); var awvCarotidTestResult = testResultRepository.GetTestResults(customer.CustomerId, eventData.EventId); if (awvCarotidTestResult != null) { model = _awvCarotidFactory.SetAwvCarotidData(model, awvCarotidTestResult as AwvCarotidTestResult); } } isTestPurchased = _testResultService.IsTestPurchasedByCustomer(eventData.EventId, customer.CustomerId, (long)TestType.AwvSpiro); if (isTestPurchased) { _logger.Info("Setting AWV Spiro data."); testResultRepository = new AwvSpiroTestRepository(); var awvSpiroTestResult = testResultRepository.GetTestResults(customer.CustomerId, eventData.EventId); if (awvSpiroTestResult != null) { model = _awvSpiroFactory.SetAwvSpiroData(model, awvSpiroTestResult as AwvSpiroTestResult); } } isTestPurchased = _testResultService.IsTestPurchasedByCustomer(eventData.EventId, customer.CustomerId, (long)TestType.AwvABI); if (isTestPurchased) { _logger.Info("Setting Awv ABI data."); testResultRepository = new AwvAbiTestRepository(); var awvAbiTestResult = testResultRepository.GetTestResults(customer.CustomerId, eventData.EventId); if (awvAbiTestResult != null) { model = _awvAbiFactory.SetAwvAbiData(model, awvAbiTestResult as AwvAbiTestResult); } } isTestPurchased = _testResultService.IsTestPurchasedByCustomer(eventData.EventId, customer.CustomerId, (long)TestType.AwvEkg); if (isTestPurchased) { _logger.Info("Setting Awv EKG data."); testResultRepository = new AwvEkgTestRepository(); var awvEkgTestResult = testResultRepository.GetTestResults(customer.CustomerId, eventData.EventId); if (awvEkgTestResult != null) { model = _awvEkgFactory.SetAwvEkgData(model, awvEkgTestResult as AwvEkgTestResult); } } isTestPurchased = _testResultService.IsTestPurchasedByCustomer(eventData.EventId, customer.CustomerId, (long)TestType.Vision); if (isTestPurchased) { _logger.Info("Setting Vision data."); testResultRepository = new VisionTestRepository(); var visionTestResult = testResultRepository.GetTestResults(customer.CustomerId, eventData.EventId); if (visionTestResult != null) { model = _visionFactory.SetVisionData(model, visionTestResult as VisionTestResult); } } WriteCsv(model, destinationPath); _logger.Info(counter + " completed out of " + totalRecords); //if (counter > 10) // break; counter++; } catch (Exception ex) { _logger.Error(string.Format("\n\nFor Event {0} and Customer {1} \n Error:{2}", eventCustomerResultEntity.EventId, eventCustomerResultEntity.CustomerId, ex.Message)); } } }
private LabsInboundViewModel SetLabResults(LabsInboundViewModel model, long customerId, long eventId, long testId, bool isNewResultFlow, bool getLeftReadings = false) { var isTestPurchased = false; ITestResultRepository testResultRepository; if (testId == (long)LabInboundTestType.Echo) { isTestPurchased = _testResultService.IsTestPurchasedByCustomer(eventId, customerId, (long)TestType.AwvEcho); if (isTestPurchased) { testResultRepository = new AwvEchocardiogramTestRepository(); var awvEchoTestResult = testResultRepository.GetTestResults(customerId, eventId, isNewResultFlow); if (awvEchoTestResult != null && (awvEchoTestResult.TestNotPerformed == null || awvEchoTestResult.TestNotPerformed.TestNotPerformedReasonId <= 0)) { var result = awvEchoTestResult as AwvEchocardiogramTestResult; if (result != null && result.Finding != null) { model.LabResult = result.Finding.Label; } } } } else if (testId == (long)LabInboundTestType.A1C) { isTestPurchased = _testResultService.IsTestPurchasedByCustomer(eventId, customerId, (long)TestType.AwvHBA1C); if (isTestPurchased) { testResultRepository = new AwvHemaglobinTestRepository(); var awvHemaglobinTestResult = testResultRepository.GetTestResults(customerId, eventId, isNewResultFlow); if (awvHemaglobinTestResult != null && (awvHemaglobinTestResult.TestNotPerformed == null || awvHemaglobinTestResult.TestNotPerformed.TestNotPerformedReasonId <= 0)) { var result = awvHemaglobinTestResult as AwvHemaglobinTestResult; if (result != null && result.Hba1c != null) { model.LabResult = result.Hba1c.Reading; } } } } else if (testId == (long)LabInboundTestType.Ekg) { isTestPurchased = _testResultService.IsTestPurchasedByCustomer(eventId, customerId, (long)TestType.AwvEkg); if (isTestPurchased) { testResultRepository = new AwvEkgTestRepository(); var awvEkgTestResult = testResultRepository.GetTestResults(customerId, eventId, isNewResultFlow); if (awvEkgTestResult != null && (awvEkgTestResult.TestNotPerformed == null || awvEkgTestResult.TestNotPerformed.TestNotPerformedReasonId <= 0)) { var result = awvEkgTestResult as AwvEkgTestResult; if (result != null && result.Finding != null) { model.LabResult = result.Finding.Label; } } } } //FL Blue asked us to Leave the Test with blank result field /*else if (testId == (long)LabInboundTestType.DiabeticRetinopathy) * { * isTestPurchased = _testResultService.IsTestPurchasedByCustomer(eventId, customerId, (long)TestType.DiabeticRetinopathy); * if (isTestPurchased) * { * testResultRepository = new DiabeticRetinopathyTestRepository(); * var diabeticRetinopathyTestResult = testResultRepository.GetTestResults(customerId, eventId, isNewResultFlow); * if (diabeticRetinopathyTestResult != null && (diabeticRetinopathyTestResult.TestNotPerformed == null || diabeticRetinopathyTestResult.TestNotPerformed.TestNotPerformedReasonId <= 0)) * { * var result = diabeticRetinopathyTestResult as DiabeticRetinopathyTestResult; * if (result != null && result.Finding != null) * model.LabResult = result.Finding.Label; * } * } * }*/ else if (testId == (long)LabInboundTestType.UrineMicroalbumin) { isTestPurchased = _testResultService.IsTestPurchasedByCustomer(eventId, customerId, (long)TestType.UrineMicroalbumin); if (isTestPurchased) { testResultRepository = new UrineMicroalbuminTestRepository(); var urineMicroalbuminTestResult = testResultRepository.GetTestResults(customerId, eventId, isNewResultFlow); if (urineMicroalbuminTestResult != null && (urineMicroalbuminTestResult.TestNotPerformed == null || urineMicroalbuminTestResult.TestNotPerformed.TestNotPerformedReasonId <= 0)) { var result = urineMicroalbuminTestResult as UrineMicroalbuminTestResult; if (result != null && result.MicroalbuminValue != null) { model.LabResult = result.MicroalbuminValue.Reading; } else { model.LabResult = KitDistributedString; } } } } else if (testId == (long)LabInboundTestType.AwvAbi) { isTestPurchased = _testResultService.IsTestPurchasedByCustomer(eventId, customerId, (long)TestType.AwvABI); if (isTestPurchased) { testResultRepository = new AwvAbiTestRepository(); var awvAbiTestResult = testResultRepository.GetTestResults(customerId, eventId, isNewResultFlow); if (awvAbiTestResult != null && (awvAbiTestResult.TestNotPerformed == null || awvAbiTestResult.TestNotPerformed.TestNotPerformedReasonId <= 0)) { var result = awvAbiTestResult as AwvAbiTestResult; if (result != null && result.Finding != null) { model.LabResult = result.Finding.Label; } } } } else if (testId == (long)LabInboundTestType.ScreeningMammographyDigital) { isTestPurchased = _testResultService.IsTestPurchasedByCustomer(eventId, customerId, (long)TestType.Mammogram); if (isTestPurchased) { testResultRepository = new MammogramTestRepository(); var mammogramTestResult = testResultRepository.GetTestResults(customerId, eventId, isNewResultFlow); if (mammogramTestResult != null && (mammogramTestResult.TestNotPerformed == null || mammogramTestResult.TestNotPerformed.TestNotPerformedReasonId <= 0)) { var result = mammogramTestResult as MammogramTestResult; if (result != null && result.Finding != null && !string.IsNullOrWhiteSpace(result.Finding.Label)) { model.LabResult = "BIRAD-" + result.Finding.Label.Substring(0, 1); } } } } else if (testId == (long)LabInboundTestType.AwvSpirometry) { isTestPurchased = _testResultService.IsTestPurchasedByCustomer(eventId, customerId, (long)TestType.AwvSpiro); if (isTestPurchased) { testResultRepository = new AwvSpiroTestRepository(); var awvSpiroTestResult = testResultRepository.GetTestResults(customerId, eventId, isNewResultFlow); if (awvSpiroTestResult != null && (awvSpiroTestResult.TestNotPerformed == null || awvSpiroTestResult.TestNotPerformed.TestNotPerformedReasonId <= 0)) { var result = awvSpiroTestResult as AwvSpiroTestResult; if (result != null && result.Finding != null) { model.LabResult = result.Finding.Label; } } } } else if (testId == (long)LabInboundTestType.BloodPressure) { isTestPurchased = _testResultService.IsTestPurchasedByCustomer(eventId, customerId, (long)TestType.Hypertension); if (isTestPurchased) { testResultRepository = new HypertensionTestRepository(); var hyperTenstionTestResult = testResultRepository.GetTestResults(customerId, eventId, isNewResultFlow); if (hyperTenstionTestResult != null && (hyperTenstionTestResult.TestNotPerformed == null || hyperTenstionTestResult.TestNotPerformed.TestNotPerformedReasonId <= 0)) { var basicBiometric = _basicBiometricRepository.Get(eventId, customerId); if (basicBiometric != null) { model.LabResult = (basicBiometric.SystolicPressure.HasValue ? basicBiometric.SystolicPressure.Value.ToString() : "0") + "/" + (basicBiometric.DiastolicPressure.HasValue ? basicBiometric.DiastolicPressure.Value.ToString() : "0"); } } } } else if (testId == (long)LabInboundTestType.AwvAaa) { isTestPurchased = _testResultService.IsTestPurchasedByCustomer(eventId, customerId, (long)TestType.AwvAAA); if (isTestPurchased) { testResultRepository = new AwvAaaTestRepository(); var awvAaaTestResult = testResultRepository.GetTestResults(customerId, eventId, isNewResultFlow); if (awvAaaTestResult != null && (awvAaaTestResult.TestNotPerformed == null || awvAaaTestResult.TestNotPerformed.TestNotPerformedReasonId <= 0)) { var result = awvAaaTestResult as AwvAaaTestResult; if (result != null && result.Finding != null) { model.LabResult = result.Finding.Label; } } } } else if (testId == (long)LabInboundTestType.Ifobt) { isTestPurchased = _testResultService.IsTestPurchasedByCustomer(eventId, customerId, (long)TestType.IFOBT); if (isTestPurchased) { testResultRepository = new IFOBTTestRepository(); var ifobtTestResult = testResultRepository.GetTestResults(customerId, eventId, isNewResultFlow); if (ifobtTestResult != null && (ifobtTestResult.TestNotPerformed == null || ifobtTestResult.TestNotPerformed.TestNotPerformedReasonId <= 0)) { var result = ifobtTestResult as IFOBTTestResult; if (result != null && result.Finding != null && !string.IsNullOrWhiteSpace(result.Finding.Label) && (result.Finding.Label.ToLower() == PositiveString.ToLower() || result.Finding.Label.ToLower() == NegativeString.ToLower())) { model.LabResult = result.Finding.Label; } else { model.LabResult = KitDistributedString; } } } } else if (testId == (long)LabInboundTestType.Lead) { isTestPurchased = _testResultService.IsTestPurchasedByCustomer(eventId, customerId, (long)TestType.Lead); if (isTestPurchased) { testResultRepository = new LeadTestRepository(); var leadTestResult = testResultRepository.GetTestResults(customerId, eventId, isNewResultFlow); if (leadTestResult != null && (leadTestResult.TestNotPerformed == null || leadTestResult.TestNotPerformed.TestNotPerformedReasonId <= 0)) { var result = leadTestResult as LeadTestResult; if (result != null) { var readings = testResultRepository.GetAllReadings((int)TestType.Lead); var readingLabels = new List <string>(); if (getLeftReadings) { model.LabType = EnumExtension.GetDescription(LabInboundTestType.Lead) + " L"; if (result.LeftResultReadings != null) { var leftResultReadings = result.LeftResultReadings; if (leftResultReadings.NoVisualPlaque != null && leftResultReadings.NoVisualPlaque.Reading != null) { var reading = readings.First(x => x.Label == ReadingLabels.LeftNoVisualPlaque); readingLabels.Add(reading.LableText); } if (leftResultReadings.VisuallyDemonstratedPlaque != null && leftResultReadings.VisuallyDemonstratedPlaque.Reading != null) { var reading = readings.First(x => x.Label == ReadingLabels.LeftVisuallyDemonstratedPlaque); readingLabels.Add(reading.LableText); } if (leftResultReadings.ModerateStenosis != null && leftResultReadings.ModerateStenosis.Reading != null) { var reading = readings.First(x => x.Label == ReadingLabels.LeftModerateStenosis); readingLabels.Add(reading.LableText); } if (leftResultReadings.PossibleOcclusion != null && leftResultReadings.PossibleOcclusion.Reading != null) { var reading = readings.First(x => x.Label == ReadingLabels.LeftPossibleOcclusion); readingLabels.Add(reading.LableText); } } } else { model.LabType = EnumExtension.GetDescription(LabInboundTestType.Lead) + " R"; if (result.RightResultReadings != null) { var rightResultReading = result.RightResultReadings; if (rightResultReading.NoVisualPlaque != null && rightResultReading.NoVisualPlaque.Reading != null) { var reading = readings.First(x => x.Label == ReadingLabels.RightNoVisualPlaque); readingLabels.Add(reading.LableText); } if (rightResultReading.VisuallyDemonstratedPlaque != null && rightResultReading.VisuallyDemonstratedPlaque.Reading != null) { var reading = readings.First(x => x.Label == ReadingLabels.RightVisuallyDemonstratedPlaque); readingLabels.Add(reading.LableText); } if (rightResultReading.ModerateStenosis != null && rightResultReading.ModerateStenosis.Reading != null) { var reading = readings.First(x => x.Label == ReadingLabels.RightModerateStenosis); readingLabels.Add(reading.LableText); } if (rightResultReading.PossibleOcclusion != null && rightResultReading.PossibleOcclusion.Reading != null) { var reading = readings.First(x => x.Label == ReadingLabels.RightPossibleOcclusion); readingLabels.Add(reading.LableText); } } } model.LabResult = string.Join(", ", readingLabels); } } } } else if (testId == (long)LabInboundTestType.Monofilament) { isTestPurchased = _testResultService.IsTestPurchasedByCustomer(eventId, customerId, (long)TestType.Monofilament); if (isTestPurchased) { testResultRepository = new MonofilamentTestRepository(); var monofilamentTestResult = testResultRepository.GetTestResults(customerId, eventId, isNewResultFlow); if (monofilamentTestResult != null && (monofilamentTestResult.TestNotPerformed == null || monofilamentTestResult.TestNotPerformed.TestNotPerformedReasonId <= 0)) { var result = monofilamentTestResult as MonofilamentTestResult; if (result != null) { var readings = testResultRepository.GetAllReadings((int)TestType.Monofilament); if (getLeftReadings) { model.LabType = EnumExtension.GetDescription(LabInboundTestType.Monofilament) + " L"; if (result.LeftPositive != null) { var reading = readings.First(x => x.Label == ReadingLabels.MonofilamentLeftFootSensationIntact); model.LabResult = reading.LableText; } else if (result.LeftNegative != null) { var reading = readings.First(x => x.Label == ReadingLabels.MonofilamentLeftFootSensationNotIntact); model.LabResult = reading.LableText; } } else { model.LabType = EnumExtension.GetDescription(LabInboundTestType.Monofilament) + " R"; if (result.RightPositive != null) { var reading = readings.First(x => x.Label == ReadingLabels.MonofilamentRightFootSensationIntact); model.LabResult = reading.LableText; } else if (result.RightNegative != null) { var reading = readings.First(x => x.Label == ReadingLabels.MonofilamentRightFootSensationNotIntact); model.LabResult = reading.LableText; } } } } } } else if (testId == (long)LabInboundTestType.QuantaFloAbi) { isTestPurchased = _testResultService.IsTestPurchasedByCustomer(eventId, customerId, (long)TestType.QuantaFloABI); if (isTestPurchased) { testResultRepository = new QuantaFloABITestRepository(); var quantaFloAbiTestResult = testResultRepository.GetTestResults(customerId, eventId, isNewResultFlow); if (quantaFloAbiTestResult != null && (quantaFloAbiTestResult.TestNotPerformed == null || quantaFloAbiTestResult.TestNotPerformed.TestNotPerformedReasonId <= 0)) { var result = quantaFloAbiTestResult as QuantaFloABITestResult; if (result != null && result.Finding != null) { model.LabResult = result.Finding.Label; } } } } return(model); }