Skip to content

Bugfix 13507 imi case classification issue#13594

Merged
KarnaiahPesula merged 4 commits into
developmentfrom
bugfix-13507-imi-case-classification-issue
Sep 11, 2025
Merged

Bugfix 13507 imi case classification issue#13594
KarnaiahPesula merged 4 commits into
developmentfrom
bugfix-13507-imi-case-classification-issue

Conversation

@KarnaiahPesula
Copy link
Copy Markdown
Contributor

@KarnaiahPesula KarnaiahPesula commented Sep 11, 2025

Fixes #

Summary by CodeRabbit

  • Bug Fixes
    • Epidemiological confirmation now updates automatically for existing cases when a known source case is linked and a related contact’s case is confirmed, ensuring accurate classification.
    • After creating a source contact, the associated case is persisted and the view refreshes so classification and epidemiological status updates appear immediately.

@KarnaiahPesula KarnaiahPesula linked an issue Sep 11, 2025 that may be closed by this pull request
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Sep 11, 2025

Walkthrough

Adds backend logic to set a case’s epidemiologicalConfirmation during updates based on whether a known source contact’s case is CONFIRMED, and updates the UI so creating a source contact saves the associated case before refreshing the view.

Changes

Cohort / File(s) Summary
Case update epi-confirmation logic
sormas-backend/src/main/java/de/symeda/sormas/backend/caze/CaseFacadeEjb.java
In onCaseChanged (update path), reads epiData.contactWithSourceCaseKnown and: if YES, checks related source contacts’ cases for any with the same disease and CONFIRMED classification; sets epidemiologicalConfirmation to YES if found, otherwise NO. If contactKnown is NO sets NO, else UNKNOWN. Runs before existing update follow-up.
UI: save related case after contact creation
sormas-ui/src/main/java/de/symeda/sormas/ui/contact/SourceContactListComponent.java
Adjusted New Contact handler to call create(..., callback) where the callback retrieves the case by UUID and saves it via FacadeProvider.getCaseFacade().save(...), then calls SormasUI.refreshView(). Added import and inline comments explaining rationale.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant UI as UI: SourceContactListComponent
  participant CF as CaseFacade
  participant DB as Database

  rect rgb(230,240,255)
    note over UI: Create Source Contact
    UI->>CF: create(contact for caseReference)
    CF->>DB: persist Contact
    DB-->>CF: Contact persisted
  end

  rect rgb(235,255,235)
    note over UI: Save related Case then refresh
    UI->>CF: getByUuid(caseReference.uuid)
    CF-->>UI: Case entity
    UI->>CF: save(Case)
    CF->>DB: update Case
    DB-->>CF: Case saved
    UI->>UI: refreshView()
  end
Loading
sequenceDiagram
  autonumber
  participant Svc as CaseFacadeEjb.onCaseChanged (update)
  participant Repo as Contact/Case Repository
  participant Case as CaseEntity

  Note over Svc: existingCase != null and newCase.epiData != null
  Svc->>Repo: fetch contacts with resultingCase = existingCase
  Repo-->>Svc: contacts (may map to related cases)
  Svc->>Svc: filter related cases by same disease and CONFIRMED
  alt contactWithSourceCaseKnown == YES and confirmed source exists
    Svc->>Case: set epidemiologicalConfirmation = YES
  else if contactWithSourceCaseKnown == YES
    Svc->>Case: set epidemiologicalConfirmation = NO
  else if contactWithSourceCaseKnown == NO
    Svc->>Case: set epidemiologicalConfirmation = NO
  else
    Svc->>Case: set epidemiologicalConfirmation = UNKNOWN
  end
  Note over Svc: continue with existing update follow-up
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Pre-merge checks (1 passed, 2 warnings)

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description currently contains only the default contribution template and still shows "Fixes #" with no issue number, and it lacks a summary of the implemented changes, rationale, and testing/QA instructions, so it does not meet the repository's required PR description content. Please replace the template with a complete description: specify the issue number after "Fixes #", add a concise summary of what was changed and why (mention key files and behavioral impact), include testing or QA steps and any migration/rollout notes, and link the related issue or discussion.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The title "Bugfix 13507 imi case classification issue" is concise, directly related to the changes (a bugfix addressing IMI case classification) and gives a clear signal to reviewers about the PR's main purpose.

Poem

I nudge the code with nimble paws,
A source is checked, the logic claws.
Save the case, then watch the view,
CONFIRMED hops into the queue.
Tiny rabbit, big deploy applause 🥕

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.38.6)
sormas-backend/src/main/java/de/symeda/sormas/backend/caze/CaseFacadeEjb.java

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a02bd82 and 4b55b04.

📒 Files selected for processing (1)
  • sormas-backend/src/main/java/de/symeda/sormas/backend/caze/CaseFacadeEjb.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • sormas-backend/src/main/java/de/symeda/sormas/backend/caze/CaseFacadeEjb.java
⏰ 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). (1)
  • GitHub Check: SORMAS CI
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix-13507-imi-case-classification-issue

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.

Actionable comments posted: 1

🧹 Nitpick comments (3)
sormas-backend/src/main/java/de/symeda/sormas/backend/caze/CaseFacadeEjb.java (1)

2210-2213: Typo in comment.

“epidemiolist” → “epidemiologist”.

-			// If contact with source case is known by epidemiolist, && its classified as confirmed, then set epidemiological confirmation to YES
+			// If contact with source case is known by epidemiologist and the source case is confirmed, set epidemiological confirmation to YES
sormas-ui/src/main/java/de/symeda/sormas/ui/contact/SourceContactListComponent.java (2)

80-85: Avoid duplicate lookups; minor clean-up.

Reuse the facade instance; keeps the code concise and avoids two static lookups.

-					e -> view.showUnsavedChangesPopup(() -> ControllerProvider.getContactController().create(caseReference, true, () -> {
-						// For case classification effectiveness, extra save is needed.
-						// Ideally, we should mark the epi case data form as dirty when a contact is created, but we couldn't find a way to do that.
-						FacadeProvider.getCaseFacade().save(FacadeProvider.getCaseFacade().getByUuid(caseReference.getUuid()));
-						SormasUI.refreshView();
-					})),
+					e -> view.showUnsavedChangesPopup(() -> ControllerProvider.getContactController().create(caseReference, true, () -> {
+						// Persist case once to trigger onCaseChanged and classification updates.
+						final var caseFacade = FacadeProvider.getCaseFacade();
+						caseFacade.save(caseFacade.getByUuid(caseReference.getUuid()));
+						SormasUI.refreshView();
+					})),

80-85: Move “trigger classification after contact creation” into backend flow.

UI-level “save case” as a side-effect can add latency and inadvertently trigger unrelated onCaseChanged side effects (e.g., share sync). Prefer firing this from ContactFacade on successful creation so the backend remains the single source of truth for classification updates.

Would you like a backend-side proposal (ContactFacade/CaseFacade API) that updates epidemiological confirmation without a full case save?

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 62a626d and a02bd82.

📒 Files selected for processing (2)
  • sormas-backend/src/main/java/de/symeda/sormas/backend/caze/CaseFacadeEjb.java (1 hunks)
  • sormas-ui/src/main/java/de/symeda/sormas/ui/contact/SourceContactListComponent.java (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
sormas-ui/src/main/java/de/symeda/sormas/ui/contact/SourceContactListComponent.java (2)
sormas-api/src/main/java/de/symeda/sormas/api/FacadeProvider.java (1)
  • FacadeProvider (127-594)
sormas-ui/src/main/java/de/symeda/sormas/ui/ControllerProvider.java (1)
  • ControllerProvider (69-362)
⏰ 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). (1)
  • GitHub Check: SORMAS CI
🔇 Additional comments (1)
sormas-ui/src/main/java/de/symeda/sormas/ui/contact/SourceContactListComponent.java (1)

28-28: Import looks fine.

Comment thread sormas-backend/src/main/java/de/symeda/sormas/backend/caze/CaseFacadeEjb.java Outdated
@KarnaiahPesula KarnaiahPesula merged commit 75e5985 into development Sep 11, 2025
5 of 8 checks passed
@KarnaiahPesula KarnaiahPesula deleted the bugfix-13507-imi-case-classification-issue branch September 11, 2025 08:42
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.

case classification for IMI not working for confirmed case

2 participants