Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ protected void postBuildCase(CaseDataDto caseDto, ExternalMessageDto externalMes
* The external message containing diagnostic data.
*/
protected void postBuildCaseData(CaseDataDto caseDto, ExternalMessageDto externalMessageDto) {

caseDto.setCaseClassification(
externalMessageDto.getCaseClassification() != null ? externalMessageDto.getCaseClassification() : caseDto.getCaseClassification());
caseDto.setRadiographyCompatibility(externalMessageDto.getRadiographyCompatibility());
caseDto.setOtherDiagnosticCriteria(externalMessageDto.getOtherDiagnosticCriteria());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,10 @@ public void setValue(PathogenTestDto newFieldValue) throws ReadOnlyException, Co
}
typingIdField.setValue(newFieldValue.getTypingId());
specieField.setValue(newFieldValue.getSpecie());
if(!genoTypingCB.isReadOnly()) {
if (!genoTypingCB.isReadOnly()) {
genoTypingCB.setValue(newFieldValue.getGenoTypeResult());
// We only set the genotyping result text if the genotyping result is not read only
if(!genoTypingResultTextTF.isReadOnly()) {
if (!genoTypingResultTextTF.isReadOnly()) {
genoTypingResultTextTF.setValue(newFieldValue.getGenoTypeResultText());
}
}
Expand Down Expand Up @@ -362,22 +362,27 @@ protected void addFields() {
I18nProperties.getPrefixCaption(SampleDto.I18N_PREFIX, SampleDto.SAMPLE_DATE_TIME),
DateFormatHelper.formatDate(getSampleDate()))));
testDateField.addValueChangeListener(e -> {
boolean hasTime = !getSampleDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate().equals(LocalTime.MIDNIGHT);
if (hasTime) {
testDateField.removeAllValidators();
testDateField.addValidator(
new DateComparisonValidator(
testDateField,
this::getSampleDate,
false,
false,
false,
I18nProperties.getValidationError(
Validations.afterDateWithDate,
testDateField.getCaption(),
I18nProperties.getPrefixCaption(SampleDto.I18N_PREFIX, SampleDto.SAMPLE_DATE_TIME),
DateFormatHelper.formatLocalDateTime(getSampleDate()))));
boolean hasTime =
getSampleDate() != null && !getSampleDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate().equals(LocalTime.MIDNIGHT);
Comment on lines +365 to +366

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix type mismatch: toLocalDate() cannot be compared with LocalTime.MIDNIGHT.

Line 366 calls .toLocalDate() which returns a LocalDate object, then attempts to compare it with LocalTime.MIDNIGHT using .equals(). This is a type mismatch—LocalDate and LocalTime are incompatible types.

Apply this diff to fix the logic:

-		boolean hasTime =
-			getSampleDate() != null && !getSampleDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate().equals(LocalTime.MIDNIGHT);
+		boolean hasTime =
+			getSampleDate() != null && !getSampleDate().toInstant().atZone(ZoneId.systemDefault()).toLocalTime().equals(LocalTime.MIDNIGHT);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
boolean hasTime =
getSampleDate() != null && !getSampleDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate().equals(LocalTime.MIDNIGHT);
boolean hasTime =
getSampleDate() != null && !getSampleDate().toInstant().atZone(ZoneId.systemDefault()).toLocalTime().equals(LocalTime.MIDNIGHT);
🤖 Prompt for AI Agents
In sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestForm.java
around lines 365-366, the code compares a LocalDate to LocalTime.MIDNIGHT
causing a type mismatch; change the comparison to examine the time component
instead — call toInstant().atZone(ZoneId.systemDefault()).toLocalTime() and
compare that to LocalTime.MIDNIGHT so hasTime becomes true when getSampleDate()
is non-null and its time is not midnight; keep the null check and timezone
conversion intact.


if (!hasTime) {
return;
}

testDateField.removeAllValidators();
testDateField.addValidator(
new DateComparisonValidator(
testDateField,
this::getSampleDate,
false,
false,
false,
I18nProperties.getValidationError(
Validations.afterDateWithDate,
testDateField.getCaption(),
I18nProperties.getPrefixCaption(SampleDto.I18N_PREFIX, SampleDto.SAMPLE_DATE_TIME),
DateFormatHelper.formatLocalDateTime(getSampleDate()))));

});
ComboBox lab = addInfrastructureField(PathogenTestDto.LAB);
lab.addItems(FacadeProvider.getFacilityFacade().getAllActiveLaboratories(true));
Expand Down
Loading