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..c7a90f70e 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 @@ -598,4 +598,30 @@ public void doSearch_shouldThrowExceptionIfNoPatientUuidIsSpecified() throws Exc ); 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); + int activeDrugOrderCount = activeDrugOrders.size(); + + // get all test orders + List activeTestOrders = orderService.getActiveOrders(patient, orderService.getOrderTypeByName("Test order"), + null, null); + int activeTestOrderCount = activeTestOrders.size(); + + // 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(activeTestOrderCount + activeDrugOrderCount, resp.size()); + + } }