Skip to content

Conversation

@roldy
Copy link

@roldy roldy commented Dec 17, 2025

Fixes #13426

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Pregnancy-related fields (pregnancy status, postpartum status, and trimester information) are now correctly hidden when viewing or editing cases and vaccination records for male patients.

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

@coderabbitai
Copy link

coderabbitai bot commented Dec 17, 2025

Walkthrough

The pull request implements sex-based conditional visibility logic across multiple UI components and forms to hide pregnancy-related fields (PREGNANT, POSTPARTUM, TRIMESTER) when the patient is male, ensuring these fields do not appear inappropriately in case and vaccination forms.

Changes

Cohort / File(s) Summary
Case UI Components
sormas-app/app/src/main/java/de/symeda/sormas/app/caze/edit/CaseEditFragment.java, sormas-app/app/src/main/java/de/symeda/sormas/app/caze/read/CaseReadFragment.java
Added Sex import and conditional logic to hide pregnancy-related fields in setUpFieldVisibilities and onAfterLayoutBinding methods when patient is male.
Case Data Form
sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseDataForm.java
Added Objects and Sex imports; introduced conditional visibility logic for TRIMESTER, POSTPARTUM, and PREGNANT fields based on patient sex in field initialization and HTML message formatting paths.
Vaccination Controller
sormas-ui/src/main/java/de/symeda/sormas/ui/vaccination/VaccinationController.java
Added helper methods getPersonSex() and getPersonSexFromVaccination() to resolve patient sex and pass it to VaccinationEditForm in both create and edit paths.
Vaccination Edit Form
sormas-ui/src/main/java/de/symeda/sormas/ui/vaccination/VaccinationEditForm.java
Updated constructor signature to accept Sex personSex parameter; added conditional visibility logic for PREGNANT and TRIMESTER fields when patient is male.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • The changes follow a consistent pattern across 5 files (sex check → hide pregnancy fields)
  • Logic is straightforward but affects multiple UI components
  • VaccinationEditForm constructor signature change requires verification of all call sites
  • Vaccination controller logic for sex resolution from different sources (Person vs. Immunization) may need careful verification

Suggested reviewers

  • obinna-h-n
  • KarnaiahPesula

Poem

🐰 A rabbit checks the patient's sex,
Hides pregnancy—no more context vexed!
Males see no trimester, postpartum, or more,
The forms now fit each case to the core. ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.14% 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 PR title accurately reflects the main change: hiding pregnancy-related fields for male cases, directly addressing issue #13426.
Description check ✅ Passed The PR description is minimal but valid, properly referencing issue #13426 as required by the template.
Linked Issues check ✅ Passed The implementation successfully hides pregnancy fields (Pregnant, Postpartum, Trimester) for male patients across case edit, case read, and vaccination forms [#13426].
Out of Scope Changes check ✅ Passed All changes directly address hiding pregnancy fields for male cases; no unrelated modifications are present outside the scope of issue #13426.
✨ 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-13426-male-case-info-fix

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

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

1451-1453: Inconsistent null-safety pattern.

Line 1452 uses Objects.isNull(person.getSex()) || !Sex.MALE.equals(person.getSex()) while line 971 uses Sex.MALE.equals(person.getSex()) without an explicit null check. Both approaches produce the same result (since equals() safely handles null), but the inconsistency may confuse future maintainers.

Consider using a consistent pattern throughout:

-		boolean isMale = Sex.MALE.equals(person.getSex());
+		boolean isMale = Sex.MALE.equals(person.getSex()); // equals() safely returns false for null

Or use the explicit null check everywhere:

-		boolean isMale = Sex.MALE.equals(person.getSex());
+		boolean isMale = person.getSex() != null && Sex.MALE.equals(person.getSex());
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between af6249b and 21743b9.

📒 Files selected for processing (5)
  • sormas-app/app/src/main/java/de/symeda/sormas/app/caze/edit/CaseEditFragment.java (2 hunks)
  • sormas-app/app/src/main/java/de/symeda/sormas/app/caze/read/CaseReadFragment.java (3 hunks)
  • sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseDataForm.java (5 hunks)
  • sormas-ui/src/main/java/de/symeda/sormas/ui/vaccination/VaccinationController.java (5 hunks)
  • sormas-ui/src/main/java/de/symeda/sormas/ui/vaccination/VaccinationEditForm.java (4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
sormas-ui/src/main/java/de/symeda/sormas/ui/vaccination/VaccinationController.java (1)
sormas-api/src/main/java/de/symeda/sormas/api/FacadeProvider.java (1)
  • FacadeProvider (128-599)
⏰ 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). (4)
  • GitHub Check: SORMAS CI
  • GitHub Check: android app test (27)
  • GitHub Check: android app test (26)
  • GitHub Check: android app test (28)
🔇 Additional comments (11)
sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseDataForm.java (1)

41-41: LGTM: Imports support the new sex-based field visibility.

The new imports for Objects and Sex are correctly used in the sex-based conditional visibility logic introduced in this file.

Also applies to: 117-117

sormas-app/app/src/main/java/de/symeda/sormas/app/caze/read/CaseReadFragment.java (2)

32-32: LGTM: Import supports sex-based field visibility.

The Sex import is correctly used in the visibility logic at lines 137-141.


136-141: LGTM: Pregnancy fields correctly hidden for male cases.

The implementation properly checks for male sex and hides the pregnancy-related fields (PREGNANT, POSTPARTUM, TRIMESTER). The null-safety check for person and the use of Sex.MALE.equals() ensure correct behavior.

sormas-app/app/src/main/java/de/symeda/sormas/app/caze/edit/CaseEditFragment.java (2)

56-56: LGTM: Import supports sex-based field visibility.

The Sex import is correctly used in the visibility logic at lines 216-220.


215-220: LGTM: Pregnancy fields correctly hidden for male cases.

The implementation mirrors the read fragment's approach and correctly hides pregnancy-related fields for male patients with appropriate null-safety checks.

sormas-ui/src/main/java/de/symeda/sormas/ui/vaccination/VaccinationController.java (3)

33-33: LGTM: Imports support sex-aware vaccination forms.

The new imports enable the controller to retrieve person sex information to pass to VaccinationEditForm, ensuring pregnancy-related fields are hidden appropriately for male patients.

Also applies to: 37-37, 39-39


95-96: LGTM: Sex information correctly passed to vaccination forms.

The controller properly retrieves person sex using the new helper methods and passes it to VaccinationEditForm, enabling appropriate field visibility based on patient sex across all vaccination form creation paths.

Also applies to: 134-135, 236-237


195-224: Helper methods retrieve person sex with proper null-safety.

Both getPersonSex and getPersonSexFromVaccination methods correctly navigate the object graph (Immunization → Person → Sex) with appropriate null checks at each level. The multiple facade calls are acceptable for form initialization scenarios.

Note: These methods make multiple remote facade calls, which could be a performance concern if called frequently. However, since they're only invoked during form initialization, the performance impact should be minimal.

sormas-ui/src/main/java/de/symeda/sormas/ui/vaccination/VaccinationEditForm.java (3)

24-24: LGTM: Imports support sex-aware field visibility.

The Sex import enables the form to hide pregnancy-related fields for male patients, and the StringUtils import is correctly retained for existing vaccine validation logic.

Also applies to: 32-32


55-67: LGTM: Constructor properly accepts and stores person sex.

The personSex field is correctly declared as final and initialized in the constructor. The constructor signature change is supported by corresponding updates in VaccinationController.java.


128-146: LGTM: Pregnancy fields correctly hidden based on sex.

The implementation properly:

  • Hides PREGNANT and TRIMESTER fields when patient is male
  • For non-male patients, sets up conditional visibility where TRIMESTER is shown only when PREGNANT=YES
  • Handles null sex safely (treated as not male, which is appropriate)

This aligns with the acceptance criteria and follows a clean implementation pattern.

@sormas-vitagroup
Copy link
Contributor

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.

Male case has unnecessary information as Pregnancy

3 participants