Skip to content

Defaulting the exposure setting to "Mosquito-borne" for malaria and d…#13924

Merged
KarnaiahPesula merged 1 commit into
developmentfrom
bugfix-13922-malaria-dengue-exposure-form-defaulting-the-exposure-setting
May 8, 2026
Merged

Defaulting the exposure setting to "Mosquito-borne" for malaria and d…#13924
KarnaiahPesula merged 1 commit into
developmentfrom
bugfix-13922-malaria-dengue-exposure-form-defaulting-the-exposure-setting

Conversation

@KarnaiahPesula
Copy link
Copy Markdown
Contributor

@KarnaiahPesula KarnaiahPesula commented May 7, 2026

…engue diseases.

Fixes #

Summary by CodeRabbit

Release Notes

  • New Features
    • Exposure entry forms now automatically pre-select appropriate default vector-borne settings when documenting Malaria and Dengue cases, streamlining data entry and improving consistency
    • Case exposure data tables now display a dedicated prophylaxis adherence column for comprehensive tracking and monitoring of preventive medication compliance across case records

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

ExposureForm 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.

Changes

Exposure Form and Field UI Improvements

Layer / File(s) Summary
ExposureForm Setting Default Logic
sormas-ui/src/main/java/de/symeda/sormas/ui/exposure/ExposureForm.java
Imports Stream utility and replaces unconditional settingField clearing with conditional defaulting logic: when disease is Malaria or Dengue and category is VECTOR_BORNE, sets settingField to ExposureSetting.MOSQUITO_BORNE; otherwise leaves it null.
ExposuresField Prophylaxis Adherence Column
sormas-ui/src/main/java/de/symeda/sormas/ui/exposure/ExposuresField.java
Adds COLUMN_PROPHYLAXIS_ADHERENCE constant, includes the column in CaseDataDto visible columns, and registers a generated column renderer that displays adherence value or empty string when null.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Suggested reviewers

  • obinna-h-n

Poem

🐰 A form now knows its place so well—
When mosquitoes buzz and dengue dwell,
Malaria whispers, "VECTOR_BORNE,"
The setting springs to life, forsworn!
And table columns bloom with care,
Prophylaxis adherence everywhere. ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete. It continues the truncated title but does not provide the required issue number or substantive explanation of changes, despite template requirements. Add the related issue number (referenced as #13922 in the branch name) and provide a brief summary of what was changed and why.
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 title clearly and specifically describes the main change: defaulting the exposure setting to 'Mosquito-borne' for malaria and dengue diseases, which matches the primary functionality change in ExposureForm.
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-13922-malaria-dengue-exposure-form-defaulting-the-exposure-setting

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
Copy Markdown

@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.

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 win

Opening an existing Malaria/Dengue VECTOR_BORNE exposure with a null setting will now silently pre-populate MOSQUITO_BORNE.

updateSettingFieldItems (line 635) now sets settingField to MOSQUITO_BORNE for these diseases/category combos. The restore guard at lines 641–642 only runs when setting != null. For historical records where setting was never set, the guard is skipped, so the form displays MOSQUITO_BORNE. A user who opens and saves such a record without touching the field will silently persist MOSQUITO_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 == null always loads as null in the form, even for diseases where updateSettingFieldItems would otherwise default to MOSQUITO_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 win

Replace 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 in java.util.stream.Stream solely 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

📥 Commits

Reviewing files that changed from the base of the PR and between 14a8b20 and c55c812.

📒 Files selected for processing (2)
  • sormas-ui/src/main/java/de/symeda/sormas/ui/exposure/ExposureForm.java
  • sormas-ui/src/main/java/de/symeda/sormas/ui/exposure/ExposuresField.java

@KarnaiahPesula KarnaiahPesula requested review from raulbob May 7, 2026 12:45
@KarnaiahPesula KarnaiahPesula merged commit 62a8957 into development May 8, 2026
7 checks passed
@KarnaiahPesula KarnaiahPesula deleted the bugfix-13922-malaria-dengue-exposure-form-defaulting-the-exposure-setting branch May 8, 2026 13:32
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.

Malaria & Dengue Exposure form defaulting the exposure setting

2 participants