Search in sources :

Example 1 with CaseFacade

use of de.symeda.sormas.api.caze.CaseFacade in project SORMAS-Project by hzi-braunschweig.

the class CaseController method showBulkCaseDataEditComponent.

public void showBulkCaseDataEditComponent(Collection<? extends CaseIndexDto> selectedCases) {
    if (selectedCases.size() == 0) {
        new Notification(I18nProperties.getString(Strings.headingNoCasesSelected), I18nProperties.getString(Strings.messageNoCasesSelected), Type.WARNING_MESSAGE, false).show(Page.getCurrent());
        return;
    }
    // Check if cases with multiple regions and districts have been selected
    String regionUuid = null, districtUuid = null;
    boolean first = true;
    for (CaseIndexDto selectedCase : selectedCases) {
        String currentRegionUuid = selectedCase.getResponsibleRegionUuid() == null ? selectedCase.getRegionUuid() : selectedCase.getResponsibleRegionUuid();
        String currentDistrictUuid = selectedCase.getResponsibleDistrictUuid() == null ? selectedCase.getDistrictUuid() : selectedCase.getResponsibleDistrictUuid();
        if (first) {
            regionUuid = currentRegionUuid;
            districtUuid = currentDistrictUuid;
            first = false;
        } else {
            if (!DataHelper.equal(regionUuid, currentDistrictUuid)) {
                regionUuid = null;
            }
            if (!DataHelper.equal(districtUuid, currentDistrictUuid)) {
                districtUuid = null;
            }
        }
        if (regionUuid == null && districtUuid == null)
            break;
    }
    RegionReferenceDto region = regionUuid != null ? FacadeProvider.getRegionFacade().getReferenceByUuid(regionUuid) : null;
    DistrictReferenceDto district = districtUuid != null ? FacadeProvider.getDistrictFacade().getReferenceByUuid(districtUuid) : null;
    // Create a temporary case in order to use the CommitDiscardWrapperComponent
    CaseBulkEditData bulkEditData = new CaseBulkEditData();
    bulkEditData.setRegion(region);
    bulkEditData.setDistrict(district);
    BulkCaseDataForm form = new BulkCaseDataForm(district, selectedCases);
    form.setValue(bulkEditData);
    final CommitDiscardWrapperComponent<BulkCaseDataForm> editView = new CommitDiscardWrapperComponent<BulkCaseDataForm>(form, form.getFieldGroup());
    Window popupWindow = VaadinUiUtil.showModalPopupWindow(editView, I18nProperties.getString(Strings.headingEditCases));
    editView.addCommitListener(() -> {
        CaseBulkEditData updatedBulkEditData = form.getValue();
        boolean diseaseChange = form.getDiseaseCheckBox().getValue();
        boolean classificationChange = form.getClassificationCheckBox().getValue();
        boolean investigationStatusChange = form.getInvestigationStatusCheckBox().getValue();
        boolean outcomeChange = form.getOutcomeCheckBox().getValue();
        boolean surveillanceOfficerChange = district != null && form.getSurveillanceOfficerCheckBox().getValue();
        boolean facilityChange = form.getHealthFacilityCheckbox().getValue();
        CaseFacade caseFacade = FacadeProvider.getCaseFacade();
        if (facilityChange) {
            VaadinUiUtil.showChooseOptionPopup(I18nProperties.getCaption(Captions.caseInfrastructureDataChanged), new Label(I18nProperties.getString(Strings.messageFacilityMulitChanged)), I18nProperties.getCaption(Captions.caseTransferCases), I18nProperties.getCaption(Captions.caseEditData), 500, e -> {
                bulkEditWithFacilities(selectedCases, updatedBulkEditData, diseaseChange, classificationChange, investigationStatusChange, outcomeChange, surveillanceOfficerChange, e.booleanValue(), caseFacade);
                popupWindow.close();
                navigateToIndex();
                Notification.show(I18nProperties.getString(Strings.messageCasesEdited), Type.HUMANIZED_MESSAGE);
            });
        } else {
            bulkEdit(selectedCases, updatedBulkEditData, diseaseChange, classificationChange, investigationStatusChange, outcomeChange, surveillanceOfficerChange, caseFacade);
            popupWindow.close();
            navigateToIndex();
            Notification.show(I18nProperties.getString(Strings.messageCasesEdited), Type.HUMANIZED_MESSAGE);
        }
    });
    editView.addDiscardListener(() -> popupWindow.close());
}
Also used : Window(com.vaadin.ui.Window) AutomaticDeletionLabel(de.symeda.sormas.ui.utils.components.automaticdeletion.AutomaticDeletionLabel) Label(com.vaadin.ui.Label) CaseBulkEditData(de.symeda.sormas.api.caze.CaseBulkEditData) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) Notification(com.vaadin.ui.Notification) CaseIndexDto(de.symeda.sormas.api.caze.CaseIndexDto) CaseFacade(de.symeda.sormas.api.caze.CaseFacade) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)

Example 2 with CaseFacade

use of de.symeda.sormas.api.caze.CaseFacade in project SORMAS-Project by hzi-braunschweig.

the class DashboardMapComponent method getCasesForFacility.

public List<CaseDataDto> getCasesForFacility(FacilityReferenceDto facility) {
    List<CaseDataDto> casesForFacility = new ArrayList<>();
    CaseFacade caseFacade = FacadeProvider.getCaseFacade();
    for (MapCaseDto mapCaseDto : casesByFacility.get(facility)) {
        casesForFacility.add(caseFacade.getCaseDataByUuid(mapCaseDto.getUuid()));
    }
    return casesForFacility;
}
Also used : MapCaseDto(de.symeda.sormas.api.caze.MapCaseDto) CaseFacade(de.symeda.sormas.api.caze.CaseFacade) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) ArrayList(java.util.ArrayList)

Aggregations

CaseFacade (de.symeda.sormas.api.caze.CaseFacade)2 Label (com.vaadin.ui.Label)1 Notification (com.vaadin.ui.Notification)1 Window (com.vaadin.ui.Window)1 CaseBulkEditData (de.symeda.sormas.api.caze.CaseBulkEditData)1 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)1 CaseIndexDto (de.symeda.sormas.api.caze.CaseIndexDto)1 MapCaseDto (de.symeda.sormas.api.caze.MapCaseDto)1 DistrictReferenceDto (de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)1 RegionReferenceDto (de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)1 CommitDiscardWrapperComponent (de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent)1 AutomaticDeletionLabel (de.symeda.sormas.ui.utils.components.automaticdeletion.AutomaticDeletionLabel)1 ArrayList (java.util.ArrayList)1