use of de.symeda.sormas.api.Disease 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 in project SORMAS-Project by hzi-braunschweig.
the class CaseFilterForm method applyDependenciesOnFieldChange.
@Override
protected void applyDependenciesOnFieldChange(String propertyId, Property.ValueChangeEvent event) {
super.applyDependenciesOnFieldChange(propertyId, event);
final CaseCriteria criteria = getValue();
final ComboBox regionField = getField(CaseDataDto.REGION);
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);
final ComboBox caseOriginField = getField(CaseDataDto.CASE_ORIGIN);
final UserDto user = currentUserDto();
final DistrictReferenceDto currentDistrict = user.getDistrict() != null ? user.getDistrict() : (DistrictReferenceDto) districtField.getValue();
final CaseOrigin currentCaseOrigin = caseOriginField != null ? (CaseOrigin) getField(CaseDataDto.CASE_ORIGIN).getValue() : CaseOrigin.POINT_OF_ENTRY;
switch(propertyId) {
case CaseDataDto.REGION:
{
final RegionReferenceDto region = user.getRegion() != null ? user.getRegion() : (RegionReferenceDto) event.getProperty().getValue();
if (!DataHelper.equal(region, criteria.getRegion())) {
final ComboBox officerField = getField(CaseDataDto.SURVEILLANCE_OFFICER);
officerField.removeAllItems();
if (region != null) {
enableFields(districtField);
FieldHelper.updateItems(districtField, FacadeProvider.getDistrictFacade().getAllActiveByRegion(region.getUuid()));
disableFields(pointOfEntryField);
clearAndDisableFields(communityField, facilityField, facilityTypeField, facilityTypeGroupField);
addOfficers(officerField, region);
} else {
clearAndDisableFields(districtField, communityField, facilityField, facilityTypeField, facilityTypeGroupField);
disableFields(pointOfEntryField);
addOfficers(officerField, user.getRegion());
}
}
break;
}
case CaseDataDto.DISTRICT:
{
final DistrictReferenceDto newDistrict = (DistrictReferenceDto) event.getProperty().getValue();
if (!DataHelper.equal(newDistrict, criteria.getDistrict())) {
final ComboBox officerField = getField(CaseDataDto.SURVEILLANCE_OFFICER);
officerField.removeAllItems();
if (newDistrict != null) {
enableFields(communityField, facilityTypeGroupField);
clearAndDisableFields(facilityField);
if (facilityTypeGroupField != null) {
if (facilityTypeGroupField.getValue() != null && facilityTypeField.getValue() != null) {
FieldHelper.updateItems(facilityField, FacadeProvider.getFacilityFacade().getActiveFacilitiesByDistrictAndType(newDistrict, (FacilityType) facilityTypeField.getValue(), true, false));
enableFields(facilityField);
} else {
FieldHelper.updateEnumData(facilityTypeGroupField, FacilityTypeGroup.getAccomodationGroups());
}
}
FieldHelper.updateItems(communityField, FacadeProvider.getCommunityFacade().getAllActiveByDistrict(newDistrict.getUuid()));
if (pointOfEntryField != null && currentCaseOrigin == CaseOrigin.POINT_OF_ENTRY) {
pointOfEntryField.setEnabled(true);
FieldHelper.updateItems(pointOfEntryField, FacadeProvider.getPointOfEntryFacade().getAllActiveByDistrict(newDistrict.getUuid(), true));
}
officerField.addItems(FacadeProvider.getUserFacade().getUserRefsByDistrict(newDistrict, false, UserRole.SURVEILLANCE_OFFICER));
} else {
clearAndDisableFields(communityField, pointOfEntryField, facilityField, facilityTypeField, facilityTypeGroupField);
final RegionReferenceDto region = regionField != null ? (RegionReferenceDto) regionField.getValue() : null;
addOfficers(officerField, region != null ? region : user.getRegion());
}
}
break;
}
case CaseDataDto.COMMUNITY:
{
CommunityReferenceDto community = (CommunityReferenceDto) event.getProperty().getValue();
if (!DataHelper.equal(community, criteria.getCommunity())) {
if (facilityField != null) {
facilityField.setValue(null);
}
final FacilityType facilityType = facilityTypeField != null ? (FacilityType) facilityTypeField.getValue() : null;
if (facilityType == null && facilityField != null) {
facilityField.removeAllItems();
} else if (facilityField != null) {
if (community == null) {
FieldHelper.updateItems(facilityField, FacadeProvider.getFacilityFacade().getActiveFacilitiesByDistrictAndType(currentDistrict, facilityType, true, false));
} else {
FieldHelper.updateItems(facilityField, FacadeProvider.getFacilityFacade().getActiveFacilitiesByCommunityAndType(community, facilityType, true, false));
}
}
}
break;
}
case CaseCriteria.FACILITY_TYPE_GROUP:
{
FacilityTypeGroup typeGroup = (FacilityTypeGroup) event.getProperty().getValue();
if (!DataHelper.equal(typeGroup, criteria.getFacilityTypeGroup())) {
if (typeGroup != null) {
enableFields(CaseDataDto.FACILITY_TYPE);
FieldHelper.updateEnumData(facilityTypeField, FacilityType.getAccommodationTypes(typeGroup));
facilityField.setValue(null);
} else {
clearAndDisableFields(facilityTypeField, facilityField);
}
}
break;
}
case CaseCriteria.FACILITY_TYPE:
{
FacilityType facilityType = (FacilityType) event.getProperty().getValue();
if (!DataHelper.equal(facilityType, criteria.getFacilityType())) {
if (facilityType == null) {
clearAndDisableFields(facilityField);
} else {
enableFields(facilityField);
facilityField.setValue(null);
CommunityReferenceDto community = (CommunityReferenceDto) communityField.getValue();
if (community != null) {
FieldHelper.updateItems(facilityField, FacadeProvider.getFacilityFacade().getActiveFacilitiesByCommunityAndType(community, facilityType, true, false));
} else if (currentDistrict != null) {
FieldHelper.updateItems(facilityField, FacadeProvider.getFacilityFacade().getActiveFacilitiesByDistrictAndType(currentDistrict, facilityType, true, false));
}
}
}
break;
}
case CaseCriteria.BIRTHDATE_MM:
{
Integer birthMM = (Integer) event.getProperty().getValue();
ComboBox birthDayDD = getField(CaseCriteria.BIRTHDATE_DD);
birthDayDD.setEnabled(birthMM != null);
FieldHelper.updateItems(birthDayDD, DateHelper.getDaysInMonth((Integer) getField(CaseCriteria.BIRTHDATE_MM).getValue(), (Integer) getField(CaseCriteria.BIRTHDATE_YYYY).getValue()));
break;
}
case CaseDataDto.CASE_ORIGIN:
{
if (pointOfEntryField != null) {
CaseOrigin caseOrigin = (CaseOrigin) event.getProperty().getValue();
if (caseOrigin == CaseOrigin.POINT_OF_ENTRY && currentDistrict != null) {
pointOfEntryField.setEnabled(true);
FieldHelper.updateItems(pointOfEntryField, FacadeProvider.getPointOfEntryFacade().getAllActiveByDistrict(currentDistrict.getUuid(), true));
} else {
clearAndDisableFields(CaseDataDto.POINT_OF_ENTRY);
}
}
break;
}
case CaseDataDto.DISEASE:
{
ComboBox field = getField(CaseDataDto.DISEASE_VARIANT);
Disease disease = (Disease) event.getProperty().getValue();
if (disease == null) {
FieldHelper.updateItems(field, Collections.emptyList());
FieldHelper.setEnabled(false, field);
} else {
List<DiseaseVariant> diseaseVariants = FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.DISEASE_VARIANT, disease);
FieldHelper.updateItems(field, diseaseVariants);
FieldHelper.setEnabled(CollectionUtils.isNotEmpty(diseaseVariants), field);
}
}
}
}
use of de.symeda.sormas.api.Disease in project SORMAS-Project by hzi-braunschweig.
the class TestEntityCreator method createCase.
public static Case createCase(Person person) {
Disease disease = Disease.EVD;
Region region = DatabaseHelper.getRegionDao().queryUuid(TestHelper.REGION_UUID);
District district = DatabaseHelper.getDistrictDao().queryUuid(TestHelper.DISTRICT_UUID);
Community community = DatabaseHelper.getCommunityDao().queryUuid(TestHelper.COMMUNITY_UUID);
Facility facility = DatabaseHelper.getFacilityDao().queryUuid(TestHelper.FACILITY_UUID);
CaseClassification caseClassification = CaseClassification.SUSPECT;
InvestigationStatus investigationStatus = InvestigationStatus.PENDING;
Case caze = DatabaseHelper.getCaseDao().build(person);
caze.setDisease(disease);
caze.setResponsibleRegion(region);
caze.setResponsibleDistrict(district);
caze.setResponsibleCommunity(community);
caze.setHealthFacility(facility);
caze.setFacilityType(FacilityType.HOSPITAL);
caze.setCaseClassification(caseClassification);
caze.setInvestigationStatus(investigationStatus);
caze.setReportDate(new Date());
try {
DatabaseHelper.getCaseDao().saveAndSnapshot(caze);
DatabaseHelper.getCaseDao().accept(caze);
} catch (DaoException e) {
throw new RuntimeException(e);
}
return DatabaseHelper.getCaseDao().queryForIdWithEmbedded(caze.getId());
}
use of de.symeda.sormas.api.Disease in project SORMAS-Project by hzi-braunschweig.
the class VaccinationFacadeEjbTest method testGetEntriesList.
@Test
public void testGetEntriesList() {
loginWith(nationalUser);
PersonDto person1 = creator.createPerson("John", "Doe");
PersonDto person2 = creator.createPerson("Jane", "Doe");
Disease disease1 = Disease.CORONAVIRUS;
Disease disease2 = Disease.CHOLERA;
ImmunizationDto immunization11 = creator.createImmunization(disease1, person1.toReference(), nationalUser.toReference(), rdcf1);
ImmunizationDto immunization12 = creator.createImmunization(disease1, person1.toReference(), nationalUser.toReference(), rdcf1);
ImmunizationDto immunization13 = creator.createImmunization(disease2, person1.toReference(), nationalUser.toReference(), rdcf1);
ImmunizationDto immunization21 = creator.createImmunization(disease1, person2.toReference(), nationalUser.toReference(), rdcf1);
creator.createImmunization(disease2, person2.toReference(), nationalUser.toReference(), rdcf1);
VaccinationDto vaccination111 = creator.createVaccination(nationalUser.toReference(), immunization11.toReference());
VaccinationDto vaccination112 = creator.createVaccination(nationalUser.toReference(), immunization11.toReference());
VaccinationDto vaccination121 = creator.createVaccination(nationalUser.toReference(), immunization12.toReference());
VaccinationDto vaccination131 = creator.createVaccination(nationalUser.toReference(), immunization13.toReference());
VaccinationDto vaccination211 = creator.createVaccination(nationalUser.toReference(), immunization21.toReference());
VaccinationDto vaccination212 = creator.createVaccination(nationalUser.toReference(), immunization21.toReference());
List<VaccinationListEntryDto> vaccinations = getVaccinationFacade().getEntriesList(new VaccinationListCriteria.Builder(person1.toReference()).withDisease(disease1).build(), null, null, null);
assertThat(vaccinations, hasSize(3));
assertThat(vaccinations, hasItems(hasProperty(EntityDto.UUID, is(vaccination111.getUuid())), hasProperty(EntityDto.UUID, is(vaccination112.getUuid())), hasProperty(EntityDto.UUID, is(vaccination121.getUuid()))));
vaccinations = getVaccinationFacade().getEntriesList(new VaccinationListCriteria.Builder(person1.toReference()).withDisease(disease2).build(), null, null, null);
assertThat(vaccinations, hasSize(1));
assertThat(vaccinations, hasItem(hasProperty(EntityDto.UUID, is(vaccination131.getUuid()))));
vaccinations = getVaccinationFacade().getEntriesList(new VaccinationListCriteria.Builder(person2.toReference()).withDisease(disease1).build(), null, null, null);
assertThat(vaccinations, hasSize(2));
assertThat(vaccinations, hasItems(hasProperty(EntityDto.UUID, is(vaccination211.getUuid())), hasProperty(EntityDto.UUID, is(vaccination212.getUuid()))));
vaccinations = getVaccinationFacade().getEntriesList(new VaccinationListCriteria.Builder(person2.toReference()).withDisease(disease2).build(), null, null, null);
assertThat(vaccinations, hasSize(0));
}
use of de.symeda.sormas.api.Disease in project SORMAS-Project by hzi-braunschweig.
the class DashboardMapComponent method getMarkerCount.
private Long getMarkerCount(Date fromDate, Date toDate, int maxCount) {
RegionReferenceDto region = dashboardDataProvider.getRegion();
DistrictReferenceDto district = dashboardDataProvider.getDistrict();
Disease disease = dashboardDataProvider.getDisease();
Long count = 0L;
if (showCases) {
count += FacadeProvider.getCaseFacade().countCasesForMap(region, district, disease, fromDate, toDate, showCurrentEpiSituation ? null : dashboardDataProvider.getNewCaseDateType());
}
if (count < maxCount && showContacts) {
count += FacadeProvider.getContactFacade().countContactsForMap(region, district, disease, fromDate, toDate);
}
if (count < maxCount && showEvents) {
count += dashboardDataProvider.getEvents().size();
}
return count;
}
Aggregations