use of org.openmrs.OrderType in project openmrs-core by openmrs.
the class OrderTypeValidatorTest method validate_shouldPassIfAllFieldsAreCorrectForAnExistingOrderType.
/**
* @see OrderTypeValidator#validate(Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldPassIfAllFieldsAreCorrectForAnExistingOrderType() {
OrderType orderType = orderService.getOrderType(1);
assertNotNull(orderType);
Errors errors = new BindException(orderType, "orderType");
new OrderTypeValidator().validate(orderType, errors);
Assert.assertFalse(errors.hasErrors());
}
use of org.openmrs.OrderType in project openmrs-core by openmrs.
the class OrderTypeValidatorTest method validate_shouldFailIfNameIsWhitespace.
/**
* @see OrderTypeValidator#validate(Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldFailIfNameIsWhitespace() {
OrderType orderType = new OrderType();
orderType.setName("");
Errors errors = new BindException(orderType, "orderType");
new OrderTypeValidator().validate(orderType, errors);
Assert.assertEquals(true, errors.hasFieldErrors("name"));
}
use of org.openmrs.OrderType in project openmrs-core by openmrs.
the class OrderTypeValidatorTest method validate_shouldFailIfParentIsAmongItsDescendants.
/**
* @see OrderTypeValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailIfParentIsAmongItsDescendants() {
OrderType orderType = orderService.getOrderType(2);
OrderType descendant = orderService.getOrderType(9);
Assert.assertTrue(descendant.getParent().getParent().equals(orderType));
orderType.setParent(descendant);
Errors errors = new BindException(orderType, "orderType");
new OrderTypeValidator().validate(orderType, errors);
Assert.assertEquals(true, errors.hasFieldErrors("parent"));
}
use of org.openmrs.OrderType in project openmrs-core by openmrs.
the class PatientServiceTest method hasActiveOrderOfType.
private boolean hasActiveOrderOfType(Patient patient, String orderTypeName) {
OrderType drugOrder = Context.getOrderService().getOrderTypeByName(orderTypeName);
List<Order> preferredPatientOrders = Context.getOrderService().getAllOrdersByPatient(patient).stream().filter(Order::isActive).filter(order -> Objects.equals(drugOrder, order.getOrderType())).collect(Collectors.toList());
return !preferredPatientOrders.isEmpty();
}
use of org.openmrs.OrderType in project openmrs-core by openmrs.
the class PatientServiceTest method mergePatients_shouldNotFailIfMultiplePatientsHaveActiveOrderOfDifferentTypes.
/**
* @see PatientService#mergePatients(org.openmrs.Patient, org.openmrs.Patient)
*/
@Test
public void mergePatients_shouldNotFailIfMultiplePatientsHaveActiveOrderOfDifferentTypes() throws Exception {
Patient preferredPatient = patientService.getPatient(2);
Patient notPreferredPatient = patientService.getPatient(7);
OrderType DrugOrder = Context.getOrderService().getOrderTypeByName("Drug order");
voidOrdersForType(Collections.singleton(preferredPatient), DrugOrder);
assertFalse("Test pre-request: No Active Drug order in " + preferredPatient, hasActiveOrderOfType(preferredPatient, "Drug order"));
assertTrue("Test pre-request: At least one Active Test order in " + preferredPatient, hasActiveOrderOfType(preferredPatient, "Test order"));
assertTrue("Test pre-request: At least one Active Drug order in " + notPreferredPatient, hasActiveOrderOfType(notPreferredPatient, "Drug order"));
assertFalse("Test pre-request: No Active Test order in " + notPreferredPatient, hasActiveOrderOfType(notPreferredPatient, "Test order"));
patientService.mergePatients(preferredPatient, notPreferredPatient);
}
Aggregations