use of org.openmrs.TestOrder in project openmrs-core by openmrs.
the class OrderServiceTest method saveOrder_shouldPassForADiscontinuationOrderWithNoPreviousOrder.
/**
* @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
*/
@Test
public void saveOrder_shouldPassForADiscontinuationOrderWithNoPreviousOrder() {
TestOrder dcOrder = new TestOrder();
dcOrder.setAction(Action.DISCONTINUE);
dcOrder.setPatient(patientService.getPatient(2));
dcOrder.setCareSetting(orderService.getCareSetting(2));
dcOrder.setConcept(conceptService.getConcept(5089));
dcOrder.setEncounter(encounterService.getEncounter(6));
dcOrder.setOrderer(providerService.getProvider(1));
orderService.saveOrder(dcOrder, null);
}
use of org.openmrs.TestOrder in project openmrs-core by openmrs.
the class OrderServiceTest method saveOrder_shouldSetTheOrderNumberReturnedByTheConfiguredGenerator.
/**
* @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
*/
@Test
public void saveOrder_shouldSetTheOrderNumberReturnedByTheConfiguredGenerator() {
GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GP_ORDER_NUMBER_GENERATOR_BEAN_ID, "orderEntry.OrderNumberGenerator");
Context.getAdministrationService().saveGlobalProperty(gp);
Order order = new TestOrder();
order.setPatient(patientService.getPatient(7));
order.setConcept(conceptService.getConcept(5497));
order.setOrderer(providerService.getProvider(1));
order.setCareSetting(orderService.getCareSetting(1));
order.setOrderType(orderService.getOrderType(2));
order.setEncounter(encounterService.getEncounter(3));
order.setDateActivated(new Date());
order = orderService.saveOrder(order, null);
assertTrue(order.getOrderNumber().startsWith(TimestampOrderNumberGenerator.ORDER_NUMBER_PREFIX));
}
use of org.openmrs.TestOrder in project openmrs-core by openmrs.
the class OrderServiceTest method saveOrder_shouldSaveRevisionOrderScheduledOnDateNotOverlappingWithAnActiveOrderForTheSameConceptAndCareSetting.
/**
* @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
*/
@Test
@Ignore("Ignored because it fails after removal of deprecated methods TRUNK-4772")
public void saveOrder_shouldSaveRevisionOrderScheduledOnDateNotOverlappingWithAnActiveOrderForTheSameConceptAndCareSetting() {
// sanity check that we have an active order
final Patient patient = patientService.getPatient(2);
final Concept cd4Count = conceptService.getConcept(5497);
TestOrder activeOrder = new TestOrder();
activeOrder.setPatient(patient);
activeOrder.setConcept(cd4Count);
activeOrder.setEncounter(encounterService.getEncounter(6));
activeOrder.setOrderer(providerService.getProvider(1));
activeOrder.setCareSetting(orderService.getCareSetting(2));
activeOrder.setDateActivated(new Date());
activeOrder.setAutoExpireDate(DateUtils.addDays(new Date(), 10));
orderService.saveOrder(activeOrder, null);
// New Drug order in future for same concept
TestOrder secondOrder = new TestOrder();
secondOrder.setPatient(activeOrder.getPatient());
secondOrder.setConcept(activeOrder.getConcept());
secondOrder.setEncounter(encounterService.getEncounter(6));
secondOrder.setOrderer(providerService.getProvider(1));
secondOrder.setCareSetting(activeOrder.getCareSetting());
secondOrder.setDateActivated(new Date());
secondOrder.setScheduledDate(DateUtils.addDays(activeOrder.getEffectiveStopDate(), 1));
secondOrder.setUrgency(Order.Urgency.ON_SCHEDULED_DATE);
orderService.saveOrder(secondOrder, null);
// Revise Second Order to have scheduled date not overlapping with active order
TestOrder revision = secondOrder.cloneForRevision();
revision.setScheduledDate(DateUtils.addDays(activeOrder.getEffectiveStopDate(), 2));
revision.setEncounter(encounterService.getEncounter(6));
revision.setOrderer(providerService.getProvider(1));
Order savedRevisionOrder = orderService.saveOrder(revision, null);
assertNotNull(orderService.getOrder(savedRevisionOrder.getOrderId()));
}
use of org.openmrs.TestOrder in project openmrs-core by openmrs.
the class OrderServiceTest method saveOrder_shouldSetOrderTypeIfNullButMappedToTheConceptClass.
/**
* @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
*/
@Test
public void saveOrder_shouldSetOrderTypeIfNullButMappedToTheConceptClass() {
TestOrder order = new TestOrder();
order.setPatient(patientService.getPatient(7));
order.setConcept(conceptService.getConcept(5497));
order.setOrderer(providerService.getProvider(1));
order.setCareSetting(orderService.getCareSetting(1));
order.setEncounter(encounterService.getEncounter(3));
order.setDateActivated(new Date());
orderService.saveOrder(order, null);
assertEquals(2, order.getOrderType().getOrderTypeId().intValue());
}
use of org.openmrs.TestOrder in project openmrs-core by openmrs.
the class OrderServiceTest method saveOrder_shouldPassForRevisionOrderIfAnActiveTestOrderForTheSameConceptAndCareSettingsExists.
/**
* settings exists
* @see OrderService#saveOrder(Order, OrderContext)
*/
@Test
@Ignore("Ignored because it fails after removal of deprecated methods TRUNK-4772")
public void saveOrder_shouldPassForRevisionOrderIfAnActiveTestOrderForTheSameConceptAndCareSettingsExists() {
final Patient patient = patientService.getPatient(2);
final Concept cd4Count = conceptService.getConcept(5497);
TestOrder activeOrder = new TestOrder();
activeOrder.setPatient(patient);
activeOrder.setConcept(cd4Count);
activeOrder.setEncounter(encounterService.getEncounter(6));
activeOrder.setOrderer(providerService.getProvider(1));
activeOrder.setCareSetting(orderService.getCareSetting(2));
activeOrder.setDateActivated(new Date());
activeOrder.setAutoExpireDate(DateUtils.addDays(new Date(), 10));
orderService.saveOrder(activeOrder, null);
// New order in future for same concept
TestOrder secondOrder = new TestOrder();
secondOrder.setPatient(activeOrder.getPatient());
secondOrder.setConcept(activeOrder.getConcept());
secondOrder.setEncounter(encounterService.getEncounter(6));
secondOrder.setOrderer(providerService.getProvider(1));
secondOrder.setCareSetting(activeOrder.getCareSetting());
secondOrder.setDateActivated(new Date());
secondOrder.setScheduledDate(DateUtils.addDays(activeOrder.getEffectiveStopDate(), 1));
secondOrder.setUrgency(Order.Urgency.ON_SCHEDULED_DATE);
orderService.saveOrder(secondOrder, null);
// Revise second order to have scheduled date overlapping with active order
TestOrder revision = secondOrder.cloneForRevision();
revision.setScheduledDate(DateUtils.addDays(activeOrder.getEffectiveStartDate(), 2));
revision.setEncounter(encounterService.getEncounter(6));
revision.setOrderer(providerService.getProvider(1));
Order savedSecondOrder = orderService.saveOrder(revision, null);
assertNotNull(orderService.getOrder(savedSecondOrder.getOrderId()));
}
Aggregations