30
30
import java .util .Map ;
31
31
import java .util .function .Consumer ;
32
32
33
- import de .symeda .sormas .api .sample .SeroGroupSpecification ;
34
- import de .symeda .sormas .api .sample .SerotypingMethod ;
35
33
import org .apache .commons .collections4 .CollectionUtils ;
36
34
37
35
import com .vaadin .ui .Label ;
61
59
import de .symeda .sormas .api .sample .PathogenTestType ;
62
60
import de .symeda .sormas .api .sample .SampleDto ;
63
61
import de .symeda .sormas .api .sample .SamplePurpose ;
62
+ import de .symeda .sormas .api .sample .SeroGroupSpecification ;
63
+ import de .symeda .sormas .api .sample .SerotypingMethod ;
64
64
import de .symeda .sormas .api .utils .fieldaccess .UiFieldAccessCheckers ;
65
65
import de .symeda .sormas .api .utils .fieldvisibility .FieldVisibilityCheckers ;
66
66
import de .symeda .sormas .ui .therapy .DrugSusceptibilityForm ;
@@ -96,15 +96,13 @@ public class PathogenTestForm extends AbstractEditForm<PathogenTestDto> {
96
96
fluidRowLocs (PathogenTestDto .TYPING_ID , "" ) +
97
97
fluidRowLocs (PathogenTestDto .TEST_DATE_TIME , PathogenTestDto .LAB ) +
98
98
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 , "" , "" ) +
101
101
fluidRowLocs (PathogenTestDto .TEST_SCALE , "" ) +
102
102
fluidRowLocs (PathogenTestDto .STRAIN_CALL_STATUS , "" ) +
103
103
fluidRowLocs (PathogenTestDto .SPECIE , "" ) +
104
104
fluidRowLocs (PathogenTestDto .PATTERN_PROFILE , "" ) +
105
105
fluidRowLocs (PathogenTestDto .DRUG_SUSCEPTIBILITY ) +
106
- fluidRowLocs (PathogenTestDto .PRELIMINARY , "" ) +
107
- fluidRowLocs (5 ,PathogenTestDto .TEST_RESULT , 4 , PathogenTestDto .TEST_RESULT_VERIFIED , 3 ,PathogenTestDto .PRELIMINARY ) +
108
106
fluidRowLocs (4 ,PathogenTestDto .SEROTYPE , 4 ,PathogenTestDto .SEROTYPING_METHOD , 4 ,PathogenTestDto .SERO_TYPING_METHOD_TEXT ) +
109
107
fluidRowLocs (6 ,PathogenTestDto .SERO_GROUP_SPECIFICATION , 6 , PathogenTestDto .SERO_GROUP_SPECIFICATION_TEXT ) +
110
108
fluidRowLocs (PathogenTestDto .FOUR_FOLD_INCREASE_ANTIBODY_TITER , "" ) +
@@ -140,12 +138,23 @@ public class PathogenTestForm extends AbstractEditForm<PathogenTestDto> {
140
138
private Disease disease ;
141
139
private TextField typingIdField ;
142
140
// 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 ) {
146
155
this (create , caseSampleCount , isPseudonymized , inJurisdiction , disease );
147
156
this .sampleForm = sampleForm ;
148
- this .disease = disease ;
157
+ this .disease = disease ;
149
158
addFields ();
150
159
if (create ) {
151
160
hideValidationUntilNextCommit ();
@@ -286,11 +295,10 @@ protected void addFields() {
286
295
addField (PathogenTestDto .EXTERNAL_ID );
287
296
addField (PathogenTestDto .EXTERNAL_ORDER_ID );
288
297
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 );
292
298
testTypeField .setItemCaptionMode (ItemCaptionMode .ID_TOSTRING );
293
299
testTypeField .setImmediate (true );
300
+ TextField seroTypingMethodText = addField (PathogenTestDto .SERO_TYPING_METHOD_TEXT );
301
+ seroTypingMethodText .setVisible (false );
294
302
pcrTestSpecification = addField (PathogenTestDto .PCR_TEST_SPECIFICATION , ComboBox .class );
295
303
testTypeTextField = addField (PathogenTestDto .TEST_TYPE_TEXT , TextField .class );
296
304
FieldHelper .addSoftRequiredStyle (testTypeTextField );
@@ -355,7 +363,7 @@ protected void addFields() {
355
363
if (!FacadeProvider .getConfigFacade ().isConfiguredCountry (CountryHelper .COUNTRY_CODE_LUXEMBOURG )) {
356
364
testResultField .removeItem (PathogenTestResultType .NOT_APPLICABLE );
357
365
}
358
- addField (PathogenTestDto .SEROTYPE , TextField .class );
366
+ TextField seroTypeTF = addField (PathogenTestDto .SEROTYPE , TextField .class );
359
367
360
368
NullableOptionGroup rifampicinResistantField = addField (PathogenTestDto .RIFAMPICIN_RESISTANT , NullableOptionGroup .class );
361
369
rifampicinResistantField .setVisible (false );
@@ -471,7 +479,6 @@ protected void addFields() {
471
479
FieldHelper .setReadOnlyWhen (getFieldGroup (), PathogenTestDto .TEST_RESULT , tuberculosisTestResultReadOnlyDependencies , false , false );
472
480
}
473
481
474
- TextField seroTypeTF = addField (PathogenTestDto .SEROTYPE , TextField .class );
475
482
seroTypeTF .setVisible (false );
476
483
ComboBox seroTypeMetCB = addField (PathogenTestDto .SEROTYPING_METHOD , ComboBox .class );
477
484
seroTypeMetCB .setVisible (false );
@@ -491,8 +498,15 @@ protected void addFields() {
491
498
FieldConfiguration .withConversionError (PathogenTestDto .CT_VALUE_ORF_1 , Validations .onlyNumbersAllowed ),
492
499
FieldConfiguration .withConversionError (PathogenTestDto .CT_VALUE_RDRP_S , Validations .onlyNumbersAllowed ));
493
500
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 );
496
510
NullableOptionGroup testResultVerifiedField = addField (PathogenTestDto .TEST_RESULT_VERIFIED , NullableOptionGroup .class );
497
511
testResultVerifiedField .setRequired (true );
498
512
addField (PathogenTestDto .PRELIMINARY ).addStyleName (CssStyles .VSPACE_4 );
@@ -564,8 +578,18 @@ protected void addFields() {
564
578
}
565
579
};
566
580
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 );
569
593
570
594
Consumer <Disease > updateDiseaseVariantField = disease -> {
571
595
List <DiseaseVariant > diseaseVariants =
@@ -580,7 +604,7 @@ protected void addFields() {
580
604
diseaseField .addValueChangeListener ((ValueChangeListener ) valueChangeEvent -> {
581
605
Disease latestDisease = (Disease ) valueChangeEvent .getProperty ().getValue ();
582
606
// If the disease changed, test type field should be updated with its respective test types
583
- if (latestDisease != disease ) {
607
+ if (latestDisease != disease ) {
584
608
testTypeField .clear ();
585
609
}
586
610
disease = latestDisease ;
@@ -609,7 +633,7 @@ protected void addFields() {
609
633
610
634
testTypeField .addValueChangeListener (e -> {
611
635
PathogenTestType testType = (PathogenTestType ) e .getProperty ().getValue ();
612
- if (testType !=null ) {
636
+ if (testType != null ) {
613
637
if (testType == PathogenTestType .IGM_SERUM_ANTIBODY || testType == PathogenTestType .IGG_SERUM_ANTIBODY ) {
614
638
fourFoldIncrease .setVisible (true );
615
639
fourFoldIncrease .setEnabled (caseSampleCount >= 2 );
@@ -627,10 +651,21 @@ protected void addFields() {
627
651
seroTypeTF .setVisible (disease == Disease .INVASIVE_PNEUMOCOCCAL_INFECTION && seroGrpTests .contains (testType ));
628
652
seroGrpSepcCB .setVisible (disease == Disease .INVASIVE_MENINGOCOCCAL_INFECTION && seroGrpTests .contains (testType ));
629
653
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 );
634
669
testResultField .clear ();
635
670
testResultField .setEnabled (true );
636
671
}
0 commit comments