Search in sources :

Example 1 with WeeklyReportOfficerSummaryDto

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));
}
Also used : WeeklyReportOfficerSummaryDto(de.symeda.sormas.api.report.WeeklyReportOfficerSummaryDto) EpiWeek(de.symeda.sormas.api.utils.EpiWeek)

Example 2 with WeeklyReportOfficerSummaryDto

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);
        }
    }
}
Also used : Window(com.vaadin.ui.Window) WeeklyReportOfficerSummaryDto(de.symeda.sormas.api.report.WeeklyReportOfficerSummaryDto) VerticalLayout(com.vaadin.ui.VerticalLayout) EpiWeek(de.symeda.sormas.api.utils.EpiWeek)

Example 3 with WeeklyReportOfficerSummaryDto

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;
}
Also used : DtoHelper(de.symeda.sormas.backend.util.DtoHelper) RolesAllowed(javax.annotation.security.RolesAllowed) Date(java.util.Date) EpiWeek(de.symeda.sormas.api.utils.EpiWeek) LoggerFactory(org.slf4j.LoggerFactory) CommunityFacadeEjb(de.symeda.sormas.backend.infrastructure.community.CommunityFacadeEjb) DistrictService(de.symeda.sormas.backend.infrastructure.district.DistrictService) Valid(javax.validation.Valid) WeeklyReportCriteria(de.symeda.sormas.api.report.WeeklyReportCriteria) TransactionAttributeType(javax.ejb.TransactionAttributeType) WeeklyReportDto(de.symeda.sormas.api.report.WeeklyReportDto) UserFacadeEjb(de.symeda.sormas.backend.user.UserFacadeEjb) Stateless(javax.ejb.Stateless) FacilityService(de.symeda.sormas.backend.infrastructure.facility.FacilityService) CommunityService(de.symeda.sormas.backend.infrastructure.community.CommunityService) FacilityType(de.symeda.sormas.api.infrastructure.facility.FacilityType) Region(de.symeda.sormas.backend.infrastructure.region.Region) NotNull(javax.validation.constraints.NotNull) WeeklyReportEntryDto(de.symeda.sormas.api.report.WeeklyReportEntryDto) Collectors(java.util.stream.Collectors) TaskType(de.symeda.sormas.api.task.TaskType) PointOfEntryService(de.symeda.sormas.backend.infrastructure.pointofentry.PointOfEntryService) List(java.util.List) UserService(de.symeda.sormas.backend.user.UserService) Stream(java.util.stream.Stream) DistrictFacadeEjb(de.symeda.sormas.backend.infrastructure.district.DistrictFacadeEjb) User(de.symeda.sormas.backend.user.User) LocalDate(java.time.LocalDate) JurisdictionLevel(de.symeda.sormas.api.user.JurisdictionLevel) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) TaskService(de.symeda.sormas.backend.task.TaskService) LocalDateTime(java.time.LocalDateTime) DateHelper(de.symeda.sormas.api.utils.DateHelper) FacilityFacadeEjb(de.symeda.sormas.backend.infrastructure.facility.FacilityFacadeEjb) ArrayList(java.util.ArrayList) WeeklyReportOfficerSummaryDto(de.symeda.sormas.api.report.WeeklyReportOfficerSummaryDto) TransactionAttribute(javax.ejb.TransactionAttribute) TaskStatus(de.symeda.sormas.api.task.TaskStatus) LocalBean(javax.ejb.LocalBean) EJB(javax.ejb.EJB) TaskCriteria(de.symeda.sormas.api.task.TaskCriteria) TaskContext(de.symeda.sormas.api.task.TaskContext) WeeklyReportRegionSummaryDto(de.symeda.sormas.api.report.WeeklyReportRegionSummaryDto) Logger(org.slf4j.Logger) DataHelper(de.symeda.sormas.api.utils.DataHelper) Task(de.symeda.sormas.backend.task.Task) RegionFacadeEjb(de.symeda.sormas.backend.infrastructure.region.RegionFacadeEjb) RegionService(de.symeda.sormas.backend.infrastructure.region.RegionService) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) UserRight(de.symeda.sormas.api.user.UserRight) WeeklyReportFacade(de.symeda.sormas.api.report.WeeklyReportFacade) WeeklyReportReferenceDto(de.symeda.sormas.api.report.WeeklyReportReferenceDto) DateHelper8(de.symeda.sormas.backend.util.DateHelper8) Comparator(java.util.Comparator) Collections(java.util.Collections) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) User(de.symeda.sormas.backend.user.User) WeeklyReportOfficerSummaryDto(de.symeda.sormas.api.report.WeeklyReportOfficerSummaryDto) Region(de.symeda.sormas.backend.infrastructure.region.Region) WeeklyReportCriteria(de.symeda.sormas.api.report.WeeklyReportCriteria)

Example 4 with WeeklyReportOfficerSummaryDto

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());
}
Also used : WeeklyReportOfficerSummaryDto(de.symeda.sormas.api.report.WeeklyReportOfficerSummaryDto) Date(java.util.Date) EpiWeek(de.symeda.sormas.api.utils.EpiWeek) Test(org.junit.Test) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest)

Aggregations

WeeklyReportOfficerSummaryDto (de.symeda.sormas.api.report.WeeklyReportOfficerSummaryDto)4 EpiWeek (de.symeda.sormas.api.utils.EpiWeek)4 Date (java.util.Date)2 VerticalLayout (com.vaadin.ui.VerticalLayout)1 Window (com.vaadin.ui.Window)1 FacilityType (de.symeda.sormas.api.infrastructure.facility.FacilityType)1 RegionReferenceDto (de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)1 WeeklyReportCriteria (de.symeda.sormas.api.report.WeeklyReportCriteria)1 WeeklyReportDto (de.symeda.sormas.api.report.WeeklyReportDto)1 WeeklyReportEntryDto (de.symeda.sormas.api.report.WeeklyReportEntryDto)1 WeeklyReportFacade (de.symeda.sormas.api.report.WeeklyReportFacade)1 WeeklyReportReferenceDto (de.symeda.sormas.api.report.WeeklyReportReferenceDto)1 WeeklyReportRegionSummaryDto (de.symeda.sormas.api.report.WeeklyReportRegionSummaryDto)1 TaskContext (de.symeda.sormas.api.task.TaskContext)1 TaskCriteria (de.symeda.sormas.api.task.TaskCriteria)1 TaskStatus (de.symeda.sormas.api.task.TaskStatus)1 TaskType (de.symeda.sormas.api.task.TaskType)1 JurisdictionLevel (de.symeda.sormas.api.user.JurisdictionLevel)1 UserReferenceDto (de.symeda.sormas.api.user.UserReferenceDto)1 UserRight (de.symeda.sormas.api.user.UserRight)1