Search in sources :

Example 1 with AggregateReportDto

use of de.symeda.sormas.api.report.AggregateReportDto in project SORMAS-Project by hzi-braunschweig.

the class AggregateReportsEditLayout method switchToEditMode.

private void switchToEditMode() {
    window.setCaption(I18nProperties.getString(Strings.headingEditAggregateReport));
    for (AggregateReportEditForm editForm : editForms) {
        String disease = editForm.getDisease();
        AggregateReportDto report = reports.get(diseaseMap.get(disease));
        if (report != null) {
            editForm.setNewCases(report.getNewCases());
            editForm.setLabConfirmations(report.getLabConfirmations());
            editForm.setDeaths(report.getDeaths());
            diseasesWithoutReport.remove(disease);
        }
    }
    removeComponent(epiweekOptions);
    comboBoxYear.setEnabled(false);
    comboBoxEpiweek.setEnabled(false);
    comboBoxRegion.setEnabled(false);
    comboBoxDistrict.setEnabled(false);
    comboBoxFacility.setEnabled(false);
    comboBoxPoe.setEnabled(false);
}
Also used : AggregateReportDto(de.symeda.sormas.api.report.AggregateReportDto)

Example 2 with AggregateReportDto

use of de.symeda.sormas.api.report.AggregateReportDto in project SORMAS-Project by hzi-braunschweig.

the class AggregateReportsEditLayout method save.

private void save() {
    if (!isValid()) {
        Notification.show(I18nProperties.getString(Strings.errorIntegerFieldValidationFailed), "", Type.ERROR_MESSAGE);
        return;
    }
    for (AggregateReportEditForm editForm : editForms) {
        String deathsFieldValue = (String) editForm.getField(AggregateReportDto.DEATHS).getValue();
        String labFieldValue = (String) editForm.getField(AggregateReportDto.LAB_CONFIRMATIONS).getValue();
        String caseFieldValue = (String) editForm.getField(AggregateReportDto.NEW_CASES).getValue();
        int deaths;
        if (!deathsFieldValue.isEmpty()) {
            deaths = Integer.parseInt(deathsFieldValue);
        } else {
            deaths = 0;
        }
        int labConfirmations;
        if (!labFieldValue.isEmpty()) {
            labConfirmations = Integer.parseInt(labFieldValue);
        } else {
            labConfirmations = 0;
        }
        int newCases;
        if (!caseFieldValue.isEmpty()) {
            newCases = Integer.parseInt(caseFieldValue);
        } else {
            newCases = 0;
        }
        AggregateReportDto report = null;
        if (reports != null) {
            report = reports.get(diseaseMap.get(editForm.getDisease()));
        }
        if (report != null && (deaths > 0 || labConfirmations > 0 || newCases > 0)) {
            report.setDeaths(deaths);
            report.setLabConfirmations(labConfirmations);
            report.setNewCases(newCases);
            FacadeProvider.getAggregateReportFacade().saveAggregateReport(report);
        } else if (report != null) {
            FacadeProvider.getAggregateReportFacade().deleteReport(report.getUuid());
        } else {
            if (deaths > 0 || labConfirmations > 0 || newCases > 0) {
                AggregateReportDto newReport = AggregateReportDto.build();
                newReport.setDeaths(deaths);
                newReport.setDisease(diseaseMap.get(editForm.getDisease()));
                newReport.setDistrict(comboBoxDistrict.getValue());
                newReport.setEpiWeek(comboBoxEpiweek.getValue().getWeek());
                newReport.setHealthFacility(comboBoxFacility.getValue());
                newReport.setLabConfirmations(labConfirmations);
                newReport.setNewCases(newCases);
                newReport.setPointOfEntry(comboBoxPoe.getValue());
                newReport.setRegion(comboBoxRegion.getValue());
                newReport.setReportingUser(UserProvider.getCurrent().getUser().toReference());
                newReport.setYear(comboBoxYear.getValue());
                FacadeProvider.getAggregateReportFacade().saveAggregateReport(newReport);
            }
        }
    }
    window.close();
}
Also used : AggregateReportDto(de.symeda.sormas.api.report.AggregateReportDto)

Example 3 with AggregateReportDto

use of de.symeda.sormas.api.report.AggregateReportDto 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);
        }
    }
}
Also used : AggregateReportDto(de.symeda.sormas.api.report.AggregateReportDto) Consumer(java.util.function.Consumer) Label(com.vaadin.ui.Label) AggregateReportCriteria(de.symeda.sormas.api.report.AggregateReportCriteria)

Example 4 with AggregateReportDto

use of de.symeda.sormas.api.report.AggregateReportDto in project SORMAS-Project by hzi-braunschweig.

the class AggregateReportFacadeEjb method toDto.

public static AggregateReportDto toDto(AggregateReport source) {
    if (source == null) {
        return null;
    }
    AggregateReportDto target = new AggregateReportDto();
    DtoHelper.fillDto(target, source);
    target.setDisease(source.getDisease());
    target.setReportingUser(UserFacadeEjb.toReferenceDto(source.getReportingUser()));
    target.setYear(source.getYear());
    target.setEpiWeek(source.getEpiWeek());
    target.setRegion(RegionFacadeEjb.toReferenceDto(source.getRegion()));
    target.setDistrict(DistrictFacadeEjb.toReferenceDto(source.getDistrict()));
    target.setHealthFacility(FacilityFacadeEjb.toReferenceDto(source.getHealthFacility()));
    target.setPointOfEntry(PointOfEntryFacadeEjb.toReferenceDto(source.getPointOfEntry()));
    target.setNewCases(source.getNewCases());
    target.setLabConfirmations(source.getLabConfirmations());
    target.setDeaths(source.getDeaths());
    return target;
}
Also used : AggregateReportDto(de.symeda.sormas.api.report.AggregateReportDto)

Aggregations

AggregateReportDto (de.symeda.sormas.api.report.AggregateReportDto)4 Label (com.vaadin.ui.Label)1 AggregateReportCriteria (de.symeda.sormas.api.report.AggregateReportCriteria)1 Consumer (java.util.function.Consumer)1