Skip to content

Commit 1ec16b6

Browse files
committedMar 31, 2014
TRUNK-4332 Add getDiscontinationOrder - post review fixes
1 parent 712d83f commit 1ec16b6

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed
 

‎api/src/main/java/org/openmrs/api/OrderService.java

+2
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ public interface OrderService extends OpenmrsService {
147147
* @param order
148148
* @return the discontinuation order or null if none
149149
* @throws APIException
150+
* @since 1.10
151+
150152
* @should return discontinuation order if order has been discontinued
151153
* @should return null if order has not been discontinued
152154
*/

‎api/src/main/java/org/openmrs/api/db/hibernate/HibernateOrderDAO.java

+3-7
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,10 @@ public Order getOrderByUuid(String uuid) {
162162

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

168-
if (nextOrder != null && Order.Action.DISCONTINUE.equals(nextOrder.getAction())) {
169-
return nextOrder;
170-
} else {
171-
return null;
172-
}
168+
return discontinuationOrder;
173169
}
174170

175171
/**

0 commit comments

Comments
 (0)
Please sign in to comment.