Skip to content

Commit 996f110

Browse files
Merge pull request #13215 from SORMAS-Foundation/feature-13190_add_range_filter_for_birthdate
#13190 - Add date range filter for birthdate (from-to) to Persons, Ca…
2 parents aef93ea + 82cb706 commit 996f110

File tree

17 files changed

+431
-4
lines changed

17 files changed

+431
-4
lines changed

sormas-api/src/main/java/de/symeda/sormas/api/caze/CaseCriteria.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ public class CaseCriteria extends CriteriaWithDateType implements ExternalShareC
106106
private Date newCaseDateTo;
107107
private Date creationDateFrom;
108108
private Date creationDateTo;
109+
private Date birthdateFrom;
110+
private Date birthdateTo;
111+
private boolean includePartialMatch;
109112
private CriteriaDateType newCaseDateType;
110113
// Used to re-construct whether users have filtered by epi weeks or dates
111114
private DateFilterOption dateFilterOption = DateFilterOption.DATE;
@@ -552,6 +555,31 @@ public CaseCriteria creationDateTo(Date creationDateTo) {
552555
return this;
553556
}
554557

558+
public Date getBirthdateFrom() {
559+
return birthdateFrom;
560+
}
561+
562+
public void setBirthdateFrom(Date birthdateFrom) {
563+
this.birthdateFrom = birthdateFrom;
564+
}
565+
566+
public Date getBirthdateTo() {
567+
return birthdateTo;
568+
}
569+
570+
public void setBirthdateTo(Date birthdateTo) {
571+
this.birthdateTo = birthdateTo;
572+
}
573+
574+
@IgnoreForUrl
575+
public boolean isIncludePartialMatch() {
576+
return includePartialMatch;
577+
}
578+
579+
public void setIncludePartialMatch(boolean includePartialMatch) {
580+
this.includePartialMatch = includePartialMatch;
581+
}
582+
555583
public Date getQuarantineTo() {
556584
return quarantineTo;
557585
}

sormas-api/src/main/java/de/symeda/sormas/api/contact/ContactCriteria.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ public class ContactCriteria extends BaseCriteria implements Serializable {
136136
private Boolean onlyContactsFromOtherInstances;
137137
private Date creationDateFrom;
138138
private Date creationDateTo;
139+
private Date birthdateFrom;
140+
private Date birthdateTo;
141+
private boolean includePartialMatch;
139142
private String reportingUserLike;
140143
private String personLike;
141144
private boolean excludeLimitedSyncRestrictions;
@@ -665,6 +668,31 @@ public ContactCriteria creationDateTo(Date creationDateTo) {
665668
return this;
666669
}
667670

671+
public Date getBirthdateFrom() {
672+
return birthdateFrom;
673+
}
674+
675+
public void setBirthdateFrom(Date birthdateFrom) {
676+
this.birthdateFrom = birthdateFrom;
677+
}
678+
679+
public Date getBirthdateTo() {
680+
return birthdateTo;
681+
}
682+
683+
public void setBirthdateTo(Date birthdateTo) {
684+
this.birthdateTo = birthdateTo;
685+
}
686+
687+
@IgnoreForUrl
688+
public boolean isIncludePartialMatch() {
689+
return includePartialMatch;
690+
}
691+
692+
public void setIncludePartialMatch(boolean includePartialMatch) {
693+
this.includePartialMatch = includePartialMatch;
694+
}
695+
668696
public String getReportingUserLike() {
669697
return reportingUserLike;
670698
}

sormas-api/src/main/java/de/symeda/sormas/api/i18n/Captions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,6 +1993,7 @@ public interface Captions {
19931993
String importSkips = "importSkips";
19941994
String importValueSeparator = "importValueSeparator";
19951995
String inaccessibleValue = "inaccessibleValue";
1996+
String includePartialBirthdates = "includePartialBirthdates";
19961997
String info = "info";
19971998
String infrastructureImportAllowOverwrite = "infrastructureImportAllowOverwrite";
19981999
String lastName = "lastName";

sormas-api/src/main/java/de/symeda/sormas/api/i18n/Descriptions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public interface Descriptions {
1313
String aefiDashboardDiseaseFilter = "aefiDashboardDiseaseFilter";
1414
String aefiDashboardDistrictFilter = "aefiDashboardDistrictFilter";
1515
String aefiDashboardRegionFilter = "aefiDashboardRegionFilter";
16+
String birthdateFilterPartialMatchDescription = "birthdateFilterPartialMatchDescription";
1617
String Campaign_calculatedBasedOn = "Campaign.calculatedBasedOn";
1718
String Campaign_campaignPhase = "Campaign.campaignPhase";
1819
String CaseData_caseClassification = "CaseData.caseClassification";

sormas-api/src/main/java/de/symeda/sormas/api/i18n/Strings.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@ public interface Strings {
705705
String headingImportSelfReports = "headingImportSelfReports";
706706
String headingImportSubcontinents = "headingImportSubcontinents";
707707
String headingImportTravelEntries = "headingImportTravelEntries";
708+
String headingIncorrectDateRange = "headingIncorrectDateRange";
708709
String headingInformationSource = "headingInformationSource";
709710
String headingInfrastructureLocked = "headingInfrastructureLocked";
710711
String headingIntroduction = "headingIntroduction";
@@ -1419,6 +1420,7 @@ public interface Strings {
14191420
String messageImportSuccessful = "messageImportSuccessful";
14201421
String messageImportSuccessfulWithSkips = "messageImportSuccessfulWithSkips";
14211422
String messageIncompleteGpsCoordinates = "messageIncompleteGpsCoordinates";
1423+
String messageIncorrectDateRange = "messageIncorrectDateRange";
14221424
String messageInfrastructureLocked = "messageInfrastructureLocked";
14231425
String messageInvalidDatesLineListing = "messageInvalidDatesLineListing";
14241426
String messageLaboratoriesArchived = "messageLaboratoriesArchived";
@@ -1680,6 +1682,8 @@ public interface Strings {
16801682
String promptAllDistricts = "promptAllDistricts";
16811683
String promptAllRegions = "promptAllRegions";
16821684
String promptArea = "promptArea";
1685+
String promptBirthdateFrom = "promptBirthdateFrom";
1686+
String promptBirthdateTo = "promptBirthdateTo";
16831687
String promptCampaign = "promptCampaign";
16841688
String promptCampaignSearch = "promptCampaignSearch";
16851689
String promptCaseOrContactEventSearchField = "promptCaseOrContactEventSearchField";

sormas-api/src/main/java/de/symeda/sormas/api/person/PersonCriteria.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package de.symeda.sormas.api.person;
22

3+
import java.util.Date;
34
import java.util.Set;
45

56
import de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto;
@@ -37,6 +38,9 @@ public class PersonCriteria extends BaseCriteria implements Cloneable {
3738
private CommunityReferenceDto community;
3839
private PersonAssociation personAssociation;
3940
private Set<String> uuids;
41+
private Date birthdateFrom;
42+
private Date birthdateTo;
43+
private boolean includePartialMatch;
4044

4145
public PersonCriteria() {
4246

@@ -127,6 +131,31 @@ public PersonCriteria personAssociation(PersonAssociation personAssociation) {
127131
return this;
128132
}
129133

134+
public Date getBirthdateFrom() {
135+
return birthdateFrom;
136+
}
137+
138+
public void setBirthdateFrom(Date birthdateFrom) {
139+
this.birthdateFrom = birthdateFrom;
140+
}
141+
142+
public Date getBirthdateTo() {
143+
return birthdateTo;
144+
}
145+
146+
public void setBirthdateTo(Date birthdateTo) {
147+
this.birthdateTo = birthdateTo;
148+
}
149+
150+
@IgnoreForUrl
151+
public boolean isIncludePartialMatch() {
152+
return includePartialMatch;
153+
}
154+
155+
public void setIncludePartialMatch(boolean includePartialMatch) {
156+
this.includePartialMatch = includePartialMatch;
157+
}
158+
130159
@IgnoreForUrl
131160
public Set<String> getUuids() {
132161
return uuids;

sormas-api/src/main/resources/captions.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ creationDate=Creation date
5252
changeDate=Date of last change
5353
notAvailableShort=NA
5454
inaccessibleValue=Confidential
55+
includePartialBirthdates = Include partial birthdates
5556
numberOfCharacters=Number of characters: %d / %d
5657
remove=Remove
5758
notTestedYet=Not tested yet

sormas-api/src/main/resources/descriptions.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ descContactOnlyWithReducedQuarantine = Only list contacts whose quarantine perio
8080
descContactIncludeContactsFromOtherJurisdictions = Include all contacts from other jurisdictions that you have access to, e.g. because you created them or their source case is in your jurisdiction
8181
descGdpr = Reminder: All comments entered must comply with GDPR rules as described during connection.
8282
discardDescription = Discards any unsaved changes
83+
birthdateFilterPartialMatchDescription = If checked the search will include also the persons that have incomplete birthdate and have only higher level match eg. only year or only year and month
8384

8485
# EpiData
8586
EpiData.bats = Did you have contact with live or dead bats or their excreta during the incubation period?

sormas-api/src/main/resources/strings.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ headingImportRegions= Import Regions
620620
headingImportTravelEntries = Import Travel Entries
621621
headingImportEnvironments = Import Environments
622622
headingImportSelfReports = Import Self Reports
623+
headingIncorrectDateRange = Incorrect date range
623624
headingInformationSource = Source of Information
624625
headingInfrastructureLocked = Infrastructure locked
625626
headingIntroduction = Introduction
@@ -1314,6 +1315,7 @@ messageImportSuccessful = <b>Import successful!</b><br/>All rows have been impor
13141315
messageImportSuccessfulWithSkips = <b>Import successful!</b><br/>The import has been successful, but some of the rows were skipped. You can now close this window.
13151316
messageUploadSuccessful = Upload successful! You can now close this window.
13161317
messageIncompleteGpsCoordinates = GPS coordinates are incomplete
1318+
messageIncorrectDateRange = Date from is after date to
13171319
messageExternalMessagesAssigned = The assignee has been changed for all selected messages
13181320
messageLoginFailed = Please check your username and password and try again
13191321
messageMissingCases = Please generate some cases before generating contacts
@@ -1651,6 +1653,8 @@ promptActionChangeDateFrom = Date of action change from...
16511653
promptActionChangeDateTo = ... to
16521654
promptActionChangeEpiWeekFrom = Date of action change from epi week...
16531655
promptActionChangeEpiWeekTo = ... to epi week
1656+
promptBirthdateFrom = Birthdate from
1657+
promptBirthdateTo = ... to
16541658
promptCampaignSearch = ID, name
16551659
promptCasesDateFrom = New cases from...
16561660
promptCasesEpiWeekFrom = New cases from epi week...

sormas-backend/src/main/java/de/symeda/sormas/backend/caze/CaseService.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@
177177
import de.symeda.sormas.backend.user.User;
178178
import de.symeda.sormas.backend.user.UserRole;
179179
import de.symeda.sormas.backend.user.UserService;
180+
import de.symeda.sormas.backend.util.BirthdateRangeFilterPredicate;
180181
import de.symeda.sormas.backend.util.ExternalDataUtil;
181182
import de.symeda.sormas.backend.util.IterableHelper;
182183
import de.symeda.sormas.backend.util.JurisdictionHelper;
@@ -912,6 +913,15 @@ public <T extends AbstractDomainObject> Predicate createCriteriaFilter(CaseCrite
912913
filter = CriteriaBuilderHelper.and(cb, filter, likeFilters);
913914
}
914915
}
916+
917+
filter = BirthdateRangeFilterPredicate.createBirthdateRangeFilter(
918+
caseCriteria.getBirthdateFrom(),
919+
caseCriteria.getBirthdateTo(),
920+
caseCriteria.isIncludePartialMatch(),
921+
cb,
922+
joins.getPerson(),
923+
filter);
924+
915925
if (caseCriteria.getBirthdateYYYY() != null) {
916926
filter = CriteriaBuilderHelper.and(cb, filter, cb.equal(joins.getPerson().get(Person.BIRTHDATE_YYYY), caseCriteria.getBirthdateYYYY()));
917927
}

0 commit comments

Comments
 (0)