use of org.openmrs.EncounterType in project openmrs-core by openmrs.
the class EncounterServiceTest method getEncounterTypeByUuid_shouldFindObjectGivenValidUuid.
/**
* @see EncounterService#getEncounterTypeByUuid(String)
*/
@Test
public void getEncounterTypeByUuid_shouldFindObjectGivenValidUuid() {
String uuid = "02c533ab-b74b-4ee4-b6e5-ffb6d09a0ac8";
EncounterType encounterType = Context.getEncounterService().getEncounterTypeByUuid(uuid);
Assert.assertEquals(6, (int) encounterType.getEncounterTypeId());
}
use of org.openmrs.EncounterType in project openmrs-core by openmrs.
the class EncounterServiceTest method saveEncounterType_shouldNotOverwriteDateCreated.
/**
* @see EncounterService#saveEncounterType(EncounterType)
*/
@Test
public void saveEncounterType_shouldNotOverwriteDateCreated() {
EncounterService encounterService = Context.getEncounterService();
// the encounter to save without a dateCreated
EncounterType encounterType = new EncounterType();
encounterType.setName("testing");
encounterType.setDescription("desc");
// make sure we
Date date = new Date(System.currentTimeMillis() - 5000);
// have a
// date that
// isn't
// "right now"
encounterType.setDateCreated(date);
encounterService.saveEncounterType(encounterType);
// make sure the encounter type date created wasn't overwritten
assertEquals(DateUtil.truncateToSeconds(date), encounterType.getDateCreated());
// make sure we can fetch this new encounter type
// from the database and its values are the same as the passed in ones
EncounterType newEncounterType = encounterService.getEncounterType(encounterType.getEncounterTypeId());
assertNotNull(newEncounterType);
assertEquals(DateUtil.truncateToSeconds(date), encounterType.getDateCreated());
}
use of org.openmrs.EncounterType in project openmrs-core by openmrs.
the class EncounterServiceTest method getEncounterType_shouldNotGetByInexactName.
/**
* Make sure that we are matching on exact name and not partial name in
*
* @see EncounterService#getEncounterType(String)
*/
@Test
public void getEncounterType_shouldNotGetByInexactName() {
EncounterService encounterService = Context.getEncounterService();
// we should not get two types here, the second one is retired
EncounterType type = encounterService.getEncounterType("Test Enc Type A");
assertEquals(2, type.getEncounterTypeId().intValue());
// we should not get any encounters here even though "Test Enc" is
// similar
// to a name that is in the db
EncounterType typeByInExactName = encounterService.getEncounterType("Test Enc");
assertNull(typeByInExactName);
}
use of org.openmrs.EncounterType in project openmrs-core by openmrs.
the class EncounterServiceTest method getAllEncounterTypes_shouldIncludeRetiredTypesWithTrueIncludeRetiredParameter.
/**
* @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);
}
use of org.openmrs.EncounterType in project openmrs-core by openmrs.
the class EncounterServiceTest method saveEncounterType_shouldNotOverwriteCreator.
/**
* @see EncounterService#saveEncounterType(EncounterType)
*/
@Test
public void saveEncounterType_shouldNotOverwriteCreator() {
EncounterService encounterService = Context.getEncounterService();
// the encounter to save without a dateCreated
EncounterType encounterType = new EncounterType("testing", "desc");
encounterType.setCreator(new User(4));
// make sure the logged in user isn't the user we're testing with
assertNotSame(encounterType.getCreator(), Context.getAuthenticatedUser());
encounterService.saveEncounterType(encounterType);
// make sure the encounter type creator is user 4 not user 1
assertEquals(4, encounterType.getCreator().getId().intValue());
assertNotSame(encounterType.getCreator(), Context.getAuthenticatedUser());
// make sure we can fetch this new encounter type
// from the database and its values are the same as the passed in ones
EncounterType newEncounterType = encounterService.getEncounterType(encounterType.getEncounterTypeId());
assertNotNull(newEncounterType);
assertEquals(4, encounterType.getCreator().getId().intValue());
assertNotSame(encounterType.getCreator(), Context.getAuthenticatedUser());
}
Aggregations