Ejemplo n.º 1
0
        public static ReturnObject DeletePrescriber(HttpContext context, long id)
        {
            if (id <= 0)
                return new ReturnObject() { Error = true, Message = "Invalid Prescriber." };

            var item = new PrescriberProfile(id);

            item.Address.Delete();
            item.Contact.Delete();
            item.Delete();

            return new ReturnObject()
            {
                Growl = new ReturnGrowlObject()
                {
                    Type = "default",
                    Vars = new ReturnGrowlVarsObject()
                    {
                        text = "You have successfully deleted a Prescriber.",
                        title = "Prescriber deleted"
                    }
                },
                Actions = new List<ReturnActionObject>()
                {
                    new ReturnActionObject() {
                        Ele = "#prescribers-table tr[data-id=\""+id.ToString()+"\"]",
                        Type = "remove"
                    }
                }
            };
        }
Ejemplo n.º 2
0
        protected void Page_Init(object sender, EventArgs e)
        {
            RequireRole( "view_provider" );

            string strID = Request.QueryString["id"];
            long id;
            if( string.IsNullOrEmpty( strID ) || !long.TryParse( strID, out id ) )
                RedirectHash( "provider/prescribers/list", true, "Invalid Prescriber" );
            else
                Prescriber = new Prescriber( id );

            Provider = Lib.Systems.Security.GetCurrentProvider();
            ProviderUser = ProviderUser.FindByProvider(Provider.ID.Value).First();
            PrescriberProfile = PrescriberProfile.FindByPrescriberAndProvider(Prescriber, ProviderUser.OrganizationID);
            ProviderFacilities = ProviderFacility.FindByProvider(Provider);
            States = State.FindAll();
            Specialities = Speciality.FindAll();
            SpecialityId = Prescriber.SpecialityID ?? 0;
            PrescriberTypes = PrescriberType.FindAll();
            TypeId = PrescriberProfile.PrescriberTypeID ?? 0;

            if(PrescriberProfile != null)
            {
                PrescriberFacilities = PrescriberProfile.GetFacilities();
                Drugs = Lib.Systems.Lists.GetUsersDrugs(PrescriberProfile.ID ?? 0);
            }
            else
                RedirectHash( "provider/prescribers/list", true, "Invalid Prescriber" );
        }
Ejemplo n.º 3
0
        public static ReturnObject AttachProfile(HttpContext context, long id, string username, string password)
        {
            if(string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password) )
                return Failure(401, "Invalid username or password.");

            if(!Framework.Security.Manager.Login(username, password))
                return Failure(401, "Invalid username or password.");

            UserProfile userProfile = UserProfile.FindByUser(Framework.Security.Manager.GetUser());
            Data.Prescriber prescriber = Data.Prescriber.FindByProfile(userProfile);
            PrescriberProfile prescriberProfile = new PrescriberProfile(id);

            if(userProfile == null || prescriber == null || prescriberProfile == null)
                return Failure(404, "There does not appear to be a prescriber associate with your account.");

            prescriberProfile.AddressID = userProfile.PrimaryAddressID ?? 0;
            prescriberProfile.ContactID = userProfile.PrimaryContactID ?? 0;
            prescriberProfile.PrescriberID = prescriber.ID;

            prescriberProfile.Save();

            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"
                    }
                }
            };
        }
Ejemplo n.º 4
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;
        }
Ejemplo n.º 5
0
        public static ReturnObject Edit(HttpContext context, long id, long prescriber_type)
        {
            PrescriberProfile profile = new PrescriberProfile(id);

            if(profile.ID == null)
                return new ReturnObject{Error = true, Message = "Invalid Request."};

            profile.PrescriberTypeID = prescriber_type;
            profile.Save();

            return new ReturnObject
            {
                Result = profile,
                Growl = new ReturnGrowlObject
                {
                    Type = "default",
                    Vars = new ReturnGrowlVarsObject
                    {
                        text = "Your information has been updated.",
                        title = "Prescriber Profile Updated"
                    }
                }
            };
        }
Ejemplo n.º 6
0
 public string GetUsername(PrescriberProfile prescriberProfile)
 {
     return prescriberProfile.Prescriber.Profile.User.Username;
 }
Ejemplo n.º 7
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);
            }
        }
Ejemplo n.º 8
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");
        }
Ejemplo n.º 9
0
        protected Account GetAccountByPrescriberPrfile(PrescriberProfile prescriberProfile)
        {
            UserProfile userProfile = prescriberProfile.Prescriber.Profile;

            return _accountSvc.GetByUserProfileId(userProfile.ID ?? 0);
        }
Ejemplo n.º 10
0
 public string GetPrescriberType(PrescriberProfile profile)
 {
     return (profile != null && profile.PrescriberTypeID != null)
         ? profile.PrescriberType.DisplayName
         : String.Empty;
 }
Ejemplo n.º 11
0
 public string GetPrescriberFacilityName(PrescriberProfile profile)
 {
     return (profile != null && profile.Facility != null)
         ? profile.Facility.Name
         : String.Empty;
 }
Ejemplo n.º 12
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"
                    }
                }
            };
        }
Ejemplo n.º 13
0
        public static ReturnObject Create(HttpContext context, string email, string first_name, string last_name, string phone_number, string message = null)
        {
            var provider = Security.GetCurrentProvider();
            var providerProfile = ProviderUser.FindByProvider(provider).FirstOrDefault();

            if( provider == null || string.IsNullOrEmpty(email) )
                return new ReturnObject() { Error = true, Message = "Invalid Request." };

            var contact = new Contact
            {
                FirstName = first_name,
                LastName = last_name,
                Email = email,
                Phone = phone_number,
                Fax = null
            };
            contact.Save();

            var address = new Address
            {
                Street1 = string.Empty,
                Street2 = null,
                City = string.Empty,
                State = string.Empty,
                Zip = string.Empty,
                Country = string.Empty
            };
            address.Save();

            var prescriberProf = new PrescriberProfile
            {
                Guid = Guid.NewGuid(),
                ProviderID = provider.ID.Value,
                ContactID = contact.ID.Value,
                AddressID = address.ID.Value,
                Expires = DateTime.Now.AddYears(1),
                PrimaryFacilityID = providerProfile.PrimaryFacilityID,
                OrganizationId = providerProfile.OrganizationID,
                Deleted = false,
            };

            prescriberProf.Save();

            var data = new Dictionary<string, object> {
                {"Message", (message != null)? message : "You have been invited to use the REMS Logic system.  Please click the link below to complete your profile"},
                {"Token", prescriberProf.Guid},
                {"Year", DateTime.Now.Year.ToString()},
                {"EmailAddress", email}
            };

            var overrides = new Framework.Email.TemplateOverrides {
                To = new [] { new MailAddress(email) }
            };

            Email.SendTemplate("PrescriberInvite", data, overrides);

            return new ReturnObject
            {
                Result = prescriberProf,
                Actions = new List<ReturnActionObject>(new ReturnActionObject[] {
                    new ReturnActionObject { Type = "back" }
                }),
                Growl = new ReturnGrowlObject
                {
                    Type = "default",
                    Vars = new ReturnGrowlVarsObject
                    {
                        text = "Your invite has been sent",
                        title = "Prescriber Invited"
                    }
                }
            };
        }
Ejemplo n.º 14
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;
        }
Ejemplo n.º 15
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");
        }