use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.
the class TaskGridFilterForm method addDistrictField.
private ComboBox addDistrictField() {
final ComboBox districtField = addField(FieldConfiguration.pixelSized(TaskIndexDto.DISTRICT, 200));
districtField.setDescription(I18nProperties.getDescription(Descriptions.descDistrictFilter));
return districtField;
}
use of com.vaadin.v7.ui.ComboBox 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 com.vaadin.v7.ui.ComboBox 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 com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.
the class SormasToSormasOptionsForm method addFields.
@Override
protected void addFields() {
ComboBox availableServersCombo = addField(SormasToSormasOptionsDto.ORGANIZATION, ComboBox.class);
availableServersCombo.setRequired(true);
List<SormasServerDescriptor> availableServers = FacadeProvider.getSormasToSormasFacade().getAllAvailableServers();
availableServersCombo.addItems(availableServers);
if (hasOptions) {
CheckBox handoverOwnership = addField(SormasToSormasOptionsDto.HAND_OVER_OWNERSHIP);
CheckBox pseudonimyzePersonalData = addField(SormasToSormasOptionsDto.PSEUDONYMIZE_PERSONAL_DATA);
CheckBox pseudonymizeSensitiveData = addField(SormasToSormasOptionsDto.PSEUDONYMIZE_SENSITIVE_DATA);
pseudonymizeSensitiveData.addStyleNames(CssStyles.VSPACE_3);
availableServersCombo.addValueChangeListener(e -> {
SormasServerDescriptor selectedServer = (SormasServerDescriptor) e.getProperty().getValue();
if (selectedServer == null) {
return;
}
Optional<SormasToSormasShareInfoDto> previousShare = findShareByOrganization(currentShares, selectedServer.getId());
previousShare.ifPresent(s -> {
if (s.getRequestStatus() != ShareRequestStatus.ACCEPTED) {
handoverOwnership.setValue(s.isOwnershipHandedOver());
}
pseudonimyzePersonalData.setValue(s.isPseudonymizedPersonalData());
pseudonimyzePersonalData.setValue(s.isPseudonymizedSensitiveData());
if (updateCustomOptionsByPreviousShare != null) {
updateCustomOptionsByPreviousShare.accept(this, s);
}
});
});
handoverOwnership.addValueChangeListener(e -> {
boolean ownershipHandedOver = (boolean) e.getProperty().getValue();
pseudonimyzePersonalData.setEnabled(!ownershipHandedOver);
pseudonymizeSensitiveData.setEnabled(!ownershipHandedOver);
if (ownershipHandedOver) {
pseudonimyzePersonalData.setValue(false);
pseudonymizeSensitiveData.setValue(false);
}
});
pseudonimyzePersonalData.addValueChangeListener(e -> {
boolean pseudonimyze = (boolean) e.getProperty().getValue() || pseudonymizeSensitiveData.getValue();
handoverOwnership.setEnabled(!pseudonimyze);
if (pseudonimyze) {
handoverOwnership.setValue(false);
}
});
pseudonymizeSensitiveData.addValueChangeListener(e -> {
boolean pseudonimyze = (boolean) e.getProperty().getValue() || pseudonimyzePersonalData.getValue();
handoverOwnership.setEnabled(!pseudonimyze);
if (pseudonimyze) {
handoverOwnership.setValue(false);
}
});
addFields(customOptions);
TextArea comment = addField(SormasToSormasOptionsDto.COMMENT, TextArea.class);
comment.setRows(3);
if (customFieldDependencies != null) {
customFieldDependencies.accept(this);
}
if (CollectionUtils.isEmpty(customOptions)) {
pseudonymizeSensitiveData.addStyleNames(CssStyles.VSPACE_3);
} else {
getField(customOptions.get(customOptions.size() - 1)).addStyleNames(CssStyles.VSPACE_3);
}
}
}
use of com.vaadin.v7.ui.ComboBox in project SORMAS-Project by hzi-braunschweig.
the class PrescriptionForm method addFields.
@Override
protected void addFields() {
ComboBox prescriptionTypeField = addField(PrescriptionDto.PRESCRIPTION_TYPE, ComboBox.class);
prescriptionTypeField.setImmediate(true);
TextField prescriptionDetailsField = addField(PrescriptionDto.PRESCRIPTION_DETAILS, TextField.class);
addField(PrescriptionDto.TYPE_OF_DRUG, NullableOptionGroup.class);
addField(PrescriptionDto.PRESCRIPTION_DATE, DateField.class);
addField(PrescriptionDto.PRESCRIBING_CLINICIAN, TextField.class);
DateField prescriptionStartField = addDateField(PrescriptionDto.PRESCRIPTION_START, DateField.class, -1);
DateField prescriptionEndField = addDateField(PrescriptionDto.PRESCRIPTION_END, DateField.class, -1);
prescriptionEndField.setImmediate(true);
addField(PrescriptionDto.FREQUENCY, TextField.class);
addField(PrescriptionDto.DOSE, TextField.class);
ComboBox routeField = addField(PrescriptionDto.ROUTE, ComboBox.class);
addField(PrescriptionDto.ROUTE_DETAILS, TextField.class);
TextArea additionalNotes = addField(PrescriptionDto.ADDITIONAL_NOTES, TextArea.class);
additionalNotes.setRows(6);
additionalNotes.setDescription(I18nProperties.getPrefixDescription(PrescriptionDto.I18N_PREFIX, PrescriptionDto.ADDITIONAL_NOTES, "") + "\n" + I18nProperties.getDescription(Descriptions.descGdpr));
initializeAccessAndAllowedAccesses();
setRequired(true, PrescriptionDto.PRESCRIPTION_TYPE, PrescriptionDto.PRESCRIPTION_DATE);
if (isEditableAllowed(PrescriptionDto.PRESCRIPTION_DETAILS)) {
FieldHelper.setRequiredWhen(getFieldGroup(), prescriptionTypeField, Collections.singletonList(PrescriptionDto.PRESCRIPTION_DETAILS), Arrays.asList(TreatmentType.OTHER, TreatmentType.DRUG_INTAKE));
}
if (isEditableAllowed(PrescriptionDto.ROUTE_DETAILS)) {
FieldHelper.setRequiredWhen(getFieldGroup(), routeField, Arrays.asList(PrescriptionDto.ROUTE_DETAILS), Arrays.asList(TreatmentRoute.OTHER));
}
FieldHelper.setVisibleWhen(getFieldGroup(), PrescriptionDto.ROUTE_DETAILS, PrescriptionDto.ROUTE, Arrays.asList(TreatmentRoute.OTHER), true);
FieldHelper.setVisibleWhen(getFieldGroup(), PrescriptionDto.TYPE_OF_DRUG, PrescriptionDto.PRESCRIPTION_TYPE, Arrays.asList(TreatmentType.DRUG_INTAKE), true);
prescriptionTypeField.addValueChangeListener(e -> {
if (e.getProperty().getValue() == TreatmentType.DRUG_INTAKE) {
prescriptionDetailsField.setCaption(I18nProperties.getPrefixCaption(PrescriptionDto.I18N_PREFIX, PrescriptionDto.DRUG_INTAKE_DETAILS));
} else {
prescriptionDetailsField.setCaption(I18nProperties.getPrefixCaption(PrescriptionDto.I18N_PREFIX, PrescriptionDto.PRESCRIPTION_DETAILS));
}
});
prescriptionStartField.addValidator(new DateComparisonValidator(prescriptionStartField, prescriptionEndField, true, false, I18nProperties.getValidationError(Validations.beforeDate, prescriptionStartField.getCaption(), prescriptionEndField.getCaption())));
prescriptionEndField.addValidator(new DateComparisonValidator(prescriptionEndField, prescriptionStartField, false, false, I18nProperties.getValidationError(Validations.afterDate, prescriptionEndField.getCaption(), prescriptionStartField.getCaption())));
}
Aggregations