Esempio n. 1
0
        protected void Page_Init(object sender, EventArgs e)
        {
            long providerUserId = long.Parse(Request.QueryString["provider-user-id"]);

            if(providerUserId <= 0)
            {
                ProviderUser = new ProviderUser();
                UserProfile = new UserProfile();
                Contact = new Contact();
                Address = new Lib.Data.Address();
                User = new Framework.Security.User();

                Account = new Account
                {
                    ExpiresOn = DateTime.Now
                };
            }
            else
            {
                ProviderUser = new ProviderUser(providerUserId);
                UserProfile = ProviderUser.Profile;
                User = UserProfile.User;
                Contact = UserProfile.PrimaryContact;
                Address = UserProfile.PrimaryAddress;
                Account = GetAccountByUserProfile(UserProfile);
            }
        }
Esempio n. 2
0
        protected void Page_Init(object sender, EventArgs e)
        {
            long providerUserId = long.Parse(Request.QueryString["provider-user-id"]);
            long organizationId = long.Parse(Request.QueryString["organization-id"]);

            Organization = _orgSvc.Get(organizationId);

            if(providerUserId <= 0)
            {
                ProviderUser = new ProviderUser();
                UserProfile = new UserProfile();
                Contact = new Contact();
                Address = new Address();
                User = new Framework.Security.User();
            }
            else
            {
                ProviderUser = new ProviderUser(providerUserId);
                UserProfile = ProviderUser.Profile;
                User = UserProfile.User;
                Contact = UserProfile.PrimaryContact;
                Address = UserProfile.PrimaryAddress;
            }
        }
Esempio n. 3
0
        public static ReturnObject Update(HttpContext context, long id, long facility_id, string agree_to_terms, string new_password, string confirm_password, string watched_video, 
            string prescriber_type, long prescriber_speciality, string npi,
            string first_name, string last_name, string title, string email, string phone, string fax,
            string street_1, string city, string state, long issuer, string zip, string country,
            string prefix = null, string postfix = null, string street_2 = null, string state_id = null)
        {
            // load the profile we're finishing
            PrescriberProfile profile = new PrescriberProfile(id);

            // save the contact
            Contact contact = new Contact()
            {
                Prefix = prefix,
                FirstName = first_name,
                LastName = last_name,
                Postfix = postfix,
                Email = email,
                Phone = phone,
                Fax = fax,
                Title = title
            };
            contact.Save();

            // save the address
            Address address = new Address()
            {
                Street1 = street_1,
                Street2 = street_2,
                City = city,
                State = state,
                Country = country,
                Zip = zip
            };
            address.Save();

            profile.PrimaryFacilityID = facility_id;

            // get the prescriber type
            PrescriberType type = PrescriberType.FindByDisplayName(prescriber_type);

            if(type != null)
                profile.PrescriberTypeID = type.ID;

            profile.Save();

            // see if the prescriber is already in the system
            Lib.Data.Prescriber prescriber = Lib.Data.Prescriber.FindByStateId(issuer, state_id);

            if(prescriber != null)
            {
                // tie the new profile to the existing prescriber
                profile.PrescriberID = prescriber.ID;
                profile.Save();

                // login the existing user so they don't get bounced to the login page.
                Framework.Security.Manager.Login(prescriber.Profile.User);

                return new ReturnObject
                {
                    Result = null,
                    Redirect = new ReturnRedirectObject
                    {
                        //Hash = "dashboard"
                        Url = "Default.aspx#dashboard"
                    },
                    Growl = new ReturnGrowlObject
                    {
                        Type = "default",
                        Vars = new ReturnGrowlVarsObject
                        {
                            text = "The profile has been attached to your account.",
                            title = "Profile Updated"
                        }
                    }
                };
            }

            // create the new prescriber
            String error;
            User user = Framework.Security.Manager.CreateUser(contact.FirstName.Substring(0,1)+contact.LastName, new_password, email, out error);
            user.Save();

            Group g1 = new Group(2);
            Group g2 = new Group(3);

            user.AddGroup(g1);
            user.AddGroup(g2);

            UserProfile userProfile = new UserProfile()
            {
                PrimaryAddressID = address.ID,
                PrimaryContactID = contact.ID,
                Created = DateTime.Now,
                UserID = user.ID ?? 0,
                UserTypeID = 3
            };
            userProfile.Save();

            prescriber = new Data.Prescriber
            {
                NpiId = npi,
                StateId = state_id,
                StateIdIssuer = issuer,
                ProfileID = userProfile.ID,
                SpecialityID = prescriber_speciality == 0 ? (long?)null : prescriber_speciality
            };
            prescriber.Save();

            // set the prescriber id
            profile.PrescriberID = prescriber.ID;
            profile.Save();

            // setup the default user peferences
            UserPreferences prefs = new UserPreferences
            {
                UserId = user.ID ?? 0,
                EmailNotifications = true
            };
            prefs.Save();

            Framework.Security.Manager.Login(user);

            //prescriber.

            return Success(
                "Profile Updated",
                "Your profile has been updated.",
                null,
                "Locked.aspx#prescriber/wizards/etasu-selections");
        }
Esempio n. 4
0
        public static ReturnObject Edit( HttpContext context, long provider_id, long profile_id, string first_name, string last_name, string email, string phone, 
            string street_1, string city, string state, string zip, string npi, string state_id, long issuer, long speciality, long prescriber_type, string username, string password, string confirm_password, string expires_on, string is_enabled, string street_2 = null, string fax = null)
        {
            IAccountService accountSvc = ObjectFactory.GetInstance<IAccountService>();

            UserProfile userProfile;
            PrescriberProfile prescriberProfile;
            Data.Prescriber prescriber;
            Address address;
            Contact contact;
            Account account;

            Framework.Security.User user;

            if (profile_id > 0)
            {
                prescriberProfile = new PrescriberProfile(profile_id);
                prescriber = prescriberProfile.Prescriber;
                userProfile = prescriber.Profile;
                user = userProfile.User;
                address = userProfile.PrimaryAddress;
                contact = userProfile.PrimaryContact;
                account = accountSvc.GetByUserProfileId(userProfile.ID ?? 0);
            }
            else
            {
                userProfile = new UserProfile();
                userProfile.Created = DateTime.Now;
                prescriberProfile = new PrescriberProfile();
                prescriber = new Data.Prescriber();
                contact = new Contact();
                user = new Framework.Security.User();
                address = new Address();

                account = new Account
                {
                    CreatedAt = DateTime.Now
                };
            }

            if (!user.ID.HasValue && string.IsNullOrEmpty(password))
            {
                return new ReturnObject()
                {
                    Error = true,
                    StatusCode = 200,
                    Message = "If you are creating a new prescriber, you must enter a password."
                };
            }

            if (!string.IsNullOrEmpty(password) )
            {
                if (password != confirm_password)
                {
                    return new ReturnObject()
                    {
                        Error = true,
                        StatusCode = 200,
                        Message = "The passwords you entered do no match."
                    };
                }
                else
                {
                    user.PasswordSalt = Framework.Security.Manager.GetRandomSalt();
                    user.Password = Framework.Security.Hash.GetSHA512(password + user.PasswordSalt);
                }
            }

            user.Username = username;
            user.Email = email;
            user.Save();

            IList<Framework.Security.Group> userGroups = user.GetGroups();

            if(!userGroups.Any(x => x.ID == 2))
                user.AddGroup(new Framework.Security.Group(2));

            if(!userGroups.Any(x => x.ID == 3))
                user.AddGroup(new Framework.Security.Group(3));

            contact.Email = email;
            contact.Phone = phone;
            contact.FirstName = first_name;
            contact.LastName = last_name;
            contact.Save();

            DateTime expiresOn;

            if(!DateTime.TryParse(expires_on, out expiresOn))
            {
                    return new ReturnObject()
                    {
                        Error = true,
                        StatusCode = 200,
                        Message = "Invalide expiration date."
                    };
            }

            address.Street1 = street_1;
            address.Street2 = street_2;
            address.City = city;
            address.State = state;
            address.Zip = zip;
            address.Country = "United States";
            address.Save();

            userProfile.UserID = user.ID.Value;
            userProfile.UserTypeID = 0;
            userProfile.PrimaryAddressID = address.ID.Value;
            userProfile.PrimaryContactID = contact.ID.Value;
            userProfile.IsEcommerce = true;
            userProfile.Save();

            prescriber.ProfileID = userProfile.ID.Value;
            prescriber.SpecialityID = speciality;
            prescriber.NpiId = npi;
            prescriber.StateId = state_id;
            prescriber.StateIdIssuer = issuer;
            prescriber.Save();

            prescriberProfile.PrescriberID = prescriber.ID;
            prescriberProfile.ProviderID = provider_id;
            prescriberProfile.AddressID = address.ID.Value;
            prescriberProfile.ContactID = contact.ID.Value;
            prescriberProfile.PrescriberTypeID = prescriber_type;
            prescriberProfile.PrimaryFacilityID = 0;
            prescriberProfile.Expires = DateTime.Now.AddYears(1);
            prescriberProfile.OrganizationId = provider_id;
            prescriberProfile.Guid = Guid.NewGuid();
            prescriberProfile.Save();

            account.UserProifleId = userProfile.ID ?? 0;
            account.ExpiresOn = expiresOn;
            account.IsEnabled = is_enabled == "yes";

            accountSvc.Save(account);

            return new ReturnObject()
            {
                Result = prescriber,
                Growl = new ReturnGrowlObject()
                {
                    Type = "default",
                    Vars = new ReturnGrowlVarsObject()
                    {
                        text = "You have successfully saved this Prescriber.",
                        title = "Prescriber Saved"
                    }
                }
            };
        }
Esempio n. 5
0
        public static ReturnObject Update(HttpContext context, long id, string agree_to_terms, string watched_video, 
            string prescriber_type, long prescriber_speciality, string npi,
            string first_name, string last_name, string title, string email, string phone, string fax,
            string street_1, string city, string state, long issuer, string zip, string country,
            string prefix = null, string postfix = null, string street_2 = null, string state_id = null)
        {
            // load the profile we're finishing
            PrescriberProfile profile = new PrescriberProfile(id);

            // save the contact
            Contact contact = new Contact()
            {
                Prefix = prefix,
                FirstName = first_name,
                LastName = last_name,
                Postfix = postfix,
                Email = email,
                Phone = phone,
                Fax = fax,
                Title = title
            };
            contact.Save();

            // save the address
            Address address = new Address()
            {
                Street1 = street_1,
                Street2 = street_2,
                City = city,
                State = state,
                Country = country,
                Zip = zip
            };
            address.Save();

            profile.PrimaryFacilityID = 0;

            // get the prescriber type
            PrescriberType type = PrescriberType.FindByDisplayName(prescriber_type);

            if(type != null)
                profile.PrescriberTypeID = type.ID;

            profile.Save();

            return Success(
                "Profile Updated",
                "Your profile has been updated.",
                null,
                "Ecommerce.aspx#ecommerce/wizards/etasu-selections");
        }