예제 #1
0
        public static DrugCompanyUser FindByProfile(UserProfile p)
        {
            if (p == null || !p.ID.HasValue)
                return null;

            return FindByProfile(p.ID.Value);
        }
예제 #2
0
        protected void Page_Init(object sender, EventArgs e)
        {
            UserInfo = Manager.GetUser();
            UserProfile = UserProfile.FindByUser(UserInfo);

            if(UserProfile.PrimaryAddressID.HasValue)
                PrimaryAddress = UserProfile.PrimaryAddress;

            if(UserProfile.PrimaryContactID.HasValue)
                PrimaryContact = UserProfile.PrimaryContact;

            if(Manager.HasRole("view_prescriber", true))
            {
                Prescriber = Prescriber.FindByProfile(UserProfile);
                PrescriberProfiles = PrescriberProfile.FindByPrescriber(Prescriber);

                Addresses = (from pp in PrescriberProfiles
                             select pp.Address).ToList();

                Contacts = (from pp in PrescriberProfiles
                            select pp.Contact).ToList();

                States = State.FindAll();
                Specialities = Speciality.FindAll();
                SpecialityId = Prescriber.SpecialityID ?? 0;
            }
        }
예제 #3
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);
            }
        }
예제 #4
0
        public static IList<DistributionList> FindByUserProfile(UserProfile profile)
        {
            Database db = Database.Get("FDARems");
            StringBuilder sql = new StringBuilder();

            sql.Append("SELECT * ");
            sql.Append("FROM "+db.DelimTable("DistributionLists")+" ");
            sql.Append("WHERE "+db.DelimColumn("UserProfileId")+" = "+db.DelimParameter("ProfileId")+" ");
            sql.Append("ORDER BY "+db.DelimColumn("Name")+" ASC;");

            List<Parameter> ps = new List<Parameter>
            {
                new Parameter("ProfileId", profile.ID)
            };

            return db.ExecuteQuery<DistributionList>(sql.ToString(), ps.ToArray());
        }
예제 #5
0
        protected void Page_Init(object sender, EventArgs e)
        {
            RequireRole( "view_prescriber" );

            string input = Request.QueryString["id"];
            long prescriberId;

            if(String.IsNullOrEmpty(input) || !long.TryParse(input, out prescriberId))
                RedirectHash( "prescriber/profiles/list", true, "Invalid Prescriber Profile" );
            else
                PrescriberProfile = new Lib.Data.PrescriberProfile(prescriberId);

            UserInfo = Framework.Security.Manager.GetUser();
            UserProfile = UserProfile.FindByUser(UserInfo);

            Address = PrescriberProfile.Address;
            Contact = PrescriberProfile.Contact;
            Provider = PrescriberProfile.Provider;
            //Facility = PrescriberProfile.Facility;
            PrescriberTypes = PrescriberType.FindAll();

            TypeId = PrescriberProfile.PrescriberTypeID ?? 0;
        }
예제 #6
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;
            }
        }
예제 #7
0
        public static ProviderUser FindByProfile(UserProfile p)
        {
            if (p == null || !p.ID.HasValue)
                return null;

            return FindByProfile(p.ID.Value);
        }
예제 #8
0
        protected void Page_Init(object sender, EventArgs e)
        {
            long prescriberProfileId = long.Parse(Request.QueryString["prescriber-profile-id"]);

            States = State.FindAll();
            Specialities = Speciality.FindAll();
            PrescriberTypes = PrescriberType.FindAll();

            if(prescriberProfileId <= 0)
            {
                PrescriberProfile = new PrescriberProfile();
                Prescriber = new Lib.Data.Prescriber();
                SpecialityId = 0;
                TypeId = 0;
                User = new Framework.Security.User();

                Account = new Account
                {
                    ExpiresOn = DateTime.Now
                };
            }
            else
            {
                PrescriberProfile = new PrescriberProfile(prescriberProfileId);
                Prescriber = PrescriberProfile.Prescriber;
                SpecialityId = Prescriber.SpecialityID ?? 0;
                TypeId = PrescriberProfile.PrescriberTypeID ?? 0;
                UserProfile userProfile = new UserProfile(Prescriber.ProfileID);
                User = userProfile.User;
                Account = _accountSvc.GetByUserProfileId(userProfile.ID ?? 0);
            }
        }
예제 #9
0
        private string BuildProviderSendToList(UserProfile userProfile)
        {
            StringBuilder sb = new StringBuilder();

            ProviderUser providerUser = ProviderUser.FindByProfile(userProfile);
            IList<PrescriberProfile> sendTo = PrescriberProfile.FindByProvider(providerUser.Provider);

            sb.Append("[{label: 'All Prescribers', value: 0},");
            foreach(PrescriberProfile prescriberProf in sendTo)
            {
                UserProfile userProf = UserProfile.FindByPrimaryContact(prescriberProf.ContactID);

                sb.Append(String.Format("{{label: '{0}, {1}', value: {2}}},",
                    prescriberProf.Contact.LastName,
                    prescriberProf.Contact.FirstName,
                    userProf.UserID));
            }
            sb.Append("]");

            return sb.ToString();
        }
예제 #10
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");
        }
예제 #11
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"
                    }
                }
            };
        }
예제 #12
0
 protected Account GetAccountByUserProfile(UserProfile userProfile)
 {
     return _accountSvc.GetByUserProfileId(userProfile.ID ?? 0);
 }
예제 #13
0
        protected void Page_Init(object sender, EventArgs e)
        {
            long prescriberProfileId = long.Parse(Request.QueryString["prescriber-profile-id"]);
            ProviderId = long.Parse(Request.QueryString["provider-id"]);

            Organization org = _orgSvc.Get(ProviderId);
            Facilities = org.Facilities;
            States = State.FindAll();
            Specialities = Speciality.FindAll();
            PrescriberTypes = PrescriberType.FindAll();

            PrescriberProfile = new PrescriberProfile(prescriberProfileId);
            Prescriber = PrescriberProfile.Prescriber;
            SpecialityId = Prescriber.SpecialityID ?? 0;
            TypeId = PrescriberProfile.PrescriberTypeID ?? 0;

            UserProfile userProfile = new UserProfile(Prescriber.ProfileID);
            User = userProfile.User;
        }
예제 #14
0
        public static Prescriber FindByProfile(UserProfile profile)
        {
            if (!profile.ID.HasValue)
                return null;

            return FindByProfile(profile.ID.Value);
        }