Skip to content

Commit 536a1b6

Browse files
authored
Merge pull request #13752 from SORMAS-Foundation/bugfix-pathogen_test_form_drug_susceptibility
Fixed visibility of drug susceptibility and prescriber heading
2 parents 117307c + 963f36e commit 536a1b6

File tree

2 files changed

+28
-39
lines changed

2 files changed

+28
-39
lines changed

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

Lines changed: 26 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252

5353
import de.symeda.sormas.api.CountryHelper;
5454
import de.symeda.sormas.api.Disease;
55-
import de.symeda.sormas.api.DiseaseHelper;
5655
import de.symeda.sormas.api.FacadeProvider;
5756
import de.symeda.sormas.api.customizableenum.CustomizableEnumType;
5857
import de.symeda.sormas.api.disease.DiseaseVariant;
@@ -257,7 +256,13 @@ private static void setCqValueVisibility(
257256
}
258257

259258
private void updateDrugSusceptibilityFieldSpecifications(PathogenTestType testType, Disease disease) {
260-
if (disease != null) { // Drug susceptibility is applicable only diseass not for environment
259+
260+
// Hide or show drug susceptibility fields based on the disease and test type (if disease is null then drug susceptibility should be hidden)
261+
if (drugSusceptibilityField != null) {
262+
drugSusceptibilityField.updateFieldsVisibility(disease, testType);
263+
}
264+
265+
if (disease != null) {
261266
if ((FacadeProvider.getConfigFacade().isConfiguredCountry(CountryHelper.COUNTRY_CODE_LUXEMBOURG))) {
262267
boolean wasReadOnly = testResultField.isReadOnly();
263268

@@ -307,26 +312,11 @@ private void updateDrugSusceptibilityFieldSpecifications(PathogenTestType testTy
307312
}
308313
}
309314
}
310-
311-
if (List.of(PathogenTestType.ANTIBIOTIC_SUSCEPTIBILITY).contains(testType)) {
312-
drugSusceptibilityField.updateFieldsVisibility(disease, testType);
313-
} else {
314-
drugSusceptibilityField.updateFieldsVisibility(disease, testType);
315-
}
316315
} else if (wasReadOnly) {
317316
// Disease is not TB or testType is null, but field was read-only
318317
testResultField.setReadOnly(false);
319318
testResultField.setValue(null);
320319
}
321-
} else {
322-
if ((disease != Disease.TUBERCULOSIS && disease != Disease.LATENT_TUBERCULOSIS)
323-
&& (DiseaseHelper.checkDiseaseIsInvasiveBacterialDiseases(disease) && testType == PathogenTestType.ANTIBIOTIC_SUSCEPTIBILITY)) { // for non lux tb no drug susceptibility
324-
drugSusceptibilityField.updateFieldsVisibility(disease, testType);
325-
} else {
326-
if (drugSusceptibilityField != null) {
327-
drugSusceptibilityField.updateFieldsVisibility(disease, testType);
328-
}
329-
}
330320
}
331321
}
332322
}
@@ -609,22 +599,10 @@ protected void addFields() {
609599
}
610600
};
611601
FieldHelper.setReadOnlyWhen(getFieldGroup(), PathogenTestDto.TEST_RESULT, tuberculosisTestResultReadOnlyDependencies, true, false);
612-
} else if (!FacadeProvider.getConfigFacade().isConfiguredCountry(CountryHelper.COUNTRY_CODE_LUXEMBOURG)
613-
&& DiseaseHelper.checkDiseaseIsInvasiveBacterialDiseases(disease)) {
614-
//invasive-antibiotic test specification
615-
Map<Object, List<Object>> invasiveAntibioticDependencies = new HashMap<>() {
616-
617-
{
618-
put(
619-
PathogenTestDto.TESTED_DISEASE,
620-
Arrays.asList(Disease.INVASIVE_MENINGOCOCCAL_INFECTION, Disease.INVASIVE_PNEUMOCOCCAL_INFECTION));
621-
put(PathogenTestDto.TEST_TYPE, Arrays.asList(PathogenTestType.ANTIBIOTIC_SUSCEPTIBILITY));
622-
}
623-
};
624-
FieldHelper.setVisibleWhen(getFieldGroup(), PathogenTestDto.DRUG_SUSCEPTIBILITY, invasiveAntibioticDependencies, true);
625602
}
626603

627604
seroTypeTF.setVisible(false);
605+
628606
ComboBox seroTypeMetCB = addField(PathogenTestDto.SEROTYPING_METHOD, ComboBox.class);
629607
seroTypeMetCB.setVisible(false);
630608
ComboBox seroGrpSepcCB = addField(PathogenTestDto.SERO_GROUP_SPECIFICATION, ComboBox.class);
@@ -1006,12 +984,9 @@ protected void addFields() {
1006984

1007985
pcrTestSpecification.setVisible(false);
1008986

1009-
if (isVisibleAllowed(PathogenTestDto.PRESCRIBER_PHYSICIAN_CODE)) {
1010-
Label prescriberHeadingLabel = new Label(I18nProperties.getCaption(Captions.PathogenTest_prescriber));
1011-
prescriberHeadingLabel.addStyleName(H3);
1012-
getContent().addComponent(prescriberHeadingLabel, PRESCRIBER_HEADING_LOC);
1013-
}
1014-
987+
Label prescriberHeadingLabel = new Label(I18nProperties.getCaption(Captions.PathogenTest_prescriber));
988+
prescriberHeadingLabel.addStyleName(H3);
989+
getContent().addComponent(prescriberHeadingLabel, PRESCRIBER_HEADING_LOC);
1015990
Map<Object, List<Object>> pcrTestSpecificationVisibilityDependencies = new HashMap<>() {
1016991

1017992
{
@@ -1187,12 +1162,13 @@ protected void addFields() {
11871162
});
11881163

11891164
BiConsumer<Disease, PathogenTestType> resultField = (disease, testType) -> {
1190-
if (testResultField.isReadOnly()) {
1191-
return;
1192-
}
1165+
final boolean testResultFieldReadOnly = testResultField.isReadOnly();
1166+
testResultField.setReadOnly(false);
1167+
11931168
if (RESULT_FIELD_DECISION_MAP.containsKey(disease) && RESULT_FIELD_DECISION_MAP.get(disease).contains(testType)) {
11941169
testResultField.setValue(PathogenTestResultType.POSITIVE);
11951170
testResultField.setEnabled(false);
1171+
testResultField.setReadOnly(testResultFieldReadOnly);
11961172
} else {
11971173
testResultField.clear();
11981174
testResultField.setEnabled(true);
@@ -1296,5 +1272,16 @@ protected void addFields() {
12961272

12971273
initializeAccessAndAllowedAccesses();
12981274
initializeVisibilitiesAndAllowedVisibilities();
1275+
1276+
// Hide/show prescriber heading after the visibilities have been initialized
1277+
prescriberHeadingLabel.setVisible(
1278+
isVisibleAllowed(PathogenTestDto.PRESCRIBER_PHYSICIAN_CODE)
1279+
|| isVisibleAllowed(PathogenTestDto.PRESCRIBER_FIRST_NAME)
1280+
|| isVisibleAllowed(PathogenTestDto.PRESCRIBER_LAST_NAME)
1281+
|| isVisibleAllowed(PathogenTestDto.PRESCRIBER_PHONE_NUMBER)
1282+
|| isVisibleAllowed(PathogenTestDto.PRESCRIBER_ADDRESS)
1283+
|| isVisibleAllowed(PathogenTestDto.PRESCRIBER_POSTAL_CODE)
1284+
|| isVisibleAllowed(PathogenTestDto.PRESCRIBER_CITY)
1285+
|| isVisibleAllowed(PathogenTestDto.PRESCRIBER_COUNTRY));
12991286
}
13001287
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@ public void updateFieldsVisibility(Disease disease, PathogenTestType pathogenTes
302302
List<String> applicableFieldIds =
303303
AnnotationFieldHelper.getFieldNamesWithMatchingDiseaseAndTestAnnotations(DrugSusceptibilityDto.class, disease, pathogenTestType);
304304

305+
formHeadingLabel.setVisible(!applicableFieldIds.isEmpty());
306+
305307
if (!applicableFieldIds.isEmpty()) {
306308
FieldHelper.showOnlyFields(getFieldGroup(), applicableFieldIds, true);
307309
}

0 commit comments

Comments
 (0)