Skip to content

Commit 8421332

Browse files
Merge pull request #13238 from SORMAS-Foundation/#13226-case-classification-on-case-creation
#13226 Add Manual Case Classification for Self-Report Processing
2 parents dafe50a + e30ca10 commit 8421332

File tree

4 files changed

+49
-16
lines changed

4 files changed

+49
-16
lines changed

sormas-api/src/main/java/de/symeda/sormas/api/selfreport/processing/AbstractSelfReportProcessingFlow.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.slf4j.Logger;
2525
import org.slf4j.LoggerFactory;
2626

27+
import de.symeda.sormas.api.caze.CaseClassification;
2728
import de.symeda.sormas.api.caze.CaseDataDto;
2829
import de.symeda.sormas.api.caze.CaseIndexDto;
2930
import de.symeda.sormas.api.caze.CaseSelectionDto;
@@ -249,6 +250,7 @@ private CaseDataDto buildCase(SelfReportDto selfReport, SelfReportProcessingResu
249250
CaseDataDto caze = CaseDataDto.build(previousResult.getPerson().getEntity().toReference(), selfReport.getDisease());
250251
caze.setReportingUser(user.toReference());
251252
caze.setReportDate(new Date());
253+
caze.setCaseClassification(CaseClassification.CONFIRMED);
252254
caze.setCaseReferenceNumber(selfReport.getCaseReference());
253255
caze.setDiseaseDetails(selfReport.getDiseaseDetails());
254256
caze.setDiseaseVariant(selfReport.getDiseaseVariant());

sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseController.java

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -635,14 +635,34 @@ public CommitDiscardWrapperComponent<CaseCreateForm> getCaseCreateComponent(
635635
PersonDto convertedPerson,
636636
Disease unrelatedDisease,
637637
boolean createdFromLabMessage) {
638+
return getCaseCreateComponent(
639+
convertedContact,
640+
convertedEventParticipant,
641+
convertedTravelEntry,
642+
convertedPerson,
643+
unrelatedDisease,
644+
createdFromLabMessage,
645+
false);
646+
}
647+
648+
public CommitDiscardWrapperComponent<CaseCreateForm> getCaseCreateComponent(
649+
ContactDto convertedContact,
650+
EventParticipantDto convertedEventParticipant,
651+
TravelEntryDto convertedTravelEntry,
652+
PersonDto convertedPerson,
653+
Disease unrelatedDisease,
654+
boolean createdFromLabMessage,
655+
boolean createdFromSelfReport) {
638656

639657
assert ((convertedContact == null && convertedEventParticipant == null)
640658
|| (convertedContact == null && convertedTravelEntry == null)
641659
|| (convertedEventParticipant == null && convertedTravelEntry == null));
642660
assert (unrelatedDisease == null || (convertedEventParticipant == null && convertedTravelEntry == null));
643661

662+
final boolean createdByProcessing = createdFromLabMessage || createdFromSelfReport;
663+
644664
CaseCreateForm createForm;
645-
if (createdFromLabMessage) {
665+
if (createdByProcessing) {
646666
createForm = new CaseCreateForm(true, false, null);
647667
} else {
648668
createForm = convertedContact == null && convertedEventParticipant == null && convertedTravelEntry == null && unrelatedDisease == null
@@ -771,7 +791,7 @@ public CommitDiscardWrapperComponent<CaseCreateForm> getCaseCreateComponent(
771791
}
772792
FacadeProvider.getCaseFacade().setSampleAssociations(convertedContact.toReference(), dto.toReference());
773793
Notification.show(I18nProperties.getString(Strings.messageCaseCreated), Type.ASSISTIVE_NOTIFICATION);
774-
if (!createdFromLabMessage) {
794+
if (!createdByProcessing) {
775795
navigateToView(CaseDataView.VIEW_NAME, dto.getUuid(), null);
776796
}
777797
} else if (convertedEventParticipant != null) {
@@ -792,15 +812,15 @@ public CommitDiscardWrapperComponent<CaseCreateForm> getCaseCreateComponent(
792812
FacadeProvider.getCaseFacade()
793813
.setSampleAssociationsUnrelatedDisease(updatedEventParticipant.toReference(), dto.toReference());
794814
}
795-
if (!createdFromLabMessage) {
815+
if (!createdByProcessing) {
796816
navigateToView(CaseDataView.VIEW_NAME, dto.getUuid(), null);
797817
}
798818
} else {
799819
if (unrelatedDisease == null && convertedEventParticipant.getResultingCase() == null) {
800820
convertedEventParticipant.setResultingCase(FacadeProvider.getCaseFacade().getReferenceByUuid(uuid));
801821
}
802822
FacadeProvider.getEventParticipantFacade().save(convertedEventParticipant);
803-
if (!createdFromLabMessage) {
823+
if (!createdByProcessing) {
804824
navigateToView(CaseDataView.VIEW_NAME, uuid, null);
805825
}
806826
}
@@ -818,10 +838,10 @@ public CommitDiscardWrapperComponent<CaseCreateForm> getCaseCreateComponent(
818838
updatedTravelEntry.setResultingCase(dto.toReference());
819839
FacadeProvider.getTravelEntryFacade().save(updatedTravelEntry);
820840
Notification.show(I18nProperties.getString(Strings.messageCaseCreated), Type.ASSISTIVE_NOTIFICATION);
821-
if (!createdFromLabMessage) {
841+
if (!createdByProcessing) {
822842
navigateToView(CaseDataView.VIEW_NAME, dto.getUuid(), null);
823843
}
824-
} else if (createdFromLabMessage) {
844+
} else if (createdByProcessing) {
825845
PersonDto dbPerson = FacadeProvider.getPersonFacade().getByUuid(dto.getPerson().getUuid());
826846
if (dbPerson == null) {
827847
PersonDto personDto = PersonDto.build();

sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseCreateForm.java

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import java.util.Date;
3232
import java.util.List;
3333

34-
import de.symeda.sormas.api.caze.CaseClassification;
3534
import org.apache.commons.collections4.CollectionUtils;
3635

3736
import com.google.common.collect.Sets;
@@ -47,6 +46,7 @@
4746

4847
import de.symeda.sormas.api.Disease;
4948
import de.symeda.sormas.api.FacadeProvider;
49+
import de.symeda.sormas.api.caze.CaseClassification;
5050
import de.symeda.sormas.api.caze.CaseDataDto;
5151
import de.symeda.sormas.api.caze.CaseOrigin;
5252
import de.symeda.sormas.api.customizableenum.CustomizableEnumType;
@@ -127,6 +127,7 @@ public class CaseCreateForm extends AbstractEditForm<CaseDataDto> {
127127
//@formatter:off
128128
private static final String HTML_LAYOUT = fluidRowLocs(CaseDataDto.CASE_ORIGIN, "")
129129
+ fluidRowLocs(CaseDataDto.REPORT_DATE, CaseDataDto.EPID_NUMBER)
130+
+ fluidRowLocs(CaseDataDto.CASE_CLASSIFICATION)
130131
+ fluidRowLocs(CaseDataDto.CASE_REFERENCE_NUMBER, CaseDataDto.EXTERNAL_ID)
131132
+ fluidRow(
132133
fluidColumnLoc(6, 0, CaseDataDto.DISEASE),
@@ -170,6 +171,7 @@ public CaseCreateForm(Boolean showHomeAddressForm, Boolean showPersonSearchButto
170171
this.convertedTravelEntry = convertedTravelEntry;
171172
this.showHomeAddressForm = showHomeAddressForm;
172173
this.showPersonSearchButton = showPersonSearchButton;
174+
173175
addFields();
174176
setWidth(720, Unit.PIXELS);
175177
hideValidationUntilNextCommit();
@@ -196,6 +198,11 @@ protected void addFields() {
196198
addField(CaseDataDto.CASE_REFERENCE_NUMBER, TextField.class);
197199

198200
addField(CaseDataDto.REPORT_DATE, DateField.class);
201+
202+
final NullableOptionGroup caseClassificationGroup = addField(CaseDataDto.CASE_CLASSIFICATION, NullableOptionGroup.class);
203+
caseClassificationGroup.removeItem(CaseClassification.CONFIRMED_NO_SYMPTOMS);
204+
caseClassificationGroup.removeItem(CaseClassification.CONFIRMED_UNKNOWN_SYMPTOMS);
205+
199206
ComboBox diseaseField = addDiseaseField(CaseDataDto.DISEASE, false, true, false);
200207
diseaseVariantField = addField(CaseDataDto.DISEASE_VARIANT, ComboBox.class);
201208
diseaseVariantDetailsField = addField(CaseDataDto.DISEASE_VARIANT_DETAILS, TextField.class);
@@ -517,7 +524,7 @@ protected void addFields() {
517524
}
518525
});
519526
diseaseField.addValueChangeListener((ValueChangeListener) valueChangeEvent -> {
520-
updateDiseaseVariant((Disease) valueChangeEvent.getProperty().getValue());
527+
handleDiseaseChanged((Disease) valueChangeEvent.getProperty().getValue());
521528
personCreateForm.updatePresentConditionEnum((Disease) valueChangeEvent.getProperty().getValue());
522529
});
523530

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

529536
if (diseaseField.getValue() != null) {
530537
Disease disease = (Disease) diseaseField.getValue();
531-
updateDiseaseVariant(disease);
538+
handleDiseaseChanged(disease);
532539
personCreateForm.updatePresentConditionEnum(disease);
533540
}
534541
}
@@ -547,20 +554,24 @@ private void hideAndFillJurisdictionFields() {
547554
responsibleCommunityCombo.setValue(FacadeProvider.getCommunityFacade().getDefaultInfrastructureReference());
548555
}
549556

550-
private void updateDiseaseVariant(Disease disease) {
557+
private void handleDiseaseChanged(Disease newDisease) {
551558
List<DiseaseVariant> diseaseVariants =
552-
FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.DISEASE_VARIANT, disease);
559+
FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.DISEASE_VARIANT, newDisease);
553560
FieldHelper.updateItems(diseaseVariantField, diseaseVariants);
554561
diseaseVariantField
555-
.setVisible(disease != null && isVisibleAllowed(CaseDataDto.DISEASE_VARIANT) && CollectionUtils.isNotEmpty(diseaseVariants));
556-
if (disease == Disease.INFLUENZA) {
562+
.setVisible(newDisease != null && isVisibleAllowed(CaseDataDto.DISEASE_VARIANT) && CollectionUtils.isNotEmpty(diseaseVariants));
563+
564+
NullableOptionGroup classificationField = getField(CaseDataDto.CASE_CLASSIFICATION);
565+
if (newDisease == Disease.INFLUENZA) {
557566
facilityOrHome.setValue(Sets.newHashSet(TypeOfPlace.HOME));
558567
facilityOrHome.select(TypeOfPlace.HOME);
559-
getValue().setCaseClassification(CaseClassification.CONFIRMED);
568+
classificationField.setValue(Sets.newHashSet(CaseClassification.CONFIRMED));
569+
classificationField.select(CaseClassification.CONFIRMED);
560570
} else {
561571
facilityOrHome.setValue(null);
562572
facilityOrHome.unselect(TypeOfPlace.HOME);
563-
getValue().setCaseClassification(CaseClassification.NOT_CLASSIFIED);
573+
classificationField.setValue(Sets.newHashSet(getValue().getCaseClassification()));
574+
classificationField.select(getValue().getCaseClassification());
564575
}
565576
}
566577

sormas-ui/src/main/java/de/symeda/sormas/ui/selfreport/processing/SelfReportProcessingFLow.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ protected void handleCreateCase(
128128
Window window = VaadinUiUtil.createPopupWindow();
129129

130130
CommitDiscardWrapperComponent<CaseCreateForm> caseCreateComponent =
131-
ControllerProvider.getCaseController().getCaseCreateComponent(null, null, null, null, null, true);
131+
ControllerProvider.getCaseController().getCaseCreateComponent(null, null, null, null, null, true, true);
132132
CaseCreateForm caseCreateForm = caseCreateComponent.getWrappedComponent();
133133

134134
caseCreateComponent.addDiscardListener(callback::cancel);

0 commit comments

Comments
 (0)