use of de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent in project SORMAS-Project by hzi-braunschweig.
the class CaseController method getCaseDataEditComponent.
// public CommitDiscardWrapperComponent<? extends Component> getCaseCombinedEditComponent(final String caseUuid,
// final ViewMode viewMode) {
//
// CaseDataDto caze = findCase(caseUuid);
// PersonDto person = FacadeProvider.getPersonFacade().getPersonByUuid(caze.getPerson().getUuid());
//
// CaseDataForm caseEditForm = new CaseDataForm(person, caze.getDisease(), viewMode);
// caseEditForm.setValue(caze);
//
// HospitalizationForm hospitalizationForm = new HospitalizationForm(caze, viewMode);
// hospitalizationForm.setValue(caze.getHospitalization());
//
// SymptomsForm symptomsForm = new SymptomsForm(caze, caze.getDisease(), person, SymptomsContext.CASE, viewMode);
// symptomsForm.setValue(caze.getSymptoms());
//
// EpiDataForm epiDataForm = new EpiDataForm(caze.getDisease(), viewMode);
// epiDataForm.setValue(caze.getEpiData());
//
// CommitDiscardWrapperComponent<? extends Component> editView = AbstractEditForm
// .buildCommitDiscardWrapper(caseEditForm, hospitalizationForm, symptomsForm, epiDataForm);
//
// editView.addCommitListener(new CommitListener() {
// @Override
// public void onCommit() {
// CaseDataDto cazeDto = caseEditForm.getValue();
// cazeDto.setHospitalization(hospitalizationForm.getValue());
// cazeDto.setSymptoms(symptomsForm.getValue());
// cazeDto.setEpiData(epiDataForm.getValue());
//
// saveCase(cazeDto);
// }
// });
//
// appendSpecialCommands(caze, editView);
//
// return editView;
// }
public CommitDiscardWrapperComponent<CaseDataForm> getCaseDataEditComponent(final String caseUuid, final ViewMode viewMode) {
CaseDataDto caze = findCase(caseUuid);
AutomaticDeletionInfoDto automaticDeletionInfoDto = FacadeProvider.getCaseFacade().getAutomaticDeletionInfo(caseUuid);
CaseDataForm caseEditForm = new CaseDataForm(caseUuid, FacadeProvider.getPersonFacade().getPersonByUuid(caze.getPerson().getUuid()), caze.getDisease(), caze.getSymptoms(), viewMode, caze.isPseudonymized());
caseEditForm.setValue(caze);
CommitDiscardWrapperComponent<CaseDataForm> editView = new CommitDiscardWrapperComponent<CaseDataForm>(caseEditForm, UserProvider.getCurrent().hasUserRight(UserRight.CASE_EDIT), caseEditForm.getFieldGroup());
if (automaticDeletionInfoDto != null) {
editView.getButtonsPanel().addComponentAsFirst(new AutomaticDeletionLabel(automaticDeletionInfoDto));
}
editView.addCommitListener(() -> {
CaseDataDto oldCase = findCase(caseUuid);
CaseDataDto cazeDto = caseEditForm.getValue();
saveCaseWithFacilityChangedPrompt(cazeDto, oldCase);
});
editView.addDiscardListener(() -> caseEditForm.onDiscard());
appendSpecialCommands(caze, editView);
return editView;
}
use of de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent in project SORMAS-Project by hzi-braunschweig.
the class CaseController method convertSamePersonContactsAndEventparticipants.
private void convertSamePersonContactsAndEventparticipants(CaseDataDto caze, Date relevantDate) {
ContactSimilarityCriteria contactCriteria = new ContactSimilarityCriteria().withPerson(caze.getPerson()).withDisease(caze.getDisease()).withContactClassification(ContactClassification.CONFIRMED).withExcludePseudonymized(true).withNoResultingCase(true);
List<SimilarContactDto> matchingContacts = FacadeProvider.getContactFacade().getMatchingContacts(contactCriteria);
EventParticipantCriteria eventParticipantCriteria = new EventParticipantCriteria().withPerson(caze.getPerson()).withDisease(caze.getDisease()).withExcludePseudonymized(true).withNoResultingCase(true);
List<SimilarEventParticipantDto> matchingEventParticipants = FacadeProvider.getEventParticipantFacade().getMatchingEventParticipants(eventParticipantCriteria);
if (matchingContacts.size() > 0 || matchingEventParticipants.size() > 0) {
String infoText = matchingEventParticipants.isEmpty() ? String.format(I18nProperties.getString(Strings.infoConvertToCaseContacts), matchingContacts.size(), caze.getDisease()) : (matchingContacts.isEmpty() ? String.format(I18nProperties.getString(Strings.infoConvertToCaseEventParticipants), matchingEventParticipants.size(), caze.getDisease()) : String.format(I18nProperties.getString(Strings.infoConvertToCaseContactsAndEventParticipants), matchingContacts.size(), caze.getDisease(), matchingEventParticipants.size(), caze.getDisease()));
HorizontalLayout infoComponent = VaadinUiUtil.createInfoComponent(infoText);
infoComponent.setWidth(600, Sizeable.Unit.PIXELS);
CommitDiscardWrapperComponent<HorizontalLayout> convertToCaseConfirmComponent = new CommitDiscardWrapperComponent<>(infoComponent);
convertToCaseConfirmComponent.getCommitButton().setCaption(I18nProperties.getCaption(Captions.actionYesForAll));
convertToCaseConfirmComponent.getDiscardButton().setCaption(I18nProperties.getCaption(Captions.actionNo));
convertToCaseConfirmComponent.addCommitListener(() -> {
CaseDataDto refreshedCaze = FacadeProvider.getCaseFacade().getCaseDataByUuid(caze.getUuid());
refreshedCaze.getEpiData().setContactWithSourceCaseKnown(YesNoUnknown.YES);
saveCase(refreshedCaze);
setResultingCase(refreshedCaze, matchingContacts, matchingEventParticipants);
SormasUI.refreshView();
});
Button convertSomeButton = ButtonHelper.createButton("convertSome", I18nProperties.getCaption(Captions.actionYesForSome), (Button.ClickListener) event -> {
convertToCaseConfirmComponent.discard();
showConvertToCaseSelection(caze, matchingContacts, matchingEventParticipants);
}, ValoTheme.BUTTON_PRIMARY);
HorizontalLayout buttonsPanel = convertToCaseConfirmComponent.getButtonsPanel();
buttonsPanel.addComponent(convertSomeButton, convertToCaseConfirmComponent.getComponentCount() - 1);
buttonsPanel.setComponentAlignment(convertSomeButton, Alignment.BOTTOM_RIGHT);
buttonsPanel.setExpandRatio(convertSomeButton, 0);
VaadinUiUtil.showModalPopupWindow(convertToCaseConfirmComponent, I18nProperties.getString(Strings.headingCaseConversion));
}
}
use of de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent in project SORMAS-Project by hzi-braunschweig.
the class CaseController method referFromPointOfEntry.
public void referFromPointOfEntry(CaseDataDto caze) {
CaseFacilityChangeForm form = new CaseFacilityChangeForm();
form.setValue(caze);
CommitDiscardWrapperComponent<CaseFacilityChangeForm> view = new CommitDiscardWrapperComponent<CaseFacilityChangeForm>(form, UserProvider.getCurrent().hasUserRight(UserRight.CASE_REFER_FROM_POE), form.getFieldGroup());
view.getCommitButton().setCaption(I18nProperties.getCaption(Captions.caseReferToFacility));
Window window = VaadinUiUtil.showPopupWindow(view);
window.setCaption(I18nProperties.getString(Strings.headingReferCaseFromPointOfEntry));
view.addCommitListener(() -> {
if (!form.getFieldGroup().isModified()) {
CaseDataDto dto = form.getValue();
dto.getHospitalization().setAdmissionDate(new Date());
FacadeProvider.getCaseFacade().save(dto);
window.close();
Notification.show(I18nProperties.getString(Strings.messageCaseReferredFromPoe), Type.ASSISTIVE_NOTIFICATION);
SormasUI.refreshView();
}
});
Button btnCancel = ButtonHelper.createButton(Captions.actionCancel, e -> {
window.close();
});
view.getButtonsPanel().replaceComponent(view.getDiscardButton(), btnCancel);
}
use of de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent in project SORMAS-Project by hzi-braunschweig.
the class CaseController method getClinicalCourseComponent.
public CommitDiscardWrapperComponent<ClinicalCourseForm> getClinicalCourseComponent(String caseUuid) {
CaseDataDto caze = FacadeProvider.getCaseFacade().getCaseDataByUuid(caseUuid);
ClinicalCourseForm form = new ClinicalCourseForm(caze.isPseudonymized());
form.setValue(caze.getClinicalCourse());
final CommitDiscardWrapperComponent<ClinicalCourseForm> view = new CommitDiscardWrapperComponent<>(form, UserProvider.getCurrent().hasUserRight(UserRight.CLINICAL_COURSE_EDIT), form.getFieldGroup());
view.addCommitListener(() -> {
if (!form.getFieldGroup().isModified()) {
CaseDataDto cazeDto = FacadeProvider.getCaseFacade().getCaseDataByUuid(caseUuid);
cazeDto.setClinicalCourse(form.getValue());
saveCase(cazeDto);
}
});
view.getCommitButton().setVisible(false);
view.getDiscardButton().setVisible(false);
return view;
}
use of de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent 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());
}
Aggregations