Skip to content

Commit

Permalink
Feature: Fetched appointments based on patient ID.
Browse files Browse the repository at this point in the history
  • Loading branch information
PreranaPandit committed Jul 23, 2020
1 parent c8d0ecd commit 5dca1ea
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
public class AppointmentSpec implements Specification<Appointment> {

private static final String FILTER_BY_NAME = "name";
private static final String FILTER_BY_PATIENT_ID = "patient.id";

private final String property;
private final String value;
Expand All @@ -29,8 +29,8 @@ public AppointmentSpec(String property, String value) {
public Predicate toPredicate(Root<Appointment> root, CriteriaQuery<?> query,
CriteriaBuilder criteriaBuilder) {
switch (property) {
case FILTER_BY_NAME:
return criteriaBuilder.like(root.get(FILTER_BY_NAME), "%" + value + "%");
case FILTER_BY_PATIENT_ID:
return criteriaBuilder.equal(root.join("patient").get("id"), Long.valueOf(value));
}
return null;
}
Expand Down

0 comments on commit 5dca1ea

Please sign in to comment.