Skip to content

Commit 7e131c6

Browse files
committed
#13120 - fetch earliest pathogen test date only for existing samples not for new sample
1 parent a3e815f commit 7e131c6

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

sormas-ui/src/main/java/de/symeda/sormas/ui/samples/environmentsample/EnvironmentSampleEditForm.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,14 @@ private void addValidators() {
369369
}
370370

371371
private Date getEarliestPathogenTestDate() {
372-
List<PathogenTestDto> pathogenTests = FacadeProvider.getPathogenTestFacade().getAllByEnvironmentSample(getValue().toReference());
373-
if (pathogenTests.isEmpty()) {
372+
if (!isCreate) {
373+
List<PathogenTestDto> pathogenTests = FacadeProvider.getPathogenTestFacade().getAllByEnvironmentSample(getValue().toReference());
374+
if (pathogenTests.isEmpty()) {
375+
return null;
376+
}
377+
return pathogenTests.stream().map(PathogenTestDto::getTestDateTime).filter(Objects::nonNull).min(Date::compareTo).orElseGet(() -> null);
378+
} else {
374379
return null;
375380
}
376-
return pathogenTests.stream().map(PathogenTestDto::getTestDateTime).filter(Objects::nonNull).min(Date::compareTo).orElseGet(() -> null);
377381
}
378382
}

0 commit comments

Comments
 (0)