use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.
the class BulkContactDataForm method addFields.
@Override
protected void addFields() {
if (!initialized) {
return;
}
classificationCheckBox = new CheckBox(I18nProperties.getCaption(Captions.bulkContactClassification));
getContent().addComponent(classificationCheckBox, CLASSIFICATION_CHECKBOX);
NullableOptionGroup contactClassification = addField(ContactBulkEditData.CONTACT_CLASSIFICATION, NullableOptionGroup.class);
contactClassification.setEnabled(false);
if (singleSelectedDistrict != null) {
contactOfficerCheckBox = new CheckBox(I18nProperties.getCaption(Captions.bulkContactOfficer));
getContent().addComponent(contactOfficerCheckBox, CONTACT_OFFICER_CHECKBOX);
ComboBox contactOfficer = addField(ContactBulkEditData.CONTACT_OFFICER, ComboBox.class);
contactOfficer.setEnabled(false);
FieldHelper.addSoftRequiredStyleWhen(getFieldGroup(), contactOfficerCheckBox, Arrays.asList(ContactBulkEditData.CONTACT_OFFICER), Arrays.asList(true), null);
Set<Disease> selectedDiseases = this.selectedContacts.stream().map(c -> c.getDisease()).collect(Collectors.toSet());
List<UserReferenceDto> assignableContactOfficers = null;
if (selectedDiseases.size() == 1) {
Disease selectedDisease = selectedDiseases.iterator().next();
assignableContactOfficers = FacadeProvider.getUserFacade().getUserRefsByDistrict(singleSelectedDistrict, selectedDisease, UserRight.CONTACT_RESPONSIBLE);
} else {
assignableContactOfficers = FacadeProvider.getUserFacade().getUserRefsByDistrict(singleSelectedDistrict, true, UserRight.CONTACT_RESPONSIBLE);
}
FieldHelper.updateItems(contactOfficer, assignableContactOfficers);
contactOfficerCheckBox.addValueChangeListener(e -> {
contactOfficer.setEnabled((boolean) e.getProperty().getValue());
});
}
FieldHelper.setRequiredWhen(getFieldGroup(), classificationCheckBox, Arrays.asList(ContactBulkEditData.CONTACT_CLASSIFICATION), Arrays.asList(true));
classificationCheckBox.addValueChangeListener(e -> {
contactClassification.setEnabled((boolean) e.getProperty().getValue());
});
}
use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.
the class PathogenTestForm method addFields.
@Override
protected void addFields() {
if (sample == null) {
return;
}
pathogenTestHeadingLabel = new Label();
pathogenTestHeadingLabel.addStyleName(H3);
getContent().addComponent(pathogenTestHeadingLabel, PATHOGEN_TEST_HEADING_LOC);
addDateField(PathogenTestDto.REPORT_DATE, DateField.class, 0);
addField(PathogenTestDto.VIA_LIMS);
addField(PathogenTestDto.EXTERNAL_ID);
addField(PathogenTestDto.EXTERNAL_ORDER_ID);
ComboBox testTypeField = addField(PathogenTestDto.TEST_TYPE, ComboBox.class);
testTypeField.setItemCaptionMode(ItemCaptionMode.ID_TOSTRING);
testTypeField.setImmediate(true);
pcrTestSpecification = addField(PathogenTestDto.PCR_TEST_SPECIFICATION, ComboBox.class);
testTypeTextField = addField(PathogenTestDto.TEST_TYPE_TEXT, TextField.class);
FieldHelper.addSoftRequiredStyle(testTypeTextField);
DateTimeField sampleTestDateField = addField(PathogenTestDto.TEST_DATE_TIME, DateTimeField.class);
sampleTestDateField.addValidator(new DateComparisonValidator(sampleTestDateField, sample.getSampleDateTime(), false, false, I18nProperties.getValidationError(Validations.afterDateWithDate, sampleTestDateField.getCaption(), I18nProperties.getPrefixCaption(SampleDto.I18N_PREFIX, SampleDto.SAMPLE_DATE_TIME), DateFormatHelper.formatDate(sample.getSampleDateTime()))));
ComboBox lab = addInfrastructureField(PathogenTestDto.LAB);
lab.addItems(FacadeProvider.getFacilityFacade().getAllActiveLaboratories(true));
TextField labDetails = addField(PathogenTestDto.LAB_DETAILS, TextField.class);
labDetails.setVisible(false);
typingIdField = addField(PathogenTestDto.TYPING_ID, TextField.class);
typingIdField.setVisible(false);
ComboBox diseaseField = addDiseaseField(PathogenTestDto.TESTED_DISEASE, true, create);
ComboBox diseaseVariantField = addField(PathogenTestDto.TESTED_DISEASE_VARIANT, ComboBox.class);
diseaseVariantField.setNullSelectionAllowed(true);
addField(PathogenTestDto.TESTED_DISEASE_DETAILS, TextField.class);
TextField diseaseVariantDetailsField = addField(PathogenTestDto.TESTED_DISEASE_VARIANT_DETAILS, TextField.class);
diseaseVariantDetailsField.setVisible(false);
ComboBox testResultField = addField(PathogenTestDto.TEST_RESULT, ComboBox.class);
testResultField.removeItem(PathogenTestResultType.NOT_DONE);
addField(PathogenTestDto.SEROTYPE, TextField.class);
TextField cqValueField = addField(PathogenTestDto.CQ_VALUE, TextField.class);
cqValueField.setConversionError(I18nProperties.getValidationError(Validations.onlyNumbersAllowed, cqValueField.getCaption()));
NullableOptionGroup testResultVerifiedField = addField(PathogenTestDto.TEST_RESULT_VERIFIED, NullableOptionGroup.class);
testResultVerifiedField.setRequired(true);
CheckBox fourFoldIncrease = addField(PathogenTestDto.FOUR_FOLD_INCREASE_ANTIBODY_TITER, CheckBox.class);
CssStyles.style(fourFoldIncrease, VSPACE_3, VSPACE_TOP_4);
fourFoldIncrease.setVisible(false);
fourFoldIncrease.setEnabled(false);
addField(PathogenTestDto.TEST_RESULT_TEXT, TextArea.class).setRows(6);
addField(PathogenTestDto.PRELIMINARY).addStyleName(CssStyles.VSPACE_4);
addField(PathogenTestDto.DELETION_REASON);
addField(PathogenTestDto.OTHER_DELETION_REASON, TextArea.class).setRows(3);
setVisible(false, PathogenTestDto.DELETION_REASON, PathogenTestDto.OTHER_DELETION_REASON);
initializeAccessAndAllowedAccesses();
initializeVisibilitiesAndAllowedVisibilities();
pcrTestSpecification.setVisible(false);
Map<Object, List<Object>> pcrTestSpecificationVisibilityDependencies = new HashMap<Object, List<Object>>() {
{
put(PathogenTestDto.TESTED_DISEASE, Arrays.asList(Disease.CORONAVIRUS));
put(PathogenTestDto.TEST_TYPE, Arrays.asList(PathogenTestType.PCR_RT_PCR));
}
};
FieldHelper.setVisibleWhen(getFieldGroup(), PathogenTestDto.PCR_TEST_SPECIFICATION, pcrTestSpecificationVisibilityDependencies, true);
FieldHelper.setVisibleWhen(getFieldGroup(), PathogenTestDto.TEST_TYPE_TEXT, PathogenTestDto.TEST_TYPE, Arrays.asList(PathogenTestType.PCR_RT_PCR, PathogenTestType.OTHER), true);
FieldHelper.setVisibleWhen(getFieldGroup(), PathogenTestDto.TESTED_DISEASE_DETAILS, PathogenTestDto.TESTED_DISEASE, Arrays.asList(Disease.OTHER), true);
FieldHelper.setVisibleWhen(getFieldGroup(), PathogenTestDto.TYPING_ID, PathogenTestDto.TEST_TYPE, Arrays.asList(PathogenTestType.PCR_RT_PCR, PathogenTestType.DNA_MICROARRAY, PathogenTestType.SEQUENCING), true);
Map<Object, List<Object>> serotypeVisibilityDependencies = new HashMap<Object, List<Object>>() {
private static final long serialVersionUID = 1967952323596082247L;
{
put(PathogenTestDto.TESTED_DISEASE, Arrays.asList(Disease.CSM));
put(PathogenTestDto.TEST_RESULT, Arrays.asList(PathogenTestResultType.POSITIVE));
}
};
FieldHelper.setVisibleWhen(getFieldGroup(), PathogenTestDto.SEROTYPE, serotypeVisibilityDependencies, true);
FieldHelper.setVisibleWhen(getFieldGroup(), PathogenTestDto.CQ_VALUE, PathogenTestDto.TEST_TYPE, Arrays.asList(PathogenTestType.CQ_VALUE_DETECTION), true);
Consumer<Disease> updateDiseaseVariantField = disease -> {
List<DiseaseVariant> diseaseVariants = FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.DISEASE_VARIANT, disease);
FieldHelper.updateItems(diseaseVariantField, diseaseVariants);
diseaseVariantField.setVisible(disease != null && isVisibleAllowed(PathogenTestDto.TESTED_DISEASE_VARIANT) && CollectionUtils.isNotEmpty(diseaseVariants));
};
// trigger the update, as the disease may already be set
updateDiseaseVariantField.accept((Disease) diseaseField.getValue());
diseaseField.addValueChangeListener((ValueChangeListener) valueChangeEvent -> {
Disease disease = (Disease) valueChangeEvent.getProperty().getValue();
updateDiseaseVariantField.accept(disease);
FieldHelper.updateItems(testTypeField, Arrays.asList(PathogenTestType.values()), FieldVisibilityCheckers.withDisease(disease), PathogenTestType.class);
});
diseaseVariantField.addValueChangeListener(e -> {
DiseaseVariant diseaseVariant = (DiseaseVariant) e.getProperty().getValue();
diseaseVariantDetailsField.setVisible(diseaseVariant != null && diseaseVariant.matchPropertyValue(DiseaseVariant.HAS_DETAILS, true));
});
testTypeField.addValueChangeListener(e -> {
PathogenTestType testType = (PathogenTestType) e.getProperty().getValue();
if (testType == PathogenTestType.IGM_SERUM_ANTIBODY || testType == PathogenTestType.IGG_SERUM_ANTIBODY) {
fourFoldIncrease.setVisible(true);
fourFoldIncrease.setEnabled(caseSampleCount >= 2);
} else {
fourFoldIncrease.setVisible(false);
fourFoldIncrease.setEnabled(false);
}
});
lab.addValueChangeListener(event -> {
if (event.getProperty().getValue() != null && ((FacilityReferenceDto) event.getProperty().getValue()).getUuid().equals(FacilityDto.OTHER_FACILITY_UUID)) {
labDetails.setVisible(true);
labDetails.setRequired(true);
} else {
labDetails.setVisible(false);
labDetails.setRequired(false);
labDetails.clear();
}
});
testTypeField.addValueChangeListener(e -> {
PathogenTestType testType = (PathogenTestType) e.getProperty().getValue();
if ((testType == PathogenTestType.PCR_RT_PCR && testResultField.getValue() == PathogenTestResultType.POSITIVE) || testType == PathogenTestType.CQ_VALUE_DETECTION) {
cqValueField.setVisible(true);
} else {
cqValueField.setVisible(false);
cqValueField.clear();
}
});
testResultField.addValueChangeListener(e -> {
PathogenTestResultType testResult = (PathogenTestResultType) e.getProperty().getValue();
if ((testTypeField.getValue() == PathogenTestType.PCR_RT_PCR && testResult == PathogenTestResultType.POSITIVE) || testTypeField.getValue() == PathogenTestType.CQ_VALUE_DETECTION) {
cqValueField.setVisible(true);
} else {
cqValueField.setVisible(false);
cqValueField.clear();
}
});
if (sample.getSamplePurpose() != SamplePurpose.INTERNAL) {
// this only works for already saved samples
setRequired(true, PathogenTestDto.LAB);
}
setRequired(true, PathogenTestDto.TEST_TYPE, PathogenTestDto.TESTED_DISEASE, PathogenTestDto.TEST_RESULT);
}
use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.
the class PersonCreateForm method updatePresentConditionEnum.
public void updatePresentConditionEnum(Disease disease) {
ComboBox presentConditionField = getField(PersonDto.PRESENT_CONDITION);
PresentCondition currentValue = (PresentCondition) presentConditionField.getValue();
List<PresentCondition> validValues;
if (disease == null) {
validValues = Arrays.asList(PresentCondition.values());
} else {
FieldVisibilityCheckers fieldVisibilityCheckers = FieldVisibilityCheckers.withDisease(disease);
validValues = Arrays.stream(PresentCondition.values()).filter(c -> fieldVisibilityCheckers.isVisible(PresentCondition.class, c.name())).collect(Collectors.toList());
if (currentValue != null && !validValues.contains(currentValue)) {
validValues.add(currentValue);
}
}
FieldHelper.updateEnumData(presentConditionField, validValues);
}
use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.
the class PersonEditForm method initializePresentConditionField.
private void initializePresentConditionField() {
PresentCondition presentCondition = getValue().getPresentCondition();
ComboBox presentConditionField = getField(PersonDto.PRESENT_CONDITION);
if (this.disease != null || FacadeProvider.getDiseaseConfigurationFacade().getDefaultDisease() != null) {
Disease disease = this.disease != null ? this.disease : FacadeProvider.getDiseaseConfigurationFacade().getDefaultDisease();
FieldVisibilityCheckers fieldVisibilityCheckers = FieldVisibilityCheckers.withDisease(disease);
List<PresentCondition> validValues = Arrays.stream(PresentCondition.values()).filter(c -> fieldVisibilityCheckers.isVisible(PresentCondition.class, c.name())).collect(Collectors.toList());
PresentCondition currentValue = (PresentCondition) presentConditionField.getValue();
if (currentValue != null && !validValues.contains(currentValue)) {
validValues.add(currentValue);
}
presentConditionField.removeValueChangeListener(presentConditionChangeListener);
FieldHelper.updateEnumData(presentConditionField, validValues);
presentConditionField.addValueChangeListener(presentConditionChangeListener);
}
/*
* It may happen that the person currently has a present condition that usually shall not be shows for the form's disease.
* In that case, the present condition is added as selectable item here.
*/
if (presentCondition != null && presentConditionField.getItem(presentCondition) == null) {
Item currentItem = presentConditionField.addItem(presentCondition);
currentItem.getItemProperty(SormasFieldGroupFieldFactory.CAPTION_PROPERTY_ID).setValue(presentCondition.toString());
}
}
use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.
the class BulkCaseDataForm method addFields.
@SuppressWarnings("deprecation")
@Override
protected void addFields() {
if (!initialized) {
return;
}
diseaseCheckBox = new CheckBox(I18nProperties.getCaption(Captions.bulkDisease));
getContent().addComponent(diseaseCheckBox, DISEASE_CHECKBOX);
ComboBox disease = addDiseaseField(CaseDataDto.DISEASE, false);
disease.setEnabled(false);
addField(CaseDataDto.DISEASE_DETAILS, TextField.class);
addField(CaseDataDto.PLAGUE_TYPE, NullableOptionGroup.class);
addField(CaseDataDto.DENGUE_FEVER_TYPE, NullableOptionGroup.class);
addField(CaseDataDto.RABIES_TYPE, NullableOptionGroup.class);
if (isVisibleAllowed(CaseDataDto.DISEASE_DETAILS)) {
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.DISEASE_DETAILS), CaseDataDto.DISEASE, Arrays.asList(Disease.OTHER), true);
FieldHelper.setRequiredWhen(getFieldGroup(), CaseDataDto.DISEASE, Arrays.asList(CaseDataDto.DISEASE_DETAILS), Arrays.asList(Disease.OTHER));
}
if (isVisibleAllowed(CaseDataDto.PLAGUE_TYPE)) {
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.PLAGUE_TYPE), CaseDataDto.DISEASE, Arrays.asList(Disease.PLAGUE), true);
}
if (isVisibleAllowed(CaseDataDto.DENGUE_FEVER_TYPE)) {
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.DENGUE_FEVER_TYPE), CaseDataDto.DISEASE, Arrays.asList(Disease.DENGUE), true);
}
if (isVisibleAllowed(CaseDataDto.RABIES_TYPE)) {
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.RABIES_TYPE), CaseDataDto.DISEASE, Arrays.asList(Disease.RABIES), true);
}
classificationCheckBox = new CheckBox(I18nProperties.getCaption(Captions.bulkCaseClassification));
getContent().addComponent(classificationCheckBox, CLASSIFICATION_CHECKBOX);
investigationStatusCheckBox = new CheckBox(I18nProperties.getCaption(Captions.bulkInvestigationStatus));
getContent().addComponent(investigationStatusCheckBox, INVESTIGATION_STATUS_CHECKBOX);
outcomeCheckBox = new CheckBox(I18nProperties.getCaption(Captions.bulkCaseOutcome));
getContent().addComponent(outcomeCheckBox, OUTCOME_CHECKBOX);
NullableOptionGroup caseClassification = addField(CaseBulkEditData.CASE_CLASSIFICATION, NullableOptionGroup.class);
caseClassification.setEnabled(false);
if (!isConfiguredServer(CountryHelper.COUNTRY_CODE_GERMANY)) {
caseClassification.removeItem(CaseClassification.CONFIRMED_NO_SYMPTOMS);
caseClassification.removeItem(CaseClassification.CONFIRMED_UNKNOWN_SYMPTOMS);
}
NullableOptionGroup investigationStatus = addField(CaseBulkEditData.INVESTIGATION_STATUS, NullableOptionGroup.class);
investigationStatus.setEnabled(false);
NullableOptionGroup outcome = addField(CaseBulkEditData.OUTCOME, NullableOptionGroup.class);
outcome.setEnabled(false);
if (singleSelectedDistrict != null) {
surveillanceOfficerCheckBox = new CheckBox(I18nProperties.getCaption(Captions.bulkSurveillanceOfficer));
getContent().addComponent(surveillanceOfficerCheckBox, SURVEILLANCE_OFFICER_CHECKBOX);
ComboBox surveillanceOfficer = addField(CaseBulkEditData.SURVEILLANCE_OFFICER, ComboBox.class);
surveillanceOfficer.setEnabled(false);
FieldHelper.addSoftRequiredStyleWhen(getFieldGroup(), surveillanceOfficerCheckBox, Arrays.asList(CaseBulkEditData.SURVEILLANCE_OFFICER), Arrays.asList(true), null);
Set<Disease> selectedDiseases = this.selectedCases.stream().map(c -> c.getDisease()).collect(Collectors.toSet());
List<UserReferenceDto> assignableCaseResponsibles = null;
if (selectedDiseases.size() == 1) {
Disease selectedDisease = selectedDiseases.iterator().next();
assignableCaseResponsibles = FacadeProvider.getUserFacade().getUserRefsByDistrict(singleSelectedDistrict, selectedDisease, UserRight.CASE_RESPONSIBLE);
} else {
assignableCaseResponsibles = FacadeProvider.getUserFacade().getUserRefsByDistrict(singleSelectedDistrict, true, UserRight.CASE_RESPONSIBLE);
}
FieldHelper.updateItems(surveillanceOfficer, assignableCaseResponsibles);
surveillanceOfficerCheckBox.addValueChangeListener(e -> {
surveillanceOfficer.setEnabled((boolean) e.getProperty().getValue());
});
}
healthFacilityCheckbox = new CheckBox(I18nProperties.getCaption(Captions.bulkFacility));
getContent().addComponent(healthFacilityCheckbox, HEALTH_FACILITY_CHECKBOX);
ComboBox region = addInfrastructureField(CaseBulkEditData.REGION);
region.setEnabled(false);
ComboBox district = addInfrastructureField(CaseBulkEditData.DISTRICT);
district.setEnabled(false);
ComboBox community = addInfrastructureField(CaseBulkEditData.COMMUNITY);
community.setNullSelectionAllowed(true);
community.setEnabled(false);
facilityOrHome = new OptionGroup(I18nProperties.getCaption(Captions.casePlaceOfStay), TypeOfPlace.FOR_CASES);
addCustomField(facilityOrHome, FACILITY_OR_HOME_LOC, I18nProperties.getCaption(Captions.casePlaceOfStay));
facilityOrHome.setId("facilityOrHome");
facilityOrHome.setEnabled(false);
CssStyles.style(facilityOrHome, ValoTheme.OPTIONGROUP_HORIZONTAL);
healthFacilityDetails = addField(CaseDataDto.HEALTH_FACILITY_DETAILS, TextField.class);
healthFacilityDetails.setVisible(false);
facilityTypeGroup = ComboBoxHelper.createComboBoxV7();
facilityTypeGroup.setId("typeGroup");
addCustomField(facilityTypeGroup, TYPE_GROUP_LOC, I18nProperties.getCaption(Captions.Facility_typeGroup));
facilityTypeGroup.addItems(FacilityTypeGroup.getAccomodationGroups());
facilityTypeGroup.setEnabled(false);
facilityType = addField(CaseDataDto.FACILITY_TYPE, ComboBox.class);
facilityType.setEnabled(false);
ComboBox facility = addInfrastructureField(CaseBulkEditData.HEALTH_FACILITY);
facility.setImmediate(true);
facility.setEnabled(false);
region.addValueChangeListener(e -> {
RegionReferenceDto regionDto = (RegionReferenceDto) e.getProperty().getValue();
FieldHelper.updateItems(district, regionDto != null ? FacadeProvider.getDistrictFacade().getAllActiveByRegion(regionDto.getUuid()) : null);
});
healthFacilityDetails.addValueChangeListener(e -> {
updateFacilityFields(facility, healthFacilityDetails);
});
district.addValueChangeListener(e -> {
FieldHelper.removeItems(facility);
FieldHelper.removeItems(community);
DistrictReferenceDto districtDto = (DistrictReferenceDto) e.getProperty().getValue();
FieldHelper.updateItems(community, districtDto != null ? FacadeProvider.getCommunityFacade().getAllActiveByDistrict(districtDto.getUuid()) : null);
if (districtDto != null && facilityType.getValue() != null) {
FieldHelper.updateItems(facility, FacadeProvider.getFacilityFacade().getActiveFacilitiesByDistrictAndType(districtDto, (FacilityType) facilityType.getValue(), true, false));
}
});
community.addValueChangeListener(e -> {
FieldHelper.removeItems(facility);
CommunityReferenceDto communityDto = (CommunityReferenceDto) e.getProperty().getValue();
if (facilityType.getValue() != null) {
FieldHelper.updateItems(facility, communityDto != null ? FacadeProvider.getFacilityFacade().getActiveFacilitiesByCommunityAndType(communityDto, (FacilityType) facilityType.getValue(), true, false) : district.getValue() != null ? FacadeProvider.getFacilityFacade().getActiveFacilitiesByDistrictAndType((DistrictReferenceDto) district.getValue(), (FacilityType) facilityType.getValue(), true, false) : null);
}
});
facilityTypeGroup.addValueChangeListener(e -> {
FieldHelper.removeItems(facility);
FieldHelper.updateEnumData(facilityType, FacilityType.getAccommodationTypes((FacilityTypeGroup) facilityTypeGroup.getValue()));
});
// default value
facilityTypeGroup.setValue(FacilityTypeGroup.MEDICAL_FACILITY);
facilityType.addValueChangeListener(e -> {
FieldHelper.removeItems(facility);
if (facilityType.getValue() != null && district.getValue() != null) {
if (community.getValue() != null) {
FieldHelper.updateItems(facility, FacadeProvider.getFacilityFacade().getActiveFacilitiesByCommunityAndType((CommunityReferenceDto) community.getValue(), (FacilityType) facilityType.getValue(), true, false));
} else {
FieldHelper.updateItems(facility, FacadeProvider.getFacilityFacade().getActiveFacilitiesByDistrictAndType((DistrictReferenceDto) district.getValue(), (FacilityType) facilityType.getValue(), true, false));
}
}
});
warningLayout = VaadinUiUtil.createWarningComponent(I18nProperties.getString(Strings.pseudonymizedCasesSelectedWarning));
facilityOrHome.addValueChangeListener(e -> {
FieldHelper.removeItems(facility);
if (TypeOfPlace.FACILITY.equals(facilityOrHome.getValue())) {
if (facilityTypeGroup.getValue() == null) {
facilityTypeGroup.setValue(FacilityTypeGroup.MEDICAL_FACILITY);
}
if (facilityType.getValue() == null && FacilityTypeGroup.MEDICAL_FACILITY.equals(facilityTypeGroup.getValue())) {
facilityType.setValue(FacilityType.HOSPITAL);
}
if (facilityType.getValue() != null) {
updateFacility((DistrictReferenceDto) district.getValue(), (CommunityReferenceDto) community.getValue(), facility);
}
this.getContent().removeComponent(warningLayout);
healthFacilityDetails.setVisible(false);
} else {
long pseudonymizedCount = selectedCases.stream().filter(caze -> caze.isPseudonymized()).count();
if (pseudonymizedCount > 0) {
this.getContent().addComponent(warningLayout, WARNING_LAYOUT);
healthFacilityDetails.setVisible(true);
}
FacilityReferenceDto noFacilityRef = FacadeProvider.getFacilityFacade().getByUuid(FacilityDto.NONE_FACILITY_UUID).toReference();
facility.addItem(noFacilityRef);
facility.setValue(noFacilityRef);
}
});
facility.addValueChangeListener(e -> {
updateFacilityFields(facility, healthFacilityDetails);
});
// default
facilityType.setValue(FacilityType.HOSPITAL);
region.addItems(FacadeProvider.getRegionFacade().getAllActiveByServerCountry());
if (FacadeProvider.getExternalSurveillanceToolFacade().isFeatureEnabled()) {
shareWithReportingToolCheckbox = new CheckBox(I18nProperties.getCaption(Captions.bulkCaseShareWithReportingTool));
shareWithReportingToolCheckbox.addStyleName(VSPACE_3);
getContent().addComponent(shareWithReportingToolCheckbox, SHARE_CHECKBOX);
CheckBox dontShareCheckbox = addField(CaseBulkEditData.DONT_SHARE_WITH_REPORTING_TOOL, CheckBox.class);
CaseFormHelper.addDontShareWithReportingTool(getContent(), () -> dontShareCheckbox, DONT_SHARE_WARNING_LOC, Strings.messageBulkDontShareWithReportingToolWarning);
dontShareCheckbox.setEnabled(false);
FieldHelper.setEnabledWhen(shareWithReportingToolCheckbox, Collections.singletonList(Boolean.TRUE), Collections.singletonList(dontShareCheckbox), true);
}
FieldHelper.setRequiredWhen(getFieldGroup(), diseaseCheckBox, Arrays.asList(CaseBulkEditData.DISEASE), Arrays.asList(true));
FieldHelper.setRequiredWhen(getFieldGroup(), classificationCheckBox, Arrays.asList(CaseBulkEditData.CASE_CLASSIFICATION), Arrays.asList(true));
FieldHelper.setRequiredWhen(getFieldGroup(), investigationStatusCheckBox, Arrays.asList(CaseBulkEditData.INVESTIGATION_STATUS), Arrays.asList(true));
FieldHelper.setRequiredWhen(getFieldGroup(), outcomeCheckBox, Arrays.asList(CaseBulkEditData.OUTCOME), Arrays.asList(true));
FieldHelper.setRequiredWhen(getFieldGroup(), healthFacilityCheckbox, Arrays.asList(CaseBulkEditData.REGION, CaseBulkEditData.DISTRICT, CaseBulkEditData.HEALTH_FACILITY), Arrays.asList(true));
FieldHelper.setRequiredWhen(healthFacilityCheckbox, Arrays.asList(facilityTypeGroup, facilityType, facilityOrHome), Arrays.asList(true), false, null);
FieldHelper.setVisibleWhen(facilityOrHome, Arrays.asList(facilityTypeGroup, facilityType, facility), Collections.singletonList(TypeOfPlace.FACILITY), false);
FieldHelper.setRequiredWhen(facilityOrHome, Arrays.asList(facilityTypeGroup, facilityType, facility), Collections.singletonList(TypeOfPlace.FACILITY), false, null);
diseaseCheckBox.addValueChangeListener(e -> {
disease.setEnabled((boolean) e.getProperty().getValue());
});
classificationCheckBox.addValueChangeListener(e -> {
caseClassification.setEnabled((boolean) e.getProperty().getValue());
});
investigationStatusCheckBox.addValueChangeListener(e -> {
investigationStatus.setEnabled((boolean) e.getProperty().getValue());
});
outcomeCheckBox.addValueChangeListener(e -> {
outcome.setEnabled((boolean) e.getProperty().getValue());
});
healthFacilityCheckbox.addValueChangeListener(e -> {
region.setEnabled((boolean) e.getProperty().getValue());
district.setEnabled((boolean) e.getProperty().getValue());
community.setEnabled((boolean) e.getProperty().getValue());
facilityTypeGroup.setEnabled((boolean) e.getProperty().getValue());
facilityOrHome.setEnabled((boolean) e.getProperty().getValue());
facilityOrHome.setRequired((boolean) e.getProperty().getValue());
healthFacilityDetails.setEnabled((boolean) e.getProperty().getValue());
facilityType.setEnabled((boolean) e.getProperty().getValue());
facility.setEnabled((boolean) e.getProperty().getValue());
if ((boolean) e.getProperty().getValue()) {
FieldHelper.addSoftRequiredStyle(community);
} else {
FieldHelper.removeSoftRequiredStyle(community);
}
});
}
Aggregations