Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit ad77d10

Browse files
SORMAS-Foundation#3681 - Don't allow adding more than one exposure per contact
1 parent eece8a8 commit ad77d10

6 files changed

Lines changed: 32 additions & 1 deletion

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ public interface Strings {
476476
String infoEpiDataSourceCaseContacts = "infoEpiDataSourceCaseContacts";
477477
String infoExportNoFilters = "infoExportNoFilters";
478478
String infoExposureInvestigation = "infoExposureInvestigation";
479+
String infoExposureInvestigationContacts = "infoExposureInvestigationContacts";
479480
String infoExposuresRiskAreaHint = "infoExposuresRiskAreaHint";
480481
String infoHowToMergeCases = "infoHowToMergeCases";
481482
String infoImportAllCountries = "infoImportAllCountries";

sormas-api/src/main/resources/strings.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,7 @@ infoCreateNewSampleDiscardsChangesEventParticipant = Creating a new sample will
576576
infoUsageOfEditableCampaignGrids = You can edit the campaign data and dashboard definitions by clicking inside one of the cells in the grid, and you can reorder the dashboard elements by dragging and dropping the grid rows
577577
infoSaveOfTask = Saving this task will discard any unsaved changes made to the case.
578578
infoExposureInvestigation = <i>Please document ALL relevant direct exposures (e.g. attended gatherings, travels, animal contacts, etc.) during the incubation period:</i>
579+
infoExposureInvestigationContacts = <i>Please document information about the exposure that led to this contact:</i>
579580
infoEpiDataFieldsHint = <i>Please indicate if any of the following is relevant for the patient during the incubation period:</i>
580581
infoEpiDataSourceCaseContacts = <i>Please indicate ALL contacts with potential source cases during the incubation period:</i>
581582
infoNoSourceCase = No source case

sormas-api/src/main/resources/strings_de-CH.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,7 @@ infoCreateNewSampleDiscardsChangesEventParticipant = Die Erstellung einer neuen
577577
infoUsageOfEditableCampaignGrids = Sie können die Kampagnendaten und Dashboard-Definitionen bearbeiten, indem Sie innerhalb einer der Zellen im Raster klicken, und Sie können die Dashboard-Elemente durch Ziehen und Ablegen der Gitterzeilen neu ordnen
578578
infoSaveOfTask = Speichern dieser Aufgabe wird alle ungespeicherten Änderungen zu diesem Fall verwerfen.
579579
infoExposureInvestigation = <i>Bitte dokumentieren Sie ALLE relevanten direkten Expositionen (z.B. besuchte Versammlungen, Reisen, Tierkontakte usw.) während der Inkubationszeit\:</i>
580+
infoExposureInvestigationContacts = <i>Bitte dokumentieren Sie die Exposition, die zu diesem Kontakt geführt hat:</i>
580581
infoEpiDataFieldsHint = <i>Bitte geben Sie an, ob einer der folgenden Punkte für den/die Patient*in während des Inkubationszeitraums relevant ist.</i>
581582
infoEpiDataSourceCaseContacts = <i>Bitte geben Sie ALLE Kontakte mit möglichen Indexfällen während des Inkubationszeitraums an\:</i>
582583
infoNoSourceCase = Kein Indexfall

sormas-api/src/main/resources/strings_de-DE.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,7 @@ infoCreateNewSampleDiscardsChangesEventParticipant = Die Erstellung neuer Proben
577577
infoUsageOfEditableCampaignGrids = Sie können die Kampagnendaten und Dashboard-Definitionen bearbeiten, indem Sie innerhalb einer der Zellen im Raster klicken, und Sie können die Dashboard-Elemente durch Ziehen und Ablegen der Gitterzeilen neu ordnen
578578
infoSaveOfTask = Speichern dieser Aufgabe wird alle ungespeicherten Änderungen zu diesem Fall verwerfen.
579579
infoExposureInvestigation = <i>Bitte dokumentieren Sie ALLE relevanten direkten Expositionen (z.B. besuchte Versammlungen, Reisen, Tierkontakte usw.) während der Inkubationszeit\:</i>
580+
infoExposureInvestigationContacts = <i>Bitte dokumentieren Sie die Exposition, die zu diesem Kontakt geführt hat:</i>
580581
infoEpiDataFieldsHint = <i>Bitte geben Sie an, ob einer der folgenden Punkte für den/die Patient*in während des Inkubationszeitraums relevant ist.</i>
581582
infoEpiDataSourceCaseContacts = <i>Bitte geben Sie ALLE Kontakte mit möglichen Indexfällen während des Inkubationszeitraums an\:</i>
582583
infoNoSourceCase = Kein Indexfall

sormas-ui/src/main/java/de/symeda/sormas/ui/epidata/EpiDataForm.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import de.symeda.sormas.api.Disease;
3939
import de.symeda.sormas.api.EntityDto;
4040
import de.symeda.sormas.api.caze.CaseDataDto;
41+
import de.symeda.sormas.api.contact.ContactDto;
4142
import de.symeda.sormas.api.contact.ContactReferenceDto;
4243
import de.symeda.sormas.api.epidata.EpiDataDto;
4344
import de.symeda.sormas.api.i18n.I18nProperties;
@@ -140,7 +141,10 @@ private void addHeadingsAndInfoTexts() {
140141
getContent().addComponent(
141142
new Label(
142143
h3(I18nProperties.getString(Strings.headingExposureInvestigation))
143-
+ divsCss(VSPACE_3, I18nProperties.getString(Strings.infoExposureInvestigation)),
144+
+ divsCss(
145+
VSPACE_3,
146+
I18nProperties.getString(
147+
parentClass == ContactDto.class ? Strings.infoExposureInvestigationContacts : Strings.infoExposureInvestigation)),
144148
ContentMode.HTML),
145149
LOC_EXPOSURE_INVESTIGATION_HEADING);
146150

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@
2525

2626
import com.vaadin.icons.VaadinIcons;
2727
import com.vaadin.ui.Window;
28+
import com.vaadin.v7.data.Property;
2829
import com.vaadin.v7.shared.ui.label.ContentMode;
2930
import com.vaadin.v7.ui.Label;
3031
import com.vaadin.v7.ui.Table;
3132

3233
import de.symeda.sormas.api.EntityDto;
3334
import de.symeda.sormas.api.caze.CaseDataDto;
35+
import de.symeda.sormas.api.contact.ContactDto;
3436
import de.symeda.sormas.api.contact.ContactReferenceDto;
3537
import de.symeda.sormas.api.event.TypeOfPlace;
3638
import de.symeda.sormas.api.exposure.ExposureDto;
@@ -210,13 +212,17 @@ protected void editEntry(ExposureDto entry, boolean create, Consumer<ExposureDto
210212
component.addCommitListener(() -> {
211213
if (!exposureForm.getFieldGroup().isModified()) {
212214
commitCallback.accept(exposureForm.getValue());
215+
216+
updateAddButtonVisibility(getValue().size());
213217
}
214218
});
215219

216220
if (!create) {
217221
component.addDeleteListener(() -> {
218222
popupWindow.close();
219223
ExposuresField.this.removeEntry(entry);
224+
225+
updateAddButtonVisibility(getValue().size());
220226
}, I18nProperties.getCaption(ExposureDto.I18N_PREFIX));
221227
}
222228
}
@@ -232,6 +238,15 @@ protected ExposureDto createEntry() {
232238
return exposure;
233239
}
234240

241+
@Override
242+
public void setPropertyDataSource(Property newDataSource) {
243+
super.setPropertyDataSource(newDataSource);
244+
245+
if (getValue() != null) {
246+
updateAddButtonVisibility(getValue().size());
247+
}
248+
}
249+
235250
public void setGetSourceContactsCallback(Supplier<List<ContactReferenceDto>> callback) {
236251
getSourceContactsCallback = callback;
237252
}
@@ -243,4 +258,12 @@ public void setEpiDataParentClass(Class<? extends EntityDto> epiDataParentClass)
243258
public void setPseudonymized(boolean isPseudonymized) {
244259
this.isPseudonymized = isPseudonymized;
245260
}
261+
262+
private void updateAddButtonVisibility(int exposureCount) {
263+
if (isReadOnly() || epiDataParentClass == ContactDto.class && exposureCount > 0) {
264+
getAddButton().setVisible(false);
265+
} else {
266+
getAddButton().setVisible(true);
267+
}
268+
}
246269
}

0 commit comments

Comments
 (0)