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

Commit 738abf6

Browse files
Merge pull request SORMAS-Foundation#3144 from hzi-braunschweig/2972-place-of-stay-in-bulk-case-edit
2972 place of stay in bulk case edit
2 parents 8cf0173 + d5fbdb6 commit 738abf6

6 files changed

Lines changed: 331 additions & 182 deletions

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
@@ -780,6 +780,7 @@ public interface Strings {
780780
String promptTypeToAdd = "promptTypeToAdd";
781781
String promptUserSearch = "promptUserSearch";
782782
String promtSampleDataType = "promtSampleDataType";
783+
String pseudonymizedCasesSelectedWarning = "pseudonymizedCasesSelectedWarning";
783784
String quarantineEnd = "quarantineEnd";
784785
String quarterShort = "quarterShort";
785786
String reportedBy = "reportedBy";

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
###############################################################################
1818

19-
# Any text presented to the user that is not a caption or can be used in
19+
# Any text presented to the user that is not a caption or can be used in
2020
# various places (e.g. as part of a larger text or caption)
2121

2222
# General Strings
@@ -522,6 +522,7 @@ infoSelectOrCreateContactImport = The database already contains at least one con
522522
infoSelectOrCreatePersonForContact = The database already contains at least one person that seems to be very similar to the personal details of the created contact.<br/><br/>Please look through the list of persons. If you feel certain that one of those persons matches your contact person, select it and click on the <i>Save</i> button. Otherwise, click on <i>Create New Person</i> to create a new person for your contact.<br/><br/>If you are unsure, you can discard this window and cancel the contact creation process.
523523
infoSelectOrCreatePersonForContactImport = The database already contains at least one person that seems to be very similar to the personal details of the imported contact.<br/><br/>Please look through the list of persons. If you feel certain that one of those persons matches your contact person, select it and click on the <i>Save</i> button. Otherwise, click on <i>Create New Person</i> to create a new person for your contact.<br/><br/>If you are unsure, you can discard this window to remove the contact from the current import.
524524
infoSelectOrCreatePersonForEventParticipant = The database already contains at least one person that seems to be very similar to the personal details of the created event participant.<br/><br/>Please look through the list of persons. If you feel certain that one of those persons matches your event person, select it and click on the <i>Save</i> button. Otherwise, click on <i>Create New Person</i> to create a new event person for your event.<br/><br/>If you are unsure, you can discard this window and cancel the event participant creation process.
525+
pseudonymizedCasesSelectedWarning = For the bulked-edited cases you have only limited access to the sensitive data. For those cases the value you put into "Place Description" will be ignored.
525526
infoPickOrCreateEventForCase = The list below contains all existing events having the same disease as the current case. Please check whether the event this case belongs to is already on this list or create a new one if it isn't.
526527
infoSelectOrCreatePersonForCase = The database already contains at least one person that seems to be very similar to the personal details of the created case.<br/><br/>Please look through the list of persons. If you feel certain that one of those persons matches your case person, select them and click on the <i>Save</i> button. Otherwise, click on <i>Create New Person</i> to create a new person for your case.<br/><br/>If you are unsure, you can discard this window and cancel the case creation process.
527528
infoSelectOrCreatePersonForCaseImport = The database already contains at least one person that seems to be very similar to the personal details of the imported case.<br/><br/>Please look through the list of persons. If you feel certain that one of those persons matches your case person, select them and click on the <i>Save</i> button. Otherwise, click on <i>Create New Person</i> to create a new person for your case.<br/><br/>If you are unsure, you can discard this window to remove the case from the current import.

sormas-ui/src/main/java/de/symeda/sormas/ui/caze/BulkCaseDataForm.java

Lines changed: 152 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@
2626
import static de.symeda.sormas.ui.utils.LayoutUtil.locs;
2727

2828
import java.util.Arrays;
29+
import java.util.Collection;
30+
import java.util.Collections;
2931
import java.util.List;
3032

33+
import com.vaadin.ui.HorizontalLayout;
34+
import com.vaadin.ui.themes.ValoTheme;
3135
import com.vaadin.v7.ui.CheckBox;
3236
import com.vaadin.v7.ui.ComboBox;
3337
import com.vaadin.v7.ui.OptionGroup;
@@ -36,18 +40,24 @@
3640
import de.symeda.sormas.api.Disease;
3741
import de.symeda.sormas.api.FacadeProvider;
3842
import de.symeda.sormas.api.caze.CaseDataDto;
43+
import de.symeda.sormas.api.caze.CaseIndexDto;
44+
import de.symeda.sormas.api.event.TypeOfPlace;
3945
import de.symeda.sormas.api.facility.FacilityDto;
46+
import de.symeda.sormas.api.facility.FacilityReferenceDto;
4047
import de.symeda.sormas.api.facility.FacilityType;
4148
import de.symeda.sormas.api.facility.FacilityTypeGroup;
4249
import de.symeda.sormas.api.i18n.Captions;
4350
import de.symeda.sormas.api.i18n.I18nProperties;
51+
import de.symeda.sormas.api.i18n.Strings;
4452
import de.symeda.sormas.api.region.CommunityReferenceDto;
4553
import de.symeda.sormas.api.region.DistrictReferenceDto;
4654
import de.symeda.sormas.api.region.RegionReferenceDto;
4755
import de.symeda.sormas.api.user.UserReferenceDto;
4856
import de.symeda.sormas.api.user.UserRole;
4957
import de.symeda.sormas.ui.utils.AbstractEditForm;
58+
import de.symeda.sormas.ui.utils.CssStyles;
5059
import de.symeda.sormas.ui.utils.FieldHelper;
60+
import de.symeda.sormas.ui.utils.VaadinUiUtil;
5161

5262
public class BulkCaseDataForm extends AbstractEditForm<CaseBulkEditData> {
5363

@@ -61,34 +71,35 @@ public class BulkCaseDataForm extends AbstractEditForm<CaseBulkEditData> {
6171
private static final String HEALTH_FACILITY_CHECKBOX = "healthFacilityCheckbox";
6272
private static final String TYPE_GROUP_LOC = "typeGroupLoc";
6373
private static final String TYPE_LOC = "typeLoc";
74+
private static final String FACILITY_OR_HOME_LOC = "facilityOrHomeLoc";
75+
private static final String WARNING_LAYOUT = "warningLayout";
6476

6577
//@formatter:off
66-
private static final String HTML_LAYOUT =
67-
fluidRowLocsCss(VSPACE_4, DISEASE_CHECKBOX) +
68-
fluidRow(
69-
fluidColumnLoc(6, 0, CaseDataDto.DISEASE),
70-
fluidColumn(6, 0,locs(
71-
CaseDataDto.DISEASE_DETAILS,
72-
CaseDataDto.PLAGUE_TYPE,
73-
CaseDataDto.DENGUE_FEVER_TYPE,
74-
CaseDataDto.RABIES_TYPE))) +
75-
fluidRowLocsCss(VSPACE_4, CLASSIFICATION_CHECKBOX) +
76-
fluidRowLocs(CaseBulkEditData.CASE_CLASSIFICATION) +
77-
fluidRowLocsCss(VSPACE_4, INVESTIGATION_STATUS_CHECKBOX) +
78-
fluidRowLocs(CaseBulkEditData.INVESTIGATION_STATUS) +
79-
fluidRowLocsCss(VSPACE_4, OUTCOME_CHECKBOX) +
80-
fluidRowLocs(CaseBulkEditData.OUTCOME) +
81-
fluidRowLocsCss(VSPACE_4, SURVEILLANCE_OFFICER_CHECKBOX) +
82-
fluidRowLocs(CaseBulkEditData.SURVEILLANCE_OFFICER, "") +
83-
fluidRowLocsCss(VSPACE_4, HEALTH_FACILITY_CHECKBOX) +
84-
fluidRowLocs(CaseBulkEditData.REGION,
85-
CaseBulkEditData.DISTRICT,
86-
CaseBulkEditData.COMMUNITY) +
87-
fluidRowLocs(
88-
TYPE_GROUP_LOC,
89-
TYPE_LOC,
90-
CaseBulkEditData.HEALTH_FACILITY);
91-
//@formatter:on
78+
private static final String HTML_LAYOUT =
79+
fluidRowLocsCss(VSPACE_4, DISEASE_CHECKBOX) +
80+
fluidRow(
81+
fluidColumnLoc(6, 0, CaseDataDto.DISEASE),
82+
fluidColumn(6, 0, locs(
83+
CaseDataDto.DISEASE_DETAILS,
84+
CaseDataDto.PLAGUE_TYPE,
85+
CaseDataDto.DENGUE_FEVER_TYPE,
86+
CaseDataDto.RABIES_TYPE))) +
87+
fluidRowLocsCss(VSPACE_4, CLASSIFICATION_CHECKBOX) +
88+
fluidRowLocs(CaseBulkEditData.CASE_CLASSIFICATION) +
89+
fluidRowLocsCss(VSPACE_4, INVESTIGATION_STATUS_CHECKBOX) +
90+
fluidRowLocs(CaseBulkEditData.INVESTIGATION_STATUS) +
91+
fluidRowLocsCss(VSPACE_4, OUTCOME_CHECKBOX) +
92+
fluidRowLocs(CaseBulkEditData.OUTCOME) +
93+
fluidRowLocsCss(VSPACE_4, SURVEILLANCE_OFFICER_CHECKBOX) +
94+
fluidRowLocs(CaseBulkEditData.SURVEILLANCE_OFFICER, "") +
95+
fluidRowLocsCss(VSPACE_4, HEALTH_FACILITY_CHECKBOX) +
96+
fluidRowLocs(CaseBulkEditData.REGION,
97+
CaseBulkEditData.DISTRICT,
98+
CaseBulkEditData.COMMUNITY) +
99+
fluidRowLocs(FACILITY_OR_HOME_LOC, TYPE_GROUP_LOC, TYPE_LOC) +
100+
fluidRowLocs(WARNING_LAYOUT) +
101+
fluidRowLocs(CaseDataDto.HEALTH_FACILITY, CaseBulkEditData.HEALTH_FACILITY_DETAILS);
102+
//@formatter:on
92103

93104
private final DistrictReferenceDto singleSelectedDistrict;
94105

@@ -102,16 +113,22 @@ public class BulkCaseDataForm extends AbstractEditForm<CaseBulkEditData> {
102113
private CheckBox healthFacilityCheckbox;
103114
private ComboBox facilityTypeGroup;
104115
private ComboBox facilityType;
116+
private TextField healthFacilityDetails;
117+
private Collection<? extends CaseIndexDto> selectedCases;
118+
OptionGroup facilityOrHome;
119+
private HorizontalLayout warningLayout;
105120

106-
public BulkCaseDataForm(DistrictReferenceDto singleSelectedDistrict) {
121+
public BulkCaseDataForm(DistrictReferenceDto singleSelectedDistrict, Collection<? extends CaseIndexDto> selectedCases) {
107122
super(CaseBulkEditData.class, CaseDataDto.I18N_PREFIX);
108123
this.singleSelectedDistrict = singleSelectedDistrict;
109124
setWidth(680, Unit.PIXELS);
110125
hideValidationUntilNextCommit();
111126
initialized = true;
127+
this.selectedCases = selectedCases;
112128
addFields();
113129
}
114130

131+
@SuppressWarnings("deprecation")
115132
@Override
116133
protected void addFields() {
117134
if (!initialized) {
@@ -193,6 +210,16 @@ protected void addFields() {
193210
ComboBox community = addInfrastructureField(CaseBulkEditData.COMMUNITY);
194211
community.setNullSelectionAllowed(true);
195212
community.setEnabled(false);
213+
facilityOrHome = new OptionGroup(I18nProperties.getCaption(Captions.casePlaceOfStay), TypeOfPlace.getTypesOfPlaceForCases());
214+
facilityOrHome.setId("facilityOrHome");
215+
facilityOrHome.setWidth(100, Unit.PERCENTAGE);
216+
facilityOrHome.setEnabled(false);
217+
CssStyles.style(facilityOrHome, ValoTheme.OPTIONGROUP_HORIZONTAL);
218+
getContent().addComponent(facilityOrHome, FACILITY_OR_HOME_LOC);
219+
220+
healthFacilityDetails = addField(CaseDataDto.HEALTH_FACILITY_DETAILS, TextField.class);
221+
healthFacilityDetails.setVisible(false);
222+
196223
facilityTypeGroup = new ComboBox();
197224
facilityTypeGroup.setId("typeGroup");
198225
facilityTypeGroup.setCaption(I18nProperties.getCaption(Captions.Facility_typeGroup));
@@ -209,12 +236,14 @@ protected void addFields() {
209236
ComboBox facility = addInfrastructureField(CaseBulkEditData.HEALTH_FACILITY);
210237
facility.setImmediate(true);
211238
facility.setEnabled(false);
212-
213239
region.addValueChangeListener(e -> {
214240
RegionReferenceDto regionDto = (RegionReferenceDto) e.getProperty().getValue();
215241
FieldHelper
216242
.updateItems(district, regionDto != null ? FacadeProvider.getDistrictFacade().getAllActiveByRegion(regionDto.getUuid()) : null);
217243
});
244+
healthFacilityDetails.addValueChangeListener(e -> {
245+
updateFacilityFields(facility, healthFacilityDetails);
246+
});
218247
district.addValueChangeListener(e -> {
219248
FieldHelper.removeItems(facility);
220249
FieldHelper.removeItems(community);
@@ -278,6 +307,38 @@ protected void addFields() {
278307
}
279308
}
280309
});
310+
warningLayout = VaadinUiUtil.createWarningComponent(I18nProperties.getString(Strings.pseudonymizedCasesSelectedWarning));
311+
facilityOrHome.addValueChangeListener(e -> {
312+
FieldHelper.removeItems(facility);
313+
if (TypeOfPlace.FACILITY.equals(facilityOrHome.getValue())) {
314+
if (facilityTypeGroup.getValue() == null) {
315+
facilityTypeGroup.setValue(FacilityTypeGroup.MEDICAL_FACILITY);
316+
}
317+
if (facilityType.getValue() == null && FacilityTypeGroup.MEDICAL_FACILITY.equals(facilityTypeGroup.getValue())) {
318+
facilityType.setValue(FacilityType.HOSPITAL);
319+
}
320+
321+
if (facilityType.getValue() != null) {
322+
updateFacility((DistrictReferenceDto) district.getValue(), (CommunityReferenceDto) community.getValue(), facility);
323+
}
324+
this.getContent().removeComponent(warningLayout);
325+
healthFacilityDetails.setVisible(false);
326+
} else {
327+
long pseudonymizedCount = selectedCases.stream().filter(caze -> caze.isPseudonymized()).count();
328+
if (pseudonymizedCount > 0) {
329+
this.getContent().addComponent(warningLayout, WARNING_LAYOUT);
330+
331+
healthFacilityDetails.setVisible(true);
332+
}
333+
FacilityReferenceDto noFacilityRef = FacadeProvider.getFacilityFacade().getByUuid(FacilityDto.NONE_FACILITY_UUID).toReference();
334+
facility.addItem(noFacilityRef);
335+
facility.setValue(noFacilityRef);
336+
}
337+
});
338+
339+
facility.addValueChangeListener(e -> {
340+
updateFacilityFields(facility, healthFacilityDetails);
341+
});
281342
facilityType.setValue(FacilityType.HOSPITAL); // default
282343

283344
region.addItems(FacadeProvider.getRegionFacade().getAllActiveAsReference());
@@ -293,8 +354,23 @@ protected void addFields() {
293354
healthFacilityCheckbox,
294355
Arrays.asList(CaseBulkEditData.REGION, CaseBulkEditData.DISTRICT, CaseBulkEditData.HEALTH_FACILITY),
295356
Arrays.asList(true));
296-
FieldHelper.setRequiredWhen(healthFacilityCheckbox, Arrays.asList(facilityTypeGroup, facilityType), Arrays.asList(true), false, null);
297-
357+
FieldHelper.setRequiredWhen(
358+
healthFacilityCheckbox,
359+
Arrays.asList(facilityTypeGroup, facilityType, facilityOrHome),
360+
Arrays.asList(true),
361+
false,
362+
null);
363+
FieldHelper.setVisibleWhen(
364+
facilityOrHome,
365+
Arrays.asList(facilityTypeGroup, facilityType, facility),
366+
Collections.singletonList(TypeOfPlace.FACILITY),
367+
false);
368+
FieldHelper.setRequiredWhen(
369+
facilityOrHome,
370+
Arrays.asList(facilityTypeGroup, facilityType, facility),
371+
Collections.singletonList(TypeOfPlace.FACILITY),
372+
false,
373+
null);
298374
diseaseCheckBox.addValueChangeListener(e -> {
299375
disease.setEnabled((boolean) e.getProperty().getValue());
300376
});
@@ -312,6 +388,9 @@ protected void addFields() {
312388
district.setEnabled((boolean) e.getProperty().getValue());
313389
community.setEnabled((boolean) e.getProperty().getValue());
314390
facilityTypeGroup.setEnabled((boolean) e.getProperty().getValue());
391+
facilityOrHome.setEnabled((boolean) e.getProperty().getValue());
392+
facilityOrHome.setRequired((boolean) e.getProperty().getValue());
393+
healthFacilityDetails.setEnabled((boolean) e.getProperty().getValue());
315394
facilityType.setEnabled((boolean) e.getProperty().getValue());
316395
facility.setEnabled((boolean) e.getProperty().getValue());
317396
if ((boolean) e.getProperty().getValue()) {
@@ -350,4 +429,47 @@ public CheckBox getSurveillanceOfficerCheckBox() {
350429
public CheckBox getHealthFacilityCheckbox() {
351430
return healthFacilityCheckbox;
352431
}
432+
433+
private void updateFacility(DistrictReferenceDto district, CommunityReferenceDto community, ComboBox facility) {
434+
FieldHelper.removeItems(facility);
435+
if (facilityType.getValue() != null && district != null) {
436+
if (community != null) {
437+
FieldHelper.updateItems(
438+
facility,
439+
FacadeProvider.getFacilityFacade()
440+
.getActiveFacilitiesByCommunityAndType(community, (FacilityType) facilityType.getValue(), true, false));
441+
} else {
442+
FieldHelper.updateItems(
443+
facility,
444+
FacadeProvider.getFacilityFacade()
445+
.getActiveFacilitiesByDistrictAndType(district, (FacilityType) facilityType.getValue(), true, false));
446+
}
447+
}
448+
}
449+
450+
private void updateFacilityFields(ComboBox cbFacility, TextField tfFacilityDetails) {
451+
452+
if (cbFacility.getValue() != null) {
453+
boolean otherHealthFacility = ((FacilityReferenceDto) cbFacility.getValue()).getUuid().equals(FacilityDto.OTHER_FACILITY_UUID);
454+
boolean noneHealthFacility = ((FacilityReferenceDto) cbFacility.getValue()).getUuid().equals(FacilityDto.NONE_FACILITY_UUID);
455+
boolean visibleAndRequired = otherHealthFacility || noneHealthFacility;
456+
457+
tfFacilityDetails.setVisible(visibleAndRequired);
458+
459+
if (otherHealthFacility) {
460+
tfFacilityDetails.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.HEALTH_FACILITY_DETAILS));
461+
tfFacilityDetails.setRequired(visibleAndRequired);
462+
}
463+
if (noneHealthFacility) {
464+
tfFacilityDetails.setCaption(I18nProperties.getCaption(Captions.CaseData_noneHealthFacilityDetails));
465+
}
466+
if (!visibleAndRequired) {
467+
tfFacilityDetails.clear();
468+
}
469+
} else if (TypeOfPlace.FACILITY.equals(facilityOrHome.getValue())) {
470+
tfFacilityDetails.setVisible(false);
471+
tfFacilityDetails.setRequired(false);
472+
tfFacilityDetails.clear();
473+
}
474+
}
353475
}

0 commit comments

Comments
 (0)