Skip to content

Commit 227edcc

Browse files
authored
Merge pull request #13934 from SORMAS-Foundation/feature-13918-salmonellosis-form-enhancements
Feature 13918 salmonellosis form enhancements
2 parents 5d78b2f + a4275cc commit 227edcc

29 files changed

Lines changed: 472 additions & 278 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ public class CaseDataDto extends SormasToSormasShareableDto implements IsCase {
389389
Disease.OTHER })
390390
@Outbreaks
391391
private VaccinationStatus vaccinationStatus;
392+
@Diseases(value = Disease.SALMONELLOSIS, hide = true)
392393
@Outbreaks
393394
@Size(max = FieldConstraints.CHARACTER_LIMIT_DEFAULT, message = Validations.textTooLong)
394395
private String vaccinationStatusDetails;

sormas-api/src/main/java/de/symeda/sormas/api/exposure/EatingOutVenue.java

Lines changed: 0 additions & 39 deletions
This file was deleted.

sormas-api/src/main/java/de/symeda/sormas/api/exposure/ExposureDto.java

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ public class ExposureDto extends PseudonymizableDto {
141141
public static final String PROPHYLAXIS_ADHERENCE_DETAILS = "prophylaxisAdherenceDetails";
142142
public static final String TRAVEL_PURPOSE = "travelPurpose";
143143
public static final String TRAVEL_PURPOSE_DETAILS = "travelPurposeDetails";
144-
public static final String EATING_OUT_VENUES = "eatingOutVenues";
145-
public static final String EATING_OUT_VENUE_OTHER = "eatingOutVenueOther";
146144
public static final String SHOPPING_FOR_FOOD_DETAILS = "shoppingForFoodDetails";
147145

148146
@SensitiveData
@@ -461,17 +459,6 @@ public class ExposureDto extends PseudonymizableDto {
461459
@Size(max = FieldConstraints.CHARACTER_LIMIT_TEXT, message = Validations.textTooLong)
462460
private String travelPurposeDetails;
463461

464-
@Diseases({
465-
Disease.SALMONELLOSIS })
466-
@HideForCountriesExcept(countries = {
467-
CountryHelper.COUNTRY_CODE_LUXEMBOURG })
468-
private Set<EatingOutVenue> eatingOutVenues;
469-
@Diseases({
470-
Disease.SALMONELLOSIS })
471-
@HideForCountriesExcept(countries = {
472-
CountryHelper.COUNTRY_CODE_LUXEMBOURG })
473-
@Size(max = FieldConstraints.CHARACTER_LIMIT_DEFAULT, message = Validations.textTooLong)
474-
private String eatingOutVenueOther;
475462
@Diseases({
476463
Disease.SALMONELLOSIS })
477464
@HideForCountriesExcept(countries = {
@@ -490,7 +477,6 @@ public static ExposureDto build(ExposureType exposureType) {
490477
exposure.setSubSettings(new HashSet<>());
491478
exposure.setContactFactors(new HashSet<>());
492479
exposure.setProtectiveMeasures(new HashSet<>());
493-
exposure.setEatingOutVenues(new HashSet<>());
494480

495481
return exposure;
496482
}
@@ -1175,22 +1161,6 @@ public void setProphylaxisAdherenceDetails(String prophylaxisAdherenceDetails) {
11751161
this.prophylaxisAdherenceDetails = prophylaxisAdherenceDetails;
11761162
}
11771163

1178-
public Set<EatingOutVenue> getEatingOutVenues() {
1179-
return eatingOutVenues;
1180-
}
1181-
1182-
public void setEatingOutVenues(Set<EatingOutVenue> eatingOutVenues) {
1183-
this.eatingOutVenues = eatingOutVenues;
1184-
}
1185-
1186-
public String getEatingOutVenueOther() {
1187-
return eatingOutVenueOther;
1188-
}
1189-
1190-
public void setEatingOutVenueOther(String eatingOutVenueOther) {
1191-
this.eatingOutVenueOther = eatingOutVenueOther;
1192-
}
1193-
11941164
public String getShoppingForFoodDetails() {
11951165
return shoppingForFoodDetails;
11961166
}

sormas-api/src/main/java/de/symeda/sormas/api/exposure/ExposureSubSetting.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
import java.util.List;
2121
import java.util.stream.Collectors;
2222

23+
import de.symeda.sormas.api.Disease;
2324
import de.symeda.sormas.api.i18n.I18nProperties;
25+
import de.symeda.sormas.api.utils.Diseases;
2426

2527
public enum ExposureSubSetting {
2628

@@ -49,6 +51,8 @@ public enum ExposureSubSetting {
4951

5052
EATING_AT_HOME(ExposureCategory.FOOD_BORNE, null),
5153
EATING_OUTSIDE(ExposureCategory.FOOD_BORNE, null),
54+
@Diseases({
55+
Disease.SALMONELLOSIS })
5256
SHOPPING_FOR_FOOD(ExposureCategory.FOOD_BORNE, null),
5357

5458
UNKNOWN(null, null),
@@ -90,6 +94,15 @@ public static List<ExposureSubSetting> getValues(ExposureCategory category, Expo
9094
.collect(Collectors.toList());
9195
}
9296

97+
/**
98+
* Disease-aware overload: filters the values returned by {@link #getValues(ExposureCategory, ExposureSetting)}
99+
* to those whose {@code @Diseases} annotation matches the given disease (or values with no annotation,
100+
* which apply to every disease).
101+
*/
102+
public static List<ExposureSubSetting> getValues(ExposureCategory category, ExposureSetting setting, Disease disease) {
103+
return getValues(category, setting).stream().filter(s -> isVisibleForDisease(s, disease)).collect(Collectors.toList());
104+
}
105+
93106
public static List<ExposureSubSetting> getValuesForCategoryOnly(ExposureCategory category) {
94107
if (category == null) {
95108
return Collections.emptyList();
@@ -109,6 +122,19 @@ public static List<ExposureSubSetting> getValuesForCategoryOnly(ExposureCategory
109122
return Arrays.stream(values()).filter(s -> (s.category == category && s.setting == null) || s.category == null).collect(Collectors.toList());
110123
}
111124

125+
/**
126+
* Disease-aware overload: filters the values returned by {@link #getValuesForCategoryOnly(ExposureCategory)}
127+
* to those whose {@code @Diseases} annotation matches the given disease (or values with no annotation).
128+
*/
129+
public static List<ExposureSubSetting> getValuesForCategoryOnly(ExposureCategory category, Disease disease) {
130+
return getValuesForCategoryOnly(category).stream().filter(s -> isVisibleForDisease(s, disease)).collect(Collectors.toList());
131+
}
132+
133+
private static boolean isVisibleForDisease(ExposureSubSetting subSetting, Disease disease) {
134+
return Diseases.DiseasesConfiguration.isMissing(ExposureSubSetting.class, subSetting.name())
135+
|| Diseases.DiseasesConfiguration.isDefined(ExposureSubSetting.class, subSetting.name(), disease);
136+
}
137+
112138
@Override
113139
public String toString() {
114140
return I18nProperties.getEnumCaption(this);

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,8 +1902,6 @@ public interface Captions {
19021902
String Exposure_deceasedPersonName = "Exposure.deceasedPersonName";
19031903
String Exposure_deceasedPersonRelation = "Exposure.deceasedPersonRelation";
19041904
String Exposure_domesticSwimming = "Exposure.domesticSwimming";
1905-
String Exposure_eatingOutVenueOther = "Exposure.eatingOutVenueOther";
1906-
String Exposure_eatingOutVenues = "Exposure.eatingOutVenues";
19071905
String Exposure_eatingRawAnimalProducts = "Exposure.eatingRawAnimalProducts";
19081906
String Exposure_endDate = "Exposure.endDate";
19091907
String Exposure_exposureCategory = "Exposure.exposureCategory";

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

Lines changed: 88 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public enum PathogenTestType {
3030
Disease.GIARDIASIS,
3131
Disease.CRYPTOSPORIDIOSIS,
3232
Disease.DENGUE,
33-
Disease.MALARIA }, hide = true)
33+
Disease.MALARIA,
34+
Disease.SALMONELLOSIS }, hide = true)
3435
ANTIBODY_DETECTION,
3536

3637
ANTIGEN_DETECTION,
@@ -55,7 +56,8 @@ public enum PathogenTestType {
5556
Disease.GIARDIASIS,
5657
Disease.CRYPTOSPORIDIOSIS,
5758
Disease.DENGUE,
58-
Disease.MALARIA }, hide = true)
59+
Disease.MALARIA,
60+
Disease.SALMONELLOSIS }, hide = true)
5961
HISTOPATHOLOGY,
6062

6163
@Diseases(value = {
@@ -91,7 +93,8 @@ public enum PathogenTestType {
9193
Disease.GIARDIASIS,
9294
Disease.CRYPTOSPORIDIOSIS,
9395
Disease.DENGUE,
94-
Disease.MALARIA }, hide = true)
96+
Disease.MALARIA,
97+
Disease.SALMONELLOSIS }, hide = true)
9598
IGA_SERUM_ANTIBODY,
9699

97100
@Diseases(value = {
@@ -103,7 +106,8 @@ public enum PathogenTestType {
103106
Disease.GIARDIASIS,
104107
Disease.CRYPTOSPORIDIOSIS,
105108
Disease.DENGUE,
106-
Disease.MALARIA }, hide = true)
109+
Disease.MALARIA,
110+
Disease.SALMONELLOSIS }, hide = true)
107111
INCUBATION_TIME,
108112

109113
@Diseases(value = {
@@ -128,7 +132,8 @@ public enum PathogenTestType {
128132
Disease.RESPIRATORY_SYNCYTIAL_VIRUS,
129133
Disease.MEASLES,
130134
Disease.DENGUE,
131-
Disease.MALARIA }, hide = true)
135+
Disease.MALARIA,
136+
Disease.SALMONELLOSIS }, hide = true)
132137
MICROSCOPY,
133138

134139
@Diseases(value = {
@@ -137,14 +142,18 @@ public enum PathogenTestType {
137142
Disease.MEASLES,
138143
Disease.GIARDIASIS,
139144
Disease.CRYPTOSPORIDIOSIS,
140-
Disease.MALARIA }, hide = true)
145+
Disease.MALARIA,
146+
Disease.SALMONELLOSIS }, hide = true)
141147
NEUTRALIZING_ANTIBODIES,
142148

143149
@Diseases(value = {
144150
Disease.RESPIRATORY_SYNCYTIAL_VIRUS,
145151
Disease.MALARIA })
146152
ENZYME_LINKED_IMMUNOSORBENT_ASSAY,
147153

154+
@Diseases(value = {
155+
Disease.SALMONELLOSIS }, hide = true)
156+
@RevealsTestTypeText
148157
PCR_RT_PCR,
149158

150159
@Diseases(value = {
@@ -154,7 +163,8 @@ public enum PathogenTestType {
154163
Disease.GIARDIASIS,
155164
Disease.CRYPTOSPORIDIOSIS,
156165
Disease.DENGUE,
157-
Disease.MALARIA }, hide = true)
166+
Disease.MALARIA,
167+
Disease.SALMONELLOSIS }, hide = true)
158168
GRAM_STAIN,
159169

160170
@Diseases(value = {
@@ -166,7 +176,8 @@ public enum PathogenTestType {
166176
Disease.GIARDIASIS,
167177
Disease.CRYPTOSPORIDIOSIS,
168178
Disease.DENGUE,
169-
Disease.MALARIA }, hide = true)
179+
Disease.MALARIA,
180+
Disease.SALMONELLOSIS }, hide = true)
170181
LATEX_AGGLUTINATION,
171182

172183
@Diseases(value = {
@@ -177,7 +188,8 @@ public enum PathogenTestType {
177188
Disease.GIARDIASIS,
178189
Disease.CRYPTOSPORIDIOSIS,
179190
Disease.DENGUE,
180-
Disease.MALARIA }, hide = true)
191+
Disease.MALARIA,
192+
Disease.SALMONELLOSIS }, hide = true)
181193
CQ_VALUE_DETECTION,
182194

183195
@Diseases(value = {
@@ -195,7 +207,8 @@ public enum PathogenTestType {
195207
Disease.GIARDIASIS,
196208
Disease.CRYPTOSPORIDIOSIS,
197209
Disease.DENGUE,
198-
Disease.MALARIA }, hide = true)
210+
Disease.MALARIA,
211+
Disease.SALMONELLOSIS }, hide = true)
199212
DNA_MICROARRAY,
200213

201214
@Diseases(value = {
@@ -206,7 +219,8 @@ public enum PathogenTestType {
206219
Disease.GIARDIASIS,
207220
Disease.CRYPTOSPORIDIOSIS,
208221
Disease.DENGUE,
209-
Disease.MALARIA }, hide = true)
222+
Disease.MALARIA,
223+
Disease.SALMONELLOSIS }, hide = true)
210224
TMA,
211225

212226
@Diseases(value = {
@@ -243,9 +257,32 @@ public enum PathogenTestType {
243257

244258
@Diseases(value = {
245259
Disease.INVASIVE_MENINGOCOCCAL_INFECTION,
246-
Disease.INVASIVE_PNEUMOCOCCAL_INFECTION })
260+
Disease.INVASIVE_PNEUMOCOCCAL_INFECTION,
261+
Disease.SALMONELLOSIS })
262+
@RevealsTestTypeText(diseases = Disease.SALMONELLOSIS)
247263
MULTILOCUS_SEQUENCE_TYPING,
248264

265+
@Diseases(value = {
266+
Disease.INVASIVE_MENINGOCOCCAL_INFECTION,
267+
Disease.INVASIVE_PNEUMOCOCCAL_INFECTION,
268+
Disease.SALMONELLOSIS })
269+
@RevealsTestTypeText(diseases = Disease.SALMONELLOSIS)
270+
CGMLST,
271+
272+
@Diseases(value = {
273+
Disease.INVASIVE_MENINGOCOCCAL_INFECTION,
274+
Disease.INVASIVE_PNEUMOCOCCAL_INFECTION,
275+
Disease.SALMONELLOSIS })
276+
@RevealsTestTypeText(diseases = Disease.SALMONELLOSIS)
277+
SNP_TYPING,
278+
279+
@Diseases(value = {
280+
Disease.INVASIVE_MENINGOCOCCAL_INFECTION,
281+
Disease.INVASIVE_PNEUMOCOCCAL_INFECTION,
282+
Disease.SALMONELLOSIS })
283+
@RevealsTestTypeText(diseases = Disease.SALMONELLOSIS)
284+
SEROTYPING,
285+
249286
@Diseases(value = {
250287
Disease.INVASIVE_MENINGOCOCCAL_INFECTION,
251288
Disease.INVASIVE_PNEUMOCOCCAL_INFECTION })
@@ -296,6 +333,7 @@ public enum PathogenTestType {
296333
@Diseases({
297334
Disease.MALARIA })
298335
OTHER_SEROLOGICAL_TEST,
336+
@RevealsTestTypeText
299337
OTHER;
300338

301339
@Override
@@ -304,6 +342,10 @@ public String toString() {
304342
}
305343

306344
public static String toString(PathogenTestType value, String details) {
345+
return toString(value, details, null);
346+
}
347+
348+
public static String toString(PathogenTestType value, String details, Disease disease) {
307349
if (value == null) {
308350
return "";
309351
}
@@ -312,6 +354,40 @@ public static String toString(PathogenTestType value, String details) {
312354
return DataHelper.toStringNullable(details);
313355
}
314356

357+
if (revealsTestTypeText(value, disease) && !DataHelper.isNullOrEmpty(details)) {
358+
return value + " (" + details + ")";
359+
}
360+
315361
return value.toString();
316362
}
363+
364+
/**
365+
* @return true when picking {@code testType} should reveal the {@code PathogenTestDto.testTypeText} free-text
366+
* companion field. The decision is data-driven via {@link RevealsTestTypeText} on the enum value; values
367+
* with no annotation never reveal the field, values annotated without a disease list reveal it for every
368+
* disease, and values with a disease list reveal it only when {@code disease} is one of those listed.
369+
*/
370+
public static boolean revealsTestTypeText(PathogenTestType testType, Disease disease) {
371+
if (testType == null) {
372+
return false;
373+
}
374+
try {
375+
RevealsTestTypeText annotation = PathogenTestType.class.getField(testType.name()).getAnnotation(RevealsTestTypeText.class);
376+
if (annotation == null) {
377+
return false;
378+
}
379+
Disease[] diseases = annotation.diseases();
380+
if (diseases.length == 0) {
381+
return true;
382+
}
383+
for (Disease d : diseases) {
384+
if (d == disease) {
385+
return true;
386+
}
387+
}
388+
return false;
389+
} catch (NoSuchFieldException e) {
390+
return false;
391+
}
392+
}
317393
}

0 commit comments

Comments
 (0)