use of org.openmrs.Order in project openmrs-core by openmrs.
the class OrderServiceTest method getDiscontinuationOrder_shouldReturnNullIfOrderHasNotBeenDiscontinued.
/**
* @see OrderService#getDiscontinuationOrder(Order)
*/
@Test
public void getDiscontinuationOrder_shouldReturnNullIfOrderHasNotBeenDiscontinued() {
Order order = orderService.getOrder(111);
Order discontinuationOrder = orderService.getDiscontinuationOrder(order);
assertThat(discontinuationOrder, is(nullValue()));
}
use of org.openmrs.Order in project openmrs-core by openmrs.
the class OrderServiceTest method getActiveOrders_shouldReturnAllOrdersIfNoOrderTypeIsSpecified.
/**
* @see OrderService#getActiveOrders(org.openmrs.Patient, org.openmrs.OrderType,
* org.openmrs.CareSetting, java.util.Date)
*/
@Test
public void getActiveOrders_shouldReturnAllOrdersIfNoOrderTypeIsSpecified() {
Patient patient = Context.getPatientService().getPatient(2);
List<Order> orders = orderService.getActiveOrders(patient, null, null, null);
assertEquals(5, orders.size());
Order[] expectedOrders = { orderService.getOrder(222), 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 OrderValidatorTest method validate_shouldFailValidationIfDateActivatedAfterAutoExpireDate.
/**
* @see OrderValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfDateActivatedAfterAutoExpireDate() {
Order order = new Order();
order.setConcept(Context.getConceptService().getConcept(88));
order.setPatient(Context.getPatientService().getPatient(2));
order.setOrderer(Context.getProviderService().getProvider(1));
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DAY_OF_MONTH) - 1);
order.setDateActivated(new Date());
order.setAutoExpireDate(cal.getTime());
Errors errors = new BindException(order, "order");
new OrderValidator().validate(order, errors);
Assert.assertTrue(errors.hasFieldErrors("dateActivated"));
Assert.assertTrue(errors.hasFieldErrors("autoExpireDate"));
}
use of org.openmrs.Order in project openmrs-core by openmrs.
the class OrderValidatorTest method validate_shouldFailValidationIfScheduledDateIsSetAndUrgencyIsNotSetAsON_SCHEDULED_DATE.
/**
* @see OrderValidator#validate(Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldFailValidationIfScheduledDateIsSetAndUrgencyIsNotSetAsON_SCHEDULED_DATE() {
Order order = new Order();
order.setConcept(Context.getConceptService().getConcept(88));
order.setPatient(Context.getPatientService().getPatient(2));
order.setOrderer(Context.getProviderService().getProvider(1));
order.setScheduledDate(new Date());
order.setUrgency(Order.Urgency.ROUTINE);
Errors errors = new BindException(order, "order");
new OrderValidator().validate(order, errors);
Assert.assertTrue(errors.hasFieldErrors("urgency"));
order.setScheduledDate(new Date());
order.setUrgency(Order.Urgency.ON_SCHEDULED_DATE);
errors = new BindException(order, "order");
new OrderValidator().validate(order, errors);
Assert.assertFalse(errors.hasFieldErrors("urgency"));
}
use of org.openmrs.Order in project openmrs-core by openmrs.
the class OrderValidatorTest method validate_shouldFailValidationIfEncounterIsNull.
/**
* @see OrderValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfEncounterIsNull() {
Order order = new Order();
order.setConcept(Context.getConceptService().getConcept(88));
order.setPatient(Context.getPatientService().getPatient(2));
order.setEncounter(null);
Errors errors = new BindException(order, "order");
new OrderValidator().validate(order, errors);
Assert.assertTrue(errors.hasFieldErrors("encounter"));
}
Aggregations