diff --git a/api/src/main/java/org/openmrs/module/queue/api/impl/QueueEntryServiceImpl.java b/api/src/main/java/org/openmrs/module/queue/api/impl/QueueEntryServiceImpl.java index 61247f2..e73c1b1 100644 --- a/api/src/main/java/org/openmrs/module/queue/api/impl/QueueEntryServiceImpl.java +++ b/api/src/main/java/org/openmrs/module/queue/api/impl/QueueEntryServiceImpl.java @@ -256,15 +256,18 @@ private void endQueueEntry(@NotNull QueueEntry queueEntry) { @Override @Transactional(readOnly = true) public QueueEntry getPreviousQueueEntry(@NotNull QueueEntry queueEntry) { + Queue queueComingFrom = queueEntry.getQueueComingFrom(); QueueEntrySearchCriteria criteria = new QueueEntrySearchCriteria(); criteria.setPatient(queueEntry.getPatient()); criteria.setVisit(queueEntry.getVisit()); criteria.setEndedOn(queueEntry.getStartedAt()); - criteria.setQueues(Arrays.asList(queueEntry.getQueueComingFrom())); + criteria.setQueues(queueComingFrom == null ? Arrays.asList() : Arrays.asList(queueComingFrom)); List prevQueueEntries = dao.getQueueEntries(criteria); if (prevQueueEntries.size() == 1) { return prevQueueEntries.get(0); } else if (prevQueueEntries.size() > 1) { + // TODO: Exceptions should be translatable and human readable on the frontend. + // See: https://openmrs.atlassian.net/browse/O3-2988 throw new IllegalStateException("Multiple previous queue entries found"); } else { return null;