use of org.openmrs.EncounterType in project openmrs-core by openmrs.
the class EncounterServiceTest method getEncounterType_shouldReturnNullIfOnlyRetiredTypeFound.
/**
* Make sure that the "Some Retired Type" type is not returned because it is retired in
* {@link EncounterService#getEncounterType(String)}
*
* @see EncounterService#getEncounterType(String)
*/
@Test
public void getEncounterType_shouldReturnNullIfOnlyRetiredTypeFound() {
EncounterService encounterService = Context.getEncounterService();
// sanity check to make sure 'some retired type' is in the dataset
assertTrue(encounterService.getEncounterType(4).getRetired());
assertEquals("Some Retired Type", encounterService.getEncounterType(4).getName());
// we should get a null here because this named type is retired
EncounterType type = encounterService.getEncounterType("Some Retired Type");
assertNull(type);
}
use of org.openmrs.EncounterType in project openmrs-core by openmrs.
the class EncounterServiceTest method purgeEncounterType_shouldThrowErrorWhenTryingToDeleteEncounterTypeWhenEncounterTypesAreLocked.
/**
* @see EncounterService#purgeEncounterType(EncounterType)
*/
@Test(expected = EncounterTypeLockedException.class)
public void purgeEncounterType_shouldThrowErrorWhenTryingToDeleteEncounterTypeWhenEncounterTypesAreLocked() {
EncounterService encounterService = Context.getEncounterService();
EncounterType encounterType = Context.getEncounterService().getEncounterType(1);
Assert.assertNotNull(encounterType);
GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_ENCOUNTER_TYPES_LOCKED);
gp.setPropertyValue("true");
Context.getAdministrationService().saveGlobalProperty(gp);
encounterService.purgeEncounterType(encounterType);
}
use of org.openmrs.EncounterType in project openmrs-core by openmrs.
the class EncounterServiceTest method canEditAllEncounterTypes_shouldReturnTrueIfUserIsGrantedToEditEncounters.
/**
* @see EncounterService#canEditAllEncounterTypes(User)
*/
@Test
public void canEditAllEncounterTypes_shouldReturnTrueIfUserIsGrantedToEditEncounters() {
EncounterService encounterService = Context.getEncounterService();
EncounterType encounterType = new EncounterType("testing", "desc");
Privilege editPrivilege = Context.getUserService().getPrivilege("Some Privilege For Edit Encounter Types");
encounterType.setEditPrivilege(editPrivilege);
encounterService.saveEncounterType(encounterType);
User user = Context.getUserService().getUserByUsername("test_user");
assertNotNull(user);
assertFalse(encounterService.canEditAllEncounterTypes(user));
Role role = Context.getUserService().getRole("Provider");
role.addPrivilege(editPrivilege);
user.addRole(role);
assertTrue(encounterService.canEditAllEncounterTypes(user));
}
use of org.openmrs.EncounterType in project openmrs-core by openmrs.
the class EncounterServiceTest method findEncounterTypes_shouldIncludeRetiredTypesInTheResults.
/**
* @see EncounterService#findEncounterTypes(String)
*/
@Test
public void findEncounterTypes_shouldIncludeRetiredTypesInTheResults() {
EncounterService encounterService = Context.getEncounterService();
List<EncounterType> types = encounterService.findEncounterTypes("Test Enc");
assertEquals(3, types.size());
// make sure at least one of the types was retired
boolean foundRetired = false;
for (EncounterType type : types) {
if (type.getRetired())
foundRetired = true;
}
assertTrue("Retired types should be returned as well", foundRetired);
}
use of org.openmrs.EncounterType in project openmrs-core by openmrs.
the class EncounterServiceTest method unretireEncounterType_shouldUnretireTypeAndUnmarkAttributes.
/**
* @see EncounterService#unretireEncounterType(EncounterType)
*/
@Test
public void unretireEncounterType_shouldUnretireTypeAndUnmarkAttributes() {
EncounterService encounterService = Context.getEncounterService();
EncounterType type = encounterService.getEncounterType(3);
assertTrue(type.getRetired());
assertNotNull(type.getRetiredBy());
assertNotNull(type.getRetireReason());
assertNotNull(type.getDateRetired());
EncounterType unretiredEncType = encounterService.unretireEncounterType(type);
// make sure its still the same object
assertEquals(unretiredEncType, type);
// make sure that all the values were unfilled in
assertFalse(unretiredEncType.getRetired());
assertNull(unretiredEncType.getDateRetired());
assertNull(unretiredEncType.getRetiredBy());
assertNull(unretiredEncType.getRetireReason());
}
Aggregations