Пример #1
0
        public bool AddPcpProductShipping(long customerId, long eventId)
        {
            var pcp = _primaryCarePhysicianRepository.Get(customerId);

            if (pcp == null || pcp.Address == null)
            {
                return(false);
            }

            var shippingOption = _shippingOptionRepository.GetShippingOptionByProductId((long)Product.UltraSoundImages);

            if (shippingOption == null)
            {
                return(false);
            }

            var order = _orderRepository.GetOrder(customerId, eventId);

            //added As Admin User Role
            var organizationRoleUser = new OrganizationRoleUser {
                Id = customerId
            };

            AddProduct(customerId, order, organizationRoleUser);

            AddPcpShipping(order, shippingOption, pcp, organizationRoleUser);

            return(true);
        }
Пример #2
0
        private void SaveProductShippingDetail(long productId, Order order, Address shippingAddress, long customerId)
        {
            var shippingOption = _shippingOptionRepository.GetShippingOptionByProductId(productId);

            if (shippingOption == null)
            {
                return;
            }

            OrderDetail orderDetail           = _orderController.GetActiveOrderDetail(order);
            var         productShippingDetail = new ShippingDetail
            {
                ShippingOption       = shippingOption,
                ActualPrice          = shippingOption.Price,
                Status               = ShipmentStatus.Processing,
                ShippingAddress      = shippingAddress,
                DataRecorderMetaData = new DataRecorderMetaData(customerId, DateTime.Now, null)
            };

            if (orderDetail != null)
            {
                productShippingDetail = _shippingController.OrderShipping(productShippingDetail);

                var shippingDetailOrderDetail = new ShippingDetailOrderDetail
                {
                    Amount           = productShippingDetail.ActualPrice,
                    IsActive         = true,
                    OrderDetailId    = orderDetail.Id,
                    ShippingDetailId = productShippingDetail.Id
                };

                _shipingDetailOrderDetailRepository.Save(shippingDetailOrderDetail);
            }
        }
        public ListModelBase <PcpSummaryLogReportModel, PcpSummaryLogReportModelFilter> GetPcpSummaryLogReport(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            var shippingOption = _shippingOptionRepository.GetShippingOptionByProductId((long)Product.UltraSoundImages, true);

            var shippingDetails = _shippingDetailRepository.GetEventCustomerShippingDetailForFilter(pageNumber, pageSize, filter as PcpSummaryLogReportModelFilter, new[] { shippingOption.Id }, out totalRecords);

            if (shippingDetails.IsNullOrEmpty())
            {
                return(null);
            }

            var shippingDetailIdEventCustomerIdPairs = _shippingDetailRepository.GetShippingDetailIdEventCustomerIdPairs(shippingDetails.Select(sd => sd.Id).ToArray());

            var eventCustomers = _eventCustomerRepository.GetByIds(shippingDetailIdEventCustomerIdPairs.Select(sdec => sdec.SecondValue).ToArray());

            var customerIds = eventCustomers.Select(ec => ec.CustomerId).Distinct().ToArray();

            var customers = _customerRepository.GetCustomers(customerIds);

            var primaryCarePhysicians = _primaryCarePhysicianRepository.GetByCustomerIds(customerIds);

            var eventids = eventCustomers.Select(e => e.EventId).Distinct().ToArray();

            var eventCollection = ((IUniqueItemRepository <Event>)_eventRepository).GetByIds(eventids);

            return(_pcpSummaryLogReportListModelFactory.Create(shippingDetails, shippingDetailIdEventCustomerIdPairs, eventCustomers, customers, primaryCarePhysicians, eventCollection));
        }
Пример #4
0
        public IEnumerable <OrderedPair <long, ShipmentStatus> > GetCdImageShippingStatusfortheEventCustomers(long[] eventCustomerIds)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(adapter);

                var queryOrders = from ecod in linqMetaData.EventCustomerOrderDetail
                                  join od in linqMetaData.OrderDetail on ecod.OrderDetailId equals od.OrderDetailId
                                  where ecod.IsActive && eventCustomerIds.Contains(ecod.EventCustomerId)
                                  select new { ecod.EventCustomerId, od.OrderId };

                var queryOrderswithProduct = (from qo in queryOrders
                                              join od in linqMetaData.OrderDetail on qo.OrderId equals od.OrderId
                                              join poi in linqMetaData.ProductOrderItem on od.OrderItemId equals poi.OrderItemId
                                              where od.Status == (int)OrderStatusState.FinalSuccess &&
                                              poi.ProductId == (long)Product.UltraSoundImages
                                              select new { qo.EventCustomerId, qo.OrderId }).ToArray();

                var orderIds = queryOrderswithProduct.Select(q => q.OrderId).ToArray();

                var cdShippingOption = _shippingOptionRepository.GetShippingOptionByProductId((long)Product.UltraSoundImages);

                var orderAndShippingStatusPairs = (from od in linqMetaData.OrderDetail
                                                   join sdod in linqMetaData.ShippingDetailOrderDetail on od.OrderDetailId equals sdod.OrderDetailId
                                                   join sd in linqMetaData.ShippingDetail on sdod.ShippingDetailId equals sd.ShippingDetailId
                                                   where orderIds.Contains(od.OrderId) && sdod.IsActive &&
                                                   od.Status == (int)OrderStatusState.FinalSuccess && sd.Status.HasValue &&
                                                   (cdShippingOption != null ? sd.ShippingOptionId == cdShippingOption.Id : true)
                                                   select new OrderedPair <long, ShipmentStatus>(od.OrderId, (ShipmentStatus)sd.Status.Value)).Distinct().ToArray();

                return((from qo in queryOrderswithProduct
                        join od in orderAndShippingStatusPairs on qo.OrderId equals od.FirstValue
                        select new OrderedPair <long, ShipmentStatus>(qo.EventCustomerId, od.SecondValue)).ToArray());
            }
        }
Пример #5
0
        private void SaveProductShipping(OrderDetail productDetail, OrderDetail activeOrderDetail, bool isExclusivelyRequested)
        {
            if (productDetail == null || activeOrderDetail == null)
            {
                return;
            }
            var shippingOption = _shippingOptionRepository.GetShippingOptionByProductId(productDetail.OrderItem.ItemId);

            if (shippingOption != null)
            {
                var resultShippingDetails = _shippingDetailRepository.GetShippingDetailsForCancellation(activeOrderDetail.Id);
                var cdShippingDetails     = _shippingDetailRepository.GetProductShippingDetailsForCancellation(activeOrderDetail.Id);

                if (!resultShippingDetails.IsNullOrEmpty() && (cdShippingDetails == null || (cdShippingDetails.Count() < resultShippingDetails.Count())))
                {
                    var address = _addressRepository.GetAddress(resultShippingDetails.First().ShippingAddress.Id);
                    address.Id = 0;
                    var productShippingDetail = new ShippingDetail
                    {
                        ShippingAddress = address,
                        Status          = ShipmentStatus.Processing,
                        ActualPrice     = shippingOption.Price,
                        ShippingOption  = new ShippingOption {
                            Id = shippingOption.Id
                        },
                        IsExclusivelyRequested = isExclusivelyRequested,
                        DataRecorderMetaData   = new DataRecorderMetaData
                        {
                            DataRecorderCreator = _organizationRoleUserRepository.GetOrganizationRoleUser(_sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId),
                            DateCreated         = DateTime.Now,
                            DateModified        = DateTime.Now
                        }
                    };
                    IShippingController shippingController = new ShippingController();
                    productShippingDetail = shippingController.OrderShipping(productShippingDetail);

                    IRepository <ShippingDetailOrderDetail> shippingDetailOrderDetailRepository = new ShippingDetailOrderDetailRepository();

                    var shippingDetailOrderDetail = new ShippingDetailOrderDetail
                    {
                        Amount           = productShippingDetail.ActualPrice,
                        IsActive         = true,
                        OrderDetailId    = activeOrderDetail.Id,
                        ShippingDetailId = productShippingDetail.Id
                    };

                    shippingDetailOrderDetailRepository.Save(shippingDetailOrderDetail);
                }
            }
        }
        public ListModelBase <DailyPatientRecapModel, DailyPatientRecapModelFilter> GetDailyPatientReapModel(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            var eventCustomers = _eventCustomerRepository.GetEventsCustomersForDailyPatientRecap(pageNumber, pageSize, filter as DailyPatientRecapModelFilter, out totalRecords);

            if (eventCustomers.IsNullOrEmpty())
            {
                return(null);
            }

            var eventIds       = eventCustomers.Select(x => x.EventId).Distinct();
            var appointmentids = eventCustomers.Where(ec => ec.AppointmentId.HasValue).Select(ec => ec.AppointmentId.Value).ToList();

            var events = _eventRepository.GetEventswithPodbyIds(eventIds);

            var pods      = _podRepository.GetPodsForEvents(eventIds);
            var eventPods = _eventPodRepository.GetByEventIds(eventIds);


            var customerIds = eventCustomers.Select(x => x.CustomerId).Distinct().ToArray();
            var customers   = _customerRepository.GetCustomers(customerIds);

            var eventCustomerIds = eventCustomers.Select(x => x.Id).ToArray();

            var orders = _orderRepository.GetAllOrdersByEventCustomerIds(eventCustomerIds, true);

            var orderPackageIdNamePair = _eventPackageRepository.GetPackageNamesForOrder(orders.Select(o => o.Id).ToList());
            //var orderTestIdNamePair = _eventTestRepository.GetTestNamesForOrders(orders.Select(o => o.Id).ToList());

            var orderIdEventPackageTestIdPairs             = _eventPackageRepository.GetOrderIdEventPackageTestIdPairsForOrder(orders.Select(o => o.Id).ToArray());
            var orderIdTestIdPairs                         = _eventTestRepository.GetOrderIdTestIdPairsForOrders(orders.Select(o => o.Id).ToArray());
            var testNotPerformedEventCustomerIdTestIdPairs = _testNotPerformedRepository.GetEventCusromerResultIdTestIdPairs(eventCustomerIds);

            var testIds = orderIdEventPackageTestIdPairs.Select(op => op.SecondValue).Distinct().ToList();

            testIds.AddRange(orderIdTestIdPairs.Select(op => op.SecondValue).Distinct().ToArray());
            var tests = _testRepository.GetTestNameValuePair(testIds);


            var shippingDetailIds = orders.SelectMany(o => o.OrderDetails.SelectMany(od => od.ShippingDetailOrderDetails.Select(sdod => sdod.ShippingDetailId))).ToArray();
            var shippingDetails   = _shippingDetailRepository.GetByIds(shippingDetailIds);

            var cdShippingOption = _shippingOptionRepository.GetShippingOptionByProductId((long)Product.UltraSoundImages);


            var eventHospitalPartners = _hospitalPartnerRepository.GetEventHospitalPartnersByEventIds(eventIds).ToArray();

            var organizationIds     = eventHospitalPartners.Select(ehp => ehp.HospitalPartnerId).Distinct().ToArray();
            var hospitalFacilityIds = eventCustomers.Where(ec => ec.HospitalFacilityId.HasValue && ec.HospitalFacilityId.Value > 0).Select(ec => ec.HospitalFacilityId.Value).ToArray();

            organizationIds = organizationIds.Concat(hospitalFacilityIds).ToArray();

            var organizations = _organizationRepository.GetOrganizations(organizationIds);
            var eventIdHospitalPartnerNamePairs = (from ehp in eventHospitalPartners
                                                   join org in organizations on ehp.HospitalPartnerId equals org.Id
                                                   select new OrderedPair <long, string>(ehp.EventId, org.Name)).ToArray();

            var eventIdCorporateAccounrNamePairs = _corporateAccountRepository.GetEventIdCorporateAccountNamePair(eventIds);

            var appointments = _appointmentRepository.GetByIds(appointmentids);

            return(_dailyPatientRecapListModelFactory.CreateListModel(eventCustomers, customers, orders, shippingDetails, cdShippingOption, eventIdHospitalPartnerNamePairs, eventIdCorporateAccounrNamePairs, appointments,
                                                                      pods, eventPods, events, orderIdEventPackageTestIdPairs, orderIdTestIdPairs, testNotPerformedEventCustomerIdTestIdPairs, tests, orderPackageIdNamePair));
        }
Пример #7
0
        public ListModelBase <HourlyAppointmentBookedModel, HourlyAppointmentsBookedListModelFilter> GetHourlyAppointmentsBooked(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            var customFilter = filter as HourlyAppointmentsBookedListModelFilter;

            customFilter = customFilter ?? new HourlyAppointmentsBookedListModelFilter();

            var appFilter = new AppointmentsBookedListModelFilter
            {
                AccountId = customFilter.AccountId,
                FromDate  = customFilter.FromDate,
                ToDate    = customFilter.ToDate,
                ShowCustomersWithAppointment = customFilter.ShowCustomersWithAppointment,
                IsHealthPlanEvent            = true
            };

            var eventCustomers = _eventCustomerRepository.GetEventCustomersbyRegisterationDate(pageNumber, pageSize, appFilter, out totalRecords);

            if (eventCustomers.IsNullOrEmpty())
            {
                return(null);
            }

            var appointments = _appointmentRepository.GetByIds(eventCustomers.Where(ec => ec.AppointmentId.HasValue).Select(ec => ec.AppointmentId.Value).ToList());
            var eventIds     = eventCustomers.Select(ec => ec.EventId).Distinct().ToArray();
            var model        = _eventReportingService.GetEventVolumeModel(eventCustomers.Select(ec => ec.EventId).Distinct().ToArray());

            var customers             = _customerRepository.GetCustomers(eventCustomers.Select(ec => ec.CustomerId).Distinct().ToArray());
            var customerIds           = customers.Select(x => x.CustomerId);
            var orders                = _orderRepository.GetAllOrdersByEventCustomerIds(eventCustomers.Select(ec => ec.Id).ToArray(), true);
            var customerEligibilities = _customerEligibilityRepository.GetCustomerEligibilityByCustomerIdsAndYear(customerIds, DateTime.Today.Year);

            if (customerEligibilities.IsNullOrEmpty())
            {
                customerEligibilities = new List <CustomerEligibility>();
            }

            var eventPackages = _eventPackageRepository.GetbyEventIds(eventIds);
            var eventTests    = _eventTestRepository.GetByEventIds(eventIds);

            var sourceCodes = _sourceCodeRepository.GetSourceCodeByIds(orders.SelectMany(o => o.OrderDetails.Where(od => od.SourceCodeOrderDetail != null && od.SourceCodeOrderDetail.IsActive)
                                                                                         .Select(od => od.SourceCodeOrderDetail.SourceCodeId)).Distinct().ToArray());

            var orgRoleUserIds = eventCustomers.Where(ec => ec.DataRecorderMetaData != null && ec.DataRecorderMetaData.DataRecorderCreator != null).Select(ec => ec.DataRecorderMetaData.DataRecorderCreator.Id).ToList();

            var eventAppointmentChangeLogs = _eventAppointmentChangeLogRepository.GetByEventCustomerIds(eventCustomers.Select(ec => ec.Id).ToArray()).ToArray();

            orgRoleUserIds.AddRange(eventAppointmentChangeLogs.Select(eacl => eacl.CreatedByOrgRoleUserId));

            var registeredbyAgent = _organizationRoleUserRepository.GetOrganizationRoleUsers(orgRoleUserIds);

            var roles = _roleRepository.GetAll();

            var registeredbyAgentNameIdPair = _organizationRoleUserRepository.GetNameIdPairofUsers(orgRoleUserIds.ToArray()).ToArray();

            var callDetails = _callCenterCallRepository.GetCallDetails(customers);

            var shippingDetailIds = orders.SelectMany(o => o.OrderDetails.SelectMany(od => od.ShippingDetailOrderDetails.Select(sdod => sdod.ShippingDetailId))).ToArray();
            var shippingDetails   = _shippingDetailRepository.GetByIds(shippingDetailIds);
            var cdShippingOption  = _shippingOptionRepository.GetShippingOptionByProductId((long)Product.UltraSoundImages);
            var shippingOptions   = _shippingOptionRepository.GetAllShippingOptions();

            var customTags = _customTagRepository.GetByCustomerIds(customerIds);

            var tagNames               = customers.Where(x => !string.IsNullOrEmpty(x.Tag)).Select(x => x.Tag).ToArray();
            var corporateAccount       = _corporateAccountRepository.GetByTags(tagNames);
            var corporateAccountIds    = corporateAccount.Select(x => x.Id).ToArray();
            var accountAdditionalField = _accountAdditionalFieldRepository.GetAccountAdditionalFieldsByAccountIds(corporateAccountIds);

            var primaryCarePhysicians = _primaryCarePhysicianRepository.GetByCustomerIds(eventCustomers.Select(ec => ec.CustomerId).Distinct().ToArray());
            var languages             = _languageRepository.GetAll();
            var pcpAppointments       = _pcpAppointmentRepository.GetByEventCustomerIds(eventCustomers.Select(ec => ec.Id).ToArray());

            return(_customAppointmentsBookedModelFactory.CreateHourlyModel(eventCustomers, appointments, orders, model, customers, registeredbyAgent, roles, registeredbyAgentNameIdPair, sourceCodes, callDetails,
                                                                           shippingDetails, cdShippingOption, shippingOptions, eventAppointmentChangeLogs, primaryCarePhysicians, eventPackages, eventTests, languages, customTags, corporateAccount,
                                                                           accountAdditionalField, pcpAppointments, customerEligibilities));
        }
Пример #8
0
        private HospitalPartnerCustomerListModel GetCustomers(IEnumerable <EventCustomer> eventCustomers, HospitalPartner hospitalPartner)
        {
            var eventCustomerIds = eventCustomers.Select(ec => ec.Id).ToArray();
            var eventIds         = eventCustomers.Select(ec => ec.EventId).Distinct().ToArray();

            var customers = _customerRepository.GetCustomers(eventCustomers.Select(ec => ec.CustomerId).ToArray());

            var orders = _orderRepository.GetAllOrdersByEventCustomerIds(eventCustomerIds, true);
            var orderPackageIdNamePair = _eventPackageRepository.GetPackageNamesForOrder(orders.Select(o => o.Id).ToList());
            var orderTestIdNamePair    = _eventTestRepository.GetTestNamesForOrders(orders.Select(o => o.Id).ToList());

            var hospitalPartnerCustomers = _hospitalPartnerCustomerRepository.GetHospitalPartnerCustomers(eventIds);

            var orgRoleUserIds = new List <long>();

            orgRoleUserIds.AddRange(hospitalPartnerCustomers.Select(hpc => hpc.CareCoordinatorOrgRoleUserId).ToArray());
            orgRoleUserIds.AddRange(hospitalPartnerCustomers.Select(hpc => hpc.DataRecorderMetaData.DataRecorderCreator.Id).ToArray());
            orgRoleUserIds.AddRange(hospitalPartnerCustomers.Where(hpc => hpc.DataRecorderMetaData.DataRecorderModifier != null).Select(hpc => hpc.DataRecorderMetaData.DataRecorderModifier.Id).ToArray());
            orgRoleUserIds = orgRoleUserIds.Select(oru => oru).Distinct().ToList();

            var idNamePairs = _organizationRoleUserRepository.GetNameIdPairofUsers(orgRoleUserIds.ToArray());

            var eventCustomerResults = _eventCustomerResultRepository.GetByIds(eventCustomerIds);

            eventCustomerResults = eventCustomerResults.Where(ecr => ecr.ResultState >= (long)TestResultStateNumber.Evaluated).ToArray();

            var pods = _podRepository.GetPodsForEvents(eventIds);

            var events            = _eventRepository.GetEventswithPodbyIds(eventIds);
            var shippingDetailIds = orders.SelectMany(o => o.OrderDetails.SelectMany(od => od.ShippingDetailOrderDetails.Select(sdod => sdod.ShippingDetailId))).ToArray();

            var resultStatuses = _eventCustomerResultRepository.GetTestResultStatus(eventCustomerIds);

            var shippingDetails  = _shippingDetailRepository.GetByIds(shippingDetailIds);
            var cdShippingOption = _shippingOptionRepository.GetShippingOptionByProductId((long)Product.UltraSoundImages);

            //var eventIdHospitalPartnerIdPairs = _hospitalPartnerRepository.GetEventAndHospitalPartnerOrderedPair(eventIds);

            var eventHospitalPartners = _hospitalPartnerRepository.GetEventHospitalPartnersByEventIds(eventIds).ToArray();

            var organizationIds     = eventHospitalPartners.Select(ehp => ehp.HospitalPartnerId).Distinct().ToArray();
            var hospitalFacilityIds = eventCustomers.Where(ec => ec.HospitalFacilityId.HasValue && ec.HospitalFacilityId.Value > 0).Select(ec => ec.HospitalFacilityId.Value).ToArray();

            organizationIds = organizationIds.Concat(hospitalFacilityIds).ToArray();

            var organizations = _organizationRepository.GetOrganizations(organizationIds);
            var eventIdHospitalPartnerNamePairs = (from ehp in eventHospitalPartners
                                                   join org in organizations on ehp.HospitalPartnerId equals org.Id
                                                   select new OrderedPair <long, string>(ehp.EventId, org.Name)).ToArray();

            var eventIdCorporateAccounrNamePairs = _corporateAccountRepository.GetEventIdCorporateAccountNamePair(eventIds);

            var primaryCarePhysicians = _primaryCarePhysicianRepository.GetByCustomerIds(eventCustomers.Select(ec => ec.CustomerId).ToArray());

            var healthAssessmentQuestions = _healthAssessmentRepository.GetAllQuestions();

            var healthAssessmentAnswers = _healthAssessmentRepository.GetByCustomerIds(eventCustomers.Select(ec => ec.CustomerId).ToArray());

            var notes = _customerCallNotesRepository.GetNotes(eventCustomers.Select(ec => ec.CustomerId).ToArray(), CustomerRegistrationNotesType.PostScreeningFollowUpNotes);

            var eventCustomerNotifications = _eventCustomerNotificationRepository.GetByEventCustomerIds(eventCustomerIds, NotificationTypeAlias.CannedMessageNotification);

            var hospitalFacilities = hospitalFacilityIds.Any() ? _hospitalFacilityRepository.GetByIds(hospitalFacilityIds) : null;

            var eventCustomerIdHospitalFacilityNamePairs = (from ec in eventCustomers
                                                            join org in organizations on ec.HospitalFacilityId equals org.Id
                                                            select new OrderedPair <long, string>(ec.Id, org.Name)).ToArray();

            var showScannedDocumentHospitalPartnerIds = _settings.ShowScannedDocumentHospitalPartnerIds;

            var languages = _languageRepository.GetAll();

            return(_hospitalPartnerCustomerViewModelFactory.Create(eventCustomers, orders, customers, orderPackageIdNamePair, orderTestIdNamePair, hospitalPartnerCustomers, idNamePairs, events, shippingDetails,
                                                                   resultStatuses, cdShippingOption, pods, eventIdHospitalPartnerNamePairs, eventIdCorporateAccounrNamePairs, primaryCarePhysicians,
                                                                   healthAssessmentQuestions, healthAssessmentAnswers, eventCustomerResults, hospitalPartner, notes, eventCustomerNotifications, eventHospitalPartners,
                                                                   eventCustomerIdHospitalFacilityNamePairs, hospitalFacilities, showScannedDocumentHospitalPartnerIds, languages));
        }