Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit f7e43a8

Browse files
SORMAS-Foundation#2902 - Extend event participant jurisdiction calculation
1 parent 5bd1726 commit f7e43a8

15 files changed

Lines changed: 294 additions & 41 deletions

File tree

sormas-api/src/main/java/de/symeda/sormas/api/event/EventParticipantDto.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
import de.symeda.sormas.api.caze.CaseReferenceDto;
2121
import de.symeda.sormas.api.person.PersonDto;
22+
import de.symeda.sormas.api.region.DistrictReferenceDto;
23+
import de.symeda.sormas.api.region.RegionReferenceDto;
2224
import de.symeda.sormas.api.user.UserReferenceDto;
2325
import de.symeda.sormas.api.utils.DataHelper;
2426
import de.symeda.sormas.api.utils.EmbeddedPersonalData;
@@ -36,6 +38,9 @@ public class EventParticipantDto extends PseudonymizableDto {
3638
public static final String PERSON = "person";
3739
public static final String INVOLVEMENT_DESCRIPTION = "involvementDescription";
3840
public static final String RESULTING_CASE = "resultingCase";
41+
public static final String REPORTING_USER = "reportingUser";
42+
public static final String REGION = "region";
43+
public static final String DISTRICT = "district";
3944

4045
private UserReferenceDto reportingUser;
4146
@Required
@@ -46,6 +51,8 @@ public class EventParticipantDto extends PseudonymizableDto {
4651
@SensitiveData
4752
private String involvementDescription;
4853
private CaseReferenceDto resultingCase; // read-only
54+
private RegionReferenceDto region;
55+
private DistrictReferenceDto district;
4956

5057
public static EventParticipantDto build(EventReferenceDto event, UserReferenceDto reportingUser) {
5158
EventParticipantDto eventParticipant = new EventParticipantDto();
@@ -123,4 +130,20 @@ public CaseReferenceDto getResultingCase() {
123130
public void setResultingCase(CaseReferenceDto resultingCase) {
124131
this.resultingCase = resultingCase;
125132
}
133+
134+
public RegionReferenceDto getRegion() {
135+
return region;
136+
}
137+
138+
public void setRegion(RegionReferenceDto region) {
139+
this.region = region;
140+
}
141+
142+
public DistrictReferenceDto getDistrict() {
143+
return district;
144+
}
145+
146+
public void setDistrict(DistrictReferenceDto district) {
147+
this.district = district;
148+
}
126149
}

sormas-api/src/main/java/de/symeda/sormas/api/event/EventParticipantJurisdictionDto.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
public class EventParticipantJurisdictionDto implements Serializable {
2121

2222
private String reportingUserUuid;
23+
private String regionUuid;
24+
private String districtUuid;
2325

2426
public EventParticipantJurisdictionDto() {
2527
}
@@ -35,4 +37,20 @@ public String getReportingUserUuid() {
3537
public void setReportingUserUuid(String reportingUserUuid) {
3638
this.reportingUserUuid = reportingUserUuid;
3739
}
40+
41+
public String getRegionUuid() {
42+
return regionUuid;
43+
}
44+
45+
public void setRegionUuid(String regionUuid) {
46+
this.regionUuid = regionUuid;
47+
}
48+
49+
public String getDistrictUuid() {
50+
return districtUuid;
51+
}
52+
53+
public void setDistrictUuid(String districtUuid) {
54+
this.districtUuid = districtUuid;
55+
}
3856
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,11 +875,13 @@ public interface Captions {
875875
String EventParticipant = "EventParticipant";
876876
String EventParticipant_approximateAge = "EventParticipant.approximateAge";
877877
String EventParticipant_caseUuid = "EventParticipant.caseUuid";
878+
String EventParticipant_district = "EventParticipant.district";
878879
String EventParticipant_event = "EventParticipant.event";
879880
String EventParticipant_involvementDescription = "EventParticipant.involvementDescription";
880881
String EventParticipant_name = "EventParticipant.name";
881882
String EventParticipant_person = "EventParticipant.person";
882883
String EventParticipant_personUuid = "EventParticipant.personUuid";
884+
String EventParticipant_region = "EventParticipant.region";
883885
String EventParticipant_sex = "EventParticipant.sex";
884886
String EventParticipant_uuid = "EventParticipant.uuid";
885887
String eventParticipantAddPerson = "eventParticipantAddPerson";

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ public interface Strings {
299299
String headingErrorReportNotAvailable = "headingErrorReportNotAvailable";
300300
String headingEventData = "headingEventData";
301301
String headingEventNotDeleted = "headingEventNotDeleted";
302+
String headingEventParticipantResponsibleJurisdictionUpdated = "headingEventParticipantResponsibleJurisdictionUpdated";
302303
String headingEventParticipantsDeleted = "headingEventParticipantsDeleted";
303304
String headingEventsArchived = "headingEventsArchived";
304305
String headingEventsDearchived = "headingEventsDearchived";
@@ -610,6 +611,7 @@ public interface Strings {
610611
String messageEventCreated = "messageEventCreated";
611612
String messageEventDearchived = "messageEventDearchived";
612613
String messageEventParticipantCreated = "messageEventParticipantCreated";
614+
String messageEventParticipantResponsibleJurisdictionUpdated = "messageEventParticipantResponsibleJurisdictionUpdated";
613615
String messageEventParticipantSaved = "messageEventParticipantSaved";
614616
String messageEventParticipantsDeleted = "messageEventParticipantsDeleted";
615617
String messageEventsArchived = "messageEventsArchived";

sormas-api/src/main/java/de/symeda/sormas/api/utils/jurisdiction/EventJurisdictionHelper.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ public static boolean isInJurisdictionOrOwned(
1111
UserJurisdiction userJurisdiction,
1212
EventJurisdictionDto eventJurisdiction) {
1313

14+
if (isOwned(userJurisdiction, eventJurisdiction))
15+
return true;
16+
17+
return isInJurisdiction(jurisdictionLevel, userJurisdiction, eventJurisdiction);
18+
}
19+
20+
public static boolean isOwned(UserJurisdiction userJurisdiction, EventJurisdictionDto eventJurisdiction) {
1421
if (eventJurisdiction.getReportingUserUuid() != null
1522
&& DataHelper.equal(userJurisdiction.getUuid(), eventJurisdiction.getReportingUserUuid())) {
1623
return true;
@@ -20,7 +27,13 @@ public static boolean isInJurisdictionOrOwned(
2027
&& DataHelper.equal(userJurisdiction.getUuid(), eventJurisdiction.getSurveillanceOfficerUuid())) {
2128
return true;
2229
}
30+
return false;
31+
}
2332

33+
public static boolean isInJurisdiction(
34+
JurisdictionLevel jurisdictionLevel,
35+
UserJurisdiction userJurisdiction,
36+
EventJurisdictionDto eventJurisdiction) {
2437
switch (jurisdictionLevel) {
2538
case NONE:
2639
return false;

sormas-api/src/main/java/de/symeda/sormas/api/utils/jurisdiction/EventParticipantJurisdictionHelper.java

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,58 @@
1717

1818
import de.symeda.sormas.api.event.EventParticipantJurisdictionDto;
1919
import de.symeda.sormas.api.user.JurisdictionLevel;
20+
import de.symeda.sormas.api.utils.DataHelper;
2021

2122
public class EventParticipantJurisdictionHelper {
2223

2324
public static boolean isInJurisdictionOrOwned(
24-
// jurisdictionLevel will be needed in the future
2525
JurisdictionLevel jurisdictionLevel,
2626
UserJurisdiction userJurisdiction,
2727
EventParticipantJurisdictionDto eventParticipantJurisdiction) {
2828

29-
/*
30-
* if (eventParticipantJurisdiction.getReportingUserUuid() != null
31-
* && DataHelper.equal(eventParticipantJurisdiction.getReportingUserUuid(), userJurisdiction.getUuid())) {
32-
* return true;
33-
* }
34-
* return false;
35-
*/
29+
if (isOwned(userJurisdiction, eventParticipantJurisdiction))
30+
return true;
3631

37-
return true;
32+
return isInJurisdiction(jurisdictionLevel, userJurisdiction, eventParticipantJurisdiction);
33+
}
34+
35+
public static boolean isOwned(UserJurisdiction userJurisdiction, EventParticipantJurisdictionDto eventParticipantJurisdiction) {
36+
37+
if (eventParticipantJurisdiction.getReportingUserUuid() != null
38+
&& DataHelper.equal(userJurisdiction.getUuid(), eventParticipantJurisdiction.getReportingUserUuid())) {
39+
return true;
40+
}
41+
return false;
42+
}
43+
44+
public static boolean isInJurisdiction(
45+
JurisdictionLevel jurisdictionLevel,
46+
UserJurisdiction userJurisdiction,
47+
EventParticipantJurisdictionDto eventParticipantJurisdiction) {
3848

49+
switch (jurisdictionLevel) {
50+
case NONE:
51+
return false;
52+
case NATION:
53+
return true;
54+
case REGION:
55+
return eventParticipantJurisdiction.getRegionUuid() != null
56+
&& DataHelper.equal(eventParticipantJurisdiction.getRegionUuid(), userJurisdiction.getRegionUuid());
57+
case DISTRICT:
58+
return eventParticipantJurisdiction.getDistrictUuid() != null
59+
&& DataHelper.equal(eventParticipantJurisdiction.getDistrictUuid(), userJurisdiction.getDistrictUuid());
60+
case COMMUNITY:
61+
return false;
62+
case HEALTH_FACILITY:
63+
return false;
64+
case LABORATORY:
65+
return false;
66+
case EXTERNAL_LABORATORY:
67+
return false;
68+
case POINT_OF_ENTRY:
69+
return false;
70+
default:
71+
return false;
72+
}
3973
}
4074
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,8 @@ EventParticipant.personUuid=Person ID
987987
EventParticipant.involvementDescription=Involvement description
988988
EventParticipant.person=Person
989989
EventParticipant.uuid=Event participant ID
990+
EventParticipant.region=Responsible region
991+
EventParticipant.district=Responsible district
990992

991993
#EventParticipant export
992994
EventParticipantExport.eventParticipantU=Event disease

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ headingEpiCurve = Epidemiological Curve
331331
headingErrorReportNotAvailable = Error report not available
332332
headingEventData = Event data
333333
headingEventParticipantsDeleted = Event participants deleted
334+
headingEventParticipantResponsibleJurisdictionUpdated = Event participant jurisdiction update
334335
headingEventsArchived = Events archived
335336
headingEventsDearchived = Events de-archived
336337
headingEventsDeleted = Events deleted
@@ -620,6 +621,7 @@ messageEventDearchived = Event has been de-archived
620621
messageEventParticipantCreated = New person created
621622
messageEventParticipantSaved = Person data saved
622623
messageEventParticipantsDeleted = All selected event participants have been deleted
624+
messageEventParticipantResponsibleJurisdictionUpdated = Changing or removing the responsible jurisdiction could make the current event participant read only or pseudonymized . Are you sure you want to continue?
623625
messageEventSaved = Event data saved
624626
messageEventsArchived = All selected events have been archived
625627
messageEventsDearchived = All selected events have been de-archived

sormas-backend/src/main/java/de/symeda/sormas/backend/event/EventJurisdictionChecker.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,19 @@ public boolean isInJurisdictionOrOwned(EventJurisdictionDto eventJurisdiction) {
4646
return EventJurisdictionHelper
4747
.isInJurisdictionOrOwned(user.getJurisdictionLevel(), JurisdictionHelper.createUserJurisdiction(user), eventJurisdiction);
4848
}
49+
50+
public boolean isOwned(Event event) {
51+
User user = userService.getCurrentUser();
52+
EventJurisdictionDto eventJurisdictionDto = JurisdictionHelper.createEventJurisdictionDto(event);
53+
54+
return EventJurisdictionHelper.isOwned(JurisdictionHelper.createUserJurisdiction(user), eventJurisdictionDto);
55+
}
56+
57+
public boolean isInJurisdiction(Event event) {
58+
User user = userService.getCurrentUser();
59+
EventJurisdictionDto eventJurisdictionDto = JurisdictionHelper.createEventJurisdictionDto(event);
60+
61+
return EventJurisdictionHelper
62+
.isInJurisdiction(user.getJurisdictionLevel(), JurisdictionHelper.createUserJurisdiction(user), eventJurisdictionDto);
63+
}
4964
}

sormas-backend/src/main/java/de/symeda/sormas/backend/event/EventParticipant.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
import de.symeda.auditlog.api.Audited;
3030
import de.symeda.sormas.backend.caze.Case;
3131
import de.symeda.sormas.backend.common.CoreAdo;
32-
import de.symeda.sormas.backend.contact.Contact;
3332
import de.symeda.sormas.backend.person.Person;
33+
import de.symeda.sormas.backend.region.District;
34+
import de.symeda.sormas.backend.region.Region;
3435
import de.symeda.sormas.backend.sample.Sample;
3536
import de.symeda.sormas.backend.user.User;
3637

@@ -54,6 +55,8 @@ public class EventParticipant extends CoreAdo {
5455
private String involvementDescription;
5556
private Case resultingCase;
5657
private Set<Sample> samples;
58+
private Region region;
59+
private District district;
5760

5861
@ManyToOne(cascade = {})
5962
public User getReportingUser() {
@@ -116,4 +119,21 @@ public void setSamples(Set<Sample> samples) {
116119
this.samples = samples;
117120
}
118121

122+
@ManyToOne(cascade = {})
123+
public Region getRegion() {
124+
return region;
125+
}
126+
127+
public void setRegion(Region region) {
128+
this.region = region;
129+
}
130+
131+
@ManyToOne(cascade = {})
132+
public District getDistrict() {
133+
return district;
134+
}
135+
136+
public void setDistrict(District district) {
137+
this.district = district;
138+
}
119139
}

0 commit comments

Comments
 (0)