3030import java .util .Map ;
3131import java .util .function .Consumer ;
3232
33- import de .symeda .sormas .api .sample .SeroGroupSpecification ;
34- import de .symeda .sormas .api .sample .SerotypingMethod ;
3533import org .apache .commons .collections4 .CollectionUtils ;
3634
3735import com .vaadin .ui .Label ;
6159import de .symeda .sormas .api .sample .PathogenTestType ;
6260import de .symeda .sormas .api .sample .SampleDto ;
6361import de .symeda .sormas .api .sample .SamplePurpose ;
62+ import de .symeda .sormas .api .sample .SeroGroupSpecification ;
63+ import de .symeda .sormas .api .sample .SerotypingMethod ;
6464import de .symeda .sormas .api .utils .fieldaccess .UiFieldAccessCheckers ;
6565import de .symeda .sormas .api .utils .fieldvisibility .FieldVisibilityCheckers ;
6666import de .symeda .sormas .ui .therapy .DrugSusceptibilityForm ;
@@ -96,15 +96,13 @@ public class PathogenTestForm extends AbstractEditForm<PathogenTestDto> {
9696 fluidRowLocs (PathogenTestDto .TYPING_ID , "" ) +
9797 fluidRowLocs (PathogenTestDto .TEST_DATE_TIME , PathogenTestDto .LAB ) +
9898 fluidRowLocs ("" , PathogenTestDto .LAB_DETAILS ) +
99- fluidRowLocs (PathogenTestDto .TEST_RESULT , PathogenTestDto .TEST_RESULT_VERIFIED ) +
100- fluidRowLocs (PathogenTestDto .RIFAMPICIN_RESISTANT , PathogenTestDto .ISONIAZID_RESISTANT ) +
99+ fluidRowLocs (6 , PathogenTestDto .TEST_RESULT , 4 , PathogenTestDto .TEST_RESULT_VERIFIED , 2 , PathogenTestDto . PRELIMINARY ) +
100+ fluidRowLocs (PathogenTestDto .RIFAMPICIN_RESISTANT , PathogenTestDto .ISONIAZID_RESISTANT , "" , "" ) +
101101 fluidRowLocs (PathogenTestDto .TEST_SCALE , "" ) +
102102 fluidRowLocs (PathogenTestDto .STRAIN_CALL_STATUS , "" ) +
103103 fluidRowLocs (PathogenTestDto .SPECIE , "" ) +
104104 fluidRowLocs (PathogenTestDto .PATTERN_PROFILE , "" ) +
105105 fluidRowLocs (PathogenTestDto .DRUG_SUSCEPTIBILITY ) +
106- fluidRowLocs (PathogenTestDto .PRELIMINARY , "" ) +
107- fluidRowLocs (5 ,PathogenTestDto .TEST_RESULT , 4 , PathogenTestDto .TEST_RESULT_VERIFIED , 3 ,PathogenTestDto .PRELIMINARY ) +
108106 fluidRowLocs (4 ,PathogenTestDto .SEROTYPE , 4 ,PathogenTestDto .SEROTYPING_METHOD , 4 ,PathogenTestDto .SERO_TYPING_METHOD_TEXT ) +
109107 fluidRowLocs (6 ,PathogenTestDto .SERO_GROUP_SPECIFICATION , 6 , PathogenTestDto .SERO_GROUP_SPECIFICATION_TEXT ) +
110108 fluidRowLocs (PathogenTestDto .FOUR_FOLD_INCREASE_ANTIBODY_TITER , "" ) +
@@ -140,12 +138,23 @@ public class PathogenTestForm extends AbstractEditForm<PathogenTestDto> {
140138 private Disease disease ;
141139 private TextField typingIdField ;
142140 // List of tests that are used for serogrouping
143- List <PathogenTestType > seroGrpTests = Arrays .asList (PathogenTestType .SEROGROUPING , PathogenTestType .MULTILOCUS_SEQUENCE_TYPING , PathogenTestType .SLIDE_AGGLUTINATION , PathogenTestType .WHOLE_GENOME_SEQUENCING , PathogenTestType .SEQUENCING );
144-
145- public PathogenTestForm (AbstractSampleForm sampleForm , boolean create , int caseSampleCount , boolean isPseudonymized , boolean inJurisdiction , Disease disease ) {
141+ List <PathogenTestType > seroGrpTests = Arrays .asList (
142+ PathogenTestType .SEROGROUPING ,
143+ PathogenTestType .MULTILOCUS_SEQUENCE_TYPING ,
144+ PathogenTestType .SLIDE_AGGLUTINATION ,
145+ PathogenTestType .WHOLE_GENOME_SEQUENCING ,
146+ PathogenTestType .SEQUENCING );
147+
148+ public PathogenTestForm (
149+ AbstractSampleForm sampleForm ,
150+ boolean create ,
151+ int caseSampleCount ,
152+ boolean isPseudonymized ,
153+ boolean inJurisdiction ,
154+ Disease disease ) {
146155 this (create , caseSampleCount , isPseudonymized , inJurisdiction , disease );
147156 this .sampleForm = sampleForm ;
148- this .disease = disease ;
157+ this .disease = disease ;
149158 addFields ();
150159 if (create ) {
151160 hideValidationUntilNextCommit ();
@@ -286,11 +295,10 @@ protected void addFields() {
286295 addField (PathogenTestDto .EXTERNAL_ID );
287296 addField (PathogenTestDto .EXTERNAL_ORDER_ID );
288297 testTypeField = addField (PathogenTestDto .TEST_TYPE , ComboBox .class );
289- TextField seroTypingMethodText = addField (PathogenTestDto .SERO_TYPING_METHOD_TEXT );
290- seroTypingMethodText .setVisible (false );
291- ComboBox testTypeField = addField (PathogenTestDto .TEST_TYPE , ComboBox .class );
292298 testTypeField .setItemCaptionMode (ItemCaptionMode .ID_TOSTRING );
293299 testTypeField .setImmediate (true );
300+ TextField seroTypingMethodText = addField (PathogenTestDto .SERO_TYPING_METHOD_TEXT );
301+ seroTypingMethodText .setVisible (false );
294302 pcrTestSpecification = addField (PathogenTestDto .PCR_TEST_SPECIFICATION , ComboBox .class );
295303 testTypeTextField = addField (PathogenTestDto .TEST_TYPE_TEXT , TextField .class );
296304 FieldHelper .addSoftRequiredStyle (testTypeTextField );
@@ -355,7 +363,7 @@ protected void addFields() {
355363 if (!FacadeProvider .getConfigFacade ().isConfiguredCountry (CountryHelper .COUNTRY_CODE_LUXEMBOURG )) {
356364 testResultField .removeItem (PathogenTestResultType .NOT_APPLICABLE );
357365 }
358- addField (PathogenTestDto .SEROTYPE , TextField .class );
366+ TextField seroTypeTF = addField (PathogenTestDto .SEROTYPE , TextField .class );
359367
360368 NullableOptionGroup rifampicinResistantField = addField (PathogenTestDto .RIFAMPICIN_RESISTANT , NullableOptionGroup .class );
361369 rifampicinResistantField .setVisible (false );
@@ -471,7 +479,6 @@ protected void addFields() {
471479 FieldHelper .setReadOnlyWhen (getFieldGroup (), PathogenTestDto .TEST_RESULT , tuberculosisTestResultReadOnlyDependencies , false , false );
472480 }
473481
474- TextField seroTypeTF = addField (PathogenTestDto .SEROTYPE , TextField .class );
475482 seroTypeTF .setVisible (false );
476483 ComboBox seroTypeMetCB = addField (PathogenTestDto .SEROTYPING_METHOD , ComboBox .class );
477484 seroTypeMetCB .setVisible (false );
@@ -491,8 +498,15 @@ protected void addFields() {
491498 FieldConfiguration .withConversionError (PathogenTestDto .CT_VALUE_ORF_1 , Validations .onlyNumbersAllowed ),
492499 FieldConfiguration .withConversionError (PathogenTestDto .CT_VALUE_RDRP_S , Validations .onlyNumbersAllowed ));
493500
494- setVisibleClear (false , PathogenTestDto .CQ_VALUE , PathogenTestDto .CT_VALUE_E , PathogenTestDto .CT_VALUE_N , PathogenTestDto .CT_VALUE_RDRP
495- , PathogenTestDto .CT_VALUE_S , PathogenTestDto .CT_VALUE_ORF_1 , PathogenTestDto .CT_VALUE_RDRP_S );
501+ setVisibleClear (
502+ false ,
503+ PathogenTestDto .CQ_VALUE ,
504+ PathogenTestDto .CT_VALUE_E ,
505+ PathogenTestDto .CT_VALUE_N ,
506+ PathogenTestDto .CT_VALUE_RDRP ,
507+ PathogenTestDto .CT_VALUE_S ,
508+ PathogenTestDto .CT_VALUE_ORF_1 ,
509+ PathogenTestDto .CT_VALUE_RDRP_S );
496510 NullableOptionGroup testResultVerifiedField = addField (PathogenTestDto .TEST_RESULT_VERIFIED , NullableOptionGroup .class );
497511 testResultVerifiedField .setRequired (true );
498512 addField (PathogenTestDto .PRELIMINARY ).addStyleName (CssStyles .VSPACE_4 );
@@ -564,8 +578,18 @@ protected void addFields() {
564578 }
565579 };
566580 FieldHelper .setVisibleWhen (getFieldGroup (), PathogenTestDto .SEROTYPE , serotypeVisibilityDependencies , true );
567- FieldHelper .setVisibleWhen (getFieldGroup (), PathogenTestDto .SERO_TYPING_METHOD_TEXT , PathogenTestDto .SEROTYPING_METHOD , SerotypingMethod .OTHER , true );
568- FieldHelper .setVisibleWhen (getFieldGroup (), PathogenTestDto .SERO_GROUP_SPECIFICATION_TEXT , PathogenTestDto .SERO_GROUP_SPECIFICATION , SeroGroupSpecification .OTHER , true );
581+ FieldHelper .setVisibleWhen (
582+ getFieldGroup (),
583+ PathogenTestDto .SERO_TYPING_METHOD_TEXT ,
584+ PathogenTestDto .SEROTYPING_METHOD ,
585+ SerotypingMethod .OTHER ,
586+ true );
587+ FieldHelper .setVisibleWhen (
588+ getFieldGroup (),
589+ PathogenTestDto .SERO_GROUP_SPECIFICATION_TEXT ,
590+ PathogenTestDto .SERO_GROUP_SPECIFICATION ,
591+ SeroGroupSpecification .OTHER ,
592+ true );
569593
570594 Consumer <Disease > updateDiseaseVariantField = disease -> {
571595 List <DiseaseVariant > diseaseVariants =
@@ -580,7 +604,7 @@ protected void addFields() {
580604 diseaseField .addValueChangeListener ((ValueChangeListener ) valueChangeEvent -> {
581605 Disease latestDisease = (Disease ) valueChangeEvent .getProperty ().getValue ();
582606 // If the disease changed, test type field should be updated with its respective test types
583- if (latestDisease != disease ) {
607+ if (latestDisease != disease ) {
584608 testTypeField .clear ();
585609 }
586610 disease = latestDisease ;
@@ -609,7 +633,7 @@ protected void addFields() {
609633
610634 testTypeField .addValueChangeListener (e -> {
611635 PathogenTestType testType = (PathogenTestType ) e .getProperty ().getValue ();
612- if (testType !=null ) {
636+ if (testType != null ) {
613637 if (testType == PathogenTestType .IGM_SERUM_ANTIBODY || testType == PathogenTestType .IGG_SERUM_ANTIBODY ) {
614638 fourFoldIncrease .setVisible (true );
615639 fourFoldIncrease .setEnabled (caseSampleCount >= 2 );
@@ -627,10 +651,21 @@ protected void addFields() {
627651 seroTypeTF .setVisible (disease == Disease .INVASIVE_PNEUMOCOCCAL_INFECTION && seroGrpTests .contains (testType ));
628652 seroGrpSepcCB .setVisible (disease == Disease .INVASIVE_MENINGOCOCCAL_INFECTION && seroGrpTests .contains (testType ));
629653 testResultField .setEnabled (!seroGrpTests .contains (testType ));
630- setVisibleClear (PathogenTestType .PCR_RT_PCR == testType , PathogenTestDto .CQ_VALUE , PathogenTestDto .CT_VALUE_E , PathogenTestDto .CT_VALUE_N , PathogenTestDto .CT_VALUE_RDRP
631- , PathogenTestDto .CT_VALUE_S , PathogenTestDto .CT_VALUE_ORF_1 , PathogenTestDto .CT_VALUE_RDRP_S );
632- }else {
633- setVisibleClear (testTypeField .getValue () != null , PathogenTestDto .SEROTYPE , PathogenTestDto .SEROTYPING_METHOD , PathogenTestDto .SERO_GROUP_SPECIFICATION );
654+ setVisibleClear (
655+ PathogenTestType .PCR_RT_PCR == testType ,
656+ PathogenTestDto .CQ_VALUE ,
657+ PathogenTestDto .CT_VALUE_E ,
658+ PathogenTestDto .CT_VALUE_N ,
659+ PathogenTestDto .CT_VALUE_RDRP ,
660+ PathogenTestDto .CT_VALUE_S ,
661+ PathogenTestDto .CT_VALUE_ORF_1 ,
662+ PathogenTestDto .CT_VALUE_RDRP_S );
663+ } else {
664+ setVisibleClear (
665+ testTypeField .getValue () != null ,
666+ PathogenTestDto .SEROTYPE ,
667+ PathogenTestDto .SEROTYPING_METHOD ,
668+ PathogenTestDto .SERO_GROUP_SPECIFICATION );
634669 testResultField .clear ();
635670 testResultField .setEnabled (true );
636671 }
0 commit comments