private void DeactiveCustomerIcdCodes(long customerId)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var entity = new CustomerIcdCodeEntity()
                {
                    IsActive = false,
                    DateEnd  = DateTime.Now
                };

                var bucket = new RelationPredicateBucket(CustomerIcdCodeFields.CustomerId == customerId);
                bucket.PredicateExpression.AddWithAnd(CustomerIcdCodeFields.IsActive == true);

                adapter.UpdateEntitiesDirectly(entity, bucket);
            }
        }
Esempio n. 2
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);
        }