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 @@ -31,6 +31,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Stream;

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

// Clear the field and its dependent details field
settingField.setValue(null);
// 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)
ExposureSetting defaultSetting =
Stream.of(Disease.MALARIA, Disease.DENGUE).anyMatch(d -> d == disease) && category == ExposureCategory.VECTOR_BORNE
? ExposureSetting.MOSQUITO_BORNE
: null;
settingField.setValue(defaultSetting);
settingDetailsField.setValue(null);
settingDetailsField.setVisible(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public class ExposuresField extends AbstractTableField<ExposureDto> {
private static final String COLUMN_DATE = Captions.date;
private static final String COLUMN_ADDRESS = Captions.address;
private static final String COLUMN_DESCRIPTION = ExposureDto.DESCRIPTION;
private static final String COLUMN_PROPHYLAXIS_ADHERENCE = ExposureDto.PROPHYLAXIS_ADHERENCE;

private final FieldVisibilityCheckers fieldVisibilityCheckers;
private Supplier<List<ContactReferenceDto>> getSourceContactsCallback;
Expand Down Expand Up @@ -106,6 +107,7 @@ protected void updateColumns() {
ACTION_COLUMN_ID,
COLUMN_EXPOSURE_CATEGORY,
COLUMN_EXPOSURE_SETTING,
COLUMN_PROPHYLAXIS_ADHERENCE,
COLUMN_DATE,
COLUMN_ADDRESS,
COLUMN_DESCRIPTION);
Expand Down Expand Up @@ -165,7 +167,6 @@ private void addGeneratedColumns(Table table) {
if (exposure.getSubSettings() != null && !exposure.getSubSettings().isEmpty()) {
return exposure.getSubSettings().stream().map(Object::toString).collect(Collectors.joining(", "));
}
return "";

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

return descriptionLabel;
});
table.addGeneratedColumn(COLUMN_PROPHYLAXIS_ADHERENCE, (Table.ColumnGenerator) (source, itemId, columnId) -> {
ExposureDto exposure = (ExposureDto) itemId;
return exposure.getProphylaxisAdherence() != null ? exposure.getProphylaxisAdherence().toString() : "";
});
}

@Override
Expand Down
Loading