Skip to content

Commit c55c812

Browse files
Defaulting the exposure setting to "Mosquito-borne" for malaria and dengue diseases.
1 parent 5ba0cd0 commit c55c812

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

sormas-ui/src/main/java/de/symeda/sormas/ui/exposure/ExposureForm.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.util.List;
3232
import java.util.Map;
3333
import java.util.Set;
34+
import java.util.stream.Stream;
3435

3536
import com.vaadin.icons.VaadinIcons;
3637
import com.vaadin.shared.ui.ContentMode;
@@ -500,7 +501,12 @@ private void updateSettingFieldItems(ExposureCategory category) {
500501
FieldHelper.updateItems(settingField, settings);
501502

502503
// Clear the field and its dependent details field
503-
settingField.setValue(null);
504+
// if the disease is Malaria or Dengue and the category is VECTOR_BORNE, preselect MOSQUITO_BORNE as setting (since it's the only valid option in this case)
505+
ExposureSetting defaultSetting =
506+
Stream.of(Disease.MALARIA, Disease.DENGUE).anyMatch(d -> d == disease) && category == ExposureCategory.VECTOR_BORNE
507+
? ExposureSetting.MOSQUITO_BORNE
508+
: null;
509+
settingField.setValue(defaultSetting);
504510
settingDetailsField.setValue(null);
505511
settingDetailsField.setVisible(false);
506512

sormas-ui/src/main/java/de/symeda/sormas/ui/exposure/ExposuresField.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public class ExposuresField extends AbstractTableField<ExposureDto> {
7474
private static final String COLUMN_DATE = Captions.date;
7575
private static final String COLUMN_ADDRESS = Captions.address;
7676
private static final String COLUMN_DESCRIPTION = ExposureDto.DESCRIPTION;
77+
private static final String COLUMN_PROPHYLAXIS_ADHERENCE = ExposureDto.PROPHYLAXIS_ADHERENCE;
7778

7879
private final FieldVisibilityCheckers fieldVisibilityCheckers;
7980
private Supplier<List<ContactReferenceDto>> getSourceContactsCallback;
@@ -106,6 +107,7 @@ protected void updateColumns() {
106107
ACTION_COLUMN_ID,
107108
COLUMN_EXPOSURE_CATEGORY,
108109
COLUMN_EXPOSURE_SETTING,
110+
COLUMN_PROPHYLAXIS_ADHERENCE,
109111
COLUMN_DATE,
110112
COLUMN_ADDRESS,
111113
COLUMN_DESCRIPTION);
@@ -165,7 +167,6 @@ private void addGeneratedColumns(Table table) {
165167
if (exposure.getSubSettings() != null && !exposure.getSubSettings().isEmpty()) {
166168
return exposure.getSubSettings().stream().map(Object::toString).collect(Collectors.joining(", "));
167169
}
168-
return "";
169170

170171
default:
171172
return exposure.getExposureSetting() != null ? exposure.getExposureSetting().toString() : "";
@@ -191,6 +192,10 @@ private void addGeneratedColumns(Table table) {
191192

192193
return descriptionLabel;
193194
});
195+
table.addGeneratedColumn(COLUMN_PROPHYLAXIS_ADHERENCE, (Table.ColumnGenerator) (source, itemId, columnId) -> {
196+
ExposureDto exposure = (ExposureDto) itemId;
197+
return exposure.getProphylaxisAdherence() != null ? exposure.getProphylaxisAdherence().toString() : "";
198+
});
194199
}
195200

196201
@Override

0 commit comments

Comments
 (0)