use of com.vaadin.v7.ui.Label in project SORMAS-Project by hzi-braunschweig.
the class CaseCreateForm method addFields.
@Override
protected void addFields() {
NullableOptionGroup ogCaseOrigin = addField(CaseDataDto.CASE_ORIGIN, NullableOptionGroup.class);
ogCaseOrigin.setRequired(true);
TextField epidField = addField(CaseDataDto.EPID_NUMBER, TextField.class);
epidField.setInvalidCommitted(true);
style(epidField, ERROR_COLOR_PRIMARY);
if (!FacadeProvider.getExternalSurveillanceToolFacade().isFeatureEnabled()) {
TextField externalIdField = addField(CaseDataDto.EXTERNAL_ID, TextField.class);
style(externalIdField, ERROR_COLOR_PRIMARY);
} else {
CheckBox dontShareCheckbox = addField(CaseDataDto.DONT_SHARE_WITH_REPORTING_TOOL, CheckBox.class);
CaseFormHelper.addDontShareWithReportingTool(getContent(), () -> dontShareCheckbox, DONT_SHARE_WARNING_LOC);
}
addField(CaseDataDto.REPORT_DATE, DateField.class);
ComboBox diseaseField = addDiseaseField(CaseDataDto.DISEASE, false, true);
diseaseVariantField = addField(CaseDataDto.DISEASE_VARIANT, ComboBox.class);
diseaseVariantDetailsField = addField(CaseDataDto.DISEASE_VARIANT_DETAILS, TextField.class);
diseaseVariantDetailsField.setVisible(false);
diseaseVariantField.setNullSelectionAllowed(true);
diseaseVariantField.setVisible(false);
addField(CaseDataDto.DISEASE_DETAILS, TextField.class);
NullableOptionGroup plagueType = addField(CaseDataDto.PLAGUE_TYPE, NullableOptionGroup.class);
addField(CaseDataDto.DENGUE_FEVER_TYPE, NullableOptionGroup.class);
addField(CaseDataDto.RABIES_TYPE, NullableOptionGroup.class);
personCreateForm = new PersonCreateForm(showHomeAddressForm, true, true, showPersonSearchButton);
personCreateForm.setWidth(100, Unit.PERCENTAGE);
getContent().addComponent(personCreateForm, CaseDataDto.PERSON);
differentPlaceOfStayJurisdiction = addCustomField(DIFFERENT_PLACE_OF_STAY_JURISDICTION, Boolean.class, CheckBox.class);
differentPlaceOfStayJurisdiction.addStyleName(VSPACE_3);
Label placeOfStayHeadingLabel = new Label(I18nProperties.getCaption(Captions.casePlaceOfStay));
placeOfStayHeadingLabel.addStyleName(H3);
getContent().addComponent(placeOfStayHeadingLabel, PLACE_OF_STAY_HEADING_LOC);
ComboBox region = addInfrastructureField(CaseDataDto.REGION);
districtCombo = addInfrastructureField(CaseDataDto.DISTRICT);
communityCombo = addInfrastructureField(CaseDataDto.COMMUNITY);
communityCombo.setNullSelectionAllowed(true);
// jurisdictionfields
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);
responsibleDistrictCombo = addInfrastructureField(CaseDataDto.RESPONSIBLE_DISTRICT);
responsibleDistrictCombo.setRequired(true);
responsibleCommunityCombo = addInfrastructureField(CaseDataDto.RESPONSIBLE_COMMUNITY);
responsibleCommunityCombo.setNullSelectionAllowed(true);
responsibleCommunityCombo.addStyleName(SOFT_REQUIRED);
InfrastructureFieldsHelper.initInfrastructureFields(responsibleRegion, responsibleDistrictCombo, responsibleCommunityCombo);
differentPointOfEntryJurisdiction = addCustomField(DIFFERENT_POINT_OF_ENTRY_JURISDICTION, Boolean.class, CheckBox.class);
differentPointOfEntryJurisdiction.addStyleName(VSPACE_3);
ComboBox pointOfEntryRegionCombo = addCustomField(POINT_OF_ENTRY_REGION, RegionReferenceDto.class, ComboBox.class);
pointOfEntryDistrictCombo = addCustomField(POINT_OF_ENTRY_DISTRICT, DistrictReferenceDto.class, ComboBox.class);
InfrastructureFieldsHelper.initInfrastructureFields(pointOfEntryRegionCombo, pointOfEntryDistrictCombo, null);
pointOfEntryDistrictCombo.addValueChangeListener(e -> updatePOEs());
FieldHelper.setVisibleWhen(differentPlaceOfStayJurisdiction, Arrays.asList(region, districtCombo, communityCombo), Collections.singletonList(Boolean.TRUE), true);
FieldHelper.setVisibleWhen(differentPointOfEntryJurisdiction, Arrays.asList(pointOfEntryRegionCombo, pointOfEntryDistrictCombo), Collections.singletonList(Boolean.TRUE), true);
FieldHelper.setRequiredWhen(differentPlaceOfStayJurisdiction, Arrays.asList(region, districtCombo), Collections.singletonList(Boolean.TRUE), false, null);
ogCaseOrigin.addValueChangeListener(e -> {
boolean pointOfEntryRegionDistrictVisible = CaseOrigin.POINT_OF_ENTRY.equals(ogCaseOrigin.getValue()) && Boolean.TRUE.equals(differentPointOfEntryJurisdiction.getValue());
pointOfEntryRegionCombo.setVisible(pointOfEntryRegionDistrictVisible);
pointOfEntryDistrictCombo.setVisible(pointOfEntryRegionDistrictVisible);
});
facilityOrHome = addCustomField(FACILITY_OR_HOME_LOC, TypeOfPlace.class, NullableOptionGroup.class, I18nProperties.getCaption(Captions.casePlaceOfStay));
facilityOrHome.removeAllItems();
for (TypeOfPlace place : TypeOfPlace.FOR_CASES) {
facilityOrHome.addItem(place);
facilityOrHome.setItemCaption(place, I18nProperties.getEnumCaption(place));
}
facilityOrHome.setItemCaptionMode(ItemCaptionMode.EXPLICIT);
facilityOrHome.setId("facilityOrHome");
facilityOrHome.setWidth(100, Unit.PERCENTAGE);
CssStyles.style(facilityOrHome, ValoTheme.OPTIONGROUP_HORIZONTAL);
facilityTypeGroup = ComboBoxHelper.createComboBoxV7();
facilityTypeGroup.setId("typeGroup");
facilityTypeGroup.setCaption(I18nProperties.getCaption(Captions.Facility_typeGroup));
facilityTypeGroup.setWidth(100, Unit.PERCENTAGE);
facilityTypeGroup.addItems(FacilityTypeGroup.getAccomodationGroups());
getContent().addComponent(facilityTypeGroup, FACILITY_TYPE_GROUP_LOC);
facilityType = ComboBoxHelper.createComboBoxV7();
facilityType.setId("type");
facilityType.setCaption(I18nProperties.getCaption(Captions.facilityType));
facilityType.setWidth(100, Unit.PERCENTAGE);
getContent().addComponent(facilityType, CaseDataDto.FACILITY_TYPE);
facilityCombo = addInfrastructureField(CaseDataDto.HEALTH_FACILITY);
facilityCombo.setImmediate(true);
TextField facilityDetails = addField(CaseDataDto.HEALTH_FACILITY_DETAILS, TextField.class);
facilityDetails.setVisible(false);
ComboBox cbPointOfEntry = addInfrastructureField(CaseDataDto.POINT_OF_ENTRY);
cbPointOfEntry.setImmediate(true);
TextField tfPointOfEntryDetails = addField(CaseDataDto.POINT_OF_ENTRY_DETAILS, TextField.class);
tfPointOfEntryDetails.setVisible(false);
if (convertedTravelEntry != null) {
differentPointOfEntryJurisdiction.setValue(true);
RegionReferenceDto regionReferenceDto = convertedTravelEntry.getPointOfEntryRegion() != null ? convertedTravelEntry.getPointOfEntryRegion() : convertedTravelEntry.getResponsibleRegion();
pointOfEntryRegionCombo.setValue(regionReferenceDto);
DistrictReferenceDto districtReferenceDto = convertedTravelEntry.getPointOfEntryDistrict() != null ? convertedTravelEntry.getPointOfEntryDistrict() : convertedTravelEntry.getResponsibleDistrict();
pointOfEntryDistrictCombo.setValue(districtReferenceDto);
differentPointOfEntryJurisdiction.setReadOnly(true);
pointOfEntryRegionCombo.setReadOnly(true);
pointOfEntryDistrictCombo.setReadOnly(true);
updatePOEs();
cbPointOfEntry.setReadOnly(true);
tfPointOfEntryDetails.setReadOnly(true);
ogCaseOrigin.setReadOnly(true);
}
region.addValueChangeListener(e -> {
RegionReferenceDto regionDto = (RegionReferenceDto) e.getProperty().getValue();
FieldHelper.updateItems(districtCombo, regionDto != null ? FacadeProvider.getDistrictFacade().getAllActiveByRegion(regionDto.getUuid()) : null);
});
districtCombo.addValueChangeListener(e -> {
FieldHelper.removeItems(communityCombo);
DistrictReferenceDto districtDto = (DistrictReferenceDto) e.getProperty().getValue();
FieldHelper.updateItems(communityCombo, districtDto != null ? FacadeProvider.getCommunityFacade().getAllActiveByDistrict(districtDto.getUuid()) : null);
updateFacility();
if (!Boolean.TRUE.equals(differentPointOfEntryJurisdiction.getValue())) {
updatePOEs();
}
});
communityCombo.addValueChangeListener(e -> {
updateFacility();
});
facilityOrHome.addValueChangeListener(e -> {
FieldHelper.removeItems(facilityCombo);
if (TypeOfPlace.FACILITY.equals(facilityOrHome.getValue()) || ((facilityOrHome.getValue() instanceof java.util.Set) && TypeOfPlace.FACILITY.equals(facilityOrHome.getNullableValue()))) {
if (facilityTypeGroup.getValue() == null) {
facilityTypeGroup.setValue(FacilityTypeGroup.MEDICAL_FACILITY);
}
if (facilityType.getValue() == null && FacilityTypeGroup.MEDICAL_FACILITY.equals(facilityTypeGroup.getValue())) {
facilityType.setValue(FacilityType.HOSPITAL);
}
if (facilityType.getValue() != null) {
updateFacility();
}
if (CaseOrigin.IN_COUNTRY.equals(ogCaseOrigin.getValue())) {
facilityCombo.setRequired(true);
}
updateFacilityFields(facilityCombo, facilityDetails);
} else if (TypeOfPlace.HOME.equals(facilityOrHome.getValue()) || ((facilityOrHome.getValue() instanceof java.util.Set) && TypeOfPlace.HOME.equals(facilityOrHome.getNullableValue()))) {
setNoneFacility();
} else {
facilityCombo.removeAllItems();
facilityCombo.setValue(null);
updateFacilityFields(facilityCombo, facilityDetails);
}
});
facilityTypeGroup.addValueChangeListener(e -> {
FieldHelper.removeItems(facilityCombo);
FieldHelper.updateEnumData(facilityType, FacilityType.getAccommodationTypes((FacilityTypeGroup) facilityTypeGroup.getValue()));
});
facilityType.addValueChangeListener(e -> updateFacility());
region.addItems(FacadeProvider.getRegionFacade().getAllActiveByServerCountry());
JurisdictionLevel userJurisdictionLevel = UserRole.getJurisdictionLevel(UserProvider.getCurrent().getUserRoles());
if (userJurisdictionLevel == JurisdictionLevel.HEALTH_FACILITY) {
region.setReadOnly(true);
responsibleRegion.setReadOnly(true);
districtCombo.setReadOnly(true);
responsibleDistrictCombo.setReadOnly(true);
communityCombo.setReadOnly(true);
responsibleCommunityCombo.setReadOnly(true);
differentPlaceOfStayJurisdiction.setVisible(false);
differentPlaceOfStayJurisdiction.setEnabled(false);
facilityOrHome.setImmediate(true);
// [FACILITY]
facilityOrHome.setValue(Sets.newHashSet(TypeOfPlace.FACILITY));
facilityOrHome.setReadOnly(true);
facilityTypeGroup.setValue(FacilityTypeGroup.MEDICAL_FACILITY);
facilityTypeGroup.setReadOnly(true);
facilityType.setValue(FacilityType.HOSPITAL);
facilityType.setReadOnly(true);
facilityCombo.setValue(UserProvider.getCurrent().getUser().getHealthFacility());
facilityCombo.setReadOnly(true);
}
if (!UserRole.isPortHealthUser(UserProvider.getCurrent().getUserRoles())) {
ogCaseOrigin.addValueChangeListener(ev -> {
if (ev.getProperty().getValue() == CaseOrigin.IN_COUNTRY) {
setVisible(false, CaseDataDto.POINT_OF_ENTRY, CaseDataDto.POINT_OF_ENTRY_DETAILS);
differentPointOfEntryJurisdiction.setVisible(false);
setRequired(true, FACILITY_OR_HOME_LOC, FACILITY_TYPE_GROUP_LOC, CaseDataDto.FACILITY_TYPE, CaseDataDto.HEALTH_FACILITY);
setRequired(false, CaseDataDto.POINT_OF_ENTRY);
updateFacilityFields(facilityCombo, facilityDetails);
} else {
setVisible(true, CaseDataDto.POINT_OF_ENTRY);
differentPointOfEntryJurisdiction.setVisible(true);
setRequired(true, CaseDataDto.POINT_OF_ENTRY);
if (userJurisdictionLevel != JurisdictionLevel.HEALTH_FACILITY) {
facilityOrHome.clear();
setRequired(false, FACILITY_OR_HOME_LOC, FACILITY_TYPE_GROUP_LOC, CaseDataDto.FACILITY_TYPE, CaseDataDto.HEALTH_FACILITY);
}
updatePointOfEntryFields(cbPointOfEntry, tfPointOfEntryDetails);
}
});
}
// jurisdiction field valuechangelisteners
responsibleDistrictCombo.addValueChangeListener(e -> {
Boolean differentPlaceOfStay = differentPlaceOfStayJurisdiction.getValue();
if (!Boolean.TRUE.equals(differentPlaceOfStay)) {
updateFacility();
if (!Boolean.TRUE.equals(differentPointOfEntryJurisdiction.getValue())) {
updatePOEs();
}
}
});
responsibleCommunityCombo.addValueChangeListener((e) -> {
Boolean differentPlaceOfStay = differentPlaceOfStayJurisdiction.getValue();
if (differentPlaceOfStay == null || Boolean.FALSE.equals(differentPlaceOfStay)) {
updateFacility();
}
});
differentPlaceOfStayJurisdiction.addValueChangeListener(e -> {
updateFacility();
if (!Boolean.TRUE.equals(differentPointOfEntryJurisdiction.getValue())) {
updatePOEs();
}
});
// Set initial visibilities & accesses
initializeVisibilitiesAndAllowedVisibilities();
setRequired(true, CaseDataDto.REPORT_DATE, CaseDataDto.DISEASE, FACILITY_OR_HOME_LOC, FACILITY_TYPE_GROUP_LOC, CaseDataDto.FACILITY_TYPE);
FieldHelper.addSoftRequiredStyle(plagueType, communityCombo, facilityDetails);
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));
FieldHelper.setRequiredWhen(getFieldGroup(), CaseDataDto.CASE_ORIGIN, Arrays.asList(CaseDataDto.HEALTH_FACILITY), Arrays.asList(CaseOrigin.IN_COUNTRY));
FieldHelper.setRequiredWhen(getFieldGroup(), CaseDataDto.CASE_ORIGIN, Arrays.asList(CaseDataDto.POINT_OF_ENTRY), Arrays.asList(CaseOrigin.POINT_OF_ENTRY));
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.PLAGUE_TYPE), CaseDataDto.DISEASE, Arrays.asList(Disease.PLAGUE), true);
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.DENGUE_FEVER_TYPE), CaseDataDto.DISEASE, Arrays.asList(Disease.DENGUE), true);
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.RABIES_TYPE), CaseDataDto.DISEASE, Arrays.asList(Disease.RABIES), true);
FieldHelper.setVisibleWhen(facilityOrHome, Arrays.asList(facilityTypeGroup, facilityType, facilityCombo), Collections.singletonList(TypeOfPlace.FACILITY), false);
FieldHelper.setRequiredWhen(facilityOrHome, Arrays.asList(facilityTypeGroup, facilityType, facilityCombo), Collections.singletonList(TypeOfPlace.FACILITY), false, null);
facilityCombo.addValueChangeListener(e -> {
updateFacilityFields(facilityCombo, facilityDetails);
this.getValue().setFacilityType((FacilityType) facilityType.getValue());
});
cbPointOfEntry.addValueChangeListener(e -> {
updatePointOfEntryFields(cbPointOfEntry, tfPointOfEntryDetails);
});
addValueChangeListener(e -> {
if (UserRole.isPortHealthUser(UserProvider.getCurrent().getUserRoles())) {
setVisible(false, CaseDataDto.CASE_ORIGIN, CaseDataDto.DISEASE, CaseDataDto.COMMUNITY, CaseDataDto.HEALTH_FACILITY);
setVisible(true, CaseDataDto.POINT_OF_ENTRY);
}
});
diseaseField.addValueChangeListener((ValueChangeListener) valueChangeEvent -> {
updateDiseaseVariant((Disease) valueChangeEvent.getProperty().getValue());
personCreateForm.updatePresentConditionEnum((Disease) valueChangeEvent.getProperty().getValue());
});
diseaseVariantField.addValueChangeListener(e -> {
DiseaseVariant diseaseVariant = (DiseaseVariant) e.getProperty().getValue();
diseaseVariantDetailsField.setVisible(diseaseVariant != null && diseaseVariant.matchPropertyValue(DiseaseVariant.HAS_DETAILS, true));
});
if (diseaseField.getValue() != null) {
Disease disease = (Disease) diseaseField.getValue();
updateDiseaseVariant(disease);
personCreateForm.updatePresentConditionEnum(disease);
}
}
use of com.vaadin.v7.ui.Label in project SORMAS-Project by hzi-braunschweig.
the class ClinicalCourseView method createClinicalVisitsHeader.
private VerticalLayout createClinicalVisitsHeader() {
VerticalLayout clinicalVisitsHeader = new VerticalLayout();
clinicalVisitsHeader.setMargin(false);
clinicalVisitsHeader.setSpacing(false);
clinicalVisitsHeader.setWidth(100, Unit.PERCENTAGE);
HorizontalLayout headlineRow = new HorizontalLayout();
headlineRow.setMargin(false);
headlineRow.setSpacing(true);
headlineRow.setWidth(100, Unit.PERCENTAGE);
{
Label clinicalVisitsLabel = new Label(I18nProperties.getString(Strings.entityClinicalVisits));
CssStyles.style(clinicalVisitsLabel, CssStyles.H3);
headlineRow.addComponent(clinicalVisitsLabel);
headlineRow.setExpandRatio(clinicalVisitsLabel, 1);
// Bulk operations
if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
MenuBar bulkOperationsDropdown = MenuBarHelper.createDropDown(Captions.bulkActions, new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, selectedItem -> {
ControllerProvider.getClinicalCourseController().deleteAllSelectedClinicalVisits(clinicalVisitGrid.getSelectedRows(), new Runnable() {
public void run() {
clinicalVisitGrid.reload();
}
});
}));
headlineRow.addComponent(bulkOperationsDropdown);
headlineRow.setComponentAlignment(bulkOperationsDropdown, Alignment.MIDDLE_RIGHT);
}
Button newClinicalVisitButton = ButtonHelper.createButton(Captions.clinicalVisitNewClinicalVisit, e -> {
ControllerProvider.getClinicalCourseController().openClinicalVisitCreateForm(clinicalVisitCriteria.getClinicalCourse(), getCaseRef().getUuid(), this::reloadClinicalVisitGrid);
}, ValoTheme.BUTTON_PRIMARY);
headlineRow.addComponent(newClinicalVisitButton);
headlineRow.setComponentAlignment(newClinicalVisitButton, Alignment.MIDDLE_RIGHT);
}
clinicalVisitsHeader.addComponent(headlineRow);
return clinicalVisitsHeader;
}
use of com.vaadin.v7.ui.Label in project SORMAS-Project by hzi-braunschweig.
the class HealthConditionsForm method addFields.
@Override
protected void addFields() {
Label healthConditionsHeadingLabel = new Label(I18nProperties.getString(Strings.headingHealthConditions));
healthConditionsHeadingLabel.addStyleName(H3);
getContent().addComponent(healthConditionsHeadingLabel, HEALTH_CONDITIONS_HEADINGS_LOC);
addFields(TUBERCULOSIS, ASPLENIA, HEPATITIS, DIABETES, HIV, HIV_ART, CHRONIC_LIVER_DISEASE, MALIGNANCY_CHEMOTHERAPY, CHRONIC_HEART_FAILURE, CHRONIC_PULMONARY_DISEASE, CHRONIC_KIDNEY_DISEASE, CHRONIC_NEUROLOGIC_CONDITION, DOWN_SYNDROME, CONGENITAL_SYPHILIS, IMMUNODEFICIENCY_OTHER_THAN_HIV, CARDIOVASCULAR_DISEASE_INCLUDING_HYPERTENSION, OBESITY, CURRENT_SMOKER, FORMER_SMOKER, ASTHMA, SICKLE_CELL_DISEASE, IMMUNODEFICIENCY_INCLUDING_HIV);
TextArea otherConditions = addField(OTHER_CONDITIONS, TextArea.class);
otherConditions.setRows(6);
otherConditions.setDescription(I18nProperties.getPrefixDescription(HealthConditionsDto.I18N_PREFIX, OTHER_CONDITIONS, "") + "\n" + I18nProperties.getDescription(Descriptions.descGdpr));
initializeVisibilitiesAndAllowedVisibilities();
initializeAccessAndAllowedAccesses();
FieldHelper.setVisibleWhen(getFieldGroup(), HIV_ART, HIV, Arrays.asList(YesNoUnknown.YES), true);
}
use of com.vaadin.v7.ui.Label in project SORMAS-Project by hzi-braunschweig.
the class CasePickOrImportField method addInfoComponent.
@Override
protected void addInfoComponent() {
HorizontalLayout infoLayout = new HorizontalLayout();
infoLayout.setWidth(100, Unit.PERCENTAGE);
infoLayout.setSpacing(true);
Image icon = new Image(null, new ThemeResource("img/info-icon.png"));
icon.setHeight(35, Unit.PIXELS);
icon.setWidth(35, Unit.PIXELS);
infoLayout.addComponent(icon);
Label infoLabel = new Label(I18nProperties.getString(Strings.infoImportSimilarity));
infoLayout.addComponent(infoLabel);
infoLayout.setExpandRatio(infoLabel, 1);
mainLayout.addComponent(infoLayout);
CssStyles.style(infoLayout, CssStyles.VSPACE_3);
// Imported case info
VerticalLayout caseInfoContainer = new VerticalLayout();
caseInfoContainer.setWidth(100, Unit.PERCENTAGE);
CssStyles.style(caseInfoContainer, CssStyles.BACKGROUND_ROUNDED_CORNERS, CssStyles.BACKGROUND_SUB_CRITERIA, CssStyles.VSPACE_3, "v-scrollable");
Label newCaseLabel = new Label(I18nProperties.getString(Strings.headingImportedCaseInfo));
CssStyles.style(newCaseLabel, CssStyles.LABEL_BOLD, CssStyles.VSPACE_4);
caseInfoContainer.addComponent(newCaseLabel);
HorizontalLayout caseInfoLayout = new HorizontalLayout();
caseInfoLayout.setSpacing(true);
caseInfoLayout.setSizeUndefined();
{
Label diseaseField = new Label();
diseaseField.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.DISEASE));
diseaseField.setValue(DiseaseHelper.toString(newCase.getDisease(), newCase.getDiseaseDetails()));
diseaseField.setWidthUndefined();
caseInfoLayout.addComponent(diseaseField);
Label reportDateField = new Label();
reportDateField.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.REPORT_DATE));
reportDateField.setValue(DateFormatHelper.formatDate(newCase.getReportDate()));
reportDateField.setWidthUndefined();
caseInfoLayout.addComponent(reportDateField);
Label responsibleRegionField = new Label();
responsibleRegionField.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.RESPONSIBLE_REGION));
responsibleRegionField.setValue(newCase.getResponsibleRegion().toString());
responsibleRegionField.setWidthUndefined();
caseInfoLayout.addComponent(responsibleRegionField);
Label responsibleDistrictField = new Label();
responsibleDistrictField.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.RESPONSIBLE_DISTRICT));
responsibleDistrictField.setValue(newCase.getResponsibleDistrict().toString());
responsibleDistrictField.setWidthUndefined();
caseInfoLayout.addComponent(responsibleDistrictField);
if (newCase.getRegion() != null) {
Label regionField = new Label();
regionField.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.REGION));
regionField.setValue(newCase.getRegion().toString());
regionField.setWidthUndefined();
caseInfoLayout.addComponent(regionField);
}
if (newCase.getDistrict() != null) {
Label districtField = new Label();
districtField.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.DISTRICT));
districtField.setValue(newCase.getDistrict().toString());
districtField.setWidthUndefined();
caseInfoLayout.addComponent(districtField);
}
Label facilityField = new Label();
facilityField.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.HEALTH_FACILITY));
facilityField.setValue(FacilityHelper.buildFacilityString(null, newCase.getHealthFacility() != null ? newCase.getHealthFacility().toString() : "", newCase.getHealthFacilityDetails()));
facilityField.setWidthUndefined();
caseInfoLayout.addComponent(facilityField);
Label firstNameField = new Label();
firstNameField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.FIRST_NAME));
firstNameField.setValue(newPerson.getFirstName());
firstNameField.setWidthUndefined();
caseInfoLayout.addComponent(firstNameField);
Label lastNameField = new Label();
lastNameField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.LAST_NAME));
lastNameField.setValue(newPerson.getLastName());
lastNameField.setWidthUndefined();
caseInfoLayout.addComponent(lastNameField);
Label ageAndBirthDateField = new Label();
ageAndBirthDateField.setCaption(I18nProperties.getCaption(Captions.personAgeAndBirthdate));
ageAndBirthDateField.setValue(PersonHelper.getAgeAndBirthdateString(newPerson.getApproximateAge(), newPerson.getApproximateAgeType(), newPerson.getBirthdateDD(), newPerson.getBirthdateMM(), newPerson.getBirthdateYYYY()));
ageAndBirthDateField.setWidthUndefined();
caseInfoLayout.addComponent(ageAndBirthDateField);
Label sexField = new Label();
sexField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.SEX));
sexField.setValue(newPerson.getSex() != null ? newPerson.getSex().toString() : "");
sexField.setWidthUndefined();
caseInfoLayout.addComponent(sexField);
}
caseInfoContainer.addComponent(caseInfoLayout);
mainLayout.addComponent(caseInfoContainer);
}
use of com.vaadin.v7.ui.Label in project SORMAS-Project by hzi-braunschweig.
the class MaternalHistoryForm method addFields.
@Override
protected void addFields() {
Label maternalHistoryHeadingLabel = new Label(I18nProperties.getString(Strings.headingMaternalHistory));
maternalHistoryHeadingLabel.addStyleName(H3);
getContent().addComponent(maternalHistoryHeadingLabel, MATERNAL_HISTORY_HEADING_LOC);
TextField tfChildrenNumber = addField(MaternalHistoryDto.CHILDREN_NUMBER, TextField.class);
tfChildrenNumber.setConversionError(I18nProperties.getValidationError(Validations.onlyIntegerNumbersAllowed, tfChildrenNumber.getCaption()));
TextField tfAgeAtBirth = addField(MaternalHistoryDto.AGE_AT_BIRTH, TextField.class);
tfAgeAtBirth.setConversionError(I18nProperties.getValidationError(Validations.onlyIntegerNumbersAllowed, tfAgeAtBirth.getCaption()));
TextField tfConjunctivitisMonth = addField(MaternalHistoryDto.CONJUNCTIVITIS_MONTH, TextField.class);
tfConjunctivitisMonth.setConversionError(I18nProperties.getValidationError(Validations.onlyIntegerNumbersAllowed, tfConjunctivitisMonth.getCaption()));
TextField tfMaculopapularRashMonth = addField(MaternalHistoryDto.MACULOPAPULAR_RASH_MONTH, TextField.class);
tfMaculopapularRashMonth.setConversionError(I18nProperties.getValidationError(Validations.onlyIntegerNumbersAllowed, tfMaculopapularRashMonth.getCaption()));
TextField tfSwollenLymphsMonth = addField(MaternalHistoryDto.SWOLLEN_LYMPHS_MONTH, TextField.class);
tfSwollenLymphsMonth.setConversionError(I18nProperties.getValidationError(Validations.onlyIntegerNumbersAllowed, tfSwollenLymphsMonth.getCaption()));
TextField tfArthralgiaArthritisMonth = addField(MaternalHistoryDto.ARTHRALGIA_ARTHRITIS_MONTH, TextField.class);
tfArthralgiaArthritisMonth.setConversionError(I18nProperties.getValidationError(Validations.onlyIntegerNumbersAllowed, tfArthralgiaArthritisMonth.getCaption()));
TextField otherComplicationsMonth = addField(MaternalHistoryDto.OTHER_COMPLICATIONS_MONTH, TextField.class);
otherComplicationsMonth.setConversionError(I18nProperties.getValidationError(Validations.onlyIntegerNumbersAllowed, otherComplicationsMonth.getCaption()));
TextField rashExposureMonth = addField(MaternalHistoryDto.RASH_EXPOSURE_MONTH, TextField.class);
rashExposureMonth.setConversionError(I18nProperties.getValidationError(Validations.onlyIntegerNumbersAllowed, rashExposureMonth.getCaption()));
addFields(MaternalHistoryDto.CONJUNCTIVITIS_ONSET, MaternalHistoryDto.MACULOPAPULAR_RASH_ONSET, MaternalHistoryDto.SWOLLEN_LYMPHS_ONSET, MaternalHistoryDto.ARTHRALGIA_ARTHRITIS_ONSET, MaternalHistoryDto.OTHER_COMPLICATIONS_ONSET, MaternalHistoryDto.OTHER_COMPLICATIONS_DETAILS, MaternalHistoryDto.RUBELLA_ONSET, MaternalHistoryDto.RASH_EXPOSURE_DATE);
addField(MaternalHistoryDto.CONJUNCTIVITIS, NullableOptionGroup.class);
addField(MaternalHistoryDto.MACULOPAPULAR_RASH, NullableOptionGroup.class);
addField(MaternalHistoryDto.SWOLLEN_LYMPHS, NullableOptionGroup.class);
addField(MaternalHistoryDto.ARTHRALGIA_ARTHRITIS, NullableOptionGroup.class);
addField(MaternalHistoryDto.OTHER_COMPLICATIONS, NullableOptionGroup.class);
addField(MaternalHistoryDto.RUBELLA, NullableOptionGroup.class);
addField(MaternalHistoryDto.RASH_EXPOSURE, NullableOptionGroup.class);
ComboBox cbRashExposureRegion = addInfrastructureField(MaternalHistoryDto.RASH_EXPOSURE_REGION);
ComboBox cbRashExposureDistrict = addInfrastructureField(MaternalHistoryDto.RASH_EXPOSURE_DISTRICT);
ComboBox cbRashExposureCommunity = addInfrastructureField(MaternalHistoryDto.RASH_EXPOSURE_COMMUNITY);
initializeAccessAndAllowedAccesses();
cbRashExposureRegion.addValueChangeListener(e -> {
RegionReferenceDto region = (RegionReferenceDto) e.getProperty().getValue();
FieldHelper.updateItems(cbRashExposureDistrict, region != null ? FacadeProvider.getDistrictFacade().getAllActiveByRegion(region.getUuid()) : null);
});
cbRashExposureDistrict.addValueChangeListener(e -> {
FieldHelper.removeItems(cbRashExposureCommunity);
DistrictReferenceDto district = (DistrictReferenceDto) e.getProperty().getValue();
FieldHelper.updateItems(cbRashExposureCommunity, district != null ? FacadeProvider.getCommunityFacade().getAllActiveByDistrict(district.getUuid()) : null);
});
cbRashExposureRegion.addItems(FacadeProvider.getRegionFacade().getAllActiveByServerCountry());
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(MaternalHistoryDto.CONJUNCTIVITIS_ONSET, MaternalHistoryDto.CONJUNCTIVITIS_MONTH), MaternalHistoryDto.CONJUNCTIVITIS, Arrays.asList(YesNoUnknown.YES), true);
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(MaternalHistoryDto.MACULOPAPULAR_RASH_ONSET, MaternalHistoryDto.MACULOPAPULAR_RASH_MONTH), MaternalHistoryDto.MACULOPAPULAR_RASH, Arrays.asList(YesNoUnknown.YES), true);
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(MaternalHistoryDto.SWOLLEN_LYMPHS_ONSET, MaternalHistoryDto.SWOLLEN_LYMPHS_MONTH), MaternalHistoryDto.SWOLLEN_LYMPHS, Arrays.asList(YesNoUnknown.YES), true);
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(MaternalHistoryDto.ARTHRALGIA_ARTHRITIS_ONSET, MaternalHistoryDto.ARTHRALGIA_ARTHRITIS_MONTH), MaternalHistoryDto.ARTHRALGIA_ARTHRITIS, Arrays.asList(YesNoUnknown.YES), true);
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(MaternalHistoryDto.OTHER_COMPLICATIONS_ONSET, MaternalHistoryDto.OTHER_COMPLICATIONS_MONTH, MaternalHistoryDto.OTHER_COMPLICATIONS_DETAILS), MaternalHistoryDto.OTHER_COMPLICATIONS, Arrays.asList(YesNoUnknown.YES), true);
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(MaternalHistoryDto.RUBELLA_ONSET), MaternalHistoryDto.RUBELLA, Arrays.asList(YesNoUnknown.YES), true);
FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(MaternalHistoryDto.RASH_EXPOSURE_DATE, MaternalHistoryDto.RASH_EXPOSURE_MONTH, MaternalHistoryDto.RASH_EXPOSURE_REGION, MaternalHistoryDto.RASH_EXPOSURE_DISTRICT, MaternalHistoryDto.RASH_EXPOSURE_COMMUNITY), MaternalHistoryDto.RASH_EXPOSURE, Arrays.asList(YesNoUnknown.YES), true);
}
Aggregations