#13426 - Fixes Male case has unnecessary information as Pregnancy#13779
#13426 - Fixes Male case has unnecessary information as Pregnancy#13779roldy merged 2 commits intodevelopmentfrom
Conversation
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughAdds sex-based visibility checks to hide pregnancy-related fields (PREGNANT, POSTPARTUM, TRIMESTER) in case and vaccination UI components by resolving the person's Sex and gating field visibility when the person is male. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CaseFragment as CaseRead/Edit Fragment
participant CaseDataForm
participant Model as Person/Record
User->>CaseFragment: Open case view
CaseFragment->>Model: fetch case & person
CaseFragment->>CaseDataForm: setUpFieldVisibilities(person)
CaseDataForm->>CaseDataForm: evaluate person.sex
alt person.sex == MALE
CaseDataForm->>CaseDataForm: hide PREGNANT/POSTPARTUM/TRIMESTER
else
CaseDataForm->>CaseDataForm: preserve existing visibility logic
end
sequenceDiagram
participant User
participant VaccinationController
participant ImmunizationDto
participant VaccinationEditForm
User->>VaccinationController: create/edit vaccination
VaccinationController->>ImmunizationDto: resolve person or immunization.person
VaccinationController->>VaccinationEditForm: new(..., personSex, ...)
VaccinationEditForm->>VaccinationEditForm: if personSex == MALE hide pregnant/trimester
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
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. Comment |
There was a problem hiding this comment.
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 usesSex.MALE.equals(person.getSex())without an explicit null check. Both approaches produce the same result (sinceequals()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 nullOr 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
📒 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
ObjectsandSexare 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
Seximport 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
personand the use ofSex.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
Seximport 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
getPersonSexandgetPersonSexFromVaccinationmethods 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
Seximport enables the form to hide pregnancy-related fields for male patients, and theStringUtilsimport is correctly retained for existing vaccine validation logic.Also applies to: 32-32
55-67: LGTM: Constructor properly accepts and stores person sex.The
personSexfield is correctly declared as final and initialized in the constructor. The constructor signature change is supported by corresponding updates inVaccinationController.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.
|
SonarCloud analysis: https://sonarcloud.io/dashboard?id=SORMAS-Project&pullRequest=13779 |
Resolved conflicts in CaseDataForm.java: - Kept both Objects and Set imports - Combined male case pregnancy fix with new postpartumField variable for mutual exclusivity feature Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
SonarCloud analysis: https://sonarcloud.io/dashboard?id=SORMAS-Project&pullRequest=13779 |
Fixes #13426
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.