use of org.openmrs.DrugOrder in project openmrs-core by openmrs.
the class DrugOrderValidatorTest method validate_shouldFailValidationIfRouteIsNullForSimpleDosingInstructionsDosingType.
/**
* @see DrugOrderValidator#validate(Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldFailValidationIfRouteIsNullForSimpleDosingInstructionsDosingType() {
DrugOrder order = new DrugOrder();
order.setDosingType(SimpleDosingInstructions.class);
order.setRoute(null);
Errors errors = new BindException(order, "order");
new DrugOrderValidator().validate(order, errors);
Assert.assertTrue(errors.hasFieldErrors("route"));
}
use of org.openmrs.DrugOrder in project openmrs-core by openmrs.
the class DrugOrderValidatorTest method validate_shouldFailValidationIfDoseUnitsIsNullWhenDoseIsPresent.
/**
* @see DrugOrderValidator#validate(Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldFailValidationIfDoseUnitsIsNullWhenDoseIsPresent() {
DrugOrder order = new DrugOrder();
order.setDosingType(FreeTextDosingInstructions.class);
order.setDose(20.0);
order.setDoseUnits(null);
Errors errors = new BindException(order, "order");
new DrugOrderValidator().validate(order, errors);
Assert.assertTrue(errors.hasFieldErrors("doseUnits"));
}
use of org.openmrs.DrugOrder in project openmrs-core by openmrs.
the class DrugOrderValidatorTest method validate_shouldFailIfConceptIsNullAndDrugIsNotSpecified.
/**
* @see DrugOrderValidator#validate(Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldFailIfConceptIsNullAndDrugIsNotSpecified() {
DrugOrder order = new DrugOrder();
Errors errors = new BindException(order, "order");
new DrugOrderValidator().validate(order, errors);
Assert.assertTrue(errors.hasFieldErrors("concept"));
}
use of org.openmrs.DrugOrder in project openmrs-core by openmrs.
the class DrugOrderValidatorTest method saveOrder_shouldPassDrugOrderWithADrugNonCodedWhenDrugOrderIsNonCoded.
@Test
public void saveOrder_shouldPassDrugOrderWithADrugNonCodedWhenDrugOrderIsNonCoded() {
executeDataSet("org/openmrs/api/include/OrderServiceTest-nonCodedDrugs.xml");
Patient patient = Context.getPatientService().getPatient(7);
CareSetting careSetting = Context.getOrderService().getCareSetting(2);
OrderType orderType = Context.getOrderService().getOrderTypeByName("Drug order");
GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_DRUG_ORDER_REQUIRE_DRUG, "true");
Context.getAdministrationService().saveGlobalProperty(gp);
// place drug order
DrugOrder order = new DrugOrder();
Encounter encounter = Context.getEncounterService().getEncounter(3);
order.setEncounter(encounter);
order.setConcept(Context.getOrderService().getNonCodedDrugConcept());
order.setDrugNonCoded("Non coded drug");
order.setPatient(patient);
order.setCareSetting(careSetting);
order.setOrderer(Context.getProviderService().getProvider(1));
order.setDateActivated(encounter.getEncounterDatetime());
order.setOrderType(orderType);
order.setDosingType(FreeTextDosingInstructions.class);
order.setInstructions("None");
order.setDosingInstructions("Test Instruction");
Errors errors = new BindException(order, "order");
new DrugOrderValidator().validate(order, errors);
Assert.assertFalse(errors.hasFieldErrors());
}
use of org.openmrs.DrugOrder in project openmrs-core by openmrs.
the class DrugOrderValidatorTest method validate_shouldPassValidationIfFieldLengthsAreCorrect.
/**
* @see DrugOrderValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldPassValidationIfFieldLengthsAreCorrect() {
DrugOrder order = new DrugOrder();
Encounter encounter = new Encounter();
Patient patient = Context.getPatientService().getPatient(2);
order.setConcept(Context.getConceptService().getConcept(88));
order.setOrderer(Context.getProviderService().getProvider(1));
order.setDosingType(FreeTextDosingInstructions.class);
order.setInstructions("Instructions");
order.setDosingInstructions("Test Instruction");
order.setPatient(patient);
encounter.setPatient(patient);
order.setEncounter(encounter);
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DAY_OF_MONTH) - 1);
order.setDateActivated(cal.getTime());
order.setAutoExpireDate(new Date());
order.setOrderType(Context.getOrderService().getOrderTypeByName("Drug order"));
order.setDrug(Context.getConceptService().getDrug(3));
order.setCareSetting(Context.getOrderService().getCareSetting(1));
order.setQuantity(2.00);
order.setQuantityUnits(Context.getConceptService().getConcept(51));
order.setNumRefills(10);
order.setAsNeededCondition("asNeededCondition");
order.setBrandName("brandName");
Errors errors = new BindException(order, "order");
new DrugOrderValidator().validate(order, errors);
Assert.assertFalse(errors.hasErrors());
}
Aggregations