Skip to content

Commit

Permalink
OP-1221 Improve filtering for all charge or discharge MovementType(s) (
Browse files Browse the repository at this point in the history
  • Loading branch information
mwithi committed May 10, 2024
1 parent 4502f7d commit e72f50d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -413,16 +413,16 @@ public List<Movement> getMovements(String wardId, LocalDateTime dateFrom, LocalD

/**
* Retrieves all the stored {@link Movement} with the specified criteria.
* @param medicalCode the medical code.
* @param medicalType the medical type.
* @param wardId the ward type.
* @param movType the movement type.
* @param movFrom the lower bound for the movement date range.
* @param movTo the upper bound for the movement date range.
* @param lotPrepFrom the lower bound for the lot preparation date range.
* @param lotPrepTo the upper bound for the lot preparation date range.
* @param lotDueFrom the lower bound for the lot due date range.
* @param lotDueTo the lower bound for the lot due date range.
* @param medicalCode the {@link Medical} code (optional).
* @param medicalTypeCode the {@link MedicalType} code (optional).
* @param wardId the {@link Ward} id (optional).
* @param movTypeCode the {@link MovementType} code or {@code "+"}/{@code "-"} for all charge/discharge types (optional).
* @param movFrom the lower bound for the movement date range (optional).
* @param movTo the upper bound for the movement date range (optional).
* @param lotPrepFrom the lower bound for the lot preparation date range (optional).
* @param lotPrepTo the upper bound for the lot preparation date range (optional).
* @param lotDueFrom the lower bound for the lot due date range (optional).
* @param lotDueTo the lower bound for the lot due date range (optional).
* @return all the retrieved movements.
* @throws OHServiceException
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,14 @@ private List<Integer> getMovementWhereData(
predicates.add(builder.between(root.<Lot> get(LOT).<LocalDateTime> get("dueDate"), TimeTools.getBeginningOfDay(lotDueFrom),
TimeTools.getBeginningOfNextDay(lotDueTo)));
}
if (movType != null) {
predicates.add(builder.equal(root.<MedicalType> get(TYPE).<String> get(CODE), movType));
if ("+".equals(movType)) {
predicates.add(builder.equal(root.<MovementType> get(TYPE).<String> get(TYPE), movType));

} else if ("-".equals(movType)) {
predicates.add(builder.equal(root.<MovementType> get(TYPE).<String> get(TYPE), movType));

} else if (movType != null) {
predicates.add(builder.equal(root.<MovementType> get(TYPE).<String> get(CODE), movType));
}
if (wardId != null) {
predicates.add(builder.equal(root.<Ward> get(WARD).<String> get(CODE), wardId));
Expand Down

0 comments on commit e72f50d

Please sign in to comment.