@@ -210,13 +210,19 @@ public PathogenTestForm(boolean create, int caseSampleCount, boolean isPseudonym
210210 setWidth (900 , Unit .PIXELS );
211211 }
212212
213- private static void setCqValueVisibility (TextField cqValueField , PathogenTestType testType , PathogenTestResultType testResultType ) {
214- if (((testType == PathogenTestType .PCR_RT_PCR && testResultType == PathogenTestResultType .POSITIVE ))
215- || testType == PathogenTestType .CQ_VALUE_DETECTION ) {
216- cqValueField .setVisible (true );
217- } else {
218- cqValueField .setVisible (false );
219- cqValueField .clear ();
213+ private static void setCqValueVisibility (
214+ ComboBox diseaseField ,
215+ TextField cqValueField ,
216+ PathogenTestType testType ,
217+ PathogenTestResultType testResultType ) {
218+ if (!List .of (Disease .TUBERCULOSIS ).contains ((Disease ) diseaseField .getValue ())) {
219+ if (((testType == PathogenTestType .PCR_RT_PCR && testResultType == PathogenTestResultType .POSITIVE ))
220+ || testType == PathogenTestType .CQ_VALUE_DETECTION ) {
221+ cqValueField .setVisible (true );
222+ } else {
223+ cqValueField .setVisible (false );
224+ cqValueField .clear ();
225+ }
220226 }
221227 }
222228
@@ -260,6 +266,16 @@ private void updateDrugSusceptibilityFieldSpecifications(PathogenTestType testTy
260266 testResultField .setReadOnly (false );
261267 testResultField .setValue (null );
262268 }
269+ } else if (List .of (Disease .INVASIVE_MENINGOCOCCAL_INFECTION ).contains (disease )) {
270+ if (Arrays .asList (PathogenTestType .ANTIBIOTIC_SUSCEPTIBILITY ).contains (testType )) {
271+ if (wasReadOnly ) {
272+ testResultField .setReadOnly (false );
273+ }
274+ testResultField .setValue (PathogenTestResultType .NOT_APPLICABLE );
275+ if (wasReadOnly ) {
276+ testResultField .setReadOnly (true );
277+ }
278+ }
263279 }
264280
265281 if (List .of (PathogenTestType .ANTIBIOTIC_SUSCEPTIBILITY ).contains (testType )) {
@@ -496,9 +512,6 @@ protected void addFields() {
496512 }
497513 };
498514 FieldHelper .setVisibleWhen (getFieldGroup (), PathogenTestDto .RIFAMPICIN_RESISTANT , tuberculosisPcrDependencies , true );
499- //FieldHelper.setRequiredWhen(getFieldGroup(), PathogenTestDto.RIFAMPICIN_RESISTANT, tuberculosisPcrDependencies);
500- FieldHelper .setVisibleWhen (getFieldGroup (), PathogenTestDto .ISONIAZID_RESISTANT , tuberculosisPcrDependencies , true );
501- //FieldHelper.setRequiredWhen(getFieldGroup(), PathogenTestDto.ISONIAZID_RESISTANT, tuberculosisPcrDependencies);
502515
503516 //tuberculosis-microscopy test specification
504517 Map <Object , List <Object >> tuberculosisMicroscopyDependencies = new HashMap <>() {
@@ -1185,17 +1198,30 @@ protected void addFields() {
11851198 fourFoldIncrease .setVisible (false );
11861199 fourFoldIncrease .setEnabled (false );
11871200 }
1201+
11881202 updateDrugSusceptibilityFieldSpecifications (testType , (Disease ) diseaseField .getValue ());
11891203
1190- setVisibleClear (
1191- PathogenTestType .PCR_RT_PCR == testType ,
1192- PathogenTestDto .CQ_VALUE ,
1193- PathogenTestDto .CT_VALUE_E ,
1194- PathogenTestDto .CT_VALUE_N ,
1195- PathogenTestDto .CT_VALUE_RDRP ,
1196- PathogenTestDto .CT_VALUE_S ,
1197- PathogenTestDto .CT_VALUE_ORF_1 ,
1198- PathogenTestDto .CT_VALUE_RDRP_S );
1204+ if (!List .of (Disease .TUBERCULOSIS ).contains ((Disease ) diseaseField .getValue ())) {
1205+ setVisibleClear (
1206+ PathogenTestType .PCR_RT_PCR == testType ,
1207+ PathogenTestDto .CQ_VALUE ,
1208+ PathogenTestDto .CT_VALUE_E ,
1209+ PathogenTestDto .CT_VALUE_N ,
1210+ PathogenTestDto .CT_VALUE_RDRP ,
1211+ PathogenTestDto .CT_VALUE_S ,
1212+ PathogenTestDto .CT_VALUE_ORF_1 ,
1213+ PathogenTestDto .CT_VALUE_RDRP_S );
1214+ } else {
1215+ setVisibleClear (
1216+ false ,
1217+ PathogenTestDto .CQ_VALUE ,
1218+ PathogenTestDto .CT_VALUE_E ,
1219+ PathogenTestDto .CT_VALUE_N ,
1220+ PathogenTestDto .CT_VALUE_RDRP ,
1221+ PathogenTestDto .CT_VALUE_S ,
1222+ PathogenTestDto .CT_VALUE_ORF_1 ,
1223+ PathogenTestDto .CT_VALUE_RDRP_S );
1224+ }
11991225 // Show tube IGRA fields only for IGRA tests and Luxembourg
12001226 setVisibleClear (
12011227 PathogenTestType .IGRA == testType && FacadeProvider .getConfigFacade ().isConfiguredCountry (CountryHelper .COUNTRY_CODE_LUXEMBOURG ),
@@ -1244,12 +1270,12 @@ protected void addFields() {
12441270
12451271 testTypeField .addValueChangeListener (e -> {
12461272 PathogenTestType testType = (PathogenTestType ) e .getProperty ().getValue ();
1247- setCqValueVisibility (cqValueField , testType , (PathogenTestResultType ) testResultField .getValue ());
1273+ setCqValueVisibility (diseaseField , cqValueField , testType , (PathogenTestResultType ) testResultField .getValue ());
12481274 });
12491275
12501276 testResultField .addValueChangeListener (e -> {
12511277 PathogenTestResultType testResult = (PathogenTestResultType ) e .getProperty ().getValue ();
1252- setCqValueVisibility (cqValueField , (PathogenTestType ) testTypeField .getValue (), testResult );
1278+ setCqValueVisibility (diseaseField , cqValueField , (PathogenTestType ) testTypeField .getValue (), testResult );
12531279 });
12541280
12551281 if (SamplePurpose .INTERNAL .equals (getSamplePurpose ())) { // this only works for already saved samples
0 commit comments