use of org.openmrs.OrderType in project openmrs-core by openmrs.
the class OrderServiceTest method saveOrderType_shouldAddANewOrderTypeToTheDatabase.
/**
* @see OrderService#saveOrderType(org.openmrs.OrderType)
*/
@Test
public void saveOrderType_shouldAddANewOrderTypeToTheDatabase() {
int orderTypeCount = orderService.getOrderTypes(true).size();
OrderType orderType = new OrderType();
orderType.setName("New Order");
orderType.setJavaClassName("org.openmrs.NewTestOrder");
orderType.setDescription("New order type for testing");
orderType.setRetired(false);
orderType = orderService.saveOrderType(orderType);
assertNotNull(orderType);
assertEquals("New Order", orderType.getName());
assertNotNull(orderType.getId());
assertEquals((orderTypeCount + 1), orderService.getOrderTypes(true).size());
}
use of org.openmrs.OrderType 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());
}
use of org.openmrs.OrderType in project openmrs-core by openmrs.
the class OrderServiceTest method saveOrder_shouldFailIfTheOrderTypeOfThePreviousOrderDoesNotMatch.
/**
* @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
*/
@Test
public void saveOrder_shouldFailIfTheOrderTypeOfThePreviousOrderDoesNotMatch() {
Order order = orderService.getOrder(7);
assertTrue(OrderUtilTest.isActiveOrder(order, null));
Order discontinuationOrder = order.cloneForDiscontinuing();
OrderType orderType = orderService.getOrderType(7);
assertNotEquals(discontinuationOrder.getOrderType(), orderType);
assertTrue(OrderUtil.isType(discontinuationOrder.getOrderType(), orderType));
discontinuationOrder.setOrderType(orderType);
discontinuationOrder.setOrderer(Context.getProviderService().getProvider(1));
discontinuationOrder.setEncounter(Context.getEncounterService().getEncounter(6));
expectedException.expect(EditedOrderDoesNotMatchPreviousException.class);
expectedException.expectMessage(mss.getMessage("Order.type.doesnot.match"));
orderService.saveOrder(discontinuationOrder, null);
}
use of org.openmrs.OrderType 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());
}
Aggregations