@@ -112,7 +112,9 @@ public class TherapyForm extends AbstractEditForm<TherapyDto> {
112
112
private TextField prescriptionTextFilter ;
113
113
private ComboBox treatmentTypeFilter ;
114
114
private TextField treatmentTextFilter ;
115
- protected boolean applyingCriteria ;
115
+ // To avoid form going infinite loop, need two different flags to track whether the criteria are being applied or not
116
+ protected boolean prescriptionApplyingCriteria ;
117
+ protected boolean treatmentApplyingCriteria ;
116
118
117
119
public TherapyForm (CaseDataDto caze , Disease disease , boolean isPseudonymized , boolean inJurisdiction , boolean isEditAllowed ) {
118
120
@@ -285,9 +287,9 @@ public void run() {
285
287
prescriptionTypeFilter .addItems ((Object []) TreatmentType .values ());
286
288
prescriptionTypeFilter .addValueChangeListener (e -> {
287
289
prescriptionCriteria .prescriptionType (((TreatmentType ) e .getProperty ().getValue ()));
288
- ControllerProvider .getTherapyController ().navigateTo (applyingCriteria , true , prescriptionCriteria );
290
+ ControllerProvider .getTherapyController ().navigateTo (prescriptionApplyingCriteria , true , prescriptionCriteria );
289
291
290
- applyingCriteria = false ;
292
+ prescriptionApplyingCriteria = false ;
291
293
});
292
294
filterRow .addComponent (prescriptionTypeFilter );
293
295
@@ -363,8 +365,9 @@ public void run() {
363
365
treatmentTypeFilter .addItems ((Object []) TreatmentType .values ());
364
366
treatmentTypeFilter .addValueChangeListener (e -> {
365
367
treatmentCriteria .treatmentType (((TreatmentType ) e .getProperty ().getValue ()));
366
- ControllerProvider .getTherapyController ().navigateTo (applyingCriteria , true , treatmentCriteria );
367
- applyingCriteria = false ;
368
+ ControllerProvider .getTherapyController ().navigateTo (treatmentApplyingCriteria , true , treatmentCriteria );
369
+
370
+ treatmentApplyingCriteria = false ;
368
371
});
369
372
filterRow .addComponent (treatmentTypeFilter );
370
373
@@ -394,14 +397,16 @@ private void update(CaseDataDto caze) {
394
397
prescriptionCriteria .therapy (caze .getTherapy ().toReference ());
395
398
treatmentCriteria .therapy (caze .getTherapy ().toReference ());
396
399
397
- applyingCriteria = true ;
400
+ prescriptionApplyingCriteria = true ;
398
401
399
402
prescriptionTypeFilter .setValue (prescriptionCriteria .getPrescriptionType ());
400
403
prescriptionTextFilter .setValue (prescriptionCriteria .getTextFilter ());
404
+ treatmentApplyingCriteria = true ;
401
405
treatmentTypeFilter .setValue (treatmentCriteria .getTreatmentType ());
402
406
treatmentTextFilter .setValue (treatmentCriteria .getTextFilter ());
403
407
404
- applyingCriteria = false ;
408
+ prescriptionApplyingCriteria = false ;
409
+ treatmentApplyingCriteria = false ;
405
410
}
406
411
407
412
public void reloadPrescriptionGrid () {
0 commit comments