Пример #1
0
        public void UpdateTestPurchased(TempCart tempCart)
        {
            if (tempCart.EventPackageId.HasValue)
            {
                var userGender   = !string.IsNullOrEmpty(tempCart.Gender) ? ((long)(Gender)Enum.Parse(typeof(Gender), tempCart.Gender, true)) : (long)Gender.Unspecified;
                var theEvent     = _eventRepository.GetById(tempCart.EventId.Value);
                var eventPackage = _eventPackageRepository.GetById(tempCart.EventPackageId.Value);
                var eventTests   = theEvent.EnableAlaCarteOnline ? _eventTestRepository.GetTestsForEventByRole(tempCart.EventId.Value, (long)Roles.Customer, userGender) : null;

                if (eventPackage.Tests.Any())
                {
                    var  packageTestIds      = eventPackage.Tests.Select(x => x.Id).ToList();
                    var  panelTestId         = (long)(userGender == (long)Gender.Male ? TestType.MenBloodPanel : TestType.WomenBloodPanel);
                    var  panelTestGroup      = (panelTestId == (long)TestType.MenBloodPanel ? TestGroup.MensBloodPanelTestIds : TestGroup.WomenBloodPanelTestIds);
                    long panelEventTestId    = 0;
                    var  panelEventTestGroup = new List <long>();

                    if (!eventTests.IsNullOrEmpty())
                    {
                        panelEventTestId = eventTests.Any(x => x.TestId == panelTestId) ? eventTests.First(x => x.TestId == panelTestId).Id : 0;

                        panelEventTestGroup = eventTests.Where(et => panelTestGroup.Contains(et.TestId)).Select(x => x.Id).ToList();
                    }


                    var seletectedTests = new List <long>();

                    var purchasedPanelTest = false;


                    if (!string.IsNullOrWhiteSpace(tempCart.TestId))
                    {
                        seletectedTests.AddRange(tempCart.TestId.Split(',').Select(long.Parse).ToList());
                    }

                    if (seletectedTests.Any() && packageTestIds.Any() && panelEventTestId > 0)
                    {
                        seletectedTests    = seletectedTests.Where(x => !packageTestIds.Contains(x)).ToList();
                        purchasedPanelTest = packageTestIds.Any(x => x == panelEventTestId);
                    }

                    if (purchasedPanelTest)
                    {
                        seletectedTests = seletectedTests.Where(x => !panelEventTestGroup.Contains(x)).ToList();
                    }

                    tempCart.TestId = null;
                    if (seletectedTests.Any())
                    {
                        var selectedTestIds = string.Join(",", seletectedTests);
                        tempCart.TestId = selectedTestIds;
                    }
                }
            }
        }
Пример #2
0
        public void GetTestForEventByROle_ValidId_Tester()
        {
            var eventTests = _eventTestRepository.GetTestsForEventByRole(24762, 1);

            Assert.IsNotNull(eventTests);
            Assert.IsNotEmpty(eventTests.ToArray());

            var eventIds     = eventTests.Select(et => et.EventId);
            var testIds      = eventTests.Select(et => et.TestId);
            var eventTestIds = eventTests.Select(et => et.Id);

            Assert.IsTrue(eventIds.Contains(24762));

            Assert.IsTrue(eventTestIds.Contains(196415));
            Assert.IsTrue(eventTestIds.Contains(196414));

            Assert.IsTrue(testIds.Contains(1));
            Assert.IsTrue(testIds.Contains(3));
        }
Пример #3
0
        public PackageSelectionViewData GetPackageSelectionViewData(long eventId, long roleId, long packageId,
                                                                    List <long> packageTestIds, List <long> independentTestIds)
        {
            var eventPackages = _eventPackageRepository.GetPackagesForEventByRole(eventId, roleId).ToList();
            var packages      = eventPackages.Select(ep => ep.Package).ToList();

            var currentSelectedPackage = packages.SingleOrDefault(p => p.Id == packageId);

            var eventTests = _eventTestRepository.GetTestsForEventByRole(eventId, roleId);
            var tests      = eventTests.Select(et => et.Test).ToList();

            tests = AdjustAndSortTests(tests);

            if (!packageTestIds.IsNullOrEmpty() || !independentTestIds.IsNullOrEmpty())
            {
                var selectedPackageId = _shoppingCartRecommendationService.RecommendPackage(packageId, packageTestIds,
                                                                                            independentTestIds, packages);
                var selectedPackage = packages.SingleOrDefault(p => p.Id == selectedPackageId);

                var packageSelectionViewData = _packageSelectionViewDataFactory.Create(selectedPackageId, packageTestIds, independentTestIds, packages, tests);

                packageSelectionViewData.RecommendationMessage =
                    _shoppingCartRecommendationService.RecommendPackageUpgrade(packageSelectionViewData, packages);

                if (selectedPackageId != packageId)
                {
                    if (selectedPackageId > 0 && packageId > 0 && (selectedPackage != null && currentSelectedPackage != null && selectedPackage.Price > currentSelectedPackage.Price))
                    {
                        packageSelectionViewData.PackageChangeMessage = string.Format(
                            "We have changed your package from {0} to {1}. This Package will save you ${2} for the same set of test(s).",
                            currentSelectedPackage.Name, selectedPackage.Name, packageSelectionViewData.TotalSavings);
                    }
                    if (selectedPackageId > 0 && packageId == 0 && selectedPackage != null)
                    {
                        packageSelectionViewData.PackageChangeMessage = string.Format(
                            "We have changed your package to {0}. This Package will save you ${1} for the same set of test(s).",
                            selectedPackage.Name, packageSelectionViewData.TotalSavings);
                    }
                }
                return(packageSelectionViewData);
            }
            return(_packageSelectionViewDataFactory.Create(packageId, packageTestIds, independentTestIds, packages, tests));
        }
Пример #4
0
        public PreQualificationViewModel SavePreQualificationAnswer(PreQualificationViewModel model)
        {
            var onlineRequestValidationModel = _tempcartService.ValidateOnlineRequest(model.Guid);

            model.RequestValidationModel = onlineRequestValidationModel;
            if (onlineRequestValidationModel.RequestStatus != OnlineRequestStatus.Valid)
            {
                return(model);
            }

            var tempCart = onlineRequestValidationModel.TempCart;

            if (!string.IsNullOrEmpty(tempCart.Gender) && tempCart.Gender != model.Gender && !string.IsNullOrEmpty(tempCart.TestId) && tempCart.EventId.HasValue)
            {
                Gender gender;
                System.Enum.TryParse(model.Gender, out gender);

                var testIds = tempCart.TestId.Split(',').Select(long.Parse).ToList();

                var eventTests = _eventTestRepository.GetTestsForEventByRole(tempCart.EventId.Value, (long)Roles.Customer, (long)gender);
                if (!eventTests.IsNullOrEmpty())
                {
                    testIds         = eventTests.Where(x => testIds.Contains(x.Id)).Select(x => x.Id).ToList();
                    tempCart.TestId = string.Join(",", testIds);
                }
            }
            tempCart.Gender = model.Gender;
            tempCart.Dob    = model.Dob;

            _tempcartService.SaveTempCart(tempCart);

            onlineRequestValidationModel.TempCart = tempCart;
            if (model.AskPreQualificationQuestion)
            {
                _onlineEventService.SaveAnswer(model);
            }
            return(model);
        }
Пример #5
0
        public PatientWorksheet GetPatientWorksheetModel(Customer customer, Event theEvent, EventCustomer eventCustomer)
        {
            var customerId = customer.Id;
            var eventId    = theEvent.Id;

            var order                = _orderRepository.GetOrderByEventCustomerId(eventCustomer.Id);
            var eventPackage         = _eventPackageRepository.GetPackageForOrder(order.Id);
            var eventTest            = _eventTestRepository.GetTestsForOrder(order.Id);
            var products             = _electronicProductRepository.GetAllProductsForEvent(eventId);
            var purchasedProduct     = _electronicProductRepository.GetElectronicProductByOrderId(order.Id);
            var customerIcdCodes     = _customerIcdCodesRepository.GetIcdByCustomerId(customerId);
            var customerTags         = _corporateCustomerCustomTagRepository.GetByCustomerId(customerId);
            var preApporvedTestNames = _preApprovedTestRepository.GetPreApprovedTestNameByEventCustomerId(eventCustomer.Id);
            var testForTechnician    = _eventTestRepository.GetTestsForEventByRole(eventId, (long)Roles.Technician);

            string[] customerRecentTags = null;

            var isCorporateEvent = theEvent.EventType == EventType.Corporate;

            if (customerTags != null && customerTags.Any() && isCorporateEvent)
            {
                customerTags       = customerTags.OrderByDescending(x => x.DataRecorderMetaData.DateCreated).Take(4);
                customerRecentTags = customerTags.Select(x => x.Tag).ToArray();
            }

            var icdCodes = new List <string>();

            if (!customerIcdCodes.IsNullOrEmpty())
            {
                icdCodes = _icdCodesRepository.GetIcdByIds(customerIcdCodes.Select(x => x.IcdCodeId)).Select(x => x.CodeName.ToUpper()).ToList();
            }

            var labName = string.Empty;

            if (customer.LabId.HasValue)
            {
                var lab = _labRepository.GetById(customer.LabId.Value);
                labName = lab.Name;
            }

            return(new PatientWorksheet
            {
                Name = customer.Name,
                CustomerId = customer.CustomerId,
                Dob = customer.DateOfBirth,
                Height = customer.Height,
                Weight = customer.Weight,
                Gender = customer.Gender,
                Package = eventPackage,
                Tests = eventTest,
                Lab = labName,
                AlaCarteTest = testForTechnician,
                AllProducts = products,
                ProductId = purchasedProduct != null ? purchasedProduct.Id : 0,
                IcdCodes = icdCodes,
                PreApporvedTestNames = preApporvedTestNames,
                EventDate = theEvent.EventDate,
                CustomTags = customerRecentTags,
                IsCorporateEvent = theEvent.EventType == EventType.Corporate
            });
        }
        public OrderPlaceEditModel GetEventPackage(OrderPlaceEditModel model, long eventId, Roles role, long customerId, TempCart tempCart)
        {
            var theEvent       = _eventRepository.GetById(eventId);
            var userGender     = !string.IsNullOrEmpty(tempCart.Gender) ? ((long)(Gender)Enum.Parse(typeof(Gender), tempCart.Gender, true)) : (long)Gender.Unspecified;
            var enableAlaCarte = Convert.ToBoolean(_configurationRepository.GetConfigurationValue(ConfigurationSettingName.EnableAlaCarte));

            var parentRole = (Roles)GetParentRoleIdByRoleId((long)role);

            if (enableAlaCarte)
            {
                if (role == Roles.Customer || parentRole == Roles.Customer)
                {
                    enableAlaCarte = theEvent.EnableAlaCarteOnline;
                }
                else if (role == Roles.CallCenterRep || role == Roles.CallCenterManager || parentRole == Roles.CallCenterRep || parentRole == Roles.CallCenterManager)
                {
                    enableAlaCarte = theEvent.EnableAlaCarteCallCenter;
                }
                else if (role == Roles.Technician || parentRole == Roles.Technician)
                {
                    enableAlaCarte = theEvent.EnableAlaCarteTechnician;
                }
                else if (!(theEvent.EnableAlaCarteOnline || theEvent.EnableAlaCarteCallCenter || theEvent.EnableAlaCarteTechnician))
                {
                    enableAlaCarte = false;
                }
            }

            var eventPackages = _eventPackageRepository.GetPackagesForEventByRole(eventId, (long)role, userGender);

            var eventTests = enableAlaCarte ? _eventTestRepository.GetTestsForEventByRole(eventId, (long)role, userGender) : null;

            if (eventTests != null && eventTests.Count() > 0)
            {
                eventTests = eventTests.Where(et => et.Test.ShowInAlaCarte).Select(et => et).ToArray();
            }
            var products        = _productRepository.GetAllProductsForEvent(eventId);
            var shippingOptions = _shippingOptionRepository.GetAllShippingOptionsForBuyingProcess();

            var shippingOptionsToBind = new List <ShippingOption>();

            if (theEvent.EventType == EventType.Retail)
            {
                var onlineShippingOption = _shippingOptionRepository.GetOnlineShippingOption();
                shippingOptionsToBind.Add(onlineShippingOption);

                if (shippingOptions != null && shippingOptions.Count > 0)
                {
                    shippingOptions.RemoveAll(so => so.Price == 0);
                    shippingOptionsToBind.AddRange(shippingOptions);
                }
                model.EventType = EventType.Retail;
            }
            else if (theEvent.EventType == EventType.Corporate)
            {
                var onlineShippingOption = _shippingOptionRepository.GetOnlineShippingOption();
                shippingOptionsToBind.Add(onlineShippingOption);

                shippingOptions = _shippingOptionRepository.GetAllShippingOptionForCorporate(theEvent.AccountId.HasValue ? theEvent.AccountId.Value : 0);
                if (shippingOptions != null && shippingOptions.Count > 0)
                {
                    shippingOptionsToBind.AddRange(shippingOptions);
                }
                else
                {
                    tempCart.ShippingId = onlineShippingOption.Id;
                }

                model.EventType = EventType.Corporate;
            }

            if (theEvent.EventType == EventType.Corporate)
            {
                eventPackages = eventPackages != null?eventPackages.OrderByDescending(d => d.Price).ThenBy(d => d.Package.RelativeOrder) : null;
            }
            else
            {
                eventPackages = eventPackages != null?eventPackages.OrderByDescending(d => d.Price) : null;
            }

            eventTests = eventTests != null?eventTests.OrderByDescending(d => d.Price) : null;

            products = products != null?products.OrderBy(d => d.Price).ToList() : null;


            model.AllEventPackages   = Mapper.Map <IEnumerable <EventPackage>, IEnumerable <EventPackageOrderItemViewModel> >(eventPackages);
            model.AllEventTests      = Mapper.Map <IEnumerable <EventTest>, IEnumerable <EventTestOrderItemViewModel> >(eventTests);
            model.AllProducts        = Mapper.Map <IEnumerable <ElectronicProduct>, IEnumerable <ProductOrderItemViewModel> >(products);
            model.AllShippingOptions = Mapper.Map <IEnumerable <ShippingOption>, IEnumerable <ShippingOptionOrderItemViewModel> >(shippingOptionsToBind);

            int age = 0;

            if (customerId > 0)
            {
                var customer = _customerRepository.GetCustomer(customerId);
                age = customer.DateOfBirth.HasValue ? customer.DateOfBirth.Value.GetAge() : 0;
            }
            else if (tempCart.Dob.HasValue)
            {
                age = tempCart.Dob.Value.GetAge();
            }

            if (age > 0)
            {
                foreach (var eventPackage in model.AllEventPackages)
                {
                    foreach (var test in eventPackage.Tests)
                    {
                        if (test.MinAge > 0 && age < test.MinAge)
                        {
                            eventPackage.NotAvailable           = true;
                            eventPackage.NotAvailabilityMessage = "includes " + test.Name + " for which minimum age required is " + test.MinAge;
                            break;
                        }
                        if (test.MaxAge > 0 && age > test.MaxAge)
                        {
                            eventPackage.NotAvailable           = true;
                            eventPackage.NotAvailabilityMessage = "includes " + test.Name + " for which maximum age required is " + test.MaxAge;
                            break;
                        }
                    }
                }

                foreach (var test in model.AllEventTests)
                {
                    if (test.MinAge > 0 && age < test.MinAge)
                    {
                        test.NotAvailable           = true;
                        test.NotAvailabilityMessage = "For this test minimum age required is " + test.MinAge;
                        break;
                    }
                    if (test.MaxAge > 0 && age > test.MaxAge)
                    {
                        test.NotAvailable           = true;
                        test.NotAvailabilityMessage = "For this test maximum age required is " + test.MaxAge;
                        break;
                    }
                }
            }

            if (model.AllEventPackages != null && model.AllEventPackages.Any())
            {
                EventPackageOrderItemViewModel package = null;
                Gender gender;
                Enum.TryParse(tempCart.Gender, out gender);

                package = EventPackageOrderItemViewModel(model.AllEventPackages, eventPackages, gender);

                foreach (var eventPackage in model.AllEventPackages)
                {
                    eventPackage.IsRecommended = eventPackage.PackageId == package.PackageId;
                }
            }

            LoadPackageImagePath(eventPackages, model.AllEventPackages);

            model.EnableImageUpsell = IsImageUpsellEnabled(eventId);

            return(model);
        }
        private IEnumerable <TestModel> GetAvilableAlaCarteTests(long eventId)
        {
            var eventTest = _eventTestRepository.GetTestsForEventByRole(eventId, (long)Roles.Technician);

            return(GetTestModels(eventTest));
        }