|
| 1 | +/* |
| 2 | + * SORMAS® - Surveillance Outbreak Response Management & Analysis System |
| 3 | + * Copyright © 2016-2024 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI) |
| 4 | + * This program is free software: you can redistribute it and/or modify |
| 5 | + * it under the terms of the GNU General Public License as published by |
| 6 | + * the Free Software Foundation, either version 3 of the License, or |
| 7 | + * (at your option) any later version. |
| 8 | + * This program is distributed in the hope that it will be useful, |
| 9 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | + * GNU General Public License for more details. |
| 12 | + * You should have received a copy of the GNU General Public License |
| 13 | + * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 14 | + */ |
| 15 | + |
| 16 | +package de.symeda.sormas.api.exposure; |
| 17 | + |
| 18 | +import java.util.Arrays; |
| 19 | +import java.util.Collections; |
| 20 | +import java.util.List; |
| 21 | +import java.util.stream.Collectors; |
| 22 | + |
| 23 | +import de.symeda.sormas.api.i18n.I18nProperties; |
| 24 | + |
| 25 | +public enum ExposureContactFactor { |
| 26 | + |
| 27 | + DURATION_OF_EXPOSURE(ExposureCategory.AIR_BORNE, ExposureSetting.INDOOR), |
| 28 | + PROXIMITY_TO_SOURCE(ExposureCategory.AIR_BORNE, ExposureSetting.INDOOR), |
| 29 | + TYPE_OF_ACTIVITY(ExposureCategory.AIR_BORNE, ExposureSetting.INDOOR), |
| 30 | + POOR_VENTILATION(ExposureCategory.AIR_BORNE, ExposureSetting.INDOOR), |
| 31 | + |
| 32 | + PROXIMITY_AND_DURATION(ExposureCategory.AIR_BORNE, ExposureSetting.OUTDOOR), |
| 33 | + WIND_AND_AIRFLOW(ExposureCategory.AIR_BORNE, ExposureSetting.OUTDOOR), |
| 34 | + DENSITY_OF_PEOPLE(ExposureCategory.AIR_BORNE, ExposureSetting.OUTDOOR), |
| 35 | + |
| 36 | + SKIN_CONTACT(ExposureCategory.DIRECT_CONTACT, ExposureSetting.PERSON_TO_PERSON), |
| 37 | + BODY_FLUIDS(ExposureCategory.DIRECT_CONTACT, ExposureSetting.PERSON_TO_PERSON), |
| 38 | + |
| 39 | + BUTCHERING(ExposureCategory.ANIMAL_CONTACT, null), |
| 40 | + COOKING(ExposureCategory.ANIMAL_CONTACT, null), |
| 41 | + TOUCHING_CONTACT_WITH_FLUIDS(ExposureCategory.ANIMAL_CONTACT, null), |
| 42 | + SCRATCHES_BITES_LICKING(ExposureCategory.ANIMAL_CONTACT, null), |
| 43 | + |
| 44 | + SHARED_SURFACES(ExposureCategory.FOMITE_TRANSMISSION, null), |
| 45 | + |
| 46 | + OUTDOOR_ACTIVITIES(ExposureCategory.VECTOR_BORNE, ExposureSetting.OUTDOOR), |
| 47 | + STANDING_WATER_PROXIMITY(ExposureCategory.VECTOR_BORNE, ExposureSetting.OUTDOOR), |
| 48 | + HIGH_MOSQUITO_ACTIVITY_REGIONS(ExposureCategory.VECTOR_BORNE, ExposureSetting.OUTDOOR), |
| 49 | + |
| 50 | + UNPROTECTED_HOUSEHOLD(ExposureCategory.VECTOR_BORNE, ExposureSetting.INDOOR), |
| 51 | + |
| 52 | + MOSQUITO_ACTIVITY_TIME_OF_DAY(ExposureCategory.VECTOR_BORNE, ExposureSetting.MOSQUITO_BORNE), |
| 53 | + CLOTHING_COVERAGE(ExposureCategory.VECTOR_BORNE, ExposureSetting.MOSQUITO_BORNE), |
| 54 | + |
| 55 | + DURATION_OUTDOORS(ExposureCategory.VECTOR_BORNE, ExposureSetting.TICK_BORNE), |
| 56 | + EXPOSED_SKIN(ExposureCategory.VECTOR_BORNE, ExposureSetting.TICK_BORNE), |
| 57 | + |
| 58 | + DRINKING_CONTAMINATED_WATER(ExposureCategory.WATER_BORNE, ExposureSetting.DRINKING_WATER), |
| 59 | + ICE_AND_FOOD_PREPARATION(ExposureCategory.WATER_BORNE, ExposureSetting.DRINKING_WATER), |
| 60 | + |
| 61 | + SWALLOWING_WATER(ExposureCategory.WATER_BORNE, ExposureSetting.RECREATIONAL_WATER), |
| 62 | + CONTACT_WITH_OPEN_WOUNDS(ExposureCategory.WATER_BORNE, ExposureSetting.RECREATIONAL_WATER), |
| 63 | + |
| 64 | + EGG(ExposureCategory.FOOD_BORNE, null), |
| 65 | + MEAT(ExposureCategory.FOOD_BORNE, null), |
| 66 | + FISH_SEAFOOD(ExposureCategory.FOOD_BORNE, null), |
| 67 | + DAIRY(ExposureCategory.FOOD_BORNE, null), |
| 68 | + FRUIT(ExposureCategory.FOOD_BORNE, null), |
| 69 | + RAW_VEGETABLES(ExposureCategory.FOOD_BORNE, null), |
| 70 | + |
| 71 | + UNKNOWN(null, null), |
| 72 | + OTHER(null, null); |
| 73 | + |
| 74 | + private final ExposureCategory category; |
| 75 | + private final ExposureSetting setting; |
| 76 | + |
| 77 | + ExposureContactFactor(ExposureCategory category, ExposureSetting setting) { |
| 78 | + this.category = category; |
| 79 | + this.setting = setting; |
| 80 | + } |
| 81 | + |
| 82 | + public ExposureCategory getCategory() { |
| 83 | + return category; |
| 84 | + } |
| 85 | + |
| 86 | + public ExposureSetting getSetting() { |
| 87 | + return setting; |
| 88 | + } |
| 89 | + |
| 90 | + /** |
| 91 | + * Returns contact factors for a given category and setting combination. |
| 92 | + * <ul> |
| 93 | + * <li>Factors with matching category AND setting are included.</li> |
| 94 | + * <li>Factors with matching category and null setting (category-wide) are included.</li> |
| 95 | + * <li>UNKNOWN and OTHER (null category) are always included.</li> |
| 96 | + * </ul> |
| 97 | + * |
| 98 | + * Because INDOOR/OUTDOOR are shared settings, the category parameter |
| 99 | + * ensures (AIR_BORNE, INDOOR) and (VECTOR_BORNE, INDOOR) return different factors. |
| 100 | + */ |
| 101 | + public static List<ExposureContactFactor> getValues(ExposureCategory category, ExposureSetting setting) { |
| 102 | + if (category == null) { |
| 103 | + return Collections.emptyList(); |
| 104 | + } |
| 105 | + return Arrays.stream(values()).filter(cf -> { |
| 106 | + if (cf.category == null) { |
| 107 | + return true; // UNKNOWN, OTHER |
| 108 | + } |
| 109 | + if (cf.category != category) { |
| 110 | + return false; |
| 111 | + } |
| 112 | + return cf.setting == null || cf.setting == setting; |
| 113 | + }).collect(Collectors.toList()); |
| 114 | + } |
| 115 | + |
| 116 | + @Override |
| 117 | + public String toString() { |
| 118 | + return I18nProperties.getEnumCaption(this); |
| 119 | + } |
| 120 | +} |
0 commit comments