/** * @see org.openmrs.api.EncounterService#canEditAllEncounterTypes(org.openmrs.User) */ @Override @Transactional(readOnly = true) public boolean canEditAllEncounterTypes(User subject) { boolean canEdit = Boolean.TRUE; for (EncounterType et : Context.getEncounterService().getAllEncounterTypes()) { if (!userHasEncounterPrivilege(et.getEditPrivilege(), subject)) { canEdit = Boolean.FALSE; break; } } return canEdit; }
/** * @see org.openmrs.api.EncounterService#canViewAllEncounterTypes(org.openmrs.User) */ @Override @Transactional(readOnly = true) public boolean canViewAllEncounterTypes(User subject) { boolean canView = Boolean.TRUE; for (EncounterType et : Context.getEncounterService().getAllEncounterTypes()) { if (!userHasEncounterPrivilege(et.getViewPrivilege(), subject)) { canView = Boolean.FALSE; break; } } return canView; }
/** * @see EncounterService#getAllEncounterTypes(boolean) */ @Test public void getAllEncounterTypes_shouldNotReturnRetiredTypes() { EncounterService encounterService = Context.getEncounterService(); List<EncounterType> encounterTypes = encounterService.getAllEncounterTypes(false); // make sure we get a list assertNotNull(encounterTypes); // make sure we only get the two non retired encounter types // defined in the initialData.xml assertEquals(2, encounterTypes.size()); }
/** * @see EncounterService#getAllEncounterTypes(null) */ @Test public void getAllEncounterTypes_shouldIncludeRetiredTypesWithTrueIncludeRetiredParameter() { EncounterService encounterService = Context.getEncounterService(); boolean foundRetired = false; List<EncounterType> types = encounterService.getAllEncounterTypes(true); // there should be five types in the database assertEquals(5, types.size()); for (EncounterType type : types) { if (type.getRetired()) foundRetired = true; } assertTrue("Retired types should be returned as well", foundRetired); }
/** * @see EncounterService#getEncounterType(String) */ @Test public void getEncounterType_shouldNotGetRetiredTypes() { EncounterService encounterService = Context.getEncounterService(); // loop over all types to make sure // that the retired "Test Enc Type C" exists boolean foundRetired = false; for (EncounterType encType : encounterService.getAllEncounterTypes(true)) { if (encType.getName().equals("Test Enc Type C") && encType.getRetired()) { foundRetired = true; } } assertTrue(foundRetired); assertNull(encounterService.getEncounterType("Test Enc Type C")); }
/** * Make sure the "@Before" method on {@link BaseContextSensitiveTest} is authenticating the user * * @throws Exception */ @Test public void shouldCallBaseSetupMethod() { // make sure we're authenticated Assert.assertTrue(Context.isAuthenticated()); // make sure we have some data from the EXAMPLE_XML_DATASET_PACKAGE_PATH Assert.assertTrue(Context.getEncounterService().getAllEncounterTypes().size() > 0); // make sure we have the data from the INITIAL_DATA_SET_XML_FILENAME Context.authenticate("admin", "test"); // this is put here for the next test method to check that authentication is // not happening when told not to Context.logout(); }
coremetadatas.put("encounter_type", Context.getEncounterService().getAllEncounterTypes(true)); coremetadatas.put("concept_datatype", Context.getConceptService().getAllConceptDatatypes(true)); coremetadatas.put("concept_class", Context.getConceptService().getAllConceptClasses(true));
/** * @see EncounterService#canEditAllEncounterTypes(User) */ @Test public void canViewAllEncounterTypes_shouldReturnTrueWhenTheEncounterTypesEditPrivilegeColumnIsNull() { EncounterService encounterService = Context.getEncounterService(); // set editPrivilege on each encounter type to null for (EncounterType encounterType : encounterService.getAllEncounterTypes()) { encounterType.setEditPrivilege(null); encounterService.saveEncounterType(encounterType); } User user = Context.getUserService().getUserByUsername("test_user"); assertNotNull(user); assertTrue(encounterService.canEditAllEncounterTypes(user)); }
/** * @see EncounterService#canViewAllEncounterTypes(User) */ @Test public void canViewAllEncounterTypes_shouldReturnTrueWhenTheEncounterTypesViewPrivilegeColumnIsNull() { EncounterService encounterService = Context.getEncounterService(); // set viewPrivilege on each encounter type to null for (EncounterType encounterType : encounterService.getAllEncounterTypes()) { encounterType.setViewPrivilege(null); encounterService.saveEncounterType(encounterType); } User user = Context.getUserService().getUserByUsername("test_user"); assertNotNull(user); assertTrue(encounterService.canViewAllEncounterTypes(user)); }
@ModelAttribute("encounterTypes") List<EncounterType> getEncounterTypes() { return Context.getEncounterService().getAllEncounterTypes(); }
@Override public long getAllCount() { return service.getAllEncounterTypes(false).size(); }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doGetAll(org.openmrs.module.webservices.rest.web.RequestContext) */ @Override protected NeedsPaging<EncounterType> doGetAll(RequestContext context) { return new NeedsPaging<EncounterType>(Context.getEncounterService().getAllEncounterTypes(context.getIncludeAll()), context); }
encounterTypes = options; } else { encounterTypes = Context.getEncounterService().getAllEncounterTypes();
@Test public void encounterTypeTag_shouldIncludeAllEncounterTypesIfNoneAreSpecified() throws Exception { String htmlform = "<htmlform><encounterType/></htmlform>"; FormEntrySession session = new FormEntrySession(null, htmlform, null); Assert.assertTrue(session.getHtmlToDisplay() .indexOf("<option value=\"\">htmlformentry.chooseEncounterType</option>") > -1); Assert.assertEquals(1 + Context.getEncounterService().getAllEncounterTypes().size(), StringUtils.countMatches(session.getHtmlToDisplay(), "<option value=\"")); }