public void UpdateEventCustomerPreApprovedTest(long eventId, long customerId) { var preApprovedTest = _preApprovedTestRepository.GetByCustomerId(customerId); var eventCustomer = _eventCustomerRepository.Get(eventId, customerId); var preApprovedPackages = _preApprovedPackageRepository.GetByCustomerId(customerId); if (preApprovedTest != null && preApprovedTest.Any() && eventCustomer != null) { _eventCustomerPreApprovedTestRepository.Save(eventCustomer.Id, preApprovedTest.Select(x => x.TestId)); } _eventCustomerPreApprovedPackageTestRepository.DeletePreApprovedPackageTests(eventCustomer.Id); if (preApprovedPackages != null && preApprovedPackages.Any()) { foreach (var preApprovedPackage in preApprovedPackages) { var preApprovedPacakgeTests = _packageTestRepository.GetbyPackageId(preApprovedPackage.PackageId); if (preApprovedPacakgeTests != null && preApprovedPacakgeTests.Any()) { _eventCustomerPreApprovedPackageTestRepository.Save(eventCustomer.Id, preApprovedPackage.PackageId, preApprovedPacakgeTests.Select(x => x.TestId)); } } } }
public void AddItem(IOrderable itemToOrder, int quantity, long forOrganizationRoleUserId, long dataRecorderCreatorId, SourceCode sourceCode, EventCustomer eventCustomer, ShippingDetail shippingDetail, OrderStatusState orderStatusState, long?sourceId = null) { if (sourceId == null && (itemToOrder is EventPackage || itemToOrder is EventTest)) { var customerId = forOrganizationRoleUserId; if (itemToOrder is EventTest) { var preApprovedTestList = _preApprovedTestRepository.GetByCustomerId(customerId).Select(x => x.TestId); if (preApprovedTestList.Contains(((EventTest)itemToOrder).TestId)) { sourceId = (long)OrderSource.PreApproved; } } else if (itemToOrder is EventPackage) { var preApprovedPackageList = _preApprovedPackageRepository.GetByCustomerId(customerId).Select(x => x.PackageId); if (preApprovedPackageList.Contains(((EventPackage)itemToOrder).PackageId)) { sourceId = (long)OrderSource.PreApproved; } } if (sourceId == null) { var oru = _organizationRoleUserRepository.GetOrganizationRoleUser(dataRecorderCreatorId); if (oru.RoleId == (long)Roles.FranchiseeAdmin) { sourceId = (long)OrderSource.Admin; } else if (oru.RoleId == (long)Roles.CallCenterRep) { sourceId = (long)OrderSource.CallCenter; } else if (oru.RoleId == (long)Roles.Technician) { sourceId = (long)OrderSource.Technician; } else if (oru.RoleId == (long)Roles.NursePractitioner) { sourceId = (long)OrderSource.NursePractioner; } } } OrderDetail orderDetail = _orderDetailFactory.CreateNewOrderDetail(itemToOrder, quantity, forOrganizationRoleUserId, dataRecorderCreatorId, sourceCode, eventCustomer, shippingDetail, sourceId); orderDetail.OrderItemStatus = _orderItemStatusFactory.CreateOrderItemStatus(itemToOrder.OrderItemType, (int)orderStatusState); var pair = new OrderedPair <OrderDetail, IOrderable>(orderDetail, itemToOrder); _lineItems.Add(pair); }
public void PollForAdjustOrder() { _logger.Info("Enter in Service to adjust Order"); var eventCustomersToAdjustOrder = _eventCustomerAdjustOrderLogRepository.GetEventCustomerToAdjustOrder(); if (eventCustomersToAdjustOrder.IsNullOrEmpty()) { _logger.Info("No Event Customer Found For Adjusting Order"); return; } var eventCustomers = _eventCustomerRepository.GetByIds(eventCustomersToAdjustOrder.Select(x => x.EventCustomerId)); foreach (var eventCustomer in eventCustomers) { if (eventCustomer.AppointmentId == null) { _logger.Info("Appointment has been cancel"); continue; } var customrePreApprovedTest = _preApprovedTestRepository.GetByCustomerId(eventCustomer.Id); if (customrePreApprovedTest.IsNullOrEmpty()) { _logger.Info("Customer has no pre approved test" + eventCustomer.CustomerId); } var preApprovedPackage = _preApprovedPackageRepository.GetByCustomerId(eventCustomer.CustomerId); if (customrePreApprovedTest.IsNullOrEmpty()) { _logger.Info("Customer has no pre-approved test" + eventCustomer.CustomerId); } if (preApprovedPackage.IsNullOrEmpty()) { _logger.Info("Customer has no pre-approved package" + eventCustomer.CustomerId); } var customerOrderDtails = new CustomerOrderDetail { CustomerId = eventCustomer.CustomerId, EventId = eventCustomer.EventId, PreApprovedTestIds = customrePreApprovedTest != null?customrePreApprovedTest.Select(x => x.TestId) : null, PrePackageId = preApprovedPackage.IsNullOrEmpty() ? 0 : preApprovedPackage.First().PackageId }; ChangePackage(customerOrderDtails); } }
public MedicareCustomerViewModel GetCustomerDetails(long customerId) { var customer = _customerRepository.GetCustomer(customerId); if (customer == null) { return(null); } var model = _medicareFactory.CreateCustomerViewModel(customer); if (customer.LanguageId.HasValue) { var lang = _languageRepository.GetById(customer.LanguageId.Value); if (lang != null) { model.PreferredLanguage = lang.Name; } } var currentMedications = _currentMedicationRepository.GetByCustomerId(customerId).ToArray(); if (currentMedications.Any()) { var currentMedicationList = new List <MedicareCurrentMedication>(); var ndcIds = currentMedications.Select(x => x.NdcId); var ndcs = _ndcRepository.GetByIds(ndcIds); if (ndcs != null && ndcs.Any()) { foreach (var ndc in ndcs) { var curr = currentMedications.FirstOrDefault(x => x.NdcId == ndc.Id); currentMedicationList.Add(new MedicareCurrentMedication { CurrentMedication = ndc.NdcCode, IsPrescribed = curr != null && curr.IsPrescribed, IsOtc = curr != null && curr.IsOtc, }); } } if (currentMedicationList.Any()) { model.CurrentMedications = new List <MedicareCurrentMedication>(); model.CurrentMedications = model.CurrentMedications.Concat(currentMedicationList); } } var raps = _rapsRepository.GetByCustomerId(customerId).ToArray(); if (raps.Any()) { model.Raps = raps.Select(Mapper.Map <Raps, MedicareRapsViewModel>); } var preApproved = _preApprovedTestRepository.GetByCustomerId(customerId).ToArray(); if (preApproved.Any()) { var testIds = preApproved.Select(x => x.TestId); model.PreapprovedTestList = _testRepository.GetAliasListByTestIdList(testIds); } return(model); }