List of usage examples for com.vaadin.v7.ui DateField getCaption
public String getCaption();
From source file:de.symeda.sormas.ui.epidata.EpiDataBurialEditForm.java
License:Open Source License
@Override protected void addFields() { DateField burialDateFrom = addField(EpiDataBurialDto.BURIAL_DATE_FROM, DateField.class); DateField burialDateTo = addField(EpiDataBurialDto.BURIAL_DATE_TO, DateField.class); burialDateFrom.addValidator(new DateComparisonValidator(burialDateFrom, burialDateTo, true, false, I18nProperties.getValidationError(Validations.beforeDate, burialDateFrom.getCaption(), burialDateTo.getCaption()))); burialDateTo.addValidator(new DateComparisonValidator(burialDateTo, burialDateFrom, false, false, I18nProperties.getValidationError(Validations.afterDate, burialDateFrom.getCaption(), burialDateTo.getCaption()))); addField(EpiDataBurialDto.BURIAL_PERSON_NAME, TextField.class); addField(EpiDataBurialDto.BURIAL_RELATION, TextField.class); addField(EpiDataBurialDto.BURIAL_ILL, OptionGroup.class); addField(EpiDataBurialDto.BURIAL_TOUCHING, OptionGroup.class); addField(EpiDataBurialDto.BURIAL_ADDRESS, LocationEditForm.class).setCaption(null); FieldHelper.addSoftRequiredStyle(burialDateFrom, burialDateTo); setRequired(true, EpiDataBurialDto.BURIAL_ILL, EpiDataBurialDto.BURIAL_TOUCHING); }
From source file:de.symeda.sormas.ui.epidata.EpiDataTravelEditForm.java
License:Open Source License
@Override protected void addFields() { DateField travelDateFrom = addField(EpiDataTravelDto.TRAVEL_DATE_FROM, DateField.class); DateField travelDateTo = addField(EpiDataTravelDto.TRAVEL_DATE_TO, DateField.class); travelDateFrom.addValidator(new DateComparisonValidator(travelDateFrom, travelDateTo, true, true, I18nProperties.getValidationError(Validations.beforeDate, travelDateFrom.getCaption(), travelDateTo.getCaption()))); travelDateTo.addValidator(new DateComparisonValidator(travelDateTo, travelDateFrom, false, true, I18nProperties.getValidationError(Validations.afterDate, travelDateFrom.getCaption(), travelDateTo.getCaption()))); addField(EpiDataTravelDto.TRAVEL_TYPE, ComboBox.class); addField(EpiDataTravelDto.TRAVEL_DESTINATION, TextField.class); FieldHelper.addSoftRequiredStyle(travelDateFrom, travelDateTo); }
From source file:de.symeda.sormas.ui.hospitalization.HospitalizationForm.java
License:Open Source License
@Override protected void addFields() { if (caze == null || viewMode == null) { return;/*w w w .j a v a 2 s .c o m*/ } TextField facilityField = addCustomField(HEALTH_FACILITY, FacilityReferenceDto.class, TextField.class); facilityField.setValue(caze.getHealthFacility().toString()); facilityField.setReadOnly(true); addField(HospitalizationDto.ADMITTED_TO_HEALTH_FACILITY, OptionGroup.class); DateField admissionDateField = addField(HospitalizationDto.ADMISSION_DATE, DateField.class); DateField dischargeDateField = addDateField(HospitalizationDto.DISCHARGE_DATE, DateField.class, 7); addFields(HospitalizationDto.ACCOMMODATION, HospitalizationDto.ISOLATION_DATE); addField(HospitalizationDto.ISOLATED, OptionGroup.class); addField(HospitalizationDto.LEFT_AGAINST_ADVICE, OptionGroup.class); OptionGroup hospitalizedPreviouslyField = addField(HospitalizationDto.HOSPITALIZED_PREVIOUSLY, OptionGroup.class); CssStyles.style(hospitalizedPreviouslyField, CssStyles.ERROR_COLOR_PRIMARY); PreviousHospitalizationsField previousHospitalizationsField = addField( HospitalizationDto.PREVIOUS_HOSPITALIZATIONS, PreviousHospitalizationsField.class); initializeVisibilitiesAndAllowedVisibilities(null, viewMode); if (isVisibleAllowed(HospitalizationDto.ISOLATION_DATE)) { FieldHelper.setVisibleWhen(getFieldGroup(), HospitalizationDto.ISOLATION_DATE, HospitalizationDto.ISOLATED, Arrays.asList(YesNoUnknown.YES), true); } if (isVisibleAllowed(HospitalizationDto.PREVIOUS_HOSPITALIZATIONS)) { FieldHelper.setVisibleWhen(getFieldGroup(), HospitalizationDto.PREVIOUS_HOSPITALIZATIONS, HospitalizationDto.HOSPITALIZED_PREVIOUSLY, Arrays.asList(YesNoUnknown.YES), true); } // Validations admissionDateField.addValidator( new DateComparisonValidator(admissionDateField, caze.getSymptoms().getOnsetDate(), false, false, I18nProperties.getValidationError(Validations.afterDateSoft, admissionDateField.getCaption(), I18nProperties.getPrefixCaption(SymptomsDto.I18N_PREFIX, SymptomsDto.ONSET_DATE)))); admissionDateField.addValidator(new DateComparisonValidator(admissionDateField, dischargeDateField, true, false, I18nProperties.getValidationError(Validations.beforeDate, admissionDateField.getCaption(), dischargeDateField.getCaption()))); admissionDateField.setInvalidCommitted(true); dischargeDateField.addValidator(new DateComparisonValidator(dischargeDateField, admissionDateField, false, false, I18nProperties.getValidationError(Validations.afterDate, dischargeDateField.getCaption(), admissionDateField.getCaption()))); hospitalizedPreviouslyField.addValueChangeListener(e -> { updatePrevHospHint(hospitalizedPreviouslyField, previousHospitalizationsField); }); previousHospitalizationsField.addValueChangeListener(e -> { updatePrevHospHint(hospitalizedPreviouslyField, previousHospitalizationsField); }); }
From source file:de.symeda.sormas.ui.hospitalization.PreviousHospitalizationEditForm.java
License:Open Source License
@Override protected void addFields() { DateField admissionDate = addField(PreviousHospitalizationDto.ADMISSION_DATE, DateField.class); DateField dischargeDate = addField(PreviousHospitalizationDto.DISCHARGE_DATE, DateField.class); addField(PreviousHospitalizationDto.ISOLATED, OptionGroup.class); addField(PreviousHospitalizationDto.DESCRIPTION, TextArea.class).setRows(2); ComboBox facilityRegion = addField(PreviousHospitalizationDto.REGION, ComboBox.class); ComboBox facilityDistrict = addField(PreviousHospitalizationDto.DISTRICT, ComboBox.class); ComboBox facilityCommunity = addField(PreviousHospitalizationDto.COMMUNITY, ComboBox.class); facilityCommunity.setNullSelectionAllowed(true); ComboBox healthFacility = addField(PreviousHospitalizationDto.HEALTH_FACILITY, ComboBox.class); TextField healthFacilityDetails = addField(CaseDataDto.HEALTH_FACILITY_DETAILS, TextField.class); healthFacilityDetails.setVisible(false); healthFacility.setImmediate(true);/*from w w w . j a v a 2s . c o m*/ facilityRegion.addValueChangeListener(e -> { RegionReferenceDto regionDto = (RegionReferenceDto) e.getProperty().getValue(); FieldHelper.updateItems(facilityDistrict, regionDto != null ? FacadeProvider.getDistrictFacade().getAllByRegion(regionDto.getUuid()) : null); }); facilityDistrict.addValueChangeListener(e -> { if (facilityCommunity.getValue() == null) { FieldHelper.removeItems(healthFacility); } FieldHelper.removeItems(facilityCommunity); DistrictReferenceDto districtDto = (DistrictReferenceDto) e.getProperty().getValue(); FieldHelper.updateItems(facilityCommunity, districtDto != null ? FacadeProvider.getCommunityFacade().getAllByDistrict(districtDto.getUuid()) : null); FieldHelper.updateItems(healthFacility, districtDto != null ? FacadeProvider.getFacilityFacade().getHealthFacilitiesByDistrict(districtDto, true) : null); }); facilityCommunity.addValueChangeListener(e -> { FieldHelper.removeItems(healthFacility); CommunityReferenceDto communityDto = (CommunityReferenceDto) e.getProperty().getValue(); FieldHelper.updateItems(healthFacility, communityDto != null ? FacadeProvider.getFacilityFacade().getHealthFacilitiesByCommunity(communityDto, true) : facilityDistrict.getValue() != null ? FacadeProvider.getFacilityFacade() .getHealthFacilitiesByDistrict((DistrictReferenceDto) facilityDistrict.getValue(), true) : null); }); facilityRegion.addItems(FacadeProvider.getRegionFacade().getAllAsReference()); healthFacility.addValueChangeListener(e -> { if (e.getProperty().getValue() != null) { boolean otherHealthFacility = ((FacilityReferenceDto) e.getProperty().getValue()).getUuid() .equals(FacilityDto.OTHER_FACILITY_UUID); boolean noneHealthFacility = ((FacilityReferenceDto) e.getProperty().getValue()).getUuid() .equals(FacilityDto.NONE_FACILITY_UUID); boolean visibleAndRequired = otherHealthFacility || noneHealthFacility; healthFacilityDetails.setVisible(visibleAndRequired); healthFacilityDetails.setRequired(visibleAndRequired); if (otherHealthFacility) { healthFacilityDetails.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.HEALTH_FACILITY_DETAILS)); } if (noneHealthFacility) { healthFacilityDetails.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.NONE_HEALTH_FACILITY_DETAILS)); } if (!visibleAndRequired) { healthFacilityDetails.clear(); } } else { healthFacilityDetails.setVisible(false); healthFacilityDetails.setRequired(false); healthFacilityDetails.clear(); } }); // Validations admissionDate.addValidator(new DateComparisonValidator(admissionDate, dischargeDate, true, false, I18nProperties.getValidationError(Validations.beforeDate, admissionDate.getCaption(), dischargeDate.getCaption()))); dischargeDate.addValidator(new DateComparisonValidator(dischargeDate, admissionDate, false, false, I18nProperties.getValidationError(Validations.afterDate, dischargeDate.getCaption(), admissionDate.getCaption()))); FieldHelper.addSoftRequiredStyle(admissionDate, dischargeDate, facilityCommunity, healthFacilityDetails); setRequired(true, PreviousHospitalizationDto.REGION, PreviousHospitalizationDto.DISTRICT, PreviousHospitalizationDto.HEALTH_FACILITY); }
From source file:de.symeda.sormas.ui.person.PersonEditForm.java
License:Open Source License
@Override protected void addFields() { if (!initialized) { // vars have to be set first return;/* ww w . j a va 2 s.c o m*/ } addField(PersonDto.FIRST_NAME, TextField.class); addField(PersonDto.LAST_NAME, TextField.class); ComboBox sex = addField(PersonDto.SEX, ComboBox.class); addField(PersonDto.NICKNAME, TextField.class); addField(PersonDto.MOTHERS_MAIDEN_NAME, TextField.class); addFields(PersonDto.MOTHERS_NAME, PersonDto.FATHERS_NAME); ComboBox presentCondition = addField(PersonDto.PRESENT_CONDITION, ComboBox.class); birthDateDay = addField(PersonDto.BIRTH_DATE_DD, ComboBox.class); // @TODO: Done for nullselection Bug, fixed in Vaadin 7.7.3 birthDateDay.setNullSelectionAllowed(true); ComboBox birthDateMonth = addField(PersonDto.BIRTH_DATE_MM, ComboBox.class); // @TODO: Done for nullselection Bug, fixed in Vaadin 7.7.3 birthDateMonth.setNullSelectionAllowed(true); birthDateMonth.addItems(DateHelper.getMonthsInYear()); birthDateMonth.setPageLength(12); setItemCaptionsForMonths(birthDateMonth); ComboBox birthDateYear = addField(PersonDto.BIRTH_DATE_YYYY, ComboBox.class); birthDateYear.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.BIRTH_DATE)); // @TODO: Done for nullselection Bug, fixed in Vaadin 7.7.3 birthDateYear.setNullSelectionAllowed(true); birthDateYear.addItems(DateHelper.getYearsToNow()); birthDateYear.setItemCaptionMode(ItemCaptionMode.ID_TOSTRING); DateField deathDate = addField(PersonDto.DEATH_DATE, DateField.class); TextField approximateAgeField = addField(PersonDto.APPROXIMATE_AGE, TextField.class); ComboBox approximateAgeTypeField = addField(PersonDto.APPROXIMATE_AGE_TYPE, ComboBox.class); addField(PersonDto.APPROXIMATE_AGE_REFERENCE_DATE, DateField.class); TextField tfGestationAgeAtBirth = addField(PersonDto.GESTATION_AGE_AT_BIRTH, TextField.class); tfGestationAgeAtBirth.setConversionError(I18nProperties.getValidationError(Validations.onlyNumbersAllowed, tfGestationAgeAtBirth.getCaption())); TextField tfBirthWeight = addField(PersonDto.BIRTH_WEIGHT, TextField.class); tfBirthWeight.setConversionError( I18nProperties.getValidationError(Validations.onlyNumbersAllowed, tfBirthWeight.getCaption())); AbstractSelect deathPlaceType = addField(PersonDto.DEATH_PLACE_TYPE, ComboBox.class); deathPlaceType.setNullSelectionAllowed(true); TextField deathPlaceDesc = addField(PersonDto.DEATH_PLACE_DESCRIPTION, TextField.class); DateField burialDate = addField(PersonDto.BURIAL_DATE, DateField.class); TextField burialPlaceDesc = addField(PersonDto.BURIAL_PLACE_DESCRIPTION, TextField.class); ComboBox burialConductor = addField(PersonDto.BURIAL_CONDUCTOR, ComboBox.class); addField(PersonDto.ADDRESS, LocationEditForm.class).setCaption(null); addField(PersonDto.PHONE, TextField.class); addField(PersonDto.PHONE_OWNER, TextField.class); addFields(PersonDto.OCCUPATION_TYPE, PersonDto.OCCUPATION_DETAILS, PersonDto.EDUCATION_TYPE, PersonDto.EDUCATION_DETAILS); ComboBox cbPlaceOfBirthRegion = addField(PersonDto.PLACE_OF_BIRTH_REGION, ComboBox.class); ComboBox cbPlaceOfBirthDistrict = addField(PersonDto.PLACE_OF_BIRTH_DISTRICT, ComboBox.class); ComboBox cbPlaceOfBirthCommunity = addField(PersonDto.PLACE_OF_BIRTH_COMMUNITY, ComboBox.class); ComboBox cbPlaceOfBirthFacility = addField(PersonDto.PLACE_OF_BIRTH_FACILITY, ComboBox.class); TextField tfPlaceOfBirthFacilityDetails = addField(PersonDto.PLACE_OF_BIRTH_FACILITY_DETAILS, TextField.class); causeOfDeathField = addField(PersonDto.CAUSE_OF_DEATH, ComboBox.class); causeOfDeathDiseaseField = addDiseaseField(PersonDto.CAUSE_OF_DEATH_DISEASE, true); causeOfDeathDetailsField = addField(PersonDto.CAUSE_OF_DEATH_DETAILS, TextField.class); ComboBox facilityRegion = addField(PersonDto.OCCUPATION_REGION, ComboBox.class); facilityRegion.setImmediate(true); facilityRegion.setNullSelectionAllowed(true); ComboBox facilityDistrict = addField(PersonDto.OCCUPATION_DISTRICT, ComboBox.class); facilityDistrict.setImmediate(true); facilityDistrict.setNullSelectionAllowed(true); ComboBox facilityCommunity = addField(PersonDto.OCCUPATION_COMMUNITY, ComboBox.class); facilityCommunity.setImmediate(true); facilityCommunity.setNullSelectionAllowed(true); occupationFacility = addField(PersonDto.OCCUPATION_FACILITY, ComboBox.class); occupationFacility.setImmediate(true); occupationFacility.setNullSelectionAllowed(true); occupationFacilityDetails = addField(PersonDto.OCCUPATION_FACILITY_DETAILS, TextField.class); // Set requirements that don't need visibility changes and read only status setReadOnly(true, PersonDto.APPROXIMATE_AGE_REFERENCE_DATE); setRequired(true, PersonDto.FIRST_NAME, PersonDto.LAST_NAME); setVisible(false, PersonDto.OCCUPATION_DETAILS, PersonDto.OCCUPATION_FACILITY, PersonDto.OCCUPATION_FACILITY_DETAILS, PersonDto.OCCUPATION_REGION, PersonDto.OCCUPATION_DISTRICT, PersonDto.OCCUPATION_COMMUNITY, PersonDto.DEATH_DATE, PersonDto.DEATH_PLACE_TYPE, PersonDto.DEATH_PLACE_DESCRIPTION, PersonDto.BURIAL_DATE, PersonDto.BURIAL_PLACE_DESCRIPTION, PersonDto.BURIAL_CONDUCTOR, PersonDto.CAUSE_OF_DEATH, PersonDto.CAUSE_OF_DEATH_DETAILS, PersonDto.CAUSE_OF_DEATH_DISEASE); FieldHelper.setVisibleWhen(getFieldGroup(), PersonDto.EDUCATION_DETAILS, PersonDto.EDUCATION_TYPE, Arrays.asList(EducationType.OTHER), true); FieldHelper.addSoftRequiredStyle(presentCondition, sex, deathDate, deathPlaceDesc, deathPlaceType, causeOfDeathField, causeOfDeathDiseaseField, causeOfDeathDetailsField, burialDate, burialPlaceDesc, burialConductor); // Set initial visibilities initializeVisibilitiesAndAllowedVisibilities(disease, viewMode); if (!getField(PersonDto.OCCUPATION_TYPE).isVisible() && !getField(PersonDto.EDUCATION_TYPE).isVisible()) occupationHeader.setVisible(false); if (!getField(PersonDto.ADDRESS).isVisible()) addressHeader.setVisible(false); // Add listeners FieldHelper.setRequiredWhenNotNull(getFieldGroup(), PersonDto.APPROXIMATE_AGE, PersonDto.APPROXIMATE_AGE_TYPE); addFieldListeners(PersonDto.APPROXIMATE_AGE, e -> { @SuppressWarnings("unchecked") Field<ApproximateAgeType> ageTypeField = (Field<ApproximateAgeType>) getField( PersonDto.APPROXIMATE_AGE_TYPE); if (e.getProperty().getValue() == null) { ageTypeField.clear(); } else { if (ageTypeField.isEmpty()) { ageTypeField.setValue(ApproximateAgeType.YEARS); } } }); addFieldListeners(PersonDto.BIRTH_DATE_DD, e -> { updateApproximateAge(); updateReadyOnlyApproximateAge(); }); addFieldListeners(PersonDto.BIRTH_DATE_MM, e -> { updateApproximateAge(); updateReadyOnlyApproximateAge(); }); addFieldListeners(PersonDto.BIRTH_DATE_YYYY, e -> { updateApproximateAge(); updateReadyOnlyApproximateAge(); }); addFieldListeners(PersonDto.DEATH_DATE, e -> updateApproximateAge()); addFieldListeners(PersonDto.OCCUPATION_TYPE, e -> { updateOccupationFieldCaptions(); toogleOccupationMetaFields(); }); addListenersToInfrastructureFields(cbPlaceOfBirthRegion, cbPlaceOfBirthDistrict, cbPlaceOfBirthCommunity, cbPlaceOfBirthFacility, tfPlaceOfBirthFacilityDetails); addListenersToInfrastructureFields(facilityRegion, facilityDistrict, facilityCommunity, occupationFacility, occupationFacilityDetails); cbPlaceOfBirthRegion.addItems(FacadeProvider.getRegionFacade().getAllAsReference()); facilityRegion.addItems(FacadeProvider.getRegionFacade().getAllAsReference()); addFieldListeners(PersonDto.PRESENT_CONDITION, e -> toogleDeathAndBurialFields()); causeOfDeathField.addValueChangeListener(e -> { toggleCauseOfDeathFields( presentCondition.getValue() != PresentCondition.ALIVE && presentCondition.getValue() != null); }); causeOfDeathDiseaseField.addValueChangeListener(e -> { toggleCauseOfDeathFields( presentCondition.getValue() != PresentCondition.ALIVE && presentCondition.getValue() != null); }); addValueChangeListener(e -> { fillDeathAndBurialFields(deathPlaceType, deathPlaceDesc, burialPlaceDesc); }); deathDate.addValidator(new DateComparisonValidator(deathDate, this::calcBirthDateValue, false, false, I18nProperties.getValidationError(Validations.afterDate, deathDate.getCaption(), birthDateYear.getCaption()))); burialDate.addValidator(new DateComparisonValidator(burialDate, deathDate, false, false, I18nProperties .getValidationError(Validations.afterDate, burialDate.getCaption(), deathDate.getCaption()))); // Update the list of days according to the selected month and year birthDateYear.addValueChangeListener(e -> { updateListOfDays((Integer) e.getProperty().getValue(), (Integer) birthDateMonth.getValue()); }); birthDateMonth.addValueChangeListener(e -> { updateListOfDays((Integer) birthDateYear.getValue(), (Integer) e.getProperty().getValue()); }); }
From source file:de.symeda.sormas.ui.samples.SampleCreateForm.java
License:Open Source License
@Override protected void addFields() { // addField(SampleDto.SAMPLE_CODE, TextField.class); addField(SampleDto.LAB_SAMPLE_ID, TextField.class); DateTimeField sampleDateField = addField(SampleDto.SAMPLE_DATE_TIME, DateTimeField.class); addField(SampleDto.SAMPLE_MATERIAL, ComboBox.class); addField(SampleDto.SAMPLE_MATERIAL_TEXT, TextField.class); ComboBox sampleSource = addField(SampleDto.SAMPLE_SOURCE, ComboBox.class); DateField shipmentDate = addDateField(SampleDto.SHIPMENT_DATE, DateField.class, 7); addField(SampleDto.SHIPMENT_DETAILS, TextField.class); DateField receivedDate = addField(SampleDto.RECEIVED_DATE, DateField.class); ComboBox lab = addField(SampleDto.LAB, ComboBox.class); lab.addItems(FacadeProvider.getFacilityFacade().getAllLaboratories(true)); TextField labDetails = addField(SampleDto.LAB_DETAILS, TextField.class); labDetails.setVisible(false);/*from w w w .ja va 2s . co m*/ addField(SampleDto.SPECIMEN_CONDITION, ComboBox.class); addField(SampleDto.NO_TEST_POSSIBLE_REASON, TextField.class); addField(SampleDto.COMMENT, TextArea.class).setRows(2); CheckBox shipped = addField(SampleDto.SHIPPED, CheckBox.class); CheckBox received = addField(SampleDto.RECEIVED, CheckBox.class); initializeRequestedTests(); // Validators sampleDateField.addValidator(new DateComparisonValidator(sampleDateField, shipmentDate, true, false, I18nProperties.getValidationError(Validations.beforeDate, sampleDateField.getCaption(), shipmentDate.getCaption()))); sampleDateField.addValidator(new DateComparisonValidator(sampleDateField, receivedDate, true, false, I18nProperties.getValidationError(Validations.beforeDate, sampleDateField.getCaption(), receivedDate.getCaption()))); shipmentDate.addValidator(new DateComparisonValidator(shipmentDate, sampleDateField, false, false, I18nProperties.getValidationError(Validations.afterDate, shipmentDate.getCaption(), sampleDateField.getCaption()))); shipmentDate.addValidator(new DateComparisonValidator(shipmentDate, receivedDate, true, false, I18nProperties.getValidationError(Validations.beforeDate, shipmentDate.getCaption(), receivedDate.getCaption()))); receivedDate.addValidator(new DateComparisonValidator(receivedDate, sampleDateField, false, false, I18nProperties.getValidationError(Validations.afterDate, receivedDate.getCaption(), sampleDateField.getCaption()))); receivedDate.addValidator(new DateComparisonValidator(receivedDate, shipmentDate, false, false, I18nProperties.getValidationError(Validations.afterDate, receivedDate.getCaption(), shipmentDate.getCaption()))); FieldHelper.setVisibleWhen(getFieldGroup(), SampleDto.SAMPLE_MATERIAL_TEXT, SampleDto.SAMPLE_MATERIAL, Arrays.asList(SampleMaterial.OTHER), true); FieldHelper.setVisibleWhen(getFieldGroup(), SampleDto.NO_TEST_POSSIBLE_REASON, SampleDto.SPECIMEN_CONDITION, Arrays.asList(SpecimenCondition.NOT_ADEQUATE), true); FieldHelper.setRequiredWhen(getFieldGroup(), SampleDto.SAMPLE_MATERIAL, Arrays.asList(SampleDto.SAMPLE_MATERIAL_TEXT), Arrays.asList(SampleMaterial.OTHER)); FieldHelper.setRequiredWhen(getFieldGroup(), SampleDto.SPECIMEN_CONDITION, Arrays.asList(SampleDto.NO_TEST_POSSIBLE_REASON), Arrays.asList(SpecimenCondition.NOT_ADEQUATE)); setRequired(true, SampleDto.SAMPLE_DATE_TIME, SampleDto.SAMPLE_MATERIAL, SampleDto.LAB); addValueChangeListener(e -> { CaseDataDto caze = FacadeProvider.getCaseFacade() .getCaseDataByUuid(getValue().getAssociatedCase().getUuid()); if (caze.getDisease() != Disease.NEW_INFLUENCA) { sampleSource.setVisible(false); } FieldHelper.setEnabledWhen(getFieldGroup(), shipped, Arrays.asList(true), Arrays.asList(SampleDto.SHIPMENT_DATE, SampleDto.SHIPMENT_DETAILS), true); FieldHelper.setRequiredWhen(getFieldGroup(), shipped, Arrays.asList(SampleDto.SHIPMENT_DATE), Arrays.asList(true)); FieldHelper.setRequiredWhen(getFieldGroup(), received, Arrays.asList(SampleDto.RECEIVED_DATE, SampleDto.SPECIMEN_CONDITION), Arrays.asList(true)); FieldHelper.setEnabledWhen(getFieldGroup(), received, Arrays.asList(true), Arrays.asList(SampleDto.RECEIVED_DATE, SampleDto.LAB_SAMPLE_ID, SampleDto.SPECIMEN_CONDITION, SampleDto.NO_TEST_POSSIBLE_REASON), true); }); shipped.addValueChangeListener(event -> { if ((boolean) event.getProperty().getValue() == true) { if (shipmentDate.getValue() == null) { shipmentDate.setValue(new Date()); } } }); received.addValueChangeListener(event -> { if ((boolean) event.getProperty().getValue() == true) { if (receivedDate.getValue() == null) { receivedDate.setValue(new Date()); } } }); lab.addValueChangeListener(e -> { if (e.getProperty().getValue() != null && ((FacilityReferenceDto) e.getProperty().getValue()).getUuid() .equals(FacilityDto.OTHER_LABORATORY_UUID)) { labDetails.setVisible(true); labDetails.setRequired(true); } else { labDetails.setVisible(false); labDetails.setRequired(false); labDetails.clear(); } }); }
From source file:de.symeda.sormas.ui.samples.SampleEditForm.java
License:Open Source License
@Override protected void addFields() { addField(SampleDto.LAB_SAMPLE_ID, TextField.class); DateTimeField sampleDateField = addField(SampleDto.SAMPLE_DATE_TIME, DateTimeField.class); sampleDateField.setInvalidCommitted(false); addField(SampleDto.SAMPLE_MATERIAL, ComboBox.class); addField(SampleDto.SAMPLE_MATERIAL_TEXT, TextField.class); ComboBox sampleSource = addField(SampleDto.SAMPLE_SOURCE, ComboBox.class); DateField shipmentDate = addDateField(SampleDto.SHIPMENT_DATE, DateField.class, 7); addField(SampleDto.SHIPMENT_DETAILS, TextField.class); DateField receivedDate = addField(SampleDto.RECEIVED_DATE, DateField.class); ComboBox lab = addField(SampleDto.LAB, ComboBox.class); lab.addItems(FacadeProvider.getFacilityFacade().getAllLaboratories(true)); TextField labDetails = addField(SampleDto.LAB_DETAILS, TextField.class); labDetails.setVisible(false);/*www . j a v a 2s .c o m*/ addField(SampleDto.SPECIMEN_CONDITION, ComboBox.class); addField(SampleDto.NO_TEST_POSSIBLE_REASON, TextField.class); addField(SampleDto.COMMENT, TextArea.class).setRows(2); CheckBox shipped = addField(SampleDto.SHIPPED, CheckBox.class); CheckBox received = addField(SampleDto.RECEIVED, CheckBox.class); ComboBox pathogenTestResultField = addField(SampleDto.PATHOGEN_TEST_RESULT, ComboBox.class); initializeRequestedTests(); // Validators sampleDateField.addValidator(new DateComparisonValidator(sampleDateField, shipmentDate, true, false, I18nProperties.getValidationError(Validations.beforeDate, sampleDateField.getCaption(), shipmentDate.getCaption()))); sampleDateField.addValidator(new DateComparisonValidator(sampleDateField, receivedDate, true, false, I18nProperties.getValidationError(Validations.beforeDate, sampleDateField.getCaption(), receivedDate.getCaption()))); shipmentDate.addValidator(new DateComparisonValidator(shipmentDate, sampleDateField, false, false, I18nProperties.getValidationError(Validations.afterDate, shipmentDate.getCaption(), sampleDateField.getCaption()))); shipmentDate.addValidator(new DateComparisonValidator(shipmentDate, receivedDate, true, false, I18nProperties.getValidationError(Validations.beforeDate, shipmentDate.getCaption(), receivedDate.getCaption()))); receivedDate.addValidator(new DateComparisonValidator(receivedDate, sampleDateField, false, false, I18nProperties.getValidationError(Validations.afterDate, receivedDate.getCaption(), sampleDateField.getCaption()))); receivedDate.addValidator(new DateComparisonValidator(receivedDate, shipmentDate, false, false, I18nProperties.getValidationError(Validations.afterDate, receivedDate.getCaption(), shipmentDate.getCaption()))); FieldHelper.setVisibleWhen(getFieldGroup(), SampleDto.SAMPLE_MATERIAL_TEXT, SampleDto.SAMPLE_MATERIAL, Arrays.asList(SampleMaterial.OTHER), true); FieldHelper.setVisibleWhen(getFieldGroup(), SampleDto.NO_TEST_POSSIBLE_REASON, SampleDto.SPECIMEN_CONDITION, Arrays.asList(SpecimenCondition.NOT_ADEQUATE), true); FieldHelper.setRequiredWhen(getFieldGroup(), SampleDto.SAMPLE_MATERIAL, Arrays.asList(SampleDto.SAMPLE_MATERIAL_TEXT), Arrays.asList(SampleMaterial.OTHER)); FieldHelper.setRequiredWhen(getFieldGroup(), SampleDto.SPECIMEN_CONDITION, Arrays.asList(SampleDto.NO_TEST_POSSIBLE_REASON), Arrays.asList(SpecimenCondition.NOT_ADEQUATE)); addValueChangeListener(e -> { CaseDataDto caze = FacadeProvider.getCaseFacade() .getCaseDataByUuid(getValue().getAssociatedCase().getUuid()); FieldHelper.setRequiredWhen(getFieldGroup(), received, Arrays.asList(SampleDto.RECEIVED_DATE, SampleDto.SPECIMEN_CONDITION), Arrays.asList(true)); FieldHelper.setEnabledWhen(getFieldGroup(), received, Arrays.asList(true), Arrays.asList(SampleDto.RECEIVED_DATE, SampleDto.LAB_SAMPLE_ID, SampleDto.SPECIMEN_CONDITION, SampleDto.NO_TEST_POSSIBLE_REASON), true); if (caze.getDisease() != Disease.NEW_INFLUENCA) { sampleSource.setVisible(false); } if (UserProvider.getCurrent().hasUserRight(UserRight.SAMPLE_EDIT_NOT_OWNED) || UserProvider.getCurrent().getUuid().equals(getValue().getReportingUser().getUuid())) { FieldHelper.setEnabledWhen(getFieldGroup(), shipped, Arrays.asList(true), Arrays.asList(SampleDto.SHIPMENT_DATE, SampleDto.SHIPMENT_DETAILS), true); FieldHelper.setRequiredWhen(getFieldGroup(), shipped, Arrays.asList(SampleDto.SHIPMENT_DATE), Arrays.asList(true)); setRequired(true, SampleDto.SAMPLE_DATE_TIME, SampleDto.SAMPLE_MATERIAL, SampleDto.LAB); } else { getField(SampleDto.SAMPLE_DATE_TIME).setEnabled(false); getField(SampleDto.SAMPLE_MATERIAL).setEnabled(false); getField(SampleDto.SAMPLE_MATERIAL_TEXT).setEnabled(false); getField(SampleDto.LAB).setEnabled(false); getField(SampleDto.SHIPPED).setEnabled(false); getField(SampleDto.SHIPMENT_DATE).setEnabled(false); getField(SampleDto.SHIPMENT_DETAILS).setEnabled(false); getField(SampleDto.SAMPLE_SOURCE).setEnabled(false); } shipped.addValueChangeListener(event -> { if ((boolean) event.getProperty().getValue() == true) { if (shipmentDate.getValue() == null) { shipmentDate.setValue(new Date()); } } }); received.addValueChangeListener(event -> { if ((boolean) event.getProperty().getValue() == true) { if (receivedDate.getValue() == null) { receivedDate.setValue(new Date()); } } }); // Initialize referral and report information VerticalLayout reportInfoLayout = new VerticalLayout(); String reportInfoText = I18nProperties.getString(Strings.reportedOn) + " " + DateHelper.formatLocalDateTime(getValue().getReportDateTime()) + " " + I18nProperties.getString(Strings.by) + " " + getValue().getReportingUser().toString(); Label reportInfoLabel = new Label(reportInfoText); reportInfoLabel.setEnabled(false); reportInfoLayout.addComponent(reportInfoLabel); SampleReferenceDto referredFromRef = FacadeProvider.getSampleFacade() .getReferredFrom(getValue().getUuid()); if (referredFromRef != null) { SampleDto referredFrom = FacadeProvider.getSampleFacade() .getSampleByUuid(referredFromRef.getUuid()); Button referredButton = new Button(I18nProperties.getCaption(Captions.sampleReferredFrom) + " " + referredFrom.getLab().toString()); referredButton.addStyleName(ValoTheme.BUTTON_LINK); referredButton.addStyleName(CssStyles.VSPACE_NONE); referredButton.addClickListener( s -> ControllerProvider.getSampleController().navigateToData(referredFrom.getUuid())); reportInfoLayout.addComponent(referredButton); } getContent().addComponent(reportInfoLayout, REPORT_INFORMATION_LOC); if (FacadeProvider.getPathogenTestFacade().hasPathogenTest(getValue().toReference())) { pathogenTestResultField.setRequired(true); } else { pathogenTestResultField.setEnabled(false); } }); lab.addValueChangeListener(event -> { if (event.getProperty().getValue() != null && ((FacilityReferenceDto) event.getProperty().getValue()) .getUuid().equals(FacilityDto.OTHER_LABORATORY_UUID)) { labDetails.setVisible(true); labDetails.setRequired(true); } else { labDetails.setVisible(false); labDetails.setRequired(false); labDetails.clear(); } }); }
From source file:de.symeda.sormas.ui.symptoms.SymptomsForm.java
License:Open Source License
@Override protected void addFields() { if (disease == null || symptomsContext == null) { // workaround to stop initialization until disease is set return;/* www .j a v a 2s .c om*/ } // Add fields DateField onsetDateField = addField(SymptomsDto.ONSET_DATE, DateField.class); ComboBox onsetSymptom = addField(SymptomsDto.ONSET_SYMPTOM, ComboBox.class); if (symptomsContext == SymptomsContext.CASE) { onsetDateField.addValidator(new DateComparisonValidator(onsetDateField, caze.getHospitalization().getAdmissionDate(), true, false, I18nProperties.getValidationError(Validations.beforeDateSoft, onsetDateField.getCaption(), I18nProperties.getPrefixCaption(HospitalizationDto.I18N_PREFIX, HospitalizationDto.ADMISSION_DATE)))); onsetDateField.setInvalidCommitted(true); } ComboBox temperature = addField(SymptomsDto.TEMPERATURE, ComboBox.class); 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(SymptomsDto.TEMPERATURE_SOURCE); ComboBox bloodPressureSystolic = addField(SymptomsDto.BLOOD_PRESSURE_SYSTOLIC, ComboBox.class); bloodPressureSystolic.addItems(SymptomsHelper.getBloodPressureValues()); ComboBox bloodPressureDiastolic = addField(SymptomsDto.BLOOD_PRESSURE_DIASTOLIC, ComboBox.class); bloodPressureDiastolic.addItems(SymptomsHelper.getBloodPressureValues()); ComboBox heartRate = addField(SymptomsDto.HEART_RATE, ComboBox.class); heartRate.addItems(SymptomsHelper.getHeartRateValues()); ComboBox respiratoryRate = addField(SymptomsDto.RESPIRATORY_RATE, ComboBox.class); respiratoryRate.addItems(SymptomsHelper.getRespiratoryRateValues()); ComboBox weight = addField(SymptomsDto.WEIGHT, ComboBox.class); for (Integer weightValue : SymptomsHelper.getWeightValues()) { weight.addItem(weightValue); weight.setItemCaption(weightValue, SymptomsHelper.getDecimalString(weightValue)); } ComboBox height = addField(SymptomsDto.HEIGHT, ComboBox.class); height.addItems(SymptomsHelper.getHeightValues()); ComboBox midUpperArmCircumference = addField(SymptomsDto.MID_UPPER_ARM_CIRCUMFERENCE, ComboBox.class); for (Integer circumferenceValue : SymptomsHelper.getMidUpperArmCircumferenceValues()) { midUpperArmCircumference.addItem(circumferenceValue); midUpperArmCircumference.setItemCaption(circumferenceValue, SymptomsHelper.getDecimalString(circumferenceValue)); } ComboBox glasgowComaScale = addField(SymptomsDto.GLASGOW_COMA_SCALE, ComboBox.class); glasgowComaScale.addItems(SymptomsHelper.getGlasgowComaScaleValues()); addFields(SymptomsDto.FEVER, SymptomsDto.VOMITING, SymptomsDto.DIARRHEA, SymptomsDto.BLOOD_IN_STOOL, SymptomsDto.NAUSEA, SymptomsDto.ABDOMINAL_PAIN, SymptomsDto.HEADACHE, SymptomsDto.MUSCLE_PAIN, SymptomsDto.FATIGUE_WEAKNESS, SymptomsDto.SKIN_RASH, SymptomsDto.NECK_STIFFNESS, SymptomsDto.SORE_THROAT, SymptomsDto.COUGH, SymptomsDto.RUNNY_NOSE, SymptomsDto.DIFFICULTY_BREATHING, SymptomsDto.CHEST_PAIN, SymptomsDto.CONJUNCTIVITIS, SymptomsDto.EYE_PAIN_LIGHT_SENSITIVE, SymptomsDto.KOPLIKS_SPOTS, SymptomsDto.THROBOCYTOPENIA, SymptomsDto.OTITIS_MEDIA, SymptomsDto.HEARINGLOSS, SymptomsDto.DEHYDRATION, SymptomsDto.ANOREXIA_APPETITE_LOSS, SymptomsDto.REFUSAL_FEEDOR_DRINK, SymptomsDto.JOINT_PAIN, SymptomsDto.HICCUPS, SymptomsDto.BACKACHE, SymptomsDto.EYES_BLEEDING, SymptomsDto.JAUNDICE, SymptomsDto.DARK_URINE, SymptomsDto.STOMACH_BLEEDING, SymptomsDto.RAPID_BREATHING, SymptomsDto.SWOLLEN_GLANDS, SymptomsDto.SYMPTOMS_COMMENTS, SymptomsDto.UNEXPLAINED_BLEEDING, SymptomsDto.GUMS_BLEEDING, SymptomsDto.INJECTION_SITE_BLEEDING, SymptomsDto.NOSE_BLEEDING, SymptomsDto.BLOODY_BLACK_STOOL, SymptomsDto.RED_BLOOD_VOMIT, SymptomsDto.DIGESTED_BLOOD_VOMIT, SymptomsDto.COUGHING_BLOOD, SymptomsDto.BLEEDING_VAGINA, SymptomsDto.SKIN_BRUISING, SymptomsDto.BLOOD_URINE, SymptomsDto.OTHER_HEMORRHAGIC_SYMPTOMS, SymptomsDto.OTHER_HEMORRHAGIC_SYMPTOMS_TEXT, SymptomsDto.OTHER_NON_HEMORRHAGIC_SYMPTOMS, SymptomsDto.OTHER_NON_HEMORRHAGIC_SYMPTOMS_TEXT, SymptomsDto.LESIONS, SymptomsDto.LESIONS_THAT_ITCH, SymptomsDto.LESIONS_SAME_STATE, SymptomsDto.LESIONS_SAME_SIZE, SymptomsDto.LESIONS_DEEP_PROFOUND, SymptomsDto.LESIONS_FACE, SymptomsDto.LESIONS_LEGS, SymptomsDto.LESIONS_SOLES_FEET, SymptomsDto.LESIONS_PALMS_HANDS, SymptomsDto.LESIONS_THORAX, SymptomsDto.LESIONS_ARMS, SymptomsDto.LESIONS_GENITALS, SymptomsDto.LESIONS_ALL_OVER_BODY, SymptomsDto.LYMPHADENOPATHY_AXILLARY, SymptomsDto.LYMPHADENOPATHY_CERVICAL, SymptomsDto.LYMPHADENOPATHY_INGUINAL, SymptomsDto.CHILLS_SWEATS, SymptomsDto.BEDRIDDEN, SymptomsDto.ORAL_ULCERS, SymptomsDto.PAINFUL_LYMPHADENITIS, SymptomsDto.BLACKENING_DEATH_OF_TISSUE, SymptomsDto.BUBOES_GROIN_ARMPIT_NECK, SymptomsDto.BULGING_FONTANELLE, SymptomsDto.PHARYNGEAL_ERYTHEMA, SymptomsDto.PHARYNGEAL_EXUDATE, SymptomsDto.OEDEMA_FACE_NECK, SymptomsDto.OEDEMA_LOWER_EXTREMITY, SymptomsDto.LOSS_SKIN_TURGOR, SymptomsDto.PALPABLE_LIVER, SymptomsDto.PALPABLE_SPLEEN, SymptomsDto.MALAISE, SymptomsDto.SUNKEN_EYES_FONTANELLE, SymptomsDto.SIDE_PAIN, SymptomsDto.FLUID_IN_LUNG_CAVITY, SymptomsDto.TREMOR, SymptomsDto.BILATERAL_CATARACTS, SymptomsDto.UNILATERAL_CATARACTS, SymptomsDto.CONGENITAL_GLAUCOMA, SymptomsDto.CONGENITAL_HEART_DISEASE, SymptomsDto.PIGMENTARY_RETINOPATHY, SymptomsDto.RADIOLUCENT_BONE_DISEASE, SymptomsDto.SPLENOMEGALY, SymptomsDto.MICROCEPHALY, SymptomsDto.MENINGOENCEPHALITIS, SymptomsDto.PURPURIC_RASH, SymptomsDto.DEVELOPMENTAL_DELAY, SymptomsDto.CONGENITAL_HEART_DISEASE_TYPE, SymptomsDto.CONGENITAL_HEART_DISEASE_DETAILS, SymptomsDto.JAUNDICE_WITHIN_24_HOURS_OF_BIRTH, SymptomsDto.PATIENT_ILL_LOCATION); addField(SymptomsDto.LESIONS_ONSET_DATE, DateField.class); // complications addFields(SymptomsDto.ALTERED_CONSCIOUSNESS, SymptomsDto.CONFUSED_DISORIENTED, SymptomsDto.HEMORRHAGIC_SYNDROME, SymptomsDto.HYPERGLYCEMIA, SymptomsDto.HYPOGLYCEMIA, SymptomsDto.MENINGEAL_SIGNS, SymptomsDto.SEIZURES, SymptomsDto.SEPSIS, SymptomsDto.SHOCK); monkeypoxImageFieldIds = Arrays.asList(SymptomsDto.LESIONS_RESEMBLE_IMG1, SymptomsDto.LESIONS_RESEMBLE_IMG2, SymptomsDto.LESIONS_RESEMBLE_IMG3, SymptomsDto.LESIONS_RESEMBLE_IMG4); for (String propertyId : monkeypoxImageFieldIds) { @SuppressWarnings("rawtypes") Field monkeypoxImageField = addField(propertyId); CssStyles.style(monkeypoxImageField, CssStyles.VSPACE_NONE); } // Set initial visibilities initializeVisibilitiesAndAllowedVisibilities(disease, viewMode); if (symptomsContext != SymptomsContext.CLINICAL_VISIT) { setVisible(false, SymptomsDto.BLOOD_PRESSURE_SYSTOLIC, SymptomsDto.BLOOD_PRESSURE_DIASTOLIC, SymptomsDto.HEART_RATE, SymptomsDto.RESPIRATORY_RATE, SymptomsDto.WEIGHT, SymptomsDto.HEIGHT, SymptomsDto.MID_UPPER_ARM_CIRCUMFERENCE, SymptomsDto.GLASGOW_COMA_SCALE); } else { setVisible(false, SymptomsDto.ONSET_SYMPTOM, SymptomsDto.ONSET_DATE); } // Initialize lists conditionalBleedingSymptomFieldIds = Arrays.asList(SymptomsDto.GUMS_BLEEDING, SymptomsDto.INJECTION_SITE_BLEEDING, SymptomsDto.NOSE_BLEEDING, SymptomsDto.BLOODY_BLACK_STOOL, SymptomsDto.RED_BLOOD_VOMIT, SymptomsDto.DIGESTED_BLOOD_VOMIT, SymptomsDto.EYES_BLEEDING, SymptomsDto.COUGHING_BLOOD, SymptomsDto.BLEEDING_VAGINA, SymptomsDto.SKIN_BRUISING, SymptomsDto.STOMACH_BLEEDING, SymptomsDto.BLOOD_URINE, SymptomsDto.OTHER_HEMORRHAGIC_SYMPTOMS); lesionsFieldIds = Arrays.asList(SymptomsDto.LESIONS_SAME_STATE, SymptomsDto.LESIONS_SAME_SIZE, SymptomsDto.LESIONS_DEEP_PROFOUND, SymptomsDto.LESIONS_THAT_ITCH); lesionsLocationFieldIds = Arrays.asList(SymptomsDto.LESIONS_FACE, SymptomsDto.LESIONS_LEGS, SymptomsDto.LESIONS_SOLES_FEET, SymptomsDto.LESIONS_PALMS_HANDS, SymptomsDto.LESIONS_THORAX, SymptomsDto.LESIONS_ARMS, SymptomsDto.LESIONS_GENITALS, SymptomsDto.LESIONS_ALL_OVER_BODY); unconditionalSymptomFieldIds = Arrays.asList(SymptomsDto.FEVER, SymptomsDto.VOMITING, SymptomsDto.DIARRHEA, SymptomsDto.BLOOD_IN_STOOL, SymptomsDto.NAUSEA, SymptomsDto.ABDOMINAL_PAIN, SymptomsDto.HEADACHE, SymptomsDto.MUSCLE_PAIN, SymptomsDto.FATIGUE_WEAKNESS, SymptomsDto.SKIN_RASH, SymptomsDto.NECK_STIFFNESS, SymptomsDto.SORE_THROAT, SymptomsDto.COUGH, SymptomsDto.RUNNY_NOSE, SymptomsDto.DIFFICULTY_BREATHING, SymptomsDto.CHEST_PAIN, SymptomsDto.CONJUNCTIVITIS, SymptomsDto.EYE_PAIN_LIGHT_SENSITIVE, SymptomsDto.KOPLIKS_SPOTS, SymptomsDto.THROBOCYTOPENIA, SymptomsDto.OTITIS_MEDIA, SymptomsDto.HEARINGLOSS, SymptomsDto.DEHYDRATION, SymptomsDto.ANOREXIA_APPETITE_LOSS, SymptomsDto.REFUSAL_FEEDOR_DRINK, SymptomsDto.JOINT_PAIN, SymptomsDto.HICCUPS, SymptomsDto.BACKACHE, SymptomsDto.JAUNDICE, SymptomsDto.DARK_URINE, SymptomsDto.RAPID_BREATHING, SymptomsDto.SWOLLEN_GLANDS, SymptomsDto.UNEXPLAINED_BLEEDING, SymptomsDto.OTHER_NON_HEMORRHAGIC_SYMPTOMS, SymptomsDto.LESIONS, SymptomsDto.LYMPHADENOPATHY_AXILLARY, SymptomsDto.LYMPHADENOPATHY_CERVICAL, SymptomsDto.LYMPHADENOPATHY_INGUINAL, SymptomsDto.CHILLS_SWEATS, SymptomsDto.BEDRIDDEN, SymptomsDto.ORAL_ULCERS, SymptomsDto.PAINFUL_LYMPHADENITIS, SymptomsDto.BLACKENING_DEATH_OF_TISSUE, SymptomsDto.BUBOES_GROIN_ARMPIT_NECK, SymptomsDto.BULGING_FONTANELLE, SymptomsDto.PHARYNGEAL_ERYTHEMA, SymptomsDto.PHARYNGEAL_EXUDATE, SymptomsDto.OEDEMA_FACE_NECK, SymptomsDto.OEDEMA_LOWER_EXTREMITY, SymptomsDto.LOSS_SKIN_TURGOR, SymptomsDto.PALPABLE_LIVER, SymptomsDto.PALPABLE_SPLEEN, SymptomsDto.MALAISE, SymptomsDto.SUNKEN_EYES_FONTANELLE, SymptomsDto.SIDE_PAIN, SymptomsDto.FLUID_IN_LUNG_CAVITY, SymptomsDto.TREMOR, SymptomsDto.BILATERAL_CATARACTS, SymptomsDto.UNILATERAL_CATARACTS, SymptomsDto.CONGENITAL_GLAUCOMA, SymptomsDto.CONGENITAL_HEART_DISEASE, SymptomsDto.RADIOLUCENT_BONE_DISEASE, SymptomsDto.SPLENOMEGALY, SymptomsDto.MICROCEPHALY, SymptomsDto.MENINGOENCEPHALITIS, SymptomsDto.DEVELOPMENTAL_DELAY, SymptomsDto.PURPURIC_RASH, SymptomsDto.PIGMENTARY_RETINOPATHY, // complications SymptomsDto.ALTERED_CONSCIOUSNESS, SymptomsDto.CONFUSED_DISORIENTED, SymptomsDto.HEMORRHAGIC_SYNDROME, SymptomsDto.HYPERGLYCEMIA, SymptomsDto.HYPOGLYCEMIA, SymptomsDto.MENINGEAL_SIGNS, SymptomsDto.SEIZURES, SymptomsDto.SEPSIS, SymptomsDto.SHOCK); // Set visibilities FieldHelper.setVisibleWhen(getFieldGroup(), conditionalBleedingSymptomFieldIds, SymptomsDto.UNEXPLAINED_BLEEDING, Arrays.asList(SymptomState.YES), true, SymptomsDto.class, disease); FieldHelper.setVisibleWhen(getFieldGroup(), SymptomsDto.OTHER_HEMORRHAGIC_SYMPTOMS_TEXT, SymptomsDto.OTHER_HEMORRHAGIC_SYMPTOMS, Arrays.asList(SymptomState.YES), true); FieldHelper.setVisibleWhen(getFieldGroup(), SymptomsDto.OTHER_NON_HEMORRHAGIC_SYMPTOMS_TEXT, SymptomsDto.OTHER_NON_HEMORRHAGIC_SYMPTOMS, Arrays.asList(SymptomState.YES), true); FieldHelper.setVisibleWhen(getFieldGroup(), lesionsFieldIds, SymptomsDto.LESIONS, Arrays.asList(SymptomState.YES), true); FieldHelper.setVisibleWhen(getFieldGroup(), lesionsLocationFieldIds, SymptomsDto.LESIONS, Arrays.asList(SymptomState.YES), true); FieldHelper.setVisibleWhen(getFieldGroup(), SymptomsDto.LESIONS_ONSET_DATE, SymptomsDto.LESIONS, Arrays.asList(SymptomState.YES), true); FieldHelper.setVisibleWhen(getFieldGroup(), SymptomsDto.CONGENITAL_HEART_DISEASE_TYPE, SymptomsDto.CONGENITAL_HEART_DISEASE, Arrays.asList(SymptomState.YES), true); FieldHelper.setVisibleWhen(getFieldGroup(), SymptomsDto.CONGENITAL_HEART_DISEASE_DETAILS, SymptomsDto.CONGENITAL_HEART_DISEASE_TYPE, Arrays.asList(CongenitalHeartDiseaseType.OTHER), true); if (isVisibleAllowed(getFieldGroup().getField(SymptomsDto.JAUNDICE_WITHIN_24_HOURS_OF_BIRTH))) { FieldHelper.setVisibleWhen(getFieldGroup(), SymptomsDto.JAUNDICE_WITHIN_24_HOURS_OF_BIRTH, SymptomsDto.JAUNDICE, Arrays.asList(SymptomState.YES), true); } FieldHelper.addSoftRequiredStyle(getField(SymptomsDto.LESIONS_ONSET_DATE)); boolean isInfant = person != null && person.getApproximateAge() != null && ((person.getApproximateAge() <= 12 && person.getApproximateAgeType() == ApproximateAgeType.MONTHS) || person.getApproximateAge() <= 1); if (!isInfant) { getFieldGroup().getField(SymptomsDto.BULGING_FONTANELLE).setVisible(false); } // Handle visibility of lesions locations caption Label lesionsLocationsCaption = new Label(I18nProperties.getCaption(Captions.symptomsLesionsLocations)); CssStyles.style(lesionsLocationsCaption, CssStyles.VSPACE_3); getContent().addComponent(lesionsLocationsCaption, LESIONS_LOCATIONS_LOC); getContent().getComponent(LESIONS_LOCATIONS_LOC) .setVisible(getFieldGroup().getField(SymptomsDto.LESIONS).getValue() == SymptomState.YES); getFieldGroup().getField(SymptomsDto.LESIONS).addValueChangeListener(e -> { getContent().getComponent(LESIONS_LOCATIONS_LOC) .setVisible(e.getProperty().getValue() == SymptomState.YES); }); // Symptoms hint text Label symptomsHint = new Label( I18nProperties.getString(symptomsContext == SymptomsContext.CASE ? Strings.messageSymptomsHint : Strings.messageSymptomsVisitHint), ContentMode.HTML); getContent().addComponent(symptomsHint, SYMPTOMS_HINT_LOC); if (disease == Disease.MONKEYPOX) { setUpMonkeypoxVisibilities(); } if (symptomsContext != SymptomsContext.CASE) { getFieldGroup().getField(SymptomsDto.PATIENT_ILL_LOCATION).setVisible(false); } FieldHelper.setRequiredWhen(getFieldGroup(), getFieldGroup().getField(SymptomsDto.OTHER_HEMORRHAGIC_SYMPTOMS), Arrays.asList(SymptomsDto.OTHER_HEMORRHAGIC_SYMPTOMS_TEXT), Arrays.asList(SymptomState.YES), disease); FieldHelper.setRequiredWhen(getFieldGroup(), getFieldGroup().getField(SymptomsDto.OTHER_NON_HEMORRHAGIC_SYMPTOMS), Arrays.asList(SymptomsDto.OTHER_NON_HEMORRHAGIC_SYMPTOMS_TEXT), Arrays.asList(SymptomState.YES), disease); FieldHelper.setRequiredWhen(getFieldGroup(), getFieldGroup().getField(SymptomsDto.LESIONS), lesionsFieldIds, Arrays.asList(SymptomState.YES), disease); FieldHelper.setRequiredWhen(getFieldGroup(), getFieldGroup().getField(SymptomsDto.LESIONS), monkeypoxImageFieldIds, Arrays.asList(SymptomState.YES), disease); addListenerForOnsetFields(onsetSymptom, onsetDateField); Button clearAllButton = new Button(I18nProperties.getCaption(Captions.actionClearAll)); clearAllButton.addStyleName(ValoTheme.BUTTON_LINK); clearAllButton.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent 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); } } }); Button setEmptyToNoButton = new Button(I18nProperties.getCaption(Captions.symptomsSetClearedToNo)); setEmptyToNoButton.addStyleName(ValoTheme.BUTTON_LINK); setEmptyToNoButton.addClickListener(new ClickListener() { @SuppressWarnings("unchecked") @Override public void buttonClick(ClickEvent event) { for (Object symptomId : unconditionalSymptomFieldIds) { Field<SymptomState> symptom = (Field<SymptomState>) getFieldGroup().getField(symptomId); if (symptom.isVisible() && symptom.getValue() == null) { symptom.setValue(SymptomState.NO); } } for (Object symptomId : conditionalBleedingSymptomFieldIds) { Field<SymptomState> symptom = (Field<SymptomState>) getFieldGroup().getField(symptomId); if (symptom.isVisible() && symptom.getValue() == null) { symptom.setValue(SymptomState.NO); } } for (Object symptomId : lesionsFieldIds) { Field<SymptomState> symptom = (Field<SymptomState>) getFieldGroup().getField(symptomId); if (symptom.isVisible() && symptom.getValue() == null) { symptom.setValue(SymptomState.NO); } } for (Object symptomId : monkeypoxImageFieldIds) { Field<SymptomState> symptom = (Field<SymptomState>) getFieldGroup().getField(symptomId); if (symptom.isVisible() && symptom.getValue() == null) { symptom.setValue(SymptomState.NO); } } } }); // 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) { getContent().addComponent(complicationsHeading, COMPLICATIONS_HEADING); } HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.addComponent(clearAllButton); buttonsLayout.addComponent(setEmptyToNoButton); buttonsLayout.setDefaultComponentAlignment(Alignment.MIDDLE_RIGHT); getContent().addComponent(buttonsLayout, BUTTONS_LOC); }