Skip to content

Commit

Permalink
Throwing exceptions for invalid next order number global property -
Browse files Browse the repository at this point in the history
TRUNK-4163
  • Loading branch information
dkayiwa committed Dec 19, 2013
1 parent c40f3d9 commit b426919
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions api/src/main/java/org/openmrs/api/impl/OrderServiceImpl.java
Expand Up @@ -140,7 +140,7 @@ public <o extends Order> o getOrder(Integer orderId, Class<o> orderClassType) th
* java.util.List, java.util.List)
*/
public <Ord extends Order> List<Ord> getOrders(Class<Ord> orderClassType, List<Patient> patients,
List<Concept> concepts, List<User> orderers, List<Encounter> encounters) {
List<Concept> concepts, List<User> orderers, List<Encounter> encounters) {
if (orderClassType == null)
throw new APIException(
"orderClassType cannot be null. An order type of Order.class or DrugOrder.class is required");
Expand Down Expand Up @@ -181,16 +181,17 @@ public synchronized String getNewOrderNumber() {

String gpTextValue = globalProperty.getPropertyValue();
if (!StringUtils.hasText(gpTextValue)) {
gpTextValue = ORDER_NUMBER_START_VALUE;
throw new APIException("Invalid value for global property named: "
+ OpenmrsConstants.GLOBAL_PROPERTY_NEXT_ORDER_NUMBER);
}

Long gpNumericValue = null;
try {
gpNumericValue = Long.parseLong(gpTextValue);
}
catch (NumberFormatException ex) {
gpNumericValue = 1l;
gpTextValue = ORDER_NUMBER_START_VALUE;
throw new APIException("Invalid value for global property named: "
+ OpenmrsConstants.GLOBAL_PROPERTY_NEXT_ORDER_NUMBER);
}

String orderNumber = ORDER_NUMBER_PREFIX + gpTextValue;
Expand All @@ -217,7 +218,8 @@ public Order getOrderByOrderNumber(String orderNumber) {
}

/**
* @see org.openmrs.api.OrderService#getOrderHistoryByConcept(org.openmrs.Patient, org.openmrs.Concept)
* @see org.openmrs.api.OrderService#getOrderHistoryByConcept(org.openmrs.Patient,
* org.openmrs.Concept)
*/
@Override
public List<Order> getOrderHistoryByConcept(Patient patient, Concept concept) {
Expand Down

0 comments on commit b426919

Please sign in to comment.