Ejemplo n.º 1
0
        public bool UpdateCustomerProfileHistory(long mergedCustomerId, long customerProfileHistoryId)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var customerProfileHistory = new CustomerProfileHistoryEntity {
                    MergedCustomerId = mergedCustomerId
                };
                var bucket = new RelationPredicateBucket(CustomerProfileHistoryFields.Id == customerProfileHistoryId);

                adapter.UpdateEntitiesDirectly(customerProfileHistory, bucket);
            }
            return(true);
        }
        public CustomerProfileHistoryEntity CustomerProfileHistoryEntity(CustomerProfileEntity customerProfileEntity, UserEntity userEntity, long createdBy, CustomerEligibility customerEligibility, CustomerWarmTransferEntity customerWarmTransfer, CustomerTargetedEntity customerTargeted)
        {
            var billingAddress = customerProfileEntity.BillingAddressId.HasValue ? _addressRepository.GetAddress(customerProfileEntity.BillingAddressId.Value) : null;
            var homeAddress    = _addressRepository.GetAddress(userEntity.HomeAddressId);

            var entity = new CustomerProfileHistoryEntity
            {
                IsNew = true,

                CustomerId                     = customerProfileEntity.CustomerId,
                FirstName                      = userEntity.FirstName,
                MiddleName                     = userEntity.MiddleName,
                LastName                       = userEntity.LastName,
                HomeAddress1                   = homeAddress.StreetAddressLine1,
                HomeAddress2                   = homeAddress.StreetAddressLine2,
                HomeCity                       = homeAddress.City,
                HomeState                      = homeAddress.State,
                HomeZipCode                    = homeAddress.ZipCode.Zip,
                HomeCountry                    = homeAddress.Country,
                PhoneOffice                    = userEntity.PhoneOffice,
                PhoneCell                      = userEntity.PhoneCell,
                PhoneHome                      = userEntity.PhoneHome,
                Email1                         = userEntity.Email1,
                Email2                         = userEntity.Email2,
                Picture                        = userEntity.Picture,
                Dob                            = userEntity.Dob,
                DefaultRoleId                  = userEntity.Role.RoleId,
                PhoneOfficeExtension           = userEntity.PhoneOfficeExtension,
                Ssn                            = userEntity.Ssn,
                DisplayId                      = customerProfileEntity.DisplayId,
                BillingAddress1                = billingAddress != null ? billingAddress.StreetAddressLine1 : string.Empty,
                BillingAddress2                = billingAddress != null ? billingAddress.StreetAddressLine2 : string.Empty,
                BillingCity                    = billingAddress != null ? billingAddress.City : string.Empty,
                BillingState                   = billingAddress != null ? billingAddress.State : string.Empty,
                BillingZipCode                 = billingAddress != null ? billingAddress.ZipCode.Zip : string.Empty,
                BillingCountry                 = billingAddress != null ? billingAddress.Country : string.Empty,
                Waist                          = customerProfileEntity.Waist,
                Height                         = customerProfileEntity.Height,
                Weight                         = customerProfileEntity.Weight,
                Gender                         = customerProfileEntity.Gender,
                Race                           = customerProfileEntity.Race,
                TrackingMarketingId            = customerProfileEntity.TrackingMarketingId,
                AddedByRoleId                  = customerProfileEntity.AddedByRoleId,
                Employer                       = customerProfileEntity.Employer,
                EmergencyContactName           = customerProfileEntity.EmergencyContactName,
                EmergencyContactRelationship   = customerProfileEntity.EmergencyContactRelationship,
                EmergencyContactPhoneNumber    = customerProfileEntity.EmergencyContactPhoneNumber,
                DoNotContactReasonId           = customerProfileEntity.DoNotContactReasonId,
                DoNotContactReasonNotesId      = customerProfileEntity.DoNotContactReasonNotesId,
                RequestNewsLetter              = customerProfileEntity.RequestNewsLetter,
                EmployeeId                     = customerProfileEntity.EmployeeId,
                InsuranceId                    = customerProfileEntity.InsuranceId,
                PreferredLanguage              = customerProfileEntity.PreferredLanguage,
                BestTimeToCall                 = customerProfileEntity.BestTimeToCall,
                Hicn                           = customerProfileEntity.Hicn,
                EnableTexting                  = customerProfileEntity.EnableTexting,
                MedicareAdvantageNumber        = customerProfileEntity.MedicareAdvantageNumber,
                Tag                            = customerProfileEntity.Tag,
                MedicareAdvantagePlanName      = customerProfileEntity.MedicareAdvantagePlanName,
                LanguageId                     = customerProfileEntity.LanguageId,
                LabId                          = customerProfileEntity.LabId,
                Copay                          = customerProfileEntity.Copay,
                Lpi                            = customerProfileEntity.Lpi,
                Market                         = customerProfileEntity.Market,
                Mrn                            = customerProfileEntity.Mrn,
                GroupName                      = customerProfileEntity.GroupName,
                IsIncorrectPhoneNumber         = customerProfileEntity.IsIncorrectPhoneNumber,
                IsLanguageBarrier              = customerProfileEntity.IsLanguageBarrier,
                DoNotContactTypeId             = customerProfileEntity.DoNotContactTypeId,
                EnableVoiceMail                = customerProfileEntity.EnableVoiceMail,
                AdditionalField1               = customerProfileEntity.AdditionalField1,
                AdditionalField2               = customerProfileEntity.AdditionalField2,
                AdditionalField3               = customerProfileEntity.AdditionalField3,
                AdditionalField4               = customerProfileEntity.AdditionalField4,
                ActivityId                     = customerProfileEntity.ActivityId,
                DoNotContactUpdateDate         = customerProfileEntity.DoNotContactUpdateDate,
                DateCreated                    = DateTime.Now,
                CreatedBy                      = createdBy,
                DoNotContactUpdateSource       = customerProfileEntity.DoNotContactUpdateSource,
                LanguageBarrierMarkedDate      = customerProfileEntity.LanguageBarrierMarkedDate,
                IncorrectPhoneNumberMarkedDate = customerProfileEntity.IncorrectPhoneNumberMarkedDate,
                IsSubscribed                   = customerProfileEntity.IsSubscribed,
                PreferredContactType           = customerProfileEntity.PreferredContactType,
                Mbi                            = customerProfileEntity.Mbi,
                PhoneHomeConsentId             = customerProfileEntity.PhoneHomeConsentId,
                PhoneCellConsentId             = customerProfileEntity.PhoneCellConsentId,
                PhoneOfficeConsentId           = customerProfileEntity.PhoneOfficeConsentId,
                PhoneHomeConsentUpdateDate     = customerProfileEntity.PhoneHomeConsentUpdateDate,
                PhoneCellConsentUpdateDate     = customerProfileEntity.PhoneCellConsentUpdateDate,
                PhoneOfficeConsentUpdateDate   = customerProfileEntity.PhoneOfficeConsentUpdateDate,
                AcesId                         = customerProfileEntity.AcesId,
                BillingMemberId                = customerProfileEntity.BillingMemberId,
                BillingMemberPlan              = customerProfileEntity.BillingMemberPlan,
                BillingMemberPlanYear          = customerProfileEntity.BillingMemberPlanYear,
                EnableEmail                    = customerProfileEntity.EnableEmail,
                EnableEmailUpdateDate          = customerProfileEntity.EnableEmailUpdateDate,
                MemberUploadSourceId           = customerProfileEntity.MemberUploadSourceId,
                ProductTypeId                  = customerProfileEntity.ProductTypeId,
                AcesClientId                   = customerProfileEntity.AcesClientId,
            };

            if (customerEligibility != null)
            {
                entity.IsEligble          = customerEligibility.IsEligible;
                entity.EligibilityForYear = customerEligibility.ForYear;
            }

            if (customerWarmTransfer != null)
            {
                entity.IsWarmTransfer   = customerWarmTransfer.IsWarmTransfer;
                entity.WarmTransferYear = customerWarmTransfer.WarmTransferYear;
            }

            if (customerTargeted != null)
            {
                entity.TargetedYear = customerTargeted.ForYear;
                entity.IsTargeted   = customerTargeted.IsTargated;
            }
            return(entity);
        }
Ejemplo n.º 3
0
        public bool MergeCustomer(long oldCustomerId, long newCustomerId, long orgRoleId)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var eventCustomer = new EventCustomersEntity {
                    CustomerId = newCustomerId
                };
                var eventCustomerBucket = new RelationPredicateBucket(EventCustomersFields.CustomerId == oldCustomerId);
                adapter.UpdateEntitiesDirectly(eventCustomer, eventCustomerBucket);

                eventCustomer = new EventCustomersEntity {
                    CreatedByOrgRoleUserId = newCustomerId
                };
                eventCustomerBucket = new RelationPredicateBucket(EventCustomersFields.CreatedByOrgRoleUserId == oldCustomerId);
                adapter.UpdateEntitiesDirectly(eventCustomer, eventCustomerBucket);

                var eventAppointment = new EventAppointmentEntity {
                    ScheduledByOrgRoleUserId = newCustomerId
                };
                var eventAppointmentBucket = new RelationPredicateBucket(EventAppointmentFields.ScheduledByOrgRoleUserId == oldCustomerId);
                adapter.UpdateEntitiesDirectly(eventAppointment, eventAppointmentBucket);

                var customerEventTestFinding = new CustomerEventTestFindingEntity {
                    CustomerId = newCustomerId
                };
                var customerEventTestBucket = new RelationPredicateBucket(CustomerEventTestFindingFields.CustomerId == oldCustomerId);
                adapter.UpdateEntitiesDirectly(customerEventTestFinding, customerEventTestBucket);

                var hospitalPartnerCustomer = new HospitalPartnerCustomerEntity {
                    CustomerId = newCustomerId
                };
                var hospitalPartnerCustomerBucket = new RelationPredicateBucket(HospitalPartnerCustomerFields.CustomerId == oldCustomerId);
                adapter.UpdateEntitiesDirectly(hospitalPartnerCustomer, hospitalPartnerCustomerBucket);

                var customerPrimaryCarePhysician = new CustomerPrimaryCarePhysicianEntity
                {
                    CustomerId   = newCustomerId,
                    IsActive     = false,
                    DateModified = DateTime.Now,
                    UpdatedByOrganizationRoleUserId = orgRoleId
                };

                var customerPrimaryCarePhysicianBucket = new RelationPredicateBucket(CustomerPrimaryCarePhysicianFields.CustomerId == oldCustomerId);
                adapter.UpdateEntitiesDirectly(customerPrimaryCarePhysician, customerPrimaryCarePhysicianBucket);

                var preApprovedTest = new PreApprovedTestEntity
                {
                    CustomerId = newCustomerId,
                    IsActive   = false,
                    DateEnd    = DateTime.Now
                };

                var preApprovedTestBucket = new RelationPredicateBucket(PreApprovedTestFields.CustomerId == oldCustomerId);
                adapter.UpdateEntitiesDirectly(preApprovedTest, preApprovedTestBucket);

                var preApprovedPackage = new PreApprovedPackageEntity
                {
                    CustomerId = newCustomerId,
                    IsActive   = false,
                    DateEnd    = DateTime.Now
                };

                var preApprovedPackageBucket = new RelationPredicateBucket(PreApprovedPackageFields.CustomerId == oldCustomerId);
                adapter.UpdateEntitiesDirectly(preApprovedPackage, preApprovedPackageBucket);

                var customerIcdCode = new CustomerIcdCodeEntity
                {
                    CustomerId = newCustomerId,
                    IsActive   = false,
                    DateEnd    = DateTime.Now
                };

                var customerIcdCodeBucket = new RelationPredicateBucket(CustomerIcdCodeFields.CustomerId == oldCustomerId);
                adapter.UpdateEntitiesDirectly(customerIcdCode, customerIcdCodeBucket);

                var currentMedication = new CurrentMedicationEntity
                {
                    CustomerId = newCustomerId,
                    IsActive   = false,
                    DateEnd    = DateTime.Now
                };

                var currentMedicationBucket = new RelationPredicateBucket(CurrentMedicationFields.CustomerId == oldCustomerId);
                adapter.UpdateEntitiesDirectly(currentMedication, currentMedicationBucket);

                var chaseOutbound = new ChaseOutboundEntity
                {
                    CustomerId = newCustomerId,
                    IsActive   = false,
                    EndDate    = DateTime.Now
                };

                var chaseOutboundBucket = new RelationPredicateBucket(ChaseOutboundFields.CustomerId == oldCustomerId);
                adapter.UpdateEntitiesDirectly(chaseOutbound, chaseOutboundBucket);


                var customerChaseCampaign = new CustomerChaseCampaignEntity
                {
                    CustomerId = newCustomerId,
                    IsActive   = false
                };

                var customerChaseCampaignBucket = new RelationPredicateBucket(CustomerChaseCampaignFields.CustomerId == oldCustomerId);
                adapter.UpdateEntitiesDirectly(customerChaseCampaign, customerChaseCampaignBucket);

                var customerChaseChannel = new CustomerChaseChannelEntity
                {
                    CustomerId = newCustomerId
                };

                var customerChaseChannelBucket = new RelationPredicateBucket(CustomerChaseChannelFields.CustomerId == oldCustomerId);
                adapter.UpdateEntitiesDirectly(customerChaseChannel, customerChaseChannelBucket);


                var customerChaseProduct = new CustomerChaseProductEntity
                {
                    CustomerId = newCustomerId
                };

                var customerChaseProductBucket = new RelationPredicateBucket(CustomerChaseProductFields.CustomerId == oldCustomerId);
                adapter.UpdateEntitiesDirectly(customerChaseProduct, customerChaseProductBucket);


                var orderDetail = new OrderDetailEntity
                {
                    ForOrganizationRoleUserId = newCustomerId
                };

                var orderDetailBucket = new RelationPredicateBucket(OrderDetailFields.ForOrganizationRoleUserId == oldCustomerId);
                adapter.UpdateEntitiesDirectly(orderDetail, orderDetailBucket);

                var order = new OrderEntity
                {
                    OrganizationRoleUserCreatorId = newCustomerId
                };

                var orderBucket = new RelationPredicateBucket(OrderFields.OrganizationRoleUserCreatorId == oldCustomerId);
                adapter.UpdateEntitiesDirectly(order, orderBucket);

                var eventCustomerResult = new EventCustomerResultEntity
                {
                    CustomerId = newCustomerId
                };

                var eventCustomerResultBucket = new RelationPredicateBucket(EventCustomerResultFields.CustomerId == oldCustomerId);
                adapter.UpdateEntitiesDirectly(eventCustomerResult, eventCustomerResultBucket);

                var eventCustomerResultHistory = new EventCustomerResultHistoryEntity
                {
                    CustomerId = newCustomerId
                };

                var eventCustomerResultHistoryBucket = new RelationPredicateBucket(EventCustomerResultHistoryFields.CustomerId == oldCustomerId);
                adapter.UpdateEntitiesDirectly(eventCustomerResultHistory, eventCustomerResultHistoryBucket);

                var resultArchiveUploadLog = new ResultArchiveUploadLogEntity
                {
                    CustomerId = newCustomerId
                };

                var resultArchiveUploadLogBucket = new RelationPredicateBucket(ResultArchiveUploadLogFields.CustomerId == oldCustomerId);
                adapter.UpdateEntitiesDirectly(resultArchiveUploadLog, resultArchiveUploadLogBucket);

                var customerHealthInfo = new CustomerHealthInfoEntity
                {
                    CustomerId = newCustomerId
                };

                var customerHealthInfoBucket = new RelationPredicateBucket(CustomerHealthInfoFields.CustomerId == oldCustomerId);
                adapter.UpdateEntitiesDirectly(customerHealthInfo, customerHealthInfoBucket);

                var customerHealthInfoArchive = new CustomerHealthInfoArchiveEntity
                {
                    CustomerId = newCustomerId
                };

                var customerHealthInfoArchiveBucket = new RelationPredicateBucket(CustomerHealthInfoArchiveFields.CustomerId == oldCustomerId);
                adapter.UpdateEntitiesDirectly(customerHealthInfoArchive, customerHealthInfoArchiveBucket);

                var customerTag = new CustomerTagEntity
                {
                    CustomerId = newCustomerId
                };

                var customerTagBucket = new RelationPredicateBucket(CustomerTagFields.CustomerId == oldCustomerId);
                adapter.UpdateEntitiesDirectly(customerTag, customerTagBucket);

                var customerRegistrationNotes = new CustomerRegistrationNotesEntity
                {
                    CustomerId = newCustomerId
                };

                var customerRegistrationNotesBucket = new RelationPredicateBucket(CustomerRegistrationNotesFields.CustomerId == oldCustomerId);
                adapter.UpdateEntitiesDirectly(customerRegistrationNotes, customerRegistrationNotesBucket);

                var directMail = new DirectMailEntity
                {
                    CustomerId = newCustomerId
                };

                var directMailBucket = new RelationPredicateBucket(DirectMailFields.CustomerId == oldCustomerId);
                adapter.UpdateEntitiesDirectly(directMail, directMailBucket);

                var calls = new CallsEntity
                {
                    CalledCustomerId = newCustomerId
                };

                var callsBucket = new RelationPredicateBucket(CallsFields.CalledCustomerId == oldCustomerId);
                adapter.UpdateEntitiesDirectly(calls, callsBucket);

                var callQueueCustomer = new CallQueueCustomerEntity
                {
                    CustomerId = newCustomerId,
                    Status     = (int)CallQueueStatus.Removed
                };

                var callQueueCustomerBucket = new RelationPredicateBucket(CallQueueCustomerFields.CustomerId == oldCustomerId);
                adapter.UpdateEntitiesDirectly(callQueueCustomer, callQueueCustomerBucket);

                var customerHistory = new CustomerProfileHistoryEntity()
                {
                    CustomerId = newCustomerId
                };
                var customerHistoryBucket = new RelationPredicateBucket(CustomerProfileHistoryFields.CustomerId == oldCustomerId);

                adapter.UpdateEntitiesDirectly(customerHistory, customerHistoryBucket);

                var preQualificationResult = new PreQualificationResultEntity {
                    CustomerId = newCustomerId
                };
                var preQualificationResultBucket = new RelationPredicateBucket(PreQualificationResultFields.CustomerId == oldCustomerId);

                adapter.UpdateEntitiesDirectly(preQualificationResult, preQualificationResultBucket);

                var customerCallQueueCallAttempt = new CustomerCallQueueCallAttemptEntity {
                    CustomerId = newCustomerId
                };
                var customerCallQueueCallAttemptBucket = new RelationPredicateBucket(CustomerCallQueueCallAttemptFields.CustomerId == oldCustomerId);

                adapter.UpdateEntitiesDirectly(customerCallQueueCallAttempt, customerCallQueueCallAttemptBucket);
            }

            return(true);
        }