Skip to content

Conversation

@raulbob
Copy link
Contributor

@raulbob raulbob commented Dec 9, 2025

Fixed #13769

Summary by CodeRabbit

  • Bug Fixes
    • Improved strain identification validation to prevent errors and ensure accurate status verification before enabling the Beijing lineage feature.

✏️ Tip: You can customize this high-level summary in your review settings.

- Test result checking was missing when setting the Beijing lineage flag
@coderabbitai
Copy link

coderabbitai bot commented Dec 9, 2025

Walkthrough

Fixed a bug in TherapyForm where the Beijing lineage field was always set to true regardless of the pathogen test result. Added null-safety check and explicit condition requiring the strain call status to be BEIJING before enabling the flag.

Changes

Cohort / File(s) Change Summary
Beijing lineage field logic fix
sormas-ui/src/main/java/de/symeda/sormas/ui/therapy/TherapyForm.java
Added import for PathogenStrainCallStatus and tightened the condition in attach() to verify that latestBejingGenotypingTest.getStrainCallStatus() is non-null and equals BEIJING before setting the Beijing lineage field, preventing NPE and ensuring the flag only activates for valid BEIJING test results.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Single file with focused logic improvement
  • Straightforward null-check and equality validation addition

Possibly related PRs

Suggested reviewers

  • obinna-h-n
  • KarnaiahPesula

Poem

🐰 A Beijing flag danced without care,
Checked when it shouldn't be there!
But now with a test—BEIJING must shine,
No false hops anymore, all is fine!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title clearly and accurately summarizes the main change—fixing the Beijing lineage flag that was incorrectly always being set to true in Therapy.
Description check ✅ Passed The pull request description is minimal but follows the template by referencing the linked issue (Fixes #13769). However, it lacks detail about what was changed to fix the issue.
Linked Issues check ✅ Passed The code changes directly address the bug: tightening the condition for setting beijingLineageField to require strain call status to be BEIJING, ensuring the flag is only set for actual Beijing test results.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the Beijing lineage flag issue in Therapy. The addition of PathogenStrainCallStatus import and condition tightening are directly relevant to the bug fix.
✨ 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-13769-tuberculosis_beijing_flag_always_true

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: 0

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

441-445: Core fix correctly addresses the bug; consider explicit false case.

The fix properly checks that strainCallStatus equals BEIJING before setting the flag to true, which resolves the issue where the flag was incorrectly set for non-BEIJING results. The null-safety checks are good defensive programming.

However, consider adding an else clause to explicitly set the field to false when conditions aren't met. This ensures the field is correctly reset if it was previously true:

 if (latestBejingGenotypingTest != null
     && latestBejingGenotypingTest.getStrainCallStatus() != null
     && latestBejingGenotypingTest.getStrainCallStatus() == PathogenStrainCallStatus.BEIJING) {
     beijingLineageField.setValue(true);
+} else {
+    beijingLineageField.setValue(false);
 }

This makes the logic more explicit and prevents potential state-persistence issues if the form lifecycle retains previous values.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4700166 and 2d2ff08.

📒 Files selected for processing (1)
  • sormas-ui/src/main/java/de/symeda/sormas/ui/therapy/TherapyForm.java (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: SORMAS CI
🔇 Additional comments (1)
sormas-ui/src/main/java/de/symeda/sormas/ui/therapy/TherapyForm.java (1)

47-47: LGTM!

The import is necessary for the fix and correctly added.

@sormas-vitagroup
Copy link
Contributor

@raulbob raulbob merged commit 87e7d44 into development Dec 9, 2025
8 of 10 checks passed
@raulbob raulbob deleted the bugfix-13769-tuberculosis_beijing_flag_always_true branch December 9, 2025 16:11
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.

When creating a tuberculosis Beijing the Therapy Beijing flag is always set to true.

4 participants