Exemplo n.º 1
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);
                }
            }
        }