use of de.symeda.sormas.api.report.AggregateReportCriteria in project SORMAS-Project by hzi-braunschweig.
the class AggregateReportFacadeEjb method getIndexList.
@Override
public List<AggregatedCaseCountDto> getIndexList(AggregateReportCriteria criteria) {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Object[]> cq = cb.createQuery(Object[].class);
Root<AggregateReport> root = cq.from(AggregateReport.class);
Predicate filter = service.createUserFilter(cb, cq, root);
if (criteria != null) {
Predicate criteriaFilter = service.createCriteriaFilter(criteria, cb, cq, root);
filter = CriteriaBuilderHelper.and(cb, filter, criteriaFilter);
}
if (filter != null) {
cq.where(filter);
}
cq.multiselect(root.get(AggregateReport.DISEASE), cb.sum(root.get(AggregateReport.NEW_CASES)), cb.sum(root.get(AggregateReport.LAB_CONFIRMATIONS)), cb.sum(root.get(AggregateReport.DEATHS)));
cq.groupBy(root.get(AggregateReport.DISEASE));
List<Object[]> resultList = em.createQuery(cq).getResultList();
Map<Disease, AggregatedCaseCountDto> reportSet = new HashMap<>();
for (Object[] result : resultList) {
reportSet.put((Disease) result[0], new AggregatedCaseCountDto((Disease) result[0], ((Long) result[1]).intValue(), ((Long) result[2]).intValue(), ((Long) result[3]).intValue()));
}
for (Disease disease : diseaseConfigurationFacade.getAllDiseases(true, false, false)) {
if (!reportSet.containsKey(disease)) {
reportSet.put(disease, new AggregatedCaseCountDto(disease, 0, 0, 0));
}
}
List<AggregatedCaseCountDto> reportList = new ArrayList<>(reportSet.values());
reportList.sort(Comparator.comparing(r -> r.getDisease().toString()));
return reportList;
}
use of de.symeda.sormas.api.report.AggregateReportCriteria in project SORMAS-Project by hzi-braunschweig.
the class AggregateReportsEditLayout method checkForExistingData.
private void checkForExistingData() {
if (comboBoxEpiweek.getValue() != null && (comboBoxFacility.getValue() != null || comboBoxPoe.getValue() != null) && !popUpIsShown) {
AggregateReportCriteria criteria = new AggregateReportCriteria();
criteria.setDistrict(comboBoxDistrict.getValue());
criteria.setEpiWeekFrom(comboBoxEpiweek.getValue());
criteria.setEpiWeekTo(comboBoxEpiweek.getValue());
criteria.setHealthFacility(comboBoxFacility.getValue());
criteria.setPointOfEntry(comboBoxPoe.getValue());
criteria.setRegion(comboBoxRegion.getValue());
reports = FacadeProvider.getAggregateReportFacade().getList(criteria).stream().collect(Collectors.toMap(AggregateReportDto::getDisease, dto -> dto));
if (!reports.isEmpty()) {
popUpIsShown = true;
Consumer<Boolean> resultConsumer = new Consumer<Boolean>() {
@Override
public void accept(Boolean edit) {
if (edit) {
switchToEditMode();
} else {
comboBoxFacility.clear();
comboBoxPoe.clear();
}
popUpIsShown = false;
}
};
VaadinUiUtil.showChooseOptionPopup(I18nProperties.getCaption(Captions.aggregateReportReportFound), new Label(I18nProperties.getString(Strings.messageAggregateReportFound)), I18nProperties.getCaption(Captions.aggregateReportEditReport), I18nProperties.getCaption(Captions.aggregateReportDiscardSelection), new Integer(480), resultConsumer);
}
}
}
Aggregations