Skip to content

#13793 - Disabled classification popup for pathogen tests that are negative#13831

Merged
raulbob merged 1 commit intodevelopmentfrom
bugfix-13793-na_test_result_confirmation_dialog
Feb 13, 2026
Merged

#13793 - Disabled classification popup for pathogen tests that are negative#13831
raulbob merged 1 commit intodevelopmentfrom
bugfix-13793-na_test_result_confirmation_dialog

Conversation

@raulbob
Copy link
Contributor

@raulbob raulbob commented Feb 13, 2026

Fixes #13793

Summary by CodeRabbit

  • Refactor
    • Internal improvements to pathogen test handling code, including enhanced null-safety checks, reduced code duplication, and improved immutability patterns for better code reliability. No user-facing changes.

…gative

The behaviour was introduced it seems by a requirement to display the
case classification popup for verified pathogen tests (positive and negative).

While the behaviour might have beed desired, the actual logic in the code and
popup text is not. The popup text and the logic in other blocks of the code lead
us to the conclusion that only positive results trigger the popup.
@coderabbitai
Copy link

coderabbitai bot commented Feb 13, 2026

📝 Walkthrough

Walkthrough

This PR refactors PathogenTestController.java to fix a bug where negative pathogen test results incorrectly triggered case confirmation dialogs. Changes introduce final variables for immutability, consolidate test selection logic, adopt null-safe Boolean comparisons, and rework dialog flow callbacks.

Changes

Cohort / File(s) Summary
Pathogen Test Controller Refactoring
sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestController.java
Introduced final local variables for case and test data retrieval to improve immutability. Consolidated logic for verified test selection with sanity null checks. Reworked dialog callback flow for sample result changes and disease-variant updates. Replaced direct boolean checks with null-safe Boolean.TRUE.equals() comparisons. Normalized Optional handling and refined empty collection checks throughout multiple test result processing paths.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • PR #13783: Directly overlaps with testResultVerified nullability handling and Optional usage modifications, addressing similar verification logic concerns.

Suggested reviewers

  • obinna-h-n
  • KarnaiahPesula

Poem

🐰 A bouncing fix for tests gone wrong,
Negative becomes confirmed—oh dear!
With null-safe checks, we right the song,
Dialog flows now crystal clear,
No false confirmations here! ✨

🚥 Pre-merge checks | ✅ 5 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly describes the main objective: disabling the classification popup for negative pathogen tests, which directly addresses the linked issue #13793.
Description check ✅ Passed The PR description is minimal but correctly references the linked issue #13793, meeting the template requirement for identifying the related issue.
Linked Issues check ✅ Passed The code changes in PathogenTestController.java implement logic to prevent the classification popup for negative test results [#13793], directly addressing the reported bug where negative tests incorrectly triggered a confirmation dialog.
Out of Scope Changes check ✅ Passed All changes are focused on the PathogenTestController logic for handling pathogen test results, directly supporting the objective of disabling the popup for negative tests without introducing unrelated modifications.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into development

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix-13793-na_test_result_confirmation_dialog

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In
`@sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestController.java`:
- Line 436: In PathogenTestController (class PathogenTestController) update the
inline comment that currently reads "// We decided this based on the intented
text in the dialog but based on the test results instead of the sample overall
result" to correct the typo "intented" to "intended" so the comment reads
"...intended text...".
- Around line 422-445: The code currently calls
checkForDiseaseVariantUpdate(resultedPathogenTest, ...) even when the selected
resultedPathogenTest is a verified negative; wrap the call to
checkForDiseaseVariantUpdate (and its nested showConfirmCaseDialog callback)
inside a guard that checks hasVerifiedPositiveTest so disease-variant update and
case-confirmation logic only runs for verified positive tests; locate the block
starting at showChangeAssociatedSampleResultDialog(...) where
resultedPathogenTest is used and add the hasVerifiedPositiveTest condition
before invoking checkForDiseaseVariantUpdate/showConfirmCaseDialog.
🧹 Nitpick comments (1)
sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestController.java (1)

426-429: Dead code: resultedPathogenTest can never be null here.

On line 424, resultedPathogenTest is assigned via positiveWithSameDisease.get() or negativeWithSameDisease.get(). We're inside the if (hasVerifiedTests) block which guarantees at least one Optional is present, and the ternary selects the present one. The null check and IllegalStateException are unreachable.

Remove unreachable check
 			final PathogenTestDto resultedPathogenTest = hasVerifiedPositiveTest ? positiveWithSameDisease.get() : negativeWithSameDisease.get();
-
-			// just a sanity check
-			if (resultedPathogenTest == null) {
-				throw new IllegalStateException("No verified test found for disease " + caze.getDisease());
-			}

@sormas-vitagroup
Copy link
Contributor

@raulbob raulbob merged commit 30e9043 into development Feb 13, 2026
8 of 10 checks passed
@raulbob raulbob deleted the bugfix-13793-na_test_result_confirmation_dialog branch February 13, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants