use of de.symeda.sormas.api.report.WeeklyReportOfficerSummaryDto in project SORMAS-Project by hzi-braunschweig.
the class WeeklyReportOfficersGrid method reload.
public void reload(RegionReferenceDto region, int year, int week) {
this.region = region;
this.week = week;
this.year = year;
getContainer().removeAllItems();
EpiWeek epiWeek = new EpiWeek(year, week);
List<WeeklyReportOfficerSummaryDto> summaryDtos = FacadeProvider.getWeeklyReportFacade().getSummariesPerOfficer(region, epiWeek);
summaryDtos.forEach(s -> getContainer().addItem(s));
}
use of de.symeda.sormas.api.report.WeeklyReportOfficerSummaryDto in project SORMAS-Project by hzi-braunschweig.
the class WeeklyReportOfficersGrid method itemClick.
@Override
public void itemClick(ItemClickEvent event) {
if (event.getPropertyId().equals(VIEW_DETAILS_BTN_ID)) {
WeeklyReportOfficerSummaryDto summaryDto = (WeeklyReportOfficerSummaryDto) event.getItemId();
if (summaryDto.getInformants() > 0) {
VerticalLayout layout = new VerticalLayout();
layout.setSizeUndefined();
layout.setMargin(true);
Window window = VaadinUiUtil.showPopupWindow(layout);
WeeklyReportInformantsGrid grid = new WeeklyReportInformantsGrid(summaryDto.getOfficer(), new EpiWeek(year, week));
grid.setWidth(960, Unit.PIXELS);
grid.setHeightMode(HeightMode.ROW);
grid.setHeightUndefined();
layout.addComponent(grid);
window.setCaption(String.format(I18nProperties.getCaption(Captions.weeklyReportsInDistrict), summaryDto.getDistrict().toString()) + " - " + I18nProperties.getString(Strings.epiWeek) + " " + week + "/" + year);
}
}
}
use of de.symeda.sormas.api.report.WeeklyReportOfficerSummaryDto in project SORMAS-Project by hzi-braunschweig.
the class WeeklyReportFacadeEjb method getSummariesPerOfficer.
@Override
public List<WeeklyReportOfficerSummaryDto> getSummariesPerOfficer(RegionReferenceDto regionRef, EpiWeek epiWeek) {
WeeklyReportCriteria officerReportCriteria = new WeeklyReportCriteria().epiWeek(epiWeek);
WeeklyReportCriteria informantsReportCriteria = new WeeklyReportCriteria().epiWeek(epiWeek).officerReport(false);
Region region = regionService.getByReferenceDto(regionRef);
Stream<User> officers = userService.getAllByDistrictsAndUserRights(region.getDistricts(), Collections.singletonList(UserRight.WEEKLYREPORT_CREATE)).stream();
officers = weeklyReportService.filterWeeklyReportUsers(userService.getCurrentUser(), officers);
List<WeeklyReportOfficerSummaryDto> summaryDtos = officers.sorted(Comparator.comparing(a -> a.getDistrict().getName())).map(officer -> {
WeeklyReportOfficerSummaryDto summaryDto = new WeeklyReportOfficerSummaryDto();
summaryDto.setOfficer(UserFacadeEjb.toReferenceDto(officer));
summaryDto.setDistrict(DistrictFacadeEjb.toReferenceDto(officer.getDistrict()));
{
officerReportCriteria.reportingUser(new UserReferenceDto(officer.getUuid()));
weeklyReportService.queryByCriteria(officerReportCriteria, null, null, true).stream().findFirst().ifPresent(officerReport -> {
summaryDto.setOfficerReportDate(officerReport.getReportDateTime());
summaryDto.setTotalCaseCount(officerReport.getTotalNumberOfCases());
});
}
{
Long informants = userService.countByAssignedOfficer(officer, UserRight.WEEKLYREPORT_CREATE);
summaryDto.setInformants(informants.intValue());
}
informantsReportCriteria.assignedOfficer(summaryDto.getOfficer());
{
informantsReportCriteria.zeroReport(false);
Long informantCaseReports = weeklyReportService.countByCriteria(informantsReportCriteria, null);
summaryDto.setInformantCaseReports(informantCaseReports.intValue());
}
{
informantsReportCriteria.zeroReport(true);
Long informantZeroReports = weeklyReportService.countByCriteria(informantsReportCriteria, null);
summaryDto.setInformantZeroReports(informantZeroReports.intValue());
}
return summaryDto;
}).collect(Collectors.toList());
return summaryDtos;
}
use of de.symeda.sormas.api.report.WeeklyReportOfficerSummaryDto in project SORMAS-Project by hzi-braunschweig.
the class WeeklyReportFacadeEjbTest method testGetSummariesPerOfficer.
@Test
public void testGetSummariesPerOfficer() {
EpiWeek previousEpiWeek = DateHelper.getPreviousEpiWeek(new Date());
createFacilityInformantReport(informant1, new Date(), previousEpiWeek.getWeek(), previousEpiWeek.getYear(), 1);
createCommunityInformantReport(informant3, new Date(), previousEpiWeek.getWeek(), previousEpiWeek.getYear(), 1);
createFacilityInformantReport(informant4, new Date(), previousEpiWeek.getWeek(), previousEpiWeek.getYear(), 0);
List<WeeklyReportOfficerSummaryDto> summariesPerRegion = getWeeklyReportFacade().getSummariesPerOfficer(officer.getRegion(), previousEpiWeek);
assertEquals(1, summariesPerRegion.size());
WeeklyReportOfficerSummaryDto summary = summariesPerRegion.get(0);
assertEquals(4, summary.getInformants());
assertEquals(2, summary.getInformantCaseReports());
assertEquals(1, summary.getInformantZeroReports());
assertEquals(1, summary.getInformantMissingReports());
}
Aggregations