use of org.openmrs.TestOrder in project openmrs-core by openmrs.
the class OrderServiceTest method saveOrder_shouldNotChangeTheAutoExpireDateIfItHasATimeComponent.
/**
* @throws ParseException
* @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
*/
@Test
public void saveOrder_shouldNotChangeTheAutoExpireDateIfItHasATimeComponent() throws ParseException {
Order order = new TestOrder();
order.setPatient(patientService.getPatient(2));
order.setCareSetting(orderService.getCareSetting(2));
order.setConcept(conceptService.getConcept(5089));
order.setEncounter(encounterService.getEncounter(6));
order.setOrderer(providerService.getProvider(1));
order.setDateActivated(new Date());
DateFormat dateformat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
order.setDateActivated(dateformat.parse("14/08/2014 10:00:00"));
Date autoExpireDate = dateformat.parse("18/08/2014 10:00:00");
order.setAutoExpireDate(autoExpireDate);
orderService.saveOrder(order, null);
assertEquals(autoExpireDate, order.getAutoExpireDate());
}
use of org.openmrs.TestOrder in project openmrs-core by openmrs.
the class OrderServiceTest method saveOrder_shouldSetOrderTypeOfTestOrderToTestOrderIfNotSetAndConceptNotMapped.
/**
* @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
*/
@Test
public void saveOrder_shouldSetOrderTypeOfTestOrderToTestOrderIfNotSetAndConceptNotMapped() {
TestOrder testOrder = new TestOrder();
testOrder.setPatient(patientService.getPatient(7));
Concept unmappedConcept = conceptService.getConcept(113);
Assert.assertNull(orderService.getOrderTypeByConcept(unmappedConcept));
testOrder.setConcept(unmappedConcept);
testOrder.setOrderer(providerService.getProvider(1));
testOrder.setCareSetting(orderService.getCareSetting(1));
Encounter encounter = encounterService.getEncounter(3);
testOrder.setEncounter(encounter);
testOrder.setDateActivated(encounter.getEncounterDatetime());
testOrder.setClinicalHistory("Patient had a negative reaction to the test in the past");
testOrder.setFrequency(orderService.getOrderFrequency(3));
testOrder.setSpecimenSource(conceptService.getConcept(22));
testOrder.setNumberOfRepeats(3);
orderService.saveOrder(testOrder, null);
Assert.assertNotNull(testOrder.getOrderType());
Assert.assertEquals(orderService.getOrderTypeByUuid(OrderType.TEST_ORDER_TYPE_UUID), testOrder.getOrderType());
}
use of org.openmrs.TestOrder in project openmrs-core by openmrs.
the class OrderServiceTest method saveOrder_shouldPassIfAnActiveTestOrderForTheSameConceptAndCareSettingExists.
/**
* @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
*/
@Test
public void saveOrder_shouldPassIfAnActiveTestOrderForTheSameConceptAndCareSettingExists() {
final Patient patient = patientService.getPatient(2);
final Concept cd4Count = conceptService.getConcept(5497);
// sanity check that we have an active order for the same concept
TestOrder duplicateOrder = (TestOrder) orderService.getOrder(7);
assertTrue(duplicateOrder.isActive());
assertEquals(cd4Count, duplicateOrder.getConcept());
Order order = new TestOrder();
order.setPatient(patient);
order.setCareSetting(orderService.getCareSetting(2));
order.setConcept(cd4Count);
order.setEncounter(encounterService.getEncounter(6));
order.setOrderer(providerService.getProvider(1));
order.setCareSetting(duplicateOrder.getCareSetting());
Order savedOrder = orderService.saveOrder(order, null);
assertNotNull(orderService.getOrder(savedOrder.getOrderId()));
}
use of org.openmrs.TestOrder in project openmrs-core by openmrs.
the class OrderServiceTest method saveOrder_shouldPassIfAnActiveOrderForTheSameConceptExistsInADifferentCareSetting.
/**
* @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
*/
@Test
public void saveOrder_shouldPassIfAnActiveOrderForTheSameConceptExistsInADifferentCareSetting() {
final Patient patient = patientService.getPatient(2);
final Concept cd4Count = conceptService.getConcept(5497);
TestOrder duplicateOrder = (TestOrder) orderService.getOrder(7);
final CareSetting inpatient = orderService.getCareSetting(2);
assertNotEquals(inpatient, duplicateOrder.getCareSetting());
assertTrue(duplicateOrder.isActive());
assertEquals(cd4Count, duplicateOrder.getConcept());
int initialActiveOrderCount = orderService.getActiveOrders(patient, null, null, null).size();
TestOrder order = new TestOrder();
order.setPatient(patient);
order.setCareSetting(orderService.getCareSetting(2));
order.setConcept(cd4Count);
order.setEncounter(encounterService.getEncounter(6));
order.setOrderer(providerService.getProvider(1));
order.setCareSetting(inpatient);
orderService.saveOrder(order, null);
List<Order> activeOrders = orderService.getActiveOrders(patient, null, null, null);
assertEquals(++initialActiveOrderCount, activeOrders.size());
}
use of org.openmrs.TestOrder in project openmrs-core by openmrs.
the class OrderServiceTest method saveOrder_shouldRollTheAutoExpireDateToTheEndOfTheDayIfItHasNoTimeComponent.
/**
* @throws ParseException
* @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
*/
@Test
public void saveOrder_shouldRollTheAutoExpireDateToTheEndOfTheDayIfItHasNoTimeComponent() throws ParseException {
Order order = new TestOrder();
order.setPatient(patientService.getPatient(2));
order.setCareSetting(orderService.getCareSetting(2));
order.setConcept(conceptService.getConcept(5089));
order.setEncounter(encounterService.getEncounter(6));
order.setOrderer(providerService.getProvider(1));
DateFormat dateformat = new SimpleDateFormat("dd/MM/yyyy");
order.setDateActivated(dateformat.parse("14/08/2014"));
order.setAutoExpireDate(dateformat.parse("18/08/2014"));
orderService.saveOrder(order, null);
dateformat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss.S");
assertEquals(dateformat.parse("18/08/2014 23:59:59.000"), order.getAutoExpireDate());
}
Aggregations