private static void AssignPatientToPortal(Role portalRole, Guid organizationKey, Patient patient) { if (patient.Email == null) { return; } var systemAccount = new SystemAccount(organizationKey, patient.Email.Address, patient.Email); systemAccount.AssignToPatient(patient.Key); systemAccount.AddRole(portalRole.Key); }
private static void SetupPatientPortal(Guid organizationKey, Guid patientKey) { var portalRole = new Role("Patient Portal", RoleType.BuiltIn); portalRole.AddPermision(BasicAccessPermission.AccessUserInterfacePermission); portalRole.AddPermision(PortalPermission.PortalViewPermission); portalRole.AddPermision(PatientPermission.PatientViewPermission); portalRole.AddPermision(AssessmentPermission.AssessmentViewPermission); portalRole.AddPermision(AssessmentPermission.AssessmentReminderViewPermission); portalRole.AddPermision(AssessmentPermission.AssessmentEditPermission); portalRole.AddPermision(AssessmentPermission.ReportViewPermission); var systemAccount = new SystemAccount(organizationKey, "*****@*****.**", new Email("*****@*****.**")); systemAccount.AssignToPatient(patientKey); systemAccount.AddRole(portalRole.Key); }
public void Execute() { var systemAccountRepository = IoC.CurrentContainer.Resolve <ISystemAccountRepository> (); var systemAccount = systemAccountRepository.GetByIdentifier(systemAccountIdentifier); if (systemAccount == null) { var systemAdminRole = _roleFactory.Create("System Admin", RoleType.Internal); systemAdminRole.AddPermision(SystemAdministrationPermission.SystemAdminPermission); systemAdminRole.AddPermision(new Permission { Name = "infrastructuremodule/accessuserinterface" }); systemAccount = new SystemAccount(Guid.Empty, systemAccountIdentifier, new Email(systemAccountIdentifier)); systemAccount.AddRole(systemAdminRole.Key); _unitOfWorkProvider.GetCurrentUnitOfWork().Commit(); } }
private static void AddSystemAccount() { const string SystemAccountIdentifier = "*****@*****.**"; var systemAccountRepository = IoC.CurrentContainer.Resolve <ISystemAccountRepository>(); var roleFactory = IoC.CurrentContainer.Resolve <IRoleFactory>(); var systemAccount = systemAccountRepository.GetByIdentifier(SystemAccountIdentifier); if (systemAccount == null) { var systemAdminRole = roleFactory.Create("System Admin", null, RoleType.Internal); systemAdminRole.AddPermision(SystemAdministrationPermission.SystemAdminPermission); systemAdminRole.AddPermision(new Permission { Name = "infrastructuremodule/accessuserinterface" }); systemAccount = new SystemAccount(Guid.Empty, SystemAccountIdentifier, new Email(SystemAccountIdentifier)); systemAccount.AddRole(systemAdminRole.Key); } }
private static Guid SetupOrganization(IEnumerable <AssessmentDefinitionDto> assessmentDefinitionDtos, out Guid staffKey) { var organization = new Organization("Safe Harbor"); var identity = new ClaimsIdentity(new List <Claim> { new Claim(ProCenterClaimType.OrganizationKeyClaimType, organization.Key.ToString()) }); var currentPrincipal = new ClaimsPrincipal(identity); Thread.CurrentPrincipal = currentPrincipal; organization.AddAddress(new OrganizationAddress(OrganizationAddressType.Office, new Address("123 Main Street", "", "Columbia", UnitedStates.Maryland, new PostalCode("12345")))); organization.AddPhone(new OrganizationPhone(OrganizationPhoneType.Office, new Phone("1234567890"))); foreach (var assessmentDefinitionDto in assessmentDefinitionDtos) { organization.AddAssessmentDefinition(assessmentDefinitionDto.Key); } { var staff = new Staff(organization.Key, new PersonName("Leo", "Smith")); staffKey = staff.Key; var systemAccount = new SystemAccount(organization.Key, "*****@*****.**", new Email("*****@*****.**")); var role = new Role("Organization Admin"); var permissionDescriptors = IoC.CurrentContainer.ResolveAll <IPermissionDescriptor>(); var type = typeof(BasicAccessPermissionDescriptor); var allPermissions = new List <Permission>(); foreach (var resource in permissionDescriptors.OfType <IInternalPermissionDescriptor>().Where(pd => !pd.IsInternal).SelectMany(pd => pd.Resources)) { GetPermissionsHelper(allPermissions, resource); } if (allPermissions.Count == 0) { allPermissions.Add(BasicAccessPermission.AccessUserInterfacePermission); allPermissions.Add(PatientPermission.PatientEditPermission); allPermissions.Add(PatientPermission.PatientViewPermission); allPermissions.Add(StaffPermission.StaffAddRolePermission); allPermissions.Add(StaffPermission.StaffCreateAccountPermission); allPermissions.Add(StaffPermission.StaffEditPermission); allPermissions.Add(StaffPermission.StaffLinkAccountPermission); allPermissions.Add(StaffPermission.StaffRemoveRolePermission); allPermissions.Add(StaffPermission.StaffViewPermission); allPermissions.Add(OrganizationPermission.OrganizationEditPermission); allPermissions.Add(OrganizationPermission.OrganizationViewPermission); allPermissions.Add(RolePermission.RoleAddPermissionPermission); allPermissions.Add(RolePermission.RoleEditPermission); allPermissions.Add(RolePermission.RoleRemovePermissionPermission); allPermissions.Add(RolePermission.RoleViewPermission); allPermissions.Add(TeamPermission.TeamEditPermission); allPermissions.Add(TeamPermission.TeamViewPermission); allPermissions.Add(AssessmentPermission.AssessmentEditPermission); allPermissions.Add(AssessmentPermission.AssessmentViewPermission); } foreach (var permission in allPermissions) { role.AddPermision(permission); } systemAccount.AddRole(role.Key); systemAccount.AssignToStaff(staff.Key); } { var staff = new Staff(organization.Key, new PersonName("Cindy", "Thomas")); var systemAccount = new SystemAccount(organization.Key, "*****@*****.**", new Email("*****@*****.**")); var role = new Role("Organization Viewer"); role.AddPermision(BasicAccessPermission.AccessUserInterfacePermission); role.AddPermision(PatientPermission.PatientViewPermission); role.AddPermision(AssessmentPermission.AssessmentViewPermission); role.AddPermision(StaffPermission.StaffViewPermission); systemAccount.AddRole(role.Key); systemAccount.AssignToStaff(staff.Key); } return(organization.Key); }