Skip to content

Commit

Permalink
O3-2899 - Bug fix to Legacy visit-queue-entry endpoint to limit to ac…
Browse files Browse the repository at this point in the history
…tive entries
  • Loading branch information
mseaton committed Mar 7, 2024
1 parent ba5242b commit 7beef8c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

Expand All @@ -37,7 +38,9 @@
import org.openmrs.VisitAttributeType;
import org.openmrs.module.queue.api.QueueServicesWrapper;
import org.openmrs.module.queue.api.digitalSignage.QueueTicketAssignments;
import org.openmrs.module.queue.api.search.QueueEntrySearchCriteria;
import org.openmrs.module.queue.model.Queue;
import org.openmrs.module.queue.model.QueueEntry;
import org.openmrs.module.queue.web.resources.QueueEntryResource;
import org.openmrs.module.queue.web.resources.QueueRoomResource;
import org.openmrs.module.queue.web.resources.RoomProviderMapResource;
Expand All @@ -48,6 +51,7 @@
import org.openmrs.module.webservices.rest.web.representation.Representation;
import org.openmrs.module.webservices.rest.web.resource.api.Converter;
import org.openmrs.module.webservices.rest.web.resource.api.PageableResult;
import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging;
import org.openmrs.module.webservices.rest.web.response.ResponseException;
import org.openmrs.module.webservices.rest.web.v1_0.controller.BaseRestController;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -93,7 +97,15 @@ public Object getVisitQueueEntries(HttpServletRequest request, HttpServletRespon
List<SimpleObject> visitQueueEntries = new ArrayList<>();
result.add("results", visitQueueEntries);
RequestContext requestContext = RestUtil.getRequestContext(request, response, Representation.REF);
Map<String, Object> searchResult = queueEntryResource.search(requestContext);
Map<String, String[]> parameters = new HashMap<String, String[]>(requestContext.getRequest().getParameterMap());
// The queueEntryResource does not limit to active by default, but the legacy resource does
if (!parameters.containsKey("isEnded")) {
parameters.put("isEnded", new String[] { "false" });
}
QueueEntrySearchCriteria criteria = queueEntryResource.getSearchCriteriaParser().constructFromRequest(parameters);
List<QueueEntry> queueEntryList = services.getQueueEntryService().getQueueEntries(criteria);
PageableResult pageableResult = new NeedsPaging<>(queueEntryList, requestContext);
Map<String, Object> searchResult = pageableResult.toSimpleObject(queueEntryResource);
List<Map<String, Object>> queueEntries = (List<Map<String, Object>>) PropertyUtils.getProperty(searchResult,
"results");
for (Map<String, Object> queueEntry : queueEntries) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.Map;
import java.util.Optional;

import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.openmrs.PersonName;
import org.openmrs.api.context.Context;
Expand Down Expand Up @@ -51,6 +52,7 @@ public class QueueEntryResource extends DelegatingCrudResource<QueueEntry> {

private final QueueServicesWrapper services;

@Getter
private final QueueEntrySearchCriteriaParser searchCriteriaParser;

public QueueEntryResource() {
Expand Down

0 comments on commit 7beef8c

Please sign in to comment.