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());
}
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());
}
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;
}
}
}
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);
}
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());
}
Aggregations