Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ public class CaseDataDto extends SormasToSormasShareableDto implements IsCase {
Disease.OTHER })
@Outbreaks
private VaccinationStatus vaccinationStatus;
@Diseases(value = Disease.SALMONELLOSIS, hide = true)
@Outbreaks
@Size(max = FieldConstraints.CHARACTER_LIMIT_DEFAULT, message = Validations.textTooLong)
private String vaccinationStatusDetails;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ public class ExposureDto extends PseudonymizableDto {
public static final String PROPHYLAXIS_ADHERENCE_DETAILS = "prophylaxisAdherenceDetails";
public static final String TRAVEL_PURPOSE = "travelPurpose";
public static final String TRAVEL_PURPOSE_DETAILS = "travelPurposeDetails";
public static final String EATING_OUT_VENUES = "eatingOutVenues";
public static final String EATING_OUT_VENUE_OTHER = "eatingOutVenueOther";
public static final String SHOPPING_FOR_FOOD_DETAILS = "shoppingForFoodDetails";

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

@Diseases({
Disease.SALMONELLOSIS })
@HideForCountriesExcept(countries = {
CountryHelper.COUNTRY_CODE_LUXEMBOURG })
private Set<EatingOutVenue> eatingOutVenues;
@Diseases({
Disease.SALMONELLOSIS })
@HideForCountriesExcept(countries = {
CountryHelper.COUNTRY_CODE_LUXEMBOURG })
@Size(max = FieldConstraints.CHARACTER_LIMIT_DEFAULT, message = Validations.textTooLong)
private String eatingOutVenueOther;
@Diseases({
Disease.SALMONELLOSIS })
@HideForCountriesExcept(countries = {
Expand All @@ -490,7 +477,6 @@ public static ExposureDto build(ExposureType exposureType) {
exposure.setSubSettings(new HashSet<>());
exposure.setContactFactors(new HashSet<>());
exposure.setProtectiveMeasures(new HashSet<>());
exposure.setEatingOutVenues(new HashSet<>());

return exposure;
}
Expand Down Expand Up @@ -1175,22 +1161,6 @@ public void setProphylaxisAdherenceDetails(String prophylaxisAdherenceDetails) {
this.prophylaxisAdherenceDetails = prophylaxisAdherenceDetails;
}

public Set<EatingOutVenue> getEatingOutVenues() {
return eatingOutVenues;
}

public void setEatingOutVenues(Set<EatingOutVenue> eatingOutVenues) {
this.eatingOutVenues = eatingOutVenues;
}

public String getEatingOutVenueOther() {
return eatingOutVenueOther;
}

public void setEatingOutVenueOther(String eatingOutVenueOther) {
this.eatingOutVenueOther = eatingOutVenueOther;
}

public String getShoppingForFoodDetails() {
return shoppingForFoodDetails;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
import java.util.List;
import java.util.stream.Collectors;

import de.symeda.sormas.api.Disease;
import de.symeda.sormas.api.i18n.I18nProperties;
import de.symeda.sormas.api.utils.Diseases;

public enum ExposureSubSetting {

Expand Down Expand Up @@ -49,6 +51,8 @@ public enum ExposureSubSetting {

EATING_AT_HOME(ExposureCategory.FOOD_BORNE, null),
EATING_OUTSIDE(ExposureCategory.FOOD_BORNE, null),
@Diseases({
Disease.SALMONELLOSIS })
SHOPPING_FOR_FOOD(ExposureCategory.FOOD_BORNE, null),

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

/**
* Disease-aware overload: filters the values returned by {@link #getValues(ExposureCategory, ExposureSetting)}
* to those whose {@code @Diseases} annotation matches the given disease (or values with no annotation,
* which apply to every disease).
*/
public static List<ExposureSubSetting> getValues(ExposureCategory category, ExposureSetting setting, Disease disease) {
return getValues(category, setting).stream().filter(s -> isVisibleForDisease(s, disease)).collect(Collectors.toList());
}

public static List<ExposureSubSetting> getValuesForCategoryOnly(ExposureCategory category) {
if (category == null) {
return Collections.emptyList();
Expand All @@ -109,6 +122,19 @@ public static List<ExposureSubSetting> getValuesForCategoryOnly(ExposureCategory
return Arrays.stream(values()).filter(s -> (s.category == category && s.setting == null) || s.category == null).collect(Collectors.toList());
}

/**
* Disease-aware overload: filters the values returned by {@link #getValuesForCategoryOnly(ExposureCategory)}
* to those whose {@code @Diseases} annotation matches the given disease (or values with no annotation).
*/
public static List<ExposureSubSetting> getValuesForCategoryOnly(ExposureCategory category, Disease disease) {
return getValuesForCategoryOnly(category).stream().filter(s -> isVisibleForDisease(s, disease)).collect(Collectors.toList());
}

private static boolean isVisibleForDisease(ExposureSubSetting subSetting, Disease disease) {
return Diseases.DiseasesConfiguration.isMissing(ExposureSubSetting.class, subSetting.name())
|| Diseases.DiseasesConfiguration.isDefined(ExposureSubSetting.class, subSetting.name(), disease);
}

@Override
public String toString() {
return I18nProperties.getEnumCaption(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1902,8 +1902,6 @@ public interface Captions {
String Exposure_deceasedPersonName = "Exposure.deceasedPersonName";
String Exposure_deceasedPersonRelation = "Exposure.deceasedPersonRelation";
String Exposure_domesticSwimming = "Exposure.domesticSwimming";
String Exposure_eatingOutVenueOther = "Exposure.eatingOutVenueOther";
String Exposure_eatingOutVenues = "Exposure.eatingOutVenues";
String Exposure_eatingRawAnimalProducts = "Exposure.eatingRawAnimalProducts";
String Exposure_endDate = "Exposure.endDate";
String Exposure_exposureCategory = "Exposure.exposureCategory";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public enum PathogenTestType {
Disease.GIARDIASIS,
Disease.CRYPTOSPORIDIOSIS,
Disease.DENGUE,
Disease.MALARIA }, hide = true)
Disease.MALARIA,
Disease.SALMONELLOSIS }, hide = true)
ANTIBODY_DETECTION,

ANTIGEN_DETECTION,
Expand All @@ -55,7 +56,8 @@ public enum PathogenTestType {
Disease.GIARDIASIS,
Disease.CRYPTOSPORIDIOSIS,
Disease.DENGUE,
Disease.MALARIA }, hide = true)
Disease.MALARIA,
Disease.SALMONELLOSIS }, hide = true)
HISTOPATHOLOGY,

@Diseases(value = {
Expand Down Expand Up @@ -91,7 +93,8 @@ public enum PathogenTestType {
Disease.GIARDIASIS,
Disease.CRYPTOSPORIDIOSIS,
Disease.DENGUE,
Disease.MALARIA }, hide = true)
Disease.MALARIA,
Disease.SALMONELLOSIS }, hide = true)
IGA_SERUM_ANTIBODY,

@Diseases(value = {
Expand All @@ -103,7 +106,8 @@ public enum PathogenTestType {
Disease.GIARDIASIS,
Disease.CRYPTOSPORIDIOSIS,
Disease.DENGUE,
Disease.MALARIA }, hide = true)
Disease.MALARIA,
Disease.SALMONELLOSIS }, hide = true)
INCUBATION_TIME,

@Diseases(value = {
Expand All @@ -128,7 +132,8 @@ public enum PathogenTestType {
Disease.RESPIRATORY_SYNCYTIAL_VIRUS,
Disease.MEASLES,
Disease.DENGUE,
Disease.MALARIA }, hide = true)
Disease.MALARIA,
Disease.SALMONELLOSIS }, hide = true)
MICROSCOPY,

@Diseases(value = {
Expand All @@ -137,14 +142,18 @@ public enum PathogenTestType {
Disease.MEASLES,
Disease.GIARDIASIS,
Disease.CRYPTOSPORIDIOSIS,
Disease.MALARIA }, hide = true)
Disease.MALARIA,
Disease.SALMONELLOSIS }, hide = true)
NEUTRALIZING_ANTIBODIES,

@Diseases(value = {
Disease.RESPIRATORY_SYNCYTIAL_VIRUS,
Disease.MALARIA })
ENZYME_LINKED_IMMUNOSORBENT_ASSAY,

@Diseases(value = {
Disease.SALMONELLOSIS }, hide = true)
@RevealsTestTypeText
PCR_RT_PCR,

@Diseases(value = {
Expand All @@ -154,7 +163,8 @@ public enum PathogenTestType {
Disease.GIARDIASIS,
Disease.CRYPTOSPORIDIOSIS,
Disease.DENGUE,
Disease.MALARIA }, hide = true)
Disease.MALARIA,
Disease.SALMONELLOSIS }, hide = true)
GRAM_STAIN,

@Diseases(value = {
Expand All @@ -166,7 +176,8 @@ public enum PathogenTestType {
Disease.GIARDIASIS,
Disease.CRYPTOSPORIDIOSIS,
Disease.DENGUE,
Disease.MALARIA }, hide = true)
Disease.MALARIA,
Disease.SALMONELLOSIS }, hide = true)
LATEX_AGGLUTINATION,

@Diseases(value = {
Expand All @@ -177,7 +188,8 @@ public enum PathogenTestType {
Disease.GIARDIASIS,
Disease.CRYPTOSPORIDIOSIS,
Disease.DENGUE,
Disease.MALARIA }, hide = true)
Disease.MALARIA,
Disease.SALMONELLOSIS }, hide = true)
CQ_VALUE_DETECTION,

@Diseases(value = {
Expand All @@ -195,7 +207,8 @@ public enum PathogenTestType {
Disease.GIARDIASIS,
Disease.CRYPTOSPORIDIOSIS,
Disease.DENGUE,
Disease.MALARIA }, hide = true)
Disease.MALARIA,
Disease.SALMONELLOSIS }, hide = true)
DNA_MICROARRAY,

@Diseases(value = {
Expand All @@ -206,7 +219,8 @@ public enum PathogenTestType {
Disease.GIARDIASIS,
Disease.CRYPTOSPORIDIOSIS,
Disease.DENGUE,
Disease.MALARIA }, hide = true)
Disease.MALARIA,
Disease.SALMONELLOSIS }, hide = true)
TMA,

@Diseases(value = {
Expand Down Expand Up @@ -243,9 +257,32 @@ public enum PathogenTestType {

@Diseases(value = {
Disease.INVASIVE_MENINGOCOCCAL_INFECTION,
Disease.INVASIVE_PNEUMOCOCCAL_INFECTION })
Disease.INVASIVE_PNEUMOCOCCAL_INFECTION,
Disease.SALMONELLOSIS })
@RevealsTestTypeText(diseases = Disease.SALMONELLOSIS)
MULTILOCUS_SEQUENCE_TYPING,

@Diseases(value = {
Disease.INVASIVE_MENINGOCOCCAL_INFECTION,
Disease.INVASIVE_PNEUMOCOCCAL_INFECTION,
Disease.SALMONELLOSIS })
@RevealsTestTypeText(diseases = Disease.SALMONELLOSIS)
CGMLST,

@Diseases(value = {
Disease.INVASIVE_MENINGOCOCCAL_INFECTION,
Disease.INVASIVE_PNEUMOCOCCAL_INFECTION,
Disease.SALMONELLOSIS })
@RevealsTestTypeText(diseases = Disease.SALMONELLOSIS)
SNP_TYPING,

@Diseases(value = {
Disease.INVASIVE_MENINGOCOCCAL_INFECTION,
Disease.INVASIVE_PNEUMOCOCCAL_INFECTION,
Disease.SALMONELLOSIS })
@RevealsTestTypeText(diseases = Disease.SALMONELLOSIS)
SEROTYPING,
Comment thread
coderabbitai[bot] marked this conversation as resolved.

@Diseases(value = {
Disease.INVASIVE_MENINGOCOCCAL_INFECTION,
Disease.INVASIVE_PNEUMOCOCCAL_INFECTION })
Expand Down Expand Up @@ -296,6 +333,7 @@ public enum PathogenTestType {
@Diseases({
Disease.MALARIA })
OTHER_SEROLOGICAL_TEST,
@RevealsTestTypeText
OTHER;

@Override
Expand All @@ -304,6 +342,10 @@ public String toString() {
}

public static String toString(PathogenTestType value, String details) {
return toString(value, details, null);
}

public static String toString(PathogenTestType value, String details, Disease disease) {
if (value == null) {
return "";
}
Expand All @@ -312,6 +354,40 @@ public static String toString(PathogenTestType value, String details) {
return DataHelper.toStringNullable(details);
}

if (revealsTestTypeText(value, disease) && !DataHelper.isNullOrEmpty(details)) {
return value + " (" + details + ")";
}

return value.toString();
}

/**
* @return true when picking {@code testType} should reveal the {@code PathogenTestDto.testTypeText} free-text
* companion field. The decision is data-driven via {@link RevealsTestTypeText} on the enum value; values
* with no annotation never reveal the field, values annotated without a disease list reveal it for every
* disease, and values with a disease list reveal it only when {@code disease} is one of those listed.
*/
public static boolean revealsTestTypeText(PathogenTestType testType, Disease disease) {
if (testType == null) {
return false;
}
try {
RevealsTestTypeText annotation = PathogenTestType.class.getField(testType.name()).getAnnotation(RevealsTestTypeText.class);
if (annotation == null) {
return false;
}
Disease[] diseases = annotation.diseases();
if (diseases.length == 0) {
return true;
}
for (Disease d : diseases) {
if (d == disease) {
return true;
}
}
return false;
} catch (NoSuchFieldException e) {
return false;
}
}
}
Loading
Loading