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

Commit 7daef7f

Browse files
Merge remote-tracking branch 'origin/SORMAS-Foundation#3965-Samples_for_even_participants_are_not_shown_hot_fix' into hotfix-1.54.1
2 parents 093b166 + 547d258 commit 7daef7f

9 files changed

Lines changed: 152 additions & 27 deletions

File tree

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919

2020
public class EventParticipantJurisdictionDto implements Serializable {
2121

22+
private String eventParticipantUuid;
2223
private String reportingUserUuid;
2324
private String regionUuid;
2425
private String districtUuid;
26+
private String eventUuid;
2527

2628
public EventParticipantJurisdictionDto() {
2729
}
@@ -30,6 +32,27 @@ public EventParticipantJurisdictionDto(String reportingUserUuid) {
3032
this.reportingUserUuid = reportingUserUuid;
3133
}
3234

35+
public EventParticipantJurisdictionDto(
36+
String eventParticipantUuid,
37+
String reportingUserUuid,
38+
String regionUuid,
39+
String districtUuid,
40+
String eventUuid) {
41+
this.eventParticipantUuid = eventParticipantUuid;
42+
this.reportingUserUuid = reportingUserUuid;
43+
this.regionUuid = regionUuid;
44+
this.districtUuid = districtUuid;
45+
this.eventUuid = eventUuid;
46+
}
47+
48+
public String getEventParticipantUuid() {
49+
return eventParticipantUuid;
50+
}
51+
52+
public void setEventParticipantUuid(String eventParticipantUuid) {
53+
this.eventParticipantUuid = eventParticipantUuid;
54+
}
55+
3356
public String getReportingUserUuid() {
3457
return reportingUserUuid;
3558
}
@@ -53,4 +76,12 @@ public String getDistrictUuid() {
5376
public void setDistrictUuid(String districtUuid) {
5477
this.districtUuid = districtUuid;
5578
}
79+
80+
public String getEventUuid() {
81+
return eventUuid;
82+
}
83+
84+
public void setEventUuid(String eventUuid) {
85+
this.eventUuid = eventUuid;
86+
}
5687
}

sormas-api/src/main/java/de/symeda/sormas/api/sample/SampleExportDto.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import de.symeda.sormas.api.contact.ContactJurisdictionDto;
2020
import de.symeda.sormas.api.contact.ContactReferenceDto;
2121
import de.symeda.sormas.api.contact.ContactStatus;
22-
import de.symeda.sormas.api.event.EventJurisdictionDto;
22+
import de.symeda.sormas.api.event.EventParticipantJurisdictionDto;
2323
import de.symeda.sormas.api.event.EventParticipantReferenceDto;
2424
import de.symeda.sormas.api.facility.FacilityHelper;
2525
import de.symeda.sormas.api.location.LocationReferenceDto;
@@ -283,17 +283,21 @@ public SampleExportDto(long id, String uuid, String labSampleId, Date sampleRepo
283283
this.contactDistrict = contactDistrict;
284284
}
285285

286-
EventJurisdictionDto associatedEventJurisdiction = null;
286+
EventParticipantJurisdictionDto associatedEventParticipantJurisdiction = null;
287287
if (eventParticipantUuid != null) {
288-
associatedEventJurisdiction =
289-
new EventJurisdictionDto(eventReportingUserUuid, eventOfficerUuid, eventRegionUuid, eventDistrictUuid, eventCommunityUuid);
288+
associatedEventParticipantJurisdiction = new EventParticipantJurisdictionDto(
289+
associatedEventParticipant.getUuid(),
290+
eventReportingUserUuid,
291+
eventRegionUuid,
292+
eventDistrictUuid,
293+
eventCommunityUuid);
290294
}
291295

292296
jurisdiction = new SampleJurisdictionDto(
293297
reportingUserUuid,
294298
associatedCaseJurisdiction,
295299
associatedContactJurisdiction,
296-
associatedEventJurisdiction,
300+
associatedEventParticipantJurisdiction,
297301
labUuid);
298302
}
299303

sormas-api/src/main/java/de/symeda/sormas/api/sample/SampleIndexDto.java

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@
1717
*******************************************************************************/
1818
package de.symeda.sormas.api.sample;
1919

20+
import java.io.Serializable;
21+
import java.util.Date;
22+
2023
import de.symeda.sormas.api.Disease;
2124
import de.symeda.sormas.api.caze.CaseJurisdictionDto;
2225
import de.symeda.sormas.api.caze.CaseReferenceDto;
2326
import de.symeda.sormas.api.contact.ContactJurisdictionDto;
2427
import de.symeda.sormas.api.contact.ContactReferenceDto;
25-
import de.symeda.sormas.api.event.EventJurisdictionDto;
28+
import de.symeda.sormas.api.event.EventParticipantJurisdictionDto;
2629
import de.symeda.sormas.api.event.EventParticipantReferenceDto;
2730
import de.symeda.sormas.api.facility.FacilityHelper;
2831
import de.symeda.sormas.api.facility.FacilityReferenceDto;
@@ -33,9 +36,6 @@
3336
import de.symeda.sormas.api.utils.pseudonymization.Pseudonymizer;
3437
import de.symeda.sormas.api.utils.pseudonymization.valuepseudonymizers.EmptyValuePseudonymizer;
3538

36-
import java.io.Serializable;
37-
import java.util.Date;
38-
3939
public class SampleIndexDto extends PseudonymizableIndexDto implements Serializable {
4040

4141
private static final long serialVersionUID = -6298614717044087479L;
@@ -111,7 +111,7 @@ public SampleIndexDto(String uuid, String epidNumber, String labSampleId, Date s
111111
String contactReportingUserUuid, String contactRegionUuid, String contactDistrictUuid, String contactCommunityUuid,
112112
String contactCaseReportingUserUuid, String contactCaseRegionUuid, String contactCaseDistrictUuid,
113113
String contactCaseCommunityUuid, String contactCaseHealthFacilityUuid, String contactCasePointOfEntryUuid,
114-
String eventReportingUserUuid, String eventOfficerUuid, String eventRegionUuid, String eventDistrictUuid, String eventCommunityUuid) {
114+
String eventReportingUserUuid, String eventOfficerUuid, String eventParticipantRegionUuid, String eventParticipantDistrictUuid, String eventUuid) {
115115
//@formatter:on
116116

117117
this.uuid = uuid;
@@ -132,7 +132,8 @@ public SampleIndexDto(String uuid, String epidNumber, String labSampleId, Date s
132132
this.labSampleID = labSampleId;
133133
this.disease = disease;
134134
this.diseaseDetails = diseaseDetails;
135-
this.district = createDistrictReference(districtName, caseDistrictUuid, contactDistrictUuid, contactCaseDistrictUuid, eventDistrictUuid);
135+
this.district =
136+
createDistrictReference(districtName, caseDistrictUuid, contactDistrictUuid, contactCaseDistrictUuid, eventParticipantDistrictUuid);
136137
this.shipped = shipped;
137138
this.received = received;
138139
this.referred = referredSampleUuid != null;
@@ -178,14 +179,22 @@ public SampleIndexDto(String uuid, String epidNumber, String labSampleId, Date s
178179
contactCaseJurisdiction);
179180
}
180181

181-
EventJurisdictionDto eventJurisdiction = null;
182+
EventParticipantJurisdictionDto eventParticipantJurisdiction = null;
182183
if (associatedEventParticipantUuid != null) {
183-
eventJurisdiction =
184-
new EventJurisdictionDto(eventReportingUserUuid, eventOfficerUuid, eventRegionUuid, eventDistrictUuid, eventCommunityUuid);
184+
eventParticipantJurisdiction = new EventParticipantJurisdictionDto(
185+
associatedEventParticipantUuid,
186+
eventReportingUserUuid,
187+
eventParticipantRegionUuid,
188+
eventParticipantDistrictUuid,
189+
eventUuid);
185190
}
186191

187-
jurisdiction =
188-
new SampleJurisdictionDto(reportingUserUuid, associatedCaseJurisdiction, associatedContactJurisdiction, eventJurisdiction, labUuid);
192+
jurisdiction = new SampleJurisdictionDto(
193+
reportingUserUuid,
194+
associatedCaseJurisdiction,
195+
associatedContactJurisdiction,
196+
eventParticipantJurisdiction,
197+
labUuid);
189198
}
190199

191200
private DistrictReferenceDto createDistrictReference(

sormas-api/src/main/java/de/symeda/sormas/api/sample/SampleJurisdictionDto.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
import de.symeda.sormas.api.caze.CaseJurisdictionDto;
66
import de.symeda.sormas.api.contact.ContactJurisdictionDto;
7-
import de.symeda.sormas.api.event.EventJurisdictionDto;
7+
import de.symeda.sormas.api.event.EventParticipantJurisdictionDto;
88

99
public class SampleJurisdictionDto implements Serializable {
1010

1111
private String reportingUserUuid;
1212
private CaseJurisdictionDto caseJurisdiction;
1313
private ContactJurisdictionDto contactJurisdiction;
14-
private EventJurisdictionDto eventJurisdiction;
14+
private EventParticipantJurisdictionDto eventParticipantJurisdiction;
1515
private String labUuid;
1616

1717
public SampleJurisdictionDto() {
@@ -22,11 +22,12 @@ public SampleJurisdictionDto(
2222
String reportingUserUuid,
2323
CaseJurisdictionDto caseJurisdiction,
2424
ContactJurisdictionDto contactJurisdiction,
25-
EventJurisdictionDto eventJurisdiction,
25+
EventParticipantJurisdictionDto eventParticipantJurisdiction,
2626
String labUuid) {
2727
this.reportingUserUuid = reportingUserUuid;
2828
this.caseJurisdiction = caseJurisdiction;
2929
this.contactJurisdiction = contactJurisdiction;
30+
this.eventParticipantJurisdiction = eventParticipantJurisdiction;
3031
this.labUuid = labUuid;
3132
}
3233

@@ -54,12 +55,12 @@ public void setContactJurisdiction(ContactJurisdictionDto contactJurisdiction) {
5455
this.contactJurisdiction = contactJurisdiction;
5556
}
5657

57-
public EventJurisdictionDto getEventJurisdiction() {
58-
return eventJurisdiction;
58+
public EventParticipantJurisdictionDto getEventParticipantJurisdiction() {
59+
return eventParticipantJurisdiction;
5960
}
6061

61-
public void setEventJurisdiction(EventJurisdictionDto eventJurisdiction) {
62-
this.eventJurisdiction = eventJurisdiction;
62+
public void setEventParticipantJurisdiction(EventParticipantJurisdictionDto eventParticipantJurisdiction) {
63+
this.eventParticipantJurisdiction = eventParticipantJurisdiction;
6364
}
6465

6566
public String getLabUuid() {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ public static boolean isInJurisdictionOrOwned(
3535
.isInJurisdictionOrOwned(jurisdictionLevel, userJurisdiction, sampleJurisdiction.getContactJurisdiction());
3636
}
3737

38+
if (sampleJurisdiction.getEventParticipantJurisdiction() != null) {
39+
return EventParticipantJurisdictionHelper
40+
.isInJurisdictionOrOwned(jurisdictionLevel, userJurisdiction, sampleJurisdiction.getEventParticipantJurisdiction());
41+
}
42+
3843
return false;
3944
}
4045
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public class EventParticipantJurisdictionChecker {
3838
private EventParticipantJurisdictionDto createEventParticipantJurisdictionDto(EventParticipant eventParticipant) {
3939
EventParticipantJurisdictionDto jurisdiction = new EventParticipantJurisdictionDto();
4040

41+
jurisdiction.setEventParticipantUuid(eventParticipant.getUuid());
42+
4143
if (eventParticipant.getReportingUser() != null) {
4244
jurisdiction.setReportingUserUuid(eventParticipant.getReportingUser().getUuid());
4345
}
@@ -50,6 +52,10 @@ private EventParticipantJurisdictionDto createEventParticipantJurisdictionDto(Ev
5052
jurisdiction.setDistrictUuid(eventParticipant.getDistrict().getUuid());
5153
}
5254

55+
if (eventParticipant.getEvent() != null) {
56+
jurisdiction.setEventUuid(eventParticipant.getEvent().getUuid());
57+
}
58+
5359
return jurisdiction;
5460
}
5561

@@ -92,6 +98,8 @@ public boolean isPseudonymized(EventParticipant eventParticipant) {
9298
boolean isInEventParticipantJurisdiction = isInJurisdiction(eventParticipant);
9399
boolean isInEventJurisdiction = isInEventJurisdiction(eventParticipant);
94100

101+
// "true" means the pseudomyzatnion will not occur
102+
// "return" false means the sensitive data will be pseudonymized
95103
return isOwned || isInEventParticipantJurisdiction || isInEventJurisdiction;
96104
}
97105

sormas-backend/src/main/java/de/symeda/sormas/backend/sample/SampleFacadeEjb.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
import de.symeda.sormas.backend.event.EventJurisdictionChecker;
9090
import de.symeda.sormas.backend.event.EventParticipant;
9191
import de.symeda.sormas.backend.event.EventParticipantFacadeEjb;
92+
import de.symeda.sormas.backend.event.EventParticipantJurisdictionChecker;
9293
import de.symeda.sormas.backend.event.EventParticipantService;
9394
import de.symeda.sormas.backend.facility.Facility;
9495
import de.symeda.sormas.backend.facility.FacilityFacadeEjb;
@@ -169,6 +170,8 @@ public class SampleFacadeEjb implements SampleFacade {
169170
@EJB
170171
private EventJurisdictionChecker eventJurisdictionChecker;
171172
@EJB
173+
private EventParticipantJurisdictionChecker eventParticipantJurisdictionChecker;
174+
@EJB
172175
private SormasToSormasOriginInfoFacadeEjbLocal originInfoFacade;
173176
@EJB
174177
private SormasToSormasShareInfoService sormasToSormasShareInfoService;
@@ -809,7 +812,13 @@ private void pseudonymizeDto(Sample source, SampleDto dto, Pseudonymizer pseudon
809812
boolean isInJurisdiction = sampleJurisdictionChecker.isInJurisdictionOrOwned(sampleJurisdiction);
810813
User currentUser = userService.getCurrentUser();
811814

812-
pseudonymizer.pseudonymizeDto(SampleDto.class, dto, isInJurisdiction, s -> {
815+
boolean samplePseudonimized = true;
816+
if (dto.getAssociatedEventParticipant() != null) {
817+
samplePseudonimized = eventParticipantJurisdictionChecker.isPseudonymized(dto.getAssociatedEventParticipant().getUuid());
818+
}
819+
EventParticipantReferenceDto eventParticipantReference = dto.getAssociatedEventParticipant();
820+
821+
pseudonymizer.pseudonymizeDto(SampleDto.class, dto, eventParticipantReference != null ? samplePseudonimized : isInJurisdiction, s -> {
813822
pseudonymizer.pseudonymizeUser(source.getReportingUser(), currentUser, s::setReportingUser);
814823
pseudonymizeAssociatedObjects(
815824
sampleJurisdiction,
@@ -818,7 +827,6 @@ private void pseudonymizeDto(Sample source, SampleDto dto, Pseudonymizer pseudon
818827
s.getAssociatedEventParticipant(),
819828
pseudonymizer);
820829
});
821-
822830
}
823831
}
824832

@@ -869,7 +877,7 @@ private void pseudonymizeAssociatedObjects(
869877
pseudonymizer.pseudonymizeDto(
870878
EventParticipantReferenceDto.class,
871879
sampleEventParticipant,
872-
eventJurisdictionChecker.isInJurisdictionOrOwned(sampleJurisdiction.getEventJurisdiction()),
880+
eventParticipantJurisdictionChecker.isPseudonymized(sampleEventParticipant.getUuid()),
873881
null);
874882
}
875883
}

sormas-backend/src/main/java/de/symeda/sormas/backend/sample/SampleJurisdictionChecker.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
import de.symeda.sormas.api.sample.SampleJurisdictionDto;
88
import de.symeda.sormas.api.utils.jurisdiction.SampleJurisdictionHelper;
9+
import de.symeda.sormas.backend.event.EventParticipant;
10+
import de.symeda.sormas.backend.event.EventParticipantJurisdictionChecker;
11+
import de.symeda.sormas.backend.event.EventParticipantService;
912
import de.symeda.sormas.backend.user.User;
1013
import de.symeda.sormas.backend.user.UserService;
1114
import de.symeda.sormas.backend.util.JurisdictionHelper;
@@ -16,6 +19,10 @@ public class SampleJurisdictionChecker {
1619

1720
@EJB
1821
private UserService userService;
22+
@EJB
23+
private EventParticipantJurisdictionChecker eventParticipantJurisdictionChecker;
24+
@EJB
25+
private EventParticipantService eventParticipantService;
1926

2027
public boolean isInJurisdictionOrOwned(Sample sample) {
2128

@@ -26,8 +33,23 @@ public boolean isInJurisdictionOrOwned(SampleJurisdictionDto sampleJurisdiction)
2633

2734
User user = userService.getCurrentUser();
2835

36+
if (sampleJurisdiction.getEventParticipantJurisdiction() != null) {
37+
EventParticipant sampleEventParticipant =
38+
eventParticipantService.getByUuid(sampleJurisdiction.getEventParticipantJurisdiction().getEventParticipantUuid());
39+
return eventParticipantJurisdictionChecker.isInJurisdiction(sampleEventParticipant);
40+
}
41+
2942
return SampleJurisdictionHelper
3043
.isInJurisdictionOrOwned(user.getJurisdictionLevel(), JurisdictionHelper.createUserJurisdiction(user), sampleJurisdiction);
3144
}
3245

46+
public boolean isPseudonymized(Sample sample) {
47+
48+
if (sample.getAssociatedEventParticipant() != null) {
49+
eventParticipantJurisdictionChecker.isPseudonymized(sample.getAssociatedEventParticipant());
50+
}
51+
52+
return false;
53+
54+
}
3355
}

0 commit comments

Comments
 (0)