@@ -139,6 +139,35 @@ public class PathogenTestForm extends AbstractEditForm<PathogenTestDto> {
139139 fluidRowLocs (PathogenTestDto .OTHER_DELETION_REASON );
140140 //@formatter:on
141141
142+ // map to decide the result type field value and enable/disable state
143+ public static final ImmutableMap <Disease , ImmutableList <PathogenTestType >> RESULT_FIELD_DECISION_MAP =
144+ ImmutableMap .<Disease , ImmutableList <PathogenTestType >> builder ()
145+ .put (
146+ Disease .INVASIVE_MENINGOCOCCAL_INFECTION ,
147+ ImmutableList .of (
148+ PathogenTestType .SEROGROUPING ,
149+ PathogenTestType .MULTILOCUS_SEQUENCE_TYPING ,
150+ PathogenTestType .SLIDE_AGGLUTINATION ,
151+ PathogenTestType .WHOLE_GENOME_SEQUENCING ,
152+ PathogenTestType .SEQUENCING ,
153+ PathogenTestType .ANTIBIOTIC_SUSCEPTIBILITY ))
154+ .put (
155+ Disease .INVASIVE_PNEUMOCOCCAL_INFECTION ,
156+ ImmutableList .of (
157+ PathogenTestType .SEROGROUPING ,
158+ PathogenTestType .MULTILOCUS_SEQUENCE_TYPING ,
159+ PathogenTestType .SLIDE_AGGLUTINATION ,
160+ PathogenTestType .WHOLE_GENOME_SEQUENCING ,
161+ PathogenTestType .SEQUENCING ,
162+ PathogenTestType .ANTIBIOTIC_SUSCEPTIBILITY ))
163+ .put (Disease .MEASLES , ImmutableList .of (PathogenTestType .GENOTYPING ))
164+ .put (
165+ Disease .RESPIRATORY_SYNCYTIAL_VIRUS ,
166+ ImmutableList .of (PathogenTestType .SEQUENCING , PathogenTestType .WHOLE_GENOME_SEQUENCING , PathogenTestType .PCR_RT_PCR ))
167+ .put (Disease .INFLUENZA , ImmutableList .of (PathogenTestType .ISOLATION , PathogenTestType .PCR_RT_PCR ))
168+ .put (Disease .CRYPTOSPORIDIOSIS , ImmutableList .of (PathogenTestType .GENOTYPING ))
169+ .build ();
170+
142171 private SampleDto sample ;
143172 private EnvironmentSampleDto environmentSample ;
144173 private AbstractSampleForm sampleForm ;
@@ -1099,16 +1128,22 @@ protected void addFields() {
10991128 FieldHelper
11001129 .setVisibleWhen (getFieldGroup (), PathogenTestDto .GENOTYPE_RESULT_TEXT , PathogenTestDto .GENOTYPE_RESULT , GenoTypeResult .OTHER , true );
11011130
1102- //RSV subtype specification
1103- Map <Object , List <Object >> rsvSubTypeDependencies = new HashMap <>() {
1131+ //disease variant specifications for RSV and Influenza
1132+ Map <Object , List <Object >> diseaseVariantDependencies = new HashMap <>() {
11041133
11051134 {
1106- put (PathogenTestDto .TESTED_DISEASE , Arrays .asList (Disease .RESPIRATORY_SYNCYTIAL_VIRUS ));
1107- put (PathogenTestDto .TEST_TYPE , Arrays .asList (PathogenTestType .SEQUENCING , PathogenTestType .WHOLE_GENOME_SEQUENCING ));
1108- put (PathogenTestDto .TEST_RESULT , Arrays .asList (PathogenTestResultType .POSITIVE ));
1135+ put (PathogenTestDto .TESTED_DISEASE , Arrays .asList (Disease .RESPIRATORY_SYNCYTIAL_VIRUS , Disease .INFLUENZA ));
1136+ put (
1137+ PathogenTestDto .TEST_TYPE ,
1138+ Arrays .asList (
1139+ PathogenTestType .SEQUENCING ,
1140+ PathogenTestType .WHOLE_GENOME_SEQUENCING ,
1141+ PathogenTestType .PCR_RT_PCR ,
1142+ PathogenTestType .ISOLATION ,
1143+ PathogenTestType .OTHER ));
11091144 }
11101145 };
1111- FieldHelper .setVisibleWhen (getFieldGroup (), PathogenTestDto .TESTED_DISEASE_VARIANT , rsvSubTypeDependencies , true );
1146+ FieldHelper .setVisibleWhen (getFieldGroup (), PathogenTestDto .TESTED_DISEASE_VARIANT , diseaseVariantDependencies , true );
11121147
11131148 Consumer <Disease > updateDiseaseVariantField = disease -> {
11141149 List <DiseaseVariant > diseaseVariants =
@@ -1150,36 +1185,11 @@ protected void addFields() {
11501185 diseaseVariantDetailsField .setVisible (diseaseVariant != null && diseaseVariant .matchPropertyValue (DiseaseVariant .HAS_DETAILS , true ));
11511186 });
11521187
1153- // map to decide the result type field value and enable/disable state
1154- ImmutableMap <Disease , ImmutableList <PathogenTestType >> resultFieldDecisionMap = ImmutableMap .of (
1155- Disease .INVASIVE_MENINGOCOCCAL_INFECTION ,
1156- ImmutableList .of (
1157- PathogenTestType .SEROGROUPING ,
1158- PathogenTestType .MULTILOCUS_SEQUENCE_TYPING ,
1159- PathogenTestType .SLIDE_AGGLUTINATION ,
1160- PathogenTestType .WHOLE_GENOME_SEQUENCING ,
1161- PathogenTestType .SEQUENCING ,
1162- PathogenTestType .ANTIBIOTIC_SUSCEPTIBILITY ),
1163- Disease .INVASIVE_PNEUMOCOCCAL_INFECTION ,
1164- ImmutableList .of (
1165- PathogenTestType .SEROGROUPING ,
1166- PathogenTestType .MULTILOCUS_SEQUENCE_TYPING ,
1167- PathogenTestType .SLIDE_AGGLUTINATION ,
1168- PathogenTestType .WHOLE_GENOME_SEQUENCING ,
1169- PathogenTestType .SEQUENCING ,
1170- PathogenTestType .ANTIBIOTIC_SUSCEPTIBILITY ),
1171- Disease .MEASLES ,
1172- ImmutableList .of (PathogenTestType .GENOTYPING ),
1173- Disease .RESPIRATORY_SYNCYTIAL_VIRUS ,
1174- ImmutableList .of (PathogenTestType .SEQUENCING , PathogenTestType .WHOLE_GENOME_SEQUENCING ),
1175- Disease .CRYPTOSPORIDIOSIS ,
1176- ImmutableList .of (PathogenTestType .GENOTYPING ));
1177-
11781188 BiConsumer <Disease , PathogenTestType > resultField = (disease , testType ) -> {
11791189 if (testResultField .isReadOnly ()) {
11801190 return ;
11811191 }
1182- if (resultFieldDecisionMap .containsKey (disease ) && resultFieldDecisionMap .get (disease ).contains (testType )) {
1192+ if (RESULT_FIELD_DECISION_MAP .containsKey (disease ) && RESULT_FIELD_DECISION_MAP .get (disease ).contains (testType )) {
11831193 testResultField .setValue (PathogenTestResultType .POSITIVE );
11841194 testResultField .setEnabled (false );
11851195 } else {
0 commit comments