Skip to content

Commit 22ed5d3

Browse files
authored
Merge pull request #13124 from SORMAS-Foundation/bugfix-13120-error-when-trying-to-create-a-new-environment-sample
#13120 - Error when trying to create a new environment sample
2 parents a3e815f + 7e131c6 commit 22ed5d3

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)