public CustomerOrderDetail GetCustomerOrderDetails(long customerId, long eventId) { var order = _orderRepository.GetOrder(customerId, eventId); var customerProfile = _customerRepository.GetCustomer(customerId); if (customerProfile == null) { return(null); } var eventPackages = _eventPackageRepository.GetPackagesForEvent(eventId); var eventTests = _eventTestRepository.GetTestsForEvent(eventId); var customerOrder = new CustomerOrderDetail { OrderId = order.Id, EventId = eventId, CustomerId = customerId }; var orderPackage = order.OrderDetails.FirstOrDefault(o => o.DetailType == OrderItemType.EventPackageItem && o.OrderItemStatus.OrderStatusState == OrderStatusState.FinalSuccess); if (orderPackage != null) { var eventPackage = eventPackages.SingleOrDefault(x => x.Id == orderPackage.OrderItem.ItemId); customerOrder.PackageModel = GetEventPackage(eventPackage); } var orderTests = order.OrderDetails.Where(o => o.DetailType == OrderItemType.EventTestItem && o.OrderItemStatus.OrderStatusState == OrderStatusState.FinalSuccess).ToList(); if (orderTests != null) { var testIds = orderTests.Select(s => s.OrderItem.ItemId).ToArray(); var evemtTest = eventTests.Where(et => testIds.Contains(et.Id)); customerOrder.AlaCarteTests = GetTestModels(evemtTest); } var product = order.OrderDetails.Where(od => od.OrderItemStatus.OrderStatusState == OrderStatusState.FinalSuccess && od.OrderItem.OrderItemType == OrderItemType.ProductItem).Select(od => od.OrderItem.ItemId).FirstOrDefault(); customerOrder.ProductId = product; var shippingDetailIds = order.OrderDetails.SelectMany(od => od.ShippingDetailOrderDetails.Where(sdod => sdod.IsActive).Select(sdod => sdod.ShippingDetailId)).ToArray(); if (shippingDetailIds.Any()) { var shipingDetails = _shippingDetailRepository.GetByIds(shippingDetailIds).ToList(); customerOrder.ShippingOptions = shipingDetails.Select(x => new ShippingOptionDetail { Id = x.Id }).ToArray(); } return(customerOrder); }
public EventScreeningAuthorizationEditModel GetCustomersForAuthorization(long physicianId) { var eventData = _eventRepository.GetEventForAuthorization(physicianId); if (eventData == null) { return(null); } var host = _hostRepository.GetHostForEvent(eventData.Id); var eventTests = _eventTestRepository.GetTestsForEvent(eventData.Id); var eventPackages = _eventPackageRepository.GetPackagesForEvent(eventData.Id); var eventCustomers = _eventCustomerRepository.GetEventCustomersForAuthorization(eventData.Id); if (eventCustomers == null || eventCustomers.Count() < 1) { return(null); } var eventCustomerIds = eventCustomers.Select(ec => ec.Id).ToArray(); var assignments = _physicianAssignmentService.GetPhysicianAssignmentsByEventcustomerIds(eventCustomerIds); if (!assignments.Any(a => a.Primary.PhysicianId == physicianId)) { return(null); } eventCustomerIds = assignments.Where(a => a.Primary.PhysicianId == physicianId).Select(a => a.EventCustomerId).ToArray(); eventCustomers = eventCustomers.Where(ec => eventCustomerIds.Contains(ec.Id)).ToArray(); var orderIdEventCustomerIdPairs = _orderRepository.GetOrderEventCustomerIdPairforEventCustomerIds(eventCustomerIds); var orderIds = orderIdEventCustomerIdPairs.Select(p => p.FirstValue).ToArray(); var orderIdTestIdPairs = _eventTestRepository.GetEventTestIdForOrders(orderIds); var orderIdpackageIdPairs = _eventPackageRepository.GetEventPackageIdsForOrder(orderIds); var ecIdTestIdPairs = (from ec in orderIdEventCustomerIdPairs join ot in orderIdTestIdPairs on ec.FirstValue equals ot.FirstValue select new OrderedPair <long, long>(ec.SecondValue, ot.SecondValue)).ToArray(); var ecIdpackageIdPairs = (from ec in orderIdEventCustomerIdPairs join op in orderIdpackageIdPairs on ec.FirstValue equals op.FirstValue select new OrderedPair <long, long>(ec.SecondValue, op.SecondValue)).ToArray(); var customers = _customerRepository.GetCustomers(eventCustomers.Select(ec => ec.CustomerId).ToArray()); return(_eventScreeningAuthorizationEditModelFactory.Create(eventData, eventTests, eventCustomers, customers, eventPackages, ecIdpackageIdPairs, ecIdTestIdPairs, host)); }
public EventMetricsViewData GetEventMetricsViewData(long eventId, long orgRoleUserId) { // TODO: This method really needs refactoring, // TODO: probably every different part of the view data needs to be handled in different factory. // TODO: Will revisit this after shopping cart is complete. var orders = _orderRepository.GetAllOrdersForEvent(eventId); var eventPackages = _eventPackageRepository.GetPackagesForEvent(eventId); var eventTests = _eventTestRepository.GetTestsForEvent(eventId); var eventCustomers = _eventCustomerRepository.GetEventCustomersbyEventId(eventId); IOrganizationRoleUserRepository organizationRoleUserRepository = new OrganizationRoleUserRepository(); var organizationRoleUser = organizationRoleUserRepository.GetOrganizationRoleUser(orgRoleUserId); var eventMetricsViewData = _revenueStatisticsViewDataFactory.CreateEventMetricsViewData(orders, eventPackages, eventTests, organizationRoleUser, eventCustomers); eventMetricsViewData = _eventCustomerRepository.GetEventCustomerFlagMetrics(eventMetricsViewData, eventId); return(eventMetricsViewData); }
public void GetbyEventId_ValidId_Tester() { var eventPackages = _eventPackageRepository.GetPackagesForEvent(24759); Assert.IsNotNull(eventPackages); Assert.IsNotEmpty(eventPackages.ToArray()); var eventPackageIds = eventPackages.Select(ep => ep.Id).ToArray(); var packageIds = eventPackages.Select(ep => ep.PackageId).ToArray(); var eventIds = eventPackages.Select(ep => ep.EventId).ToArray(); Assert.IsTrue(eventPackageIds.Contains(73563)); Assert.IsTrue(eventPackageIds.Contains(73562)); Assert.IsTrue(packageIds.Contains(124)); Assert.IsTrue(packageIds.Contains(107)); Assert.IsTrue(eventIds.Contains(24759)); }
public MassRegistrationEditModel GetRegistrationEditModel(DataRow row, IEnumerable <State> states, IEnumerable <Country> countries, long eventId, List <long> selectedAppointmentIds) { var registrationEditModel = new MassRegistrationEditModel(); registrationEditModel.FirstName = GetRowValue(row, "FirstName"); registrationEditModel.LastName = GetRowValue(row, "LastName"); registrationEditModel.Email = GetRowValue(row, "Email"); registrationEditModel.Address = new AddressEditModel(); registrationEditModel.Address.StreetAddressLine1 = GetRowValue(row, "Address"); registrationEditModel.Address.StreetAddressLine2 = GetRowValue(row, "Suite"); registrationEditModel.Address.City = GetRowValue(row, "City"); registrationEditModel.Address.StateId = states.Where(s => s.Name == GetRowValue(row, "State")).Select(s => s.Id).FirstOrDefault(); registrationEditModel.Address.CountryId = countries.Where(c => c.Name == GetRowValue(row, "Country")).Select(c => c.Id).FirstOrDefault(); registrationEditModel.Address.ZipCode = GetRowValue(row, "Zip"); var packages = _eventPackageRepository.GetPackagesForEvent(eventId); var appointments = _slotService.GetSlots(eventId, AppointmentStatus.Free).ToList(); appointments.RemoveAll(a => selectedAppointmentIds.Contains(a.Id)); registrationEditModel.PackageId = packages.Where(p => p.Package.Name == GetRowValue(row, "Package")).Select(p => p.PackageId).FirstOrDefault(); var appointmentString = GetRowValue(row, "AppointmentTime"); registrationEditModel.AppointmentId = string.IsNullOrEmpty(appointmentString) ? 0 : appointments.Where(ap => ap.StartTime.ToShortTimeString() == Convert.ToDateTime((string)appointmentString).ToShortTimeString()).Select(ap => ap.Id).FirstOrDefault(); if (registrationEditModel.AppointmentId > 0) { selectedAppointmentIds.Add(registrationEditModel.AppointmentId); } var dateString = GetRowValue(row, "DOB"); DateTime date; if (DateTime.TryParse(dateString, out date)) { registrationEditModel.DateOfBirth = date; } registrationEditModel.HomeNumber = PhoneNumber.Create(GetRowValue(row, "PhoneNumber"), PhoneNumberType.Home); try { registrationEditModel.EmployeeId = GetRowValue(row, "EmployeeId"); } catch { } try { registrationEditModel.InsuranceId = GetRowValue(row, "MemberId"); } catch { } try { registrationEditModel.InsuranceId = GetRowValue(row, "InsuranceId"); } catch { } try { var ssn = GetRowValue(row, "SSN"); if (!string.IsNullOrEmpty(ssn)) { var length = ssn.Length; var appendString = ""; for (int i = 0; i < 9 - length; i++) { appendString += "X"; } registrationEditModel.Ssn = appendString + ssn; } } catch { } registrationEditModel.SendNotification = true; registrationEditModel.AddFreeShipping = true; return(registrationEditModel); }
public CustomerEventDetailViewModel GetPatients(PatientSearchFilter filter, long technicianId) { var list = new List <ShortPatientInfoViewModel>(); var patientList = _customerRepository.GetPatientList(filter); if (patientList.IsNullOrEmpty()) { return(new CustomerEventDetailViewModel()); } var customerIds = patientList.Select(x => x.CustomerId); var eventCustomers = _eventCustomerRepository.GetByCustomerIdEventDate(customerIds, DateTime.Today, DateTime.Now.AddDays(-1), technicianId).Where(x => x.AppointmentId.HasValue).ToArray(); if (eventCustomers.IsNullOrEmpty()) { return(new CustomerEventDetailViewModel()); } customerIds = eventCustomers.Select(x => x.CustomerId).Distinct().ToList(); var appointmentIds = eventCustomers.Where(x => x.AppointmentId.HasValue).Select(x => x.AppointmentId.Value).ToArray(); var appointments = _appointmentRepository.GetByIds(appointmentIds); var eventIds = eventCustomers.Select(x => x.EventId).Distinct().ToArray(); var events = _eventRepository.GetEventsByIds(eventIds); var eventModels = _eventService.GetShortEventInfoList(events); var hosts = _hostRepository.GetEventHosts(eventIds); var eventCustomerIds = eventCustomers.Select(x => x.Id); var orders = _orderRepository.GetAllOrdersByEventCustomerIds(eventCustomerIds); var participationConsentSignatures = _participationConsentSignatureRepository.GetByEventCustomerIds(eventCustomerIds); var fluConsentSignatures = _fluConsentSignatureRepository.GetByEventCustomerIds(eventCustomerIds); var physicianRecordRequestSignatures = _physicianRecordRequestSignatureRepository.GetByEventCustomerIds(eventCustomerIds); var primaryCarePhysicians = _primaryCarePhysicianRepository.GetByCustomerIds(customerIds); foreach (var eventCustomer in eventCustomers) { var patient = patientList.First(x => x.CustomerId == eventCustomer.CustomerId); var appointment = appointments.First(x => x.Id == eventCustomer.AppointmentId); var theEvent = events.First(x => x.Id == eventCustomer.EventId); var host = hosts.First(x => x.Id == theEvent.HostId); var order = orders.Single(o => o.CustomerId == eventCustomer.CustomerId); var eventPackages = _eventPackageRepository.GetPackagesForEvent(eventCustomer.EventId); var eventTests = _eventTestRepository.GetTestsForEvent(eventCustomer.EventId); var eventpackageId = order.OrderDetails.Where(od => od.OrderItemStatus.OrderStatusState == OrderStatusState.FinalSuccess && od.OrderItem.OrderItemType == OrderItemType.EventPackageItem) .Select(od => od.OrderItem.ItemId).SingleOrDefault(); var eventPackage = eventPackages.SingleOrDefault(ep => eventpackageId == ep.Id); var eventTestIds = order.OrderDetails.Where(od => od.OrderItemStatus.OrderStatusState == OrderStatusState.FinalSuccess && od.OrderItem.OrderItemType == OrderItemType.EventTestItem).Select(od => od.OrderItem.ItemId).ToArray(); var eventTestsonOrder = eventTests.Where(et => eventTestIds.Contains(et.Id)).ToArray(); var chaperoneSignature = _chaperoneSignatureRepository.GetByEventCustomerId(eventCustomer.Id); var model = new ShortPatientInfoViewModel { CustomerId = patient.CustomerId, EventCustomerId = eventCustomer.Id, FirstName = patient.Name.FirstName, MiddleName = patient.Name.MiddleName, LastName = patient.Name.LastName, Email = patient.Email.ToString(), HomePhone = patient.HomePhoneNumber.FormatPhoneNumber, MobileNumber = patient.MobilePhoneNumber.FormatPhoneNumber, EventId = eventCustomer.EventId, AppointmentTime = appointment.StartTime, Packages = eventPackage != null ? eventPackage.Package.Name : "", Tests = !eventTestsonOrder.IsNullOrEmpty() ? string.Join(", ", eventTestsonOrder.Select(t => t.Test.Name)) : "", HipaaConsent = eventCustomer.HIPAAStatus, CheckInTime = appointment.CheckInTime, CheckOutTime = appointment.CheckOutTime, MatrixConsent = participationConsentSignatures != null && participationConsentSignatures.SingleOrDefault(x => x.EventCustomerId == eventCustomer.Id) != null, PhysicianRecordRequest = physicianRecordRequestSignatures != null && physicianRecordRequestSignatures.SingleOrDefault(x => x.EventCustomerId == eventCustomer.Id) != null, FluVaccine = fluConsentSignatures != null && fluConsentSignatures.SingleOrDefault(x => x.EventCustomerId == eventCustomer.Id) != null, NoShow = eventCustomer.AppointmentId.HasValue && eventCustomer.NoShow, LeftWithoutScreening = eventCustomer.AppointmentId.HasValue && eventCustomer.LeftWithoutScreeningReasonId.HasValue, ChaperoneConsent = chaperoneSignature != null?true: false }; var pcp = primaryCarePhysicians != null?primaryCarePhysicians.FirstOrDefault(x => x.CustomerId == eventCustomer.CustomerId) : null; if (pcp != null) { var pcpAddress = pcp.Address != null?Mapper.Map <Address, AddressViewModel>(pcp.Address) : null; model.PrimaryCarePhysician = new PcpInfoViewModel { Name = pcp.Name.FullName, Address = pcpAddress, PhoneNumber = pcp.Primary != null ? pcp.Primary.FormatPhoneNumber : pcp.Secondary != null ? pcp.Secondary.FormatPhoneNumber : "", Fax = pcp.Fax != null ? pcp.Fax.FormatPhoneNumber : "" }; } list.Add(model); } return(new CustomerEventDetailViewModel { Customers = list, Events = eventModels }); }