Skip to content

Conversation

vanitha1822
Copy link
Contributor

@vanitha1822 vanitha1822 commented Jul 6, 2025

πŸ“‹ Description

JIRA ID:

AMM-1411

Add JsonProperty to map the fields with request body to fetch the values for income status, education and occupation

βœ… Type of Change

  • 🐞 Bug fix (non-breaking change which resolves an issue)

Summary by CodeRabbit

  • Bug Fixes

    • Improved the handling of occupation and education information in beneficiary details, ensuring more accurate data is included when certain fields are missing or null.
  • Style

    • Cleaned up unused imports and improved code formatting for better readability.
  • New Features

    • Updated how certain beneficiary fields appear in exported data to use more descriptive property names.

…n getting the value for income, education and occupation
Copy link
Contributor

coderabbitai bot commented Jul 6, 2025

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.

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

Walkthrough

The changes update JSON serialization in the BeneficiaryModel by annotating three fields with specific property names. In the RegisterBenificiaryServiceImpl class, the logic for setting occupation and education fields in demographic DTOs is refined to use a prioritized fallback approach, and some minor formatting and import cleanups are made.

Changes

File(s) Change Summary
src/main/java/com/iemr/common/model/beneficiary/BeneficiaryModel.java Added @JsonProperty annotations to occupationName, incomeStatus, and education fields.
src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java Refined logic for setting occupation/education in demographic DTOs; removed unused import; formatting.

Sequence Diagram(s)

sequenceDiagram
    participant Controller
    participant RegisterBenificiaryServiceImpl
    participant BeneficiaryModel
    participant DTO

    Controller->>RegisterBenificiaryServiceImpl: updateBenificiary(model)
    RegisterBenificiaryServiceImpl->>BeneficiaryModel: Access occupation, education fields
    alt occupation is present
        RegisterBenificiaryServiceImpl->>DTO: Set occupation from model
    else if demographic.occupation present
        RegisterBenificiaryServiceImpl->>DTO: Set occupation from demographic
    else
        RegisterBenificiaryServiceImpl->>DTO: Set occupation from occupationName
    end
    alt education is present
        RegisterBenificiaryServiceImpl->>DTO: Set education from model
    else if demographic.educationName present
        RegisterBenificiaryServiceImpl->>DTO: Set education from demographic
    end
    RegisterBenificiaryServiceImpl->>Controller: Return result
Loading

Suggested reviewers

  • ravishanigarapu

Poem

A hop and a skip, some JSON tags in place,
Fields with new names now join the race.
Logic refined, with fallbacks so neat,
Occupations and schoolingβ€”no longer incomplete!
The code hops forward, with carrots in sight,
Another small patch makes serialization right. πŸ₯•


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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

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

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 generate sequence diagram to generate a sequence diagram of the changes in this 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.

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.

@vanitha1822 vanitha1822 self-assigned this Jul 6, 2025
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: 2

πŸ“œ Review details

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

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 46195c5 and 90c39fc.

πŸ“’ Files selected for processing (2)
  • src/main/java/com/iemr/common/model/beneficiary/BeneficiaryModel.java (2 hunks)
  • src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java (3 hunks)
🧰 Additional context used
🧠 Learnings (2)
πŸ““ Common learnings
Learnt from: srishtigrp78
PR: PSMRI/Common-API#166
File: src/main/java/com/iemr/common/service/grievance/GrievanceHandlingServiceImpl.java:422-431
Timestamp: 2025-03-03T05:44:08.973Z
Learning: In the Common-API project, JsonNode from Jackson library has been found to not work properly for certain JSON parsing tasks, so JSONObject is preferred in those cases, particularly in the GrievanceHandlingServiceImpl class.
src/main/java/com/iemr/common/model/beneficiary/BeneficiaryModel.java (1)
Learnt from: srishtigrp78
PR: PSMRI/Common-API#166
File: src/main/java/com/iemr/common/service/grievance/GrievanceHandlingServiceImpl.java:422-431
Timestamp: 2025-03-03T05:44:08.973Z
Learning: In the Common-API project, JsonNode from Jackson library has been found to not work properly for certain JSON parsing tasks, so JSONObject is preferred in those cases, particularly in the GrievanceHandlingServiceImpl class.
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: style-check / checkstyle
  • GitHub Check: Build
  • GitHub Check: Package-test
  • GitHub Check: Analyze (java)
πŸ”‡ Additional comments (4)
src/main/java/com/iemr/common/model/beneficiary/BeneficiaryModel.java (2)

38-38: Good addition for JSON property mapping.

The import of @JsonProperty is correctly added to support the field annotations below.


215-215: Proper JSON property mapping implemented.

The @JsonProperty annotations correctly map the fields to their expected JSON property names:

  • occupationName β†’ "occupationOther"
  • incomeStatus β†’ "incomeName"
  • education β†’ "educationQualificationName"

This addresses the field value fetching issue mentioned in the PR objectives.

Also applies to: 220-220, 227-227

src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java (2)

123-123: Minor typo fix in comment.

Good catch fixing the typo from "OtherFedields" to "OtherFields" in the comment.


143-157: Robust fallback mechanism implemented.

The prioritized fallback approach for occupation and education fields is well-designed and addresses the field value fetching issue mentioned in the PR. The logic correctly handles cases where primary values might be null by falling back to demographic fields and then to alternative field names.

Also applies to: 220-234

@vanitha1822 vanitha1822 requested review from vishwab1 and drtechie July 7, 2025 05:04
@Expose
private String occupation;
@Expose
@JsonProperty("incomeName")
Copy link
Member

Choose a reason for hiding this comment

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

I didn't follow this. The string below looks different?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't follow this. The string below looks different?
Yes. For these fields income, occupation and education, there is mismatch in the json property and entity names. So to tag those used 'JsonProperty'

@vanitha1822 vanitha1822 changed the base branch from develop to release-3.6.0 July 14, 2025 08:20
Copy link

@vanitha1822 vanitha1822 requested a review from drtechie July 14, 2025 08:33
@vanitha1822 vanitha1822 merged commit 8ced854 into release-3.6.0 Jul 16, 2025
2 checks passed
@vanitha1822 vanitha1822 deleted the nd/vs/mmuregistration branch July 16, 2025 10:16
snehar-nd pushed a commit that referenced this pull request Aug 25, 2025
* Fix the issue in fetching the value for fields (#257)

* fix: Add jsonProperty to map with the request body to fix the issue in getting the value for income, education and occupation

* fix: remove commented code

* Update version in pom.xml to 3.4.0

* Update pom.xml

* Add ServerAuthorization key in allow headers (#275)

* fix: add serverAuthorization

* fix: add console

* fix: correct the spelling

* Nd/vs/token bengen issue (#280)

* fix: add useragent as java to skip the token

* fix: add logger

* fix: add logger

---------

Co-authored-by: Vanitha S <116701245+vanitha1822@users.noreply.github.com>
Co-authored-by: Amoghavarsh <93114621+5Amogh@users.noreply.github.com>
Co-authored-by: Mithun James <drtechie@users.noreply.github.com>
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