Defaulting the exposure setting to "Mosquito-borne" for malaria and d…#13924
Conversation
📝 WalkthroughWalkthroughExposureForm now conditionally preselects MOSQUITO_BORNE as the default ExposureSetting when the disease is Malaria or Dengue and the exposure category is VECTOR_BORNE. ExposuresField adds a new prophylaxis adherence column display for case-associated exposures. ChangesExposure Form and Field UI Improvements
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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.
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/exposure/ExposureForm.java (1)
634-643:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winOpening an existing Malaria/Dengue VECTOR_BORNE exposure with a
nullsetting will now silently pre-populateMOSQUITO_BORNE.
updateSettingFieldItems(line 635) now setssettingFieldtoMOSQUITO_BORNEfor these diseases/category combos. The restore guard at lines 641–642 only runs whensetting != null. For historical records wheresettingwas never set, the guard is skipped, so the form displaysMOSQUITO_BORNE. A user who opens and saves such a record without touching the field will silently persistMOSQUITO_BORNE.If this is intentional (backfilling historical null values), it may be worth an explicit comment documenting the decision. If not, the restore logic should clear the default when an original null setting is loaded:
🛡️ Proposed fix if the silent mutation is unintended
- // Restore setting field value and visibility - if (setting != null) { - settingField.setValue(setting); - } + // Restore setting field value and visibility (always restore; overrides any default set by updateSettingFieldItems) + settingField.setValue(setting);This ensures that a DTO with
setting == nullalways loads as null in the form, even for diseases whereupdateSettingFieldItemswould otherwise default toMOSQUITO_BORNE.🤖 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/exposure/ExposureForm.java` around lines 634 - 643, The form update sequence currently allows updateSettingFieldItems(...) to default settingField to MOSQUITO_BORNE and only restores the original value when setting != null, causing historical nulls to be silently overwritten; modify the restore logic after the update* calls in ExposureForm so that when setting == null you explicitly clear the UI control (e.g., call settingField.setValue(null) or settingField.clear()) instead of leaving the default, thereby preserving a loaded-null DTO; reference the existing updateSettingFieldItems, updateSubSettingsFieldItems, updateContactFactorsFieldItems, updateProtectiveMeasuresFieldItems calls and the settingField restore block and add the explicit clear for the null case.
🧹 Nitpick comments (1)
sormas-ui/src/main/java/de/symeda/sormas/ui/exposure/ExposureForm.java (1)
505-509: ⚡ Quick winReplace
Stream.of(...).anyMatch()with a simple||comparison.Using
Stream.of(Disease.MALARIA, Disease.DENGUE).anyMatch(d -> d == disease)for two values is unnecessarily verbose and brings injava.util.stream.Streamsolely for this expression.♻️ Proposed simplification
- ExposureSetting defaultSetting = - Stream.of(Disease.MALARIA, Disease.DENGUE).anyMatch(d -> d == disease) && category == ExposureCategory.VECTOR_BORNE - ? ExposureSetting.MOSQUITO_BORNE - : null; + ExposureSetting defaultSetting = + (disease == Disease.MALARIA || disease == Disease.DENGUE) && category == ExposureCategory.VECTOR_BORNE + ? ExposureSetting.MOSQUITO_BORNE + : null;And remove the now-unused import:
-import java.util.stream.Stream;🤖 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/exposure/ExposureForm.java` around lines 505 - 509, Replace the verbose Stream.of(...).anyMatch(...) expression in ExposureForm where defaultSetting is computed with a direct boolean check using (disease == Disease.MALARIA || disease == Disease.DENGUE) combined with the existing category check for ExposureCategory.VECTOR_BORNE so defaultSetting is set to ExposureSetting.MOSQUITO_BORNE in that case; then remove the now-unused java.util.stream.Stream import.
🤖 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.
Outside diff comments:
In `@sormas-ui/src/main/java/de/symeda/sormas/ui/exposure/ExposureForm.java`:
- Around line 634-643: The form update sequence currently allows
updateSettingFieldItems(...) to default settingField to MOSQUITO_BORNE and only
restores the original value when setting != null, causing historical nulls to be
silently overwritten; modify the restore logic after the update* calls in
ExposureForm so that when setting == null you explicitly clear the UI control
(e.g., call settingField.setValue(null) or settingField.clear()) instead of
leaving the default, thereby preserving a loaded-null DTO; reference the
existing updateSettingFieldItems, updateSubSettingsFieldItems,
updateContactFactorsFieldItems, updateProtectiveMeasuresFieldItems calls and the
settingField restore block and add the explicit clear for the null case.
---
Nitpick comments:
In `@sormas-ui/src/main/java/de/symeda/sormas/ui/exposure/ExposureForm.java`:
- Around line 505-509: Replace the verbose Stream.of(...).anyMatch(...)
expression in ExposureForm where defaultSetting is computed with a direct
boolean check using (disease == Disease.MALARIA || disease == Disease.DENGUE)
combined with the existing category check for ExposureCategory.VECTOR_BORNE so
defaultSetting is set to ExposureSetting.MOSQUITO_BORNE in that case; then
remove the now-unused java.util.stream.Stream import.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2f1b2f9d-8034-4664-9bc4-27166e0eda15
📒 Files selected for processing (2)
sormas-ui/src/main/java/de/symeda/sormas/ui/exposure/ExposureForm.javasormas-ui/src/main/java/de/symeda/sormas/ui/exposure/ExposuresField.java
…engue diseases.
Fixes #
Summary by CodeRabbit
Release Notes