Skip to content

Commit b426919

Browse files
committedDec 19, 2013
Throwing exceptions for invalid next order number global property -
TRUNK-4163
1 parent c40f3d9 commit b426919

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed
 

‎api/src/main/java/org/openmrs/api/impl/OrderServiceImpl.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public <o extends Order> o getOrder(Integer orderId, Class<o> orderClassType) th
140140
* java.util.List, java.util.List)
141141
*/
142142
public <Ord extends Order> List<Ord> getOrders(Class<Ord> orderClassType, List<Patient> patients,
143-
List<Concept> concepts, List<User> orderers, List<Encounter> encounters) {
143+
List<Concept> concepts, List<User> orderers, List<Encounter> encounters) {
144144
if (orderClassType == null)
145145
throw new APIException(
146146
"orderClassType cannot be null. An order type of Order.class or DrugOrder.class is required");
@@ -181,16 +181,17 @@ public synchronized String getNewOrderNumber() {
181181

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

187188
Long gpNumericValue = null;
188189
try {
189190
gpNumericValue = Long.parseLong(gpTextValue);
190191
}
191192
catch (NumberFormatException ex) {
192-
gpNumericValue = 1l;
193-
gpTextValue = ORDER_NUMBER_START_VALUE;
193+
throw new APIException("Invalid value for global property named: "
194+
+ OpenmrsConstants.GLOBAL_PROPERTY_NEXT_ORDER_NUMBER);
194195
}
195196

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

219220
/**
220-
* @see org.openmrs.api.OrderService#getOrderHistoryByConcept(org.openmrs.Patient, org.openmrs.Concept)
221+
* @see org.openmrs.api.OrderService#getOrderHistoryByConcept(org.openmrs.Patient,
222+
* org.openmrs.Concept)
221223
*/
222224
@Override
223225
public List<Order> getOrderHistoryByConcept(Patient patient, Concept concept) {

0 commit comments

Comments
 (0)
Please sign in to comment.