Search in sources :

Example 1 with ImmunizationCriteria

use of de.symeda.sormas.api.immunization.ImmunizationCriteria in project SORMAS-Project by hzi-braunschweig.

the class ImmunizationFacadeEjbTest method testOverdueImmunizationsFilterEnabledAtStartOfDay.

@Test
public void testOverdueImmunizationsFilterEnabledAtStartOfDay() {
    loginWith(nationalUser);
    final PersonDto person = creator.createPerson("John", "Doe");
    final Date startOfDay = DateHelper.getStartOfDay(new Date());
    final ImmunizationDto ongoingImmunizationThatEndedYesterday = createOngoingImmunizationWithEndDate(person, new DateTime(startOfDay).minusDays(1).toDate());
    createOngoingImmunizationWithEndDate(person, startOfDay);
    final ImmunizationCriteria immunizationCriteria = new ImmunizationCriteria();
    immunizationCriteria.setOnlyPersonsWithOverdueImmunization(true);
    final List<ImmunizationIndexDto> onlyOverdueImmunizations = getImmunizationFacade().getIndexList(immunizationCriteria, 0, 100, null);
    Assert.assertEquals(1, onlyOverdueImmunizations.size());
    Assert.assertEquals(ongoingImmunizationThatEndedYesterday.getUuid(), onlyOverdueImmunizations.get(0).getUuid());
}
Also used : ImmunizationIndexDto(de.symeda.sormas.api.immunization.ImmunizationIndexDto) ImmunizationDto(de.symeda.sormas.api.immunization.ImmunizationDto) ImmunizationCriteria(de.symeda.sormas.api.immunization.ImmunizationCriteria) PersonDto(de.symeda.sormas.api.person.PersonDto) Date(java.util.Date) DateTime(org.joda.time.DateTime) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 2 with ImmunizationCriteria

use of de.symeda.sormas.api.immunization.ImmunizationCriteria in project SORMAS-Project by hzi-braunschweig.

the class ImmunizationFacadeEjbTest method testGetIndexListIsFilteredByCurrentUserLimitedDisease.

@Test
public void testGetIndexListIsFilteredByCurrentUserLimitedDisease() {
    loginWith(nationalUser);
    final PersonDto person = creator.createPerson("John", "Doe");
    creator.createImmunization(Disease.ANTHRAX, person.toReference(), nationalUser.toReference(), ImmunizationStatus.ACQUIRED, MeansOfImmunization.VACCINATION, ImmunizationManagementStatus.COMPLETED, rdcf1);
    creator.createImmunization(Disease.CORONAVIRUS, person.toReference(), nationalUser.toReference(), ImmunizationStatus.ACQUIRED, MeansOfImmunization.VACCINATION, ImmunizationManagementStatus.COMPLETED, rdcf1);
    loginWith(districtUser1);
    Assert.assertEquals(2, getImmunizationFacade().getIndexList(new ImmunizationCriteria(), 0, 100, null).size());
    loginWith(covidLimitedDistrictUser);
    Assert.assertEquals(1, getImmunizationFacade().getIndexList(new ImmunizationCriteria(), 0, 100, null).size());
}
Also used : ImmunizationCriteria(de.symeda.sormas.api.immunization.ImmunizationCriteria) PersonDto(de.symeda.sormas.api.person.PersonDto) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 3 with ImmunizationCriteria

use of de.symeda.sormas.api.immunization.ImmunizationCriteria 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;
            }
    }
}
Also used : CommunityReferenceDto(de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) ImmunizationCriteria(de.symeda.sormas.api.immunization.ImmunizationCriteria) ComboBox(com.vaadin.v7.ui.ComboBox) UserDto(de.symeda.sormas.api.user.UserDto) FacilityTypeGroup(de.symeda.sormas.api.infrastructure.facility.FacilityTypeGroup) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) FacilityType(de.symeda.sormas.api.infrastructure.facility.FacilityType)

Example 4 with ImmunizationCriteria

use of de.symeda.sormas.api.immunization.ImmunizationCriteria in project SORMAS-Project by hzi-braunschweig.

the class ImmunizationGrid method setLazyDataProvider.

private void setLazyDataProvider() {
    DataProvider<ImmunizationIndexDto, ImmunizationCriteria> dataProvider = DataProvider.fromFilteringCallbacks(query -> FacadeProvider.getImmunizationFacade().getIndexList(query.getFilter().orElse(null), query.getOffset(), query.getLimit(), query.getSortOrders().stream().map(sortOrder -> new SortProperty(sortOrder.getSorted(), sortOrder.getDirection() == SortDirection.ASCENDING)).collect(Collectors.toList())).stream(), query -> (int) FacadeProvider.getImmunizationFacade().count(query.getFilter().orElse(null)));
    setDataProvider(dataProvider);
    setSelectionMode(SelectionMode.NONE);
}
Also used : ImmunizationIndexDto(de.symeda.sormas.api.immunization.ImmunizationIndexDto) SortProperty(de.symeda.sormas.api.utils.SortProperty) ImmunizationCriteria(de.symeda.sormas.api.immunization.ImmunizationCriteria)

Example 5 with ImmunizationCriteria

use of de.symeda.sormas.api.immunization.ImmunizationCriteria in project SORMAS-Project by hzi-braunschweig.

the class ImmunizationFacadeEjbTest method testOverdueImmunizationsFilterEnabled.

@Test
public void testOverdueImmunizationsFilterEnabled() {
    loginWith(nationalUser);
    final PersonDto person = creator.createPerson("John", "Doe");
    final Date now = new Date();
    final ImmunizationDto ongoingImmunizationThatEndedYesterday = createOngoingImmunizationWithEndDate(person, new DateTime(now).minusDays(1).toDate());
    createOngoingImmunizationWithEndDate(person, now);
    final ImmunizationCriteria immunizationCriteria = new ImmunizationCriteria();
    immunizationCriteria.setOnlyPersonsWithOverdueImmunization(true);
    final List<ImmunizationIndexDto> onlyOverdueImmunizations = getImmunizationFacade().getIndexList(immunizationCriteria, 0, 100, null);
    Assert.assertEquals(1, onlyOverdueImmunizations.size());
    Assert.assertEquals(ongoingImmunizationThatEndedYesterday.getUuid(), onlyOverdueImmunizations.get(0).getUuid());
}
Also used : ImmunizationIndexDto(de.symeda.sormas.api.immunization.ImmunizationIndexDto) ImmunizationDto(de.symeda.sormas.api.immunization.ImmunizationDto) ImmunizationCriteria(de.symeda.sormas.api.immunization.ImmunizationCriteria) PersonDto(de.symeda.sormas.api.person.PersonDto) Date(java.util.Date) DateTime(org.joda.time.DateTime) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Aggregations

ImmunizationCriteria (de.symeda.sormas.api.immunization.ImmunizationCriteria)7 ImmunizationIndexDto (de.symeda.sormas.api.immunization.ImmunizationIndexDto)4 PersonDto (de.symeda.sormas.api.person.PersonDto)4 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)4 Date (java.util.Date)4 Test (org.junit.Test)4 DateTime (org.joda.time.DateTime)3 ImmunizationDto (de.symeda.sormas.api.immunization.ImmunizationDto)2 ComboBox (com.vaadin.v7.ui.ComboBox)1 ImmunizationDateType (de.symeda.sormas.api.immunization.ImmunizationDateType)1 CommunityReferenceDto (de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto)1 DistrictReferenceDto (de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)1 FacilityType (de.symeda.sormas.api.infrastructure.facility.FacilityType)1 FacilityTypeGroup (de.symeda.sormas.api.infrastructure.facility.FacilityTypeGroup)1 RegionReferenceDto (de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)1 UserDto (de.symeda.sormas.api.user.UserDto)1 DateFilterOption (de.symeda.sormas.api.utils.DateFilterOption)1 EpiWeek (de.symeda.sormas.api.utils.EpiWeek)1 SortProperty (de.symeda.sormas.api.utils.SortProperty)1