Search in sources :

Example 1 with LineListingLayout

use of de.symeda.sormas.ui.caze.components.linelisting.LineListingLayout in project SORMAS-Project by hzi-braunschweig.

the class CaseController method openLineListingWindow.

public void openLineListingWindow() {
    Window window = new Window(I18nProperties.getString(Strings.headingLineListing));
    LineListingLayout lineListingForm = new LineListingLayout(window);
    lineListingForm.setSaveCallback(cases -> saveCasesFromLineListing(lineListingForm, cases));
    if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_CHANGE_EPID_NUMBER)) {
        lineListingForm.setWidth(LineListingLayout.DEFAULT_WIDTH, Unit.PIXELS);
    } else {
        lineListingForm.setWidth(LineListingLayout.WITDH_WITHOUT_EPID_NUMBER, Unit.PIXELS);
    }
    window.setContent(lineListingForm);
    window.setModal(true);
    window.setPositionX((int) Math.max(0, (Page.getCurrent().getBrowserWindowWidth() - lineListingForm.getWidth())) / 2);
    window.setPositionY(70);
    window.setResizable(false);
    UI.getCurrent().addWindow(window);
}
Also used : Window(com.vaadin.ui.Window) LineListingLayout(de.symeda.sormas.ui.caze.components.linelisting.LineListingLayout)

Example 2 with LineListingLayout

use of de.symeda.sormas.ui.caze.components.linelisting.LineListingLayout in project SORMAS-Project by hzi-braunschweig.

the class CaseController method saveCasesFromLineListing.

private void saveCasesFromLineListing(LineListingLayout lineListingForm, List<LineListingLayout.CaseLineDto> cases) {
    try {
        lineListingForm.validate();
    } catch (ValidationRuntimeException e) {
        Notification.show(I18nProperties.getString(Strings.errorFieldValidationFailed), "", Type.ERROR_MESSAGE);
        return;
    }
    for (LineListingLayout.CaseLineDto caseLineDto : cases) {
        CaseDataDto newCase = CaseDataDto.build(PersonDto.build().toReference(), caseLineDto.getDisease());
        newCase.setDiseaseDetails(caseLineDto.getDiseaseDetails());
        newCase.setResponsibleRegion(caseLineDto.getRegion());
        newCase.setResponsibleDistrict(caseLineDto.getDistrict());
        newCase.setReportDate(DateHelper8.toDate(caseLineDto.getDateOfReport()));
        newCase.setEpidNumber(caseLineDto.getEpidNumber());
        newCase.setResponsibleCommunity(caseLineDto.getCommunity());
        newCase.setFacilityType(caseLineDto.getFacilityType());
        newCase.setHealthFacility(caseLineDto.getFacility());
        newCase.setHealthFacilityDetails(caseLineDto.getFacilityDetails());
        if (caseLineDto.getDateOfOnset() != null) {
            newCase.getSymptoms().setOnsetDate(DateHelper8.toDate(caseLineDto.getDateOfOnset()));
        }
        newCase.setReportingUser(UserProvider.getCurrent().getUserReference());
        final PersonDto newPerson = PersonDto.build();
        newPerson.setFirstName(caseLineDto.getPerson().getFirstName());
        newPerson.setLastName(caseLineDto.getPerson().getLastName());
        if (caseLineDto.getPerson().getBirthDate() != null) {
            newPerson.setBirthdateYYYY(caseLineDto.getPerson().getBirthDate().getDateOfBirthYYYY());
            newPerson.setBirthdateMM(caseLineDto.getPerson().getBirthDate().getDateOfBirthMM());
            newPerson.setBirthdateDD(caseLineDto.getPerson().getBirthDate().getDateOfBirthDD());
        }
        newPerson.setSex(caseLineDto.getPerson().getSex());
        ControllerProvider.getPersonController().selectOrCreatePerson(newPerson, I18nProperties.getString(Strings.infoSelectOrCreatePersonForCase), selectedPerson -> {
            if (selectedPerson != null) {
                newCase.setPerson(selectedPerson);
                selectOrCreateCase(newCase, FacadeProvider.getPersonFacade().getPersonByUuid(selectedPerson.getUuid()), uuid -> {
                    if (uuid == null) {
                        FacadeProvider.getCaseFacade().save(newCase);
                        Notification.show(I18nProperties.getString(Strings.messageCaseCreated), Type.ASSISTIVE_NOTIFICATION);
                    }
                });
            }
        }, true);
    }
    lineListingForm.closeWindow();
    ControllerProvider.getCaseController().navigateToIndex();
}
Also used : CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) ValidationRuntimeException(de.symeda.sormas.api.utils.ValidationRuntimeException) LineListingLayout(de.symeda.sormas.ui.caze.components.linelisting.LineListingLayout)

Aggregations

LineListingLayout (de.symeda.sormas.ui.caze.components.linelisting.LineListingLayout)2 Window (com.vaadin.ui.Window)1 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)1 PersonDto (de.symeda.sormas.api.person.PersonDto)1 ValidationRuntimeException (de.symeda.sormas.api.utils.ValidationRuntimeException)1