Skip to content

Commit 7c70253

Browse files
Updating the variants from PathogenTest to Case's form and vice versa.
Fatigue symptom for all countries Enabling the test result field.
1 parent 6b728b2 commit 7c70253

3 files changed

Lines changed: 68 additions & 46 deletions

File tree

sormas-api/src/main/java/de/symeda/sormas/api/symptoms/SymptomsDto.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2524,8 +2524,6 @@ public static SymptomsDto build() {
25242524
CRYPTOSPORIDIOSIS,
25252525
UNDEFINED,
25262526
OTHER })
2527-
@HideForCountriesExcept(countries = {
2528-
CountryHelper.COUNTRY_CODE_SWITZERLAND })
25292527
@SymptomGrouping(SymptomGroup.GENERAL)
25302528
private SymptomState fatigue;
25312529
@Diseases({

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

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
import java.util.function.Consumer;
2929
import java.util.stream.Collectors;
3030

31-
import de.symeda.sormas.api.DiseaseHelper;
32-
import de.symeda.sormas.api.event.EventReferenceDto;
33-
import de.symeda.sormas.api.sample.PathogenTestType;
3431
import org.apache.commons.collections4.CollectionUtils;
3532

3633
import com.vaadin.ui.Label;
@@ -40,6 +37,7 @@
4037

4138
import de.symeda.sormas.api.CountryHelper;
4239
import de.symeda.sormas.api.Disease;
40+
import de.symeda.sormas.api.DiseaseHelper;
4341
import de.symeda.sormas.api.FacadeProvider;
4442
import de.symeda.sormas.api.caze.CaseClassification;
4543
import de.symeda.sormas.api.caze.CaseDataDto;
@@ -54,13 +52,15 @@
5452
import de.symeda.sormas.api.event.EventDto;
5553
import de.symeda.sormas.api.event.EventParticipantDto;
5654
import de.symeda.sormas.api.event.EventParticipantReferenceDto;
55+
import de.symeda.sormas.api.event.EventReferenceDto;
5756
import de.symeda.sormas.api.feature.FeatureType;
5857
import de.symeda.sormas.api.i18n.Captions;
5958
import de.symeda.sormas.api.i18n.I18nProperties;
6059
import de.symeda.sormas.api.i18n.Strings;
6160
import de.symeda.sormas.api.sample.PathogenTestDto;
6261
import de.symeda.sormas.api.sample.PathogenTestFacade;
6362
import de.symeda.sormas.api.sample.PathogenTestResultType;
63+
import de.symeda.sormas.api.sample.PathogenTestType;
6464
import de.symeda.sormas.api.sample.SampleDto;
6565
import de.symeda.sormas.api.sample.SampleReferenceDto;
6666
import de.symeda.sormas.api.user.UserRight;
@@ -127,7 +127,8 @@ public CommitDiscardWrapperComponent<PathogenTestForm> getPathogenTestCreateComp
127127
associatedEventOrCaseOrContactDisease = caseDataDto.getDisease();
128128
}
129129
if (associatedEventOrCaseOrContactDisease == null && sampleDto.getAssociatedEventParticipant() != null) {
130-
EventParticipantDto eventParticipant = FacadeProvider.getEventParticipantFacade().getEventParticipantByUuid(sampleDto.getAssociatedEventParticipant().getUuid());
130+
EventParticipantDto eventParticipant =
131+
FacadeProvider.getEventParticipantFacade().getEventParticipantByUuid(sampleDto.getAssociatedEventParticipant().getUuid());
131132
EventReferenceDto eventDto = eventParticipant.getEvent();
132133
EventDto participantEvent = FacadeProvider.getEventFacade().getEventByUuid(eventDto.getUuid(), false);
133134
associatedEventOrCaseOrContactDisease = participantEvent.getDisease();
@@ -211,11 +212,22 @@ public CommitDiscardWrapperComponent<PathogenTestForm> getPathogenTestEditCompon
211212
final PathogenTestForm form;
212213
if (forHumanSample) {
213214
SampleDto sample = FacadeProvider.getSampleFacade().getSampleByUuid(pathogenTest.getSample().getUuid());
214-
form = new PathogenTestForm(sample, false, 0, pathogenTest.isPseudonymized(), pathogenTest.isInJurisdiction(), pathogenTest.getTestedDisease());
215+
form = new PathogenTestForm(
216+
sample,
217+
false,
218+
0,
219+
pathogenTest.isPseudonymized(),
220+
pathogenTest.isInJurisdiction(),
221+
pathogenTest.getTestedDisease());
215222
} else {
216223
EnvironmentSampleDto environmentSample =
217224
FacadeProvider.getEnvironmentSampleFacade().getByUuid(pathogenTest.getEnvironmentSample().getUuid());
218-
form = new PathogenTestForm(environmentSample, false, pathogenTest.isPseudonymized(), pathogenTest.isInJurisdiction(), pathogenTest.getTestedDisease());
225+
form = new PathogenTestForm(
226+
environmentSample,
227+
false,
228+
pathogenTest.isPseudonymized(),
229+
pathogenTest.isInJurisdiction(),
230+
pathogenTest.getTestedDisease());
219231
}
220232

221233
form.setValue(pathogenTest);
@@ -274,7 +286,7 @@ public static void showCaseUpdateWithNewDiseaseVariantDialog(
274286
existingCaseDto.getDiseaseVariant() == null
275287
? "[" + I18nProperties.getCaption(Captions.caseNoDiseaseVariant) + "]"
276288
: existingCaseDto.getDiseaseVariant().toString(),
277-
diseaseVariant.toString())),
289+
diseaseVariant != null ? diseaseVariant.toString() : "[" + I18nProperties.getCaption(Captions.caseNoDiseaseVariant) + "]")),
278290
I18nProperties.getString(Strings.yes),
279291
I18nProperties.getString(Strings.no),
280292
800,
@@ -317,10 +329,11 @@ public void savePathogenTests(List<PathogenTestDto> pathogenTests, SampleReferen
317329

318330
pathogenTests.forEach(p -> {
319331
p.setSample(sampleRef);
320-
boolean luxTB = FacadeProvider.getConfigFacade().isConfiguredCountry(CountryHelper.COUNTRY_CODE_LUXEMBOURG) && Disease.TUBERCULOSIS == p.getTestedDisease();
332+
boolean luxTB = FacadeProvider.getConfigFacade().isConfiguredCountry(CountryHelper.COUNTRY_CODE_LUXEMBOURG)
333+
&& Disease.TUBERCULOSIS == p.getTestedDisease();
321334
boolean invasiveDisease = DiseaseHelper.checkDiseaseIsInvasiveBacterialDiseases(p.getTestedDisease());
322335
//the susceptibility test is applicable only for LUX TB and all-countries invasive disease
323-
if(PathogenTestType.ANTIBIOTIC_SUSCEPTIBILITY == p.getTestType() && !luxTB && !invasiveDisease) {
336+
if (PathogenTestType.ANTIBIOTIC_SUSCEPTIBILITY == p.getTestType() && !luxTB && !invasiveDisease) {
324337
p.setDrugSusceptibility(null);
325338
}
326339
facade.savePathogenTest(p);
@@ -367,14 +380,21 @@ private void handleAssociatedCase(List<PathogenTestDto> pathogenTests, CaseRefer
367380
.filter(t -> t.getTestResult() == PathogenTestResultType.NEGATIVE && t.getTestResultVerified())
368381
.findFirst();
369382

383+
PathogenTestDto resultedPathogenTest;
370384
if (positiveWithSameDisease.isPresent()) {
371-
showChangeAssociatedSampleResultDialog(positiveWithSameDisease.get(), (accepted) -> {
385+
resultedPathogenTest = positiveWithSameDisease.get();
386+
} else if (negativeWithSameDisease.isPresent()) {
387+
resultedPathogenTest = negativeWithSameDisease.get();
388+
} else {
389+
resultedPathogenTest = null;
390+
}
391+
392+
if (resultedPathogenTest != null) {
393+
showChangeAssociatedSampleResultDialog(resultedPathogenTest, (accepted) -> {
372394
if (accepted) {
373-
checkForDiseaseVariantUpdate(positiveWithSameDisease.get(), caze, suppressNavigateToCase, this::showConfirmCaseDialog);
395+
checkForDiseaseVariantUpdate(resultedPathogenTest, caze, suppressNavigateToCase, this::showConfirmCaseDialog);
374396
}
375397
});
376-
} else if (negativeWithSameDisease.isPresent()) {
377-
showChangeAssociatedSampleResultDialog(negativeWithSameDisease.get(), null);
378398
}
379399

380400
testsByDisease.keySet().stream().filter(disease -> disease != caze.getDisease()).forEach((disease) -> {
@@ -532,9 +552,7 @@ private void checkForDiseaseVariantUpdate(
532552
CaseDataDto caze,
533553
boolean suppressNavigateToCase,
534554
Consumer<CaseDataDto> callback) {
535-
if (test.getTestedDiseaseVariant() != null
536-
&& !DataHelper.equal(test.getTestedDiseaseVariant(), caze.getDiseaseVariant())
537-
&& isNotYetRelatedDiseaseVariant(test)) {
555+
if (!DataHelper.equal(test.getTestedDiseaseVariant(), caze.getDiseaseVariant()) && isNotYetRelatedDiseaseVariant(test)) {
538556
showCaseUpdateWithNewDiseaseVariantDialog(caze, test.getTestedDiseaseVariant(), test.getTestedDiseaseVariantDetails(), yes -> {
539557
if (yes && !suppressNavigateToCase) {
540558
ControllerProvider.getCaseController().navigateToCase(caze.getUuid());

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

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@
2525

2626
import java.time.LocalTime;
2727
import java.time.ZoneId;
28+
import java.util.ArrayList;
2829
import java.util.Arrays;
2930
import java.util.Collection;
31+
import java.util.Collections;
3032
import java.util.Date;
3133
import java.util.HashMap;
3234
import java.util.List;
@@ -38,8 +40,6 @@
3840
import org.slf4j.Logger;
3941
import org.slf4j.LoggerFactory;
4042

41-
import com.google.common.collect.ImmutableList;
42-
import com.google.common.collect.ImmutableMap;
4343
import com.vaadin.ui.Label;
4444
import com.vaadin.v7.data.util.converter.Converter;
4545
import com.vaadin.v7.ui.AbstractSelect.ItemCaptionMode;
@@ -140,33 +140,35 @@ public class PathogenTestForm extends AbstractEditForm<PathogenTestDto> {
140140
//@formatter:on
141141

142142
// 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(
143+
public static final Map<Disease, ArrayList<PathogenTestType>> RESULT_FIELD_DECISION_MAP = Collections.unmodifiableMap(new HashMap<>() {
144+
145+
{
146+
put(
146147
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(
148+
new ArrayList<>(
149+
List.of(
150+
PathogenTestType.SEROGROUPING,
151+
PathogenTestType.MULTILOCUS_SEQUENCE_TYPING,
152+
PathogenTestType.SLIDE_AGGLUTINATION,
153+
PathogenTestType.WHOLE_GENOME_SEQUENCING,
154+
PathogenTestType.SEQUENCING,
155+
PathogenTestType.ANTIBIOTIC_SUSCEPTIBILITY)));
156+
put(
155157
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();
158+
new ArrayList<>(
159+
List.of(
160+
PathogenTestType.SEROGROUPING,
161+
PathogenTestType.MULTILOCUS_SEQUENCE_TYPING,
162+
PathogenTestType.SLIDE_AGGLUTINATION,
163+
PathogenTestType.WHOLE_GENOME_SEQUENCING,
164+
PathogenTestType.SEQUENCING,
165+
PathogenTestType.ANTIBIOTIC_SUSCEPTIBILITY)));
166+
put(Disease.MEASLES, new ArrayList<>(List.of(PathogenTestType.GENOTYPING)));
167+
put(Disease.RESPIRATORY_SYNCYTIAL_VIRUS, new ArrayList<>(List.of(PathogenTestType.SEQUENCING, PathogenTestType.WHOLE_GENOME_SEQUENCING)));
168+
put(Disease.INFLUENZA, new ArrayList<>(List.of(PathogenTestType.ISOLATION)));
169+
put(Disease.CRYPTOSPORIDIOSIS, new ArrayList<>(List.of(PathogenTestType.GENOTYPING)));
170+
}
171+
});
170172

171173
private SampleDto sample;
172174
private EnvironmentSampleDto environmentSample;
@@ -1159,6 +1161,11 @@ protected void addFields() {
11591161
});
11601162
diseaseVariantField.addValueChangeListener(e -> {
11611163
DiseaseVariant diseaseVariant = (DiseaseVariant) e.getProperty().getValue();
1164+
if (diseaseVariant != null) {
1165+
testResultField.setValue(PathogenTestResultType.POSITIVE);
1166+
} else {
1167+
testResultField.clear();
1168+
}
11621169
diseaseVariantDetailsField.setVisible(diseaseVariant != null && diseaseVariant.matchPropertyValue(DiseaseVariant.HAS_DETAILS, true));
11631170
});
11641171

@@ -1168,7 +1175,6 @@ protected void addFields() {
11681175

11691176
if (RESULT_FIELD_DECISION_MAP.containsKey(disease) && RESULT_FIELD_DECISION_MAP.get(disease).contains(testType)) {
11701177
testResultField.setValue(PathogenTestResultType.POSITIVE);
1171-
testResultField.setEnabled(false);
11721178
testResultField.setReadOnly(testResultFieldReadOnly);
11731179
} else {
11741180
testResultField.clear();

0 commit comments

Comments
 (0)