Skip to content

Commit a02101a

Browse files
authored
Merge pull request #13697 from SORMAS-Foundation/bugfix-13639-drug-susc-result-component-visibility
fixed issue with visibility of drug susc form
2 parents e88508f + 3bb7931 commit a02101a

3 files changed

Lines changed: 54 additions & 50 deletions

File tree

sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestForm.java

Lines changed: 45 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -225,47 +225,59 @@ private void updateDrugSusceptibilityFieldSpecifications(PathogenTestType testTy
225225
if ((FacadeProvider.getConfigFacade().isConfiguredCountry(CountryHelper.COUNTRY_CODE_LUXEMBOURG))) {
226226
boolean wasReadOnly = testResultField.isReadOnly();
227227

228-
if ((disease == Disease.TUBERCULOSIS || disease == Disease.LATENT_TUBERCULOSIS) && testType != null) {
229-
230-
if (Arrays
231-
.asList(PathogenTestType.BEIJINGGENOTYPING, PathogenTestType.MIRU_PATTERN_CODE, PathogenTestType.ANTIBIOTIC_SUSCEPTIBILITY)
232-
.contains(testType)) {
233-
if (wasReadOnly) {
234-
testResultField.setReadOnly(false);
235-
}
236-
testResultField.setValue(PathogenTestResultType.NOT_APPLICABLE);
237-
if (wasReadOnly) {
238-
testResultField.setReadOnly(true);
239-
}
240-
} else if (testType == PathogenTestType.SPOLIGOTYPING) {
241-
if (wasReadOnly) {
228+
if (List
229+
.of(
230+
Disease.TUBERCULOSIS,
231+
Disease.LATENT_TUBERCULOSIS,
232+
Disease.INVASIVE_MENINGOCOCCAL_INFECTION,
233+
Disease.INVASIVE_PNEUMOCOCCAL_INFECTION)
234+
.contains(disease)
235+
&& testType != null) {
236+
if (List.of(Disease.TUBERCULOSIS, Disease.LATENT_TUBERCULOSIS).contains(disease)) {
237+
if (Arrays
238+
.asList(
239+
PathogenTestType.BEIJINGGENOTYPING,
240+
PathogenTestType.MIRU_PATTERN_CODE,
241+
PathogenTestType.ANTIBIOTIC_SUSCEPTIBILITY)
242+
.contains(testType)) {
243+
if (wasReadOnly) {
244+
testResultField.setReadOnly(false);
245+
}
246+
testResultField.setValue(PathogenTestResultType.NOT_APPLICABLE);
247+
if (wasReadOnly) {
248+
testResultField.setReadOnly(true);
249+
}
250+
} else if (testType == PathogenTestType.SPOLIGOTYPING) {
251+
if (wasReadOnly) {
252+
testResultField.setReadOnly(false);
253+
}
254+
testResultField.setValue(PathogenTestResultType.POSITIVE);
255+
if (wasReadOnly) {
256+
testResultField.setReadOnly(true);
257+
}
258+
} else if (wasReadOnly) {
259+
// Field was read-only but no longer meets conditions for auto-set values
242260
testResultField.setReadOnly(false);
261+
testResultField.setValue(null);
243262
}
244-
testResultField.setValue(PathogenTestResultType.POSITIVE);
245-
if (wasReadOnly) {
246-
testResultField.setReadOnly(true);
247-
}
248-
} else if (wasReadOnly) {
249-
// Field was read-only but no longer meets conditions for auto-set values
250-
testResultField.setReadOnly(false);
251-
testResultField.setValue(null);
263+
}
264+
265+
if (List.of(PathogenTestType.ANTIBIOTIC_SUSCEPTIBILITY).contains(testType)) {
266+
drugSusceptibilityField.updateFieldsVisibility(disease, testType);
267+
} else {
268+
drugSusceptibilityField.updateFieldsVisibility(disease, testType);
252269
}
253270
} else if (wasReadOnly) {
254271
// Disease is not TB or testType is null, but field was read-only
255272
testResultField.setReadOnly(false);
256273
testResultField.setValue(null);
257274
}
258-
259-
drugSusceptibilityField.updateFieldsVisibility(disease, testType);
260-
drugSusceptibilityField.setVisible(true);
261275
} else {
262276
if ((disease != Disease.TUBERCULOSIS && disease != Disease.LATENT_TUBERCULOSIS)
263277
&& (DiseaseHelper.checkDiseaseIsInvasiveBacterialDiseases(disease) && testType == PathogenTestType.ANTIBIOTIC_SUSCEPTIBILITY)) { // for non lux tb no drug susceptibility
264278
drugSusceptibilityField.updateFieldsVisibility(disease, testType);
265-
drugSusceptibilityField.setVisible(true);
266279
} else {
267280
if (drugSusceptibilityField != null) {
268-
drugSusceptibilityField.setVisible(false);
269281
drugSusceptibilityField.updateFieldsVisibility(disease, testType);
270282
}
271283
}
@@ -467,10 +479,11 @@ protected void addFields() {
467479
drugSusceptibilityField = (DrugSusceptibilityForm) addField(
468480
PathogenTestDto.DRUG_SUSCEPTIBILITY,
469481
new DrugSusceptibilityForm(
470-
FieldVisibilityCheckers.withCountry(FacadeProvider.getConfigFacade().getCountryLocale()),
482+
FieldVisibilityCheckers.getNoop(),
471483
UiFieldAccessCheckers.getDefault(true, FacadeProvider.getConfigFacade().getCountryLocale())));
472484
drugSusceptibilityField.setCaption(null);
473-
drugSusceptibilityField.setVisible(false);
485+
//drugSusceptibilityField.setVisible(false);
486+
addToVisibleAllowedFields(drugSusceptibilityField);
474487

475488
if (FacadeProvider.getConfigFacade().isConfiguredCountry(CountryHelper.COUNTRY_CODE_LUXEMBOURG)) {
476489
//tuberculosis-pcr test specification
@@ -532,22 +545,6 @@ protected void addFields() {
532545
FieldHelper.setVisibleWhen(getFieldGroup(), PathogenTestDto.PATTERN_PROFILE, tuberculosisMiruCodeDependencies, true);
533546
//FieldHelper.setRequiredWhen(getFieldGroup(), PathogenTestDto.PATTERN_PROFILE, tuberculosisMiruCodeDependencies);
534547

535-
//tuberculosis-antibiotic test specification
536-
Map<Object, List<Object>> tuberculosisAntibioticDependencies = new HashMap<>() {
537-
538-
{
539-
put(
540-
PathogenTestDto.TESTED_DISEASE,
541-
Arrays.asList(
542-
Disease.TUBERCULOSIS,
543-
Disease.LATENT_TUBERCULOSIS,
544-
Disease.INVASIVE_MENINGOCOCCAL_INFECTION,
545-
Disease.INVASIVE_PNEUMOCOCCAL_INFECTION));
546-
put(PathogenTestDto.TEST_TYPE, Arrays.asList(PathogenTestType.ANTIBIOTIC_SUSCEPTIBILITY));
547-
}
548-
};
549-
FieldHelper.setVisibleWhen(getFieldGroup(), PathogenTestDto.DRUG_SUSCEPTIBILITY, tuberculosisAntibioticDependencies, true);
550-
551548
//test result - read only
552549
Map<Object, List<Object>> tuberculosisTestResultReadOnlyDependencies = new HashMap<>() {
553550

@@ -964,9 +961,6 @@ protected void addFields() {
964961
addField(PathogenTestDto.OTHER_DELETION_REASON, TextArea.class).setRows(3);
965962
setVisible(false, PathogenTestDto.DELETION_REASON, PathogenTestDto.OTHER_DELETION_REASON);
966963

967-
initializeAccessAndAllowedAccesses();
968-
initializeVisibilitiesAndAllowedVisibilities();
969-
970964
pcrTestSpecification.setVisible(false);
971965

972966
if (isVisibleAllowed(PathogenTestDto.PRESCRIBER_PHYSICIAN_CODE)) {
@@ -1262,5 +1256,8 @@ protected void addFields() {
12621256
setRequired(true, PathogenTestDto.LAB);
12631257
}
12641258
setRequired(true, PathogenTestDto.TEST_TYPE, PathogenTestDto.TEST_RESULT);
1259+
1260+
initializeAccessAndAllowedAccesses();
1261+
initializeVisibilitiesAndAllowedVisibilities();
12651262
}
12661263
}

sormas-ui/src/main/java/de/symeda/sormas/ui/therapy/DrugSusceptibilityForm.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public class DrugSusceptibilityForm extends AbstractEditForm<DrugSusceptibilityD
5151

5252
private static final String FORM_HEADING_LOC = "formHeadingLoc";
5353

54+
private Label formHeadingLabel;
55+
5456
//@formatter:off
5557
private static final String HTML_LAYOUT =
5658
loc(FORM_HEADING_LOC) +
@@ -79,7 +81,7 @@ public class DrugSusceptibilityForm extends AbstractEditForm<DrugSusceptibilityD
7981

8082
public DrugSusceptibilityForm(FieldVisibilityCheckers fieldVisibilityCheckers, UiFieldAccessCheckers fieldAccessCheckers) {
8183
super(DrugSusceptibilityDto.class, I18N_PREFIX, true, fieldVisibilityCheckers, fieldAccessCheckers);
82-
this.addStyleNames(CssStyles.VIEW_SECTION, CssStyles.VSPACE_2);
84+
//this.addStyleNames(CssStyles.VIEW_SECTION, CssStyles.VSPACE_2);
8385
}
8486

8587
@Override
@@ -89,9 +91,10 @@ protected String createHtmlLayout() {
8991

9092
@Override
9193
protected void addFields() {
92-
Label formHeadingLabel = new Label(I18nProperties.getString(Strings.headingDrugSusceptibility));
94+
formHeadingLabel = new Label(I18nProperties.getString(Strings.headingDrugSusceptibility));
9395
formHeadingLabel.addStyleName(H3);
9496
getContent().addComponent(formHeadingLabel, FORM_HEADING_LOC);
97+
formHeadingLabel.setVisible(false);
9598

9699
addMicField(DrugSusceptibilityDto.AMIKACIN_MIC, Drug.AMIKACIN).setInputPrompt(I18nProperties.getString(Strings.promptMicValue));
97100
addResistanceResultField(DrugSusceptibilityDto.AMIKACIN_SUSCEPTIBILITY)

sormas-ui/src/main/java/de/symeda/sormas/ui/utils/AbstractEditForm.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,10 @@ protected boolean isVisibleAllowed(String propertyId) {
561561
return isVisibleAllowed(getFieldGroup().getField(propertyId));
562562
}
563563

564+
protected void addToVisibleAllowedFields(Field<?> field) {
565+
visibleAllowedFields.add(field);
566+
}
567+
564568
/**
565569
* Sets the initial enabled states based on annotations and builds a list of all fields in a form
566570
* that are allowed to be enabled based on access rights

0 commit comments

Comments
 (0)