Skip to content

Fixed issue with samples creation always displaying for Doctor Declaration #13579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

raulbob
Copy link
Contributor

@raulbob raulbob commented Aug 13, 2025

  • The doctor declaration processing was showing sample creation options even when no relevant samples were available.
  • Added check to ensure that sample creation options are only displayed when there are valid sample reports.

Summary by CodeRabbit

  • Bug Fixes

    • Doctor declarations now skip creating samples when sample reports contain no tests, preventing unnecessary processing and reducing noise. Existing behavior remains unchanged when tests are present.
  • Refactor

    • Enhanced extensibility of message processing flows to allow tailored handling for specific message types, improving maintainability and enabling more precise processing logic without affecting user workflows.

…ation

- The doctor declaration processing was showing sample creation options even when no relevant samples were available.
- Added check to ensure that sample creation options are only displayed when there are valid sample reports.
Copy link

coderabbitai bot commented Aug 13, 2025

Walkthrough

Changed a private method to protected in AbstractMessageProcessingFlowBase. Added an override in AbstractDoctorDeclarationMessageProcessingFlow that early-exits when sample reports are absent or have no tests; otherwise delegates to the superclass flow.

Changes

Cohort / File(s) Summary of changes
Visibility adjustment in base flow
sormas-api/.../processing/AbstractMessageProcessingFlowBase.java
Changed method visibility: doPickOrCreateSamplesFlow from private to protected; signature and behavior unchanged.
Doctor declaration early-exit override
sormas-api/.../processing/doctordeclaration/AbstractDoctorDeclarationMessageProcessingFlow.java
Added protected doPickOrCreateSamplesFlow override: checks sample reports; if none or no tests, returns provided flow immediately; otherwise calls superclass implementation. Added necessary imports.

Sequence Diagram(s)

sequenceDiagram
  actor ExternalMessageProcessor as Processor
  participant DoctorFlow as AbstractDoctorDeclarationMessageProcessingFlow
  participant BaseFlow as AbstractMessageProcessingFlowBase

  Processor->>DoctorFlow: doPickOrCreateSamplesFlow(...)
  alt No sample reports or reports without tests
    DoctorFlow-->>Processor: Return provided flow (completed)
  else Reports with tests
    DoctorFlow->>BaseFlow: super.doPickOrCreateSamplesFlow(...)
    BaseFlow-->>DoctorFlow: FlowThen result
    DoctorFlow-->>Processor: FlowThen result
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

I twitch my ears at guarded gates,
A hop reveals when flow abates—
No tests? I bounce right past the queue,
With carrots saved and logic true.
But when the samples call for checks,
I leap to super, no regrets.
Thump-thump! The path is clean and new.


📜 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 d918ad3 and e18b06b.

📒 Files selected for processing (2)
  • sormas-api/src/main/java/de/symeda/sormas/api/externalmessage/processing/AbstractMessageProcessingFlowBase.java (1 hunks)
  • sormas-api/src/main/java/de/symeda/sormas/api/externalmessage/processing/doctordeclaration/AbstractDoctorDeclarationMessageProcessingFlow.java (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
sormas-api/src/main/java/de/symeda/sormas/api/externalmessage/processing/doctordeclaration/AbstractDoctorDeclarationMessageProcessingFlow.java (2)
sormas-api/src/main/java/de/symeda/sormas/api/utils/dataprocessing/ProcessingResult.java (1)
  • ProcessingResult (22-56)
sormas-api/src/main/java/de/symeda/sormas/api/utils/dataprocessing/flow/FlowThen.java (1)
  • FlowThen (28-68)
🔇 Additional comments (4)
sormas-api/src/main/java/de/symeda/sormas/api/externalmessage/processing/AbstractMessageProcessingFlowBase.java (1)

258-258: LGTM! Appropriate visibility change to enable subclass customization.

The method visibility change from private to protected correctly enables the subclass AbstractDoctorDeclarationMessageProcessingFlow to override this method with custom pre-check logic.

sormas-api/src/main/java/de/symeda/sormas/api/externalmessage/processing/doctordeclaration/AbstractDoctorDeclarationMessageProcessingFlow.java (3)

22-24: LGTM! Required imports for the new method.

The new imports support the overridden method signature and implementation.


47-47: LGTM! Additional imports for sample report handling.

These imports are necessary for the sample report validation logic in the new method.

Also applies to: 58-58, 66-66


87-109: LGTM! Well-implemented early-exit logic for doctor declarations.

The method correctly implements the PR objective by adding pre-checks to prevent sample creation options from being displayed when no relevant samples are available. The logic flow is:

  1. Line 93: Uses getSampleReports() (non-null-safe) to detect cases where no sample reports were created during DD parsing
  2. Lines 95-98: Early exit when no sample reports exist
  3. Lines 101-105: Early exit when sample reports exist but contain no test reports
  4. Line 108: Delegates to superclass implementation when valid samples with tests are present

The implementation correctly addresses the issue described in the PR objectives where doctor declaration processing was always displaying sample creation options.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature-13294_doctor_declarations_xml_esante_adapter

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@raulbob raulbob merged commit 45fbef5 into development Aug 14, 2025
6 of 12 checks passed
@raulbob raulbob deleted the feature-13294_doctor_declarations_xml_esante_adapter branch August 14, 2025 07:31
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.

1 participant