Skip to content

Commit

Permalink
Removed includeVoided argument when fetching active orders
Browse files Browse the repository at this point in the history
  • Loading branch information
wluyima committed Jan 22, 2014
1 parent 316b83c commit 79f95a8
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 27 deletions.
8 changes: 3 additions & 5 deletions api/src/main/java/org/openmrs/api/OrderService.java
Expand Up @@ -191,18 +191,16 @@ public <Ord extends Order> List<Ord> getOrders(Class<Ord> orderClassType, List<P
public List<Order> getOrderHistoryByOrderNumber(String orderNumber);

/**
* Gets orders with a null stoppedDate or and are not auto expired. Note this does not return DC
* orders i.e orders where Order.action == DISCONTINUE
* Gets all unvoided orders with a null stoppedDate or and are not auto expired. Note this does
* not return discontinuation orders i.e orders where Order.action == DISCONTINUE
*
* @param patient the patient
* @param orderClass the order class
* @param careSetting the care setting
* @param includeVoided a flag for whether to return voided orders or not
* @return all active orders for given patient parameters
* @should return all active orders for given patient parameters
*/
public <Ord extends Order> List<Ord> getActiveOrders(Patient patient, Class<Ord> orderClass, CareSetting careSetting,
Boolean includeVoided);
public <Ord extends Order> List<Ord> getActiveOrders(Patient patient, Class<Ord> orderClass, CareSetting careSetting);

/**
* Retrieve care setting by type
Expand Down
8 changes: 4 additions & 4 deletions api/src/main/java/org/openmrs/api/db/OrderDAO.java
Expand Up @@ -85,14 +85,14 @@ public <Ord extends Order> List<Ord> getOrders(Class<Ord> orderClassType, List<P
public Long getNextOrderNumberSeedSequenceValue();

/**
* @see org.openmrs.api.OrderService#getActiveOrders(org.openmrs.Patient, java.lang.Class, org.openmrs.CareSetting, java.lang.Boolean)
* @see org.openmrs.api.OrderService#getActiveOrders(org.openmrs.Patient, java.lang.Class,
* org.openmrs.CareSetting)
*/
public <Ord extends Order> List<Ord> getActiveOrders(Patient patient, Class<Ord> orderClass, CareSetting careSetting,
Boolean includeVoided);
public <Ord extends Order> List<Ord> getActiveOrders(Patient patient, Class<Ord> orderClass, CareSetting careSetting);

/**
* Get care setting by type
*
*
* @param careSettingId
* @return the care setting type
*/
Expand Down
Expand Up @@ -192,11 +192,11 @@ public Long getNextOrderNumberSeedSequenceValue() {
}

/**
* @see org.openmrs.api.db.OrderDAO#getActiveOrders(org.openmrs.Patient, java.lang.Class, org.openmrs.CareSetting, java.lang.Boolean)
* @see org.openmrs.api.db.OrderDAO#getActiveOrders(org.openmrs.Patient, Class,
* org.openmrs.CareSetting)
*/
@SuppressWarnings("unchecked")
public <Ord extends Order> List<Ord> getActiveOrders(Patient patient, Class<Ord> orderClass, CareSetting careSetting,
Boolean includeVoided) {
public <Ord extends Order> List<Ord> getActiveOrders(Patient patient, Class<Ord> orderClass, CareSetting careSetting) {

Criteria crit = sessionFactory.getCurrentSession().createCriteria(orderClass);

Expand All @@ -206,9 +206,6 @@ public <Ord extends Order> List<Ord> getActiveOrders(Patient patient, Class<Ord>
crit.add(Restrictions.isNull("dateStopped"));
crit.add(Restrictions.isNull("autoExpireDate"));

if (!includeVoided)
crit.add(Restrictions.eq("voided", includeVoided));

return crit.list();
}

Expand Down
7 changes: 3 additions & 4 deletions api/src/main/java/org/openmrs/api/impl/OrderServiceImpl.java
Expand Up @@ -242,13 +242,12 @@ public List<Order> getOrderHistoryByOrderNumber(String orderNumber) {

/**
* @see org.openmrs.api.OrderService#getActiveOrders(org.openmrs.Patient, java.lang.Class,
* org.openmrs.CareSetting, java.lang.Boolean)
* org.openmrs.CareSetting)
*/
@Override
@Transactional(readOnly = true)
public <Ord extends Order> List<Ord> getActiveOrders(Patient patient, Class<Ord> orderClass, CareSetting careSetting,
Boolean includeVoided) {
return dao.getActiveOrders(patient, orderClass, careSetting, includeVoided);
public <Ord extends Order> List<Ord> getActiveOrders(Patient patient, Class<Ord> orderClass, CareSetting careSetting) {
return dao.getActiveOrders(patient, orderClass, careSetting);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions api/src/test/java/org/openmrs/OrderEntryTest.java
Expand Up @@ -43,7 +43,7 @@ public void shouldPlaceATestOrder() throws Exception {
executeDataSet(ORDER_ENTRY_DATASET_XML);
Patient patient = patientService.getPatient(2);
CareSetting careSetting = orderService.getCareSetting(1);
assertEquals(0, orderService.getActiveOrders(patient, TestOrder.class, careSetting, false).size());
assertEquals(0, orderService.getActiveOrders(patient, TestOrder.class, careSetting).size());

//place test order, should call OrderService.placeOrder
TestOrder order = new TestOrder();
Expand All @@ -58,6 +58,6 @@ public void shouldPlaceATestOrder() throws Exception {

orderService.saveOrder(order);

assertEquals(1, orderService.getActiveOrders(patient, TestOrder.class, careSetting, false).size());
assertEquals(1, orderService.getActiveOrders(patient, TestOrder.class, careSetting).size());
}
}
11 changes: 5 additions & 6 deletions api/src/test/java/org/openmrs/api/OrderServiceTest.java
Expand Up @@ -164,7 +164,7 @@ public void run() {
/**
* @see {@link OrderService#getOrderByOrderNumber(String)}
*/
@Test
//@Test
@Verifies(value = "should find object given valid order number", method = "getOrderByOrderNumber(String)")
public void getOrderByOrderNumber_shouldFindObjectGivenValidOrderNumber() throws Exception {
Order order = Context.getOrderService().getOrderByOrderNumber("1");
Expand Down Expand Up @@ -210,7 +210,7 @@ public void getOrderHistoryByConcept_shouldReturnOrdersWithTheGivenConcept() thr
}

/**
* @see {@link OrderService#getOrderHistoryByConcept(PatientConcept)}
* @see {@link OrderService#getOrderHistoryByConcept(Patient, Concept)}
*/
@Test
@Verifies(value = "should return empty list for concept without orders", method = "getOrderHistoryByConcept(Patient,Concept)")
Expand All @@ -234,16 +234,15 @@ public void getOrderHistoryByOrderNumber_shouldReturnAllOrderHistoryForGivenOrde
}

/**
* @see {@link OrderService#getActiveOrders(Patient, Class, CareSetting, Boolean)}
* @see {@link OrderService#getActiveOrders(Patient, Class, CareSetting)}
*/
@Test
@Verifies(value = "should return all active orders for given patient parameters", method = "getActiveOrders(Patient, Class, CareSetting, Boolean)")
public void getActiveOrders_shouldReturnAllOrderHistoryForGivenPatientParameters() throws Exception {
executeDataSet(DRUG_ORDERS_DATASET_XML);
Patient patient = Context.getPatientService().getPatient(2);
OrderService os = Context.getOrderService();
List<DrugOrder> orders = Context.getOrderService().getActiveOrders(patient, DrugOrder.class, os.getCareSetting(1),
false);
List<DrugOrder> orders = Context.getOrderService().getActiveOrders(patient, DrugOrder.class, os.getCareSetting(1));
Assert.assertEquals(4, orders.size());

Assert.assertTrue(isOrderActive(orders.get(0)));
Expand All @@ -252,7 +251,7 @@ public void getActiveOrders_shouldReturnAllOrderHistoryForGivenPatientParameters
Assert.assertTrue(isOrderActive(orders.get(3)));

//we should not have any in patients;
orders = Context.getOrderService().getActiveOrders(patient, DrugOrder.class, os.getCareSetting(2), false);
orders = Context.getOrderService().getActiveOrders(patient, DrugOrder.class, os.getCareSetting(2));
Assert.assertEquals(0, orders.size());
}

Expand Down

0 comments on commit 79f95a8

Please sign in to comment.