use of org.openmrs.Patient 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.Patient 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()));
}
use of org.openmrs.Patient in project openmrs-core by openmrs.
the class OrderServiceTest method getOrders_shouldIncludeOrdersForSubTypesIfOrderTypeIsSpecified.
/**
* @see OrderService#getOrders(org.openmrs.Patient, org.openmrs.CareSetting,
* org.openmrs.OrderType, boolean)
*/
@Test
public void getOrders_shouldIncludeOrdersForSubTypesIfOrderTypeIsSpecified() {
executeDataSet("org/openmrs/api/include/OrderServiceTest-otherOrders.xml");
Patient patient = patientService.getPatient(2);
OrderType testOrderType = orderService.getOrderType(2);
CareSetting outPatient = orderService.getCareSetting(1);
List<Order> orders = orderService.getOrders(patient, outPatient, testOrderType, false);
assertEquals(7, orders.size());
Order[] expectedOrder1 = { orderService.getOrder(6), orderService.getOrder(7), orderService.getOrder(9), orderService.getOrder(101), orderService.getOrder(102), orderService.getOrder(103), orderService.getOrder(104) };
assertThat(orders, hasItems(expectedOrder1));
OrderType labTestOrderType = orderService.getOrderType(7);
orders = orderService.getOrders(patient, outPatient, labTestOrderType, false);
assertEquals(3, orderService.getOrders(patient, outPatient, labTestOrderType, false).size());
Order[] expectedOrder2 = { orderService.getOrder(101), orderService.getOrder(103), orderService.getOrder(104) };
assertThat(orders, hasItems(expectedOrder2));
}
use of org.openmrs.Patient in project openmrs-core by openmrs.
the class OrderServiceTest method getActiveOrders_shouldIncludeOrdersForSubTypesIfOrderTypeIsSpecified.
/**
* @see OrderService#getActiveOrders(org.openmrs.Patient, org.openmrs.OrderType,
* org.openmrs.CareSetting, java.util.Date)
*/
@Test
public void getActiveOrders_shouldIncludeOrdersForSubTypesIfOrderTypeIsSpecified() {
executeDataSet("org/openmrs/api/include/OrderServiceTest-otherOrders.xml");
Patient patient = Context.getPatientService().getPatient(2);
OrderType testOrderType = orderService.getOrderType(2);
List<Order> orders = orderService.getActiveOrders(patient, testOrderType, null, null);
assertEquals(5, orders.size());
Order[] expectedOrder1 = { orderService.getOrder(7), orderService.getOrder(101), orderService.getOrder(102), orderService.getOrder(103), orderService.getOrder(104) };
assertThat(orders, hasItems(expectedOrder1));
OrderType labTestOrderType = orderService.getOrderType(7);
orders = orderService.getActiveOrders(patient, labTestOrderType, null, null);
assertEquals(3, orders.size());
Order[] expectedOrder2 = { orderService.getOrder(101), orderService.getOrder(103), orderService.getOrder(104) };
assertThat(orders, hasItems(expectedOrder2));
}
use of org.openmrs.Patient in project openmrs-core by openmrs.
the class OrderServiceTest method getActiveOrders_shouldReturnAllActiveDrugOrdersForTheSpecifiedPatient.
/**
* @see OrderService#getActiveOrders(org.openmrs.Patient, org.openmrs.OrderType,
* org.openmrs.CareSetting, java.util.Date)
*/
@Test
public void getActiveOrders_shouldReturnAllActiveDrugOrdersForTheSpecifiedPatient() {
Patient patient = patientService.getPatient(2);
List<Order> orders = orderService.getActiveOrders(patient, orderService.getOrderType(1), null, null);
assertEquals(4, orders.size());
Order[] expectedOrders = { orderService.getOrder(222), orderService.getOrder(3), orderService.getOrder(444), orderService.getOrder(5) };
assertThat(orders, hasItems(expectedOrders));
}
Aggregations