Search in sources :

Example 36 with EncounterType

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());
}
Also used : EncounterType(org.openmrs.EncounterType) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 37 with EncounterType

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());
}
Also used : EncounterType(org.openmrs.EncounterType) Date(java.util.Date) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 38 with EncounterType

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);
}
Also used : EncounterType(org.openmrs.EncounterType) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 39 with EncounterType

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);
}
Also used : EncounterType(org.openmrs.EncounterType) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 40 with EncounterType

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());
}
Also used : User(org.openmrs.User) EncounterType(org.openmrs.EncounterType) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Aggregations

EncounterType (org.openmrs.EncounterType)60 Test (org.junit.Test)44 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)42 Encounter (org.openmrs.Encounter)19 Date (java.util.Date)17 Location (org.openmrs.Location)12 Patient (org.openmrs.Patient)10 User (org.openmrs.User)10 EncounterRole (org.openmrs.EncounterRole)9 Provider (org.openmrs.Provider)8 BindException (org.springframework.validation.BindException)7 Errors (org.springframework.validation.Errors)7 ArrayList (java.util.ArrayList)5 GlobalProperty (org.openmrs.GlobalProperty)5 List (java.util.List)4 Privilege (org.openmrs.Privilege)4 Concept (org.openmrs.Concept)3 Visit (org.openmrs.Visit)3 HashMap (java.util.HashMap)2 SQLQuery (org.hibernate.SQLQuery)2