Skip to content
Open
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 @@ -155,7 +155,6 @@ public class PathogenTestDto extends PseudonymizableDto {
@SensitiveData
@Size(max = FieldConstraints.CHARACTER_LIMIT_BIG, message = Validations.textTooLong)
private String testResultText;
@NotNull(message = Validations.requiredField)
private Boolean testResultVerified;
private boolean fourFoldIncreaseAntibodyTiter;
@SensitiveData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import android.os.AsyncTask;
import android.util.Log;
import android.view.Menu;

import de.symeda.sormas.api.disease.DiseaseVariant;
import de.symeda.sormas.api.i18n.I18nProperties;
import de.symeda.sormas.api.i18n.Strings;
Expand Down Expand Up @@ -100,7 +99,7 @@ public void saveData() {
DiseaseVariant caseDiseaseVariant = associatedCase.getDiseaseVariant();
DiseaseVariant newDiseaseVariant = pathogenTestToSave.getTestedDiseaseVariant();
if (pathogenTestToSave.getTestResult() == PathogenTestResultType.POSITIVE
&& pathogenTestToSave.getTestResultVerified()
&& Boolean.TRUE.equals(pathogenTestToSave.getTestResultVerified())
&& !DataHelper.equal(newDiseaseVariant, caseDiseaseVariant)) {

String heading = I18nProperties.getString(Strings.headingUpdateCaseWithNewDiseaseVariant);
Expand Down Expand Up @@ -155,7 +154,7 @@ protected void onPostExecute(AsyncTaskResult<TaskResultHolder> taskResult) {
if (taskResult.getResultStatus().isSuccess()) {
Sample sampleOfPathogenTestToSave = pathogenTestToSave.getSample();
if (sampleOfPathogenTestToSave != null
&& Boolean.TRUE == pathogenTestToSave.getTestResultVerified()
&& Boolean.TRUE.equals(pathogenTestToSave.getTestResultVerified())
&& pathogenTestToSave.getTestedDisease() == associatedCase.getDisease()
&& pathogenTestToSave.getTestResult() != sampleOfPathogenTestToSave.getPathogenTestResult()) {
final ConfirmationDialog confirmationDialog = new ConfirmationDialog(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public void saveData() {
DiseaseVariant caseDiseaseVariant = associatedCase.getDiseaseVariant();
DiseaseVariant newDiseaseVariant = pathogenTestToSave.getTestedDiseaseVariant();
if (pathogenTestToSave.getTestResult() == PathogenTestResultType.POSITIVE
&& pathogenTestToSave.getTestResultVerified()
&& Boolean.TRUE.equals(pathogenTestToSave.getTestResultVerified())
&& !DataHelper.equal(newDiseaseVariant, caseDiseaseVariant)) {

String heading = I18nProperties.getString(Strings.headingUpdateCaseWithNewDiseaseVariant);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ public void setTestResultText(String testResultText) {
this.testResultText = testResultText;
}

@Column(nullable = false)
@Column
public Boolean getTestResultVerified() {
return testResultVerified;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,8 @@ public void validate(PathogenTestDto pathogenTest) throws ValidationRuntimeExcep
Validations.required,
I18nProperties.getPrefixCaption(PathogenTestDto.I18N_PREFIX, PathogenTestDto.TEST_RESULT)));
}
if (pathogenTest.getTestResultVerified() == null) {
// Validate testResultVerified is required when test comes via LIMS (laboratory is directly connected)
if (pathogenTest.isViaLims() && pathogenTest.getTestResultVerified() == null) {
throw new ValidationRuntimeException(
I18nProperties.getValidationError(
Validations.required,
Expand Down
6 changes: 6 additions & 0 deletions sormas-backend/src/main/resources/sql/sormas_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15062,4 +15062,10 @@ ALTER TABLE testreport_history ADD COLUMN serotype character varying(255);
ALTER TABLE testreport_history ADD COLUMN straincallstatus character varying(255);

INSERT INTO schema_version (version_number, comment) VALUES (602, 'External message additional fields');

-- 2025-12-18 Make testResultVerified optional in pathogentest #13557
ALTER TABLE pathogentest ALTER COLUMN testresultverified DROP NOT NULL;
ALTER TABLE pathogentest_history ALTER COLUMN testresultverified DROP NOT NULL;

INSERT INTO schema_version (version_number, comment) VALUES (603, 'Make testResultVerified optional in pathogentest #13557');
-- *** Insert new sql commands BEFORE this line. Remember to always consider _history tables. ***
Original file line number Diff line number Diff line change
Expand Up @@ -372,12 +372,12 @@ private void handleAssociatedCase(List<PathogenTestDto> pathogenTests, CaseRefer
Map<Disease, List<PathogenTestDto>> testsByDisease = pathogenTests.stream().collect(Collectors.groupingBy(PathogenTestDto::getTestedDisease));
Optional<PathogenTestDto> positiveWithSameDisease = testsByDisease.getOrDefault(caze.getDisease(), Collections.emptyList())
.stream()
.filter(t -> t.getTestResult() == PathogenTestResultType.POSITIVE && t.getTestResultVerified())
.filter(t -> t.getTestResult() == PathogenTestResultType.POSITIVE && Boolean.TRUE.equals(t.getTestResultVerified()))
.findFirst();

Optional<PathogenTestDto> negativeWithSameDisease = testsByDisease.getOrDefault(caze.getDisease(), Collections.emptyList())
.stream()
.filter(t -> t.getTestResult() == PathogenTestResultType.NEGATIVE && t.getTestResultVerified())
.filter(t -> t.getTestResult() == PathogenTestResultType.NEGATIVE && Boolean.TRUE.equals(t.getTestResultVerified()))
.findFirst();

PathogenTestDto resultedPathogenTest;
Expand All @@ -401,7 +401,7 @@ private void handleAssociatedCase(List<PathogenTestDto> pathogenTests, CaseRefer
List<PathogenTestDto> tests = testsByDisease.get(disease);

Optional<PathogenTestDto> positiveWithOtherDisease =
tests.stream().filter(t -> t.getTestResult() == PathogenTestResultType.POSITIVE && t.getTestResultVerified()).findFirst();
tests.stream().filter(t -> t.getTestResult() == PathogenTestResultType.POSITIVE && Boolean.TRUE.equals(t.getTestResultVerified())).findFirst();

if (positiveWithOtherDisease.isPresent()) {
List<CaseDataDto> duplicatedCases =
Expand Down Expand Up @@ -441,12 +441,12 @@ private void handleAssociatedContact(List<PathogenTestDto> pathogenTests, Contac
Map<Disease, List<PathogenTestDto>> testsByDisease = pathogenTests.stream().collect(Collectors.groupingBy(PathogenTestDto::getTestedDisease));
Optional<PathogenTestDto> positiveWithSameDisease = testsByDisease.getOrDefault(contact.getDisease(), Collections.emptyList())
.stream()
.filter(t -> t.getTestResult() == PathogenTestResultType.POSITIVE && t.getTestResultVerified())
.filter(t -> t.getTestResult() == PathogenTestResultType.POSITIVE && Boolean.TRUE.equals(t.getTestResultVerified()))
.findFirst();

Optional<PathogenTestDto> negativeWithSameDisease = testsByDisease.getOrDefault(contact.getDisease(), Collections.emptyList())
.stream()
.filter(t -> t.getTestResult() == PathogenTestResultType.NEGATIVE && t.getTestResultVerified())
.filter(t -> t.getTestResult() == PathogenTestResultType.NEGATIVE && Boolean.TRUE.equals(t.getTestResultVerified()))
.findFirst();

final boolean caseCreationPossible = UiUtil.permitted(FeatureType.CASE_SURVEILANCE, UserRight.CASE_CREATE);
Expand All @@ -467,7 +467,7 @@ private void handleAssociatedContact(List<PathogenTestDto> pathogenTests, Contac
List<PathogenTestDto> tests = testsByDisease.get(disease);

Optional<PathogenTestDto> positiveWithOtherDisease =
tests.stream().filter(t -> t.getTestResult() == PathogenTestResultType.POSITIVE && t.getTestResultVerified()).findFirst();
tests.stream().filter(t -> t.getTestResult() == PathogenTestResultType.POSITIVE && Boolean.TRUE.equals(t.getTestResultVerified())).findFirst();
if (positiveWithOtherDisease.isPresent()) {
List<CaseDataDto> duplicatedCases =
FacadeProvider.getCaseFacade().getDuplicatesWithPathogenTest(contact.getPerson(), positiveWithOtherDisease.get());
Expand Down Expand Up @@ -504,12 +504,12 @@ private void handleAssociatedEventParticipant(List<PathogenTestDto> pathogenTest
Map<Disease, List<PathogenTestDto>> testsByDisease = pathogenTests.stream().collect(Collectors.groupingBy(PathogenTestDto::getTestedDisease));
Optional<PathogenTestDto> positiveWithSameDisease = testsByDisease.getOrDefault(eventDisease, Collections.emptyList())
.stream()
.filter(t -> t.getTestResult() == PathogenTestResultType.POSITIVE && t.getTestResultVerified())
.filter(t -> t.getTestResult() == PathogenTestResultType.POSITIVE && Boolean.TRUE.equals(t.getTestResultVerified()))
.findFirst();

Optional<PathogenTestDto> negativeWithSameDisease = testsByDisease.getOrDefault(eventDisease, Collections.emptyList())
.stream()
.filter(t -> t.getTestResult() == PathogenTestResultType.NEGATIVE && t.getTestResultVerified())
.filter(t -> t.getTestResult() == PathogenTestResultType.NEGATIVE && Boolean.TRUE.equals(t.getTestResultVerified()))
.findFirst();

final boolean caseCreationPossible = UiUtil.permitted(FeatureType.CASE_SURVEILANCE, UserRight.CASE_CREATE);
Expand All @@ -531,7 +531,7 @@ private void handleAssociatedEventParticipant(List<PathogenTestDto> pathogenTest
List<PathogenTestDto> tests = testsByDisease.get(disease);

Optional<PathogenTestDto> positiveWithOtherDisease =
tests.stream().filter(t -> t.getTestResult() == PathogenTestResultType.POSITIVE && t.getTestResultVerified()).findFirst();
tests.stream().filter(t -> t.getTestResult() == PathogenTestResultType.POSITIVE && Boolean.TRUE.equals(t.getTestResultVerified())).findFirst();
if (positiveWithOtherDisease.isPresent() && UiUtil.enabled(FeatureType.CASE_SURVEILANCE)) {
List<CaseDataDto> duplicatedCases = FacadeProvider.getCaseFacade()
.getDuplicatesWithPathogenTest(eventParticipant.getPerson().toReference(), positiveWithOtherDisease.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ protected void addFields() {
getContent().addComponent(pathogenTestHeadingLabel, PATHOGEN_TEST_HEADING_LOC);

addDateField(PathogenTestDto.REPORT_DATE, DateField.class, 0);
addField(PathogenTestDto.VIA_LIMS);
CheckBox viaLimsField = addField(PathogenTestDto.VIA_LIMS);
addField(PathogenTestDto.EXTERNAL_ID);
addField(PathogenTestDto.EXTERNAL_ORDER_ID);
testTypeField = addField(PathogenTestDto.TEST_TYPE, ComboBox.class);
Expand Down Expand Up @@ -951,9 +951,17 @@ protected void addFields() {
PathogenTestDto.TUBE_MITOGENE_GT10);

NullableOptionGroup testResultVerifiedField = addField(PathogenTestDto.TEST_RESULT_VERIFIED, NullableOptionGroup.class);
testResultVerifiedField.setRequired(true);
addField(PathogenTestDto.PRELIMINARY).addStyleName(CssStyles.VSPACE_4);

// Make TEST_RESULT_VERIFIED required only when the test comes via LIMS (laboratory is directly connected)
viaLimsField.addValueChangeListener(e -> {
boolean isViaLims = Boolean.TRUE.equals(e.getProperty().getValue());
testResultVerifiedField.setRequired(isViaLims);
});

// Set initial required state based on current viaLims value
testResultVerifiedField.setRequired(Boolean.TRUE.equals(viaLimsField.getValue()));

CheckBox fourFoldIncrease = addField(PathogenTestDto.FOUR_FOLD_INCREASE_ANTIBODY_TITER, CheckBox.class);
CssStyles.style(fourFoldIncrease, VSPACE_3, VSPACE_TOP_4);
fourFoldIncrease.setVisible(false);
Expand Down
Loading