|
28 | 28 | import java.util.function.Consumer; |
29 | 29 | import java.util.stream.Collectors; |
30 | 30 |
|
31 | | -import de.symeda.sormas.api.DiseaseHelper; |
32 | | -import de.symeda.sormas.api.event.EventReferenceDto; |
33 | | -import de.symeda.sormas.api.sample.PathogenTestType; |
34 | 31 | import org.apache.commons.collections4.CollectionUtils; |
35 | 32 |
|
36 | 33 | import com.vaadin.ui.Label; |
|
40 | 37 |
|
41 | 38 | import de.symeda.sormas.api.CountryHelper; |
42 | 39 | import de.symeda.sormas.api.Disease; |
| 40 | +import de.symeda.sormas.api.DiseaseHelper; |
43 | 41 | import de.symeda.sormas.api.FacadeProvider; |
44 | 42 | import de.symeda.sormas.api.caze.CaseClassification; |
45 | 43 | import de.symeda.sormas.api.caze.CaseDataDto; |
|
54 | 52 | import de.symeda.sormas.api.event.EventDto; |
55 | 53 | import de.symeda.sormas.api.event.EventParticipantDto; |
56 | 54 | import de.symeda.sormas.api.event.EventParticipantReferenceDto; |
| 55 | +import de.symeda.sormas.api.event.EventReferenceDto; |
57 | 56 | import de.symeda.sormas.api.feature.FeatureType; |
58 | 57 | import de.symeda.sormas.api.i18n.Captions; |
59 | 58 | import de.symeda.sormas.api.i18n.I18nProperties; |
60 | 59 | import de.symeda.sormas.api.i18n.Strings; |
61 | 60 | import de.symeda.sormas.api.sample.PathogenTestDto; |
62 | 61 | import de.symeda.sormas.api.sample.PathogenTestFacade; |
63 | 62 | import de.symeda.sormas.api.sample.PathogenTestResultType; |
| 63 | +import de.symeda.sormas.api.sample.PathogenTestType; |
64 | 64 | import de.symeda.sormas.api.sample.SampleDto; |
65 | 65 | import de.symeda.sormas.api.sample.SampleReferenceDto; |
66 | 66 | import de.symeda.sormas.api.user.UserRight; |
@@ -127,7 +127,8 @@ public CommitDiscardWrapperComponent<PathogenTestForm> getPathogenTestCreateComp |
127 | 127 | associatedEventOrCaseOrContactDisease = caseDataDto.getDisease(); |
128 | 128 | } |
129 | 129 | 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()); |
131 | 132 | EventReferenceDto eventDto = eventParticipant.getEvent(); |
132 | 133 | EventDto participantEvent = FacadeProvider.getEventFacade().getEventByUuid(eventDto.getUuid(), false); |
133 | 134 | associatedEventOrCaseOrContactDisease = participantEvent.getDisease(); |
@@ -211,11 +212,22 @@ public CommitDiscardWrapperComponent<PathogenTestForm> getPathogenTestEditCompon |
211 | 212 | final PathogenTestForm form; |
212 | 213 | if (forHumanSample) { |
213 | 214 | 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()); |
215 | 222 | } else { |
216 | 223 | EnvironmentSampleDto environmentSample = |
217 | 224 | 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()); |
219 | 231 | } |
220 | 232 |
|
221 | 233 | form.setValue(pathogenTest); |
@@ -274,7 +286,7 @@ public static void showCaseUpdateWithNewDiseaseVariantDialog( |
274 | 286 | existingCaseDto.getDiseaseVariant() == null |
275 | 287 | ? "[" + I18nProperties.getCaption(Captions.caseNoDiseaseVariant) + "]" |
276 | 288 | : existingCaseDto.getDiseaseVariant().toString(), |
277 | | - diseaseVariant.toString())), |
| 289 | + diseaseVariant != null ? diseaseVariant.toString() : "[" + I18nProperties.getCaption(Captions.caseNoDiseaseVariant) + "]")), |
278 | 290 | I18nProperties.getString(Strings.yes), |
279 | 291 | I18nProperties.getString(Strings.no), |
280 | 292 | 800, |
@@ -317,10 +329,11 @@ public void savePathogenTests(List<PathogenTestDto> pathogenTests, SampleReferen |
317 | 329 |
|
318 | 330 | pathogenTests.forEach(p -> { |
319 | 331 | 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(); |
321 | 334 | boolean invasiveDisease = DiseaseHelper.checkDiseaseIsInvasiveBacterialDiseases(p.getTestedDisease()); |
322 | 335 | //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) { |
324 | 337 | p.setDrugSusceptibility(null); |
325 | 338 | } |
326 | 339 | facade.savePathogenTest(p); |
@@ -367,14 +380,21 @@ private void handleAssociatedCase(List<PathogenTestDto> pathogenTests, CaseRefer |
367 | 380 | .filter(t -> t.getTestResult() == PathogenTestResultType.NEGATIVE && t.getTestResultVerified()) |
368 | 381 | .findFirst(); |
369 | 382 |
|
| 383 | + PathogenTestDto resultedPathogenTest; |
370 | 384 | 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) -> { |
372 | 394 | if (accepted) { |
373 | | - checkForDiseaseVariantUpdate(positiveWithSameDisease.get(), caze, suppressNavigateToCase, this::showConfirmCaseDialog); |
| 395 | + checkForDiseaseVariantUpdate(resultedPathogenTest, caze, suppressNavigateToCase, this::showConfirmCaseDialog); |
374 | 396 | } |
375 | 397 | }); |
376 | | - } else if (negativeWithSameDisease.isPresent()) { |
377 | | - showChangeAssociatedSampleResultDialog(negativeWithSameDisease.get(), null); |
378 | 398 | } |
379 | 399 |
|
380 | 400 | testsByDisease.keySet().stream().filter(disease -> disease != caze.getDisease()).forEach((disease) -> { |
@@ -532,9 +552,7 @@ private void checkForDiseaseVariantUpdate( |
532 | 552 | CaseDataDto caze, |
533 | 553 | boolean suppressNavigateToCase, |
534 | 554 | 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)) { |
538 | 556 | showCaseUpdateWithNewDiseaseVariantDialog(caze, test.getTestedDiseaseVariant(), test.getTestedDiseaseVariantDetails(), yes -> { |
539 | 557 | if (yes && !suppressNavigateToCase) { |
540 | 558 | ControllerProvider.getCaseController().navigateToCase(caze.getUuid()); |
|
0 commit comments