use of de.symeda.sormas.api.infrastructure.region.RegionReferenceDto in project SORMAS-Project by hzi-braunschweig.
the class EventGroupMemberList method drawDisplayedEntries.
@Override
protected void drawDisplayedEntries() {
List<EventIndexDto> displayedEntries = getDisplayedEntries();
for (int i = 0, displayedEntriesSize = displayedEntries.size(); i < displayedEntriesSize; i++) {
EventIndexDto event = displayedEntries.get(i);
EventGroupMemberListEntry listEntry = new EventGroupMemberListEntry(event);
UserProvider user = UserProvider.getCurrent();
if (user.hasUserRight(UserRight.EVENTGROUP_LINK)) {
listEntry.addUnlinkEventListener(i, (ClickListener) clickEvent -> {
if (!user.hasNationalJurisdictionLevel() && !user.hasRegion(new RegionReferenceDto(event.getRegionUuid()))) {
new Notification(I18nProperties.getString(Strings.headingEventGroupUnlinkEventIssue), I18nProperties.getString(Strings.errorEventFromAnotherJurisdiction), Notification.Type.ERROR_MESSAGE, false).show(Page.getCurrent());
return;
}
ControllerProvider.getEventGroupController().unlinkEventGroup(event.toReference(), eventGroupReference);
reload();
});
}
if (user.hasUserRight(UserRight.EVENTGROUP_EDIT)) {
listEntry.addEditListener(i, (ClickListener) clickEvent -> ControllerProvider.getEventController().navigateToData(listEntry.getEvent().getUuid()));
}
listLayout.addComponent(listEntry);
}
}
use of de.symeda.sormas.api.infrastructure.region.RegionReferenceDto in project SORMAS-Project by hzi-braunschweig.
the class EventsFilterForm method applyDependenciesOnNewValue.
@Override
protected void applyDependenciesOnNewValue(EventCriteria criteria) {
applyDateDependencyOnNewValue(EVENT_WEEK_AND_DATE_FILTER, criteria.getDateFilterOption(), criteria.getEventDateFrom(), criteria.getEventDateTo());
applyDateDependencyOnNewValue(EVENT_SIGNAL_EVOLUTION_WEEK_AND_DATE_FILTER, criteria.getEvolutionDateFilterOption(), criteria.getEventEvolutionDateFrom(), criteria.getEventEvolutionDateTo());
applyDateDependencyOnNewValue(ACTION_CHANGE_WEEK_AND_DATE_FILTER, criteria.getActionChangeDateFilterOption(), criteria.getActionChangeDateFrom(), criteria.getActionChangeDateTo());
applyDateDependencyOnNewValue(ACTION_WEEK_AND_DATE_FILTER, criteria.getActionDateFilterOption(), criteria.getActionDateFrom(), criteria.getActionDateTo());
RegionReferenceDto region = criteria.getRegion();
DistrictReferenceDto district = criteria.getDistrict();
applyRegionAndDistrictFilterDependency(region, LocationDto.DISTRICT, district, LocationDto.COMMUNITY);
applyFacilityFieldsDependencies(criteria.getTypeOfPlace(), criteria.getDistrict(), criteria.getCommunity());
updateResponsibleUserFieldItems(criteria.getDistrict(), criteria.getRegion());
ComboBox diseaseField = getField(CaseDataDto.DISEASE);
Disease disease = (Disease) diseaseField.getValue();
applyDiseaseFilterDependency(disease);
}
use of de.symeda.sormas.api.infrastructure.region.RegionReferenceDto in project SORMAS-Project by hzi-braunschweig.
the class ImmunizationFilterForm method applyDependenciesOnFieldChange.
@Override
protected void applyDependenciesOnFieldChange(String propertyId, Property.ValueChangeEvent event) {
super.applyDependenciesOnFieldChange(propertyId, event);
final ImmunizationCriteria criteria = getValue();
final ComboBox districtField = getField(ImmunizationCriteria.DISTRICT);
final ComboBox communityField = getField(ImmunizationCriteria.COMMUNITY);
final ComboBox facilityTypeGroupField = getField(ImmunizationCriteria.FACILITY_TYPE_GROUP);
final ComboBox facilityTypeField = getField(ImmunizationCriteria.FACILITY_TYPE);
final ComboBox facilityField = getField(ImmunizationCriteria.HEALTH_FACILITY);
final UserDto user = currentUserDto();
final DistrictReferenceDto currentDistrict = user.getDistrict() != null ? user.getDistrict() : (DistrictReferenceDto) districtField.getValue();
switch(propertyId) {
case ImmunizationCriteria.REGION:
{
final RegionReferenceDto region = user.getRegion() != null ? user.getRegion() : (RegionReferenceDto) event.getProperty().getValue();
if (!DataHelper.equal(region, criteria.getRegion())) {
if (region != null) {
enableFields(districtField);
FieldHelper.updateItems(districtField, FacadeProvider.getDistrictFacade().getAllActiveByRegion(region.getUuid()));
} else {
clearAndDisableFields(districtField);
}
clearAndDisableFields(communityField, facilityField, facilityTypeField, facilityTypeGroupField);
}
break;
}
case ImmunizationCriteria.DISTRICT:
{
final DistrictReferenceDto newDistrict = (DistrictReferenceDto) event.getProperty().getValue();
if (!DataHelper.equal(newDistrict, criteria.getDistrict())) {
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()));
} else {
clearAndDisableFields(communityField, facilityField, facilityTypeField, facilityTypeGroupField);
}
}
break;
}
case ImmunizationCriteria.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 ImmunizationCriteria.FACILITY_TYPE_GROUP:
{
FacilityTypeGroup typeGroup = (FacilityTypeGroup) event.getProperty().getValue();
if (!DataHelper.equal(typeGroup, criteria.getFacilityTypeGroup())) {
if (typeGroup != null) {
enableFields(ImmunizationCriteria.FACILITY_TYPE);
FieldHelper.updateEnumData(facilityTypeField, FacilityType.getAccommodationTypes(typeGroup));
facilityField.setValue(null);
} else {
clearAndDisableFields(facilityTypeField, facilityField);
}
}
break;
}
case ImmunizationCriteria.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 ImmunizationCriteria.BIRTHDATE_MM:
{
Integer birthMM = (Integer) event.getProperty().getValue();
ComboBox birthDayDD = getField(ImmunizationCriteria.BIRTHDATE_DD);
birthDayDD.setEnabled(birthMM != null);
FieldHelper.updateItems(birthDayDD, DateHelper.getDaysInMonth((Integer) getField(ImmunizationCriteria.BIRTHDATE_MM).getValue(), (Integer) getField(ImmunizationCriteria.BIRTHDATE_YYYY).getValue()));
break;
}
}
}
use of de.symeda.sormas.api.infrastructure.region.RegionReferenceDto in project SORMAS-Project by hzi-braunschweig.
the class ImmunizationFilterForm method applyDependenciesOnNewValue.
@Override
protected void applyDependenciesOnNewValue(ImmunizationCriteria criteria) {
final UserDto user = currentUserDto();
UserProvider currentUserProvider = UserProvider.getCurrent();
final JurisdictionLevel userJurisdictionLevel = currentUserProvider != null ? UserRole.getJurisdictionLevel(currentUserProvider.getUserRoles()) : null;
final ComboBox districtField = getField(ImmunizationCriteria.DISTRICT);
final ComboBox communityField = getField(ImmunizationCriteria.COMMUNITY);
final ComboBox facilityTypeGroupField = getField(ImmunizationCriteria.FACILITY_TYPE_GROUP);
final ComboBox facilityTypeField = getField(ImmunizationCriteria.FACILITY_TYPE);
final ComboBox facilityField = getField(ImmunizationCriteria.HEALTH_FACILITY);
// Disable all fields
clearAndDisableFields(districtField, communityField, facilityTypeGroupField, facilityTypeField, facilityField);
// 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);
}
}
// 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);
}
ComboBox birthDateDD = getField(ImmunizationCriteria.BIRTHDATE_DD);
if (getField(ImmunizationCriteria.BIRTHDATE_YYYY).getValue() != null && getField(ImmunizationCriteria.BIRTHDATE_MM).getValue() != null) {
birthDateDD.addItems(DateHelper.getDaysInMonth((Integer) getField(ImmunizationCriteria.BIRTHDATE_MM).getValue(), (Integer) getField(ImmunizationCriteria.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<ImmunizationDateType> weekAndDateFilter = (EpiWeekAndDateFilterComponent<ImmunizationDateType>) dateFilterLayout.getComponent(0);
ImmunizationDateType immunizationDateType = criteria.getImmunizationDateType();
weekAndDateFilter.getDateTypeSelector().setValue(immunizationDateType);
weekAndDateFilter.getDateFilterOptionFilter().setValue(criteria.getDateFilterOption());
Date dateFrom = criteria.getFromDate();
Date dateTo = criteria.getToDate();
if (DateFilterOption.EPI_WEEK.equals(criteria.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);
}
}
use of de.symeda.sormas.api.infrastructure.region.RegionReferenceDto in project SORMAS-Project by hzi-braunschweig.
the class CaseFacadeEjbTest method testSetResponsibleSurveillanceOfficer.
@Test
public void testSetResponsibleSurveillanceOfficer() {
RDCF rdcf = creator.createRDCF();
RDCF rdcf2 = creator.createRDCF("Region2", "District2", "Community2", "Facility2");
RDCF rdcf3 = creator.createRDCF("Region3", "District3", "Community3", "Facility3");
creator.createUser(rdcf, "First", "User", UserRole.SURVEILLANCE_OFFICER).toReference();
UserReferenceDto survOff2 = creator.createUser(rdcf, "Second", "User", UserRole.SURVEILLANCE_OFFICER).toReference();
UserReferenceDto survOff3 = creator.createUser(rdcf2, "Third", "User", UserRole.SURVEILLANCE_OFFICER).toReference();
UserDto informant = creator.createUser(rdcf, UserRole.HOSPITAL_INFORMANT);
informant.setAssociatedOfficer(survOff3);
getUserFacade().saveUser(informant);
// Reporting user is set as surveillance officer
CaseDataDto caze = creator.createCase(survOff2, creator.createPerson().toReference(), rdcf);
assertThat(caze.getSurveillanceOfficer(), is(survOff2));
// Surveillance officer is removed if the responsible district changes
caze.setResponsibleRegion(new RegionReferenceDto(rdcf3.region.getUuid(), null, null));
caze.setResponsibleDistrict(new DistrictReferenceDto(rdcf3.district.getUuid(), null, null));
caze.setResponsibleCommunity(new CommunityReferenceDto(rdcf3.community.getUuid(), null, null));
caze.setHealthFacility(new FacilityReferenceDto(rdcf3.facility.getUuid(), null, null));
caze = getCaseFacade().save(caze);
assertNull(caze.getSurveillanceOfficer());
// Surveillance officer is set to the associated officer of an informant if available
caze.setRegion(new RegionReferenceDto(rdcf2.region.getUuid(), null, null));
caze.setDistrict(new DistrictReferenceDto(rdcf2.district.getUuid(), null, null));
caze.setCommunity(new CommunityReferenceDto(rdcf2.community.getUuid(), null, null));
caze.setHealthFacility(new FacilityReferenceDto(rdcf2.facility.getUuid(), null, null));
caze = getCaseFacade().save(caze);
assertThat(caze.getSurveillanceOfficer(), is(survOff3));
}
Aggregations