|
52 | 52 |
|
53 | 53 | import de.symeda.sormas.api.CountryHelper; |
54 | 54 | import de.symeda.sormas.api.Disease; |
55 | | -import de.symeda.sormas.api.DiseaseHelper; |
56 | 55 | import de.symeda.sormas.api.FacadeProvider; |
57 | 56 | import de.symeda.sormas.api.customizableenum.CustomizableEnumType; |
58 | 57 | import de.symeda.sormas.api.disease.DiseaseVariant; |
@@ -257,7 +256,13 @@ private static void setCqValueVisibility( |
257 | 256 | } |
258 | 257 |
|
259 | 258 | 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) { |
261 | 266 | if ((FacadeProvider.getConfigFacade().isConfiguredCountry(CountryHelper.COUNTRY_CODE_LUXEMBOURG))) { |
262 | 267 | boolean wasReadOnly = testResultField.isReadOnly(); |
263 | 268 |
|
@@ -307,26 +312,11 @@ private void updateDrugSusceptibilityFieldSpecifications(PathogenTestType testTy |
307 | 312 | } |
308 | 313 | } |
309 | 314 | } |
310 | | - |
311 | | - if (List.of(PathogenTestType.ANTIBIOTIC_SUSCEPTIBILITY).contains(testType)) { |
312 | | - drugSusceptibilityField.updateFieldsVisibility(disease, testType); |
313 | | - } else { |
314 | | - drugSusceptibilityField.updateFieldsVisibility(disease, testType); |
315 | | - } |
316 | 315 | } else if (wasReadOnly) { |
317 | 316 | // Disease is not TB or testType is null, but field was read-only |
318 | 317 | testResultField.setReadOnly(false); |
319 | 318 | testResultField.setValue(null); |
320 | 319 | } |
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 | | - } |
330 | 320 | } |
331 | 321 | } |
332 | 322 | } |
@@ -609,22 +599,10 @@ protected void addFields() { |
609 | 599 | } |
610 | 600 | }; |
611 | 601 | 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); |
625 | 602 | } |
626 | 603 |
|
627 | 604 | seroTypeTF.setVisible(false); |
| 605 | + |
628 | 606 | ComboBox seroTypeMetCB = addField(PathogenTestDto.SEROTYPING_METHOD, ComboBox.class); |
629 | 607 | seroTypeMetCB.setVisible(false); |
630 | 608 | ComboBox seroGrpSepcCB = addField(PathogenTestDto.SERO_GROUP_SPECIFICATION, ComboBox.class); |
@@ -1006,12 +984,9 @@ protected void addFields() { |
1006 | 984 |
|
1007 | 985 | pcrTestSpecification.setVisible(false); |
1008 | 986 |
|
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); |
1015 | 990 | Map<Object, List<Object>> pcrTestSpecificationVisibilityDependencies = new HashMap<>() { |
1016 | 991 |
|
1017 | 992 | { |
@@ -1187,12 +1162,13 @@ protected void addFields() { |
1187 | 1162 | }); |
1188 | 1163 |
|
1189 | 1164 | BiConsumer<Disease, PathogenTestType> resultField = (disease, testType) -> { |
1190 | | - if (testResultField.isReadOnly()) { |
1191 | | - return; |
1192 | | - } |
| 1165 | + final boolean testResultFieldReadOnly = testResultField.isReadOnly(); |
| 1166 | + testResultField.setReadOnly(false); |
| 1167 | + |
1193 | 1168 | if (RESULT_FIELD_DECISION_MAP.containsKey(disease) && RESULT_FIELD_DECISION_MAP.get(disease).contains(testType)) { |
1194 | 1169 | testResultField.setValue(PathogenTestResultType.POSITIVE); |
1195 | 1170 | testResultField.setEnabled(false); |
| 1171 | + testResultField.setReadOnly(testResultFieldReadOnly); |
1196 | 1172 | } else { |
1197 | 1173 | testResultField.clear(); |
1198 | 1174 | testResultField.setEnabled(true); |
@@ -1296,5 +1272,16 @@ protected void addFields() { |
1296 | 1272 |
|
1297 | 1273 | initializeAccessAndAllowedAccesses(); |
1298 | 1274 | 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)); |
1299 | 1286 | } |
1300 | 1287 | } |
0 commit comments