Search in sources :

Example 6 with OrderType

use of org.openmrs.OrderType in project openmrs-core by openmrs.

the class OrderServiceTest method getOrderTypeByConceptClass_shouldGetOrderTypeMappedToTheGivenConceptClass.

/**
 * @see OrderService#getOrderTypeByConceptClass(ConceptClass)
 */
@Test
public void getOrderTypeByConceptClass_shouldGetOrderTypeMappedToTheGivenConceptClass() {
    OrderType orderType = orderService.getOrderTypeByConceptClass(Context.getConceptService().getConceptClass(1));
    Assert.assertNotNull(orderType);
    Assert.assertEquals(2, orderType.getOrderTypeId().intValue());
}
Also used : OrderType(org.openmrs.OrderType) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) OrderUtilTest(org.openmrs.order.OrderUtilTest) Test(org.junit.Test)

Example 7 with OrderType

use of org.openmrs.OrderType in project openmrs-core by openmrs.

the class OrderServiceTest method getOrderType_shouldReturnNullIfNoOrderTypeObjectFoundWithGivenId.

/**
 * @see OrderService#getOrderType(Integer)
 */
@Test
public void getOrderType_shouldReturnNullIfNoOrderTypeObjectFoundWithGivenId() {
    OrderType orderType = orderService.getOrderType(1000);
    assertNull(orderType);
}
Also used : OrderType(org.openmrs.OrderType) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) OrderUtilTest(org.openmrs.order.OrderUtilTest) Test(org.junit.Test)

Example 8 with OrderType

use of org.openmrs.OrderType in project openmrs-core by openmrs.

the class OrderServiceTest method getActiveOrders_shouldIncludeOrdersForSubTypesIfOrderTypeIsSpecified.

/**
 * @see OrderService#getActiveOrders(org.openmrs.Patient, org.openmrs.OrderType,
 *      org.openmrs.CareSetting, java.util.Date)
 */
@Test
public void getActiveOrders_shouldIncludeOrdersForSubTypesIfOrderTypeIsSpecified() {
    executeDataSet("org/openmrs/api/include/OrderServiceTest-otherOrders.xml");
    Patient patient = Context.getPatientService().getPatient(2);
    OrderType testOrderType = orderService.getOrderType(2);
    List<Order> orders = orderService.getActiveOrders(patient, testOrderType, null, null);
    assertEquals(5, orders.size());
    Order[] expectedOrder1 = { orderService.getOrder(7), orderService.getOrder(101), orderService.getOrder(102), orderService.getOrder(103), orderService.getOrder(104) };
    assertThat(orders, hasItems(expectedOrder1));
    OrderType labTestOrderType = orderService.getOrderType(7);
    orders = orderService.getActiveOrders(patient, labTestOrderType, null, null);
    assertEquals(3, orders.size());
    Order[] expectedOrder2 = { orderService.getOrder(101), orderService.getOrder(103), orderService.getOrder(104) };
    assertThat(orders, hasItems(expectedOrder2));
}
Also used : DrugOrder(org.openmrs.DrugOrder) TestOrder(org.openmrs.TestOrder) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Order(org.openmrs.Order) OrderType(org.openmrs.OrderType) Patient(org.openmrs.Patient) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) OrderUtilTest(org.openmrs.order.OrderUtilTest) Test(org.junit.Test)

Example 9 with OrderType

use of org.openmrs.OrderType in project openmrs-core by openmrs.

the class OrderServiceTest method retireOrderType_shouldRetireOrderType.

/**
 * @see OrderService#retireOrderType(org.openmrs.OrderType, String)
 */
@Test
public void retireOrderType_shouldRetireOrderType() {
    OrderType orderType = orderService.getOrderType(15);
    assertFalse(orderType.getRetired());
    assertNull(orderType.getRetiredBy());
    assertNull(orderType.getRetireReason());
    assertNull(orderType.getDateRetired());
    orderService.retireOrderType(orderType, "Retire for testing purposes");
    orderType = orderService.getOrderType(15);
    assertTrue(orderType.getRetired());
    assertNotNull(orderType.getRetiredBy());
    assertNotNull(orderType.getRetireReason());
    assertNotNull(orderType.getDateRetired());
}
Also used : OrderType(org.openmrs.OrderType) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) OrderUtilTest(org.openmrs.order.OrderUtilTest) Test(org.junit.Test)

Example 10 with OrderType

use of org.openmrs.OrderType in project openmrs-core by openmrs.

the class OrderServiceTest method getOrderTypeByUuid_shouldFindOrderTypeObjectGivenValidUuid.

/**
 * @see OrderService#getOrderTypeByUuid(String)
 */
@Test
public void getOrderTypeByUuid_shouldFindOrderTypeObjectGivenValidUuid() {
    OrderType orderType = orderService.getOrderTypeByUuid("131168f4-15f5-102d-96e4-000c29c2a5d7");
    assertEquals("Drug order", orderType.getName());
}
Also used : OrderType(org.openmrs.OrderType) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) OrderUtilTest(org.openmrs.order.OrderUtilTest) Test(org.junit.Test)

Aggregations

OrderType (org.openmrs.OrderType)54 Test (org.junit.Test)46 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)45 OrderUtilTest (org.openmrs.order.OrderUtilTest)29 BindException (org.springframework.validation.BindException)22 Errors (org.springframework.validation.Errors)22 Patient (org.openmrs.Patient)17 DrugOrder (org.openmrs.DrugOrder)16 CareSetting (org.openmrs.CareSetting)15 Encounter (org.openmrs.Encounter)11 GlobalProperty (org.openmrs.GlobalProperty)8 Order (org.openmrs.Order)8 TestOrder (org.openmrs.TestOrder)6 Matchers.containsInAnyOrder (org.hamcrest.Matchers.containsInAnyOrder)5 ConceptClass (org.openmrs.ConceptClass)5 HashSet (java.util.HashSet)4 Date (java.util.Date)3 ArrayList (java.util.ArrayList)2 Criteria (org.hibernate.Criteria)2 PatientServiceImplTest (org.openmrs.api.impl.PatientServiceImplTest)2