diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestForm.java index 75e5de17c0b..62c28a0b62e 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestForm.java @@ -52,7 +52,6 @@ import de.symeda.sormas.api.CountryHelper; import de.symeda.sormas.api.Disease; -import de.symeda.sormas.api.DiseaseHelper; import de.symeda.sormas.api.FacadeProvider; import de.symeda.sormas.api.customizableenum.CustomizableEnumType; import de.symeda.sormas.api.disease.DiseaseVariant; @@ -257,7 +256,13 @@ private static void setCqValueVisibility( } private void updateDrugSusceptibilityFieldSpecifications(PathogenTestType testType, Disease disease) { - if (disease != null) { // Drug susceptibility is applicable only diseass not for environment + + // Hide or show drug susceptibility fields based on the disease and test type (if disease is null then drug susceptibility should be hidden) + if (drugSusceptibilityField != null) { + drugSusceptibilityField.updateFieldsVisibility(disease, testType); + } + + if (disease != null) { if ((FacadeProvider.getConfigFacade().isConfiguredCountry(CountryHelper.COUNTRY_CODE_LUXEMBOURG))) { boolean wasReadOnly = testResultField.isReadOnly(); @@ -307,26 +312,11 @@ private void updateDrugSusceptibilityFieldSpecifications(PathogenTestType testTy } } } - - if (List.of(PathogenTestType.ANTIBIOTIC_SUSCEPTIBILITY).contains(testType)) { - drugSusceptibilityField.updateFieldsVisibility(disease, testType); - } else { - drugSusceptibilityField.updateFieldsVisibility(disease, testType); - } } else if (wasReadOnly) { // Disease is not TB or testType is null, but field was read-only testResultField.setReadOnly(false); testResultField.setValue(null); } - } else { - if ((disease != Disease.TUBERCULOSIS && disease != Disease.LATENT_TUBERCULOSIS) - && (DiseaseHelper.checkDiseaseIsInvasiveBacterialDiseases(disease) && testType == PathogenTestType.ANTIBIOTIC_SUSCEPTIBILITY)) { // for non lux tb no drug susceptibility - drugSusceptibilityField.updateFieldsVisibility(disease, testType); - } else { - if (drugSusceptibilityField != null) { - drugSusceptibilityField.updateFieldsVisibility(disease, testType); - } - } } } } @@ -609,22 +599,10 @@ protected void addFields() { } }; FieldHelper.setReadOnlyWhen(getFieldGroup(), PathogenTestDto.TEST_RESULT, tuberculosisTestResultReadOnlyDependencies, true, false); - } else if (!FacadeProvider.getConfigFacade().isConfiguredCountry(CountryHelper.COUNTRY_CODE_LUXEMBOURG) - && DiseaseHelper.checkDiseaseIsInvasiveBacterialDiseases(disease)) { - //invasive-antibiotic test specification - Map> invasiveAntibioticDependencies = new HashMap<>() { - - { - put( - PathogenTestDto.TESTED_DISEASE, - Arrays.asList(Disease.INVASIVE_MENINGOCOCCAL_INFECTION, Disease.INVASIVE_PNEUMOCOCCAL_INFECTION)); - put(PathogenTestDto.TEST_TYPE, Arrays.asList(PathogenTestType.ANTIBIOTIC_SUSCEPTIBILITY)); - } - }; - FieldHelper.setVisibleWhen(getFieldGroup(), PathogenTestDto.DRUG_SUSCEPTIBILITY, invasiveAntibioticDependencies, true); } seroTypeTF.setVisible(false); + ComboBox seroTypeMetCB = addField(PathogenTestDto.SEROTYPING_METHOD, ComboBox.class); seroTypeMetCB.setVisible(false); ComboBox seroGrpSepcCB = addField(PathogenTestDto.SERO_GROUP_SPECIFICATION, ComboBox.class); @@ -1006,12 +984,9 @@ protected void addFields() { pcrTestSpecification.setVisible(false); - if (isVisibleAllowed(PathogenTestDto.PRESCRIBER_PHYSICIAN_CODE)) { - Label prescriberHeadingLabel = new Label(I18nProperties.getCaption(Captions.PathogenTest_prescriber)); - prescriberHeadingLabel.addStyleName(H3); - getContent().addComponent(prescriberHeadingLabel, PRESCRIBER_HEADING_LOC); - } - + Label prescriberHeadingLabel = new Label(I18nProperties.getCaption(Captions.PathogenTest_prescriber)); + prescriberHeadingLabel.addStyleName(H3); + getContent().addComponent(prescriberHeadingLabel, PRESCRIBER_HEADING_LOC); Map> pcrTestSpecificationVisibilityDependencies = new HashMap<>() { { @@ -1187,12 +1162,13 @@ protected void addFields() { }); BiConsumer resultField = (disease, testType) -> { - if (testResultField.isReadOnly()) { - return; - } + final boolean testResultFieldReadOnly = testResultField.isReadOnly(); + testResultField.setReadOnly(false); + if (RESULT_FIELD_DECISION_MAP.containsKey(disease) && RESULT_FIELD_DECISION_MAP.get(disease).contains(testType)) { testResultField.setValue(PathogenTestResultType.POSITIVE); testResultField.setEnabled(false); + testResultField.setReadOnly(testResultFieldReadOnly); } else { testResultField.clear(); testResultField.setEnabled(true); @@ -1296,5 +1272,16 @@ protected void addFields() { initializeAccessAndAllowedAccesses(); initializeVisibilitiesAndAllowedVisibilities(); + + // Hide/show prescriber heading after the visibilities have been initialized + prescriberHeadingLabel.setVisible( + isVisibleAllowed(PathogenTestDto.PRESCRIBER_PHYSICIAN_CODE) + || isVisibleAllowed(PathogenTestDto.PRESCRIBER_FIRST_NAME) + || isVisibleAllowed(PathogenTestDto.PRESCRIBER_LAST_NAME) + || isVisibleAllowed(PathogenTestDto.PRESCRIBER_PHONE_NUMBER) + || isVisibleAllowed(PathogenTestDto.PRESCRIBER_ADDRESS) + || isVisibleAllowed(PathogenTestDto.PRESCRIBER_POSTAL_CODE) + || isVisibleAllowed(PathogenTestDto.PRESCRIBER_CITY) + || isVisibleAllowed(PathogenTestDto.PRESCRIBER_COUNTRY)); } } diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/therapy/DrugSusceptibilityForm.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/therapy/DrugSusceptibilityForm.java index 4d812a2c75f..42cfabaf6ae 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/therapy/DrugSusceptibilityForm.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/therapy/DrugSusceptibilityForm.java @@ -302,6 +302,8 @@ public void updateFieldsVisibility(Disease disease, PathogenTestType pathogenTes List applicableFieldIds = AnnotationFieldHelper.getFieldNamesWithMatchingDiseaseAndTestAnnotations(DrugSusceptibilityDto.class, disease, pathogenTestType); + formHeadingLabel.setVisible(!applicableFieldIds.isEmpty()); + if (!applicableFieldIds.isEmpty()) { FieldHelper.showOnlyFields(getFieldGroup(), applicableFieldIds, true); }