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
  • Loading branch information
IamMujuziMoses committed Sep 19, 2023
1 parent 576916a commit 4d82900
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ protected PageableResult doSearch(RequestContext context) throws ResponseExcepti
return new NeedsPaging<Order>(orders, context);
}
} else {
throw new InvalidSearchException("Please specify patient parameter with valid patientUuid");
throw new InvalidSearchException("Please provide patientUuid in the patient parameter");
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Order> activeDrugOrders = orderService.getActiveOrders(patient, orderService.getOrderTypeByName("Drug order"),
null, null);

// get all test orders
List<Order> 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<Object> resp = (ArrayList<Object>) PropertyUtils.getProperty(orders, "results");
assertEquals(activeTestOrders.size() + activeDrugOrders.size(), resp.size());

}
}

0 comments on commit 4d82900

Please sign in to comment.