use of org.openmrs.Order in project openmrs-core by openmrs.
the class OrderValidatorTest method validate_shouldFailValidationIfUrgencyIsNull.
/**
* @see OrderValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfUrgencyIsNull() {
Order order = new Order();
order.setConcept(Context.getConceptService().getConcept(88));
order.setPatient(Context.getPatientService().getPatient(2));
order.setUrgency(null);
Errors errors = new BindException(order, "order");
new OrderValidator().validate(order, errors);
Assert.assertTrue(errors.hasFieldErrors("urgency"));
}
use of org.openmrs.Order in project openmrs-core by openmrs.
the class OrderValidatorTest method validate_shouldFailValidationIfActionIsNull.
/**
* @see OrderValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfActionIsNull() {
Order order = new Order();
order.setConcept(Context.getConceptService().getConcept(88));
order.setPatient(Context.getPatientService().getPatient(2));
order.setAction(null);
Errors errors = new BindException(order, "order");
new OrderValidator().validate(order, errors);
Assert.assertTrue(errors.hasFieldErrors("action"));
}
use of org.openmrs.Order in project openmrs-core by openmrs.
the class OrderValidatorTest method validate_shouldFailValidationIfDateActivatedIsBeforeEncountersEncounterDatetime.
/**
* @see OrderValidator#validate(Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldFailValidationIfDateActivatedIsBeforeEncountersEncounterDatetime() {
Date encounterDate = new Date();
Date orderDate = DateUtils.addDays(encounterDate, -1);
Encounter encounter = Context.getEncounterService().getEncounter(3);
encounter.setEncounterDatetime(encounterDate);
Order order = new Order();
order.setDateActivated(orderDate);
order.setConcept(Context.getConceptService().getConcept(88));
order.setPatient(Context.getPatientService().getPatient(2));
order.setEncounter(encounter);
order.setOrderer(Context.getProviderService().getProvider(1));
Errors errors = new BindException(order, "order");
new OrderValidator().validate(order, errors);
Assert.assertTrue(errors.hasFieldErrors("dateActivated"));
}
use of org.openmrs.Order in project openmrs-core by openmrs.
the class OrderValidatorTest method validate_shouldFailValidationIfOrdererIsNull.
/**
* @see OrderValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfOrdererIsNull() {
Order order = new Order();
order.setConcept(Context.getConceptService().getConcept(88));
order.setPatient(Context.getPatientService().getPatient(2));
Errors errors = new BindException(order, "order");
new OrderValidator().validate(order, errors);
Assert.assertFalse(errors.hasFieldErrors("discontinued"));
Assert.assertFalse(errors.hasFieldErrors("concept"));
Assert.assertTrue(errors.hasFieldErrors("orderer"));
Assert.assertFalse(errors.hasFieldErrors("patient"));
}
use of org.openmrs.Order in project openmrs-core by openmrs.
the class OrderServiceImpl method ensureCareSettingIsSet.
private void ensureCareSettingIsSet(Order order, OrderContext orderContext) {
if (order.getCareSetting() != null) {
return;
}
CareSetting careSetting = null;
if (orderContext != null) {
careSetting = orderContext.getCareSetting();
}
Order previousOrder = order.getPreviousOrder();
if (careSetting == null || (previousOrder != null && !careSetting.equals(previousOrder.getCareSetting()))) {
throw new OrderEntryException("Order.care.cannot.determine");
}
order.setCareSetting(careSetting);
}
Aggregations