23
23
import static de .symeda .sormas .ui .utils .LayoutUtil .fluidRowLocs ;
24
24
import static de .symeda .sormas .ui .utils .LayoutUtil .loc ;
25
25
26
+ import java .util .ArrayList ;
26
27
import java .util .Arrays ;
27
28
import java .util .Date ;
28
29
import java .util .HashMap ;
@@ -206,46 +207,51 @@ private static void setCqValueVisibility(TextField cqValueField, PathogenTestTyp
206
207
}
207
208
}
208
209
209
- private void updateTuberculosisFieldSpecifications (PathogenTestType testType , Disease disease ) {
210
- if ((FacadeProvider .getConfigFacade ().isConfiguredCountry (CountryHelper .COUNTRY_CODE_LUXEMBOURG ))) {
211
- boolean wasReadOnly = testResultField .isReadOnly ();
212
-
213
- if (disease == Disease .TUBERCULOSIS && testType != null ) {
214
- if (Arrays .asList (PathogenTestType .BEIJINGGENOTYPING , PathogenTestType .MIRU_PATTERN_CODE , PathogenTestType .ANTIBIOTIC_SUSCEPTIBILITY )
215
- .contains (testType )) {
216
- if (wasReadOnly ) {
210
+ private void updateDrugSusceptibilityFieldSpecifications (PathogenTestType testType , Disease disease ) {
211
+ if (disease != null ) { // Drug susceptibility is applicable only diseass not for environment
212
+ if ((FacadeProvider .getConfigFacade ().isConfiguredCountry (CountryHelper .COUNTRY_CODE_LUXEMBOURG ))) {
213
+ boolean wasReadOnly = testResultField .isReadOnly ();
214
+
215
+ if (disease == Disease .TUBERCULOSIS && testType != null ) {
216
+ if (Arrays .asList (PathogenTestType .BEIJINGGENOTYPING , PathogenTestType .MIRU_PATTERN_CODE , PathogenTestType .ANTIBIOTIC_SUSCEPTIBILITY ).contains (testType )) {
217
+ if (wasReadOnly ) {
218
+ testResultField .setReadOnly (false );
219
+ }
220
+ testResultField .setValue (PathogenTestResultType .NOT_APPLICABLE );
221
+ if (wasReadOnly ) {
222
+ testResultField .setReadOnly (true );
223
+ }
224
+ } else if (testType == PathogenTestType .SPOLIGOTYPING ) {
225
+ if (wasReadOnly ) {
226
+ testResultField .setReadOnly (false );
227
+ }
228
+ testResultField .setValue (PathogenTestResultType .POSITIVE );
229
+ if (wasReadOnly ) {
230
+ testResultField .setReadOnly (true );
231
+ }
232
+ } else if (wasReadOnly ) {
233
+ // Field was read-only but no longer meets conditions for auto-set values
217
234
testResultField .setReadOnly (false );
218
- }
219
- testResultField .setValue (PathogenTestResultType .NOT_APPLICABLE );
220
- if (wasReadOnly ) {
221
- testResultField .setReadOnly (true );
222
- }
223
- } else if (testType == PathogenTestType .SPOLIGOTYPING ) {
224
- if (wasReadOnly ) {
225
- testResultField .setReadOnly (false );
226
- }
227
- testResultField .setValue (PathogenTestResultType .POSITIVE );
228
- if (wasReadOnly ) {
229
- testResultField .setReadOnly (true );
235
+ testResultField .setValue (null );
230
236
}
231
237
} else if (wasReadOnly ) {
232
- // Field was read-only but no longer meets conditions for auto-set values
238
+ // Disease is not TB or testType is null, but field was read-only
233
239
testResultField .setReadOnly (false );
234
240
testResultField .setValue (null );
235
241
}
236
- } else if (wasReadOnly ) {
237
- // Disease is not TB or testType is null, but field was read-only
238
- testResultField .setReadOnly (false );
239
- testResultField .setValue (null );
240
- }
241
242
242
- drugSusceptibilityField .updateFieldsVisibility (disease , testType );
243
- }else if (!FacadeProvider .getConfigFacade ().isConfiguredCountry (CountryHelper .COUNTRY_CODE_LUXEMBOURG ) && DiseaseHelper .checkDiseaseIsInvasiveBacterialDiseases (disease )){
244
- drugSusceptibilityField .updateFieldsVisibility (disease , testType );
245
- }else {
246
- testResultField .setReadOnly (false );
247
- testResultField .setValue (null );
248
- testResultField .setEnabled (true );
243
+ drugSusceptibilityField .updateFieldsVisibility (disease , testType );
244
+ } else {
245
+ if (disease != Disease .TUBERCULOSIS && (DiseaseHelper .checkDiseaseIsInvasiveBacterialDiseases (disease ) && testType == PathogenTestType .ANTIBIOTIC_SUSCEPTIBILITY )) { // for non lux tb no drug susceptibility
246
+ drugSusceptibilityField .updateFieldsVisibility (disease , testType );
247
+ drugSusceptibilityField .setVisible (true );
248
+ } else {
249
+ if (drugSusceptibilityField != null ) {
250
+ drugSusceptibilityField .setVisible (false );
251
+ drugSusceptibilityField .updateFieldsVisibility (disease , testType );
252
+ }
253
+ }
254
+ }
249
255
}
250
256
}
251
257
@@ -391,13 +397,13 @@ protected void addFields() {
391
397
TextField patternProfileField = addField (PathogenTestDto .PATTERN_PROFILE , TextField .class );
392
398
patternProfileField .setVisible (false );
393
399
394
- drugSusceptibilityField = (DrugSusceptibilityForm ) addField (
395
- PathogenTestDto .DRUG_SUSCEPTIBILITY ,
396
- new DrugSusceptibilityForm (
397
- FieldVisibilityCheckers .withCountry (FacadeProvider .getConfigFacade ().getCountryLocale ()),
398
- UiFieldAccessCheckers .getDefault (true , FacadeProvider .getConfigFacade ().getCountryLocale ())));
399
- drugSusceptibilityField .setCaption (null );
400
- drugSusceptibilityField .setVisible (false );
400
+ drugSusceptibilityField = (DrugSusceptibilityForm ) addField (
401
+ PathogenTestDto .DRUG_SUSCEPTIBILITY ,
402
+ new DrugSusceptibilityForm (
403
+ FieldVisibilityCheckers .withCountry (FacadeProvider .getConfigFacade ().getCountryLocale ()),
404
+ UiFieldAccessCheckers .getDefault (true , FacadeProvider .getConfigFacade ().getCountryLocale ())));
405
+ drugSusceptibilityField .setCaption (null );
406
+ drugSusceptibilityField .setVisible (false );
401
407
402
408
if (FacadeProvider .getConfigFacade ().isConfiguredCountry (CountryHelper .COUNTRY_CODE_LUXEMBOURG )) {
403
409
//tuberculosis-pcr test specification
@@ -640,7 +646,7 @@ protected void addFields() {
640
646
FieldVisibilityCheckers .withDisease (disease ),
641
647
PathogenStrainCallStatus .class );
642
648
643
- updateTuberculosisFieldSpecifications ((PathogenTestType ) testTypeField .getValue (), disease );
649
+ updateDrugSusceptibilityFieldSpecifications ((PathogenTestType ) testTypeField .getValue (), disease );
644
650
}
645
651
});
646
652
diseaseVariantField .addValueChangeListener (e -> {
@@ -664,18 +670,21 @@ protected void addFields() {
664
670
} else {
665
671
testResultField .clear ();
666
672
}
673
+
674
+ updateDrugSusceptibilityFieldSpecifications (testType , (Disease ) diseaseField .getValue ());
675
+
667
676
seroTypeMetCB .setVisible (disease == Disease .INVASIVE_PNEUMOCOCCAL_INFECTION && PathogenTestType .SEROGROUPING .equals (testType ));
668
677
seroTypeTF .setVisible (disease == Disease .INVASIVE_PNEUMOCOCCAL_INFECTION && seroGrpTests .contains (testType ));
669
678
seroGrpSepcCB .setVisible (disease == Disease .INVASIVE_MENINGOCOCCAL_INFECTION && seroGrpTests .contains (testType ));
670
679
// for enabling the test result, finding configured country and disease
671
680
boolean isLuxTbAntiSus = FacadeProvider .getConfigFacade ().isConfiguredCountry (CountryHelper .COUNTRY_CODE_LUXEMBOURG )
672
681
&& Disease .TUBERCULOSIS .equals ((Disease ) diseaseField .getValue ()) && PathogenTestType .ANTIBIOTIC_SUSCEPTIBILITY .equals (testType );
673
682
if (isLuxTbAntiSus ){
674
- testResultField .setEnabled (true );
675
- }else {
676
- testResultField .setEnabled (!seroGrpTests .contains (testType ) && !PathogenTestType .ANTIBIOTIC_SUSCEPTIBILITY .equals (testType ));
683
+ seroGrpTests = new ArrayList <>(seroGrpTests );
684
+ seroGrpTests .add (testType );
677
685
}
678
- drugSusceptibilityField .setVisible (isLuxTbAntiSus || DiseaseHelper .checkDiseaseIsInvasiveBacterialDiseases ((Disease )diseaseField .getValue ()) && PathogenTestType .ANTIBIOTIC_SUSCEPTIBILITY .equals (testType ));
686
+ // for all serogrouping tests and isLuxTbAntiSus the test result field should be disabled
687
+ testResultField .setEnabled (!seroGrpTests .contains (testType ));
679
688
setVisibleClear (
680
689
PathogenTestType .PCR_RT_PCR == testType ,
681
690
PathogenTestDto .CQ_VALUE ,
@@ -685,6 +694,13 @@ protected void addFields() {
685
694
PathogenTestDto .CT_VALUE_S ,
686
695
PathogenTestDto .CT_VALUE_ORF_1 ,
687
696
PathogenTestDto .CT_VALUE_RDRP_S );
697
+ // If the disease is IMI or IPI and the test type is antibiotic susceptibility,
698
+ // then a test result is set to positive and disabled
699
+ if (DiseaseHelper .checkDiseaseIsInvasiveBacterialDiseases ((Disease ) diseaseField .getValue ()) && testType == PathogenTestType .ANTIBIOTIC_SUSCEPTIBILITY ) {
700
+ testResultField .setValue (PathogenTestResultType .POSITIVE );
701
+ testResultField .setEnabled (false );
702
+ }
703
+
688
704
} else {
689
705
setVisibleClear (
690
706
testTypeField .getValue () != null ,
@@ -695,14 +711,11 @@ protected void addFields() {
695
711
testResultField .setEnabled (true );
696
712
}
697
713
698
- // if (FacadeProvider.getConfigFacade().isConfiguredCountry(CountryHelper.COUNTRY_CODE_LUXEMBOURG)) {
699
- updateTuberculosisFieldSpecifications (testType , (Disease ) diseaseField .getValue ());
700
714
// If disease is IMI or IPI and test type is antibiotic susceptibility, then test result is set to positive
701
715
if ((diseaseField .getValue () == Disease .INVASIVE_PNEUMOCOCCAL_INFECTION || diseaseField .getValue () == Disease .INVASIVE_MENINGOCOCCAL_INFECTION )
702
716
&& testType == PathogenTestType .ANTIBIOTIC_SUSCEPTIBILITY ) {
703
717
testResultField .setValue (PathogenTestResultType .POSITIVE );
704
718
}
705
- // }
706
719
});
707
720
lab .addValueChangeListener (event -> {
708
721
if (event .getProperty ().getValue () != null
0 commit comments