diff --git a/sormas-api/src/main/java/de/symeda/sormas/api/selfreport/processing/AbstractSelfReportProcessingFlow.java b/sormas-api/src/main/java/de/symeda/sormas/api/selfreport/processing/AbstractSelfReportProcessingFlow.java index 6fc8ba76d03..40d9b0cf354 100644 --- a/sormas-api/src/main/java/de/symeda/sormas/api/selfreport/processing/AbstractSelfReportProcessingFlow.java +++ b/sormas-api/src/main/java/de/symeda/sormas/api/selfreport/processing/AbstractSelfReportProcessingFlow.java @@ -24,6 +24,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import de.symeda.sormas.api.caze.CaseClassification; import de.symeda.sormas.api.caze.CaseDataDto; import de.symeda.sormas.api.caze.CaseIndexDto; import de.symeda.sormas.api.caze.CaseSelectionDto; @@ -249,6 +250,7 @@ private CaseDataDto buildCase(SelfReportDto selfReport, SelfReportProcessingResu CaseDataDto caze = CaseDataDto.build(previousResult.getPerson().getEntity().toReference(), selfReport.getDisease()); caze.setReportingUser(user.toReference()); caze.setReportDate(new Date()); + caze.setCaseClassification(CaseClassification.CONFIRMED); caze.setCaseReferenceNumber(selfReport.getCaseReference()); caze.setDiseaseDetails(selfReport.getDiseaseDetails()); caze.setDiseaseVariant(selfReport.getDiseaseVariant()); diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseController.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseController.java index 3d293a30e35..4377c893ec6 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseController.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseController.java @@ -635,14 +635,34 @@ public CommitDiscardWrapperComponent getCaseCreateComponent( PersonDto convertedPerson, Disease unrelatedDisease, boolean createdFromLabMessage) { + return getCaseCreateComponent( + convertedContact, + convertedEventParticipant, + convertedTravelEntry, + convertedPerson, + unrelatedDisease, + createdFromLabMessage, + false); + } + + public CommitDiscardWrapperComponent getCaseCreateComponent( + ContactDto convertedContact, + EventParticipantDto convertedEventParticipant, + TravelEntryDto convertedTravelEntry, + PersonDto convertedPerson, + Disease unrelatedDisease, + boolean createdFromLabMessage, + boolean createdFromSelfReport) { assert ((convertedContact == null && convertedEventParticipant == null) || (convertedContact == null && convertedTravelEntry == null) || (convertedEventParticipant == null && convertedTravelEntry == null)); assert (unrelatedDisease == null || (convertedEventParticipant == null && convertedTravelEntry == null)); + final boolean createdByProcessing = createdFromLabMessage || createdFromSelfReport; + CaseCreateForm createForm; - if (createdFromLabMessage) { + if (createdByProcessing) { createForm = new CaseCreateForm(true, false, null); } else { createForm = convertedContact == null && convertedEventParticipant == null && convertedTravelEntry == null && unrelatedDisease == null @@ -771,7 +791,7 @@ public CommitDiscardWrapperComponent getCaseCreateComponent( } FacadeProvider.getCaseFacade().setSampleAssociations(convertedContact.toReference(), dto.toReference()); Notification.show(I18nProperties.getString(Strings.messageCaseCreated), Type.ASSISTIVE_NOTIFICATION); - if (!createdFromLabMessage) { + if (!createdByProcessing) { navigateToView(CaseDataView.VIEW_NAME, dto.getUuid(), null); } } else if (convertedEventParticipant != null) { @@ -792,7 +812,7 @@ public CommitDiscardWrapperComponent getCaseCreateComponent( FacadeProvider.getCaseFacade() .setSampleAssociationsUnrelatedDisease(updatedEventParticipant.toReference(), dto.toReference()); } - if (!createdFromLabMessage) { + if (!createdByProcessing) { navigateToView(CaseDataView.VIEW_NAME, dto.getUuid(), null); } } else { @@ -800,7 +820,7 @@ public CommitDiscardWrapperComponent getCaseCreateComponent( convertedEventParticipant.setResultingCase(FacadeProvider.getCaseFacade().getReferenceByUuid(uuid)); } FacadeProvider.getEventParticipantFacade().save(convertedEventParticipant); - if (!createdFromLabMessage) { + if (!createdByProcessing) { navigateToView(CaseDataView.VIEW_NAME, uuid, null); } } @@ -818,10 +838,10 @@ public CommitDiscardWrapperComponent getCaseCreateComponent( updatedTravelEntry.setResultingCase(dto.toReference()); FacadeProvider.getTravelEntryFacade().save(updatedTravelEntry); Notification.show(I18nProperties.getString(Strings.messageCaseCreated), Type.ASSISTIVE_NOTIFICATION); - if (!createdFromLabMessage) { + if (!createdByProcessing) { navigateToView(CaseDataView.VIEW_NAME, dto.getUuid(), null); } - } else if (createdFromLabMessage) { + } else if (createdByProcessing) { PersonDto dbPerson = FacadeProvider.getPersonFacade().getByUuid(dto.getPerson().getUuid()); if (dbPerson == null) { PersonDto personDto = PersonDto.build(); diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseCreateForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseCreateForm.java index 0d9c5b85bff..ac059c063d2 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseCreateForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseCreateForm.java @@ -31,7 +31,6 @@ import java.util.Date; import java.util.List; -import de.symeda.sormas.api.caze.CaseClassification; import org.apache.commons.collections4.CollectionUtils; import com.google.common.collect.Sets; @@ -47,6 +46,7 @@ import de.symeda.sormas.api.Disease; import de.symeda.sormas.api.FacadeProvider; +import de.symeda.sormas.api.caze.CaseClassification; import de.symeda.sormas.api.caze.CaseDataDto; import de.symeda.sormas.api.caze.CaseOrigin; import de.symeda.sormas.api.customizableenum.CustomizableEnumType; @@ -127,6 +127,7 @@ public class CaseCreateForm extends AbstractEditForm { //@formatter:off private static final String HTML_LAYOUT = fluidRowLocs(CaseDataDto.CASE_ORIGIN, "") + fluidRowLocs(CaseDataDto.REPORT_DATE, CaseDataDto.EPID_NUMBER) + + fluidRowLocs(CaseDataDto.CASE_CLASSIFICATION) + fluidRowLocs(CaseDataDto.CASE_REFERENCE_NUMBER, CaseDataDto.EXTERNAL_ID) + fluidRow( fluidColumnLoc(6, 0, CaseDataDto.DISEASE), @@ -170,6 +171,7 @@ public CaseCreateForm(Boolean showHomeAddressForm, Boolean showPersonSearchButto this.convertedTravelEntry = convertedTravelEntry; this.showHomeAddressForm = showHomeAddressForm; this.showPersonSearchButton = showPersonSearchButton; + addFields(); setWidth(720, Unit.PIXELS); hideValidationUntilNextCommit(); @@ -196,6 +198,11 @@ protected void addFields() { addField(CaseDataDto.CASE_REFERENCE_NUMBER, TextField.class); addField(CaseDataDto.REPORT_DATE, DateField.class); + + final NullableOptionGroup caseClassificationGroup = addField(CaseDataDto.CASE_CLASSIFICATION, NullableOptionGroup.class); + caseClassificationGroup.removeItem(CaseClassification.CONFIRMED_NO_SYMPTOMS); + caseClassificationGroup.removeItem(CaseClassification.CONFIRMED_UNKNOWN_SYMPTOMS); + ComboBox diseaseField = addDiseaseField(CaseDataDto.DISEASE, false, true, false); diseaseVariantField = addField(CaseDataDto.DISEASE_VARIANT, ComboBox.class); diseaseVariantDetailsField = addField(CaseDataDto.DISEASE_VARIANT_DETAILS, TextField.class); @@ -517,7 +524,7 @@ protected void addFields() { } }); diseaseField.addValueChangeListener((ValueChangeListener) valueChangeEvent -> { - updateDiseaseVariant((Disease) valueChangeEvent.getProperty().getValue()); + handleDiseaseChanged((Disease) valueChangeEvent.getProperty().getValue()); personCreateForm.updatePresentConditionEnum((Disease) valueChangeEvent.getProperty().getValue()); }); @@ -528,7 +535,7 @@ protected void addFields() { if (diseaseField.getValue() != null) { Disease disease = (Disease) diseaseField.getValue(); - updateDiseaseVariant(disease); + handleDiseaseChanged(disease); personCreateForm.updatePresentConditionEnum(disease); } } @@ -547,20 +554,24 @@ private void hideAndFillJurisdictionFields() { responsibleCommunityCombo.setValue(FacadeProvider.getCommunityFacade().getDefaultInfrastructureReference()); } - private void updateDiseaseVariant(Disease disease) { + private void handleDiseaseChanged(Disease newDisease) { List diseaseVariants = - FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.DISEASE_VARIANT, disease); + FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.DISEASE_VARIANT, newDisease); FieldHelper.updateItems(diseaseVariantField, diseaseVariants); diseaseVariantField - .setVisible(disease != null && isVisibleAllowed(CaseDataDto.DISEASE_VARIANT) && CollectionUtils.isNotEmpty(diseaseVariants)); - if (disease == Disease.INFLUENZA) { + .setVisible(newDisease != null && isVisibleAllowed(CaseDataDto.DISEASE_VARIANT) && CollectionUtils.isNotEmpty(diseaseVariants)); + + NullableOptionGroup classificationField = getField(CaseDataDto.CASE_CLASSIFICATION); + if (newDisease == Disease.INFLUENZA) { facilityOrHome.setValue(Sets.newHashSet(TypeOfPlace.HOME)); facilityOrHome.select(TypeOfPlace.HOME); - getValue().setCaseClassification(CaseClassification.CONFIRMED); + classificationField.setValue(Sets.newHashSet(CaseClassification.CONFIRMED)); + classificationField.select(CaseClassification.CONFIRMED); } else { facilityOrHome.setValue(null); facilityOrHome.unselect(TypeOfPlace.HOME); - getValue().setCaseClassification(CaseClassification.NOT_CLASSIFIED); + classificationField.setValue(Sets.newHashSet(getValue().getCaseClassification())); + classificationField.select(getValue().getCaseClassification()); } } diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/selfreport/processing/SelfReportProcessingFLow.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/selfreport/processing/SelfReportProcessingFLow.java index e2e8370e6d7..2d726ce6e09 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/selfreport/processing/SelfReportProcessingFLow.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/selfreport/processing/SelfReportProcessingFLow.java @@ -128,7 +128,7 @@ protected void handleCreateCase( Window window = VaadinUiUtil.createPopupWindow(); CommitDiscardWrapperComponent caseCreateComponent = - ControllerProvider.getCaseController().getCaseCreateComponent(null, null, null, null, null, true); + ControllerProvider.getCaseController().getCaseCreateComponent(null, null, null, null, null, true, true); CaseCreateForm caseCreateForm = caseCreateComponent.getWrappedComponent(); caseCreateComponent.addDiscardListener(callback::cancel);