Skip to content

FIX: Parent-Leaf grouping for Patching: Immunization-Vaccinationattion#13947

Merged
KarnaiahPesula merged 2 commits into
developmentfrom
fix/ngsurvey-v2
May 29, 2026
Merged

FIX: Parent-Leaf grouping for Patching: Immunization-Vaccinationattion#13947
KarnaiahPesula merged 2 commits into
developmentfrom
fix/ngsurvey-v2

Conversation

@Pa-Touche
Copy link
Copy Markdown
Contributor

@Pa-Touche Pa-Touche commented May 29, 2026

Fixes #13832

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of grouped immunization and vaccination records to correctly associate vaccinations with their corresponding immunizations.
    • Enhanced data validation to prevent missing immunization or case data during vaccination processing.
    • Corrected the system to create new immunization records when needed rather than overriding existing ones.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1a80a76e-d4ff-46a4-ab2e-1af5c610fe7f

📥 Commits

Reviewing files that changed from the base of the PR and between 077c979 and 9791341.

📒 Files selected for processing (4)
  • sormas-backend/src/main/java/de/symeda/sormas/backend/patch/BusinessDtoFacade.java
  • sormas-backend/src/main/java/de/symeda/sormas/backend/patch/DataPatcherImpl.java
  • sormas-backend/src/test/java/de/symeda/sormas/backend/patch/BusinessDtoFacadeTest.java
  • sormas-backend/src/test/java/de/symeda/sormas/patch/DataPatcherImplTest.java

📝 Walkthrough

Walkthrough

The PR refactors BusinessDtoFacade to manage DTOs grouped by integer keys as List<Tuple<Integer, EntityDto>> instead of flat lists. Leaf attachment logic now groups immunizations by index and creates missing ones from case data. DataPatcherImpl adapts to build tuples from entity cache entries. Comprehensive tests cover tuple-based saves, vaccination grouping, and end-to-end patching with multiple immunization groups.

Changes

Grouped DTO Saving Pipeline

Layer / File(s) Summary
Tuple-based save contract and leaf attachment mechanism
sormas-backend/src/main/java/de/symeda/sormas/backend/patch/BusinessDtoFacade.java
save(...) method signature updated to accept List<Tuple<Integer, EntityDto>>. Leaf attachment registration rewritten to operate on tuple items: vaccination attachment now groups immunizations by groupIndex, creates missing ones from case data, sets meansOfImmunization, and appends vaccinations; exposure, activity, and previous-hospitalization leaves added directly to case data. LeafAttacher contract updated to accept groupIndex and in-progress tuple list instead of returning parent DTO. Helper requireCaseData extracts CaseDataDto from tuple list.
DataPatcher caller adaptation
sormas-backend/src/main/java/de/symeda/sormas/backend/patch/DataPatcherImpl.java
saveDTOsIfAppropriate builds tuple list from entityCache.entrySet() instead of values, collecting (groupIndex, EntityDto) pairs and passing to the updated businessDtoFacade.save contract.
Unit test coverage for grouped saving
sormas-backend/src/test/java/de/symeda/sormas/backend/patch/BusinessDtoFacadeTest.java
Imports added for Tuple and test utilities. Comprehensive tests use tuple-based inputs: basic save delegation for cases/persons/immunizations; vaccination attach-and-save with existing and auto-created immunizations; error handling for missing immunization/case data; grouped vaccinations attaching to distinct immunizations per group index with correct facade delegation counts.
Integration test for grouped patching
sormas-backend/src/test/java/de/symeda/sormas/patch/DataPatcherImplTest.java
New test patch_grouped_twoImmunizationsThreeVaccinations_thirdVaccinationCreatesNewImmunization validates end-to-end grouped immunization/vaccination patching: applying a patch with three immunization groups (two with status, one without) results in three immunizations with one vaccination each, correct statuses, and auto-creation of missing immunizations.

🎯 3 (Moderate) | ⏱️ ~22 minutes

🐰 A tuple here, a tuple there,
Groups by index, with utmost care!
Vaccinations find their home,
No immunization left alone!
Logic flows through patch domain,
Survey data enters the main

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description only contains the boilerplate template with issue reference (#13832) and no actual explanation of the changes or their purpose. Add a substantive description explaining what parent-leaf grouping means, why the changes support it, and how it enables grouped patching of related entities.
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title has a typo ('Vaccinationattion') and is partially unclear, but it does refer to parent-leaf grouping for immunization-vaccination which is the core change. Fix the typo 'Vaccinationattion' to 'Vaccination' for clarity. Consider a more concise title like 'Fix parent-leaf grouping for immunization-vaccination patching'.
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR addresses the parent-leaf grouping requirement necessary for patching related entities like Immunization-Vaccination grouped by index, which is foundational for ngSurvey integration.
Out of Scope Changes check ✅ Passed All changes are focused on refactoring the save pipeline to support integer-keyed tuple grouping and updating leaf attachment logic for vaccines, case data, and exposures—directly supporting the patching infrastructure needed for survey data mapping.

✏️ 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 fix/ngsurvey-v2

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.

@Pa-Touche Pa-Touche changed the title FIX: Parent-Leaf grouping for Patching. Example Immunization-Vaccination… FIX: Parent-Leaf grouping for Patching: Immunization-Vaccinationattion May 29, 2026
@Pa-Touche Pa-Touche marked this pull request as ready for review May 29, 2026 16:53
@Pa-Touche Pa-Touche self-assigned this May 29, 2026
@Pa-Touche Pa-Touche requested a review from KarnaiahPesula May 29, 2026 16:53
@KarnaiahPesula KarnaiahPesula merged commit d39bee4 into development May 29, 2026
7 checks passed
@KarnaiahPesula KarnaiahPesula deleted the fix/ngsurvey-v2 branch May 29, 2026 19: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.

External survey tool integration: ngSurvey

2 participants