Search in sources :

Example 1 with OrderType

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

the class OrderUtilTest method isType_shouldTrueIfOrderType2IsTheSameOrIsASubtypeOfOrderType1.

/**
 * @see OrderUtil#isType(org.openmrs.OrderType, org.openmrs.OrderType)
 */
@Test
public void isType_shouldTrueIfOrderType2IsTheSameOrIsASubtypeOfOrderType1() {
    OrderType orderType = new OrderType();
    OrderType subType1 = new OrderType();
    OrderType subType2 = new OrderType();
    subType2.setParent(subType1);
    subType1.setParent(orderType);
    assertTrue(OrderUtil.isType(subType2, subType2));
    assertTrue(OrderUtil.isType(subType1, subType2));
    assertTrue(OrderUtil.isType(orderType, subType2));
}
Also used : OrderType(org.openmrs.OrderType) Test(org.junit.Test)

Example 2 with OrderType

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

the class HibernateOrderDAO method getOrderTypeByName.

/**
 * @see OrderDAO#getOrderTypeByName
 */
@Override
public OrderType getOrderTypeByName(String orderTypeName) {
    Criteria criteria = sessionFactory.getCurrentSession().createCriteria(OrderType.class);
    criteria.add(Restrictions.eq("name", orderTypeName));
    return (OrderType) criteria.uniqueResult();
}
Also used : OrderType(org.openmrs.OrderType) Criteria(org.hibernate.Criteria)

Example 3 with OrderType

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

the class OrderServiceTest method getOrderTypeByName_shouldReturnTheOrderTypeThatMatchesTheSpecifiedName.

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

Example 4 with OrderType

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

the class OrderServiceTest method getOrders_shouldIncludeVoidedMatchesIfIncludeVoidedIsSetToTrue.

/**
 * @see OrderService#getOrders(org.openmrs.Patient, org.openmrs.CareSetting,
 *      org.openmrs.OrderType, boolean)
 */
@Test
public void getOrders_shouldIncludeVoidedMatchesIfIncludeVoidedIsSetToTrue() {
    Patient patient = patientService.getPatient(2);
    CareSetting outPatient = orderService.getCareSetting(1);
    OrderType testOrderType = orderService.getOrderType(2);
    assertEquals(4, orderService.getOrders(patient, outPatient, testOrderType, true).size());
}
Also used : OrderType(org.openmrs.OrderType) Patient(org.openmrs.Patient) CareSetting(org.openmrs.CareSetting) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) OrderUtilTest(org.openmrs.order.OrderUtilTest) Test(org.junit.Test)

Example 5 with OrderType

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

the class OrderServiceTest method getOrders_shouldIncludeOrdersForSubTypesIfOrderTypeIsSpecified.

/**
 * @see OrderService#getOrders(org.openmrs.Patient, org.openmrs.CareSetting,
 *      org.openmrs.OrderType, boolean)
 */
@Test
public void getOrders_shouldIncludeOrdersForSubTypesIfOrderTypeIsSpecified() {
    executeDataSet("org/openmrs/api/include/OrderServiceTest-otherOrders.xml");
    Patient patient = patientService.getPatient(2);
    OrderType testOrderType = orderService.getOrderType(2);
    CareSetting outPatient = orderService.getCareSetting(1);
    List<Order> orders = orderService.getOrders(patient, outPatient, testOrderType, false);
    assertEquals(7, orders.size());
    Order[] expectedOrder1 = { orderService.getOrder(6), orderService.getOrder(7), orderService.getOrder(9), orderService.getOrder(101), orderService.getOrder(102), orderService.getOrder(103), orderService.getOrder(104) };
    assertThat(orders, hasItems(expectedOrder1));
    OrderType labTestOrderType = orderService.getOrderType(7);
    orders = orderService.getOrders(patient, outPatient, labTestOrderType, false);
    assertEquals(3, orderService.getOrders(patient, outPatient, labTestOrderType, false).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) CareSetting(org.openmrs.CareSetting) 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