use of de.symeda.sormas.api.disease.DiseaseVariant in project SORMAS-Project by hzi-braunschweig.
the class EventEditFragment method updateCustomizableEnumFields.
private void updateCustomizableEnumFields(FragmentEventEditLayoutBinding contentBinding) {
// Disease variant
DiseaseVariant selectedVariant = (DiseaseVariant) contentBinding.eventDiseaseVariant.getValue();
List<DiseaseVariant> diseaseVariants = DatabaseHelper.getCustomizableEnumValueDao().getEnumValues(CustomizableEnumType.DISEASE_VARIANT, record.getDisease());
diseaseVariantList.clear();
diseaseVariantList.addAll(DataUtils.toItems(diseaseVariants));
contentBinding.eventDiseaseVariant.setSpinnerData(diseaseVariantList);
if (diseaseVariants.contains(selectedVariant)) {
contentBinding.eventDiseaseVariant.setValue(selectedVariant);
} else {
contentBinding.eventDiseaseVariant.setValue(null);
}
contentBinding.eventDiseaseVariant.setVisibility(diseaseVariants.isEmpty() ? GONE : VISIBLE);
// Specific risk
SpecificRisk selectedRisk = (SpecificRisk) contentBinding.eventSpecificRisk.getValue();
List<SpecificRisk> specificRisks = DatabaseHelper.getCustomizableEnumValueDao().getEnumValues(CustomizableEnumType.SPECIFIC_EVENT_RISK, record.getDisease());
specificRiskList.clear();
specificRiskList.addAll(DataUtils.toItems(specificRisks));
contentBinding.eventSpecificRisk.setSpinnerData(specificRiskList);
if (specificRisks.contains(selectedRisk)) {
contentBinding.eventSpecificRisk.setValue(selectedRisk);
} else {
contentBinding.eventSpecificRisk.setValue(null);
}
contentBinding.eventSpecificRisk.setVisibility(specificRisks.isEmpty() ? GONE : VISIBLE);
}
use of de.symeda.sormas.api.disease.DiseaseVariant 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);
ComboBox 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);
addCustomField(PersonDto.FIRST_NAME, String.class, TextField.class);
addCustomField(PersonDto.LAST_NAME, String.class, TextField.class);
if (showPersonSearchButton) {
searchPersonButton = createPersonSearchButton(PERSON_SEARCH_LOC);
getContent().addComponent(searchPersonButton, PERSON_SEARCH_LOC);
}
TextField nationalHealthIdField = addCustomField(PersonDto.NATIONAL_HEALTH_ID, String.class, TextField.class);
TextField passportNumberField = addCustomField(PersonDto.PASSPORT_NUMBER, String.class, TextField.class);
if (CountryHelper.isCountry(FacadeProvider.getConfigFacade().getCountryLocale(), CountryHelper.COUNTRY_CODE_GERMANY)) {
nationalHealthIdField.setVisible(false);
}
if (CountryHelper.isInCountries(FacadeProvider.getConfigFacade().getCountryLocale(), CountryHelper.COUNTRY_CODE_GERMANY, CountryHelper.COUNTRY_CODE_FRANCE)) {
passportNumberField.setVisible(false);
}
birthDateDay = addCustomField(PersonDto.BIRTH_DATE_DD, Integer.class, ComboBox.class);
// @TODO: Done for nullselection Bug, fixed in Vaadin 7.7.3
birthDateDay.setNullSelectionAllowed(true);
birthDateDay.addStyleName(FORCE_CAPTION);
birthDateDay.setInputPrompt(I18nProperties.getString(Strings.day));
ComboBox birthDateMonth = addCustomField(PersonDto.BIRTH_DATE_MM, Integer.class, ComboBox.class);
// @TODO: Done for nullselection Bug, fixed in Vaadin 7.7.3
birthDateMonth.setNullSelectionAllowed(true);
birthDateMonth.addItems(DateHelper.getMonthsInYear());
birthDateMonth.setPageLength(12);
birthDateMonth.addStyleName(FORCE_CAPTION);
birthDateMonth.setInputPrompt(I18nProperties.getString(Strings.month));
setItemCaptionsForMonths(birthDateMonth);
ComboBox birthDateYear = addCustomField(PersonDto.BIRTH_DATE_YYYY, Integer.class, 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);
birthDateYear.setInputPrompt(I18nProperties.getString(Strings.year));
birthDateDay.addValidator(e -> ControllerProvider.getPersonController().validateBirthDate((Integer) birthDateYear.getValue(), (Integer) birthDateMonth.getValue(), (Integer) e));
birthDateMonth.addValidator(e -> ControllerProvider.getPersonController().validateBirthDate((Integer) birthDateYear.getValue(), (Integer) e, (Integer) birthDateDay.getValue()));
birthDateYear.addValidator(e -> ControllerProvider.getPersonController().validateBirthDate((Integer) e, (Integer) birthDateMonth.getValue(), (Integer) birthDateDay.getValue()));
// Update the list of days according to the selected month and year
birthDateYear.addValueChangeListener(e -> {
updateListOfDays((Integer) e.getProperty().getValue(), (Integer) birthDateMonth.getValue());
birthDateMonth.markAsDirty();
birthDateDay.markAsDirty();
});
birthDateMonth.addValueChangeListener(e -> {
updateListOfDays((Integer) birthDateYear.getValue(), (Integer) e.getProperty().getValue());
birthDateYear.markAsDirty();
birthDateDay.markAsDirty();
});
birthDateDay.addValueChangeListener(e -> {
birthDateYear.markAsDirty();
birthDateMonth.markAsDirty();
});
ComboBox sex = addCustomField(PersonDto.SEX, Sex.class, ComboBox.class);
sex.setCaption(I18nProperties.getCaption(Captions.Person_sex));
ComboBox presentCondition = addCustomField(PersonDto.PRESENT_CONDITION, PresentCondition.class, ComboBox.class);
presentCondition.setCaption(I18nProperties.getCaption(Captions.Person_presentCondition));
addCustomField(SymptomsDto.ONSET_DATE, Date.class, DateField.class, I18nProperties.getPrefixCaption(SymptomsDto.I18N_PREFIX, SymptomsDto.ONSET_DATE));
TextField phone = addCustomField(PersonDto.PHONE, String.class, TextField.class);
phone.setCaption(I18nProperties.getCaption(Captions.Person_phone));
TextField email = addCustomField(PersonDto.EMAIL_ADDRESS, String.class, TextField.class);
email.setCaption(I18nProperties.getCaption(Captions.Person_emailAddress));
phone.addValidator(new PhoneNumberValidator(I18nProperties.getValidationError(Validations.validPhoneNumber, phone.getCaption())));
email.addValidator(new EmailValidator(I18nProperties.getValidationError(Validations.validEmailAddress, email.getCaption())));
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());
if (showHomeAddressForm) {
addHomeAddressForm();
}
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, PersonDto.FIRST_NAME, PersonDto.LAST_NAME, CaseDataDto.DISEASE, PersonDto.SEX, 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 -> {
Disease disease = (Disease) valueChangeEvent.getProperty().getValue();
List<DiseaseVariant> diseaseVariants = FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.DISEASE_VARIANT, disease);
FieldHelper.updateItems(diseaseVariantField, diseaseVariants);
diseaseVariantField.setVisible(disease != null && isVisibleAllowed(CaseDataDto.DISEASE_VARIANT) && CollectionUtils.isNotEmpty(diseaseVariants));
});
diseaseVariantField.addValueChangeListener(e -> {
DiseaseVariant diseaseVariant = (DiseaseVariant) e.getProperty().getValue();
diseaseVariantDetailsField.setVisible(diseaseVariant != null && diseaseVariant.matchPropertyValue(DiseaseVariant.HAS_DETAILS, true));
});
}
use of de.symeda.sormas.api.disease.DiseaseVariant in project SORMAS-Project by hzi-braunschweig.
the class ContactsFilterForm method applyDependenciesOnNewValue.
@Override
protected void applyDependenciesOnNewValue(ContactCriteria newValue) {
final RegionReferenceDto region = newValue.getRegion();
final DistrictReferenceDto district = newValue.getDistrict();
applyRegionAndDistrictFilterDependency(region, ContactCriteria.DISTRICT, district, ContactCriteria.COMMUNITY);
final UserDto user = currentUserDto();
ComboBox officerField = getField(ContactCriteria.CONTACT_OFFICER);
if (user.getRegion() != null) {
officerField.addItems(FacadeProvider.getUserFacade().getUsersByRegionAndRoles(user.getRegion(), UserRole.CONTACT_OFFICER));
} else if (region != null) {
officerField.addItems(FacadeProvider.getUserFacade().getUsersByRegionAndRoles(region, UserRole.CONTACT_OFFICER));
} else {
officerField.removeAllItems();
}
ComboBox birthDateDD = getField(ContactCriteria.BIRTHDATE_DD);
if (getField(ContactCriteria.BIRTHDATE_YYYY).getValue() != null && getField(ContactCriteria.BIRTHDATE_MM).getValue() != null) {
birthDateDD.addItems(DateHelper.getDaysInMonth((Integer) getField(ContactCriteria.BIRTHDATE_MM).getValue(), (Integer) getField(ContactCriteria.BIRTHDATE_YYYY).getValue()));
birthDateDD.setEnabled(true);
} else {
birthDateDD.clear();
birthDateDD.setEnabled(false);
}
// Date/Epi week filter
HorizontalLayout dateFilterLayout = (HorizontalLayout) getMoreFiltersContainer().getComponent(WEEK_AND_DATE_FILTER);
@SuppressWarnings("unchecked") EpiWeekAndDateFilterComponent<NewCaseDateType> weekAndDateFilter = (EpiWeekAndDateFilterComponent<NewCaseDateType>) dateFilterLayout.getComponent(0);
ContactDateType contactDateType = newValue.getReportDateFrom() != null ? ContactDateType.REPORT_DATE : newValue.getLastContactDateFrom() != null ? ContactDateType.LAST_CONTACT_DATE : null;
weekAndDateFilter.getDateTypeSelector().setValue(contactDateType);
weekAndDateFilter.getDateFilterOptionFilter().setValue(newValue.getDateFilterOption());
Date dateFrom = contactDateType == ContactDateType.REPORT_DATE ? newValue.getReportDateFrom() : contactDateType == ContactDateType.LAST_CONTACT_DATE ? newValue.getLastContactDateFrom() : null;
Date dateTo = contactDateType == ContactDateType.REPORT_DATE ? newValue.getReportDateTo() : contactDateType == ContactDateType.LAST_CONTACT_DATE ? newValue.getLastContactDateTo() : null;
if (DateFilterOption.EPI_WEEK.equals(newValue.getDateFilterOption())) {
weekAndDateFilter.getWeekFromFilter().setValue(dateFrom == null ? null : DateHelper.getEpiWeek(dateFrom));
weekAndDateFilter.getWeekToFilter().setValue(dateTo == null ? null : DateHelper.getEpiWeek(dateTo));
} else {
weekAndDateFilter.getDateFromFilter().setValue(dateFrom);
weekAndDateFilter.getDateToFilter().setValue(dateTo);
}
if (StringUtils.isBlank(newValue.getEventLike())) {
clearAndDisableFields(ContactCriteria.ONLY_CONTACTS_SHARING_EVENT_WITH_SOURCE_CASE);
} else {
enableFields(ContactCriteria.ONLY_CONTACTS_SHARING_EVENT_WITH_SOURCE_CASE);
}
ComboBox diseaseField = getField(ContactIndexDto.DISEASE);
ComboBox diseaseVariantField = getField(ContactCriteria.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 de.symeda.sormas.api.disease.DiseaseVariant in project SORMAS-Project by hzi-braunschweig.
the class LabMessageMapperTest method testMigrateDiseaseVariant.
@Test
public void testMigrateDiseaseVariant() throws CustomEnumNotFoundException {
CustomizableEnumFacadeEjb customizableEnumFacade = mock(CustomizableEnumFacadeEjb.class);
LabMessageDto labMessage = LabMessageDto.build();
labMessage.setTestedDisease(Disease.CORONAVIRUS);
TestReportDto testReport = TestReportDto.build();
LabMessageMapper mapper = LabMessageMapper.forLabMessage(labMessage);
DiseaseVariant diseaseVariant = new DiseaseVariant();
when(customizableEnumFacade.getEnumValue(CustomizableEnumType.DISEASE_VARIANT, "P.2", Disease.CORONAVIRUS)).thenReturn(diseaseVariant);
when(customizableEnumFacade.getEnumValue(CustomizableEnumType.DISEASE_VARIANT, "NON-EXISTENT", Disease.CORONAVIRUS)).thenThrow(new CustomEnumNotFoundException("not found"));
when(customizableEnumFacade.getEnumValue(CustomizableEnumType.DISEASE_VARIANT, null, Disease.CORONAVIRUS)).thenThrow(new CustomEnumNotFoundException("not found"));
try (MockedStatic<FacadeProvider> facadeProvider = Mockito.mockStatic(FacadeProvider.class)) {
facadeProvider.when(FacadeProvider::getCustomizableEnumFacade).thenReturn(customizableEnumFacade);
// No disease variant set
ImmutableTriple<String, DiseaseVariant, String> result = mapper.migrateDiseaseVariant(testReport);
assertNull(result.getLeft());
assertNull(result.getMiddle());
assertNull(result.getRight());
// Unknown disease variant set
testReport.setTestedDiseaseVariant("NON-EXISTENT");
result = mapper.migrateDiseaseVariant(testReport);
assertEquals(I18nProperties.getPrefixCaption(PathogenTestDto.I18N_PREFIX, PathogenTestDto.TESTED_DISEASE_VARIANT) + ": NON-EXISTENT\n", result.getLeft());
assertNull(result.getMiddle());
assertNull(result.getRight());
// Unknown disease variant and disease variant details set
testReport.setTestedDiseaseVariantDetails("SOME-DETAILS");
result = mapper.migrateDiseaseVariant(testReport);
assertEquals(I18nProperties.getPrefixCaption(PathogenTestDto.I18N_PREFIX, PathogenTestDto.TESTED_DISEASE_VARIANT) + ": NON-EXISTENT\n" + I18nProperties.getPrefixCaption(PathogenTestDto.I18N_PREFIX, PathogenTestDto.TESTED_DISEASE_VARIANT_DETAILS) + ": SOME-DETAILS\n", result.getLeft());
assertNull(result.getMiddle());
assertNull(result.getRight());
// Only disease variant details set
testReport.setTestedDiseaseVariant(null);
result = mapper.migrateDiseaseVariant(testReport);
assertEquals(I18nProperties.getPrefixCaption(PathogenTestDto.I18N_PREFIX, PathogenTestDto.TESTED_DISEASE_VARIANT_DETAILS) + ": SOME-DETAILS\n", result.getLeft());
assertNull(result.getMiddle());
assertNull(result.getRight());
// Known disease variant and disease variant details set
testReport.setTestedDiseaseVariant("P.2");
result = mapper.migrateDiseaseVariant(testReport);
assertNull(result.getLeft());
assertEquals(diseaseVariant, result.getMiddle());
assertEquals("SOME-DETAILS", result.getRight());
// Known disease variant set
testReport.setTestedDiseaseVariantDetails(null);
result = mapper.migrateDiseaseVariant(testReport);
assertNull(result.getLeft());
assertEquals(diseaseVariant, result.getMiddle());
assertNull(result.getRight());
}
}
use of de.symeda.sormas.api.disease.DiseaseVariant in project SORMAS-Project by hzi-braunschweig.
the class PathogenTestEditActivity method saveData.
@Override
public void saveData() {
if (saveTask != null) {
NotificationHelper.showNotification(this, WARNING, getString(R.string.message_already_saving));
// don't save multiple times
return;
}
final PathogenTest pathogenTestToSave = getStoredRootEntity();
final Case associatedCase = pathogenTestToSave.getSample().getAssociatedCase();
if (associatedCase != null) {
DiseaseVariant caseDiseaseVariant = associatedCase.getDiseaseVariant();
DiseaseVariant newDiseaseVariant = pathogenTestToSave.getTestedDiseaseVariant();
if (pathogenTestToSave.getTestResult() == PathogenTestResultType.POSITIVE && pathogenTestToSave.getTestResultVerified() && !DataHelper.equal(newDiseaseVariant, caseDiseaseVariant)) {
String heading = I18nProperties.getString(Strings.headingUpdateCaseWithNewDiseaseVariant);
String subHeading = I18nProperties.getString(Strings.messageUpdateCaseWithNewDiseaseVariant);
int positiveButtonTextResId = R.string.yes;
int negativeButtonTextResId = R.string.no;
ConfirmationDialog dlg = new ConfirmationDialog(this, heading, subHeading, positiveButtonTextResId, negativeButtonTextResId);
dlg.setCancelable(false);
dlg.setNegativeCallback(() -> {
save(pathogenTestToSave, associatedCase);
});
dlg.setPositiveCallback(() -> {
associatedCase.setDiseaseVariant(newDiseaseVariant);
try {
DatabaseHelper.getCaseDao().updateOrCreate(associatedCase);
} catch (SQLException | java.sql.SQLException e) {
Log.e(getClass().getSimpleName(), "Could not update case: " + associatedCase.getUuid());
throw new RuntimeException(e);
}
save(pathogenTestToSave, associatedCase);
});
dlg.show();
} else {
save(pathogenTestToSave, associatedCase);
}
}
}
Aggregations