Source:
<code>private void discontinueExistingOrdersIfNecessary(Order order, Boolean isRetrospective) { if (DISCONTINUE != order.getAction()) { return; } Order previousOrder = order.getPreviousOrder(); if (previousOrder != null) { stopOrder(previousOrder, aMomentBefore(order.getDateActivated()), isRetrospective); return; } Date asOfDate = null; <START> if (isRetrospective) <END> asOfDate = order.getDateActivated(); List<? extends Order> orders = getActiveOrders(order.getPatient(), order.getOrderType(), order.getCareSetting(), asOfDate); boolean isDrugOrderAndHasADrug = DrugOrder.class.isAssignableFrom(getActualType(order)) && (((DrugOrder) order).getDrug() != null || ((DrugOrder) order).isNonCodedDrug()); Order orderToBeDiscontinued = null; for (Order activeOrder : orders) { if (!getActualType(order).equals(getActualType(activeOrder))) { continue; } if (isDrugOrderAndHasADrug) { Order existing = order.hasSameOrderableAs(activeOrder) ? activeOrder : null; if (existing != null) { if (orderToBeDiscontinued == null) { orderToBeDiscontinued = existing; } else { throw new AmbiguousOrderException("Order.discontinuing.ambiguous.orders"); } } } else if (activeOrder.getConcept().equals(order.getConcept())) { if (orderToBeDiscontinued == null) { orderToBeDiscontinued = activeOrder; } else { throw new AmbiguousOrderException("Order.discontinuing.ambiguous.orders"); } } } if (orderToBeDiscontinued != null) { order.setPreviousOrder(orderToBeDiscontinued); stopOrder(orderToBeDiscontinued, aMomentBefore(order.getDateActivated()), isRetrospective); } }</code><technical_language>convention is wrap if clauses in curly braces</technical_language>

Target:
private void discontinueExistingOrdersIfNecessary(Order order, Boolean isRetrospective) { if (DISCONTINUE != order.getAction()) { return; } Order previousOrder = order.getPreviousOrder(); if (previousOrder != null) { stopOrder(previousOrder, aMomentBefore(order.getDateActivated()), isRetrospective); return; } Date asOfDate = null; if (isRetrospective) { asOfDate = order.getDateActivated(); } List<? extends Order> orders = getActiveOrders(order.getPatient(), order.getOrderType(), order.getCareSetting(), asOfDate); boolean isDrugOrderAndHasADrug = DrugOrder.class.isAssignableFrom(getActualType(order)) && (((DrugOrder) order).getDrug() != null || ((DrugOrder) order).isNonCodedDrug()); Order orderToBeDiscontinued = null; for (Order activeOrder : orders) { if (!getActualType(order).equals(getActualType(activeOrder))) { continue; } if (isDrugOrderAndHasADrug) { Order existing = order.hasSameOrderableAs(activeOrder) ? activeOrder : null; if (existing != null) { if (orderToBeDiscontinued == null) { orderToBeDiscontinued = existing; } else { throw new AmbiguousOrderException("Order.discontinuing.ambiguous.orders"); } } } else if (activeOrder.getConcept().equals(order.getConcept())) { if (orderToBeDiscontinued == null) { orderToBeDiscontinued = activeOrder; } else { throw new AmbiguousOrderException("Order.discontinuing.ambiguous.orders"); } } } if (orderToBeDiscontinued != null) { order.setPreviousOrder(orderToBeDiscontinued); stopOrder(orderToBeDiscontinued, aMomentBefore(order.getDateActivated()), isRetrospective); } }