Skip to content

Add null check to FlowSheetCustomizationService#2429

Open
sebastian-j-ibanez wants to merge 1 commit into
maintenancefrom
fix-1867-flowsheet-customization
Open

Add null check to FlowSheetCustomizationService#2429
sebastian-j-ibanez wants to merge 1 commit into
maintenancefrom
fix-1867-flowsheet-customization

Conversation

@sebastian-j-ibanez

@sebastian-j-ibanez sebastian-j-ibanez commented May 16, 2026

Copy link
Copy Markdown
Collaborator

Changes made

  • Add null check to FlowSheetCustomizationService.getScopeLevel().
  • Format doc comments.

Summary by Sourcery

Add a null-safe scope resolution for flowsheet customizations and tidy related service documentation and formatting.

Bug Fixes:

  • Prevent potential null pointer issues when determining a customization's scope level by checking for null demographic values.

Enhancements:

  • Rename method parameters for clarity and adjust formatting and Javadoc for improved readability in the flowsheet customization service.

Summary by cubic

Adds null-safety to scope resolution and archiving checks in FlowSheetCustomizationService to prevent NPEs. Ensures correct clinic/provider/patient detection even when fields are missing.

  • Bug Fixes

    • Add null checks in getScopeLevel() and handle null levels in getScopeLevelName() and checkCanArchive() (returns allowed when customization is null).
    • Scope rules: clinic when providerNo is empty and demographicNo is "0"; patient when demographicNo != "0".
  • Refactors

    • Rename parameters (cust -> custom) and clean up Javadoc and formatting.

Written for commit e24503b. Summary will update on new commits. Review in cubic

@sourcery-ai

sourcery-ai Bot commented May 16, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds a null-safe scope resolution in FlowSheetCustomizationService.getScopeLevel while applying minor documentation and formatting cleanups across the service.

File-Level Changes

Change Details Files
Harden scope resolution logic to handle null demographic numbers safely.
  • Update getScopeLevel to use a renamed parameter and guard the PATIENT branch with a null check on demographicNo before comparing to "0".
  • Adjust call sites and related methods to use the new parameter name consistently (custom instead of cust).
  • Ensure checkCanArchive uses the updated getScopeLevel signature and passes the correct customization instance through to CascadeCheckResult.blocked.
src/main/java/ca/openosp/openo/commn/service/FlowSheetCustomizationService.java
Normalize Javadoc and code formatting for readability and consistency.
  • Reformat Javadoc

    tags and line wrapping to standard multi-line style.

  • Align Javadoc @param spacing for better readability.
  • Reflow long constructor and method signatures across multiple lines and adjust indentation of DAO method calls.
src/main/java/ca/openosp/openo/commn/service/FlowSheetCustomizationService.java

Possibly linked issues

  • openosp openo sync #1862: PR updates getScopeLevel with a demographicNo null check, exactly matching the issue’s described fix.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sebastian-j-ibanez sebastian-j-ibanez self-assigned this May 16, 2026
@coderabbitai

coderabbitai Bot commented May 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: db85fdaf-5eb2-49d4-98f8-40f8d77a91e8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-1867-flowsheet-customization

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.

@sebastian-j-ibanez sebastian-j-ibanez added the type: maintenance Code refactoring, dependency updates label May 16, 2026
@qodo-code-review

Copy link
Copy Markdown

Review Summary by Qodo

Add null check and improve code formatting in FlowSheetCustomizationService

🐞 Bug fix ✨ Enhancement

Grey Divider

Walkthroughs

Description
• Add null check to getDemographicNo() in getScopeLevel() method
• Rename parameter cust to custom for consistency across methods
• Format JavaDoc comments for improved readability
• Align parameter documentation with consistent spacing
Diagram
flowchart LR
  A["getScopeLevel method"] -->|"Add null check"| B["Prevent NullPointerException"]
  C["Parameter naming"] -->|"Rename cust to custom"| D["Improved consistency"]
  E["JavaDoc formatting"] -->|"Align spacing"| F["Better readability"]
Loading

Grey Divider

File Changes

1. src/main/java/ca/openosp/openo/commn/service/FlowSheetCustomizationService.java 🐞 Bug fix +46/-32

Null check and code formatting improvements

• Add null check for getDemographicNo() in getScopeLevel() to prevent NullPointerException
• Rename parameter cust to custom in getScopeLevel(), getScopeLevelName(), and
 checkCanArchive() methods for naming consistency
• Reformat JavaDoc comments with proper line breaks and spacing alignment
• Align parameter documentation with consistent indentation across all methods

src/main/java/ca/openosp/openo/commn/service/FlowSheetCustomizationService.java


Grey Divider

Qodo Logo

@qodo-code-review

qodo-code-review Bot commented May 16, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (1)

Grey Divider


Remediation recommended

1. JavaDoc @param missing types 📘 Rule violation ⚙ Maintainability
Description
Modified JavaDoc @param tags list descriptions but omit the required data types, violating the
project JavaDoc tag rules. This reduces API clarity and can cause documentation drift during
migration/maintenance.
Code

src/main/java/ca/openosp/openo/commn/service/FlowSheetCustomizationService.java[R163-168]

+     * @param flowsheet     the flowsheet name
+     * @param measurement   the measurement name
+     * @param action        the action type (ADD, UPDATE, DELETE)
+     * @param providerNo    current provider number (empty string for clinic scope)
+     * @param demographicNo current demographic number ("0" for clinic/provider
+     *                      scope)
Evidence
PR Compliance ID 8 requires @param tags to include data types. The modified JavaDoc blocks for
several public methods include @param entries like @param flowsheet the flowsheet name and
@param custom the FlowSheetCustomization to check, which omit the data types in the tag text.

CLAUDE.md
src/main/java/ca/openosp/openo/commn/service/FlowSheetCustomizationService.java[163-168]
src/main/java/ca/openosp/openo/commn/service/FlowSheetCustomizationService.java[189-190]
src/main/java/ca/openosp/openo/commn/service/FlowSheetCustomizationService.java[219-221]
src/main/java/ca/openosp/openo/commn/service/FlowSheetCustomizationService.java[257-261]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Per the JavaDoc compliance rule, `@param` tags must include data types. The modified JavaDoc blocks list only parameter names and descriptions.

## Issue Context
This PR reformats JavaDoc and updates parameter naming; while touching these JavaDoc blocks, they should be brought into compliance with the required tag format.

## Fix Focus Areas
- src/main/java/ca/openosp/openo/commn/service/FlowSheetCustomizationService.java[163-168]
- src/main/java/ca/openosp/openo/commn/service/FlowSheetCustomizationService.java[189-190]
- src/main/java/ca/openosp/openo/commn/service/FlowSheetCustomizationService.java[219-221]
- src/main/java/ca/openosp/openo/commn/service/FlowSheetCustomizationService.java[257-261]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • In getScopeLevel, you now guard against a null demographicNo but still call "".equals(custom.getProviderNo()) without a null check; consider handling a null providerNo as well for consistency and to avoid potential NPEs.
  • If demographicNo can be null on FlowSheetCustomization, review other call sites that interpret scope (e.g., resolveCurrentScopeLevel and any DAO queries) to ensure they either never receive null or handle it consistently with the new logic.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `getScopeLevel`, you now guard against a null `demographicNo` but still call `"".equals(custom.getProviderNo())` without a null check; consider handling a null `providerNo` as well for consistency and to avoid potential NPEs.
- If `demographicNo` can be null on `FlowSheetCustomization`, review other call sites that interpret scope (e.g., `resolveCurrentScopeLevel` and any DAO queries) to ensure they either never receive null or handle it consistently with the new logic.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the FlowSheetCustomizationService by renaming parameters for clarity, updating Javadoc formatting, and introducing a null check for demographic numbers. Feedback was provided regarding the getScopeLevel method, which remains vulnerable to a NullPointerException if the custom object is null; a guard clause was suggested to improve robustness.

@LiamStanziani LiamStanziani left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 1 file (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

fix: add provider number null check

fix: add null check for flowsheet customization argument

fix: add more null checks
@sebastian-j-ibanez

Copy link
Copy Markdown
Collaborator Author

Just squashed the commits to make the git history cleaner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: maintenance Code refactoring, dependency updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix null demographicNo handling in FlowSheetCustomizationService.getScopeLevel()

2 participants