Skip to content

Commit

Permalink
#13226 Add Manual Case Classification for Self-Report Processing
Browse files Browse the repository at this point in the history
  • Loading branch information
Levente Gal committed Jan 21, 2025
1 parent dafe50a commit e30ca10
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,14 +635,34 @@ public CommitDiscardWrapperComponent<CaseCreateForm> getCaseCreateComponent(
PersonDto convertedPerson,
Disease unrelatedDisease,
boolean createdFromLabMessage) {
return getCaseCreateComponent(
convertedContact,
convertedEventParticipant,
convertedTravelEntry,
convertedPerson,
unrelatedDisease,
createdFromLabMessage,
false);
}

public CommitDiscardWrapperComponent<CaseCreateForm> 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
Expand Down Expand Up @@ -771,7 +791,7 @@ public CommitDiscardWrapperComponent<CaseCreateForm> 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) {
Expand All @@ -792,15 +812,15 @@ public CommitDiscardWrapperComponent<CaseCreateForm> getCaseCreateComponent(
FacadeProvider.getCaseFacade()
.setSampleAssociationsUnrelatedDisease(updatedEventParticipant.toReference(), dto.toReference());
}
if (!createdFromLabMessage) {
if (!createdByProcessing) {
navigateToView(CaseDataView.VIEW_NAME, dto.getUuid(), null);
}
} else {
if (unrelatedDisease == null && convertedEventParticipant.getResultingCase() == null) {
convertedEventParticipant.setResultingCase(FacadeProvider.getCaseFacade().getReferenceByUuid(uuid));
}
FacadeProvider.getEventParticipantFacade().save(convertedEventParticipant);
if (!createdFromLabMessage) {
if (!createdByProcessing) {
navigateToView(CaseDataView.VIEW_NAME, uuid, null);
}
}
Expand All @@ -818,10 +838,10 @@ public CommitDiscardWrapperComponent<CaseCreateForm> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -127,6 +127,7 @@ public class CaseCreateForm extends AbstractEditForm<CaseDataDto> {
//@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),
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand Down Expand Up @@ -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());
});

Expand All @@ -528,7 +535,7 @@ protected void addFields() {

if (diseaseField.getValue() != null) {
Disease disease = (Disease) diseaseField.getValue();
updateDiseaseVariant(disease);
handleDiseaseChanged(disease);
personCreateForm.updatePresentConditionEnum(disease);
}
}
Expand All @@ -547,20 +554,24 @@ private void hideAndFillJurisdictionFields() {
responsibleCommunityCombo.setValue(FacadeProvider.getCommunityFacade().getDefaultInfrastructureReference());
}

private void updateDiseaseVariant(Disease disease) {
private void handleDiseaseChanged(Disease newDisease) {
List<DiseaseVariant> 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());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ protected void handleCreateCase(
Window window = VaadinUiUtil.createPopupWindow();

CommitDiscardWrapperComponent<CaseCreateForm> 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);
Expand Down

0 comments on commit e30ca10

Please sign in to comment.