@@ -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}
0 commit comments