99import com .vaadin .v7 .ui .CheckBox ;
1010import com .vaadin .v7 .ui .ComboBox ;
1111import com .vaadin .v7 .ui .TextArea ;
12+ import com .vaadin .v7 .ui .TextField ;
1213
1314import de .symeda .sormas .api .Disease ;
1415import de .symeda .sormas .api .i18n .Captions ;
@@ -32,6 +33,7 @@ public class SampleCreateForm extends AbstractSampleForm {
3233 + fluidRowLocs (Captions .sampleIncludeTestOnCreation )
3334 + fluidRowLocs (PathogenTestDto .TEST_RESULT , PathogenTestDto .TEST_RESULT_VERIFIED )
3435 + fluidRowLocs (PathogenTestDto .TEST_TYPE , PathogenTestDto .TESTED_DISEASE )
36+ + fluidRowLocs (6 , PathogenTestDto .CQ_VALUE )
3537 + fluidRowLocs (PathogenTestDto .TEST_DATE_TIME , PathogenTestDto .TEST_RESULT_TEXT );
3638
3739 public SampleCreateForm () {
@@ -49,6 +51,7 @@ protected void addFields() {
4951 NullableOptionGroup testVerifiedField = addCustomField (PathogenTestDto .TEST_RESULT_VERIFIED , Boolean .class , NullableOptionGroup .class );
5052 ComboBox testTypeField = addCustomField (PathogenTestDto .TEST_TYPE , PathogenTestType .class , ComboBox .class );
5153 ComboBox testDiseaseField = addCustomField (PathogenTestDto .TESTED_DISEASE , Disease .class , ComboBox .class );
54+ TextField cqValueField = addCustomField (PathogenTestDto .CQ_VALUE , Float .class , TextField .class );
5255 DateTimeField testDateField = addCustomField (
5356 PathogenTestDto .TEST_DATE_TIME ,
5457 I18nProperties .getPrefixCaption (PathogenTestDto .I18N_PREFIX , PathogenTestDto .TEST_DATE_TIME ),
@@ -62,6 +65,8 @@ protected void addFields() {
6265
6366 setVisibilities ();
6467
68+ cqValueField .setVisible (false );
69+
6570 FieldHelper .setVisibleWhen (
6671 includeTestField ,
6772 Arrays .asList (pathogenTestResultField , testVerifiedField , testTypeField , testDiseaseField , testDateField , testDetailsField ),
@@ -90,6 +95,18 @@ protected void addFields() {
9095 false ,
9196 I18nProperties .getValidationError (Validations .afterDate , testDateField .getCaption (), sampleDateField .getCaption ())));
9297
98+ pathogenTestResultField .addValueChangeListener (e -> {
99+ PathogenTestResultType testResult = (PathogenTestResultType ) e .getProperty ().getValue ();
100+ PathogenTestType testType = (PathogenTestType ) testTypeField .getValue ();
101+ showCqValueField (cqValueField , testType , testResult );
102+ });
103+
104+ testTypeField .addValueChangeListener (e -> {
105+ PathogenTestType testType = (PathogenTestType ) e .getProperty ().getValue ();
106+ PathogenTestResultType testResult = (PathogenTestResultType ) pathogenTestResultField .getValue ();
107+ showCqValueField (cqValueField , testType , testResult );
108+ });
109+
93110 includeTestField .addValueChangeListener (e -> {
94111 final Boolean includeTest = (Boolean ) e .getProperty ().getValue ();
95112 if (includeTest ) {
@@ -109,6 +126,16 @@ protected void addFields() {
109126 });
110127 }
111128
129+ private void showCqValueField (TextField cqValueField , PathogenTestType testType , PathogenTestResultType testResult ) {
130+ if ((testType == PathogenTestType .PCR_RT_PCR && testResult == PathogenTestResultType .POSITIVE )
131+ || testType == PathogenTestType .CQ_VALUE_DETECTION ) {
132+ cqValueField .setVisible (true );
133+ } else {
134+ cqValueField .setVisible (false );
135+ cqValueField .clear ();
136+ }
137+ }
138+
112139 @ Override
113140 protected String createHtmlLayout () {
114141 return HTML_LAYOUT ;
@@ -120,13 +147,15 @@ private void setPathogenTestFieldCaptions() {
120147 final NullableOptionGroup testResultVerified = (NullableOptionGroup ) getField (PathogenTestDto .TEST_RESULT_VERIFIED );
121148 final ComboBox testTypeField = (ComboBox ) getField (PathogenTestDto .TEST_TYPE );
122149 final ComboBox testedDiseaseField = (ComboBox ) getField (PathogenTestDto .TESTED_DISEASE );
150+ final TextField cqValueField = (TextField ) getField (PathogenTestDto .CQ_VALUE );
123151 final DateTimeField testDateField = (DateTimeField ) getField (PathogenTestDto .TEST_DATE_TIME );
124152 final TextArea testTextField = (TextArea ) getField (PathogenTestDto .TEST_RESULT_TEXT );
125153
126154 testResult .setCaption (getPrefixCaption (PathogenTestDto .I18N_PREFIX , PathogenTestDto .TEST_RESULT ));
127155 testResultVerified .setCaption (getPrefixCaption (PathogenTestDto .I18N_PREFIX , PathogenTestDto .TEST_RESULT_VERIFIED ));
128156 testTypeField .setCaption (getPrefixCaption (PathogenTestDto .I18N_PREFIX , PathogenTestDto .TEST_TYPE ));
129157 testedDiseaseField .setCaption (getPrefixCaption (PathogenTestDto .I18N_PREFIX , PathogenTestDto .TESTED_DISEASE ));
158+ cqValueField .setCaption (getPrefixCaption (PathogenTestDto .I18N_PREFIX , PathogenTestDto .CQ_VALUE ));
130159 testDateField .setCaption (getPrefixCaption (PathogenTestDto .I18N_PREFIX , PathogenTestDto .TEST_DATE_TIME ));
131160 testTextField .setCaption (getPrefixCaption (PathogenTestDto .I18N_PREFIX , PathogenTestDto .TEST_RESULT_TEXT ));
132161 }
0 commit comments