Skip to content

Commit

Permalink
#13157 - Disable Contact Management for RSV Cases
Browse files Browse the repository at this point in the history
  • Loading branch information
SergiuPacurariu committed Nov 11, 2024
1 parent 902363d commit b99f4bb
Showing 1 changed file with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

package de.symeda.sormas.ui.utils;

import static com.vaadin.v7.data.fieldgroup.DefaultFieldGroupFieldFactory.CAPTION_PROPERTY_ID;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
Expand Down Expand Up @@ -221,6 +223,11 @@ protected ComboBox addDiseaseField(

diseaseField = addField(fieldId, ComboBox.class);
this.setServerDiseaseAsDefault = setServerDiseaseAsDefault;

if (hideFollowUpDisabledDiseases) {
removeFollowUpDisabledDiseases(diseaseField);
}

if (showNonPrimaryDiseases) {
addNonPrimaryDiseasesTo(diseaseField);
}
Expand All @@ -234,15 +241,10 @@ protected ComboBox addDiseaseField(
Object value = e.getProperty().getValue();
if (value != null && !diseaseField.containsId(value)) {
Item newItem = diseaseField.addItem(value);
newItem.getItemProperty(SormasFieldGroupFieldFactory.CAPTION_PROPERTY_ID).setValue(value.toString());
newItem.getItemProperty(CAPTION_PROPERTY_ID).setValue(value.toString());
}
});

//
if (hideFollowUpDisabledDiseases) {
removeFollowUpDisabledDiseases(diseaseField);
}

return diseaseField;
}

Expand Down Expand Up @@ -509,17 +511,16 @@ protected void addNonPrimaryDiseasesTo(ComboBox diseaseField) {
}

Item newItem = diseaseField.addItem(disease);
newItem.getItemProperty(SormasFieldGroupFieldFactory.CAPTION_PROPERTY_ID).setValue(disease.toString());
newItem.getItemProperty(CAPTION_PROPERTY_ID).setValue(disease.toString());
}
}

protected void removeFollowUpDisabledDiseases(ComboBox diseaseField) {
List<Disease> allActiveDiseases = FacadeProvider.getDiseaseConfigurationFacade().getAllActiveDiseases();

for (Disease disease : allActiveDiseases) {
if (diseaseField.getItem(disease) != null && !disease.isDefaultFollowUpEnabled()) {
diseaseField.removeItem(disease);
}
List<Disease> allDiseasesWithFollowUp = FacadeProvider.getDiseaseConfigurationFacade().getAllDiseasesWithFollowUp(true, true, true);
diseaseField.removeAllItems();
for (Object r : allDiseasesWithFollowUp) {
Item newItem = diseaseField.addItem(r);
newItem.getItemProperty(CAPTION_PROPERTY_ID).setValue(r.toString());
}
}

Expand Down

0 comments on commit b99f4bb

Please sign in to comment.