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

Commit 31a4d45

Browse files
Merge pull request SORMAS-Foundation#3535 from hzi-braunschweig/2902-Extend_event_participant_jurisdiction_calculation
2902 extend event participant jurisdiction calculation
2 parents b5294d0 + 2a7f3b9 commit 31a4d45

15 files changed

Lines changed: 294 additions & 40 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
@@ -880,11 +880,13 @@ public interface Captions {
880880
String EventParticipant_approximateAge = "EventParticipant.approximateAge";
881881
String EventParticipant_caseUuid = "EventParticipant.caseUuid";
882882
String EventParticipant_contactCount = "EventParticipant.contactCount";
883+
String EventParticipant_district = "EventParticipant.district";
883884
String EventParticipant_event = "EventParticipant.event";
884885
String EventParticipant_involvementDescription = "EventParticipant.involvementDescription";
885886
String EventParticipant_name = "EventParticipant.name";
886887
String EventParticipant_person = "EventParticipant.person";
887888
String EventParticipant_personUuid = "EventParticipant.personUuid";
889+
String EventParticipant_region = "EventParticipant.region";
888890
String EventParticipant_sex = "EventParticipant.sex";
889891
String EventParticipant_uuid = "EventParticipant.uuid";
890892
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
@@ -302,6 +302,7 @@ public interface Strings {
302302
String headingErrorReportNotAvailable = "headingErrorReportNotAvailable";
303303
String headingEventData = "headingEventData";
304304
String headingEventNotDeleted = "headingEventNotDeleted";
305+
String headingEventParticipantResponsibleJurisdictionUpdated = "headingEventParticipantResponsibleJurisdictionUpdated";
305306
String headingEventParticipantsDeleted = "headingEventParticipantsDeleted";
306307
String headingEventsArchived = "headingEventsArchived";
307308
String headingEventsDearchived = "headingEventsDearchived";
@@ -615,6 +616,7 @@ public interface Strings {
615616
String messageEventCreated = "messageEventCreated";
616617
String messageEventDearchived = "messageEventDearchived";
617618
String messageEventParticipantCreated = "messageEventParticipantCreated";
619+
String messageEventParticipantResponsibleJurisdictionUpdated = "messageEventParticipantResponsibleJurisdictionUpdated";
618620
String messageEventParticipantSaved = "messageEventParticipantSaved";
619621
String messageEventParticipantsDeleted = "messageEventParticipantsDeleted";
620622
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
@@ -995,6 +995,8 @@ EventParticipant.personUuid=Person ID
995995
EventParticipant.involvementDescription=Involvement description
996996
EventParticipant.person=Person
997997
EventParticipant.uuid=Event participant ID
998+
EventParticipant.region=Responsible region
999+
EventParticipant.district=Responsible district
9981000

9991001
#EventParticipant export
10001002
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
@@ -334,6 +334,7 @@ headingEpiCurve = Epidemiological Curve
334334
headingErrorReportNotAvailable = Error report not available
335335
headingEventData = Event data
336336
headingEventParticipantsDeleted = Event participants deleted
337+
headingEventParticipantResponsibleJurisdictionUpdated = Event participant jurisdiction update
337338
headingEventsArchived = Events archived
338339
headingEventsDearchived = Events de-archived
339340
headingEventsDeleted = Events deleted
@@ -625,6 +626,7 @@ messageEventDearchived = Event has been de-archived
625626
messageEventParticipantCreated = New person created
626627
messageEventParticipantSaved = Person data saved
627628
messageEventParticipantsDeleted = All selected event participants have been deleted
629+
messageEventParticipantResponsibleJurisdictionUpdated = Changing or removing the responsible jurisdiction could make the current event participant read only or pseudonymized . Are you sure you want to continue?
628630
messageEventSaved = Event data saved
629631
messageEventsArchived = All selected events have been archived
630632
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)