15
15
16
16
package de .symeda .sormas .ui .utils ;
17
17
18
+ import static com .vaadin .v7 .data .fieldgroup .DefaultFieldGroupFieldFactory .CAPTION_PROPERTY_ID ;
19
+
18
20
import java .util .ArrayList ;
19
21
import java .util .Collection ;
20
22
import java .util .List ;
@@ -221,6 +223,11 @@ protected ComboBox addDiseaseField(
221
223
222
224
diseaseField = addField (fieldId , ComboBox .class );
223
225
this .setServerDiseaseAsDefault = setServerDiseaseAsDefault ;
226
+
227
+ if (hideFollowUpDisabledDiseases ) {
228
+ removeFollowUpDisabledDiseases (diseaseField );
229
+ }
230
+
224
231
if (showNonPrimaryDiseases ) {
225
232
addNonPrimaryDiseasesTo (diseaseField );
226
233
}
@@ -234,15 +241,10 @@ protected ComboBox addDiseaseField(
234
241
Object value = e .getProperty ().getValue ();
235
242
if (value != null && !diseaseField .containsId (value )) {
236
243
Item newItem = diseaseField .addItem (value );
237
- newItem .getItemProperty (SormasFieldGroupFieldFactory . CAPTION_PROPERTY_ID ).setValue (value .toString ());
244
+ newItem .getItemProperty (CAPTION_PROPERTY_ID ).setValue (value .toString ());
238
245
}
239
246
});
240
247
241
- //
242
- if (hideFollowUpDisabledDiseases ) {
243
- removeFollowUpDisabledDiseases (diseaseField );
244
- }
245
-
246
248
return diseaseField ;
247
249
}
248
250
@@ -509,17 +511,16 @@ protected void addNonPrimaryDiseasesTo(ComboBox diseaseField) {
509
511
}
510
512
511
513
Item newItem = diseaseField .addItem (disease );
512
- newItem .getItemProperty (SormasFieldGroupFieldFactory . CAPTION_PROPERTY_ID ).setValue (disease .toString ());
514
+ newItem .getItemProperty (CAPTION_PROPERTY_ID ).setValue (disease .toString ());
513
515
}
514
516
}
515
517
516
518
protected void removeFollowUpDisabledDiseases (ComboBox diseaseField ) {
517
- List <Disease > allActiveDiseases = FacadeProvider .getDiseaseConfigurationFacade ().getAllActiveDiseases ();
518
-
519
- for (Disease disease : allActiveDiseases ) {
520
- if (diseaseField .getItem (disease ) != null && !disease .isDefaultFollowUpEnabled ()) {
521
- diseaseField .removeItem (disease );
522
- }
519
+ List <Disease > allDiseasesWithFollowUp = FacadeProvider .getDiseaseConfigurationFacade ().getAllDiseasesWithFollowUp (true , true , true );
520
+ diseaseField .removeAllItems ();
521
+ for (Object r : allDiseasesWithFollowUp ) {
522
+ Item newItem = diseaseField .addItem (r );
523
+ newItem .getItemProperty (CAPTION_PROPERTY_ID ).setValue (r .toString ());
523
524
}
524
525
}
525
526
0 commit comments