Skip to content

Commit

Permalink
(fix):Filter Queue Entries to return count of those waiting for a ser…
Browse files Browse the repository at this point in the history
…vice
  • Loading branch information
makombe committed Mar 13, 2024
1 parent 840d736 commit 2ef5960
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import org.openmrs.module.queue.api.QueueServicesWrapper;
import org.openmrs.module.queue.api.search.QueueEntrySearchCriteria;
Expand Down Expand Up @@ -71,8 +72,12 @@ public Object handleRequest(HttpServletRequest request) {
ret.add(COUNT, services.getQueueEntryService().getCountOfQueueEntries(criteria).intValue());
} else {
List<QueueEntry> queueEntries = services.getQueueEntryService().getQueueEntries(criteria);
// Filter queueEntries where ended_at is null. The count should be for those waiting for a service
List<QueueEntry> filteredQueueEntries = queueEntries.stream().filter(entry -> entry.getEndedAt() == null)
.collect(Collectors.toList());

if (metrics.isEmpty() || metrics.contains(COUNT)) {
ret.add(COUNT, queueEntries.size());
ret.add(COUNT, filteredQueueEntries.size());
}
if (metrics.isEmpty() || metrics.contains(AVERAGE_WAIT_TIME)) {
ret.add(AVERAGE_WAIT_TIME, QueueUtils.computeAverageWaitTimeInMinutes(queueEntries));
Expand Down

0 comments on commit 2ef5960

Please sign in to comment.