-
Notifications
You must be signed in to change notification settings - Fork 24
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:1817 - Bug Fix - validating plan employee assignments only for active update calls #1329
Conversation
WalkthroughThis pull request introduces a comprehensive enhancement to the plan service by adding support for additional fields across multiple components. The changes span from database schema modifications to data model updates, repository implementations, and validation logic. The primary focus is on extending the plan-related data structures to accommodate more flexible and dynamic information storage, specifically through the introduction of a new Changes
Sequence DiagramsequenceDiagram
participant Client
participant PlanService
participant PlanEnricher
participant PlanRepository
participant Database
Client->>PlanService: Create/Update Plan
PlanService->>PlanEnricher: Enrich Plan
PlanEnricher-->>PlanService: Generate UUIDs for Additional Fields
PlanService->>PlanRepository: Save Plan
PlanRepository->>Database: Insert Plan and Additional Fields
Database-->>PlanRepository: Confirm Insertion
PlanRepository-->>PlanService: Return Saved Plan
PlanService-->>Client: Return Plan Details
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (12)
🧰 Additional context used📓 Learnings (4)health-services/plan-service/src/main/java/digit/service/enrichment/PlanFacilityEnricher.java (1)
health-services/plan-service/src/main/java/digit/web/models/PlanDTO.java (1)
health-services/plan-service/src/main/java/digit/web/models/Plan.java (1)
health-services/plan-service/src/main/resources/db/migration/main/V20242112151500__plan_additional_field_create_ddl.sql (1)
🔇 Additional comments (12)
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caution
Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments.
Actionable comments posted: 3
🔭 Outside diff range comments (1)
health-services/plan-service/src/main/java/digit/web/models/AdditionalField.java (1)
Line range hint
31-33
: Consider making the value field type more flexible.If the database column type is changed to
text
, consider updating this field to useString
instead ofBigDecimal
to support different value types.- private BigDecimal value = null; + private String value = null;
🛑 Comments failed to post (3)
health-services/plan-service/src/main/java/digit/service/enrichment/PlanEnricher.java (1)
114-119:
⚠️ Potential issueAdd null check before forEach operation.
The code could throw NullPointerException if additionalFields is null.
Apply this diff to add null check:
- body.getPlan().getAdditionalFields().forEach(additionalFields -> { - if(ObjectUtils.isEmpty(additionalFields.getId())) { - UUIDEnrichmentUtil.enrichRandomUuid(additionalFields, "id"); - } - }); + if(!CollectionUtils.isEmpty(body.getPlan().getAdditionalFields())) { + body.getPlan().getAdditionalFields().forEach(additionalFields -> { + if(ObjectUtils.isEmpty(additionalFields.getId())) { + UUIDEnrichmentUtil.enrichRandomUuid(additionalFields, "id"); + } + }); + }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.// Generate uuid for new additionalFields if(!CollectionUtils.isEmpty(body.getPlan().getAdditionalFields())) { body.getPlan().getAdditionalFields().forEach(additionalFields -> { if(ObjectUtils.isEmpty(additionalFields.getId())) { UUIDEnrichmentUtil.enrichRandomUuid(additionalFields, "id"); } }); }
health-services/plan-service/src/main/java/digit/service/validator/PlanEmployeeAssignmentValidator.java (1)
320-322: 🧹 Nitpick (assertive)
LGTM! Consider adding braces for better readability.
The conditional validation for active records is logically correct and aligns with the PR objective. However, consider adding braces to the if statement for better readability and maintainability.
- if(planEmployeeAssignment.getActive()) - validateCampaignDetails(planConfigurations.get(0).getCampaignId(), rootTenantId, request); + if (planEmployeeAssignment.getActive()) { + validateCampaignDetails(planConfigurations.get(0).getCampaignId(), rootTenantId, request); + }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.// Validate campaign id and employee jurisdiction for active records if (planEmployeeAssignment.getActive()) { validateCampaignDetails(planConfigurations.get(0).getCampaignId(), rootTenantId, request); }
health-services/plan-service/src/main/java/digit/service/enrichment/PlanFacilityEnricher.java (1)
6-6: 🧹 Nitpick (assertive)
Consider using individual imports instead of wildcard.
While wildcard imports reduce the number of import statements, individual imports are generally preferred as they:
- Make dependencies explicit
- Avoid potential naming conflicts
- Improve code readability and maintainability
-import digit.web.models.*; +import digit.web.models.PlanFacility; +import digit.web.models.PlanFacilityRequest; +import digit.web.models.PlanFacilitySearchCriteria; +import digit.web.models.PlanFacilitySearchRequest;Committable suggestion skipped: line range outside the PR's diff.
Bug link: https://digit-discuss.atlassian.net/browse/HCMPRE-1817?atlOrigin=eyJpIjoiZDQ5Yzk0MTJmNzBkNGRlMjk4NTVhMzY0MzBiNTNjZjQiLCJwIjoiaiJ9
Summary by CodeRabbit
New Features
Database Changes
plan_additional_field
to store supplementary plan detailsImprovements