Skip to content

Commit

Permalink
address more PR comment
Browse files Browse the repository at this point in the history
  • Loading branch information
chibongho committed Mar 22, 2024
1 parent 41a9ceb commit e1dd8f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ public interface QueueEntryService {
QueueEntry transitionQueueEntry(@NotNull QueueEntryTransition queueEntryTransition);

/**
* Undos a transition to the input queue entry by voiding it and
* making its previous queue entry active by
* setting the previous entry's end time to null.
* Undos a transition to the input queue entry by voiding it and making its previous queue entry
* active by setting the previous entry's end time to null.
*
* @see QueueEntryService#getPreviousQueueEntry(QueueEntry)
* @param queueEntry the queue entry to undo transition to. Must be active
Expand Down Expand Up @@ -129,7 +128,7 @@ String generateVisitQueueNumber(@NotNull Location location, @NotNull Queue queue

/**
* Given a specified queue entry Q, return its previous queue entry P, where P has same patient and
* visit as Q, and P.endedAt time is same as Q.startAt time.
* visit as Q, and P.endedAt time is same as Q.startedAt time, and P.queue is same as Q.queueComingFrom
*
* @param queueEntry
* @return the previous queue entry, null otherwise.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
Expand Down Expand Up @@ -136,6 +137,8 @@ public QueueEntry transitionQueueEntry(QueueEntryTransition queueEntryTransition
*/
@Override
public QueueEntry undoTransition(@NotNull QueueEntry queueEntry) {
// TODO: Exceptions should be translatable and human readable on the frontend.
// See: https://openmrs.atlassian.net/browse/O3-2988
if (queueEntry.getVoided()) {
throw new IllegalArgumentException("cannot undo transition on a voided queue entry");
}
Expand Down Expand Up @@ -257,10 +260,11 @@ public QueueEntry getPreviousQueueEntry(@NotNull QueueEntry queueEntry) {
criteria.setPatient(queueEntry.getPatient());
criteria.setVisit(queueEntry.getVisit());
criteria.setEndedOn(queueEntry.getStartedAt());
criteria.setQueues(Arrays.asList(queueEntry.getQueueComingFrom()));
List<QueueEntry> prevQueueEntries = dao.getQueueEntries(criteria);
if (prevQueueEntries.size() == 1) {
return prevQueueEntries.get(0);
} else if(prevQueueEntries.size() > 1) {
} else if (prevQueueEntries.size() > 1) {
throw new IllegalStateException("Multiple previous queue entries found");
} else {
return null;
Expand Down

0 comments on commit e1dd8f4

Please sign in to comment.