Skip to content

Commit

Permalink
null check for queueComingFrom of queueEntry in getPreviousQueueEntry
Browse files Browse the repository at this point in the history
  • Loading branch information
chibongho committed Mar 22, 2024
1 parent c4d0006 commit 49d9486
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<QueueEntry> 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;
Expand Down

0 comments on commit 49d9486

Please sign in to comment.