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 4, 2023
1 parent 20ee5a5 commit 19d1e28
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Order> activeDrugOrders = orderService.getActiveOrders(patient, orderService.getOrderTypeByName("Drug order"),
null, null);
int activeDrugOrderCount = activeDrugOrders.size();

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

}
}

0 comments on commit 19d1e28

Please sign in to comment.