diff --git a/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/OrderResource1_10.java b/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/OrderResource1_10.java index 7aa36d0a6..6ce57c38d 100644 --- a/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/OrderResource1_10.java +++ b/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/OrderResource1_10.java @@ -275,7 +275,7 @@ protected PageableResult doSearch(RequestContext context) throws ResponseExcepti return new NeedsPaging(orders, context); } } else { - throw new InvalidSearchException("Please specify patient parameter with valid patientUuid"); + throw new InvalidSearchException("Please provide patientUuid in the patient parameter"); } } diff --git a/omod-1.10/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_10/OrderController1_10Test.java b/omod-1.10/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_10/OrderController1_10Test.java index 53462086f..547a832b5 100644 --- a/omod-1.10/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_10/OrderController1_10Test.java +++ b/omod-1.10/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_10/OrderController1_10Test.java @@ -592,10 +592,34 @@ public void invalidCareCenterShouldThrowException() throws Exception { } @Test(expected = InvalidSearchException.class) - public void doSearch_shouldThrowExceptionIfNoPatientUuidIsSpecified() throws Exception { + public void doSearch_shouldReturnExceptionNotNullSetIfNoPatientUuidIsSpecified() throws Exception { MockHttpServletRequest req = newGetRequest(getURI(), new Parameter("status", "active") ); handle(req); } + + @Test + public void shouldGetOrdersByPatientUuid() throws Exception { + + Patient patient = patientService.getPatientByUuid(PATIENT_UUID); + + // get all drug orders + List activeDrugOrders = orderService.getActiveOrders(patient, orderService.getOrderTypeByName("Drug order"), + null, null); + + // get all test orders + List activeTestOrders = orderService.getActiveOrders(patient, orderService.getOrderTypeByName("Test order"), + null, null); + + // order service should return all active orders with patientUuid specified + MockHttpServletRequest req = newGetRequest(getURI(), + new Parameter("patient", PATIENT_UUID), + new Parameter("status", "active") + ); + SimpleObject orders = deserialize(handle(req)); + ArrayList resp = (ArrayList) PropertyUtils.getProperty(orders, "results"); + assertEquals(activeTestOrders.size() + activeDrugOrders.size(), resp.size()); + + } }