Skip to content

Commit

Permalink
TRUNK-4332 Add getDiscontinationOrder - post review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rkorytkowski committed Mar 31, 2014
1 parent 712d83f commit 1ec16b6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 2 additions & 0 deletions api/src/main/java/org/openmrs/api/OrderService.java
Expand Up @@ -147,6 +147,8 @@ public interface OrderService extends OpenmrsService {
* @param order
* @return the discontinuation order or null if none
* @throws APIException
* @since 1.10
* @should return discontinuation order if order has been discontinued
* @should return null if order has not been discontinued
*/
Expand Down
Expand Up @@ -162,14 +162,10 @@ public Order getOrderByUuid(String uuid) {

@Override
public Order getDiscontinuationOrder(Order order) {
Order nextOrder = (Order) sessionFactory.getCurrentSession().createQuery(
"from Order o where o.previousOrder = :orderId").setInteger("orderId", order.getId()).uniqueResult();
Order discontinuationOrder = (Order) sessionFactory.getCurrentSession().createCriteria(Order.class).add(
Restrictions.eq("previousOrder", order)).add(Restrictions.eq("action", Order.Action.DISCONTINUE)).uniqueResult();

if (nextOrder != null && Order.Action.DISCONTINUE.equals(nextOrder.getAction())) {
return nextOrder;
} else {
return null;
}
return discontinuationOrder;
}

/**
Expand Down

0 comments on commit 1ec16b6

Please sign in to comment.