31
31
import java .util .Date ;
32
32
import java .util .List ;
33
33
34
- import de .symeda .sormas .api .caze .CaseClassification ;
35
34
import org .apache .commons .collections4 .CollectionUtils ;
36
35
37
36
import com .google .common .collect .Sets ;
47
46
48
47
import de .symeda .sormas .api .Disease ;
49
48
import de .symeda .sormas .api .FacadeProvider ;
49
+ import de .symeda .sormas .api .caze .CaseClassification ;
50
50
import de .symeda .sormas .api .caze .CaseDataDto ;
51
51
import de .symeda .sormas .api .caze .CaseOrigin ;
52
52
import de .symeda .sormas .api .customizableenum .CustomizableEnumType ;
@@ -127,6 +127,7 @@ public class CaseCreateForm extends AbstractEditForm<CaseDataDto> {
127
127
//@formatter:off
128
128
private static final String HTML_LAYOUT = fluidRowLocs (CaseDataDto .CASE_ORIGIN , "" )
129
129
+ fluidRowLocs (CaseDataDto .REPORT_DATE , CaseDataDto .EPID_NUMBER )
130
+ + fluidRowLocs (CaseDataDto .CASE_CLASSIFICATION )
130
131
+ fluidRowLocs (CaseDataDto .CASE_REFERENCE_NUMBER , CaseDataDto .EXTERNAL_ID )
131
132
+ fluidRow (
132
133
fluidColumnLoc (6 , 0 , CaseDataDto .DISEASE ),
@@ -170,6 +171,7 @@ public CaseCreateForm(Boolean showHomeAddressForm, Boolean showPersonSearchButto
170
171
this .convertedTravelEntry = convertedTravelEntry ;
171
172
this .showHomeAddressForm = showHomeAddressForm ;
172
173
this .showPersonSearchButton = showPersonSearchButton ;
174
+
173
175
addFields ();
174
176
setWidth (720 , Unit .PIXELS );
175
177
hideValidationUntilNextCommit ();
@@ -196,6 +198,11 @@ protected void addFields() {
196
198
addField (CaseDataDto .CASE_REFERENCE_NUMBER , TextField .class );
197
199
198
200
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
+
199
206
ComboBox diseaseField = addDiseaseField (CaseDataDto .DISEASE , false , true , false );
200
207
diseaseVariantField = addField (CaseDataDto .DISEASE_VARIANT , ComboBox .class );
201
208
diseaseVariantDetailsField = addField (CaseDataDto .DISEASE_VARIANT_DETAILS , TextField .class );
@@ -517,7 +524,7 @@ protected void addFields() {
517
524
}
518
525
});
519
526
diseaseField .addValueChangeListener ((ValueChangeListener ) valueChangeEvent -> {
520
- updateDiseaseVariant ((Disease ) valueChangeEvent .getProperty ().getValue ());
527
+ handleDiseaseChanged ((Disease ) valueChangeEvent .getProperty ().getValue ());
521
528
personCreateForm .updatePresentConditionEnum ((Disease ) valueChangeEvent .getProperty ().getValue ());
522
529
});
523
530
@@ -528,7 +535,7 @@ protected void addFields() {
528
535
529
536
if (diseaseField .getValue () != null ) {
530
537
Disease disease = (Disease ) diseaseField .getValue ();
531
- updateDiseaseVariant (disease );
538
+ handleDiseaseChanged (disease );
532
539
personCreateForm .updatePresentConditionEnum (disease );
533
540
}
534
541
}
@@ -547,20 +554,24 @@ private void hideAndFillJurisdictionFields() {
547
554
responsibleCommunityCombo .setValue (FacadeProvider .getCommunityFacade ().getDefaultInfrastructureReference ());
548
555
}
549
556
550
- private void updateDiseaseVariant (Disease disease ) {
557
+ private void handleDiseaseChanged (Disease newDisease ) {
551
558
List <DiseaseVariant > diseaseVariants =
552
- FacadeProvider .getCustomizableEnumFacade ().getEnumValues (CustomizableEnumType .DISEASE_VARIANT , disease );
559
+ FacadeProvider .getCustomizableEnumFacade ().getEnumValues (CustomizableEnumType .DISEASE_VARIANT , newDisease );
553
560
FieldHelper .updateItems (diseaseVariantField , diseaseVariants );
554
561
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 ) {
557
566
facilityOrHome .setValue (Sets .newHashSet (TypeOfPlace .HOME ));
558
567
facilityOrHome .select (TypeOfPlace .HOME );
559
- getValue ().setCaseClassification (CaseClassification .CONFIRMED );
568
+ classificationField .setValue (Sets .newHashSet (CaseClassification .CONFIRMED ));
569
+ classificationField .select (CaseClassification .CONFIRMED );
560
570
} else {
561
571
facilityOrHome .setValue (null );
562
572
facilityOrHome .unselect (TypeOfPlace .HOME );
563
- getValue ().setCaseClassification (CaseClassification .NOT_CLASSIFIED );
573
+ classificationField .setValue (Sets .newHashSet (getValue ().getCaseClassification ()));
574
+ classificationField .select (getValue ().getCaseClassification ());
564
575
}
565
576
}
566
577
0 commit comments