use of org.openmrs.Order in project openmrs-core by openmrs.
the class OrderServiceTest method getActiveOrders_shouldReturnAllActiveOrdersForTheSpecifiedPatientAndCareSetting.
/**
* @see OrderService#getActiveOrders(org.openmrs.Patient, org.openmrs.OrderType,
* org.openmrs.CareSetting, java.util.Date)
*/
@Test
public void getActiveOrders_shouldReturnAllActiveOrdersForTheSpecifiedPatientAndCareSetting() {
Patient patient = patientService.getPatient(2);
CareSetting careSetting = orderService.getCareSetting(1);
List<Order> orders = orderService.getActiveOrders(patient, null, careSetting, null);
assertEquals(4, orders.size());
Order[] expectedOrders = { orderService.getOrder(3), orderService.getOrder(444), orderService.getOrder(5), orderService.getOrder(7) };
assertThat(orders, hasItems(expectedOrders));
}
use of org.openmrs.Order in project openmrs-core by openmrs.
the class OrderServiceTest method discontinueOrder_shouldFailForAVoidedOrder.
/**
* @see OrderService#discontinueOrder(org.openmrs.Order, String, java.util.Date,
* org.openmrs.Provider, org.openmrs.Encounter)
*/
@Test
public void discontinueOrder_shouldFailForAVoidedOrder() {
Order orderToDiscontinue = orderService.getOrder(8);
Encounter encounter = encounterService.getEncounter(3);
assertTrue(orderToDiscontinue.getVoided());
expectedException.expect(CannotStopInactiveOrderException.class);
expectedException.expectMessage(mss.getMessage("Order.cannot.discontinue.inactive"));
orderService.discontinueOrder(orderToDiscontinue, "testing", null, null, encounter);
}
use of org.openmrs.Order in project openmrs-core by openmrs.
the class OrderServiceTest method unvoidOrder_shouldStopThePreviousOrderIfTheSpecifiedOrderIsADiscontinuation.
/**
* @see OrderService#unvoidOrder(org.openmrs.Order)
*/
@Test
public void unvoidOrder_shouldStopThePreviousOrderIfTheSpecifiedOrderIsADiscontinuation() {
Order order = orderService.getOrder(22);
assertEquals(Action.DISCONTINUE, order.getAction());
Order previousOrder = order.getPreviousOrder();
assertNotNull(previousOrder.getDateStopped());
assertFalse(order.getVoided());
// void the DC order for testing purposes so we can unvoid it later
orderService.voidOrder(order, "None");
Context.flushSession();
assertTrue(order.getVoided());
assertNull(previousOrder.getDateStopped());
orderService.unvoidOrder(order);
Context.flushSession();
assertFalse(order.getVoided());
assertNotNull(previousOrder.getDateStopped());
}
use of org.openmrs.Order in project openmrs-core by openmrs.
the class OrderServiceTest method voidOrder_shouldVoidAnOrder.
/**
* @see OrderService#voidOrder(org.openmrs.Order, String)
*/
@Test
public void voidOrder_shouldVoidAnOrder() {
Order order = orderService.getOrder(1);
assertFalse(order.getVoided());
assertNull(order.getDateVoided());
assertNull(order.getVoidedBy());
assertNull(order.getVoidReason());
orderService.voidOrder(order, "None");
assertTrue(order.getVoided());
assertNotNull(order.getDateVoided());
assertNotNull(order.getVoidedBy());
assertNotNull(order.getVoidReason());
}
use of org.openmrs.Order in project openmrs-core by openmrs.
the class OrderServiceTest method saveOrder_shouldFailIfConceptInPreviousOrderDoesNotMatchThisConcept.
/**
* @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
*/
@Test
public void saveOrder_shouldFailIfConceptInPreviousOrderDoesNotMatchThisConcept() {
Order previousOrder = orderService.getOrder(7);
assertTrue(OrderUtilTest.isActiveOrder(previousOrder, null));
Order order = previousOrder.cloneForDiscontinuing();
order.setDateActivated(new Date());
order.setOrderReasonNonCoded("Discontinue this");
order.setEncounter(encounterService.getEncounter(6));
order.setOrderer(providerService.getProvider(1));
Concept newConcept = conceptService.getConcept(5089);
assertFalse(previousOrder.getConcept().equals(newConcept));
order.setConcept(newConcept);
expectedException.expect(EditedOrderDoesNotMatchPreviousException.class);
expectedException.expectMessage("The orderable of the previous order and the new one order don't match");
orderService.saveOrder(order, null);
}
Aggregations