From 49d94866e39c06f72e4d79d51f0a86d2c7c520ce Mon Sep 17 00:00:00 2001 From: Chi Bong Ho Date: Fri, 22 Mar 2024 13:13:18 -0400 Subject: [PATCH] null check for queueComingFrom of queueEntry in getPreviousQueueEntry --- .../openmrs/module/queue/api/impl/QueueEntryServiceImpl.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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;