Package org.openmrs

Examples of org.openmrs.Role


        String htmlform4 = "<htmlform><restrictByRole exclude=\"System Developer,Data Manager\">This is not shown to admin with multiple roles in exclude field</restrictByRole><restrictByRole exclude=\"Provider,Data Manager\">This is shown to admin with multiple roles in exclude field</restrictByRole></htmlform>";
        FormEntrySession session4 = new FormEntrySession(patient, htmlform4, null);
        Assert.assertEquals("<div class=\"htmlform\">This is shown to admin with multiple roles in exclude field</div>", session4.getHtmlToDisplay());

        /* check the restriction for a single user with multiple roles */
        Context.getAuthenticatedUser().addRole(new Role("Test Role", "A temporary role for the test"));

        String htmlform5 = "<htmlform><restrictByRole include=\"System Developer,Test Role\">This is shown to admin with multiple roles to single user in include field</restrictByRole><restrictByRole include=\"Provider,Data Manager\">This is not shown to admin with multiple roles to single user in include field</restrictByRole></htmlform>";
        FormEntrySession session5 = new FormEntrySession(patient, htmlform5, null);
        Assert.assertEquals("<div class=\"htmlform\">This is shown to admin with multiple roles to single user in include field</div>", session5.getHtmlToDisplay());

View Full Code Here


        Assert.assertEquals("Hippocrates of Cos", service.getUsersAsPersonStubs("Provider").get(0).getDisplayValue());
        Assert.assertEquals(0, service.getUsersAsPersonStubs("Clinician").size());
       
        //Create the Clinician role and add to the existing user, and see if user is returned.
        Integer userId = service.getUsersAsPersonStubs("Provider").get(0).getId();
        Role role = new Role();
        role.setUuid(java.util.UUID.randomUUID().toString());
        role.setRole("Clinician");
        role.setRetired(false);
        role.setName("Clinician");
        role.setDateCreated(new Date());
        role.setDescription("boo");
        role.setCreator(Context.getAuthenticatedUser());
        Context.getUserService().saveRole(role);
        User user = Context.getUserService().getUser(userId);
        user.addRole(role);
        user.getPersonName().setFamilyName(null);
        user.getPersonName().setGivenName(null);
View Full Code Here

                List<PersonStub> users = new ArrayList<PersonStub>();
                List<Option> providerUsers = new ArrayList<Option>();

                // If the "role" attribute is passed in, limit to users with this role
                if (parameters.get("role") != null) {
                    Role role = Context.getUserService().getRole((String) parameters.get("role"));
                    if (role == null) {
                        throw new RuntimeException("Cannot find role: " + parameters.get("role"));
                    } else {
                        users = Context.getService(HtmlFormEntryService.class).getUsersAsPersonStubs(role.getRole());
                    }
                }

                // Otherwise, use default options appropriate to the underlying OpenMRS version
                else {
                    if (openmrsVersionDoesNotSupportProviders()) {
                        // limit to users with the default OpenMRS PROVIDER role,
                        String defaultRole = OpenmrsConstants.PROVIDER_ROLE;
                        Role role = Context.getUserService().getRole(defaultRole);
                        if (role != null) {
                            users = Context.getService(HtmlFormEntryService.class).getUsersAsPersonStubs(role.getRole());
                        }
                        // If this role isn't used, default to all Users
                        if (users.isEmpty()) {
                            users = Context.getService(HtmlFormEntryService.class).getUsersAsPersonStubs(null);
                        }
View Full Code Here

    Location existing2 = Context.getLocationService().getLocation(2); // Xanadu
   
    Drug incoming3 = Context.getConceptService().getDrug(3)// Aspirin
    Drug existing3 = Context.getConceptService().getDrug(11); // NyQuil
   
    Role incoming4 = Context.getUserService().getRole(incomingRoleName);
    Role existing4 = Context.getUserService().getRole(existingRoleName);
   
    Map<OpenmrsObject, OpenmrsObject> incomingToExisting = new HashMap<OpenmrsObject, OpenmrsObject>();
    incomingToExisting.put(incoming1, existing1);
    incomingToExisting.put(incoming2, existing2);
    incomingToExisting.put(incoming3, existing3);
View Full Code Here

                    dependencies.add(workflow);
                  }
                }
                // need to special case of the name of a role
                if (Role.class.equals(attributeDescriptor.getClazz())) {
                  Role role = Context.getUserService().getRole(id);
                  if (role != null) {
                    dependencies.add(role);
                    continue;
                  }
                }
View Full Code Here

           
            List<PersonStub> users = new ArrayList<PersonStub>();
           
            // If the "role" attribute is passed in, limit to users with this role
            if (parameters.get("role") != null) {
              Role role = Context.getUserService().getRole((String) parameters.get("role"));
              if (role == null) {
                throw new RuntimeException("Cannot find role: " + parameters.get("role"));
              } else {
                users = Context.getService(HtmlFormEntryService.class).getUsersAsPersonStubs(role.getRole());
              }
            }

            // Otherwise, limit to users with the default OpenMRS PROVIDER role,
            else {
              String defaultRole = OpenmrsConstants.PROVIDER_ROLE;
              Role role = Context.getUserService().getRole(defaultRole);
              if (role != null) {
                users = Context.getService(HtmlFormEntryService.class).getUsersAsPersonStubs(role.getRole());
              }
              // If this role isn't used, default to all Users
              if (users.isEmpty()) {
                users = Context.getService(HtmlFormEntryService.class).getUsersAsPersonStubs(null);
              }
View Full Code Here

TOP

Related Classes of org.openmrs.Role

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.