Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit 6c81c79

Browse files
SORMAS-Foundation#4125 - Enable CQ/CT value field in sample creation window (SORMAS-Foundation#4155)
* SORMAS-Foundation#4125 - Enable CQ/CT value field in sample creation window * SORMAS-Foundation#4125 - Extracted the sequence which sets up the visibility of CQ field into its own method * SORMAS-Foundation#4125 - Save CQ value
1 parent 620bddc commit 6c81c79

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

sormas-ui/src/main/java/de/symeda/sormas/ui/samples/SampleController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ private void saveSample(SampleCreateForm createForm) {
174174
pathogenTest.setTestedDisease((Disease) (createForm.getField(PathogenTestDto.TESTED_DISEASE)).getValue());
175175
pathogenTest.setTestDateTime((Date) (createForm.getField(PathogenTestDto.TEST_DATE_TIME)).getValue());
176176
pathogenTest.setTestResultText((String) (createForm.getField(PathogenTestDto.TEST_RESULT_TEXT)).getValue());
177+
pathogenTest.setCqValue(Float.parseFloat((String) createForm.getField(PathogenTestDto.CQ_VALUE).getValue()));
177178
FacadeProvider.getSampleFacade().saveSample(newSample);
178179
FacadeProvider.getPathogenTestFacade().savePathogenTest(pathogenTest);
179180
final EventParticipantReferenceDto eventParticipantRef = newSample.getAssociatedEventParticipant();

sormas-ui/src/main/java/de/symeda/sormas/ui/samples/SampleCreateForm.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.vaadin.v7.ui.CheckBox;
1010
import com.vaadin.v7.ui.ComboBox;
1111
import com.vaadin.v7.ui.TextArea;
12+
import com.vaadin.v7.ui.TextField;
1213

1314
import de.symeda.sormas.api.Disease;
1415
import 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

Comments
 (0)