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" ); }
protected void Page_Init(object sender, EventArgs e) { long id; if(!long.TryParse(Request.QueryString["id"], out id)) id = 0; Provider = Provider.FindByUser(ProviderUser.FindByProfile(UserProfile.FindByUser(Framework.Security.Manager.GetUser()))); DistributionList = new DistributionList(id); Prescribers = UserListItem.FindByList<Prescriber>(long.Parse(DistributionList.Settings)); }
protected void Page_Init(object sender, EventArgs e) { Provider = Lib.Systems.Security.GetCurrentProvider(); User user = Framework.Security.Manager.GetUser(); UserProfile userProfile = UserProfile.FindByUser(user); ProviderUser providerUser = ProviderUser.FindByProfile(userProfile); Organization org = _orgSvc.Get(providerUser.OrganizationID); OrganizationId = org.Id; Facilities = org.Facilities; }
public static IList<PrescriberUpdate> FindByProvider( Provider provider ) { if( provider == null || provider.ID == null ) return new List<PrescriberUpdate>(); var db = Framework.Data.Database.Get( "FDARems" ); string sql = "SELECT TOP 10 * " + " FROM " + db.Delim( "PrescriberUpdates", Framework.Data.DelimType.Table ) + " WHERE [ProviderID] = @providerID " + " ORDER BY [DateCreated] DESC"; var ps = new List<Parameter>(); ps.Add( new Parameter( "providerID", provider.ID.Value ) ); return db.ExecuteQuery<PrescriberUpdate>( sql, ps.ToArray() ); }
public static IList<ProviderUser> FindByProvider(Provider p) { if (p == null || !p.ID.HasValue) return new List<ProviderUser>(); return FindByProvider(p.ID.Value); }
public static ReturnObject Edit(HttpContext context, long provider_user_id, long organization_id, long facility_id, string user_type, string username, string password, string email, string first_name, string last_name, string street, string city, string state, string zip, string street_2 = null, string phone = null) { Lib.Data.Provider provider; Lib.Data.ProviderUser providerUser; UserProfile userProfile; Contact contact; Address address; Framework.Security.User user; if (provider_user_id > 0) { providerUser = new Lib.Data.ProviderUser(provider_user_id); provider = providerUser.Provider; userProfile = providerUser.Profile; user = userProfile.User; contact = userProfile.PrimaryContact; address = userProfile.PrimaryAddress; user.Username = username; user.Save(); Framework.Security.Manager.SetPassword(user, password); } else { provider = new Lib.Data.Provider(); providerUser = new Lib.Data.ProviderUser(); userProfile = new Data.UserProfile(); userProfile.Created = DateTime.Now; contact = new Data.Contact(); address = new Data.Address(); string error = ""; user = Framework.Security.Manager.CreateUser(username, password, email, out error); user.AddGroup(Framework.Security.Group.FindByName("users")); user.AddGroup(Framework.Security.Group.FindByName("providers")); if (!string.IsNullOrEmpty(error)) { return new ReturnObject() { Error = true, StatusCode = 200, Message = error }; } } if (user_type != "technical" && user_type != "administrative") { return new ReturnObject() { Error = true, StatusCode = 200, Message = "Invalid user type." }; } address.Street1 = street; address.Street2 = street_2; address.City = city; address.State = state; address.Zip = zip; address.Country = "United States"; address.Save(); contact.Email = email; contact.FirstName = first_name; contact.LastName = last_name; contact.Phone = phone; contact.Save(); provider.AddressID = address.ID; provider.PrimaryContactID = contact.ID; provider.Created = DateTime.Now; provider.FacilitySize = String.Empty; provider.Name = string.Empty; provider.Save(); var ut = Lib.Data.UserType.FindByName("provider"); userProfile.UserTypeID = ut.ID.Value; userProfile.UserID = user.ID.Value; userProfile.PrimaryAddressID = address.ID.Value; userProfile.PrimaryContactID = contact.ID.Value; userProfile.Save(); providerUser.ProfileID = userProfile.ID.Value; providerUser.ProviderID = provider.ID.Value; providerUser.OrganizationID = organization_id; providerUser.ProviderUserType = user_type; providerUser.PrimaryFacilityID = facility_id; providerUser.Save(); return new ReturnObject() { Result = providerUser, Growl = new ReturnGrowlObject() { Type = "default", Vars = new ReturnGrowlVarsObject() { text = "You have successfully saved this provider user.", title = "Provider User Saved" } } }; }
protected void Page_Init(object sender, EventArgs e) { _providerUser = ProviderUser.FindByProfile(UserProfile.FindByUser(Framework.Security.Manager.GetUser())); _provider = Provider.FindByUser(_providerUser); Prescribers = _provider.GetPrescribers(); BuildDistributionListArray(DistributionList.FindByUserProfile(UserProfile.FindByUser(Framework.Security.Manager.GetUser()))); }
public static IList<ProviderFacility> FindByProvider(Provider provider) { if (provider == null || provider.ID == null) return new List<ProviderFacility>(); return FindByProvider(provider.ID.Value); }
public static ReturnObject EditProvider(HttpContext context, long provider_user_id, string username, string password, string email, string first_name, string last_name, string street, string city, string state, string zip, string expires_on, string is_enabled, string street_2 = null, string phone = null) { IAccountService accountSvc = ObjectFactory.GetInstance<IAccountService>(); Lib.Data.Provider provider; Lib.Data.ProviderUser providerUser; UserProfile userProfile; Contact contact; Address address; Account account; Framework.Security.User user; if (provider_user_id > 0) { providerUser = new Lib.Data.ProviderUser(provider_user_id); provider = providerUser.Provider; userProfile = providerUser.Profile; user = userProfile.User; contact = userProfile.PrimaryContact; address = userProfile.PrimaryAddress; account = accountSvc.GetByUserProfileId(userProfile.ID ?? 0); user.Username = username; user.Save(); Framework.Security.Manager.SetPassword(user, password); } else { provider = new Lib.Data.Provider(); providerUser = new Lib.Data.ProviderUser(); userProfile = new Data.UserProfile(); userProfile.Created = DateTime.Now; contact = new Data.Contact(); address = new Data.Address(); account = new Account { CreatedAt = DateTime.Now }; string error = ""; user = Framework.Security.Manager.CreateUser(username, password, email, out error); user.AddGroup(Framework.Security.Group.FindByName("users")); user.AddGroup(Framework.Security.Group.FindByName("providers")); if (!string.IsNullOrEmpty(error)) { return new ReturnObject() { Error = true, StatusCode = 200, Message = error }; } } DateTime expiresOn; if(!DateTime.TryParse(expires_on, out expiresOn)) { return new ReturnObject() { Error = true, StatusCode = 200, Message = "Invalide expiration date." }; } address.Street1 = street; address.Street2 = street_2; address.City = city; address.State = state; address.Zip = zip; address.Country = "United States"; address.Save(); contact.Email = email; contact.FirstName = first_name; contact.LastName = last_name; contact.Phone = phone; contact.Save(); provider.AddressID = address.ID; provider.PrimaryContactID = contact.ID; provider.Created = DateTime.Now; provider.FacilitySize = String.Empty; provider.Name = string.Empty; provider.Save(); var ut = Lib.Data.UserType.FindByName("provider"); userProfile.UserTypeID = ut.ID.Value; userProfile.UserID = user.ID.Value; userProfile.PrimaryAddressID = address.ID.Value; userProfile.PrimaryContactID = contact.ID.Value; userProfile.IsEcommerce = true; userProfile.Save(); providerUser.ProfileID = userProfile.ID.Value; providerUser.ProviderID = provider.ID.Value; providerUser.OrganizationID = 0; providerUser.ProviderUserType = ""; providerUser.PrimaryFacilityID = 0; providerUser.Save(); account.UserProifleId = userProfile.ID ?? 0; account.ExpiresOn = expiresOn; account.IsEnabled = is_enabled == "yes"; accountSvc.Save(account); return new ReturnObject() { Result = providerUser, Growl = new ReturnGrowlObject() { Type = "default", Vars = new ReturnGrowlVarsObject() { text = "You have successfully saved this provider user.", title = "Provider User Saved" } } }; }
public static IList<PrescriberProfile> FindPendingInvitesByProvider(Provider provider) { return FindAllBy<PrescriberProfile>( new Dictionary<string, object> { { "ProviderID", provider.ID.Value }, { "PrescriberId", SpecialValue.IsNull }, }, new[] { "-Expires" } ); }
public static IList<PrescriberProfile> FindByProvider(Provider p) { return FindAllBy<PrescriberProfile>( new Dictionary<string, object> { { "ProviderID", p.ID.Value }, { "PrescriberID", SpecialValue.IsNotNull }, { "Deleted", false }, }, new[] { "-Expires" } ); }