Exemplo n.º 1
0
        private void SavePcp(long customerId, string primaryCarePhysicianName, long updatorOrgRoleUserId, long eventCustomerId)
        {
            var pcp = _primaryCarePhysicianRepository.Get(customerId);

            if (!string.IsNullOrEmpty(primaryCarePhysicianName))
            {
                if (pcp == null)
                {
                    pcp = new PrimaryCarePhysician
                    {
                        CustomerId           = customerId,
                        Name                 = new Name(primaryCarePhysicianName),
                        DataRecorderMetaData =
                            new DataRecorderMetaData(updatorOrgRoleUserId, DateTime.Now, null)
                    };
                }
                else
                {
                    pcp.Name = new Name(primaryCarePhysicianName);
                }

                _primaryCarePhysicianRepository.Save(pcp);
                SaveCustomerHealthAnswer("Yes", customerId, eventCustomerId);
            }
            else if (pcp != null)
            {
                _primaryCarePhysicianRepository.Delete(pcp);
                SaveCustomerHealthAnswer("No", customerId, eventCustomerId);
            }
        }
Exemplo n.º 2
0
        public void UpdateCustomerPrimaryCarePhysician(PhysicianMaster physicianMaster, long stateId, long countryId)
        {
            var primaryCarePhysicians = _primaryCarePhysicianRepository.GetByPhysicianMasterId(physicianMaster.Id);

            if (primaryCarePhysicians != null && primaryCarePhysicians.Any())
            {
                foreach (var primaryCarePhysician in primaryCarePhysicians)
                {
                    primaryCarePhysician.Name    = new Name(physicianMaster.FirstName, physicianMaster.MiddleName, physicianMaster.LastName);
                    primaryCarePhysician.Primary = physicianMaster.PracticePhone;
                    primaryCarePhysician.Fax     = physicianMaster.PracticeFax;
                    primaryCarePhysician.DataRecorderMetaData.DataRecorderModifier = new OrganizationRoleUser(1);//TaazaaAdmin
                    primaryCarePhysician.DataRecorderMetaData.DateModified         = DateTime.Now;

                    primaryCarePhysician.Npi            = physicianMaster.Npi;
                    primaryCarePhysician.PrefixText     = physicianMaster.PrefixText;
                    primaryCarePhysician.SuffixText     = physicianMaster.SuffixText;
                    primaryCarePhysician.CredentialText = physicianMaster.CredentialText;

                    if (!string.IsNullOrEmpty(physicianMaster.PracticeAddress1) && !string.IsNullOrEmpty(physicianMaster.PracticeState) && !string.IsNullOrEmpty(physicianMaster.PracticeCity) && !string.IsNullOrEmpty(physicianMaster.PracticeZip))
                    {
                        long addressId = 0;
                        if (primaryCarePhysician.Address != null)
                        {
                            addressId = primaryCarePhysician.Address.Id;
                        }

                        primaryCarePhysician.Address = new Address(addressId)
                        {
                            StreetAddressLine1 = physicianMaster.PracticeAddress1,
                            StreetAddressLine2 = physicianMaster.PracticeAddress2,
                            City      = physicianMaster.PracticeCity,
                            StateId   = stateId,//physicianMaster.PracticeState,
                            ZipCode   = new ZipCode(physicianMaster.PracticeZip),
                            CountryId = countryId
                        };
                    }

                    _primaryCarePhysicianRepository.Save(primaryCarePhysician);
                }
            }
        }
        private void UpdateCustomerPrimaryCarePhysician(CorporateCustomerEditModel model, OrganizationRoleUser createdByOrgRoleUser, Customer customer, IEnumerable <EventCustomer> eventCustomers)
        {
            if (!string.IsNullOrEmpty(model.PcpFirstName) || !string.IsNullOrEmpty(model.PcpLastName))
            {
                var pcp = _primaryCarePhysicianRepository.Get(customer.CustomerId);

                var ispcpUpdated = pcp != null && IsPcpUpdated(pcp, model);

                pcp = ispcpUpdated ? null : pcp;

                if (pcp == null)
                {
                    pcp = new PrimaryCarePhysician
                    {
                        CustomerId           = customer.CustomerId,
                        DataRecorderMetaData = new DataRecorderMetaData(createdByOrgRoleUser.Id, DateTime.Now, null)
                    };
                }
                else
                {
                    pcp.DataRecorderMetaData.DataRecorderModifier = new OrganizationRoleUser(createdByOrgRoleUser.Id);
                    pcp.DataRecorderMetaData.DateModified         = DateTime.Now;
                }

                pcp.IsPcpAddressVerified = null;
                pcp.PcpAddressVerifiedBy = null;
                pcp.PcpAddressVerifiedOn = null;
                pcp.Source = (long)CustomerPcpUpdateSource.CorporateUpload;

                pcp.Name    = new Name(model.PcpFirstName, "", model.PcpLastName);
                pcp.Fax     = PhoneNumber.Create(PhoneNumber.ToNumber(model.PcpFax), PhoneNumberType.Unknown);
                pcp.Primary = PhoneNumber.Create(PhoneNumber.ToNumber(model.PcpPhone), PhoneNumberType.Office);
                if (!string.IsNullOrEmpty(model.PcpEmail))
                {
                    pcp.Email = new Email(model.PcpEmail);
                }

                pcp.Npi = model.PcpNpi;
                pcp.PhysicianMasterId = null;

                SetPcpPracticeAddress(pcp, model);
                SetPcpMailingAddress(pcp, model);

                if (IsPcpAddressSame(pcp))
                {
                    pcp.MailingAddress = null;
                }

                pcp.IsActive = true;

                pcp = _primaryCarePhysicianRepository.Save(pcp);

                if (pcp != null)
                {
                    model.CustomerAddressId   = customer.Address != null ? customer.Address.Id : 0;
                    model.PCPAddressId        = pcp.Address != null ? pcp.Address.Id : 0;
                    model.PCPMailingAddressId = pcp.MailingAddress != null ? pcp.MailingAddress.Id : 0;
                }

                if (ispcpUpdated)
                {
                    foreach (var eventCustomer in eventCustomers)
                    {
                        _eventCustomerPrimaryCarePhysicianRepository.Save(new EventCustomerPrimaryCarePhysician
                        {
                            EventCustomerId        = eventCustomer.Id,
                            IsPcpAddressVerified   = false,
                            PcpAddressVerifiedBy   = createdByOrgRoleUser.Id,
                            PcpAddressVerifiedOn   = DateTime.Now,
                            PrimaryCarePhysicianId = pcp.Id
                        });
                    }
                }
            }
        }
Exemplo n.º 4
0
        public void SavePrimaryCarePhysician(PrimaryCarePhysicianEditModel pcpEditModel, long customerId, long orgRoleUserId = 0)
        {
            var pcp = _primaryCarePhysicianRepository.Get(customerId);

            if (pcp == null && pcpEditModel == null)
            {
                return;
            }

            if (pcp != null && pcpEditModel == null)
            {
                _primaryCarePhysicianRepository.DecativatePhysician(customerId, orgRoleUserId > 0 ? orgRoleUserId : customerId);
            }
            else
            {
                if (pcp == null)
                {
                    pcp = new PrimaryCarePhysician
                    {
                        Name                 = pcpEditModel.FullName,
                        Primary              = !string.IsNullOrEmpty(pcpEditModel.Phone) ? PhoneNumber.Create(pcpEditModel.Phone, PhoneNumberType.Unknown) : pcpEditModel.PhoneNumber,
                        Email                = string.IsNullOrEmpty(pcpEditModel.Email) ? new Email(string.Empty, string.Empty) : new Email(pcpEditModel.Email),
                        CustomerId           = customerId,
                        DataRecorderMetaData = new DataRecorderMetaData(orgRoleUserId > 0 ? orgRoleUserId : customerId, DateTime.Now, null)
                    };
                }
                else
                {
                    pcp.Name    = pcpEditModel.FullName;
                    pcp.Primary = !string.IsNullOrEmpty(pcpEditModel.Phone) ? PhoneNumber.Create(pcpEditModel.Phone, PhoneNumberType.Unknown) : pcpEditModel.PhoneNumber;
                    pcp.Email   = string.IsNullOrEmpty(pcpEditModel.Email) ? new Email(string.Empty, string.Empty) : new Email(pcpEditModel.Email);
                    pcp.DataRecorderMetaData.DataRecorderModifier = new OrganizationRoleUser(orgRoleUserId > 0 ? orgRoleUserId : customerId);
                    pcp.DataRecorderMetaData.DateModified         = DateTime.Now;
                }

                if (pcpEditModel.Address != null && !pcpEditModel.Address.IsEmpty())
                {
                    long addressId = 0;
                    if (pcp.Address != null)
                    {
                        addressId = pcp.Address.Id;
                    }
                    pcp.Address    = Mapper.Map <AddressEditModel, Address>(pcpEditModel.Address);
                    pcp.Address.Id = addressId;
                }
                else
                {
                    pcp.Address = null;
                }

                if (pcpEditModel.MailingAddress != null && !pcpEditModel.MailingAddress.IsEmpty() && !IsAddressSame(pcpEditModel))
                {
                    long addressId = 0;
                    if (pcp.MailingAddress != null && pcp.Address != null && pcp.MailingAddress.Id != pcp.Address.Id)
                    {
                        addressId = pcp.MailingAddress.Id;
                    }

                    pcp.MailingAddress    = Mapper.Map <AddressEditModel, Address>(pcpEditModel.MailingAddress);
                    pcp.MailingAddress.Id = addressId;
                }
                else
                {
                    pcp.MailingAddress = null;
                }

                _primaryCarePhysicianRepository.Save(pcp);
            }
        }