Skip to content

Fixed the case classification when a negative test result is detected.#13985

Merged
KarnaiahPesula merged 2 commits into
developmentfrom
bugfix-negative-test-results-updates-caseclassification
Jun 15, 2026
Merged

Fixed the case classification when a negative test result is detected.#13985
KarnaiahPesula merged 2 commits into
developmentfrom
bugfix-negative-test-results-updates-caseclassification

Conversation

@KarnaiahPesula

@KarnaiahPesula KarnaiahPesula commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Fixes #

Summary by CodeRabbit

  • New Features

    • Classify cases as "not a case" after verified negative pathogen tests, with a confirmation dialog to apply the change.
    • Added UI text/labels for the new "negative case" confirmation and message prompts.
  • Bug Fixes / Improvements

    • Disease classification updated to handle negative-test logic for additional diseases.
    • Samples side panel now displays for measles contacts in Luxembourg.

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds UI and i18n pieces to allow reclassifying cases as "not a case" after verified negative pathogen tests, enables negative-case criteria for two diseases in backend rules, and tweaks contact view panel gating.

Changes

Negative Case Classification Workflow

Layer / File(s) Summary
i18n Caption and Message Definitions
sormas-api/src/main/java/de/symeda/sormas/api/i18n/Captions.java, sormas-api/src/main/java/de/symeda/sormas/api/i18n/Strings.java, sormas-api/src/main/resources/captions.properties, sormas-api/src/main/resources/strings.properties
Adds caseNegativeCase and messageNegativeCaseAfterPathogenTest keys and English property entries for the "Negative case" caption and confirmation message.
Disease Classification Rules for Negative Tests
sormas-backend/src/main/java/de/symeda/sormas/backend/caze/classification/CaseClassificationFacadeEjb.java
GIARDIASIS and CRYPTOSPORIDIOSIS now receive computed notACase(...) criteria instead of null when building classification rules.
Negative Case Confirmation Dialog in UI
sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestController.java
Adds showNegativeCaseDialog(CaseDataDto) and invokes it from handleAssociatedCase() for verified negative tests; on confirmation sets caseClassification to NO_CASE, saves, and navigates to the case.
Contact view samples / immunization panel gates
sormas-ui/src/main/java/de/symeda/sormas/ui/contact/ContactDataView.java
Removes MEASLES from the Luxembourg samples-panel exclusion and reformats the immunizations panel condition without changing its logic.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • roldy
  • obinna-h-n

Poem

🐰 I sniffed the tests and hopped around,

A negative sign, a softer sound.
A tiny dialog, “Not a case?” it asks,
Giardia, Crypto join the tasks,
Saved, relabeled — onward bound.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description contains only the repository template boilerplate without any substantive information about the changes, objectives, or rationale. The issue reference is unfilled (shows 'Fixes #' with no number). Fill in the issue number after 'Fixes #' and provide a clear description of what the PR accomplishes, why the changes were made, and any relevant testing or implementation details.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately describes the main change—fixing case classification behavior when negative test results are detected, which aligns with the core modifications across multiple files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bugfix-negative-test-results-updates-caseclassification

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestController.java (1)

455-467: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Avoid triggering both confirm and negative dialogs in the same save flow.

Line 455 and Line 462 can both execute when verified positive and negative tests are present, leading to conflicting classification prompts in one action. Gate this to a single branch (based on the selected/latest result), and pass the refreshed case (c) consistently.

Suggested fix
-						if (hasVerifiedPositiveTest) {
+						if (hasVerifiedPositiveTest) {
 							this.showConfirmCaseDialog(c); // Case classification
-						}
-						// Show the confirmation dialog if there are verified negative tests.
-						if (hasVerifiedNegativeTest) {
-							this.showNegativeCaseDialog(caze);
+						} else if (hasVerifiedNegativeTest) {
+							this.showNegativeCaseDialog(c);
 						}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestController.java`
around lines 455 - 467, The save flow may call both branches when
hasVerifiedPositiveTest and hasVerifiedNegativeTest are true, causing
conflicting dialogs; update the logic in PathogenTestController (the block
checking hasVerifiedPositiveTest / hasVerifiedNegativeTest) to choose a single
branch (e.g., prefer the selected/latest test result) and invoke only one
dialog: either showConfirmCaseDialog(c) or showNegativeCaseDialog(c) (use the
refreshed case variable c consistently instead of caze). Ensure the selection
criterion (latest/selected result) is used to gate the if/else so only one
dialog path runs.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestController.java`:
- Around line 798-813: showNegativeCaseDialog is missing the early short-circuit
used in showConfirmCaseDialog and it unboxes a nullable Boolean (confirmed)
which can NPE; add the same guard checks as in showConfirmCaseDialog (e.g.,
return early if caze.getCountryCode() is null/empty or if
caze.getCaseClassification() == CaseClassification.NO_CASE) before showing the
popup, and change the confirmation check to a null-safe comparison (use
Boolean.TRUE.equals(confirmed)) so the callback cannot NPE; reference the
methods/fields showNegativeCaseDialog, showConfirmCaseDialog,
caze.getCountryCode(), caze.getCaseClassification(), and
CaseClassification.NO_CASE when making the changes.

---

Outside diff comments:
In
`@sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestController.java`:
- Around line 455-467: The save flow may call both branches when
hasVerifiedPositiveTest and hasVerifiedNegativeTest are true, causing
conflicting dialogs; update the logic in PathogenTestController (the block
checking hasVerifiedPositiveTest / hasVerifiedNegativeTest) to choose a single
branch (e.g., prefer the selected/latest test result) and invoke only one
dialog: either showConfirmCaseDialog(c) or showNegativeCaseDialog(c) (use the
refreshed case variable c consistently instead of caze). Ensure the selection
criterion (latest/selected result) is used to gate the if/else so only one
dialog path runs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8ed02873-d088-4f15-845a-2aa9625af39f

📥 Commits

Reviewing files that changed from the base of the PR and between e1224d8 and a0c357f.

📒 Files selected for processing (6)
  • sormas-api/src/main/java/de/symeda/sormas/api/i18n/Captions.java
  • sormas-api/src/main/java/de/symeda/sormas/api/i18n/Strings.java
  • sormas-api/src/main/resources/captions.properties
  • sormas-api/src/main/resources/strings.properties
  • sormas-backend/src/main/java/de/symeda/sormas/backend/caze/classification/CaseClassificationFacadeEjb.java
  • sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestController.java

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
sormas-ui/src/main/java/de/symeda/sormas/ui/contact/ContactDataView.java (1)

231-233: 💤 Low value

Consider simplifying single-element disease check.

For a single-disease exclusion check, a direct equality comparison would be clearer and slightly more efficient than creating a single-element list.

♻️ Suggested simplification
-		// Allowing the samples component for LUX Measles.
 		if (!(FacadeProvider.getConfigFacade().isConfiguredCountry(CountryHelper.COUNTRY_CODE_LUXEMBOURG)
-			&& List.of(Disease.INVASIVE_MENINGOCOCCAL_INFECTION).contains(contactDto.getDisease()))) {
+			&& contactDto.getDisease() == Disease.INVASIVE_MENINGOCOCCAL_INFECTION)) {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@sormas-ui/src/main/java/de/symeda/sormas/ui/contact/ContactDataView.java`
around lines 231 - 233, The conditional in ContactDataView that currently does:
List.of(Disease.INVASIVE_MENINGOCOCCAL_INFECTION).contains(contactDto.getDisease())
should be simplified to a direct enum comparison; replace the single-element
list containment check with contactDto.getDisease() ==
Disease.INVASIVE_MENINGOCOCCAL_INFECTION (or .equals(...) if not an enum) inside
the existing if to make the intent clearer and slightly more efficient.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@sormas-ui/src/main/java/de/symeda/sormas/ui/contact/ContactDataView.java`:
- Around line 231-233: The conditional in ContactDataView that currently does:
List.of(Disease.INVASIVE_MENINGOCOCCAL_INFECTION).contains(contactDto.getDisease())
should be simplified to a direct enum comparison; replace the single-element
list containment check with contactDto.getDisease() ==
Disease.INVASIVE_MENINGOCOCCAL_INFECTION (or .equals(...) if not an enum) inside
the existing if to make the intent clearer and slightly more efficient.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0cfc9469-3d0f-4691-bb9a-53c51716728d

📥 Commits

Reviewing files that changed from the base of the PR and between a0c357f and 46ea358.

📒 Files selected for processing (2)
  • sormas-ui/src/main/java/de/symeda/sormas/ui/contact/ContactDataView.java
  • sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestController.java

@KarnaiahPesula KarnaiahPesula merged commit 3d90d96 into development Jun 15, 2026
7 checks passed
@KarnaiahPesula KarnaiahPesula deleted the bugfix-negative-test-results-updates-caseclassification branch June 15, 2026 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants