Skip to content

Conversation

@ravishanigarapu
Copy link
Contributor

@ravishanigarapu ravishanigarapu commented Mar 21, 2025

πŸ“‹ Description

JIRA ID: AMM-1217

Please provide a summary of the change and the motivation behind it. Include relevant context and details.


βœ… Type of Change

  • 🐞 Bug fix (non-breaking change which resolves an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • πŸ”₯ Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • πŸ›  Refactor (change that is neither a fix nor a new feature)
  • βš™οΈ Config change (configuration file or build script updates)
  • πŸ“š Documentation (updates to docs or readme)
  • πŸ§ͺ Tests (adding new or updating existing tests)
  • 🎨 UI/UX (changes that affect the user interface)
  • πŸš€ Performance (improves performance)
  • 🧹 Chore (miscellaneous changes that don't modify src or test files)

ℹ️ Additional Information

Please describe how the changes were tested, and include any relevant screenshots, logs, or other information that provides additional context.

Summary by CodeRabbit

  • Chores

    • Updated system dependencies and build plugins for improved stability and performance.
  • New Features

    • Enhanced beneficiary data retrieval to present a more comprehensive, detailed view.
    • Introduced streamlined query options for efficient filtering and access to beneficiary information.
    • Added new query methods for more specific retrieval of beneficiary service mappings.

@coderabbitai
Copy link

coderabbitai bot commented Mar 21, 2025

Walkthrough

This pull request updates the project's dependency versions in the pom.xml file and adjusts the annotation processor configuration. It also introduces new query methods in both the BenMappingRepo and BenServiceMappingRepo interfaces. Additionally, the IdentityService’s getBeneficiariesDTONew method is refactored to retrieve and aggregate additional beneficiary data from multiple repositories before returning the enriched mapping object.

Changes

File(s) Change Summary
pom.xml Updated dependency versions: org.projectlombok from 1.18.22 to 1.18.36, maven-compiler-plugin from 3.12.1 to 3.14.0; adjusted annotationProcessorPaths property.
src/.../repo/BenFamilyMappingRepo.java
src/.../repo/BenIdentityRepo.java
Added a blank line at the end of BenFamilyMappingRepo and a new line at the end of BenIdentityRepo.
src/.../repo/BenMappingRepo.java Added new query method getWithVanSerialNoVanID to retrieve MBeneficiarymapping based on parameters vanSerialNo and vanID.
src/.../repo/BenServiceMappingRepo.java Added new query method getWithVanSerialNoVanID to retrieve a list of MBeneficiaryservicemapping based on parameters benMapId and vanID.
src/.../service/IdentityService.java Refactored getBeneficiariesDTONew method to call additional repositories (address, consent, contact, detail, regId, account, image) and populate extra fields.

Suggested reviewers

  • drtechie
  • helenKaryamsetty

Poem

Oh, I've hopped through lines of code so bright,
Updating versions, making plugins right.
New queries bloom like carrots in the field,
Each repository call a fresh, fun yield.
With my twitching nose, I cheer every change in sight! πŸ₯•πŸ‡


πŸ“œ 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 ecabd88 and 4030d56.

πŸ“’ Files selected for processing (1)
  • src/main/java/com/iemr/common/identity/repo/BenFamilyMappingRepo.java (1 hunks)
βœ… Files skipped from review due to trivial changes (1)
  • src/main/java/com/iemr/common/identity/repo/BenFamilyMappingRepo.java
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build_and_analyse
  • GitHub Check: Analyze (java)

πŸͺ§ 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

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

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

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

πŸ”­ Outside diff range comments (1)
src/main/java/com/iemr/common/identity/service/IdentityService.java (1)

575-622: πŸ› οΈ Refactor suggestion

⚠️ Potential issue

Risk of overwriting newly-set fields in getBeneficiariesDTONew.
Within this method, lines 578–580 set key attributes (BenMapId, CreatedBy, CreatedDate) on a new mapping instance, but line 581 reassigns mapping to the result of mappingRepo.getWithVanSerialNoVanID(...), discarding those newly-set fields. This can cause inconsistent data initialization. Consider restructuring the logic so the final mapping object retains all intended values. For example, fetch the existing entity first, then set any additional fields:

 private MBeneficiarymapping getBeneficiariesDTONew(Object[] benMapArr) {
     MBeneficiarymapping mapping = mappingRepo.getWithVanSerialNoVanID(
-        getBigIntegerValueFromObject(benMapArr[9]),
-        (Integer) benMapArr[8]
-    );
+        getBigIntegerValueFromObject(benMapArr[9]),
+        (Integer) benMapArr[8]
+    );
+    // If no DB record is found, create a new one.
+    if (mapping == null) {
+        mapping = new MBeneficiarymapping();
+    }

     if (benMapArr != null && benMapArr.length == 12
         && benMapArr[8] != null && benMapArr[9] != null) {
-        mapping.setBenMapId(getBigIntegerValueFromObject(benMapArr[0]));
-        mapping.setCreatedBy(String.valueOf(benMapArr[10]));
-        mapping.setCreatedDate((Timestamp) benMapArr[11]);
-        mapping = mappingRepo.getWithVanSerialNoVanID(
-            getBigIntegerValueFromObject(benMapArr[9]),
-            (Integer) benMapArr[8]
-        );
+        // Now safely set fields after retrieving or creating the entity
+        mapping.setBenMapId(getBigIntegerValueFromObject(benMapArr[0]));
+        mapping.setCreatedBy(String.valueOf(benMapArr[10]));
+        mapping.setCreatedDate((Timestamp) benMapArr[11]);

         // ...rest of the logic
     }
     return mapping;
 }
🧹 Nitpick comments (1)
src/main/java/com/iemr/common/identity/repo/BenMappingRepo.java (1)

142-144: Addition of simplified query method

This new method provides a streamlined way to fetch a MBeneficiarymapping entity without all the complex joins present in the existing getMapping method (lines 127-140). It's a good performance optimization for cases where only the basic entity is needed.

Consider documenting the difference between this simpler method and the existing getMapping method to help other developers choose the appropriate one based on their data needs.

Add a comment above the method explaining when to use this method versus the full getMapping method that includes all joins:

+/**
+ * Retrieves a basic MBeneficiarymapping entity without additional joins.
+ * Use this method when only the core mapping data is needed for better performance.
+ * For a complete entity with all related data, use getMapping() instead.
+ */
@Query("SELECT a FROM MBeneficiarymapping a WHERE a.vanSerialNo =:vanSerialNo AND a.vanID =:vanID ")
MBeneficiarymapping getWithVanSerialNoVanID(@Param("vanSerialNo") BigInteger vanSerialNo,
        @Param("vanID") Integer vanID);
πŸ“œ Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 7e746a0 and ff301e4.

πŸ“’ Files selected for processing (6)
  • pom.xml (2 hunks)
  • src/main/java/com/iemr/common/identity/repo/BenFamilyMappingRepo.java (2 hunks)
  • src/main/java/com/iemr/common/identity/repo/BenIdentityRepo.java (2 hunks)
  • src/main/java/com/iemr/common/identity/repo/BenMappingRepo.java (2 hunks)
  • src/main/java/com/iemr/common/identity/repo/BenServiceMappingRepo.java (1 hunks)
  • src/main/java/com/iemr/common/identity/service/IdentityService.java (2 hunks)
🧰 Additional context used
🧠 Learnings (4)
src/main/java/com/iemr/common/identity/repo/BenIdentityRepo.java (1)
Learnt from: ravishanigarapu
PR: PSMRI/Identity-API#85
File: src/main/java/com/iemr/common/identity/repo/BenMappingRepo.java:125-138
Timestamp: 2025-03-21T08:17:59.398Z
Learning: In the Identity-API project, tables involved in beneficiary mapping queries (MBeneficiaryregidmapping, MBeneficiarycontact, MBeneficiarydetail, MBeneficiaryaddress, MBeneficiaryconsent, MBeneficiaryImage, MBeneficiaryAccount, MBeneficiaryidentity, MBeneficiaryfamilymapping, MBeneficiaryservicemapping) have indexes created on join columns (vanID, vanSerialNo) to optimize query performance.
src/main/java/com/iemr/common/identity/repo/BenFamilyMappingRepo.java (1)
Learnt from: ravishanigarapu
PR: PSMRI/Identity-API#85
File: src/main/java/com/iemr/common/identity/repo/BenMappingRepo.java:125-138
Timestamp: 2025-03-21T08:17:59.398Z
Learning: In the Identity-API project, tables involved in beneficiary mapping queries (MBeneficiaryregidmapping, MBeneficiarycontact, MBeneficiarydetail, MBeneficiaryaddress, MBeneficiaryconsent, MBeneficiaryImage, MBeneficiaryAccount, MBeneficiaryidentity, MBeneficiaryfamilymapping, MBeneficiaryservicemapping) have indexes created on join columns (vanID, vanSerialNo) to optimize query performance.
src/main/java/com/iemr/common/identity/repo/BenMappingRepo.java (1)
Learnt from: ravishanigarapu
PR: PSMRI/Identity-API#85
File: src/main/java/com/iemr/common/identity/repo/BenMappingRepo.java:125-138
Timestamp: 2025-03-21T08:17:59.398Z
Learning: In the Identity-API project, tables involved in beneficiary mapping queries (MBeneficiaryregidmapping, MBeneficiarycontact, MBeneficiarydetail, MBeneficiaryaddress, MBeneficiaryconsent, MBeneficiaryImage, MBeneficiaryAccount, MBeneficiaryidentity, MBeneficiaryfamilymapping, MBeneficiaryservicemapping) have indexes created on join columns (vanID, vanSerialNo) to optimize query performance.
src/main/java/com/iemr/common/identity/service/IdentityService.java (1)
Learnt from: ravishanigarapu
PR: PSMRI/Identity-API#85
File: src/main/java/com/iemr/common/identity/repo/BenMappingRepo.java:125-138
Timestamp: 2025-03-21T08:17:59.398Z
Learning: In the Identity-API project, tables involved in beneficiary mapping queries (MBeneficiaryregidmapping, MBeneficiarycontact, MBeneficiarydetail, MBeneficiaryaddress, MBeneficiaryconsent, MBeneficiaryImage, MBeneficiaryAccount, MBeneficiaryidentity, MBeneficiaryfamilymapping, MBeneficiaryservicemapping) have indexes created on join columns (vanID, vanSerialNo) to optimize query performance.
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (java)
  • GitHub Check: Build_and_analyse
πŸ”‡ Additional comments (5)
src/main/java/com/iemr/common/identity/repo/BenServiceMappingRepo.java (1)

86-88: New query method added for simplified beneficiary service lookup

The new method provides a direct way to look up beneficiary service mappings by benMapId and vanID. This is a good addition for more focused queries.

Based on the retrieved learnings, ensure that appropriate indexes exist on the vanID and benMapId columns to optimize query performance.

src/main/java/com/iemr/common/identity/repo/BenMappingRepo.java (1)

36-36: New import added for MBeneficiaryservicemapping

This import supports the broader beneficiary mapping changes across the codebase.

pom.xml (3)

29-29: Bump Lombok version.
Upgrading to version 1.18.36 ensures the project benefits from the latest Lombok fixes and features.


295-295: Update Maven Compiler Plugin.
Switching from 3.12.1 to 3.14.0 is a reasonable move to keep up with the latest compiler improvements. Please confirm compilation runs smoothly.


303-303: Use consistent Lombok property.
Aligning the annotation processor’s version with ${org.projectlombok.version} ensures a single property reference across the POM.

@sonarqubecloud
Copy link

@helenKaryamsetty helenKaryamsetty merged commit 76dafa6 into PSMRI:develop Mar 25, 2025
7 checks passed
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.

2 participants