use of org.openmrs.CareSetting in project openmrs-core by openmrs.
the class DrugOrderValidatorTest method validate_shouldFailIfDurationUnitsHasNoMappingToSNOMEDCTSource.
/**
* @see DrugOrderValidator#validate(Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldFailIfDurationUnitsHasNoMappingToSNOMEDCTSource() {
Patient patient = Context.getPatientService().getPatient(7);
CareSetting careSetting = Context.getOrderService().getCareSetting(2);
OrderType orderType = Context.getOrderService().getOrderTypeByName("Drug order");
// place drug order
DrugOrder order = new DrugOrder();
Encounter encounter = Context.getEncounterService().getEncounter(3);
order.setEncounter(encounter);
ConceptService cs = Context.getConceptService();
order.setConcept(cs.getConcept(5497));
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");
order.setDuration(20);
order.setDurationUnits(cs.getConcept(28));
Errors errors = new BindException(order, "order");
new DrugOrderValidator().validate(order, errors);
assertEquals("DrugOrder.error.durationUnitsNotMappedToSnomedCtDurationCode", errors.getFieldError("durationUnits").getCode());
}
use of org.openmrs.CareSetting 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.CareSetting in project openmrs-core by openmrs.
the class DrugOrderValidatorTest method saveOrder_shouldPassDrugOrderWithNeitherDrugNonCodedNorDrugAreSetForDrugOrderWhenDrugRequiredISNotSet.
@Test
public void saveOrder_shouldPassDrugOrderWithNeitherDrugNonCodedNorDrugAreSetForDrugOrderWhenDrugRequiredISNotSet() {
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, "false");
Context.getAdministrationService().saveGlobalProperty(gp);
// place drug order
DrugOrder order = new DrugOrder();
Encounter encounter = Context.getEncounterService().getEncounter(3);
order.setEncounter(encounter);
order.setPatient(patient);
order.setCareSetting(careSetting);
order.setConcept(Context.getOrderService().getNonCodedDrugConcept());
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.CareSetting in project openmrs-core by openmrs.
the class OrderServiceTest method getOrders_shouldGetAllUnvoidedMatchesIfIncludeVoidedIsSetToFalse.
/**
* @see OrderService#getOrders(org.openmrs.Patient, org.openmrs.CareSetting,
* org.openmrs.OrderType, boolean)
*/
@Test
public void getOrders_shouldGetAllUnvoidedMatchesIfIncludeVoidedIsSetToFalse() {
Patient patient = patientService.getPatient(2);
CareSetting outPatient = orderService.getCareSetting(1);
OrderType testOrderType = orderService.getOrderType(2);
assertEquals(3, orderService.getOrders(patient, outPatient, testOrderType, false).size());
}
use of org.openmrs.CareSetting in project openmrs-core by openmrs.
the class OrderServiceTest method discontinueOrder_shouldRejectAFutureDiscontinueDate.
/**
* @see OrderService#discontinueOrder(org.openmrs.Order, org.openmrs.Concept, java.util.Date,
* org.openmrs.Provider, org.openmrs.Encounter)
*/
@Test
public void discontinueOrder_shouldRejectAFutureDiscontinueDate() {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.HOUR_OF_DAY, 1);
Patient patient = Context.getPatientService().getPatient(2);
CareSetting careSetting = orderService.getCareSetting(1);
Order orderToDiscontinue = orderService.getActiveOrders(patient, null, careSetting, null).get(0);
Encounter encounter = encounterService.getEncounter(3);
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Discontinue date cannot be in the future");
orderService.discontinueOrder(orderToDiscontinue, new Concept(), cal.getTime(), null, encounter);
}
Aggregations