use of com.vaadin.v7.ui.HorizontalLayout in project SORMAS-Project by hzi-braunschweig.
the class CasePickOrCreateField method addInfoComponent.
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.infoPickOrCreateCase));
infoLabel.setContentMode(ContentMode.HTML);
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.infoPickOrCreateCaseNewCase));
CssStyles.style(newCaseLabel, CssStyles.LABEL_BOLD, CssStyles.VSPACE_4);
caseInfoContainer.addComponent(newCaseLabel);
HorizontalLayout caseInfoLayout = new HorizontalLayout();
caseInfoLayout.setSpacing(true);
caseInfoLayout.setSizeUndefined();
{
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 responsibleDistrictField = new Label();
responsibleDistrictField.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.RESPONSIBLE_DISTRICT));
responsibleDistrictField.setValue(newCase.getResponsibleDistrict() != null ? newCase.getResponsibleDistrict().toString() : "");
responsibleDistrictField.setWidthUndefined();
caseInfoLayout.addComponent(responsibleDistrictField);
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 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 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);
Label classificationField = new Label();
classificationField.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.CASE_CLASSIFICATION));
classificationField.setValue(newCase.getCaseClassification().toString());
classificationField.setWidthUndefined();
caseInfoLayout.addComponent(classificationField);
Label outcomeField = new Label();
outcomeField.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.OUTCOME));
outcomeField.setValue(newCase.getOutcome().toString());
outcomeField.setWidthUndefined();
caseInfoLayout.addComponent(outcomeField);
}
caseInfoContainer.addComponent(caseInfoLayout);
mainLayout.addComponent(caseInfoContainer);
}
use of com.vaadin.v7.ui.HorizontalLayout in project SORMAS-Project by hzi-braunschweig.
the class CampaignEditForm method addFields.
@Override
protected void addFields() {
if (isCreateForm == null) {
return;
}
Label campaignBasicHeadingLabel = new Label(I18nProperties.getString(Strings.headingCampaignBasics));
campaignBasicHeadingLabel.addStyleName(H3);
getContent().addComponent(campaignBasicHeadingLabel, CAMPAIGN_BASIC_HEADING_LOC);
addField(CampaignDto.UUID, TextField.class);
addField(CampaignDto.CREATING_USER);
DateField startDate = addField(CampaignDto.START_DATE, DateField.class);
startDate.removeAllValidators();
DateField endDate = addField(CampaignDto.END_DATE, DateField.class);
endDate.removeAllValidators();
startDate.addValidator(new DateComparisonValidator(startDate, endDate, true, true, I18nProperties.getValidationError(Validations.beforeDate, startDate.getCaption(), endDate.getCaption())));
endDate.addValidator(new DateComparisonValidator(endDate, startDate, false, true, I18nProperties.getValidationError(Validations.afterDate, endDate.getCaption(), startDate.getCaption())));
addField(CampaignDto.NAME);
TextArea description = addField(CampaignDto.DESCRIPTION, TextArea.class);
description.setRows(6);
setReadOnly(true, CampaignDto.UUID, CampaignDto.CREATING_USER);
setVisible(!isCreateForm, CampaignDto.UUID, CampaignDto.CREATING_USER);
setRequired(true, CampaignDto.UUID, CampaignDto.CREATING_USER, CampaignDto.START_DATE, CampaignDto.END_DATE, CampaignDto.NAME);
FieldHelper.addSoftRequiredStyle(description);
final HorizontalLayout usageLayout = new HorizontalLayout();
usageLayout.setWidthFull();
Label usageLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml() + " " + I18nProperties.getString(Strings.infoUsageOfEditableCampaignGrids), ContentMode.HTML);
usageLabel.setWidthFull();
usageLayout.addComponent(usageLabel);
usageLayout.setSpacing(true);
usageLayout.setMargin(new MarginInfo(true, false, true, false));
getContent().addComponent(usageLayout, USAGE_INFO);
campaignFormsGridComponent = new CampaignFormsGridComponent(this.campaignDto == null ? Collections.EMPTY_LIST : new ArrayList<>(campaignDto.getCampaignFormMetas()), FacadeProvider.getCampaignFormMetaFacade().getAllCampaignFormMetasAsReferences());
getContent().addComponent(campaignFormsGridComponent, CAMPAIGN_DATA_LOC);
final List<CampaignDashboardElement> campaignDashboardElements = FacadeProvider.getCampaignFacade().getCampaignDashboardElements(null);
campaignDashboardGridComponent = new CampaignDashboardElementsGridComponent(this.campaignDto == null ? Collections.EMPTY_LIST : FacadeProvider.getCampaignFacade().getCampaignDashboardElements(campaignDto.getUuid()), campaignDashboardElements);
getContent().addComponent(campaignDashboardGridComponent, CAMPAIGN_DASHBOARD_LOC);
final Label spacer = new Label();
getContent().addComponent(spacer, SPACE_LOC);
addField(CampaignDto.DELETION_REASON);
addField(CampaignDto.OTHER_DELETION_REASON, TextArea.class).setRows(3);
setVisible(false, CampaignDto.DELETION_REASON, CampaignDto.OTHER_DELETION_REASON);
}
use of com.vaadin.v7.ui.HorizontalLayout in project SORMAS-Project by hzi-braunschweig.
the class CaseFilterForm method applyDependenciesOnNewValue.
@Override
protected void applyDependenciesOnNewValue(CaseCriteria criteria) {
final UserDto user = currentUserDto();
final JurisdictionLevel userJurisdictionLevel = UserRole.getJurisdictionLevel(UserProvider.getCurrent().getUserRoles());
final ComboBox districtField = getField(CaseDataDto.DISTRICT);
final ComboBox communityField = getField(CaseDataDto.COMMUNITY);
final ComboBox facilityTypeGroupField = getField(CaseCriteria.FACILITY_TYPE_GROUP);
final ComboBox facilityTypeField = getField(CaseCriteria.FACILITY_TYPE);
final ComboBox facilityField = getField(CaseDataDto.HEALTH_FACILITY);
final ComboBox pointOfEntryField = getField(CaseDataDto.POINT_OF_ENTRY);
// Disable all fields
clearAndDisableFields(districtField, communityField, facilityTypeGroupField, facilityTypeField, facilityField, pointOfEntryField);
// Get initial field values according to user and criteria
final RegionReferenceDto region = user.getRegion() == null ? criteria.getRegion() : user.getRegion();
final DistrictReferenceDto district = user.getDistrict() == null ? criteria.getDistrict() : user.getDistrict();
final CommunityReferenceDto community = user.getCommunity() == null ? criteria.getCommunity() : user.getCommunity();
final FacilityTypeGroup facilityTypeGroup = criteria.getFacilityTypeGroup();
final FacilityType facilityType = criteria.getFacilityType();
// district
if (region != null) {
enableFields(districtField);
districtField.addItems(FacadeProvider.getDistrictFacade().getAllActiveByRegion(region.getUuid()));
// community
if (district != null) {
districtField.setValue(district);
communityField.addItems(FacadeProvider.getCommunityFacade().getAllActiveByDistrict(district.getUuid()));
enableFields(communityField);
if (community != null) {
communityField.setValue(community);
}
} else {
clearAndDisableFields(communityField);
}
} else {
clearAndDisableFields(districtField, communityField);
}
// facility
if (userJurisdictionLevel == JurisdictionLevel.HEALTH_FACILITY) {
facilityField.setValue(user.getHealthFacility());
disableFields(facilityTypeGroupField, facilityTypeField, facilityField);
} else if (facilityTypeGroupField != null && district != null) {
enableFields(facilityTypeGroupField);
FieldHelper.updateEnumData(facilityTypeGroupField, FacilityTypeGroup.getAccomodationGroups());
if (facilityTypeGroup != null) {
facilityTypeGroupField.setValue(facilityTypeGroup);
enableFields(facilityTypeField);
FieldHelper.updateEnumData(facilityTypeField, FacilityType.getAccommodationTypes(facilityTypeGroup));
if (facilityType != null) {
facilityTypeField.setValue(facilityType);
enableFields(facilityField);
if (community != null) {
facilityField.addItems(FacadeProvider.getFacilityFacade().getActiveFacilitiesByCommunityAndType(community, facilityType, true, false));
} else {
facilityField.addItems(FacadeProvider.getFacilityFacade().getActiveFacilitiesByDistrictAndType(district, facilityType, true, false));
}
} else {
disableFields(facilityField);
}
} else {
disableFields(facilityTypeField);
}
}
if (pointOfEntryField != null && district != null) {
pointOfEntryField.setEnabled(criteria.getCaseOrigin() != CaseOrigin.IN_COUNTRY);
pointOfEntryField.addItems(FacadeProvider.getPointOfEntryFacade().getAllActiveByDistrict(district.getUuid(), true));
}
// Disable fields according to user & jurisdiction
if (userJurisdictionLevel == JurisdictionLevel.DISTRICT) {
clearAndDisableFields(districtField);
} else if (userJurisdictionLevel == JurisdictionLevel.COMMUNITY) {
clearAndDisableFields(districtField, communityField);
} else if (userJurisdictionLevel == JurisdictionLevel.HEALTH_FACILITY) {
clearAndDisableFields(districtField, communityField, facilityTypeGroupField, facilityTypeField, facilityField);
}
getField(CaseCriteria.MUST_BE_PORT_HEALTH_CASE_WITHOUT_FACILITY).setEnabled(criteria.getCaseOrigin() != CaseOrigin.IN_COUNTRY);
// Date/Epi week filter
HorizontalLayout dateFilterLayout = (HorizontalLayout) getMoreFiltersContainer().getComponent(WEEK_AND_DATE_FILTER);
@SuppressWarnings("unchecked") EpiWeekAndDateFilterComponent<NewCaseDateType> weekAndDateFilter = (EpiWeekAndDateFilterComponent<NewCaseDateType>) dateFilterLayout.getComponent(0);
weekAndDateFilter.getDateTypeSelector().setValue(criteria.getNewCaseDateType());
weekAndDateFilter.getDateFilterOptionFilter().setValue(criteria.getDateFilterOption());
Date newCaseDateFrom = criteria.getNewCaseDateFrom();
Date newCaseDateTo = criteria.getNewCaseDateTo();
if (newCaseDateFrom != null && newCaseDateTo != null) {
if (DateFilterOption.EPI_WEEK.equals(criteria.getDateFilterOption())) {
weekAndDateFilter.getWeekFromFilter().setValue(DateHelper.getEpiWeek(newCaseDateFrom));
weekAndDateFilter.getWeekToFilter().setValue(DateHelper.getEpiWeek(newCaseDateTo));
} else {
weekAndDateFilter.getDateFromFilter().setValue(criteria.getNewCaseDateFrom());
weekAndDateFilter.getDateToFilter().setValue(criteria.getNewCaseDateTo());
}
}
ComboBox birthDateDD = getField(CaseCriteria.BIRTHDATE_DD);
if (getField(CaseCriteria.BIRTHDATE_YYYY).getValue() != null && getField(CaseCriteria.BIRTHDATE_MM).getValue() != null) {
birthDateDD.addItems(DateHelper.getDaysInMonth((Integer) getField(CaseCriteria.BIRTHDATE_MM).getValue(), (Integer) getField(CaseCriteria.BIRTHDATE_YYYY).getValue()));
birthDateDD.setEnabled(true);
} else {
birthDateDD.clear();
birthDateDD.setEnabled(false);
}
ComboBox diseaseField = getField(CaseDataDto.DISEASE);
ComboBox diseaseVariantField = getField(CaseDataDto.DISEASE_VARIANT);
Disease disease = (Disease) diseaseField.getValue();
if (disease == null) {
FieldHelper.updateItems(diseaseVariantField, Collections.emptyList());
FieldHelper.setEnabled(false, diseaseVariantField);
} else {
List<DiseaseVariant> diseaseVariants = FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.DISEASE_VARIANT, disease);
FieldHelper.updateItems(diseaseVariantField, diseaseVariants);
FieldHelper.setEnabled(CollectionUtils.isNotEmpty(diseaseVariants), diseaseVariantField);
}
}
use of com.vaadin.v7.ui.HorizontalLayout in project SORMAS-Project by hzi-braunschweig.
the class SymptomsForm method addFields.
@Override
protected void addFields() {
if (disease == null || symptomsContext == null) {
// workaround to stop initialization until disease is set
return;
}
// Add fields
Label clinicalMeasurementsHeadingLabel = createLabel(I18nProperties.getString(Strings.headingClinicalMeasurements), H3, CLINICAL_MEASUREMENTS_HEADING_LOC);
Label signsAndSymptomsHeadingLabel = createLabel(I18nProperties.getString(Strings.headingSignsAndSymptoms), H3, SIGNS_AND_SYMPTOMS_HEADING_LOC);
final Label generalSymptomsHeadingLabel = createLabel(SymptomGroup.GENERAL.toString(), H4, GENERAL_SIGNS_AND_SYMPTOMS_HEADING_LOC);
final Label respiratorySymptomsHeadingLabel = createLabel(SymptomGroup.RESPIRATORY.toString(), H4, RESPIRATORY_SIGNS_AND_SYMPTOMS_HEADING_LOC);
final Label cardiovascularSymptomsHeadingLabel = createLabel(SymptomGroup.CARDIOVASCULAR.toString(), H4, CARDIOVASCULAR_SIGNS_AND_SYMPTOMS_HEADING_LOC);
final Label gastrointestinalSymptomsHeadingLabel = createLabel(SymptomGroup.GASTROINTESTINAL.toString(), H4, GASTROINTESTINAL_SIGNS_AND_SYMPTOMS_HEADING_LOC);
final Label urinarySymptomsHeadingLabel = createLabel(SymptomGroup.URINARY.toString(), H4, URINARY_SIGNS_AND_SYMPTOMS_HEADING_LOC);
final Label nervousSystemSymptomsHeadingLabel = createLabel(SymptomGroup.NERVOUS_SYSTEM.toString(), H4, NERVOUS_SYSTEM_SIGNS_AND_SYMPTOMS_HEADING_LOC);
final Label skinSymptomsHeadingLabel = createLabel(SymptomGroup.SKIN.toString(), H4, SKIN_SIGNS_AND_SYMPTOMS_HEADING_LOC);
final Label otherSymptomsHeadingLabel = createLabel(SymptomGroup.OTHER.toString(), H4, OTHER_SIGNS_AND_SYMPTOMS_HEADING_LOC);
DateField onsetDateField = addField(ONSET_DATE, DateField.class);
ComboBox onsetSymptom = addField(ONSET_SYMPTOM, ComboBox.class);
if (symptomsContext == SymptomsContext.CASE) {
// If the symptom onset date is after the hospital admission date, show a warning but don't prevent the user from saving
onsetDateField.addValueChangeListener(event -> {
if (caze.getHospitalization().getAdmissionDate() != null && DateTimeComparator.getDateOnlyInstance().compare(caze.getHospitalization().getAdmissionDate(), onsetDateField.getValue()) < 0) {
onsetDateField.setComponentError(new ErrorMessage() {
@Override
public ErrorLevel getErrorLevel() {
return ErrorLevel.INFO;
}
@Override
public String getFormattedHtmlMessage() {
return I18nProperties.getValidationError(Validations.beforeDateSoft, onsetDateField.getCaption(), I18nProperties.getPrefixCaption(HospitalizationDto.I18N_PREFIX, HospitalizationDto.ADMISSION_DATE));
}
});
} else if (onsetDateField.isValid()) {
onsetDateField.setComponentError(null);
}
});
}
ComboBox temperature = addField(TEMPERATURE, ComboBox.class);
temperature.setImmediate(true);
for (Float temperatureValue : SymptomsHelper.getTemperatureValues()) {
temperature.addItem(temperatureValue);
temperature.setItemCaption(temperatureValue, SymptomsHelper.getTemperatureString(temperatureValue));
}
if (symptomsContext == SymptomsContext.CASE) {
temperature.setCaption(I18nProperties.getCaption(Captions.symptomsMaxTemperature));
}
addField(TEMPERATURE_SOURCE);
ComboBox bloodPressureSystolic = addField(BLOOD_PRESSURE_SYSTOLIC, ComboBox.class);
bloodPressureSystolic.addItems(SymptomsHelper.getBloodPressureValues());
ComboBox bloodPressureDiastolic = addField(BLOOD_PRESSURE_DIASTOLIC, ComboBox.class);
bloodPressureDiastolic.addItems(SymptomsHelper.getBloodPressureValues());
ComboBox heartRate = addField(HEART_RATE, ComboBox.class);
heartRate.addItems(SymptomsHelper.getHeartRateValues());
ComboBox respiratoryRate = addField(RESPIRATORY_RATE, ComboBox.class);
respiratoryRate.addItems(SymptomsHelper.getRespiratoryRateValues());
ComboBox weight = addField(WEIGHT, ComboBox.class);
for (Integer weightValue : SymptomsHelper.getWeightValues()) {
weight.addItem(weightValue);
weight.setItemCaption(weightValue, SymptomsHelper.getDecimalString(weightValue));
}
ComboBox height = addField(HEIGHT, ComboBox.class);
height.addItems(SymptomsHelper.getHeightValues());
ComboBox midUpperArmCircumference = addField(MID_UPPER_ARM_CIRCUMFERENCE, ComboBox.class);
for (Integer circumferenceValue : SymptomsHelper.getMidUpperArmCircumferenceValues()) {
midUpperArmCircumference.addItem(circumferenceValue);
midUpperArmCircumference.setItemCaption(circumferenceValue, SymptomsHelper.getDecimalString(circumferenceValue));
}
ComboBox glasgowComaScale = addField(GLASGOW_COMA_SCALE, ComboBox.class);
glasgowComaScale.addItems(SymptomsHelper.getGlasgowComaScaleValues());
addFields(VOMITING, DIARRHEA, BLOOD_IN_STOOL, NAUSEA, ABDOMINAL_PAIN, HEADACHE, MUSCLE_PAIN, FATIGUE_WEAKNESS, SKIN_RASH, NECK_STIFFNESS, SORE_THROAT, COUGH, COUGH_WITH_SPUTUM, COUGH_WITH_HEAMOPTYSIS, RUNNY_NOSE, DIFFICULTY_BREATHING, CHEST_PAIN, CONJUNCTIVITIS, EYE_PAIN_LIGHT_SENSITIVE, KOPLIKS_SPOTS, THROBOCYTOPENIA, OTITIS_MEDIA, HEARINGLOSS, DEHYDRATION, ANOREXIA_APPETITE_LOSS, REFUSAL_FEEDOR_DRINK, JOINT_PAIN, HICCUPS, BACKACHE, EYES_BLEEDING, JAUNDICE, DARK_URINE, STOMACH_BLEEDING, RAPID_BREATHING, SWOLLEN_GLANDS, UNEXPLAINED_BLEEDING, GUMS_BLEEDING, INJECTION_SITE_BLEEDING, NOSE_BLEEDING, BLOODY_BLACK_STOOL, RED_BLOOD_VOMIT, DIGESTED_BLOOD_VOMIT, COUGHING_BLOOD, BLEEDING_VAGINA, SKIN_BRUISING, BLOOD_URINE, OTHER_HEMORRHAGIC_SYMPTOMS, OTHER_HEMORRHAGIC_SYMPTOMS_TEXT, OTHER_NON_HEMORRHAGIC_SYMPTOMS, OTHER_NON_HEMORRHAGIC_SYMPTOMS_TEXT, LESIONS, LESIONS_THAT_ITCH, LESIONS_SAME_STATE, LESIONS_SAME_SIZE, LESIONS_DEEP_PROFOUND, LESIONS_FACE, LESIONS_LEGS, LESIONS_SOLES_FEET, LESIONS_PALMS_HANDS, LESIONS_THORAX, LESIONS_ARMS, LESIONS_GENITALS, LESIONS_ALL_OVER_BODY, LYMPHADENOPATHY, LYMPHADENOPATHY_AXILLARY, LYMPHADENOPATHY_CERVICAL, LYMPHADENOPATHY_INGUINAL, CHILLS_SWEATS, BEDRIDDEN, ORAL_ULCERS, PAINFUL_LYMPHADENITIS, BLACKENING_DEATH_OF_TISSUE, BUBOES_GROIN_ARMPIT_NECK, BULGING_FONTANELLE, PHARYNGEAL_ERYTHEMA, PHARYNGEAL_EXUDATE, OEDEMA_FACE_NECK, OEDEMA_LOWER_EXTREMITY, LOSS_SKIN_TURGOR, PALPABLE_LIVER, PALPABLE_SPLEEN, MALAISE, SUNKEN_EYES_FONTANELLE, SIDE_PAIN, FLUID_IN_LUNG_CAVITY, TREMOR, BILATERAL_CATARACTS, UNILATERAL_CATARACTS, CONGENITAL_GLAUCOMA, CONGENITAL_HEART_DISEASE, PIGMENTARY_RETINOPATHY, RADIOLUCENT_BONE_DISEASE, SPLENOMEGALY, MICROCEPHALY, MENINGOENCEPHALITIS, PURPURIC_RASH, DEVELOPMENTAL_DELAY, CONGENITAL_HEART_DISEASE_TYPE, CONGENITAL_HEART_DISEASE_DETAILS, JAUNDICE_WITHIN_24_HOURS_OF_BIRTH, PATIENT_ILL_LOCATION, HYDROPHOBIA, OPISTHOTONUS, ANXIETY_STATES, DELIRIUM, UPROARIOUSNESS, PARASTHESIA_AROUND_WOUND, EXCESS_SALIVATION, INSOMNIA, PARALYSIS, EXCITATION, DYSPHAGIA, AEROPHOBIA, HYPERACTIVITY, PARESIS, AGITATION, ASCENDING_FLACCID_PARALYSIS, ERRATIC_BEHAVIOUR, COMA, CONVULSION, FLUID_IN_LUNG_CAVITY_AUSCULTATION, FLUID_IN_LUNG_CAVITY_XRAY, ABNORMAL_LUNG_XRAY_FINDINGS, CONJUNCTIVAL_INJECTION, ACUTE_RESPIRATORY_DISTRESS_SYNDROME, PNEUMONIA_CLINICAL_OR_RADIOLOGIC, LOSS_OF_TASTE, LOSS_OF_SMELL, WHEEZING, SKIN_ULCERS, INABILITY_TO_WALK, IN_DRAWING_OF_CHEST_WALL, FEELING_ILL, SHIVERING, RESPIRATORY_DISEASE_VENTILATION, FAST_HEART_RATE, OXYGEN_SATURATION_LOWER_94, FEVERISHFEELING, WEAKNESS, FATIGUE, COUGH_WITHOUT_SPUTUM, BREATHLESSNESS, CHEST_PRESSURE, BLUE_LIPS, BLOOD_CIRCULATION_PROBLEMS, PALPITATIONS, DIZZINESS_STANDING_UP, HIGH_OR_LOW_BLOOD_PRESSURE, URINARY_RETENTION, FEVER);
addField(SYMPTOMS_COMMENTS, TextField.class).setDescription(I18nProperties.getPrefixDescription(I18N_PREFIX, SYMPTOMS_COMMENTS, "") + "\n" + I18nProperties.getDescription(Descriptions.descGdpr));
addField(LESIONS_ONSET_DATE, DateField.class);
// complications
addFields(ALTERED_CONSCIOUSNESS, CONFUSED_DISORIENTED, OTHER_COMPLICATIONS, OTHER_COMPLICATIONS_TEXT, HEMORRHAGIC_SYNDROME, HYPERGLYCEMIA, HYPOGLYCEMIA, MENINGEAL_SIGNS, SEIZURES, SEPSIS, SHOCK);
monkeypoxImageFieldIds = Arrays.asList(LESIONS_RESEMBLE_IMG1, LESIONS_RESEMBLE_IMG2, LESIONS_RESEMBLE_IMG3, LESIONS_RESEMBLE_IMG4);
for (String propertyId : monkeypoxImageFieldIds) {
@SuppressWarnings("rawtypes") Field monkeypoxImageField = addField(propertyId);
CssStyles.style(monkeypoxImageField, VSPACE_NONE);
}
// Set initial visibilities
initializeVisibilitiesAndAllowedVisibilities();
initializeAccessAndAllowedAccesses();
if (symptomsContext != SymptomsContext.CLINICAL_VISIT) {
setVisible(false, BLOOD_PRESSURE_SYSTOLIC, BLOOD_PRESSURE_DIASTOLIC, HEART_RATE, RESPIRATORY_RATE, WEIGHT, HEIGHT, MID_UPPER_ARM_CIRCUMFERENCE, GLASGOW_COMA_SCALE);
} else {
setVisible(false, ONSET_SYMPTOM, ONSET_DATE);
}
// Initialize lists
conditionalBleedingSymptomFieldIds = Arrays.asList(GUMS_BLEEDING, INJECTION_SITE_BLEEDING, NOSE_BLEEDING, BLOODY_BLACK_STOOL, RED_BLOOD_VOMIT, DIGESTED_BLOOD_VOMIT, EYES_BLEEDING, COUGHING_BLOOD, BLEEDING_VAGINA, SKIN_BRUISING, STOMACH_BLEEDING, BLOOD_URINE, OTHER_HEMORRHAGIC_SYMPTOMS);
lesionsFieldIds = Arrays.asList(LESIONS_SAME_STATE, LESIONS_SAME_SIZE, LESIONS_DEEP_PROFOUND, LESIONS_THAT_ITCH);
lesionsLocationFieldIds = Arrays.asList(LESIONS_FACE, LESIONS_LEGS, LESIONS_SOLES_FEET, LESIONS_PALMS_HANDS, LESIONS_THORAX, LESIONS_ARMS, LESIONS_GENITALS, LESIONS_ALL_OVER_BODY);
unconditionalSymptomFieldIds = Arrays.asList(FEVER, ABNORMAL_LUNG_XRAY_FINDINGS, CONJUNCTIVAL_INJECTION, ACUTE_RESPIRATORY_DISTRESS_SYNDROME, PNEUMONIA_CLINICAL_OR_RADIOLOGIC, VOMITING, DIARRHEA, BLOOD_IN_STOOL, NAUSEA, ABDOMINAL_PAIN, HEADACHE, MUSCLE_PAIN, FATIGUE_WEAKNESS, SKIN_RASH, NECK_STIFFNESS, SORE_THROAT, COUGH, COUGH_WITH_SPUTUM, COUGH_WITH_HEAMOPTYSIS, RUNNY_NOSE, DIFFICULTY_BREATHING, CHEST_PAIN, CONJUNCTIVITIS, EYE_PAIN_LIGHT_SENSITIVE, KOPLIKS_SPOTS, THROBOCYTOPENIA, OTITIS_MEDIA, HEARINGLOSS, DEHYDRATION, ANOREXIA_APPETITE_LOSS, REFUSAL_FEEDOR_DRINK, JOINT_PAIN, HICCUPS, BACKACHE, JAUNDICE, DARK_URINE, RAPID_BREATHING, SWOLLEN_GLANDS, UNEXPLAINED_BLEEDING, OTHER_NON_HEMORRHAGIC_SYMPTOMS, LESIONS, LYMPHADENOPATHY, LYMPHADENOPATHY_AXILLARY, LYMPHADENOPATHY_CERVICAL, LYMPHADENOPATHY_INGUINAL, CHILLS_SWEATS, BEDRIDDEN, ORAL_ULCERS, PAINFUL_LYMPHADENITIS, BLACKENING_DEATH_OF_TISSUE, BUBOES_GROIN_ARMPIT_NECK, BULGING_FONTANELLE, PHARYNGEAL_ERYTHEMA, PHARYNGEAL_EXUDATE, OEDEMA_FACE_NECK, OEDEMA_LOWER_EXTREMITY, LOSS_SKIN_TURGOR, PALPABLE_LIVER, PALPABLE_SPLEEN, MALAISE, SUNKEN_EYES_FONTANELLE, SIDE_PAIN, FLUID_IN_LUNG_CAVITY, FLUID_IN_LUNG_CAVITY_AUSCULTATION, FLUID_IN_LUNG_CAVITY_XRAY, TREMOR, BILATERAL_CATARACTS, UNILATERAL_CATARACTS, CONGENITAL_GLAUCOMA, CONGENITAL_HEART_DISEASE, RADIOLUCENT_BONE_DISEASE, SPLENOMEGALY, MICROCEPHALY, MENINGOENCEPHALITIS, DEVELOPMENTAL_DELAY, PURPURIC_RASH, PIGMENTARY_RETINOPATHY, CONVULSION, AEROPHOBIA, AGITATION, ANXIETY_STATES, ASCENDING_FLACCID_PARALYSIS, COMA, DELIRIUM, DYSPHAGIA, ERRATIC_BEHAVIOUR, EXCESS_SALIVATION, EXCITATION, HYDROPHOBIA, HYPERACTIVITY, INSOMNIA, OPISTHOTONUS, PARALYSIS, PARASTHESIA_AROUND_WOUND, PARESIS, UPROARIOUSNESS, LOSS_OF_TASTE, LOSS_OF_SMELL, WHEEZING, SKIN_ULCERS, INABILITY_TO_WALK, IN_DRAWING_OF_CHEST_WALL, OTHER_COMPLICATIONS, FEELING_ILL, SHIVERING, RESPIRATORY_DISEASE_VENTILATION, FAST_HEART_RATE, OXYGEN_SATURATION_LOWER_94, FEVERISHFEELING, WEAKNESS, FATIGUE, COUGH_WITHOUT_SPUTUM, BREATHLESSNESS, CHEST_PRESSURE, BLUE_LIPS, BLOOD_CIRCULATION_PROBLEMS, PALPITATIONS, DIZZINESS_STANDING_UP, HIGH_OR_LOW_BLOOD_PRESSURE, URINARY_RETENTION, // complications
ALTERED_CONSCIOUSNESS, CONFUSED_DISORIENTED, HEMORRHAGIC_SYNDROME, HYPERGLYCEMIA, HYPOGLYCEMIA, MENINGEAL_SIGNS, SEIZURES, SEPSIS, SHOCK);
// Set visibilities
NullableOptionGroup feverField = (NullableOptionGroup) getFieldGroup().getField(FEVER);
feverField.setImmediate(true);
FieldHelper.setVisibleWhen(getFieldGroup(), conditionalBleedingSymptomFieldIds, UNEXPLAINED_BLEEDING, Arrays.asList(SymptomState.YES), true);
FieldHelper.setVisibleWhen(getFieldGroup(), OTHER_HEMORRHAGIC_SYMPTOMS_TEXT, OTHER_HEMORRHAGIC_SYMPTOMS, Arrays.asList(SymptomState.YES), true);
FieldHelper.setVisibleWhen(getFieldGroup(), OTHER_NON_HEMORRHAGIC_SYMPTOMS_TEXT, OTHER_NON_HEMORRHAGIC_SYMPTOMS, Arrays.asList(SymptomState.YES), true);
FieldHelper.setVisibleWhen(getFieldGroup(), OTHER_COMPLICATIONS_TEXT, OTHER_COMPLICATIONS, Arrays.asList(SymptomState.YES), true);
FieldHelper.setVisibleWhen(getFieldGroup(), lesionsFieldIds, LESIONS, Arrays.asList(SymptomState.YES), true);
FieldHelper.setVisibleWhen(getFieldGroup(), lesionsLocationFieldIds, LESIONS, Arrays.asList(SymptomState.YES), true);
FieldHelper.setVisibleWhen(getFieldGroup(), LESIONS_ONSET_DATE, LESIONS, Arrays.asList(SymptomState.YES), true);
FieldHelper.setVisibleWhen(getFieldGroup(), CONGENITAL_HEART_DISEASE_TYPE, CONGENITAL_HEART_DISEASE, Arrays.asList(SymptomState.YES), true);
FieldHelper.setVisibleWhen(getFieldGroup(), CONGENITAL_HEART_DISEASE_DETAILS, CONGENITAL_HEART_DISEASE_TYPE, Arrays.asList(CongenitalHeartDiseaseType.OTHER), true);
if (isVisibleAllowed(getFieldGroup().getField(JAUNDICE_WITHIN_24_HOURS_OF_BIRTH))) {
FieldHelper.setVisibleWhen(getFieldGroup(), JAUNDICE_WITHIN_24_HOURS_OF_BIRTH, JAUNDICE, Arrays.asList(SymptomState.YES), true);
}
FieldHelper.addSoftRequiredStyle(getField(LESIONS_ONSET_DATE));
boolean isInfant = person != null && person.getApproximateAge() != null && ((person.getApproximateAge() <= 12 && person.getApproximateAgeType() == ApproximateAgeType.MONTHS) || person.getApproximateAge() <= 1);
if (!isInfant) {
getFieldGroup().getField(BULGING_FONTANELLE).setVisible(false);
}
// Handle visibility of lesions locations caption
Label lesionsLocationsCaption = new Label(I18nProperties.getCaption(Captions.symptomsLesionsLocations));
CssStyles.style(lesionsLocationsCaption, VSPACE_3);
getContent().addComponent(lesionsLocationsCaption, LESIONS_LOCATIONS_LOC);
getContent().getComponent(LESIONS_LOCATIONS_LOC).setVisible(FieldHelper.getNullableSourceFieldValue(getFieldGroup().getField(LESIONS)) == SymptomState.YES);
getFieldGroup().getField(LESIONS).addValueChangeListener(e -> {
getContent().getComponent(LESIONS_LOCATIONS_LOC).setVisible(FieldHelper.getNullableSourceFieldValue((Field) e.getProperty()) == SymptomState.YES);
});
// Symptoms hint text
Label symptomsHint = new Label(I18nProperties.getString(symptomsContext == SymptomsContext.CASE ? Strings.messageSymptomsHint : Strings.messageSymptomsVisitHint), ContentMode.HTML);
symptomsHint.setWidth(100, Unit.PERCENTAGE);
getContent().addComponent(symptomsHint, SYMPTOMS_HINT_LOC);
if (disease == Disease.MONKEYPOX) {
setUpMonkeypoxVisibilities();
}
if (symptomsContext != SymptomsContext.CASE) {
getFieldGroup().getField(PATIENT_ILL_LOCATION).setVisible(false);
}
symptomGroupMap.forEach((location, strings) -> {
final Component groupLabel = getContent().getComponent(location);
final Optional<String> groupHasVisibleSymptom = strings.stream().filter(s -> getFieldGroup().getField(s).isVisible()).findAny();
if (!groupHasVisibleSymptom.isPresent()) {
groupLabel.setVisible(false);
}
});
if (isEditableAllowed(OTHER_HEMORRHAGIC_SYMPTOMS_TEXT)) {
FieldHelper.setRequiredWhen(getFieldGroup(), getFieldGroup().getField(OTHER_HEMORRHAGIC_SYMPTOMS), Arrays.asList(OTHER_HEMORRHAGIC_SYMPTOMS_TEXT), Arrays.asList(SymptomState.YES), disease);
}
if (isEditableAllowed(OTHER_NON_HEMORRHAGIC_SYMPTOMS_TEXT)) {
FieldHelper.setRequiredWhen(getFieldGroup(), getFieldGroup().getField(OTHER_NON_HEMORRHAGIC_SYMPTOMS), Arrays.asList(OTHER_NON_HEMORRHAGIC_SYMPTOMS_TEXT), Arrays.asList(SymptomState.YES), disease);
}
if (isEditableAllowed(OTHER_COMPLICATIONS_TEXT)) {
FieldHelper.setRequiredWhen(getFieldGroup(), getFieldGroup().getField(OTHER_COMPLICATIONS), Arrays.asList(OTHER_COMPLICATIONS_TEXT), Arrays.asList(SymptomState.YES), disease);
}
FieldHelper.setRequiredWhen(getFieldGroup(), getFieldGroup().getField(LESIONS), lesionsFieldIds, Arrays.asList(SymptomState.YES), disease);
FieldHelper.setRequiredWhen(getFieldGroup(), getFieldGroup().getField(LESIONS), monkeypoxImageFieldIds, Arrays.asList(SymptomState.YES), disease);
addListenerForOnsetFields(onsetSymptom, onsetDateField);
Button clearAllButton = ButtonHelper.createButton(Captions.actionClearAll, event -> {
for (Object symptomId : unconditionalSymptomFieldIds) {
getFieldGroup().getField(symptomId).setValue(null);
}
for (Object symptomId : conditionalBleedingSymptomFieldIds) {
getFieldGroup().getField(symptomId).setValue(null);
}
for (Object symptomId : lesionsFieldIds) {
getFieldGroup().getField(symptomId).setValue(null);
}
for (Object symptomId : lesionsLocationFieldIds) {
getFieldGroup().getField(symptomId).setValue(null);
}
for (Object symptomId : monkeypoxImageFieldIds) {
getFieldGroup().getField(symptomId).setValue(null);
}
}, ValoTheme.BUTTON_LINK);
Button setEmptyToNoButton = createButtonSetClearedToSymptomState(Captions.symptomsSetClearedToNo, SymptomState.NO);
Button setEmptyToUnknownButton = createButtonSetClearedToSymptomState(Captions.symptomsSetClearedToUnknown, SymptomState.UNKNOWN);
// Complications heading - not displayed for Rubella (dirty, should be made generic)
Label complicationsHeading = new Label(I18nProperties.getString(Strings.headingComplications));
CssStyles.style(complicationsHeading, CssStyles.H3);
if (disease != Disease.CONGENITAL_RUBELLA && !isConfiguredServer("de")) {
getContent().addComponent(complicationsHeading, COMPLICATIONS_HEADING);
}
HorizontalLayout buttonsLayout = new HorizontalLayout();
buttonsLayout.addComponent(clearAllButton);
buttonsLayout.addComponent(setEmptyToNoButton);
buttonsLayout.addComponent(setEmptyToUnknownButton);
buttonsLayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
buttonsLayout.setMargin(new MarginInfo(true, false, true, true));
getContent().addComponent(buttonsLayout, BUTTONS_LOC);
if (feverField.isVisible()) {
temperature.addValueChangeListener(e -> {
toggleFeverComponentError(feverField, temperature);
});
feverField.addValueChangeListener(e -> {
toggleFeverComponentError(feverField, temperature);
});
}
}
use of com.vaadin.v7.ui.HorizontalLayout in project SORMAS-Project by hzi-braunschweig.
the class TaskEditForm method addFields.
@Override
protected void addFields() {
addField(TaskDto.CAZE, ComboBox.class);
addField(TaskDto.EVENT, ComboBox.class);
addField(TaskDto.CONTACT, ComboBox.class);
DateTimeField startDate = addDateField(TaskDto.SUGGESTED_START, DateTimeField.class, -1);
DateTimeField dueDate = addDateField(TaskDto.DUE_DATE, DateTimeField.class, -1);
dueDate.setImmediate(true);
addField(TaskDto.PRIORITY, ComboBox.class);
NullableOptionGroup taskStatus = addField(TaskDto.TASK_STATUS, NullableOptionGroup.class);
NullableOptionGroup taskContext = addField(TaskDto.TASK_CONTEXT, NullableOptionGroup.class);
taskContext.setImmediate(true);
taskContext.addValueChangeListener(event -> updateByTaskContext());
ComboBox taskTypeField = addField(TaskDto.TASK_TYPE, ComboBox.class);
taskTypeField.setItemCaptionMode(ItemCaptionMode.ID_TOSTRING);
taskTypeField.setImmediate(true);
taskTypeField.addValueChangeListener(e -> {
TaskType taskType = (TaskType) e.getProperty().getValue();
if (taskType != null) {
setRequired(taskType.isCreatorCommentRequired(), TaskDto.CREATOR_COMMENT);
}
});
ComboBox assigneeUser = addField(TaskDto.ASSIGNEE_USER, ComboBox.class);
assigneeUser.addValueChangeListener(e -> {
updateObserversList();
updateByCreatingAndAssignee();
checkIfUserEmailOrPhoneIsProvided((UserReferenceDto) e.getProperty().getValue(), Strings.infoAssigneeMissingEmail, Strings.infoAssigneeMissingEmailOrPhoneNumber, ASSIGNEE_MISSING_INFO);
});
assigneeUser.setImmediate(true);
TextArea creatorComment = addField(TaskDto.CREATOR_COMMENT, TextArea.class);
creatorComment.setRows(2);
creatorComment.setImmediate(true);
addField(TaskDto.ASSIGNEE_REPLY, TextArea.class).setRows(4);
MultiSelect<UserReferenceDto> observerUsers = addField(TaskDto.OBSERVER_USERS, MultiSelect.class);
observerUsers.addValueChangeListener(e -> {
Collection<UserReferenceDto> userReferences = (Collection<UserReferenceDto>) e.getProperty().getValue();
for (UserReferenceDto userReference : userReferences) {
checkIfUserEmailOrPhoneIsProvided(userReference, Strings.infoObserverMissingEmail, Strings.infoObserverMissingEmailOrPhoneNumber, OBSERVER_MISSING_INFO);
}
});
observerUsers.setImmediate(true);
CssStyles.style(observerUsers, CssStyles.OPTIONGROUP_MAX_HEIGHT_150);
setRequired(true, TaskDto.TASK_CONTEXT, TaskDto.TASK_TYPE, TaskDto.ASSIGNEE_USER, TaskDto.DUE_DATE, TaskDto.TASK_STATUS);
setReadOnly(true, TaskDto.TASK_CONTEXT, TaskDto.CAZE, TaskDto.CONTACT, TaskDto.EVENT);
addValueChangeListener(e -> {
TaskDto taskDto = getValue();
if (taskDto.getTaskType() == TaskType.CASE_INVESTIGATION && taskDto.getCaze() != null) {
taskStatus.addValidator(new TaskStatusValidator(taskDto.getCaze().getUuid(), I18nProperties.getValidationError(Validations.investigationStatusUnclassifiedCase)));
if (!editedFromTaskGrid) {
final HorizontalLayout saveInfoLayout = new HorizontalLayout(new Label(VaadinIcons.INFO_CIRCLE.getHtml() + " " + I18nProperties.getString(Strings.infoSaveOfTask), ContentMode.HTML));
saveInfoLayout.setSpacing(true);
saveInfoLayout.setMargin(new MarginInfo(true, false, true, false));
getContent().addComponent(saveInfoLayout, SAVE_INFO);
}
}
final UserDto userDto = UserProvider.getCurrent().getUser();
availableUsers = new ArrayList<>();
if (taskDto.getCaze() != null) {
availableUsers.addAll(FacadeProvider.getUserFacade().getUsersHavingCaseInJurisdiction(taskDto.getCaze()));
} else if (taskDto.getContact() != null) {
availableUsers.addAll(FacadeProvider.getUserFacade().getUsersHavingContactInJurisdiction(taskDto.getContact()));
} else if (taskDto.getEvent() != null) {
availableUsers.addAll(FacadeProvider.getUserFacade().getUsersHavingEventInJurisdiction(taskDto.getEvent()));
} else if (taskDto.getTravelEntry() != null) {
availableUsers.addAll(FacadeProvider.getUserFacade().getUsersHavingTravelEntryInJurisdiction(taskDto.getTravelEntry()));
} else {
availableUsers.addAll(FacadeProvider.getUserFacade().getAllUserRefs(false));
}
// For national users, there is no higher level
if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.ASSIGN_TASKS_TO_HIGHER_LEVEL) && UserRole.getJurisdictionLevel(userDto.getUserRoles()) != JurisdictionLevel.NATION) {
List<UserReferenceDto> superordinateUsers = FacadeProvider.getUserFacade().getUsersWithSuperiorJurisdiction(userDto);
if (superordinateUsers != null) {
availableUsers.addAll(superordinateUsers);
}
}
// Validation
startDate.addValidator(new DateComparisonValidator(startDate, dueDate, true, false, I18nProperties.getValidationError(Validations.beforeDate, startDate.getCaption(), dueDate.getCaption())));
dueDate.addValidator(new DateComparisonValidator(dueDate, startDate, false, false, I18nProperties.getValidationError(Validations.afterDate, dueDate.getCaption(), startDate.getCaption())));
Map<String, Long> userTaskCounts = FacadeProvider.getTaskFacade().getPendingTaskCountPerUser(availableUsers.stream().map(ReferenceDto::getUuid).collect(Collectors.toList()));
for (UserReferenceDto user : availableUsers) {
assigneeUser.addItem(user);
Long userTaskCount = userTaskCounts.get(user.getUuid());
assigneeUser.setItemCaption(user, user.getCaption() + " (" + (userTaskCount != null ? userTaskCount.toString() : "0") + ")");
if (!user.equals(assigneeUser.getValue())) {
// If a user has been assigned to the task, do not make it available for observers field
observerUsers.addItem(user);
observerUsers.setItemCaption(user, user.getCaption());
}
}
});
}
Aggregations