@@ -112,7 +112,9 @@ public class TherapyForm extends AbstractEditForm<TherapyDto> {
112112 private TextField prescriptionTextFilter ;
113113 private ComboBox treatmentTypeFilter ;
114114 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 ;
116118
117119 public TherapyForm (CaseDataDto caze , Disease disease , boolean isPseudonymized , boolean inJurisdiction , boolean isEditAllowed ) {
118120
@@ -285,9 +287,9 @@ public void run() {
285287 prescriptionTypeFilter .addItems ((Object []) TreatmentType .values ());
286288 prescriptionTypeFilter .addValueChangeListener (e -> {
287289 prescriptionCriteria .prescriptionType (((TreatmentType ) e .getProperty ().getValue ()));
288- ControllerProvider .getTherapyController ().navigateTo (applyingCriteria , true , prescriptionCriteria );
290+ ControllerProvider .getTherapyController ().navigateTo (prescriptionApplyingCriteria , true , prescriptionCriteria );
289291
290- applyingCriteria = false ;
292+ prescriptionApplyingCriteria = false ;
291293 });
292294 filterRow .addComponent (prescriptionTypeFilter );
293295
@@ -363,8 +365,9 @@ public void run() {
363365 treatmentTypeFilter .addItems ((Object []) TreatmentType .values ());
364366 treatmentTypeFilter .addValueChangeListener (e -> {
365367 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 ;
368371 });
369372 filterRow .addComponent (treatmentTypeFilter );
370373
@@ -394,14 +397,16 @@ private void update(CaseDataDto caze) {
394397 prescriptionCriteria .therapy (caze .getTherapy ().toReference ());
395398 treatmentCriteria .therapy (caze .getTherapy ().toReference ());
396399
397- applyingCriteria = true ;
400+ prescriptionApplyingCriteria = true ;
398401
399402 prescriptionTypeFilter .setValue (prescriptionCriteria .getPrescriptionType ());
400403 prescriptionTextFilter .setValue (prescriptionCriteria .getTextFilter ());
404+ treatmentApplyingCriteria = true ;
401405 treatmentTypeFilter .setValue (treatmentCriteria .getTreatmentType ());
402406 treatmentTextFilter .setValue (treatmentCriteria .getTextFilter ());
403407
404- applyingCriteria = false ;
408+ prescriptionApplyingCriteria = false ;
409+ treatmentApplyingCriteria = false ;
405410 }
406411
407412 public void reloadPrescriptionGrid () {
0 commit comments