Skip to content

Commit f038fbb

Browse files
RESTWS-716: Orders resource returns no results when only status is specified (#585)
* RESTWS-716: Orders resource returns no results when only status is specified * RESTWS-716: Orders resource returns no results when only status is specified
1 parent e4ae0d7 commit f038fbb

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/OrderResource1_10.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription;
3434
import org.openmrs.module.webservices.rest.web.resource.impl.EmptySearchResult;
3535
import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging;
36+
import org.openmrs.module.webservices.rest.web.response.InvalidSearchException;
3637
import org.openmrs.module.webservices.rest.web.response.ObjectNotFoundException;
3738
import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException;
3839
import org.openmrs.module.webservices.rest.web.response.ResponseException;
@@ -273,9 +274,10 @@ protected PageableResult doSearch(RequestContext context) throws ResponseExcepti
273274
else {
274275
return new NeedsPaging<Order>(orders, context);
275276
}
277+
} else {
278+
throw new InvalidSearchException("Please provide patientUuid in the patient parameter");
276279
}
277-
278-
return new EmptySearchResult();
280+
279281
}
280282

281283
private static Date getUsableDate(Order order) {

omod-1.10/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_10/OrderController1_10Test.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.openmrs.module.webservices.rest.test.Util;
2727
import org.openmrs.module.webservices.rest.web.RestConstants;
2828
import org.openmrs.module.webservices.rest.web.RestTestConstants1_10;
29+
import org.openmrs.module.webservices.rest.web.response.InvalidSearchException;
2930
import org.openmrs.module.webservices.rest.web.response.ObjectNotFoundException;
3031
import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException;
3132
import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest;
@@ -361,7 +362,7 @@ public void shouldReviseAnActiveOrder() throws Exception {
361362
revisedOrder.add("orderer", "c2299800-cca9-11e0-9572-0800200c9a66");
362363
revisedOrder.add("instructions", "To be taken after a meal");
363364
revisedOrder.add("orderReasonNonCoded", "Changed instructions");
364-
365+
365366
SimpleObject savedOrder = deserialize(handle(newPostRequest(getURI(), revisedOrder)));
366367

367368
List<Order> newActiveOrders = orderService.getActiveOrders(patient, null, null, null);
@@ -589,4 +590,12 @@ public void invalidCareCenterShouldThrowException() throws Exception {
589590
);
590591
handle(req);
591592
}
593+
594+
@Test(expected = InvalidSearchException.class)
595+
public void doSearch_shouldReturnExceptionIfNoPatientUuidIsSpecified() throws Exception {
596+
MockHttpServletRequest req = newGetRequest(getURI(),
597+
new Parameter("status", "active")
598+
);
599+
handle(req);
600+
}
592601
}

0 commit comments

Comments
 (0)