Skip to content
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

HCMPRE-492 Changes for plan estimation workflow integration #978

Closed
wants to merge 2 commits into from

Conversation

Priyanka-eGov
Copy link
Collaborator

@Priyanka-eGov Priyanka-eGov commented Oct 14, 2024

Ticket link - https://digit-discuss.atlassian.net/browse/HCMPRE-492

  1. Plan SEARCH API - add jurisdiction, assignee, status
  2. Plan CREATE/UPDATE API Validate employee assignment and jurisdiction
  3. Plan workflow integration
  4. Changes for converting role in PlanEmployeeSearchCriteria to List of role
  5. Moved validateUserInfo to commonUtils for reusability in Plan

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced plan management with new fields: status, assignee, boundaryAncestralPath, and workflow.
    • Expanded search capabilities with new criteria: status, assignee, and jurisdiction.
  • Improvements

    • Improved validation processes for plan creation and updates, including checks for user information and employee assignments.
    • Enhanced query-building logic to support multiple roles and additional filtering options.
  • Configuration Changes

    • New configuration entry for plan.estimation.approver.roles added to application properties.
  • Database Updates

    • New columns added to the plan table: boundary_ancestral_path, status, and assignee.

@Priyanka-eGov
Copy link
Collaborator Author

@CodeRabbit review

Copy link
Contributor

coderabbitai bot commented Oct 14, 2024

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

coderabbitai bot commented Oct 14, 2024

Walkthrough

This pull request introduces several modifications across multiple classes in the health-services/plan-service module. Key changes include the addition of new fields and constants for handling plan estimation roles, enhancements to query builders for improved filtering capabilities, and updates to validation logic. Notably, the Plan class now includes new properties, and the database schema for the plan table has been updated to accommodate these changes. Additionally, new methods have been introduced in the WorkflowService to manage workflow transitions related to plan status updates.

Changes

File Change Summary
.../Configuration.java Added a new public variable planEstimationApproverRoles (List) for configuration management.
.../ServiceConstants.java Introduced new constants for handling plan-employee assignments and JSON fields.
.../PlanEmployeeAssignmentQueryBuilder.java Modified buildPlanEmployeeAssignmentQuery to support multiple roles using an SQL IN clause.
.../PlanQueryBuilder.java Enhanced buildPlanSearchQuery with new conditions for status, assignee, and jurisdiction. Updated PLAN_QUERY to include boundary_ancestral_path.
.../PlanRowMapper.java Updated extractData method to include boundaryAncestralPath in the Plan object.
.../PlanService.java Added WorkflowService dependency and updated createPlan to invoke invokeWorkflowForStatusUpdate.
.../PlanValidator.java Modified constructor to include PlanEmployeeService and Configuration. Added validatePlanEmployeeAssignmentAndJurisdiction method for enhanced validation.
.../PlanConfigurationValidator.java Replaced validateUserInfo method with a call to commonUtil.validateUserInfo. Removed the original validateUserInfo method.
.../PlanEmployeeAssignmentValidator.java Updated validateRoleConflict to pass role as a Collections.singletonList.
.../WorkflowService.java Introduced new methods for workflow management: invokeWorkflowForStatusUpdate and createWorkflowRequest. Updated constructor to include CommonUtil.
.../CommonUtil.java Added validateUserInfo(RequestInfo requestInfo) method for user information validation.
.../Plan.java Added new properties: status, assignee, boundaryAncestralPath, and workflow to the Plan class.
.../PlanEmployeeAssignmentSearchCriteria.java Changed role field type from String to List<String>.
.../PlanSearchCriteria.java Added new fields: status, assignee, and jurisdiction to enhance search criteria.
.../application.properties Added plan.estimation.approver.roles property and reformatted role.map entry.
.../V20240910200000__plan_add_boundaryAncestralPath_ddl.sql Added new columns: boundary_ancestral_path, status, and assignee to the plan table in the database schema.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PlanService
    participant WorkflowService
    participant PlanValidator
    participant CommonUtil

    User->>PlanService: createPlan(PlanRequest)
    PlanService->>WorkflowService: invokeWorkflowForStatusUpdate(PlanRequest)
    WorkflowService->>CommonUtil: validateUserInfo(RequestInfo)
    PlanService->>PlanValidator: validatePlanCreate(PlanRequest)
    PlanValidator->>PlanEmployeeService: validatePlanEmployeeAssignmentAndJurisdiction(PlanRequest)
    PlanService-->>User: Plan created successfully
Loading

Possibly related PRs

Suggested reviewers

  • sathishp-eGov
  • kavi-egov
  • shashwat-egov

Poem

🐰 In the fields where plans do grow,
New roles and paths begin to flow.
With queries built to seek and find,
And workflows set to ease the mind.
A hop, a skip, a leap so bright,
Our plans take shape, oh what a sight! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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.

Documentation and Community

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

Copy link
Contributor

@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: 16

🧹 Outside diff range comments (2)
health-services/plan-service/src/main/java/digit/service/validator/PlanEmployeeAssignmentValidator.java (1)

Consistent Role Handling Needed in PlanEmployeeAssignment Class

The current implementation of getRole() returns a single role, while the recent change introduces a list-based approach using Collections.singletonList(). This inconsistency can lead to potential issues in role validation and processing.

  • Update the PlanEmployeeAssignment class to handle roles consistently as either single roles or lists across all methods.
  • Refactor related methods to align with the chosen approach for role handling.
🔗 Analysis chain

Line range hint 132-149: Consider reviewing the PlanEmployeeAssignment class for consistency

While the change to use Collections.singletonList() is appropriate, it highlights a potential inconsistency in how roles are handled throughout the codebase. The planEmployeeAssignment.getRole() method seems to return a single role, which may not be consistent with the list-based approach introduced by this change.

To ensure consistency across the codebase, please review the PlanEmployeeAssignment class and related classes. Consider updating them to use a list of roles instead of a single role if appropriate. You can use the following script to locate relevant files:

This will help identify areas where the role handling might need to be updated for consistency with the new list-based approach.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for PlanEmployeeAssignment class definition and usages
echo "Searching for PlanEmployeeAssignment class definition:"
rg --type java "class PlanEmployeeAssignment"

echo "\nSearching for getRole() method in PlanEmployeeAssignment:"
rg --type java "getRole\(\)" -C 5

echo "\nSearching for usages of getRole() method:"
rg --type java "\.getRole\(\)" -C 2

Length of output: 18591

health-services/plan-service/src/main/java/digit/service/validator/PlanConfigurationValidator.java (1)

Line range hint 1-638: Overall assessment: Good refactoring for improved maintainability.

The changes made to this file are consistent and improve code maintainability by centralizing the user info validation logic. The addition of the RequestInfo import and the use of commonUtil.validateUserInfo() in both validateCreate and validateUpdateRequest methods are positive changes.

To ensure the refactoring hasn't introduced any regressions:

  1. Verify the implementation of CommonUtil.validateUserInfo() as suggested earlier.
  2. Run the existing test suite to confirm that the validation behavior remains unchanged.
  3. Consider adding or updating tests to specifically cover the user info validation scenarios.
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between bc35618 and 7307c21.

📒 Files selected for processing (16)
  • health-services/plan-service/src/main/java/digit/config/Configuration.java (2 hunks)
  • health-services/plan-service/src/main/java/digit/config/ServiceConstants.java (3 hunks)
  • health-services/plan-service/src/main/java/digit/repository/querybuilder/PlanEmployeeAssignmentQueryBuilder.java (2 hunks)
  • health-services/plan-service/src/main/java/digit/repository/querybuilder/PlanQueryBuilder.java (3 hunks)
  • health-services/plan-service/src/main/java/digit/repository/rowmapper/PlanRowMapper.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/service/PlanService.java (3 hunks)
  • health-services/plan-service/src/main/java/digit/service/PlanValidator.java (5 hunks)
  • health-services/plan-service/src/main/java/digit/service/validator/PlanConfigurationValidator.java (3 hunks)
  • health-services/plan-service/src/main/java/digit/service/validator/PlanEmployeeAssignmentValidator.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/service/workflow/WorkflowService.java (5 hunks)
  • health-services/plan-service/src/main/java/digit/util/CommonUtil.java (2 hunks)
  • health-services/plan-service/src/main/java/digit/web/models/Plan.java (3 hunks)
  • health-services/plan-service/src/main/java/digit/web/models/PlanEmployeeAssignmentSearchCriteria.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/web/models/PlanSearchCriteria.java (2 hunks)
  • health-services/plan-service/src/main/resources/application.properties (1 hunks)
  • health-services/plan-service/src/main/resources/db/migration/main/V20240910200000__plan_add_boundaryAncestralPath_ddl.sql (1 hunks)
🧰 Additional context used
📓 Learnings (5)
health-services/plan-service/src/main/java/digit/config/ServiceConstants.java (2)
Learnt from: Saloni-eGov
PR: egovernments/health-campaign-services#906
File: health-services/plan-service/src/main/java/digit/config/ServiceConstants.java:189-193
Timestamp: 2024-09-26T11:17:36.420Z
Learning: When reviewing error messages in `ServiceConstants.java`, avoid suggesting changes to make them more descriptive unless specifically requested.
Learnt from: Saloni-eGov
PR: egovernments/health-campaign-services#906
File: health-services/plan-service/src/main/java/digit/config/ServiceConstants.java:189-193
Timestamp: 2024-10-08T20:11:07.772Z
Learning: When reviewing error messages in `ServiceConstants.java`, avoid suggesting changes to make them more descriptive unless specifically requested.
health-services/plan-service/src/main/java/digit/service/PlanValidator.java (2)
Learnt from: Priyanka-eGov
PR: egovernments/health-campaign-services#902
File: health-services/plan-service/src/main/java/digit/service/validator/PlanConfigurationValidator.java:553-553
Timestamp: 2024-09-25T08:41:31.377Z
Learning: The plan-service project is using Java 17.
Learnt from: Priyanka-eGov
PR: egovernments/health-campaign-services#902
File: health-services/plan-service/src/main/java/digit/service/validator/PlanConfigurationValidator.java:553-553
Timestamp: 2024-10-08T20:11:07.772Z
Learning: The plan-service project is using Java 17.
health-services/plan-service/src/main/java/digit/service/validator/PlanConfigurationValidator.java (2)
Learnt from: Priyanka-eGov
PR: egovernments/health-campaign-services#902
File: health-services/plan-service/src/main/java/digit/service/validator/PlanConfigurationValidator.java:553-553
Timestamp: 2024-09-25T08:41:31.377Z
Learning: The plan-service project is using Java 17.
Learnt from: Priyanka-eGov
PR: egovernments/health-campaign-services#902
File: health-services/plan-service/src/main/java/digit/service/validator/PlanConfigurationValidator.java:553-553
Timestamp: 2024-10-08T20:11:07.772Z
Learning: The plan-service project is using Java 17.
health-services/plan-service/src/main/java/digit/web/models/PlanSearchCriteria.java (1)
Learnt from: Priyanka-eGov
PR: egovernments/health-campaign-services#737
File: health-services/plan-service/src/main/java/digit/web/models/PlanConfigurationSearchCriteria.java:34-35
Timestamp: 2024-10-08T20:11:07.773Z
Learning: In the `PlanConfigurationSearchCriteria` class, the `status` field can be empty, and no validation constraints are required for this field.
health-services/plan-service/src/main/resources/db/migration/main/V20240910200000__plan_add_boundaryAncestralPath_ddl.sql (2)
Learnt from: Taniya-eGov
PR: egovernments/health-campaign-services#914
File: health-services/plan-service/src/main/resources/db/migration/main/V20240923113045__plan_facility_create_ddl.sql:8-8
Timestamp: 2024-09-27T06:09:27.293Z
Learning: In the `plan_facility_linkage` table, the `service_boundaries` column is intentionally defined as `varchar(2048)` and does not need to be changed to an array or JSONB.
Learnt from: Taniya-eGov
PR: egovernments/health-campaign-services#914
File: health-services/plan-service/src/main/resources/db/migration/main/V20240923113045__plan_facility_create_ddl.sql:8-8
Timestamp: 2024-10-08T20:11:07.772Z
Learning: In the `plan_facility_linkage` table, the `service_boundaries` column is intentionally defined as `varchar(2048)` and does not need to be changed to an array or JSONB.
🔇 Additional comments (31)
health-services/plan-service/src/main/resources/db/migration/main/V20240910200000__plan_add_boundaryAncestralPath_ddl.sql (1)

1-4: 🧹 Nitpick (assertive)

Approve changes with suggestions for improvement

The alterations to the plan table align with the PR objectives and enhance the data model. However, there are a few points to consider:

  1. For boundary_ancestral_path:

    • The use of TEXT is suitable for storing hierarchical data, but consider implementing a maximum length constraint if possible to prevent excessive data storage.
    • Since it's NOT NULL, ensure that all existing rows in the plan table can be populated with a valid value during migration.
  2. For status:

    • Consider adding a CHECK constraint to limit the possible values for the status field, ensuring data integrity.
  3. For assignee:

    • The nullable design is appropriate, allowing plans to be unassigned.
  4. General suggestion:

    • For the NOT NULL columns (boundary_ancestral_path and status), consider adding DEFAULT values to ease future insertions and prevent issues with existing data.

Here's a suggested refinement:

ALTER TABLE plan
ADD boundary_ancestral_path TEXT NOT NULL DEFAULT '',
ADD status character varying(64) NOT NULL DEFAULT 'draft',
ADD assignee varchar(64),
ADD CONSTRAINT check_status CHECK (status IN ('draft', 'active', 'completed', 'cancelled'));

This suggestion adds default values and a CHECK constraint for the status field. Adjust the status values in the CHECK constraint according to your specific requirements.

To ensure these changes don't conflict with existing data or constraints, please run the following verification script:

Please review the script output to ensure the changes are compatible with the existing data and schema.

health-services/plan-service/src/main/java/digit/web/models/PlanEmployeeAssignmentSearchCriteria.java (1)

41-41: Approve the change of role field type to List<String>

The modification of the role field from String to List<String> is consistent with the AI-generated summary and appears to be a valid change. This update allows for multiple roles to be assigned, which can provide more flexibility in role management.

However, there are a few considerations:

  1. Ensure that all code that uses this class is updated to handle a list of roles instead of a single role.
  2. Update any documentation or API specifications to reflect this change.
  3. Consider adding a null check and empty list check when processing this field to avoid potential NullPointerExceptions.

To ensure this change is consistently applied throughout the codebase, please run the following script:

This script will help identify areas of the codebase that might need updates due to this change.

✅ Verification successful

To ensure all usages of the role field in PlanEmployeeAssignmentSearchCriteria are correctly updated to handle a list of roles, please run the following scripts:


Verified the change of role field type to List<String>.

The role field in PlanEmployeeAssignmentSearchCriteria.java has been successfully updated to List<String>. No additional usages or manipulations of this field were found within the class, indicating that the change is safe and consistent across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for usages of PlanEmployeeAssignmentSearchCriteria and its role field

# Search for PlanEmployeeAssignmentSearchCriteria usage
echo "Searching for PlanEmployeeAssignmentSearchCriteria usage:"
rg --type java "PlanEmployeeAssignmentSearchCriteria" -C 3

# Search for specific usage of the role field
echo "\nSearching for specific usage of the role field:"
rg --type java "PlanEmployeeAssignmentSearchCriteria.*role" -C 3

# Search for potential places where single role might still be used
echo "\nSearching for potential places where single role might still be used:"
rg --type java "PlanEmployeeAssignmentSearchCriteria.*getRole\\(\\)" -C 3

Length of output: 17223


Script:

#!/bin/bash
# Description: Comprehensive search for all interactions with the 'role' field in PlanEmployeeAssignmentSearchCriteria

# Search for any assignments to the role field
echo "Searching for assignments to the role field:"
rg --type java "PlanEmployeeAssignmentSearchCriteria.*role\s*=" -C 3

# Search for any method calls that involve the role field, such as setters or custom methods
echo "\nSearching for method interactions with the role field:"
rg --type java "PlanEmployeeAssignmentSearchCriteria.*setRole|addRole|removeRole|updateRole" -C 3

# Search for any iterations or stream operations on the role field
echo "\nSearching for iterations or stream operations on the role field:"
rg --type java "PlanEmployeeAssignmentSearchCriteria.*role\.stream\(" -C 3

Length of output: 7209

health-services/plan-service/src/main/java/digit/web/models/PlanSearchCriteria.java (4)

3-3: LGTM: Import statement for List is appropriate.

The addition of import java.util.List; is necessary and correct for the new jurisdiction field.


42-43: LGTM: Status field added correctly.

The status field is appropriately added with the correct type and annotation. The absence of validation constraints aligns with the previous learning that the status field can be empty.


Line range hint 1-58: Overall, the changes to PlanSearchCriteria.java look good and align with the PR objectives.

The additions of status, assignee, and jurisdiction fields enhance the search criteria capabilities as intended. The implementation is clean and follows good practices. Consider the suggestions for potential validation improvements, particularly for the assignee and jurisdiction fields.


45-46: LGTM: Assignee field added correctly. Consider validation requirements.

The assignee field is appropriately added with the correct type and annotation. However, consider whether any validation constraints (e.g., @NotNull or @Size) should be applied to this field.

To verify the usage and potential validation requirements for the assignee field, you can run the following script:

health-services/plan-service/src/main/java/digit/web/models/Plan.java (2)

10-10: LGTM: Workflow import added correctly

The import for the Workflow class from org.egov.common.contract.models is correctly placed and aligns with the new workflow property in the Plan class.


75-77: LGTM: workflow property added correctly

The workflow property has been correctly added to the Plan class with appropriate @JsonProperty and @Valid annotations. The @Valid annotation ensures that the Workflow object itself will be validated, which is excellent for maintaining data integrity with nested objects.

The property type Workflow corresponds to the newly added import, ensuring consistency in the class structure.

health-services/plan-service/src/main/java/digit/config/Configuration.java (2)

9-10: LGTM: Import statement added correctly.

The import for java.util.List has been added appropriately to support the new field planEstimationApproverRoles.


25-26: New configuration field for plan estimation approver roles.

The addition of planEstimationApproverRoles aligns with the PR objectives for enhancing the plan estimation workflow. This field will allow the application to configure and access the list of roles that can approve plan estimations.

A few points to consider:

  1. Ensure that the corresponding property plan.estimation.approver.roles is defined in your application properties file.
  2. Document the expected format of this property (e.g., comma-separated list of role names).
  3. Consider adding a brief comment explaining the purpose of this field for future maintainers.

To ensure the property is correctly defined, let's check the application properties:

✅ Verification successful

Verified: plan.estimation.approver.roles is defined in application.properties.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the presence of plan.estimation.approver.roles in application properties

# Test: Search for the property in application.properties or application.yml files
rg --type yaml --type properties 'plan\.estimation\.approver\.roles' src/main/resources/

Length of output: 125


Script:

#!/bin/bash
# Description: Verify the presence of plan.estimation.approver.roles in application properties

# Test: Search for the property in application.properties or application.yml files
rg 'plan\.estimation\.approver\.roles' src/main/resources/application.{properties,yml}

Length of output: 274


Script:

#!/bin/bash
# Description: Recursively search for plan.estimation.approver.roles in the entire codebase

rg 'plan\.estimation\.approver\.roles' .

Length of output: 329

health-services/plan-service/src/main/java/digit/service/PlanService.java (4)

4-4: LGTM: Import statement added correctly.

The import for WorkflowService is appropriately placed and aligns with the new dependency introduced in the class.


25-26: LGTM: WorkflowService field added correctly.

The workflowService field is appropriately declared as private and follows the established naming convention in the class.


27-31: LGTM: Constructor updated correctly to include WorkflowService.

The constructor has been properly modified to include the new WorkflowService parameter. The new dependency is correctly assigned to the corresponding field while maintaining existing parameters and assignments.


Line range hint 1-95: Overall, the changes look good with a minor suggestion for improvement.

The integration of WorkflowService into the PlanService class has been implemented correctly. The new dependency is properly injected, and the createPlan method has been updated to include the workflow status update. The code structure and style remain consistent with the existing implementation.

The only suggestion for improvement is to add error handling for the workflow invocation in the createPlan method, as mentioned in the previous comment. This will enhance the robustness of the service.

health-services/plan-service/src/main/java/digit/repository/querybuilder/PlanEmployeeAssignmentQueryBuilder.java (1)

9-9: LGTM: Import statement addition is appropriate.

The addition of java.util.LinkedHashSet import is consistent with the changes in the query building logic. LinkedHashSet is a good choice as it maintains insertion order, which can be important for consistent query generation.

health-services/plan-service/src/main/java/digit/util/CommonUtil.java (2)

9-12: LGTM: New imports are correctly added and necessary.

The new imports for RequestInfo and ObjectUtils are correctly placed and are required for the new validateUserInfo method. They follow the existing import structure of the file.


148-160: LGTM: New validateUserInfo method is well-implemented.

The new method is correctly implemented and serves a clear purpose. It follows existing coding conventions and includes proper error handling with both logging and exception throwing.

A minor note:

  • Ensure that the constants USERINFO_MISSING_CODE and USERINFO_MISSING_MESSAGE are defined in the appropriate constants file (likely ServiceConstants.java).

To verify the constants, please run the following script:

✅ Verification successful

LGTM: validateUserInfo method and related constants are properly implemented.

The new method is correctly implemented and serves a clear purpose. It follows existing coding conventions and includes proper error handling with both logging and exception throwing.

The constants USERINFO_MISSING_CODE and USERINFO_MISSING_MESSAGE are properly defined in ServiceConstants.java.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that USERINFO_MISSING_CODE and USERINFO_MISSING_MESSAGE constants are defined.

# Test: Search for the constants in the ServiceConstants file
rg --type java 'USERINFO_MISSING_(CODE|MESSAGE)' health-services/plan-service/src/main/java/digit/config/ServiceConstants.java

Length of output: 301

health-services/plan-service/src/main/java/digit/repository/rowmapper/PlanRowMapper.java (1)

57-57: LGTM: New field added correctly.

The addition of the boundaryAncestralPath field to the Plan object is implemented correctly and follows the existing pattern for mapping database columns to object properties.

To ensure consistency across the codebase, please run the following script to check for usage of the new boundaryAncestralPath field:

This script will help identify if the new field is consistently used across the codebase and if there are any places where it might have been missed.

✅ Verification successful

Verified: boundaryAncestralPath is consistently used across the codebase.

The boundaryAncestralPath field has been correctly added to the Plan object and is consistently referenced in both Java and SQL files. No missing usages or inconsistencies were found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistent usage of the new boundaryAncestralPath field

# Search for references to boundaryAncestralPath in Java files
echo "Searching for references to boundaryAncestralPath:"
rg --type java 'boundaryAncestralPath'

# Search for references to plan_boundary_ancestral_path in SQL files
echo "Searching for references to plan_boundary_ancestral_path in SQL files:"
rg --type sql 'plan_boundary_ancestral_path'

# Search for potential missed usages of the new field
echo "Checking for potential missed usages:"
rg --type java 'class Plan' -A 20 | grep -v 'boundaryAncestralPath'

Length of output: 120034

health-services/plan-service/src/main/java/digit/config/ServiceConstants.java (3)

100-101: LGTM: New constants for plan-employee assignment not found error.

The new constants PLAN_EMPLOYEE_ASSIGNMENT_NOT_FOUND_CODE and PLAN_EMPLOYEE_ASSIGNMENT_NOT_FOUND_MESSAGE are well-defined and follow the existing naming conventions. They provide a clear error message for cases where a plan-employee assignment is not found for a given boundary.


258-258: LGTM: New constant for boundary ancestral path JSON field.

The new constant JSON_FIELD_BOUNDARY_ANCESTRAL_PATH is well-defined and follows the existing naming conventions for JSON field constants. It will be useful for handling hierarchical boundary data in JSON format.


272-273: LGTM: New constant for plan estimation business service.

The new constant PLAN_ESTIMATION_BUSINESS_SERVICE is well-defined and follows the existing naming conventions for business service constants. It will be useful for workflow integration related to plan estimation. The added empty line after the constant improves readability.

health-services/plan-service/src/main/java/digit/service/validator/PlanConfigurationValidator.java (3)

19-19: LGTM: Import statement added for RequestInfo.

The addition of the import statement for RequestInfo is appropriate, as it's likely being used in the updated user info validation process.


481-481: LGTM: Consistent use of CommonUtil for user info validation.

This change is consistent with the modification made in the validateCreate method. It reinforces the centralization of user info validation logic in the CommonUtil class.

Please refer to the previous comment regarding the verification of the CommonUtil.validateUserInfo() method.


93-93: LGTM: User info validation moved to CommonUtil.

The change to use commonUtil.validateUserInfo() instead of a local method is a good refactoring that promotes code reuse. This change simplifies the PlanConfigurationValidator class and centralizes the user info validation logic.

Please ensure that the CommonUtil class's validateUserInfo method provides at least the same level of validation as the original method. You can verify this by running the following command:

health-services/plan-service/src/main/java/digit/service/workflow/WorkflowService.java (3)

36-41: Constructor updated to include CommonUtil dependency.

The constructor now includes CommonUtil as a parameter and assigns it to the class member commonUtil. This is appropriate for the added functionality that relies on CommonUtil.


66-75: Method invokeWorkflowForStatusUpdate correctly integrates workflow for PlanRequest.

The method appropriately handles the workflow integration for PlanRequest objects, checking for empty workflows and updating the plan status based on the workflow response.


128-146: Method createWorkflowRequest constructs ProcessInstanceRequest for PlanRequest successfully.

The method correctly builds a ProcessInstance using details from the Plan and returns a ProcessInstanceRequest. The use of the builder pattern enhances readability and maintainability.

health-services/plan-service/src/main/java/digit/repository/querybuilder/PlanQueryBuilder.java (2)

110-114: Verify the Data Type of assignee

Ensure that the assignee field in planSearchCriteria.getAssignee() matches the data type expected by the database schema. If assignee is intended to be a list or an array of IDs, the current implementation may need to handle multiple values.

Would you like assistance in verifying the data types and updating the query accordingly?


116-124: ⚠️ Potential issue

Correct the SQL Syntax for Jurisdiction Filtering

The SQL syntax used for filtering by jurisdiction may lead to errors. Specifically, the way you're constructing the array and using the && operator might not yield the intended results. The && operator checks for overlap between two arrays in PostgreSQL.

Apply this diff to correct the query construction:

-        builder.append(" ARRAY [ ")
-                .append(queryUtil.createQuery(planSearchCriteria.getJurisdiction().size()))  // Create placeholders (?, ?, ?...)
-                .append(" ]::text[] ");
-
-        builder.append(" && string_to_array(boundary_ancestral_path, '|') ");
+        builder.append(" string_to_array(boundary_ancestral_path, '|') && ARRAY[ ")
+                .append(queryUtil.createQuery(planSearchCriteria.getJurisdiction().size()))  // Create placeholders (?, ?, ?...)
+                .append(" ]::text[] ");

This rearranges the query to compare the boundary_ancestral_path array with the jurisdiction array correctly.

Here's a script to verify the SQL syntax correctness:

This script checks if the array comparison works as expected.

health-services/plan-service/src/main/java/digit/service/PlanValidator.java (2)

88-89: Confirm the intentional commenting out of validateCampaignId(campaignResponse);

The call to validateCampaignId(campaignResponse); has been commented out in the validatePlanCreate method. Please verify if this is intentional. Skipping this validation might allow invalid campaign IDs to be processed.


479-480: Verify correct retrieval of plan estimation approver roles

When building PlanEmployeeAssignmentSearchCriteria, the roles are retrieved using config.getPlanEstimationApproverRoles(). Please ensure that this method returns the expected list of roles and that it aligns with the roles used in the planEmployeeService search logic.

If necessary, run the following script to verify the roles:

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