Search in sources :

Example 26 with CareSetting

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

the class OrderServiceTest method getCareSettings_shouldReturnRetiredCareSettingsIfIncludeRetiredIsSetToTrue.

/**
 * @see OrderService#getCareSettings(boolean)
 */
@Test
public void getCareSettings_shouldReturnRetiredCareSettingsIfIncludeRetiredIsSetToTrue() {
    CareSetting retiredCareSetting = orderService.getCareSetting(3);
    assertTrue(retiredCareSetting.getRetired());
    List<CareSetting> careSettings = orderService.getCareSettings(true);
    assertEquals(3, careSettings.size());
    assertTrue(containsId(careSettings, retiredCareSetting.getCareSettingId()));
}
Also used : CareSetting(org.openmrs.CareSetting) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) OrderUtilTest(org.openmrs.order.OrderUtilTest) Test(org.junit.Test)

Example 27 with CareSetting

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

the class OrderServiceTest method saveOrder_shouldDefaultToCareSettingAndOrderTypeDefinedInTheOrderContextIfNull.

/**
 * @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
 */
@Test
public void saveOrder_shouldDefaultToCareSettingAndOrderTypeDefinedInTheOrderContextIfNull() {
    Order order = new TestOrder();
    order.setPatient(patientService.getPatient(7));
    Concept trimune30 = conceptService.getConcept(792);
    order.setConcept(trimune30);
    order.setOrderer(providerService.getProvider(1));
    order.setEncounter(encounterService.getEncounter(3));
    order.setDateActivated(new Date());
    OrderType expectedOrderType = orderService.getOrderType(2);
    CareSetting expectedCareSetting = orderService.getCareSetting(1);
    OrderContext orderContext = new OrderContext();
    orderContext.setOrderType(expectedOrderType);
    orderContext.setCareSetting(expectedCareSetting);
    order = orderService.saveOrder(order, orderContext);
    assertFalse(expectedOrderType.getConceptClasses().contains(trimune30.getConceptClass()));
    assertEquals(expectedOrderType, order.getOrderType());
    assertEquals(expectedCareSetting, order.getCareSetting());
}
Also used : DrugOrder(org.openmrs.DrugOrder) TestOrder(org.openmrs.TestOrder) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Order(org.openmrs.Order) Concept(org.openmrs.Concept) OrderType(org.openmrs.OrderType) TestOrder(org.openmrs.TestOrder) CareSetting(org.openmrs.CareSetting) Date(java.util.Date) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) OrderUtilTest(org.openmrs.order.OrderUtilTest) Test(org.junit.Test)

Example 28 with CareSetting

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

the class OrderServiceTest method getOrders_shouldGetTheOrdersThatMatchAllTheArguments.

/**
 * @see OrderService#getOrders(org.openmrs.Patient, org.openmrs.CareSetting,
 *      org.openmrs.OrderType, boolean)
 */
@Test
public void getOrders_shouldGetTheOrdersThatMatchAllTheArguments() {
    Patient patient = patientService.getPatient(2);
    CareSetting outPatient = orderService.getCareSetting(1);
    OrderType testOrderType = orderService.getOrderType(2);
    List<Order> testOrders = orderService.getOrders(patient, outPatient, testOrderType, false);
    assertEquals(3, testOrders.size());
    TestUtil.containsId(testOrders, 6);
    TestUtil.containsId(testOrders, 7);
    TestUtil.containsId(testOrders, 9);
    OrderType drugOrderType = orderService.getOrderType(1);
    List<Order> drugOrders = orderService.getOrders(patient, outPatient, drugOrderType, false);
    assertEquals(5, drugOrders.size());
    TestUtil.containsId(drugOrders, 2);
    TestUtil.containsId(drugOrders, 3);
    TestUtil.containsId(drugOrders, 44);
    TestUtil.containsId(drugOrders, 444);
    TestUtil.containsId(drugOrders, 5);
    CareSetting inPatient = orderService.getCareSetting(2);
    List<Order> inPatientDrugOrders = orderService.getOrders(patient, inPatient, drugOrderType, false);
    assertEquals(222, inPatientDrugOrders.get(0).getOrderId().intValue());
}
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

CareSetting (org.openmrs.CareSetting)28 Test (org.junit.Test)27 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)27 OrderUtilTest (org.openmrs.order.OrderUtilTest)25 Patient (org.openmrs.Patient)22 DrugOrder (org.openmrs.DrugOrder)21 Encounter (org.openmrs.Encounter)16 OrderType (org.openmrs.OrderType)15 BindException (org.springframework.validation.BindException)14 Errors (org.springframework.validation.Errors)14 TestOrder (org.openmrs.TestOrder)13 Order (org.openmrs.Order)11 Matchers.containsInAnyOrder (org.hamcrest.Matchers.containsInAnyOrder)7 GlobalProperty (org.openmrs.GlobalProperty)7 Date (java.util.Date)6 Concept (org.openmrs.Concept)5 Calendar (java.util.Calendar)4 ConceptService (org.openmrs.api.ConceptService)3 OrderService (org.openmrs.api.OrderService)2 Provider (org.openmrs.Provider)1