use of de.symeda.sormas.ui.utils.CssStyles.VSPACE_3 in project SORMAS-Project by hzi-braunschweig.
the class CaseDataForm method addFields.
@SuppressWarnings("deprecation")
@Override
protected void addFields() {
if (person == null || disease == null) {
return;
}
Label caseDataHeadingLabel = new Label(I18nProperties.getString(Strings.headingCaseData));
caseDataHeadingLabel.addStyleName(H3);
getContent().addComponent(caseDataHeadingLabel, CASE_DATA_HEADING_LOC);
if (caseFollowUpEnabled) {
Label followUpStatusHeadingLabel = new Label(I18nProperties.getString(Strings.headingFollowUpStatus));
followUpStatusHeadingLabel.addStyleName(H3);
getContent().addComponent(followUpStatusHeadingLabel, FOLLOW_UP_STATUS_HEADING_LOC);
}
// Add fields
DateField reportDate = addField(CaseDataDto.REPORT_DATE, DateField.class);
addFields(CaseDataDto.UUID, CaseDataDto.REPORTING_USER, CaseDataDto.DISTRICT_LEVEL_DATE, CaseDataDto.REGION_LEVEL_DATE, CaseDataDto.NATIONAL_LEVEL_DATE, CaseDataDto.CLASSIFICATION_DATE, CaseDataDto.CLASSIFICATION_USER, CaseDataDto.CLASSIFICATION_COMMENT, CaseDataDto.NOTIFYING_CLINIC, CaseDataDto.NOTIFYING_CLINIC_DETAILS, CaseDataDto.CLINICIAN_NAME, CaseDataDto.CLINICIAN_PHONE, CaseDataDto.CLINICIAN_EMAIL);
TextField epidField = addField(CaseDataDto.EPID_NUMBER, TextField.class);
epidField.setInvalidCommitted(true);
epidField.setMaxLength(24);
style(epidField, ERROR_COLOR_PRIMARY);
// Button to automatically assign a new epid number
Button assignNewEpidNumberButton = ButtonHelper.createButton(Captions.actionAssignNewEpidNumber, e -> epidField.setValue(FacadeProvider.getCaseFacade().getGenerateEpidNumber(getValue())), ValoTheme.BUTTON_DANGER, FORCE_CAPTION);
getContent().addComponent(assignNewEpidNumberButton, ASSIGN_NEW_EPID_NUMBER_LOC);
assignNewEpidNumberButton.setVisible(false);
Label epidNumberWarningLabel = new Label(I18nProperties.getString(Strings.messageEpidNumberWarning));
epidNumberWarningLabel.addStyleName(VSPACE_3);
addField(CaseDataDto.EXTERNAL_ID, TextField.class);
if (FacadeProvider.getExternalSurveillanceToolFacade().isFeatureEnabled()) {
CheckBox dontShareCheckbox = addField(CaseDataDto.DONT_SHARE_WITH_REPORTING_TOOL, CheckBox.class);
CaseFormHelper.addDontShareWithReportingTool(getContent(), () -> dontShareCheckbox, DONT_SHARE_WARNING_LOC);
}
TextField externalTokenField = addField(CaseDataDto.EXTERNAL_TOKEN, TextField.class);
Label externalTokenWarningLabel = new Label(I18nProperties.getString(Strings.messageCaseExternalTokenWarning));
externalTokenWarningLabel.addStyleNames(VSPACE_3, LABEL_WHITE_SPACE_NORMAL);
getContent().addComponent(externalTokenWarningLabel, EXTERNAL_TOKEN_WARNING_LOC);
addField(CaseDataDto.INTERNAL_TOKEN, TextField.class);
addField(CaseDataDto.INVESTIGATION_STATUS, NullableOptionGroup.class);
addField(CaseDataDto.OUTCOME, NullableOptionGroup.class);
addField(CaseDataDto.BLOOD_ORGAN_OR_TISSUE_DONATED, NullableOptionGroup.class);
addField(CaseDataDto.SEQUELAE, NullableOptionGroup.class);
addFields(CaseDataDto.INVESTIGATED_DATE, CaseDataDto.OUTCOME_DATE, CaseDataDto.SEQUELAE_DETAILS);
addField(CaseDataDto.CASE_IDENTIFICATION_SOURCE);
addField(CaseDataDto.SCREENING_TYPE);
FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.SCREENING_TYPE, CaseDataDto.CASE_IDENTIFICATION_SOURCE, Collections.singletonList(CaseIdentificationSource.SCREENING), true);
ComboBox diseaseField = addDiseaseField(CaseDataDto.DISEASE, false);
ComboBox diseaseVariantField = addField(CaseDataDto.DISEASE_VARIANT, ComboBox.class);
TextField diseaseVariantDetailsField = addField(CaseDataDto.DISEASE_VARIANT_DETAILS, TextField.class);
diseaseVariantDetailsField.setVisible(false);
diseaseVariantField.setNullSelectionAllowed(true);
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);
addField(CaseDataDto.CASE_ORIGIN, TextField.class);
quarantine = addField(CaseDataDto.QUARANTINE);
quarantine.addValueChangeListener(e -> onValueChange());
quarantineFrom = addField(CaseDataDto.QUARANTINE_FROM, DateField.class);
dfQuarantineTo = addDateField(CaseDataDto.QUARANTINE_TO, DateField.class, -1);
quarantineFrom.addValidator(new DateComparisonValidator(quarantineFrom, dfQuarantineTo, true, false, I18nProperties.getValidationError(Validations.beforeDate, quarantineFrom.getCaption(), dfQuarantineTo.getCaption())));
dfQuarantineTo.addValidator(new DateComparisonValidator(dfQuarantineTo, quarantineFrom, false, false, I18nProperties.getValidationError(Validations.afterDate, dfQuarantineTo.getCaption(), quarantineFrom.getCaption())));
quarantineChangeComment = addField(CaseDataDto.QUARANTINE_CHANGE_COMMENT);
dfPreviousQuarantineTo = addDateField(CaseDataDto.PREVIOUS_QUARANTINE_TO, DateField.class, -1);
setReadOnly(true, CaseDataDto.PREVIOUS_QUARANTINE_TO);
setVisible(false, CaseDataDto.QUARANTINE_CHANGE_COMMENT, CaseDataDto.PREVIOUS_QUARANTINE_TO);
if (isConfiguredServer(CountryHelper.COUNTRY_CODE_GERMANY)) {
final ComboBox cbCaseClassification = addField(CaseDataDto.CASE_CLASSIFICATION, ComboBox.class);
cbCaseClassification.addValidator(new GermanCaseClassificationValidator(caseUuid, I18nProperties.getValidationError(Validations.caseClassificationInvalid)));
ComboBox caseReferenceDefinition = addField(CaseDataDto.CASE_REFERENCE_DEFINITION, ComboBox.class);
caseReferenceDefinition.setReadOnly(true);
if (diseaseClassificationExists()) {
Button caseClassificationCalculationButton = ButtonHelper.createButton(Captions.caseClassificationCalculationButton, e -> {
CaseClassification classification = FacadeProvider.getCaseClassificationFacade().getClassification(getValue());
((Field<CaseClassification>) getField(CaseDataDto.CASE_CLASSIFICATION)).setValue(classification);
}, ValoTheme.BUTTON_PRIMARY, FORCE_CAPTION);
getContent().addComponent(caseClassificationCalculationButton, CASE_CLASSIFICATION_CALCULATE_BTN_LOC);
if (!UserProvider.getCurrent().hasUserRight(UserRight.CASE_CLASSIFY)) {
caseClassificationCalculationButton.setEnabled(false);
}
}
// if(cbCaseClassification.getCaption())
addField(CaseDataDto.NOT_A_CASE_REASON_NEGATIVE_TEST, CheckBox.class);
addField(CaseDataDto.NOT_A_CASE_REASON_PHYSICIAN_INFORMATION, CheckBox.class);
addField(CaseDataDto.NOT_A_CASE_REASON_DIFFERENT_PATHOGEN, CheckBox.class);
addField(CaseDataDto.NOT_A_CASE_REASON_OTHER, CheckBox.class);
addField(CaseDataDto.NOT_A_CASE_REASON_DETAILS, TextField.class);
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.NOT_A_CASE_REASON_NEGATIVE_TEST, CaseDataDto.NOT_A_CASE_REASON_PHYSICIAN_INFORMATION, CaseDataDto.NOT_A_CASE_REASON_DIFFERENT_PATHOGEN, CaseDataDto.NOT_A_CASE_REASON_OTHER), CaseDataDto.CASE_CLASSIFICATION, CaseClassification.NO_CASE, true);
FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.NOT_A_CASE_REASON_DETAILS, CaseDataDto.NOT_A_CASE_REASON_OTHER, true, true);
} else {
final NullableOptionGroup caseClassificationGroup = addField(CaseDataDto.CASE_CLASSIFICATION, NullableOptionGroup.class);
caseClassificationGroup.removeItem(CaseClassification.CONFIRMED_NO_SYMPTOMS);
caseClassificationGroup.removeItem(CaseClassification.CONFIRMED_UNKNOWN_SYMPTOMS);
}
boolean extendedClassification = FacadeProvider.getDiseaseConfigurationFacade().usesExtendedClassification(disease);
if (extendedClassification) {
ComboBox clinicalConfirmationCombo = addField(CaseDataDto.CLINICAL_CONFIRMATION, ComboBox.class);
ComboBox epidemiologicalConfirmationCombo = addField(CaseDataDto.EPIDEMIOLOGICAL_CONFIRMATION, ComboBox.class);
ComboBox laboratoryConfirmationCombo = addField(CaseDataDto.LABORATORY_DIAGNOSTIC_CONFIRMATION, ComboBox.class);
ComboBox caseConfirmationBasisCombo = addCustomField(CASE_CONFIRMATION_BASIS, CaseConfirmationBasis.class, ComboBox.class);
boolean extendedClassificationMulti = FacadeProvider.getDiseaseConfigurationFacade().usesExtendedClassificationMulti(disease);
if (extendedClassificationMulti) {
caseConfirmationBasisCombo.setVisible(false);
} else {
caseConfirmationBasisCombo.addValueChangeListener(field -> {
clinicalConfirmationCombo.setValue(null);
epidemiologicalConfirmationCombo.setValue(null);
laboratoryConfirmationCombo.setValue(null);
if (caseConfirmationBasisCombo.getValue() != null) {
switch((CaseConfirmationBasis) caseConfirmationBasisCombo.getValue()) {
case CLINICAL_CONFIRMATION:
clinicalConfirmationCombo.setValue(YesNoUnknown.YES);
break;
case EPIDEMIOLOGICAL_CONFIRMATION:
epidemiologicalConfirmationCombo.setValue(YesNoUnknown.YES);
break;
case LABORATORY_DIAGNOSTIC_CONFIRMATION:
laboratoryConfirmationCombo.setValue(YesNoUnknown.YES);
break;
}
}
});
FieldHelper.setVisibleWhen(getField(CaseDataDto.CASE_CLASSIFICATION), Collections.singletonList(caseConfirmationBasisCombo), Collections.singletonList(CaseClassification.CONFIRMED), true);
clinicalConfirmationCombo.setVisible(false);
epidemiologicalConfirmationCombo.setVisible(false);
laboratoryConfirmationCombo.setVisible(false);
}
}
quarantineOrderedVerbally = addField(CaseDataDto.QUARANTINE_ORDERED_VERBALLY, CheckBox.class);
CssStyles.style(quarantineOrderedVerbally, CssStyles.FORCE_CAPTION);
addField(CaseDataDto.QUARANTINE_ORDERED_VERBALLY_DATE, DateField.class);
quarantineOrderedOfficialDocument = addField(CaseDataDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT, CheckBox.class);
CssStyles.style(quarantineOrderedOfficialDocument, CssStyles.FORCE_CAPTION);
addField(CaseDataDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT_DATE, DateField.class);
CheckBox quarantineOfficialOrderSent = addField(CaseDataDto.QUARANTINE_OFFICIAL_ORDER_SENT, CheckBox.class);
CssStyles.style(quarantineOfficialOrderSent, FORCE_CAPTION);
addField(CaseDataDto.QUARANTINE_OFFICIAL_ORDER_SENT_DATE, DateField.class);
FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.QUARANTINE_OFFICIAL_ORDER_SENT, CaseDataDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT, Collections.singletonList(Boolean.TRUE), true);
cbQuarantineExtended = addField(CaseDataDto.QUARANTINE_EXTENDED, CheckBox.class);
cbQuarantineExtended.setEnabled(false);
cbQuarantineExtended.setVisible(false);
CssStyles.style(cbQuarantineExtended, CssStyles.FORCE_CAPTION);
cbQuarantineReduced = addField(CaseDataDto.QUARANTINE_REDUCED, CheckBox.class);
cbQuarantineReduced.setEnabled(false);
cbQuarantineReduced.setVisible(false);
CssStyles.style(cbQuarantineReduced, CssStyles.FORCE_CAPTION);
TextField quarantineHelpNeeded = addField(CaseDataDto.QUARANTINE_HELP_NEEDED, TextField.class);
quarantineHelpNeeded.setInputPrompt(I18nProperties.getString(Strings.pleaseSpecify));
TextField quarantineTypeDetails = addField(CaseDataDto.QUARANTINE_TYPE_DETAILS, TextField.class);
quarantineTypeDetails.setInputPrompt(I18nProperties.getString(Strings.pleaseSpecify));
addField(CaseDataDto.NOSOCOMIAL_OUTBREAK).addStyleNames(CssStyles.FORCE_CAPTION_CHECKBOX);
addField(CaseDataDto.INFECTION_SETTING);
FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.INFECTION_SETTING, CaseDataDto.NOSOCOMIAL_OUTBREAK, true, true);
// Reinfection
{
NullableOptionGroup ogReinfection = addField(CaseDataDto.RE_INFECTION, NullableOptionGroup.class);
addField(CaseDataDto.PREVIOUS_INFECTION_DATE);
ComboBox tfReinfectionStatus = addField(CaseDataDto.REINFECTION_STATUS, ComboBox.class);
tfReinfectionStatus.setReadOnly(true);
FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.PREVIOUS_INFECTION_DATE, CaseDataDto.RE_INFECTION, YesNoUnknown.YES, true);
FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.REINFECTION_STATUS, CaseDataDto.RE_INFECTION, YesNoUnknown.YES, false);
final Label reinfectionInfoLabel = new Label(VaadinIcons.EYE.getHtml(), ContentMode.HTML);
CssStyles.style(reinfectionInfoLabel, CssStyles.LABEL_XLARGE, CssStyles.VSPACE_TOP_3);
getContent().addComponent(reinfectionInfoLabel, REINFECTION_INFO_LOC);
reinfectionInfoLabel.setVisible(false);
final VerticalLayout reinfectionDetailsLeftLayout = new VerticalLayout();
CssStyles.style(reinfectionDetailsLeftLayout, CssStyles.VSPACE_3);
final VerticalLayout reinfectionDetailsRightLayout = new VerticalLayout();
CssStyles.style(reinfectionDetailsRightLayout, CssStyles.VSPACE_3);
for (ReinfectionDetailGroup group : ReinfectionDetailGroup.values()) {
CaseReinfectionCheckBoxTree reinfectionTree = new CaseReinfectionCheckBoxTree(ReinfectionDetail.values(group).stream().map(e -> new CheckBoxTree.CheckBoxElement<>(null, e)).collect(Collectors.toList()), () -> {
tfReinfectionStatus.setReadOnly(false);
tfReinfectionStatus.setValue(CaseLogic.calculateReinfectionStatus(mergeReinfectionTrees()));
tfReinfectionStatus.setReadOnly(true);
});
reinfectionTrees.put(group, reinfectionTree);
if (StringUtils.isNotBlank(group.toString())) {
Label heading = new Label(group.toString());
CssStyles.style(heading, CssStyles.H4);
if (group.ordinal() < 2) {
reinfectionDetailsLeftLayout.addComponent(heading);
} else {
reinfectionDetailsRightLayout.addComponent(heading);
}
}
if (group.ordinal() < 2) {
reinfectionDetailsLeftLayout.addComponent(reinfectionTree);
} else {
reinfectionDetailsRightLayout.addComponent(reinfectionTree);
}
}
getContent().addComponent(reinfectionDetailsLeftLayout, REINFECTION_DETAILS_COL_1_LOC);
getContent().addComponent(reinfectionDetailsRightLayout, REINFECTION_DETAILS_COL_2_LOC);
reinfectionDetailsLeftLayout.setVisible(false);
reinfectionDetailsRightLayout.setVisible(false);
ogReinfection.addValueChangeListener(e -> {
if (((NullableOptionGroup) e.getProperty()).getNullableValue() == YesNoUnknown.YES) {
PreviousCaseDto previousCase = FacadeProvider.getCaseFacade().getMostRecentPreviousCase(getValue().getPerson(), getValue().getDisease(), CaseLogic.getStartDate(getValue()));
if (previousCase != null) {
String reinfectionInfoTemplate = "<b>Previous case:</b><br/><br/>%s: %s<br/>%s: %s<br/>%s: %s<br/>%s: %s<br/>%s: %s";
String reinfectionInfo = String.format(reinfectionInfoTemplate, I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, EntityDto.UUID), DataHelper.getShortUuid(previousCase.getUuid()), I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.REPORT_DATE), DateHelper.formatLocalDate(previousCase.getReportDate(), I18nProperties.getUserLanguage()), I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.EXTERNAL_TOKEN), DataHelper.toStringNullable(previousCase.getExternalToken()), I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.DISEASE_VARIANT), DataHelper.toStringNullable(previousCase.getDiseaseVariant()), I18nProperties.getPrefixCaption(SymptomsDto.I18N_PREFIX, SymptomsDto.ONSET_DATE), previousCase.getOnsetDate() != null ? DateHelper.formatLocalDate(previousCase.getOnsetDate(), I18nProperties.getUserLanguage()) : "");
reinfectionInfoLabel.setDescription(reinfectionInfo, ContentMode.HTML);
reinfectionInfoLabel.setVisible(isVisibleAllowed(CaseDataDto.RE_INFECTION));
} else {
reinfectionInfoLabel.setDescription(null);
reinfectionInfoLabel.setVisible(false);
}
reinfectionDetailsLeftLayout.setVisible(isVisibleAllowed(CaseDataDto.RE_INFECTION));
reinfectionDetailsRightLayout.setVisible(isVisibleAllowed(CaseDataDto.RE_INFECTION));
} else {
reinfectionInfoLabel.setDescription(null);
reinfectionInfoLabel.setVisible(false);
for (CaseReinfectionCheckBoxTree reinfectionTree : reinfectionTrees.values()) {
reinfectionTree.clearCheckBoxTree();
}
reinfectionDetailsLeftLayout.setVisible(false);
reinfectionDetailsRightLayout.setVisible(false);
}
});
}
addField(CaseDataDto.QUARANTINE_HOME_POSSIBLE, NullableOptionGroup.class);
addField(CaseDataDto.QUARANTINE_HOME_POSSIBLE_COMMENT, TextField.class);
addField(CaseDataDto.QUARANTINE_HOME_SUPPLY_ENSURED, NullableOptionGroup.class);
addField(CaseDataDto.QUARANTINE_HOME_SUPPLY_ENSURED_COMMENT, TextField.class);
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.QUARANTINE_FROM, CaseDataDto.QUARANTINE_TO, CaseDataDto.QUARANTINE_HELP_NEEDED), CaseDataDto.QUARANTINE, QuarantineType.QUARANTINE_IN_EFFECT, true);
if (isConfiguredServer(CountryHelper.COUNTRY_CODE_GERMANY) || isConfiguredServer(CountryHelper.COUNTRY_CODE_SWITZERLAND)) {
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.QUARANTINE_ORDERED_VERBALLY, CaseDataDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT), CaseDataDto.QUARANTINE, QuarantineType.QUARANTINE_IN_EFFECT, true);
}
FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.QUARANTINE_HOME_POSSIBLE_COMMENT, CaseDataDto.QUARANTINE_HOME_POSSIBLE, Arrays.asList(YesNoUnknown.NO), true);
FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.QUARANTINE_HOME_SUPPLY_ENSURED, CaseDataDto.QUARANTINE_HOME_POSSIBLE, Arrays.asList(YesNoUnknown.YES), true);
FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.QUARANTINE_HOME_SUPPLY_ENSURED_COMMENT, CaseDataDto.QUARANTINE_HOME_SUPPLY_ENSURED, Arrays.asList(YesNoUnknown.NO), true);
FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.QUARANTINE_TYPE_DETAILS, CaseDataDto.QUARANTINE, Arrays.asList(QuarantineType.OTHER), true);
FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.QUARANTINE_ORDERED_VERBALLY_DATE, CaseDataDto.QUARANTINE_ORDERED_VERBALLY, Arrays.asList(Boolean.TRUE), true);
FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT_DATE, CaseDataDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT, Arrays.asList(Boolean.TRUE), true);
FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.QUARANTINE_OFFICIAL_ORDER_SENT_DATE, CaseDataDto.QUARANTINE_OFFICIAL_ORDER_SENT, Collections.singletonList(Boolean.TRUE), true);
ComboBox surveillanceOfficerField = addField(CaseDataDto.SURVEILLANCE_OFFICER, ComboBox.class);
surveillanceOfficerField.setNullSelectionAllowed(true);
differentPlaceOfStayJurisdiction = addCustomField(DIFFERENT_PLACE_OF_STAY_JURISDICTION, Boolean.class, CheckBox.class);
differentPlaceOfStayJurisdiction.addStyleName(VSPACE_3);
if (UserRole.getJurisdictionLevel(UserProvider.getCurrent().getUserRoles()) == JurisdictionLevel.HEALTH_FACILITY) {
differentPlaceOfStayJurisdiction.setEnabled(false);
differentPlaceOfStayJurisdiction.setVisible(false);
}
ComboBox regionCombo = addInfrastructureField(CaseDataDto.REGION);
districtCombo = addInfrastructureField(CaseDataDto.DISTRICT);
communityCombo = addInfrastructureField(CaseDataDto.COMMUNITY);
communityCombo.setNullSelectionAllowed(true);
communityCombo.addStyleName(SOFT_REQUIRED);
FieldHelper.setVisibleWhen(differentPlaceOfStayJurisdiction, Arrays.asList(regionCombo, districtCombo, communityCombo), Collections.singletonList(Boolean.TRUE), true);
FieldHelper.setRequiredWhen(differentPlaceOfStayJurisdiction, Arrays.asList(regionCombo, districtCombo), Collections.singletonList(Boolean.TRUE), false, null);
Label placeOfStayHeadingLabel = new Label(I18nProperties.getCaption(Captions.casePlaceOfStay));
placeOfStayHeadingLabel.addStyleName(H3);
getContent().addComponent(placeOfStayHeadingLabel, PLACE_OF_STAY_HEADING_LOC);
facilityOrHome = new OptionGroup(I18nProperties.getCaption(Captions.casePlaceOfStay), TypeOfPlace.FOR_CASES);
facilityOrHome.setId("facilityOrHome");
facilityOrHome.setWidth(100, Unit.PERCENTAGE);
CssStyles.style(facilityOrHome, ValoTheme.OPTIONGROUP_HORIZONTAL);
getContent().addComponent(facilityOrHome, FACILITY_OR_HOME_LOC);
facilityTypeGroup = ComboBoxHelper.createComboBoxV7();
facilityTypeGroup.setId("typeGroup");
facilityTypeGroup.setCaption(I18nProperties.getCaption(Captions.Facility_typeGroup));
facilityTypeGroup.setWidth(100, Unit.PERCENTAGE);
facilityTypeGroup.addItems(FacilityTypeGroup.getAccomodationGroups());
facilityTypeGroup.setVisible(false);
getContent().addComponent(facilityTypeGroup, TYPE_GROUP_LOC);
facilityTypeCombo = addField(CaseDataDto.FACILITY_TYPE);
facilityCombo = addInfrastructureField(CaseDataDto.HEALTH_FACILITY);
facilityCombo.setImmediate(true);
facilityDetails = addField(CaseDataDto.HEALTH_FACILITY_DETAILS, TextField.class);
facilityDetails.setVisible(false);
regionCombo.addValueChangeListener(e -> {
RegionReferenceDto regionDto = (RegionReferenceDto) e.getProperty().getValue();
FieldHelper.updateItems(districtCombo, regionDto != null ? FacadeProvider.getDistrictFacade().getAllActiveByRegion(regionDto.getUuid()) : null);
});
districtCombo.addValueChangeListener(e -> {
DistrictReferenceDto districtDto = (DistrictReferenceDto) e.getProperty().getValue();
FieldHelper.updateItems(communityCombo, districtDto != null ? FacadeProvider.getCommunityFacade().getAllActiveByDistrict(districtDto.getUuid()) : null);
updateFacility();
});
communityCombo.addValueChangeListener(e -> updateFacility());
facilityOrHome.addValueChangeListener(e -> {
FieldHelper.removeItems(facilityCombo);
if (TypeOfPlace.FACILITY.equals(facilityOrHome.getValue())) {
// default values
if (facilityTypeGroup.getValue() == null && !facilityTypeGroup.isReadOnly()) {
facilityTypeGroup.setValue(FacilityTypeGroup.MEDICAL_FACILITY);
}
if (facilityTypeCombo.getValue() == null && FacilityTypeGroup.MEDICAL_FACILITY.equals(facilityTypeGroup.getValue()) && !facilityTypeCombo.isReadOnly()) {
facilityTypeCombo.setValue(FacilityType.HOSPITAL);
}
if (facilityTypeCombo.getValue() != null) {
updateFacility();
}
if (CaseOrigin.IN_COUNTRY.equals(getField(CaseDataDto.CASE_ORIGIN).getValue())) {
facilityCombo.setRequired(true);
}
updateFacilityDetails(facilityCombo, facilityDetails);
} else {
// switched from facility to home
if (!facilityCombo.isReadOnly()) {
FacilityReferenceDto noFacilityRef = FacadeProvider.getFacilityFacade().getByUuid(FacilityDto.NONE_FACILITY_UUID).toReference();
facilityCombo.addItem(noFacilityRef);
facilityCombo.setValue(noFacilityRef);
}
facilityTypeGroup.clear();
facilityTypeCombo.clear();
}
});
facilityTypeGroup.addValueChangeListener(e -> FieldHelper.updateEnumData(facilityTypeCombo, FacilityType.getAccommodationTypes((FacilityTypeGroup) facilityTypeGroup.getValue())));
facilityTypeCombo.addValueChangeListener(e -> updateFacility());
facilityCombo.addValueChangeListener(e -> updateFacilityDetails(facilityCombo, facilityDetails));
regionCombo.addItems(FacadeProvider.getRegionFacade().getAllActiveByServerCountry());
if (!FacadeProvider.getFeatureConfigurationFacade().isFeatureDisabled(FeatureType.NATIONAL_CASE_SHARING)) {
addField(CaseDataDto.SHARED_TO_COUNTRY, CheckBox.class);
setReadOnly(!UserProvider.getCurrent().hasUserRight(UserRight.CASE_SHARE), CaseDataDto.SHARED_TO_COUNTRY);
}
ComboBox pointOfEntry = addInfrastructureField(CaseDataDto.POINT_OF_ENTRY);
addField(CaseDataDto.POINT_OF_ENTRY_DETAILS, TextField.class);
addField(CaseDataDto.PROHIBITION_TO_WORK, NullableOptionGroup.class).addStyleName(ValoTheme.OPTIONGROUP_HORIZONTAL);
DateField prohibitionToWorkFrom = addField(CaseDataDto.PROHIBITION_TO_WORK_FROM, DateField.class);
DateField prohibitionToWorkUntil = addDateField(CaseDataDto.PROHIBITION_TO_WORK_UNTIL, DateField.class, -1);
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.PROHIBITION_TO_WORK_FROM, CaseDataDto.PROHIBITION_TO_WORK_UNTIL), CaseDataDto.PROHIBITION_TO_WORK, YesNoUnknown.YES, true);
prohibitionToWorkFrom.addValidator(new DateComparisonValidator(prohibitionToWorkFrom, prohibitionToWorkUntil, true, false, I18nProperties.getValidationError(Validations.beforeDate, prohibitionToWorkFrom.getCaption(), prohibitionToWorkUntil.getCaption())));
prohibitionToWorkUntil.addValidator(new DateComparisonValidator(prohibitionToWorkUntil, prohibitionToWorkFrom, false, false, I18nProperties.getValidationError(Validations.afterDate, prohibitionToWorkUntil.getCaption(), prohibitionToWorkFrom.getCaption())));
AccessibleTextField tfReportLat = addField(CaseDataDto.REPORT_LAT, AccessibleTextField.class);
tfReportLat.setConverter(new StringToAngularLocationConverter());
AccessibleTextField tfReportLon = addField(CaseDataDto.REPORT_LON, AccessibleTextField.class);
tfReportLon.setConverter(new StringToAngularLocationConverter());
addField(CaseDataDto.REPORT_LAT_LON_ACCURACY, TextField.class);
dfFollowUpUntil = null;
cbOverwriteFollowUpUntil = null;
if (caseFollowUpEnabled) {
addField(CaseDataDto.FOLLOW_UP_STATUS, ComboBox.class);
addField(CaseDataDto.FOLLOW_UP_STATUS_CHANGE_DATE);
addField(CaseDataDto.FOLLOW_UP_STATUS_CHANGE_USER);
addField(CaseDataDto.FOLLOW_UP_COMMENT, TextArea.class).setRows(3);
dfFollowUpUntil = addDateField(CaseDataDto.FOLLOW_UP_UNTIL, DateField.class, -1);
dfFollowUpUntil.addValueChangeListener(v -> onFollowUpUntilChanged());
tfExpectedFollowUpUntilDate = new TextField();
tfExpectedFollowUpUntilDate.setCaption(I18nProperties.getCaption(Captions.CaseData_expectedFollowUpUntil));
getContent().addComponent(tfExpectedFollowUpUntilDate, EXPECTED_FOLLOW_UP_UNTIL_DATE_LOC);
cbOverwriteFollowUpUntil = addField(ContactDto.OVERWRITE_FOLLOW_UP_UTIL, CheckBox.class);
setReadOnly(true, CaseDataDto.FOLLOW_UP_STATUS, CaseDataDto.FOLLOW_UP_STATUS_CHANGE_DATE, CaseDataDto.FOLLOW_UP_STATUS_CHANGE_USER);
FieldHelper.setRequiredWhen(getFieldGroup(), CaseDataDto.FOLLOW_UP_STATUS, Arrays.asList(CaseDataDto.FOLLOW_UP_COMMENT), Arrays.asList(FollowUpStatus.CANCELED, FollowUpStatus.LOST));
FieldHelper.setRequiredWhen(getFieldGroup(), CaseDataDto.OVERWRITE_FOLLOW_UP_UNTIL, Arrays.asList(CaseDataDto.FOLLOW_UP_UNTIL), Arrays.asList(Boolean.TRUE));
FieldHelper.setVisibleWhenSourceNotNull(getFieldGroup(), Arrays.asList(CaseDataDto.FOLLOW_UP_STATUS_CHANGE_DATE, CaseDataDto.FOLLOW_UP_STATUS_CHANGE_USER), CaseDataDto.FOLLOW_UP_STATUS_CHANGE_DATE, true);
}
if (cbOverwriteFollowUpUntil != null) {
cbOverwriteFollowUpUntil.addValueChangeListener(e -> {
if (!(Boolean) e.getProperty().getValue()) {
dfFollowUpUntil.discard();
}
});
FieldHelper.setReadOnlyWhen(getFieldGroup(), Arrays.asList(CaseDataDto.FOLLOW_UP_UNTIL), CaseDataDto.OVERWRITE_FOLLOW_UP_UNTIL, Arrays.asList(Boolean.FALSE), false, true);
}
dfQuarantineTo.addValueChangeListener(e -> onQuarantineEndChange());
this.addValueChangeListener(e -> onValueChange());
Label generalCommentLabel = new Label(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.ADDITIONAL_DETAILS));
generalCommentLabel.addStyleName(H3);
getContent().addComponent(generalCommentLabel, GENERAL_COMMENT_LOC);
TextArea additionalDetails = addField(CaseDataDto.ADDITIONAL_DETAILS, TextArea.class);
additionalDetails.setRows(6);
additionalDetails.setDescription(I18nProperties.getPrefixDescription(CaseDataDto.I18N_PREFIX, CaseDataDto.ADDITIONAL_DETAILS, "") + "\n" + I18nProperties.getDescription(Descriptions.descGdpr));
CssStyles.style(additionalDetails, CssStyles.CAPTION_HIDDEN);
addField(CaseDataDto.PREGNANT, NullableOptionGroup.class);
addField(CaseDataDto.POSTPARTUM, NullableOptionGroup.class);
addField(CaseDataDto.TRIMESTER, NullableOptionGroup.class);
addField(CaseDataDto.VACCINATION_STATUS);
addFields(CaseDataDto.SMALLPOX_VACCINATION_SCAR, CaseDataDto.SMALLPOX_VACCINATION_RECEIVED);
addDateField(CaseDataDto.SMALLPOX_LAST_VACCINATION_DATE, DateField.class, 0);
// Swiss fields
AccessibleTextField caseIdIsmField = addField(CaseDataDto.CASE_ID_ISM, AccessibleTextField.class);
caseIdIsmField.setConversionError(I18nProperties.getValidationError(Validations.onlyIntegerNumbersAllowed, caseIdIsmField.getCaption()));
if (fieldVisibilityCheckers.isVisible(CaseDataDto.class, CaseDataDto.CONTACT_TRACING_FIRST_CONTACT_TYPE)) {
Label contactTracingFirstContactHeadingLabel = new Label(I18nProperties.getString(Strings.headingContactTracingFirstContact));
contactTracingFirstContactHeadingLabel.addStyleName(H3);
getContent().addComponent(contactTracingFirstContactHeadingLabel, CONTACT_TRACING_FIRST_CONTACT_HEADER_LOC);
addFields(CaseDataDto.CONTACT_TRACING_FIRST_CONTACT_TYPE, CaseDataDto.CONTACT_TRACING_FIRST_CONTACT_DATE);
}
addField(CaseDataDto.WAS_IN_QUARANTINE_BEFORE_ISOLATION).setStyleName(ValoTheme.OPTIONGROUP_HORIZONTAL);
addFields(CaseDataDto.QUARANTINE_REASON_BEFORE_ISOLATION, CaseDataDto.QUARANTINE_REASON_BEFORE_ISOLATION_DETAILS);
FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.QUARANTINE_REASON_BEFORE_ISOLATION_DETAILS, CaseDataDto.QUARANTINE_REASON_BEFORE_ISOLATION, Arrays.asList(QuarantineReason.OTHER_REASON), true);
addFields(CaseDataDto.END_OF_ISOLATION_REASON, CaseDataDto.END_OF_ISOLATION_REASON_DETAILS);
FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.END_OF_ISOLATION_REASON_DETAILS, CaseDataDto.END_OF_ISOLATION_REASON, Arrays.asList(EndOfIsolationReason.OTHER), true);
// jurisdiction fields
Label jurisdictionHeadingLabel = new Label(I18nProperties.getString(Strings.headingCaseResponsibleJurisidction));
jurisdictionHeadingLabel.addStyleName(H3);
getContent().addComponent(jurisdictionHeadingLabel, RESPONSIBLE_JURISDICTION_HEADING_LOC);
ComboBox responsibleRegion = addInfrastructureField(CaseDataDto.RESPONSIBLE_REGION);
responsibleRegion.setRequired(true);
responsibleDistrict = addInfrastructureField(CaseDataDto.RESPONSIBLE_DISTRICT);
responsibleDistrict.setRequired(true);
responsibleCommunity = addInfrastructureField(CaseDataDto.RESPONSIBLE_COMMUNITY);
responsibleCommunity.setNullSelectionAllowed(true);
responsibleCommunity.addStyleName(SOFT_REQUIRED);
InfrastructureFieldsHelper.initInfrastructureFields(responsibleRegion, responsibleDistrict, responsibleCommunity);
InfrastructureFieldsHelper.initPointOfEntry(responsibleDistrict, pointOfEntry);
responsibleDistrict.addValueChangeListener(e -> {
Boolean differentPlaceOfStay = differentPlaceOfStayJurisdiction.getValue();
if (differentPlaceOfStay == null || Boolean.FALSE.equals(differentPlaceOfStay)) {
updateFacility();
}
});
responsibleCommunity.addValueChangeListener((e) -> {
Boolean differentPlaceOfStay = differentPlaceOfStayJurisdiction.getValue();
if (differentPlaceOfStay == null || Boolean.FALSE.equals(differentPlaceOfStay)) {
updateFacility();
}
});
differentPlaceOfStayJurisdiction.addValueChangeListener(e -> {
if (!ignoreDifferentPlaceOfStayJurisdiction) {
updateFacility();
}
});
// Set initial visibilities & accesses
initializeVisibilitiesAndAllowedVisibilities();
initializeAccessAndAllowedAccesses();
// Set requirements that don't need visibility changes and read only status
setRequired(true, CaseDataDto.REPORT_DATE, CaseDataDto.CASE_CLASSIFICATION, CaseDataDto.INVESTIGATION_STATUS, CaseDataDto.OUTCOME, CaseDataDto.DISEASE);
setSoftRequired(true, CaseDataDto.INVESTIGATED_DATE, CaseDataDto.OUTCOME_DATE, CaseDataDto.PLAGUE_TYPE, CaseDataDto.SURVEILLANCE_OFFICER);
if (isEditableAllowed(CaseDataDto.INVESTIGATED_DATE)) {
FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.INVESTIGATED_DATE, CaseDataDto.INVESTIGATION_STATUS, Arrays.asList(InvestigationStatus.DONE, InvestigationStatus.DISCARDED), true);
}
setReadOnly(true, CaseDataDto.UUID, CaseDataDto.REPORTING_USER, CaseDataDto.CLASSIFICATION_USER, CaseDataDto.CLASSIFICATION_DATE, CaseDataDto.POINT_OF_ENTRY, CaseDataDto.POINT_OF_ENTRY_DETAILS, CaseDataDto.CASE_ORIGIN);
setReadOnly(!UserProvider.getCurrent().hasUserRight(UserRight.CASE_CHANGE_DISEASE), CaseDataDto.DISEASE);
setReadOnly(!UserProvider.getCurrent().hasUserRight(UserRight.CASE_INVESTIGATE), CaseDataDto.INVESTIGATION_STATUS, CaseDataDto.INVESTIGATED_DATE);
setReadOnly(!UserProvider.getCurrent().hasUserRight(UserRight.CASE_CLASSIFY), CaseDataDto.CASE_CLASSIFICATION, CaseDataDto.OUTCOME, CaseDataDto.OUTCOME_DATE);
setReadOnly(!UserProvider.getCurrent().hasUserRight(UserRight.CASE_TRANSFER), CaseDataDto.RESPONSIBLE_REGION, CaseDataDto.RESPONSIBLE_DISTRICT, CaseDataDto.RESPONSIBLE_COMMUNITY, DIFFERENT_PLACE_OF_STAY_JURISDICTION, CaseDataDto.REGION, CaseDataDto.DISTRICT, CaseDataDto.COMMUNITY, FACILITY_OR_HOME_LOC, TYPE_GROUP_LOC, CaseDataDto.FACILITY_TYPE, CaseDataDto.HEALTH_FACILITY, CaseDataDto.HEALTH_FACILITY_DETAILS);
if (!isEditableAllowed(CaseDataDto.COMMUNITY)) {
setEnabled(false, CaseDataDto.REGION, CaseDataDto.DISTRICT);
}
if (!isEditableAllowed(CaseDataDto.RESPONSIBLE_COMMUNITY)) {
setEnabled(false, CaseDataDto.RESPONSIBLE_REGION, CaseDataDto.RESPONSIBLE_DISTRICT);
}
FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.TRIMESTER, CaseDataDto.PREGNANT, Arrays.asList(YesNoUnknown.YES), true);
diseaseField.addValueChangeListener((ValueChangeListener) valueChangeEvent -> {
Disease disease = (Disease) valueChangeEvent.getProperty().getValue();
List<DiseaseVariant> diseaseVariants = FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.DISEASE_VARIANT, disease);
FieldHelper.updateItems(diseaseVariantField, diseaseVariants);
diseaseVariantField.setVisible(disease != null && isVisibleAllowed(CaseDataDto.DISEASE_VARIANT) && CollectionUtils.isNotEmpty(diseaseVariants));
});
diseaseVariantField.addValueChangeListener(e -> {
DiseaseVariant diseaseVariant = (DiseaseVariant) e.getProperty().getValue();
diseaseVariantDetailsField.setVisible(diseaseVariant != null && diseaseVariant.matchPropertyValue(DiseaseVariant.HAS_DETAILS, true));
});
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);
}
if (isVisibleAllowed(CaseDataDto.SMALLPOX_VACCINATION_SCAR)) {
FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.SMALLPOX_VACCINATION_SCAR, CaseDataDto.SMALLPOX_VACCINATION_RECEIVED, Arrays.asList(YesNoUnknown.YES), true);
}
if (isVisibleAllowed(CaseDataDto.SMALLPOX_LAST_VACCINATION_DATE)) {
if (isVisibleAllowed(CaseDataDto.SMALLPOX_VACCINATION_RECEIVED)) {
FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.SMALLPOX_LAST_VACCINATION_DATE, CaseDataDto.SMALLPOX_VACCINATION_RECEIVED, Collections.singletonList(YesNoUnknown.YES), true);
}
}
if (isVisibleAllowed(CaseDataDto.OUTCOME_DATE)) {
FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.OUTCOME_DATE, CaseDataDto.OUTCOME, Arrays.asList(CaseOutcome.DECEASED, CaseOutcome.RECOVERED, CaseOutcome.UNKNOWN), true);
}
if (isVisibleAllowed(CaseDataDto.SEQUELAE)) {
FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.SEQUELAE, CaseDataDto.OUTCOME, Arrays.asList(CaseOutcome.RECOVERED, CaseOutcome.UNKNOWN), true);
}
if (isVisibleAllowed(CaseDataDto.SEQUELAE_DETAILS)) {
FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.SEQUELAE_DETAILS, CaseDataDto.SEQUELAE, Arrays.asList(YesNoUnknown.YES), true);
}
if (isVisibleAllowed(CaseDataDto.NOTIFYING_CLINIC_DETAILS)) {
FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.NOTIFYING_CLINIC_DETAILS, CaseDataDto.NOTIFYING_CLINIC, Arrays.asList(HospitalWardType.OTHER), true);
}
FieldHelper.setVisibleWhen(facilityOrHome, Arrays.asList(facilityTypeGroup, facilityTypeCombo, facilityCombo), Collections.singletonList(TypeOfPlace.FACILITY), false);
FieldHelper.setRequiredWhen(facilityOrHome, Arrays.asList(facilityTypeGroup, facilityTypeCombo, facilityCombo), Collections.singletonList(TypeOfPlace.FACILITY), false, null);
// / CLINICIAN FIELDS
if (isVisibleAllowed(CaseDataDto.CLINICIAN_NAME)) {
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.CLINICIAN_NAME, CaseDataDto.CLINICIAN_PHONE, CaseDataDto.CLINICIAN_EMAIL), CaseDataDto.FACILITY_TYPE, Arrays.asList(FacilityType.HOSPITAL, FacilityType.OTHER_MEDICAL_FACILITY), true);
}
// Other initializations
if (disease == Disease.MONKEYPOX) {
Image smallpoxVaccinationScarImg = new Image(null, new ThemeResource("img/smallpox-vaccination-scar.jpg"));
style(smallpoxVaccinationScarImg, VSPACE_3);
getContent().addComponent(smallpoxVaccinationScarImg, SMALLPOX_VACCINATION_SCAR_IMG);
// Set up initial image visibility
getContent().getComponent(SMALLPOX_VACCINATION_SCAR_IMG).setVisible(getFieldGroup().getField(CaseDataDto.SMALLPOX_VACCINATION_RECEIVED).getValue() == YesNoUnknown.YES);
// Set up image visibility listener
getFieldGroup().getField(CaseDataDto.SMALLPOX_VACCINATION_RECEIVED).addValueChangeListener(e -> getContent().getComponent(SMALLPOX_VACCINATION_SCAR_IMG).setVisible(e.getProperty().getValue() == YesNoUnknown.YES));
}
List<String> medicalInformationFields = Arrays.asList(CaseDataDto.PREGNANT, CaseDataDto.VACCINATION_STATUS, CaseDataDto.SMALLPOX_VACCINATION_RECEIVED);
addField(CaseDataDto.HEALTH_CONDITIONS, HealthConditionsForm.class).setCaption(null);
for (String medicalInformationField : medicalInformationFields) {
if (getFieldGroup().getField(medicalInformationField).isVisible()) {
Label medicalInformationCaptionLabel = new Label(I18nProperties.getString(Strings.headingMedicalInformation));
medicalInformationCaptionLabel.addStyleName(H3);
getContent().addComponent(medicalInformationCaptionLabel, MEDICAL_INFORMATION_LOC);
break;
}
}
if (!shouldHidePaperFormDates()) {
Label paperFormDatesLabel = new Label(I18nProperties.getString(Strings.headingPaperFormDates));
paperFormDatesLabel.addStyleName(H3);
getContent().addComponent(paperFormDatesLabel, PAPER_FORM_DATES_LOC);
}
// Automatic case classification rules button - invisible for other diseases
DiseaseClassificationCriteriaDto diseaseClassificationCriteria = FacadeProvider.getCaseClassificationFacade().getByDisease(disease);
if (diseaseClassificationExists()) {
Button classificationRulesButton = ButtonHelper.createIconButton(Captions.info, VaadinIcons.INFO_CIRCLE, e -> ControllerProvider.getCaseController().openClassificationRulesPopup(diseaseClassificationCriteria), ValoTheme.BUTTON_PRIMARY, FORCE_CAPTION);
getContent().addComponent(classificationRulesButton, CLASSIFICATION_RULES_LOC);
}
addField(CaseDataDto.DELETION_REASON);
addField(CaseDataDto.OTHER_DELETION_REASON, TextArea.class).setRows(3);
setVisible(false, CaseDataDto.DELETION_REASON, CaseDataDto.OTHER_DELETION_REASON);
addValueChangeListener(e -> {
diseaseField.addValueChangeListener(new DiseaseChangeListener(diseaseField, getValue().getDisease()));
FieldHelper.updateOfficersField(surveillanceOfficerField, getValue(), UserRight.CASE_RESPONSIBLE);
// Replace classification user if case has been automatically classified
if (getValue().getClassificationDate() != null && getValue().getClassificationUser() == null) {
getField(CaseDataDto.CLASSIFICATION_USER).setVisible(false);
Label classifiedBySystemLabel = new Label(I18nProperties.getCaption(Captions.system));
classifiedBySystemLabel.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.CLASSIFIED_BY));
// ensure correct formatting
GridLayout tempLayout = new GridLayout();
tempLayout.addComponent(classifiedBySystemLabel);
getContent().addComponent(tempLayout, CLASSIFIED_BY_SYSTEM_LOC);
}
updateFollowUpStatusComponents();
setEpidNumberError(epidField, assignNewEpidNumberButton, epidNumberWarningLabel, getValue().getEpidNumber());
epidField.addValueChangeListener(f -> {
setEpidNumberError(epidField, assignNewEpidNumberButton, epidNumberWarningLabel, (String) f.getProperty().getValue());
});
ValidationUtils.initComponentErrorValidator(externalTokenField, getValue().getExternalToken(), Validations.duplicateExternalToken, externalTokenWarningLabel, (externalToken) -> FacadeProvider.getCaseFacade().doesExternalTokenExist(externalToken, getValue().getUuid()));
updateFacilityOrHome();
// Set health facility/point of entry visibility based on case origin
if (getValue().getCaseOrigin() == CaseOrigin.POINT_OF_ENTRY) {
setVisible(true, CaseDataDto.POINT_OF_ENTRY);
if (getValue().getPointOfEntry() != null) {
setVisible(getValue().getPointOfEntry().isOtherPointOfEntry(), CaseDataDto.POINT_OF_ENTRY_DETAILS);
}
if (getValue().getHealthFacility() == null) {
setVisible(false, DIFFERENT_PLACE_OF_STAY_JURISDICTION, CaseDataDto.COMMUNITY, FACILITY_OR_HOME_LOC, TYPE_GROUP_LOC, CaseDataDto.FACILITY_TYPE, CaseDataDto.HEALTH_FACILITY, CaseDataDto.HEALTH_FACILITY_DETAILS);
setReadOnly(true, CaseDataDto.REGION, CaseDataDto.DISTRICT, CaseDataDto.COMMUNITY);
}
} else {
facilityOrHome.setRequired(true);
setVisible(false, CaseDataDto.POINT_OF_ENTRY, CaseDataDto.POINT_OF_ENTRY_DETAILS);
}
// take over the value that has been set based on access rights
facilityTypeGroup.setReadOnly(facilityTypeCombo.isReadOnly());
facilityOrHome.setReadOnly(facilityTypeCombo.isReadOnly());
// Hide case origin from port health users
if (UserRole.isPortHealthUser(UserProvider.getCurrent().getUserRoles())) {
setVisible(false, CaseDataDto.CASE_ORIGIN);
}
if (caseFollowUpEnabled) {
// Add follow-up until validator
List<SampleDto> samples = Collections.emptyList();
if (UserProvider.getCurrent().hasAllUserRights(UserRight.SAMPLE_VIEW)) {
samples = FacadeProvider.getSampleFacade().getByCaseUuids(Collections.singletonList(caseUuid));
}
FollowUpPeriodDto followUpPeriod = CaseLogic.getFollowUpStartDate(symptoms.getOnsetDate(), reportDate.getValue(), samples);
Date minimumFollowUpUntilDate = FollowUpLogic.calculateFollowUpUntilDate(followUpPeriod, null, FacadeProvider.getVisitFacade().getVisitsByCase(new CaseReferenceDto(caseUuid)), FacadeProvider.getDiseaseConfigurationFacade().getCaseFollowUpDuration((Disease) diseaseField.getValue()), FacadeProvider.getFeatureConfigurationFacade().isPropertyValueTrue(FeatureType.CASE_FOLLOWUP, FeatureTypeProperty.ALLOW_FREE_FOLLOW_UP_OVERWRITE)).getFollowUpEndDate();
if (FacadeProvider.getFeatureConfigurationFacade().isPropertyValueTrue(FeatureType.CASE_FOLLOWUP, FeatureTypeProperty.ALLOW_FREE_FOLLOW_UP_OVERWRITE)) {
dfFollowUpUntil.addValueChangeListener(valueChangeEvent -> {
if (DateHelper.getEndOfDay(dfFollowUpUntil.getValue()).before(minimumFollowUpUntilDate)) {
dfFollowUpUntil.setComponentError(new ErrorMessage() {
@Override
public ErrorLevel getErrorLevel() {
return ErrorLevel.INFO;
}
@Override
public String getFormattedHtmlMessage() {
return I18nProperties.getValidationError(Validations.contactFollowUpUntilDateSoftValidation, I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.FOLLOW_UP_UNTIL));
}
});
}
});
} else {
dfFollowUpUntil.addValidator(new DateRangeValidator(I18nProperties.getValidationError(Validations.contactFollowUpUntilDate), minimumFollowUpUntilDate, null, Resolution.DAY));
}
}
// Overwrite visibility for quarantine fields
if (!isConfiguredServer(CountryHelper.COUNTRY_CODE_GERMANY) && !isConfiguredServer(CountryHelper.COUNTRY_CODE_SWITZERLAND)) {
setVisible(false, CaseDataDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT, CaseDataDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT_DATE, CaseDataDto.QUARANTINE_ORDERED_VERBALLY, CaseDataDto.QUARANTINE_ORDERED_VERBALLY_DATE, CaseDataDto.QUARANTINE_OFFICIAL_ORDER_SENT, CaseDataDto.QUARANTINE_OFFICIAL_ORDER_SENT_DATE);
}
// Make external ID field read-only when SORMAS is connected to a SurvNet instance
if (StringUtils.isNotEmpty(FacadeProvider.getConfigFacade().getExternalSurveillanceToolGatewayUrl())) {
setEnabled(false, CaseDataDto.EXTERNAL_ID);
((TextField) getField(CaseDataDto.EXTERNAL_ID)).setInputPrompt(I18nProperties.getString(Strings.promptExternalIdExternalSurveillanceTool));
}
for (CaseReinfectionCheckBoxTree reinfectionTree : reinfectionTrees.values()) {
reinfectionTree.initCheckboxes();
}
});
}
use of de.symeda.sormas.ui.utils.CssStyles.VSPACE_3 in project SORMAS-Project by hzi-braunschweig.
the class SymptomsForm method addFields.
@Override
protected void addFields() {
if (disease == null || symptomsContext == null) {
// workaround to stop initialization until disease is set
return;
}
// Add fields
Label clinicalMeasurementsHeadingLabel = createLabel(I18nProperties.getString(Strings.headingClinicalMeasurements), H3, CLINICAL_MEASUREMENTS_HEADING_LOC);
Label signsAndSymptomsHeadingLabel = createLabel(I18nProperties.getString(Strings.headingSignsAndSymptoms), H3, SIGNS_AND_SYMPTOMS_HEADING_LOC);
final Label generalSymptomsHeadingLabel = createLabel(SymptomGroup.GENERAL.toString(), H4, GENERAL_SIGNS_AND_SYMPTOMS_HEADING_LOC);
final Label respiratorySymptomsHeadingLabel = createLabel(SymptomGroup.RESPIRATORY.toString(), H4, RESPIRATORY_SIGNS_AND_SYMPTOMS_HEADING_LOC);
final Label cardiovascularSymptomsHeadingLabel = createLabel(SymptomGroup.CARDIOVASCULAR.toString(), H4, CARDIOVASCULAR_SIGNS_AND_SYMPTOMS_HEADING_LOC);
final Label gastrointestinalSymptomsHeadingLabel = createLabel(SymptomGroup.GASTROINTESTINAL.toString(), H4, GASTROINTESTINAL_SIGNS_AND_SYMPTOMS_HEADING_LOC);
final Label urinarySymptomsHeadingLabel = createLabel(SymptomGroup.URINARY.toString(), H4, URINARY_SIGNS_AND_SYMPTOMS_HEADING_LOC);
final Label nervousSystemSymptomsHeadingLabel = createLabel(SymptomGroup.NERVOUS_SYSTEM.toString(), H4, NERVOUS_SYSTEM_SIGNS_AND_SYMPTOMS_HEADING_LOC);
final Label skinSymptomsHeadingLabel = createLabel(SymptomGroup.SKIN.toString(), H4, SKIN_SIGNS_AND_SYMPTOMS_HEADING_LOC);
final Label otherSymptomsHeadingLabel = createLabel(SymptomGroup.OTHER.toString(), H4, OTHER_SIGNS_AND_SYMPTOMS_HEADING_LOC);
DateField onsetDateField = addField(ONSET_DATE, DateField.class);
ComboBox onsetSymptom = addField(ONSET_SYMPTOM, ComboBox.class);
if (symptomsContext == SymptomsContext.CASE) {
// If the symptom onset date is after the hospital admission date, show a warning but don't prevent the user from saving
onsetDateField.addValueChangeListener(event -> {
if (caze.getHospitalization().getAdmissionDate() != null && DateTimeComparator.getDateOnlyInstance().compare(caze.getHospitalization().getAdmissionDate(), onsetDateField.getValue()) < 0) {
onsetDateField.setComponentError(new ErrorMessage() {
@Override
public ErrorLevel getErrorLevel() {
return ErrorLevel.INFO;
}
@Override
public String getFormattedHtmlMessage() {
return I18nProperties.getValidationError(Validations.beforeDateSoft, onsetDateField.getCaption(), I18nProperties.getPrefixCaption(HospitalizationDto.I18N_PREFIX, HospitalizationDto.ADMISSION_DATE));
}
});
} else if (onsetDateField.isValid()) {
onsetDateField.setComponentError(null);
}
});
}
ComboBox temperature = addField(TEMPERATURE, ComboBox.class);
temperature.setImmediate(true);
for (Float temperatureValue : SymptomsHelper.getTemperatureValues()) {
temperature.addItem(temperatureValue);
temperature.setItemCaption(temperatureValue, SymptomsHelper.getTemperatureString(temperatureValue));
}
if (symptomsContext == SymptomsContext.CASE) {
temperature.setCaption(I18nProperties.getCaption(Captions.symptomsMaxTemperature));
}
addField(TEMPERATURE_SOURCE);
ComboBox bloodPressureSystolic = addField(BLOOD_PRESSURE_SYSTOLIC, ComboBox.class);
bloodPressureSystolic.addItems(SymptomsHelper.getBloodPressureValues());
ComboBox bloodPressureDiastolic = addField(BLOOD_PRESSURE_DIASTOLIC, ComboBox.class);
bloodPressureDiastolic.addItems(SymptomsHelper.getBloodPressureValues());
ComboBox heartRate = addField(HEART_RATE, ComboBox.class);
heartRate.addItems(SymptomsHelper.getHeartRateValues());
ComboBox respiratoryRate = addField(RESPIRATORY_RATE, ComboBox.class);
respiratoryRate.addItems(SymptomsHelper.getRespiratoryRateValues());
ComboBox weight = addField(WEIGHT, ComboBox.class);
for (Integer weightValue : SymptomsHelper.getWeightValues()) {
weight.addItem(weightValue);
weight.setItemCaption(weightValue, SymptomsHelper.getDecimalString(weightValue));
}
ComboBox height = addField(HEIGHT, ComboBox.class);
height.addItems(SymptomsHelper.getHeightValues());
ComboBox midUpperArmCircumference = addField(MID_UPPER_ARM_CIRCUMFERENCE, ComboBox.class);
for (Integer circumferenceValue : SymptomsHelper.getMidUpperArmCircumferenceValues()) {
midUpperArmCircumference.addItem(circumferenceValue);
midUpperArmCircumference.setItemCaption(circumferenceValue, SymptomsHelper.getDecimalString(circumferenceValue));
}
ComboBox glasgowComaScale = addField(GLASGOW_COMA_SCALE, ComboBox.class);
glasgowComaScale.addItems(SymptomsHelper.getGlasgowComaScaleValues());
addFields(VOMITING, DIARRHEA, BLOOD_IN_STOOL, NAUSEA, ABDOMINAL_PAIN, HEADACHE, MUSCLE_PAIN, FATIGUE_WEAKNESS, SKIN_RASH, NECK_STIFFNESS, SORE_THROAT, COUGH, COUGH_WITH_SPUTUM, COUGH_WITH_HEAMOPTYSIS, RUNNY_NOSE, DIFFICULTY_BREATHING, CHEST_PAIN, CONJUNCTIVITIS, EYE_PAIN_LIGHT_SENSITIVE, KOPLIKS_SPOTS, THROBOCYTOPENIA, OTITIS_MEDIA, HEARINGLOSS, DEHYDRATION, ANOREXIA_APPETITE_LOSS, REFUSAL_FEEDOR_DRINK, JOINT_PAIN, HICCUPS, BACKACHE, EYES_BLEEDING, JAUNDICE, DARK_URINE, STOMACH_BLEEDING, RAPID_BREATHING, SWOLLEN_GLANDS, UNEXPLAINED_BLEEDING, GUMS_BLEEDING, INJECTION_SITE_BLEEDING, NOSE_BLEEDING, BLOODY_BLACK_STOOL, RED_BLOOD_VOMIT, DIGESTED_BLOOD_VOMIT, COUGHING_BLOOD, BLEEDING_VAGINA, SKIN_BRUISING, BLOOD_URINE, OTHER_HEMORRHAGIC_SYMPTOMS, OTHER_HEMORRHAGIC_SYMPTOMS_TEXT, OTHER_NON_HEMORRHAGIC_SYMPTOMS, OTHER_NON_HEMORRHAGIC_SYMPTOMS_TEXT, LESIONS, LESIONS_THAT_ITCH, LESIONS_SAME_STATE, LESIONS_SAME_SIZE, LESIONS_DEEP_PROFOUND, LESIONS_FACE, LESIONS_LEGS, LESIONS_SOLES_FEET, LESIONS_PALMS_HANDS, LESIONS_THORAX, LESIONS_ARMS, LESIONS_GENITALS, LESIONS_ALL_OVER_BODY, LYMPHADENOPATHY, LYMPHADENOPATHY_AXILLARY, LYMPHADENOPATHY_CERVICAL, LYMPHADENOPATHY_INGUINAL, CHILLS_SWEATS, BEDRIDDEN, ORAL_ULCERS, PAINFUL_LYMPHADENITIS, BLACKENING_DEATH_OF_TISSUE, BUBOES_GROIN_ARMPIT_NECK, BULGING_FONTANELLE, PHARYNGEAL_ERYTHEMA, PHARYNGEAL_EXUDATE, OEDEMA_FACE_NECK, OEDEMA_LOWER_EXTREMITY, LOSS_SKIN_TURGOR, PALPABLE_LIVER, PALPABLE_SPLEEN, MALAISE, SUNKEN_EYES_FONTANELLE, SIDE_PAIN, FLUID_IN_LUNG_CAVITY, TREMOR, BILATERAL_CATARACTS, UNILATERAL_CATARACTS, CONGENITAL_GLAUCOMA, CONGENITAL_HEART_DISEASE, PIGMENTARY_RETINOPATHY, RADIOLUCENT_BONE_DISEASE, SPLENOMEGALY, MICROCEPHALY, MENINGOENCEPHALITIS, PURPURIC_RASH, DEVELOPMENTAL_DELAY, CONGENITAL_HEART_DISEASE_TYPE, CONGENITAL_HEART_DISEASE_DETAILS, JAUNDICE_WITHIN_24_HOURS_OF_BIRTH, PATIENT_ILL_LOCATION, HYDROPHOBIA, OPISTHOTONUS, ANXIETY_STATES, DELIRIUM, UPROARIOUSNESS, PARASTHESIA_AROUND_WOUND, EXCESS_SALIVATION, INSOMNIA, PARALYSIS, EXCITATION, DYSPHAGIA, AEROPHOBIA, HYPERACTIVITY, PARESIS, AGITATION, ASCENDING_FLACCID_PARALYSIS, ERRATIC_BEHAVIOUR, COMA, CONVULSION, FLUID_IN_LUNG_CAVITY_AUSCULTATION, FLUID_IN_LUNG_CAVITY_XRAY, ABNORMAL_LUNG_XRAY_FINDINGS, CONJUNCTIVAL_INJECTION, ACUTE_RESPIRATORY_DISTRESS_SYNDROME, PNEUMONIA_CLINICAL_OR_RADIOLOGIC, LOSS_OF_TASTE, LOSS_OF_SMELL, WHEEZING, SKIN_ULCERS, INABILITY_TO_WALK, IN_DRAWING_OF_CHEST_WALL, FEELING_ILL, SHIVERING, RESPIRATORY_DISEASE_VENTILATION, FAST_HEART_RATE, OXYGEN_SATURATION_LOWER_94, FEVERISHFEELING, WEAKNESS, FATIGUE, COUGH_WITHOUT_SPUTUM, BREATHLESSNESS, CHEST_PRESSURE, BLUE_LIPS, BLOOD_CIRCULATION_PROBLEMS, PALPITATIONS, DIZZINESS_STANDING_UP, HIGH_OR_LOW_BLOOD_PRESSURE, URINARY_RETENTION, FEVER);
addField(SYMPTOMS_COMMENTS, TextField.class).setDescription(I18nProperties.getPrefixDescription(I18N_PREFIX, SYMPTOMS_COMMENTS, "") + "\n" + I18nProperties.getDescription(Descriptions.descGdpr));
addField(LESIONS_ONSET_DATE, DateField.class);
// complications
addFields(ALTERED_CONSCIOUSNESS, CONFUSED_DISORIENTED, OTHER_COMPLICATIONS, OTHER_COMPLICATIONS_TEXT, HEMORRHAGIC_SYNDROME, HYPERGLYCEMIA, HYPOGLYCEMIA, MENINGEAL_SIGNS, SEIZURES, SEPSIS, SHOCK);
monkeypoxImageFieldIds = Arrays.asList(LESIONS_RESEMBLE_IMG1, LESIONS_RESEMBLE_IMG2, LESIONS_RESEMBLE_IMG3, LESIONS_RESEMBLE_IMG4);
for (String propertyId : monkeypoxImageFieldIds) {
@SuppressWarnings("rawtypes") Field monkeypoxImageField = addField(propertyId);
CssStyles.style(monkeypoxImageField, VSPACE_NONE);
}
// Set initial visibilities
initializeVisibilitiesAndAllowedVisibilities();
initializeAccessAndAllowedAccesses();
if (symptomsContext != SymptomsContext.CLINICAL_VISIT) {
setVisible(false, BLOOD_PRESSURE_SYSTOLIC, BLOOD_PRESSURE_DIASTOLIC, HEART_RATE, RESPIRATORY_RATE, WEIGHT, HEIGHT, MID_UPPER_ARM_CIRCUMFERENCE, GLASGOW_COMA_SCALE);
} else {
setVisible(false, ONSET_SYMPTOM, ONSET_DATE);
}
// Initialize lists
conditionalBleedingSymptomFieldIds = Arrays.asList(GUMS_BLEEDING, INJECTION_SITE_BLEEDING, NOSE_BLEEDING, BLOODY_BLACK_STOOL, RED_BLOOD_VOMIT, DIGESTED_BLOOD_VOMIT, EYES_BLEEDING, COUGHING_BLOOD, BLEEDING_VAGINA, SKIN_BRUISING, STOMACH_BLEEDING, BLOOD_URINE, OTHER_HEMORRHAGIC_SYMPTOMS);
lesionsFieldIds = Arrays.asList(LESIONS_SAME_STATE, LESIONS_SAME_SIZE, LESIONS_DEEP_PROFOUND, LESIONS_THAT_ITCH);
lesionsLocationFieldIds = Arrays.asList(LESIONS_FACE, LESIONS_LEGS, LESIONS_SOLES_FEET, LESIONS_PALMS_HANDS, LESIONS_THORAX, LESIONS_ARMS, LESIONS_GENITALS, LESIONS_ALL_OVER_BODY);
unconditionalSymptomFieldIds = Arrays.asList(FEVER, ABNORMAL_LUNG_XRAY_FINDINGS, CONJUNCTIVAL_INJECTION, ACUTE_RESPIRATORY_DISTRESS_SYNDROME, PNEUMONIA_CLINICAL_OR_RADIOLOGIC, VOMITING, DIARRHEA, BLOOD_IN_STOOL, NAUSEA, ABDOMINAL_PAIN, HEADACHE, MUSCLE_PAIN, FATIGUE_WEAKNESS, SKIN_RASH, NECK_STIFFNESS, SORE_THROAT, COUGH, COUGH_WITH_SPUTUM, COUGH_WITH_HEAMOPTYSIS, RUNNY_NOSE, DIFFICULTY_BREATHING, CHEST_PAIN, CONJUNCTIVITIS, EYE_PAIN_LIGHT_SENSITIVE, KOPLIKS_SPOTS, THROBOCYTOPENIA, OTITIS_MEDIA, HEARINGLOSS, DEHYDRATION, ANOREXIA_APPETITE_LOSS, REFUSAL_FEEDOR_DRINK, JOINT_PAIN, HICCUPS, BACKACHE, JAUNDICE, DARK_URINE, RAPID_BREATHING, SWOLLEN_GLANDS, UNEXPLAINED_BLEEDING, OTHER_NON_HEMORRHAGIC_SYMPTOMS, LESIONS, LYMPHADENOPATHY, LYMPHADENOPATHY_AXILLARY, LYMPHADENOPATHY_CERVICAL, LYMPHADENOPATHY_INGUINAL, CHILLS_SWEATS, BEDRIDDEN, ORAL_ULCERS, PAINFUL_LYMPHADENITIS, BLACKENING_DEATH_OF_TISSUE, BUBOES_GROIN_ARMPIT_NECK, BULGING_FONTANELLE, PHARYNGEAL_ERYTHEMA, PHARYNGEAL_EXUDATE, OEDEMA_FACE_NECK, OEDEMA_LOWER_EXTREMITY, LOSS_SKIN_TURGOR, PALPABLE_LIVER, PALPABLE_SPLEEN, MALAISE, SUNKEN_EYES_FONTANELLE, SIDE_PAIN, FLUID_IN_LUNG_CAVITY, FLUID_IN_LUNG_CAVITY_AUSCULTATION, FLUID_IN_LUNG_CAVITY_XRAY, TREMOR, BILATERAL_CATARACTS, UNILATERAL_CATARACTS, CONGENITAL_GLAUCOMA, CONGENITAL_HEART_DISEASE, RADIOLUCENT_BONE_DISEASE, SPLENOMEGALY, MICROCEPHALY, MENINGOENCEPHALITIS, DEVELOPMENTAL_DELAY, PURPURIC_RASH, PIGMENTARY_RETINOPATHY, CONVULSION, AEROPHOBIA, AGITATION, ANXIETY_STATES, ASCENDING_FLACCID_PARALYSIS, COMA, DELIRIUM, DYSPHAGIA, ERRATIC_BEHAVIOUR, EXCESS_SALIVATION, EXCITATION, HYDROPHOBIA, HYPERACTIVITY, INSOMNIA, OPISTHOTONUS, PARALYSIS, PARASTHESIA_AROUND_WOUND, PARESIS, UPROARIOUSNESS, LOSS_OF_TASTE, LOSS_OF_SMELL, WHEEZING, SKIN_ULCERS, INABILITY_TO_WALK, IN_DRAWING_OF_CHEST_WALL, OTHER_COMPLICATIONS, FEELING_ILL, SHIVERING, RESPIRATORY_DISEASE_VENTILATION, FAST_HEART_RATE, OXYGEN_SATURATION_LOWER_94, FEVERISHFEELING, WEAKNESS, FATIGUE, COUGH_WITHOUT_SPUTUM, BREATHLESSNESS, CHEST_PRESSURE, BLUE_LIPS, BLOOD_CIRCULATION_PROBLEMS, PALPITATIONS, DIZZINESS_STANDING_UP, HIGH_OR_LOW_BLOOD_PRESSURE, URINARY_RETENTION, // complications
ALTERED_CONSCIOUSNESS, CONFUSED_DISORIENTED, HEMORRHAGIC_SYNDROME, HYPERGLYCEMIA, HYPOGLYCEMIA, MENINGEAL_SIGNS, SEIZURES, SEPSIS, SHOCK);
// Set visibilities
NullableOptionGroup feverField = (NullableOptionGroup) getFieldGroup().getField(FEVER);
feverField.setImmediate(true);
FieldHelper.setVisibleWhen(getFieldGroup(), conditionalBleedingSymptomFieldIds, UNEXPLAINED_BLEEDING, Arrays.asList(SymptomState.YES), true);
FieldHelper.setVisibleWhen(getFieldGroup(), OTHER_HEMORRHAGIC_SYMPTOMS_TEXT, OTHER_HEMORRHAGIC_SYMPTOMS, Arrays.asList(SymptomState.YES), true);
FieldHelper.setVisibleWhen(getFieldGroup(), OTHER_NON_HEMORRHAGIC_SYMPTOMS_TEXT, OTHER_NON_HEMORRHAGIC_SYMPTOMS, Arrays.asList(SymptomState.YES), true);
FieldHelper.setVisibleWhen(getFieldGroup(), OTHER_COMPLICATIONS_TEXT, OTHER_COMPLICATIONS, Arrays.asList(SymptomState.YES), true);
FieldHelper.setVisibleWhen(getFieldGroup(), lesionsFieldIds, LESIONS, Arrays.asList(SymptomState.YES), true);
FieldHelper.setVisibleWhen(getFieldGroup(), lesionsLocationFieldIds, LESIONS, Arrays.asList(SymptomState.YES), true);
FieldHelper.setVisibleWhen(getFieldGroup(), LESIONS_ONSET_DATE, LESIONS, Arrays.asList(SymptomState.YES), true);
FieldHelper.setVisibleWhen(getFieldGroup(), CONGENITAL_HEART_DISEASE_TYPE, CONGENITAL_HEART_DISEASE, Arrays.asList(SymptomState.YES), true);
FieldHelper.setVisibleWhen(getFieldGroup(), CONGENITAL_HEART_DISEASE_DETAILS, CONGENITAL_HEART_DISEASE_TYPE, Arrays.asList(CongenitalHeartDiseaseType.OTHER), true);
if (isVisibleAllowed(getFieldGroup().getField(JAUNDICE_WITHIN_24_HOURS_OF_BIRTH))) {
FieldHelper.setVisibleWhen(getFieldGroup(), JAUNDICE_WITHIN_24_HOURS_OF_BIRTH, JAUNDICE, Arrays.asList(SymptomState.YES), true);
}
FieldHelper.addSoftRequiredStyle(getField(LESIONS_ONSET_DATE));
boolean isInfant = person != null && person.getApproximateAge() != null && ((person.getApproximateAge() <= 12 && person.getApproximateAgeType() == ApproximateAgeType.MONTHS) || person.getApproximateAge() <= 1);
if (!isInfant) {
getFieldGroup().getField(BULGING_FONTANELLE).setVisible(false);
}
// Handle visibility of lesions locations caption
Label lesionsLocationsCaption = new Label(I18nProperties.getCaption(Captions.symptomsLesionsLocations));
CssStyles.style(lesionsLocationsCaption, VSPACE_3);
getContent().addComponent(lesionsLocationsCaption, LESIONS_LOCATIONS_LOC);
getContent().getComponent(LESIONS_LOCATIONS_LOC).setVisible(FieldHelper.getNullableSourceFieldValue(getFieldGroup().getField(LESIONS)) == SymptomState.YES);
getFieldGroup().getField(LESIONS).addValueChangeListener(e -> {
getContent().getComponent(LESIONS_LOCATIONS_LOC).setVisible(FieldHelper.getNullableSourceFieldValue((Field) e.getProperty()) == SymptomState.YES);
});
// Symptoms hint text
Label symptomsHint = new Label(I18nProperties.getString(symptomsContext == SymptomsContext.CASE ? Strings.messageSymptomsHint : Strings.messageSymptomsVisitHint), ContentMode.HTML);
symptomsHint.setWidth(100, Unit.PERCENTAGE);
getContent().addComponent(symptomsHint, SYMPTOMS_HINT_LOC);
if (disease == Disease.MONKEYPOX) {
setUpMonkeypoxVisibilities();
}
if (symptomsContext != SymptomsContext.CASE) {
getFieldGroup().getField(PATIENT_ILL_LOCATION).setVisible(false);
}
symptomGroupMap.forEach((location, strings) -> {
final Component groupLabel = getContent().getComponent(location);
final Optional<String> groupHasVisibleSymptom = strings.stream().filter(s -> getFieldGroup().getField(s).isVisible()).findAny();
if (!groupHasVisibleSymptom.isPresent()) {
groupLabel.setVisible(false);
}
});
if (isEditableAllowed(OTHER_HEMORRHAGIC_SYMPTOMS_TEXT)) {
FieldHelper.setRequiredWhen(getFieldGroup(), getFieldGroup().getField(OTHER_HEMORRHAGIC_SYMPTOMS), Arrays.asList(OTHER_HEMORRHAGIC_SYMPTOMS_TEXT), Arrays.asList(SymptomState.YES), disease);
}
if (isEditableAllowed(OTHER_NON_HEMORRHAGIC_SYMPTOMS_TEXT)) {
FieldHelper.setRequiredWhen(getFieldGroup(), getFieldGroup().getField(OTHER_NON_HEMORRHAGIC_SYMPTOMS), Arrays.asList(OTHER_NON_HEMORRHAGIC_SYMPTOMS_TEXT), Arrays.asList(SymptomState.YES), disease);
}
if (isEditableAllowed(OTHER_COMPLICATIONS_TEXT)) {
FieldHelper.setRequiredWhen(getFieldGroup(), getFieldGroup().getField(OTHER_COMPLICATIONS), Arrays.asList(OTHER_COMPLICATIONS_TEXT), Arrays.asList(SymptomState.YES), disease);
}
FieldHelper.setRequiredWhen(getFieldGroup(), getFieldGroup().getField(LESIONS), lesionsFieldIds, Arrays.asList(SymptomState.YES), disease);
FieldHelper.setRequiredWhen(getFieldGroup(), getFieldGroup().getField(LESIONS), monkeypoxImageFieldIds, Arrays.asList(SymptomState.YES), disease);
addListenerForOnsetFields(onsetSymptom, onsetDateField);
Button clearAllButton = ButtonHelper.createButton(Captions.actionClearAll, event -> {
for (Object symptomId : unconditionalSymptomFieldIds) {
getFieldGroup().getField(symptomId).setValue(null);
}
for (Object symptomId : conditionalBleedingSymptomFieldIds) {
getFieldGroup().getField(symptomId).setValue(null);
}
for (Object symptomId : lesionsFieldIds) {
getFieldGroup().getField(symptomId).setValue(null);
}
for (Object symptomId : lesionsLocationFieldIds) {
getFieldGroup().getField(symptomId).setValue(null);
}
for (Object symptomId : monkeypoxImageFieldIds) {
getFieldGroup().getField(symptomId).setValue(null);
}
}, ValoTheme.BUTTON_LINK);
Button setEmptyToNoButton = createButtonSetClearedToSymptomState(Captions.symptomsSetClearedToNo, SymptomState.NO);
Button setEmptyToUnknownButton = createButtonSetClearedToSymptomState(Captions.symptomsSetClearedToUnknown, SymptomState.UNKNOWN);
// Complications heading - not displayed for Rubella (dirty, should be made generic)
Label complicationsHeading = new Label(I18nProperties.getString(Strings.headingComplications));
CssStyles.style(complicationsHeading, CssStyles.H3);
if (disease != Disease.CONGENITAL_RUBELLA && !isConfiguredServer("de")) {
getContent().addComponent(complicationsHeading, COMPLICATIONS_HEADING);
}
HorizontalLayout buttonsLayout = new HorizontalLayout();
buttonsLayout.addComponent(clearAllButton);
buttonsLayout.addComponent(setEmptyToNoButton);
buttonsLayout.addComponent(setEmptyToUnknownButton);
buttonsLayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
buttonsLayout.setMargin(new MarginInfo(true, false, true, true));
getContent().addComponent(buttonsLayout, BUTTONS_LOC);
if (feverField.isVisible()) {
temperature.addValueChangeListener(e -> {
toggleFeverComponentError(feverField, temperature);
});
feverField.addValueChangeListener(e -> {
toggleFeverComponentError(feverField, temperature);
});
}
}
use of de.symeda.sormas.ui.utils.CssStyles.VSPACE_3 in project SORMAS-Project by hzi-braunschweig.
the class TravelEntryDataForm method addFields.
@Override
protected void addFields() {
Label travelEntryDataHeadingLabel = new Label(I18nProperties.getString(Strings.headingTravelEntryData));
travelEntryDataHeadingLabel.addStyleName(H3);
getContent().addComponent(travelEntryDataHeadingLabel, TRAVEL_ENTRY_HEADING_LOC);
addField(TravelEntryDto.REPORT_DATE, DateField.class);
addFields(TravelEntryDto.UUID, TravelEntryDto.REPORTING_USER);
TextField externalIdField = addField(TravelEntryDto.EXTERNAL_ID, TextField.class);
style(externalIdField, ERROR_COLOR_PRIMARY);
ComboBox diseaseField = addDiseaseField(TravelEntryDto.DISEASE, false);
ComboBox diseaseVariantField = addField(TravelEntryDto.DISEASE_VARIANT, ComboBox.class);
diseaseVariantField.setNullSelectionAllowed(true);
diseaseVariantField.setVisible(false);
addField(TravelEntryDto.DISEASE_DETAILS, TextField.class);
TextField diseaseVariantDetailsField = addField(TravelEntryDto.DISEASE_VARIANT_DETAILS, TextField.class);
diseaseVariantDetailsField.setVisible(false);
addField(TravelEntryDto.RECOVERED).addStyleNames(CssStyles.FORCE_CAPTION_CHECKBOX);
addField(TravelEntryDto.VACCINATED).addStyleNames(CssStyles.FORCE_CAPTION_CHECKBOX);
addField(TravelEntryDto.TESTED_NEGATIVE).addStyleNames(CssStyles.FORCE_CAPTION_CHECKBOX);
addField(TravelEntryDto.DATE_OF_ARRIVAL).setRequired(true);
Label jurisdictionHeadingLabel = new Label(I18nProperties.getString(Strings.headingResponsibleJurisdiction));
jurisdictionHeadingLabel.addStyleName(H3);
getContent().addComponent(jurisdictionHeadingLabel, RESPONSIBLE_JURISDICTION_HEADING_LOC);
responsibleRegion = addInfrastructureField(TravelEntryDto.RESPONSIBLE_REGION);
responsibleRegion.setRequired(true);
responsibleDistrict = addInfrastructureField(TravelEntryDto.RESPONSIBLE_DISTRICT);
responsibleDistrict.setRequired(true);
responsibleCommunity = addInfrastructureField(TravelEntryDto.RESPONSIBLE_COMMUNITY);
responsibleCommunity.setNullSelectionAllowed(true);
responsibleCommunity.addStyleName(SOFT_REQUIRED);
InfrastructureFieldsHelper.initInfrastructureFields(responsibleRegion, responsibleDistrict, responsibleCommunity);
differentPointOfEntryJurisdiction = addCustomField(DIFFERENT_POINT_OF_ENTRY_JURISDICTION, Boolean.class, CheckBox.class);
differentPointOfEntryJurisdiction.addStyleName(VSPACE_3);
Label pointOfEntryHeadingLabel = new Label(I18nProperties.getCaption(Captions.travelEntryPointOfEntry));
pointOfEntryHeadingLabel.addStyleName(H3);
getContent().addComponent(pointOfEntryHeadingLabel, POINT_OF_ENTRY_HEADING_LOC);
ComboBox regionCombo = addInfrastructureField(TravelEntryDto.REGION);
districtCombo = addInfrastructureField(TravelEntryDto.DISTRICT);
differentPointOfEntryJurisdiction.addValueChangeListener(e -> {
if (!ignoreDifferentPointOfEntryJurisdiction) {
if (differentPointOfEntryJurisdiction.booleanValue()) {
districtCombo.setValue(null);
}
cbPointOfEntry.setValue(null);
updatePointsOfEntry();
}
});
cbPointOfEntry = addInfrastructureField(TravelEntryDto.POINT_OF_ENTRY);
cbPointOfEntry.setImmediate(true);
TextField tfPointOfEntryDetails = addField(TravelEntryDto.POINT_OF_ENTRY_DETAILS, TextField.class);
tfPointOfEntryDetails.setVisible(false);
regionCombo.addItems(FacadeProvider.getRegionFacade().getAllActiveByServerCountry());
regionCombo.addValueChangeListener(e -> {
RegionReferenceDto regionDto = (RegionReferenceDto) e.getProperty().getValue();
FieldHelper.updateItems(districtCombo, regionDto != null ? FacadeProvider.getDistrictFacade().getAllActiveByRegion(regionDto.getUuid()) : null);
});
districtCombo.addValueChangeListener(e -> {
if (differentPointOfEntryJurisdiction.booleanValue()) {
updatePointsOfEntry();
}
});
quarantine = addField(TravelEntryDto.QUARANTINE);
quarantine.addValueChangeListener(e -> onQuarantineValueChange());
quarantineFrom = addField(TravelEntryDto.QUARANTINE_FROM, DateField.class);
quarantineTo = addDateField(TravelEntryDto.QUARANTINE_TO, DateField.class, -1);
quarantineFrom.addValidator(new DateComparisonValidator(quarantineFrom, quarantineTo, true, false, I18nProperties.getValidationError(Validations.beforeDate, quarantineFrom.getCaption(), quarantineTo.getCaption())));
quarantineTo.addValidator(new DateComparisonValidator(quarantineTo, quarantineFrom, false, false, I18nProperties.getValidationError(Validations.afterDate, quarantineTo.getCaption(), quarantineFrom.getCaption())));
quarantineOrderedVerbally = addField(TravelEntryDto.QUARANTINE_ORDERED_VERBALLY, CheckBox.class);
CssStyles.style(quarantineOrderedVerbally, CssStyles.FORCE_CAPTION);
addField(TravelEntryDto.QUARANTINE_ORDERED_VERBALLY_DATE, DateField.class);
quarantineOrderedOfficialDocument = addField(TravelEntryDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT, CheckBox.class);
CssStyles.style(quarantineOrderedOfficialDocument, CssStyles.FORCE_CAPTION);
addField(TravelEntryDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT_DATE, DateField.class);
CheckBox quarantineOfficialOrderSent = addField(TravelEntryDto.QUARANTINE_OFFICIAL_ORDER_SENT, CheckBox.class);
CssStyles.style(quarantineOfficialOrderSent, FORCE_CAPTION);
addField(TravelEntryDto.QUARANTINE_OFFICIAL_ORDER_SENT_DATE, DateField.class);
FieldHelper.setVisibleWhen(getFieldGroup(), TravelEntryDto.QUARANTINE_OFFICIAL_ORDER_SENT, TravelEntryDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT, Collections.singletonList(Boolean.TRUE), true);
quarantineExtended = addField(TravelEntryDto.QUARANTINE_EXTENDED, CheckBox.class);
quarantineExtended.setEnabled(false);
quarantineExtended.setVisible(false);
CssStyles.style(quarantineExtended, CssStyles.FORCE_CAPTION);
quarantineReduced = addField(TravelEntryDto.QUARANTINE_REDUCED, CheckBox.class);
quarantineReduced.setEnabled(false);
quarantineReduced.setVisible(false);
CssStyles.style(quarantineReduced, CssStyles.FORCE_CAPTION);
TextField quarantineHelpNeeded = addField(TravelEntryDto.QUARANTINE_HELP_NEEDED, TextField.class);
quarantineHelpNeeded.setInputPrompt(I18nProperties.getString(Strings.pleaseSpecify));
TextField quarantineTypeDetails = addField(TravelEntryDto.QUARANTINE_TYPE_DETAILS, TextField.class);
quarantineTypeDetails.setInputPrompt(I18nProperties.getString(Strings.pleaseSpecify));
addField(TravelEntryDto.QUARANTINE_HOME_POSSIBLE, NullableOptionGroup.class);
addField(TravelEntryDto.QUARANTINE_HOME_POSSIBLE_COMMENT, TextField.class);
addField(TravelEntryDto.QUARANTINE_HOME_SUPPLY_ENSURED, NullableOptionGroup.class);
addField(TravelEntryDto.QUARANTINE_HOME_SUPPLY_ENSURED_COMMENT, TextField.class);
addField(TravelEntryDto.DELETION_REASON);
addField(TravelEntryDto.OTHER_DELETION_REASON, TextArea.class).setRows(3);
setVisible(false, TravelEntryDto.DELETION_REASON, TravelEntryDto.OTHER_DELETION_REASON);
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(TravelEntryDto.QUARANTINE_FROM, TravelEntryDto.QUARANTINE_TO, TravelEntryDto.QUARANTINE_HELP_NEEDED), TravelEntryDto.QUARANTINE, QuarantineType.QUARANTINE_IN_EFFECT, true);
if (isConfiguredServer(CountryHelper.COUNTRY_CODE_GERMANY) || isConfiguredServer(CountryHelper.COUNTRY_CODE_SWITZERLAND)) {
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(TravelEntryDto.QUARANTINE_ORDERED_VERBALLY, TravelEntryDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT), TravelEntryDto.QUARANTINE, QuarantineType.QUARANTINE_IN_EFFECT, true);
}
FieldHelper.setVisibleWhen(getFieldGroup(), TravelEntryDto.QUARANTINE_HOME_POSSIBLE_COMMENT, TravelEntryDto.QUARANTINE_HOME_POSSIBLE, Arrays.asList(YesNoUnknown.NO), true);
FieldHelper.setVisibleWhen(getFieldGroup(), TravelEntryDto.QUARANTINE_HOME_SUPPLY_ENSURED, TravelEntryDto.QUARANTINE_HOME_POSSIBLE, Arrays.asList(YesNoUnknown.YES), true);
FieldHelper.setVisibleWhen(getFieldGroup(), TravelEntryDto.QUARANTINE_HOME_SUPPLY_ENSURED_COMMENT, TravelEntryDto.QUARANTINE_HOME_SUPPLY_ENSURED, Arrays.asList(YesNoUnknown.NO), true);
FieldHelper.setVisibleWhen(getFieldGroup(), TravelEntryDto.QUARANTINE_TYPE_DETAILS, TravelEntryDto.QUARANTINE, Arrays.asList(QuarantineType.OTHER), true);
FieldHelper.setVisibleWhen(getFieldGroup(), TravelEntryDto.QUARANTINE_ORDERED_VERBALLY_DATE, TravelEntryDto.QUARANTINE_ORDERED_VERBALLY, Arrays.asList(Boolean.TRUE), true);
FieldHelper.setVisibleWhen(getFieldGroup(), TravelEntryDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT_DATE, TravelEntryDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT, Arrays.asList(Boolean.TRUE), true);
FieldHelper.setVisibleWhen(getFieldGroup(), TravelEntryDto.QUARANTINE_OFFICIAL_ORDER_SENT_DATE, TravelEntryDto.QUARANTINE_OFFICIAL_ORDER_SENT, Collections.singletonList(Boolean.TRUE), true);
// Set initial visibilities & accesses
initializeVisibilitiesAndAllowedVisibilities();
setRequired(true, TravelEntryDto.REPORT_DATE, TravelEntryDto.POINT_OF_ENTRY, TravelEntryDto.DISEASE);
FieldHelper.setVisibleWhen(getFieldGroup(), Collections.singletonList(TravelEntryDto.DISEASE_DETAILS), TravelEntryDto.DISEASE, Collections.singletonList(Disease.OTHER), true);
FieldHelper.setRequiredWhen(getFieldGroup(), TravelEntryDto.DISEASE, Collections.singletonList(TravelEntryDto.DISEASE_DETAILS), Collections.singletonList(Disease.OTHER));
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(TravelEntryDto.RECOVERED, TravelEntryDto.VACCINATED, TravelEntryDto.TESTED_NEGATIVE), TravelEntryDto.DISEASE, Disease.DISEASE_LIST, true);
cbPointOfEntry.addValueChangeListener(e -> updatePointOfEntryFields(cbPointOfEntry, tfPointOfEntryDetails));
FieldHelper.setVisibleWhen(differentPointOfEntryJurisdiction, Arrays.asList(regionCombo, districtCombo), Collections.singletonList(Boolean.TRUE), true);
FieldHelper.setRequiredWhen(differentPointOfEntryJurisdiction, Arrays.asList(regionCombo, districtCombo), Collections.singletonList(Boolean.TRUE), false, null);
setReadOnly(true, TravelEntryDto.UUID, TravelEntryDto.REPORTING_USER);
responsibleDistrict.addValueChangeListener(e -> {
if (!differentPointOfEntryJurisdiction.booleanValue()) {
updatePointsOfEntry();
}
});
diseaseField.addValueChangeListener((ValueChangeListener) valueChangeEvent -> {
Disease disease = (Disease) valueChangeEvent.getProperty().getValue();
List<DiseaseVariant> diseaseVariants = FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.DISEASE_VARIANT, disease);
FieldHelper.updateItems(diseaseVariantField, diseaseVariants);
diseaseVariantField.setVisible(disease != null && isVisibleAllowed(TravelEntryDto.DISEASE_VARIANT) && CollectionUtils.isNotEmpty(diseaseVariants));
});
diseaseVariantField.addValueChangeListener(e -> {
DiseaseVariant diseaseVariant = (DiseaseVariant) e.getProperty().getValue();
diseaseVariantDetailsField.setVisible(diseaseVariant != null && diseaseVariant.matchPropertyValue(DiseaseVariant.HAS_DETAILS, true));
});
}
use of de.symeda.sormas.ui.utils.CssStyles.VSPACE_3 in project SORMAS-Project by hzi-braunschweig.
the class TravelEntryCreateForm method addFields.
@Override
protected void addFields() {
addField(TravelEntryDto.REPORT_DATE, DateField.class);
TextField externalIdField = addField(TravelEntryDto.EXTERNAL_ID, TextField.class);
style(externalIdField, ERROR_COLOR_PRIMARY);
ComboBox diseaseField = addDiseaseField(TravelEntryDto.DISEASE, false, true);
ComboBox diseaseVariantField = addField(TravelEntryDto.DISEASE_VARIANT, ComboBox.class);
diseaseVariantField.setNullSelectionAllowed(true);
diseaseVariantField.setVisible(false);
addField(TravelEntryDto.DISEASE_DETAILS, TextField.class);
TextField diseaseVariantDetailsField = addField(TravelEntryDto.DISEASE_VARIANT_DETAILS, TextField.class);
diseaseVariantDetailsField.setVisible(false);
addField(TravelEntryDto.DATE_OF_ARRIVAL).setRequired(true);
Label jurisdictionHeadingLabel = new Label(I18nProperties.getString(Strings.headingResponsibleJurisdiction));
jurisdictionHeadingLabel.addStyleName(H3);
getContent().addComponent(jurisdictionHeadingLabel, RESPONSIBLE_JURISDICTION_HEADING_LOC);
responsibleRegion = addInfrastructureField(TravelEntryDto.RESPONSIBLE_REGION);
responsibleRegion.setRequired(true);
responsibleDistrict = addInfrastructureField(TravelEntryDto.RESPONSIBLE_DISTRICT);
responsibleDistrict.setRequired(true);
responsibleCommunity = addInfrastructureField(TravelEntryDto.RESPONSIBLE_COMMUNITY);
responsibleCommunity.setNullSelectionAllowed(true);
responsibleCommunity.addStyleName(SOFT_REQUIRED);
InfrastructureFieldsHelper.initInfrastructureFields(responsibleRegion, responsibleDistrict, responsibleCommunity);
CheckBox differentPointOfEntryJurisdiction = addCustomField(DIFFERENT_POINT_OF_ENTRY_JURISDICTION, Boolean.class, CheckBox.class);
differentPointOfEntryJurisdiction.addStyleName(VSPACE_3);
Label placeOfStayHeadingLabel = new Label(I18nProperties.getCaption(Captions.travelEntryPointOfEntry));
placeOfStayHeadingLabel.addStyleName(H3);
getContent().addComponent(placeOfStayHeadingLabel, POINT_OF_ENTRY_HEADING_LOC);
ComboBox regionCombo = addInfrastructureField(TravelEntryDto.REGION);
districtCombo = addInfrastructureField(TravelEntryDto.DISTRICT);
cbPointOfEntry = addInfrastructureField(TravelEntryDto.POINT_OF_ENTRY);
cbPointOfEntry.setImmediate(true);
TextField tfPointOfEntryDetails = addField(TravelEntryDto.POINT_OF_ENTRY_DETAILS, TextField.class);
tfPointOfEntryDetails.setVisible(false);
personCreateForm = new PersonCreateForm(false, true, false);
personCreateForm.setWidth(100, Unit.PERCENTAGE);
personCreateForm.setValue(new PersonDto());
getContent().addComponent(personCreateForm, TravelEntryDto.PERSON);
regionCombo.addItems(FacadeProvider.getRegionFacade().getAllActiveByServerCountry());
regionCombo.addValueChangeListener(e -> {
RegionReferenceDto regionDto = (RegionReferenceDto) e.getProperty().getValue();
FieldHelper.updateItems(districtCombo, regionDto != null ? FacadeProvider.getDistrictFacade().getAllActiveByRegion(regionDto.getUuid()) : null);
});
districtCombo.addValueChangeListener(e -> {
if (differentPointOfEntryJurisdiction.getValue()) {
DistrictReferenceDto districtDto = (DistrictReferenceDto) e.getProperty().getValue();
getPointsOfEntryForDistrict(districtDto);
}
});
differentPointOfEntryJurisdiction.addValueChangeListener(v -> {
if (differentPointOfEntryJurisdiction.getValue()) {
cbPointOfEntry.removeAllItems();
} else {
getPointsOfEntryForDistrict((DistrictReferenceDto) responsibleDistrict.getValue());
}
});
// Set initial visibilities & accesses
initializeVisibilitiesAndAllowedVisibilities();
setRequired(true, TravelEntryDto.REPORT_DATE, TravelEntryDto.POINT_OF_ENTRY, TravelEntryDto.DISEASE);
FieldHelper.setVisibleWhen(getFieldGroup(), Collections.singletonList(TravelEntryDto.DISEASE_DETAILS), TravelEntryDto.DISEASE, Collections.singletonList(Disease.OTHER), true);
FieldHelper.setRequiredWhen(getFieldGroup(), TravelEntryDto.DISEASE, Collections.singletonList(TravelEntryDto.DISEASE_DETAILS), Collections.singletonList(Disease.OTHER));
cbPointOfEntry.addValueChangeListener(e -> updatePointOfEntryFields(cbPointOfEntry, tfPointOfEntryDetails));
FieldHelper.setVisibleWhen(differentPointOfEntryJurisdiction, Arrays.asList(regionCombo, districtCombo), Collections.singletonList(Boolean.TRUE), true);
FieldHelper.setRequiredWhen(differentPointOfEntryJurisdiction, Arrays.asList(regionCombo, districtCombo), Collections.singletonList(Boolean.TRUE), false, null);
responsibleDistrict.addValueChangeListener(e -> {
DistrictReferenceDto districtDto = (DistrictReferenceDto) e.getProperty().getValue();
getPointsOfEntryForDistrict(districtDto);
});
diseaseField.addValueChangeListener((ValueChangeListener) valueChangeEvent -> {
Disease disease = (Disease) valueChangeEvent.getProperty().getValue();
List<DiseaseVariant> diseaseVariants = FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.DISEASE_VARIANT, disease);
FieldHelper.updateItems(diseaseVariantField, diseaseVariants);
diseaseVariantField.setVisible(disease != null && isVisibleAllowed(TravelEntryDto.DISEASE_VARIANT) && CollectionUtils.isNotEmpty(diseaseVariants));
personCreateForm.updatePresentConditionEnum(disease);
});
diseaseVariantField.addValueChangeListener(e -> {
DiseaseVariant diseaseVariant = (DiseaseVariant) e.getProperty().getValue();
diseaseVariantDetailsField.setVisible(diseaseVariant != null && diseaseVariant.matchPropertyValue(DiseaseVariant.HAS_DETAILS, true));
});
addValueChangeListener(e -> {
if (personDto != null) {
personCreateForm.setVisible(false);
personCreateForm.setReadOnly(false);
} else {
personCreateForm.enablePersonFields(true);
}
});
}
use of de.symeda.sormas.ui.utils.CssStyles.VSPACE_3 in project SORMAS-Project by hzi-braunschweig.
the class EventDataForm method addFields.
@Override
protected void addFields() {
if (isCreateForm == null) {
return;
}
Label eventDataHeadingLabel = new Label(I18nProperties.getString(Strings.headingEventData));
eventDataHeadingLabel.addStyleName(H3);
getContent().addComponent(eventDataHeadingLabel, EVENT_DATA_HEADING_LOC);
Label informationSourceHeadingLabel = new Label(I18nProperties.getString(Strings.headingInformationSource));
informationSourceHeadingLabel.addStyleName(H3);
getContent().addComponent(informationSourceHeadingLabel, INFORMATION_SOURCE_HEADING_LOC);
Label locationHeadingLabel = new Label(I18nProperties.getString(Strings.headingLocation));
locationHeadingLabel.addStyleName(H3);
getContent().addComponent(locationHeadingLabel, LOCATION_HEADING_LOC);
addField(EventDto.UUID, TextField.class);
ComboBox diseaseField = addDiseaseField(EventDto.DISEASE, false, isCreateForm);
addField(EventDto.DISEASE_DETAILS, TextField.class);
ComboBox diseaseVariantField = addField(EventDto.DISEASE_VARIANT, ComboBox.class);
diseaseVariantField.setNullSelectionAllowed(true);
addFields(EventDto.EXTERNAL_ID);
TextField diseaseVariantDetailsField = addField(EventDto.DISEASE_VARIANT_DETAILS, TextField.class);
diseaseVariantDetailsField.setVisible(false);
TextField externalTokenField = addField(EventDto.EXTERNAL_TOKEN);
Label externalTokenWarningLabel = new Label(I18nProperties.getString(Strings.messageEventExternalTokenWarning));
externalTokenWarningLabel.addStyleNames(VSPACE_3, LABEL_WHITE_SPACE_NORMAL);
getContent().addComponent(externalTokenWarningLabel, EXTERNAL_TOKEN_WARNING_LOC);
addField(EventDto.INTERNAL_TOKEN);
DateTimeField startDate = addField(EventDto.START_DATE, DateTimeField.class);
CheckBox multiDayCheckbox = addField(EventDto.MULTI_DAY_EVENT, CheckBox.class);
DateTimeField endDate = addField(EventDto.END_DATE, DateTimeField.class);
initEventDateValidation(startDate, endDate, multiDayCheckbox);
addField(EventDto.EVENT_STATUS, NullableOptionGroup.class);
addField(EventDto.RISK_LEVEL);
ComboBox specificRiskField = addField(EventDto.SPECIFIC_RISK, ComboBox.class);
specificRiskField.setNullSelectionAllowed(true);
addField(EventDto.EVENT_MANAGEMENT_STATUS, NullableOptionGroup.class);
addField(EventDto.EVENT_IDENTIFICATION_SOURCE, NullableOptionGroup.class);
addField(EventDto.EVENT_INVESTIGATION_STATUS, NullableOptionGroup.class);
addField(EventDto.EVENT_INVESTIGATION_START_DATE, DateField.class);
addField(EventDto.EVENT_INVESTIGATION_END_DATE, DateField.class);
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(EventDto.EVENT_INVESTIGATION_START_DATE, EventDto.EVENT_INVESTIGATION_END_DATE), EventDto.EVENT_INVESTIGATION_STATUS, Arrays.asList(EventInvestigationStatus.ONGOING, EventInvestigationStatus.DONE, EventInvestigationStatus.DISCARDED), true);
TextField title = addField(EventDto.EVENT_TITLE, TextField.class);
title.addStyleName(CssStyles.SOFT_REQUIRED);
TextArea descriptionField = addField(EventDto.EVENT_DESC, TextArea.class, new ResizableTextAreaWrapper<>());
descriptionField.setRows(2);
descriptionField.setDescription(I18nProperties.getPrefixDescription(EventDto.I18N_PREFIX, EventDto.EVENT_DESC, "") + "\n" + I18nProperties.getDescription(Descriptions.descGdpr));
addField(EventDto.DISEASE_TRANSMISSION_MODE, ComboBox.class);
addField(EventDto.NOSOCOMIAL, NullableOptionGroup.class);
addFields(EventDto.HUMAN_TRANSMISSION_MODE, EventDto.INFECTION_PATH_CERTAINTY);
addFields(EventDto.PARENTERAL_TRANSMISSION_MODE, EventDto.MEDICALLY_ASSOCIATED_TRANSMISSION_MODE);
final NullableOptionGroup epidemiologicalEvidence = addField(EventDto.EPIDEMIOLOGICAL_EVIDENCE, NullableOptionGroup.class);
final NullableOptionGroup laboratoryDiagnosticEvidence = addField(EventDto.LABORATORY_DIAGNOSTIC_EVIDENCE, NullableOptionGroup.class);
epidemiologicalEvidenceCheckBoxTree = new EpidemiologicalEvidenceCheckBoxTree(Arrays.stream(EpidemiologicalEvidenceDetail.values()).map(epidemiologicalEvidenceDetail -> epidemiologicalEvidenceDetailToCheckBoxElement(epidemiologicalEvidenceDetail)).collect(Collectors.toList()));
getContent().addComponent(epidemiologicalEvidenceCheckBoxTree, EventDto.EPIDEMIOLOGICAL_EVIDENCE_DETAILS);
epidemiologicalEvidenceCheckBoxTree.setVisible(false);
laboratoryDiagnosticEvidenceCheckBoxTree = new LaboratoryDiagnosticEvidenceCheckBoxTree(Arrays.stream(LaboratoryDiagnosticEvidenceDetail.values()).map(laboratoryDiagnosticEvidenceDetail -> laboratoryDiagnosticEvidenceDetailToCheckBoxElement(laboratoryDiagnosticEvidenceDetail)).collect(Collectors.toList()));
getContent().addComponent(laboratoryDiagnosticEvidenceCheckBoxTree, EventDto.LABORATORY_DIAGNOSTIC_EVIDENCE_DETAILS);
laboratoryDiagnosticEvidenceCheckBoxTree.setVisible(false);
DateField evolutionDateField = addField(EventDto.EVOLUTION_DATE, DateField.class);
TextField evolutionCommentField = addField(EventDto.EVOLUTION_COMMENT, TextField.class);
Field<?> statusField = getField(EventDto.EVENT_STATUS);
statusField.addValueChangeListener(e -> {
if (statusField.getValue() == null) {
return;
}
EventStatus eventStatus = (EventStatus) statusField.getValue();
// The status will be used to modify the caption of the field
// However we don't want to have somthing like "Dropped evolution date"
// So let's ignore the DROPPED status and use the Event entity caption instead
String statusCaption;
if (eventStatus == EventStatus.DROPPED) {
statusCaption = I18nProperties.getCaption(EVENT_ENTITY);
} else {
statusCaption = I18nProperties.getEnumCaption(eventStatus);
}
evolutionDateField.setCaption(String.format(I18nProperties.getCaption(EVOLUTION_DATE_WITH_STATUS), statusCaption));
evolutionCommentField.setCaption(String.format(I18nProperties.getCaption(EVOLUTION_COMMENT_WITH_STATUS), statusCaption));
});
FieldHelper.setVisibleWhenSourceNotNull(getFieldGroup(), Collections.singletonList(EventDto.EVOLUTION_COMMENT), EventDto.EVOLUTION_DATE, true);
ComboBox typeOfPlace = addField(EventDto.TYPE_OF_PLACE, ComboBox.class);
typeOfPlace.setNullSelectionAllowed(true);
addField(EventDto.TYPE_OF_PLACE_TEXT, TextField.class);
addField(EventDto.WORK_ENVIRONMENT);
ComboBox meansOfTransport = addField(EventDto.MEANS_OF_TRANSPORT);
TextField connectionNumber = addField(EventDto.CONNECTION_NUMBER);
DateField travelDate = addField(EventDto.TRAVEL_DATE);
FieldHelper.setVisibleWhen(getFieldGroup(), Collections.singletonList(EventDto.MEANS_OF_TRANSPORT), EventDto.TYPE_OF_PLACE, Collections.singletonList(TypeOfPlace.MEANS_OF_TRANSPORT), true);
TextField meansOfTransportDetails = addField(EventDto.MEANS_OF_TRANSPORT_DETAILS);
FieldHelper.setVisibleWhen(getFieldGroup(), Collections.singletonList(EventDto.MEANS_OF_TRANSPORT_DETAILS), EventDto.MEANS_OF_TRANSPORT, Collections.singletonList(MeansOfTransport.OTHER), true);
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(EventDto.CONNECTION_NUMBER, EventDto.TRAVEL_DATE), EventDto.TYPE_OF_PLACE, Collections.singletonList(TypeOfPlace.MEANS_OF_TRANSPORT), true);
getField(EventDto.MEANS_OF_TRANSPORT).addValueChangeListener(e -> {
if (e.getProperty().getValue() == MeansOfTransport.PLANE) {
getField(EventDto.CONNECTION_NUMBER).setCaption(I18nProperties.getCaption(Captions.exposureFlightNumber));
} else {
getField(EventDto.CONNECTION_NUMBER).setCaption(I18nProperties.getPrefixCaption(EventDto.I18N_PREFIX, EventDto.CONNECTION_NUMBER));
}
});
DateField reportDate = addField(EventDto.REPORT_DATE_TIME, DateField.class);
addField(EventDto.REPORTING_USER, ComboBox.class);
addField(EventDto.TRANSREGIONAL_OUTBREAK, NullableOptionGroup.class);
ComboBox srcType = addField(EventDto.SRC_TYPE);
TextField srcFirstName = addField(EventDto.SRC_FIRST_NAME, TextField.class);
TextField srcLastName = addField(EventDto.SRC_LAST_NAME, TextField.class);
TextField srcTelNo = addField(EventDto.SRC_TEL_NO, TextField.class);
addField(EventDto.SRC_EMAIL, TextField.class);
TextField srcMediaWebsite = addField(EventDto.SRC_MEDIA_WEBSITE, TextField.class);
TextField srcMediaName = addField(EventDto.SRC_MEDIA_NAME, TextField.class);
TextArea srcMediaDetails = addField(EventDto.SRC_MEDIA_DETAILS, TextArea.class);
srcMediaDetails.setRows(4);
ComboBox srcInstitutionalPartnerType = addField(EventDto.SRC_INSTITUTIONAL_PARTNER_TYPE);
FieldHelper.setVisibleWhen(getFieldGroup(), Collections.singletonList(EventDto.SRC_INSTITUTIONAL_PARTNER_TYPE), EventDto.SRC_TYPE, Collections.singletonList(EventSourceType.INSTITUTIONAL_PARTNER), true);
TextField srcInstitutionalPartnerTypeDetails = addField(EventDto.SRC_INSTITUTIONAL_PARTNER_TYPE_DETAILS);
FieldHelper.setVisibleWhen(getFieldGroup(), Collections.singletonList(EventDto.SRC_INSTITUTIONAL_PARTNER_TYPE_DETAILS), EventDto.SRC_INSTITUTIONAL_PARTNER_TYPE, Collections.singletonList(InstitutionalPartnerType.OTHER), true);
addField(EventDto.EVENT_LOCATION, new LocationEditForm(fieldVisibilityCheckers, createFieldAccessCheckers(isPseudonymized, false))).setCaption(null);
locationForm = (LocationEditForm) getFieldGroup().getField(EventDto.EVENT_LOCATION);
locationForm.setDistrictRequiredOnDefaultCountry(true);
ComboBox regionField = (ComboBox) locationForm.getFieldGroup().getField(LocationDto.REGION);
ComboBox districtField = (ComboBox) locationForm.getFieldGroup().getField(LocationDto.DISTRICT);
ComboBox responsibleUserField = addField(EventDto.RESPONSIBLE_USER, ComboBox.class);
responsibleUserField.setNullSelectionAllowed(true);
addField(EventDto.DELETION_REASON);
addField(EventDto.OTHER_DELETION_REASON, TextArea.class).setRows(3);
setVisible(false, EventDto.DELETION_REASON, EventDto.OTHER_DELETION_REASON);
if (isCreateForm) {
locationForm.hideValidationUntilNextCommit();
}
setReadOnly(true, EventDto.UUID, EventDto.REPORTING_USER);
initializeVisibilitiesAndAllowedVisibilities();
initializeAccessAndAllowedAccesses();
FieldHelper.setVisibleWhen(getFieldGroup(), EventDto.WORK_ENVIRONMENT, locationForm.getFacilityTypeGroup(), Collections.singletonList(FacilityTypeGroup.WORKING_PLACE), true);
FieldHelper.setVisibleWhen(getFieldGroup(), Collections.singletonList(EventDto.DISEASE_DETAILS), EventDto.DISEASE, Collections.singletonList(Disease.OTHER), true);
FieldHelper.setRequiredWhen(getFieldGroup(), EventDto.DISEASE, Collections.singletonList(EventDto.DISEASE_DETAILS), Collections.singletonList(Disease.OTHER));
// Customizable enum fields visibilities
diseaseVariantField.setVisible(false);
diseaseField.addValueChangeListener((ValueChangeListener) valueChangeEvent -> {
Disease disease = (Disease) valueChangeEvent.getProperty().getValue();
List<DiseaseVariant> diseaseVariants = FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.DISEASE_VARIANT, disease);
FieldHelper.updateItems(diseaseVariantField, diseaseVariants);
diseaseVariantField.setVisible(disease != null && CollectionUtils.isNotEmpty(diseaseVariants));
List<SpecificRisk> specificRiskValues = FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.SPECIFIC_EVENT_RISK, disease);
FieldHelper.updateItems(specificRiskField, specificRiskValues);
specificRiskField.setVisible(isVisibleAllowed(EventDto.SPECIFIC_RISK) && CollectionUtils.isNotEmpty(specificRiskValues));
});
diseaseVariantField.addValueChangeListener(e -> {
DiseaseVariant diseaseVariant = (DiseaseVariant) e.getProperty().getValue();
diseaseVariantDetailsField.setVisible(diseaseVariant != null && diseaseVariant.matchPropertyValue(DiseaseVariant.HAS_DETAILS, true));
});
setRequired(true, EventDto.EVENT_STATUS, EventDto.UUID, EventDto.EVENT_TITLE, EventDto.REPORT_DATE_TIME, EventDto.REPORTING_USER);
reportDate.addValidator(new DateComparisonValidator(reportDate, startDate, false, false, I18nProperties.getValidationError(Validations.afterDate, reportDate.getCaption(), startDate.getCaption())));
startDate.addValidator(new DateComparisonValidator(startDate, reportDate, true, false, I18nProperties.getValidationError(Validations.beforeDate, startDate.getCaption(), reportDate.getCaption())));
reportDate.addValueChangeListener(e -> startDate.setValidationVisible(!startDate.isValid()));
startDate.addValueChangeListener(e -> reportDate.setValidationVisible(!reportDate.isValid()));
FieldHelper.setVisibleWhen(getFieldGroup(), EventDto.END_DATE, EventDto.MULTI_DAY_EVENT, Collections.singletonList(true), true);
FieldHelper.setCaptionWhen(multiDayCheckbox, startDate, false, I18nProperties.getCaption(Captions.singleDayEventDate), I18nProperties.getCaption(Captions.Event_startDate));
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(EventDto.NOSOCOMIAL, EventDto.TRANSREGIONAL_OUTBREAK, EventDto.DISEASE_TRANSMISSION_MODE), EventDto.EVENT_STATUS, Collections.singletonList(EventStatus.CLUSTER), true);
if (isVisibleAllowed(EventDto.INFECTION_PATH_CERTAINTY)) {
FieldHelper.setVisibleWhen(getFieldGroup(), EventDto.INFECTION_PATH_CERTAINTY, EventDto.NOSOCOMIAL, Collections.singletonList(YesNoUnknown.YES), true);
}
if (isVisibleAllowed(EventDto.HUMAN_TRANSMISSION_MODE)) {
FieldHelper.setVisibleWhen(getFieldGroup(), EventDto.HUMAN_TRANSMISSION_MODE, EventDto.DISEASE_TRANSMISSION_MODE, Collections.singletonList(DiseaseTransmissionMode.HUMAN_TO_HUMAN), true);
}
if (isVisibleAllowed(EventDto.PARENTERAL_TRANSMISSION_MODE)) {
FieldHelper.setVisibleWhen(getFieldGroup(), EventDto.PARENTERAL_TRANSMISSION_MODE, EventDto.HUMAN_TRANSMISSION_MODE, Collections.singletonList(HumanTransmissionMode.PARENTERAL), true);
}
if (isVisibleAllowed(EventDto.MEDICALLY_ASSOCIATED_TRANSMISSION_MODE)) {
FieldHelper.setVisibleWhen(getFieldGroup(), EventDto.MEDICALLY_ASSOCIATED_TRANSMISSION_MODE, EventDto.PARENTERAL_TRANSMISSION_MODE, Collections.singletonList(ParenteralTransmissionMode.MEDICALLY_ASSOCIATED), true);
}
if (isVisibleAllowed(EventDto.EPIDEMIOLOGICAL_EVIDENCE)) {
FieldHelper.setVisibleWhen(getFieldGroup(), EventDto.EPIDEMIOLOGICAL_EVIDENCE, EventDto.DISEASE_TRANSMISSION_MODE, Collections.singletonList(DiseaseTransmissionMode.HUMAN_TO_HUMAN), true);
epidemiologicalEvidence.addValueChangeListener(valueChangeEvent -> {
if (((NullableOptionGroup) valueChangeEvent.getProperty()).getNullableValue() == YesNoUnknown.YES) {
epidemiologicalEvidenceCheckBoxTree.setVisible(true);
} else {
epidemiologicalEvidenceCheckBoxTree.clearCheckBoxTree();
epidemiologicalEvidenceCheckBoxTree.setVisible(false);
}
});
}
if (isVisibleAllowed(EventDto.LABORATORY_DIAGNOSTIC_EVIDENCE)) {
FieldHelper.setVisibleWhen(getFieldGroup(), EventDto.LABORATORY_DIAGNOSTIC_EVIDENCE, EventDto.DISEASE_TRANSMISSION_MODE, Collections.singletonList(DiseaseTransmissionMode.HUMAN_TO_HUMAN), true);
laboratoryDiagnosticEvidence.addValueChangeListener(valueChangeEvent -> {
if (((NullableOptionGroup) valueChangeEvent.getProperty()).getNullableValue() == YesNoUnknown.YES) {
laboratoryDiagnosticEvidenceCheckBoxTree.setVisible(true);
} else {
laboratoryDiagnosticEvidenceCheckBoxTree.clearCheckBoxTree();
laboratoryDiagnosticEvidenceCheckBoxTree.setVisible(false);
}
});
}
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(EventDto.SRC_FIRST_NAME, EventDto.SRC_LAST_NAME, EventDto.SRC_TEL_NO, EventDto.SRC_EMAIL), EventDto.SRC_TYPE, Arrays.asList(EventSourceType.HOTLINE_PERSON, EventSourceType.INSTITUTIONAL_PARTNER), true);
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(EventDto.SRC_MEDIA_WEBSITE, EventDto.SRC_MEDIA_NAME, EventDto.SRC_MEDIA_DETAILS), EventDto.SRC_TYPE, Collections.singletonList(EventSourceType.MEDIA_NEWS), true);
FieldHelper.setVisibleWhen(getFieldGroup(), EventDto.TYPE_OF_PLACE_TEXT, EventDto.TYPE_OF_PLACE, Collections.singletonList(TypeOfPlace.OTHER), true);
setTypeOfPlaceTextRequirement();
locationForm.setFacilityFieldsVisible(getField(EventDto.TYPE_OF_PLACE).getValue() == TypeOfPlace.FACILITY, true);
typeOfPlace.addValueChangeListener(e -> locationForm.setFacilityFieldsVisible(e.getProperty().getValue() == TypeOfPlace.FACILITY, true));
regionField.addValueChangeListener(e -> {
RegionReferenceDto region = (RegionReferenceDto) regionField.getValue();
if (region != null) {
regionEventResponsibles = FacadeProvider.getUserFacade().getUsersByRegionAndRights(region, getValue().getDisease(), UserRight.EVENT_RESPONSIBLE);
} else {
regionEventResponsibles.clear();
}
});
districtField.addValueChangeListener(e -> {
DistrictReferenceDto district = (DistrictReferenceDto) districtField.getValue();
if (district != null) {
List<UserReferenceDto> districtEventResponsibles = FacadeProvider.getUserFacade().getUserRefsByDistrict(district, getValue().getDisease(), UserRight.EVENT_RESPONSIBLE);
List<UserReferenceDto> responsibleUsers = new ArrayList<>();
responsibleUsers.addAll(districtEventResponsibles);
responsibleUsers.addAll(regionEventResponsibles);
FieldHelper.updateItems(responsibleUserField, responsibleUsers);
} else {
responsibleUserField.removeAllItems();
}
});
FieldHelper.addSoftRequiredStyle(startDate, endDate, typeOfPlace, meansOfTransport, meansOfTransportDetails, connectionNumber, travelDate, responsibleUserField, srcType, srcInstitutionalPartnerType, srcInstitutionalPartnerTypeDetails, srcFirstName, srcLastName, srcTelNo, srcMediaWebsite, srcMediaName);
// Make external ID field read-only when SORMAS is connected to a SurvNet instance
if (StringUtils.isNotEmpty(FacadeProvider.getConfigFacade().getExternalSurveillanceToolGatewayUrl())) {
setEnabled(false, EventDto.EXTERNAL_ID);
((TextField) getField(EventDto.EXTERNAL_ID)).setInputPrompt(I18nProperties.getString(Strings.promptExternalIdExternalSurveillanceTool));
}
addValueChangeListener((e) -> {
ValidationUtils.initComponentErrorValidator(externalTokenField, getValue().getExternalToken(), Validations.duplicateExternalToken, externalTokenWarningLabel, (externalToken) -> FacadeProvider.getEventFacade().doesExternalTokenExist(externalToken, getValue().getUuid()));
epidemiologicalEvidenceCheckBoxTree.initCheckboxes();
laboratoryDiagnosticEvidenceCheckBoxTree.initCheckboxes();
// Initialize specific risk field if disease is null
if (getValue().getDisease() == null) {
List<SpecificRisk> specificRiskValues = FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.SPECIFIC_EVENT_RISK, null);
FieldHelper.updateItems(specificRiskField, specificRiskValues);
specificRiskField.setVisible(isVisibleAllowed(EventDto.SPECIFIC_RISK) && CollectionUtils.isNotEmpty(specificRiskValues));
}
});
}
Aggregations