Skip to content

Commit

Permalink
RESTWS-716: Orders resource returns no results when only status is sp…
Browse files Browse the repository at this point in the history
…ecified (#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
  • Loading branch information
IamMujuziMoses authored Sep 24, 2023
1 parent e4ae0d7 commit f038fbb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription;
import org.openmrs.module.webservices.rest.web.resource.impl.EmptySearchResult;
import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging;
import org.openmrs.module.webservices.rest.web.response.InvalidSearchException;
import org.openmrs.module.webservices.rest.web.response.ObjectNotFoundException;
import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException;
import org.openmrs.module.webservices.rest.web.response.ResponseException;
Expand Down Expand Up @@ -273,9 +274,10 @@ protected PageableResult doSearch(RequestContext context) throws ResponseExcepti
else {
return new NeedsPaging<Order>(orders, context);
}
} else {
throw new InvalidSearchException("Please provide patientUuid in the patient parameter");
}

return new EmptySearchResult();

}

private static Date getUsableDate(Order order) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.openmrs.module.webservices.rest.test.Util;
import org.openmrs.module.webservices.rest.web.RestConstants;
import org.openmrs.module.webservices.rest.web.RestTestConstants1_10;
import org.openmrs.module.webservices.rest.web.response.InvalidSearchException;
import org.openmrs.module.webservices.rest.web.response.ObjectNotFoundException;
import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException;
import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest;
Expand Down Expand Up @@ -361,7 +362,7 @@ public void shouldReviseAnActiveOrder() throws Exception {
revisedOrder.add("orderer", "c2299800-cca9-11e0-9572-0800200c9a66");
revisedOrder.add("instructions", "To be taken after a meal");
revisedOrder.add("orderReasonNonCoded", "Changed instructions");

SimpleObject savedOrder = deserialize(handle(newPostRequest(getURI(), revisedOrder)));

List<Order> newActiveOrders = orderService.getActiveOrders(patient, null, null, null);
Expand Down Expand Up @@ -589,4 +590,12 @@ public void invalidCareCenterShouldThrowException() throws Exception {
);
handle(req);
}

@Test(expected = InvalidSearchException.class)
public void doSearch_shouldReturnExceptionIfNoPatientUuidIsSpecified() throws Exception {
MockHttpServletRequest req = newGetRequest(getURI(),
new Parameter("status", "active")
);
handle(req);
}
}

0 comments on commit f038fbb

Please sign in to comment.