-
Notifications
You must be signed in to change notification settings - Fork 31
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
AMM-1076 and AMM-1078 #146
Conversation
WalkthroughThe pull request introduces several enhancements to the beneficiary management system, focusing on improving data capture and processing. Changes span multiple components, including phone number handling, demographic data management, and request interceptor configurations. The modifications primarily involve adding new fields for beneficiary details, updating data mapping processes, and refining system interceptors to handle specific request types more flexibly. Changes
Poem
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
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
π§Ή Nitpick comments (6)
src/main/java/com/iemr/common/controller/nhmdashboard/NHMDetailCallReportScheduler.java (2)
65-67
: Consolidate repeated phone number preprocessing.Currently, the phone number preprocessing (removal of leading zeros) is handled inline. Consider extracting this logic into a helper method to avoid duplication and to ensure consistency across different parts of the codebase.
156-159
: Avoid duplication of phone number parsing logic.This block repeats the same phone number trimming logic. Calling a shared helper method (as suggested above) can reduce the risk of errors and make the code more maintainable.
src/main/java/com/iemr/common/service/beneficiary/IEMRSearchUserServiceImpl.java (1)
381-382
: Consider validating the newly set fields.
Ifeducation
andincomeStatus
are restricted to a set of valid values, adding a lightweight validation or enumeration would reduce potential data inconsistencies.src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java (1)
133-154
: Guard Against Confused Fallback LogicIn
setDemographicDetails(...)
, the fallback checks for different religion fields (beneficiaryDetails.getReligion()
,.getI_bendemographics().getReligion()
,.getI_bendemographics().getReligionName()
) may cause confusion or data inconsistency if these fields differ. Consider clarifying or documenting the priority of these fields to ensure the correct value is always set.src/main/java/com/iemr/common/model/beneficiary/BeneficiaryModel.java (2)
216-217
: Clarify Usage ofoccupation
vs.occupationName
Having both
occupation
andoccupationName
can cause confusion or data mismatches. Provide clear documentation or rename one field to differentiate raw IDs or codes from user-friendly labels.
224-225
: Avoid Potential Redundancy ineducation
FieldsSimilar to occupation, confirm whether
education
vs.educationName
serve distinct purposes. If not, consider consolidating or clarifying these fields.
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
π Files selected for processing (7)
src/main/java/com/iemr/common/controller/nhmdashboard/NHMDetailCallReportScheduler.java
(2 hunks)src/main/java/com/iemr/common/dto/identity/CommonIdentityDTO.java
(1 hunks)src/main/java/com/iemr/common/model/beneficiary/BeneficiaryModel.java
(2 hunks)src/main/java/com/iemr/common/repository/report/CallReportRepo.java
(1 hunks)src/main/java/com/iemr/common/service/beneficiary/IEMRSearchUserServiceImpl.java
(1 hunks)src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java
(3 hunks)src/main/java/com/iemr/common/utils/http/HTTPRequestInterceptor.java
(1 hunks)
π Additional comments (7)
src/main/java/com/iemr/common/utils/http/HTTPRequestInterceptor.java (1)
90-92
: Ensure appropriateness of skipping authentication on these endpoints.These cases disable validation for
index.html
,swagger-initializer.js
, andswagger-config
. Confirm whether these endpoints or assets must be publicly accessible. If any of them could expose sensitive data or become an attack surface, consider enforcing some level of protection.src/main/java/com/iemr/common/service/beneficiary/IEMRSearchUserServiceImpl.java (2)
375-375
: Nice usage of null checks to avoid NullPointerExceptions.
The explicit check forbeneficiaryModel
and its nested object helps prevent runtime errors.
377-380
: Clarify the distinction between religion & religionName and occupation & occupationName.
Both field pairs are currently set to the same value. It might be more maintainable and less confusing if each pair held distinct data (e.g., a code vs. a descriptive label).src/main/java/com/iemr/common/dto/identity/CommonIdentityDTO.java (1)
154-154
: Ensure Consistent Usage ofreligionName
The addition of the
religionName
field is straightforward and enhances clarity. Verify that the new field is consistently set across the codebase, particularly within database operations, to prevent mismatches or null references if other fields (likereligion
) take precedence.src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java (2)
117-118
: Centralization of Demographic LogicCalling
setDemographicDetails(...)
withinupdateBenificiary
is a good approach for consolidating demographic handling. This improves readability and helps keep the method focused on cohesive logic. Nice work!
171-174
: Validate Null Handling forbeneficiaryModel.getI_bendemographics()
In the
save(...)
method, youβre setting extra fields (religion, occupation, etc.) only ifbeneficiaryModel.getI_bendemographics()
is non-null. This is correct. If future expansions require partial demographic data, ensure that each sub-field is also properly null-checked or defaults are provided.src/main/java/com/iemr/common/model/beneficiary/BeneficiaryModel.java (1)
292-293
: Maintain Consistency withreligion
vs.religionName
Adding a separate
religionName
field is beneficial when numeric IDs or codes differ from displayed text. However, ensure that downstream operations reference the correct field to avoid user-facing errors or incomplete updates.
@@ -42,7 +42,7 @@ public interface CallReportRepo extends CrudRepository<BeneficiaryCall, Integer> | |||
+ "and report.createdDate >= :startDate and report.createdDate <= :endDate ") | |||
public List<BeneficiaryCall> getAllBenCallIDetails(@Param("startDate") Timestamp startDate, @Param("endDate") Timestamp endDate);//start date and end date as param for x days. | |||
|
|||
@Query("SELECT call FROM BeneficiaryCall call WHERE call.callID = :sessionID and call.phoneNo = :phoneNo") | |||
@Query("SELECT call FROM BeneficiaryCall call WHERE call.callID = :sessionID and call.phoneNo like %:phoneNo%") |
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.
π οΈ Refactor suggestion
Consider clarifying matching requirements and potential performance trade-offs.
Switching from =
to LIKE
broadens the match criteria, which may risk unintended matches or degrade performance if the underlying column lacks an appropriate index. Evaluate whether partial matches are truly desired, and if so, ensure that phone numbers are sanitized and indexed appropriately to mitigate performance and accuracy concerns.
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.
CTI server is maintaining 0 before the phone number resulting false for every search from our server Hence using like operator to match phonenumber
@coderabbitai
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.
@ravishanigarapu I understand now - the LIKE operator is necessary to handle the phone number format discrepancy between the CTI server (which prepends zeros) and your server. Thank you for the clarification.
βοΈ Learnings added
Learnt from: ravishanigarapu
PR: PSMRI/Common-API#146
File: src/main/java/com/iemr/common/repository/report/CallReportRepo.java:45-45
Timestamp: 2025-01-07T11:10:32.956Z
Learning: The CTI server prepends '0' to phone numbers, requiring the use of LIKE operator instead of exact matching (=) when comparing phone numbers between CTI server and application server data.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!
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.
Actionable comments posted: 2
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
π Files selected for processing (1)
src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java
(4 hunks)
β° Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Analyze (java)
- GitHub Check: Package-test
- GitHub Check: Build
π Additional comments (1)
src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java (1)
117-118
: LGTM! Good refactoring of demographic details.The extraction of demographic details into a separate method improves code organization and maintainability.
private void setSaveDemographicDetails(CommonIdentityDTO identityDTO, BeneficiaryModel beneficiaryModel) { | ||
if(null != beneficiaryModel.getI_bendemographics()) { | ||
identityDTO.setCommunity(beneficiaryModel.getI_bendemographics().getCommunityName()); | ||
if(null != beneficiaryModel.getReligion()) | ||
identityDTO.setReligion(beneficiaryModel.getReligion()); | ||
else if(null != beneficiaryModel.getI_bendemographics().getReligion()) | ||
identityDTO.setReligion(beneficiaryModel.getI_bendemographics().getReligion()); | ||
else | ||
identityDTO.setReligion(beneficiaryModel.getI_bendemographics().getReligionName()); | ||
if(null != beneficiaryModel.getOccupation()) | ||
identityDTO.setOccupationName(beneficiaryModel.getOccupation()); | ||
else | ||
identityDTO.setOccupationName(beneficiaryModel.getI_bendemographics().getOccupation()); | ||
identityDTO.setEducation(beneficiaryModel.getI_bendemographics().getEducationName()); | ||
if(null != beneficiaryModel.getIncomeStatus()) | ||
identityDTO.setIncomeStatus(beneficiaryModel.getIncomeStatus()); | ||
else | ||
identityDTO.setIncomeStatus(beneficiaryModel.getI_bendemographics().getIncomeStatus()); | ||
} | ||
|
||
} |
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.
π οΈ Refactor suggestion
Reduce code duplication with setDemographicDetails
.
This method largely duplicates the logic from setDemographicDetails
. Consider creating a common helper method to handle the demographic data extraction.
Here's a suggested approach:
+ private static class DemographicData {
+ String community;
+ String religion;
+ String occupation;
+ String education;
+ String incomeStatus;
+ }
+
+ private DemographicData extractDemographicData(BeneficiaryModel beneficiaryModel) {
+ DemographicData data = new DemographicData();
+ if(beneficiaryModel.getI_bendemographics() != null) {
+ BeneficiaryDemographicsModel demographics = beneficiaryModel.getI_bendemographics();
+
+ data.community = demographics.getCommunityName();
+
+ data.religion = beneficiaryModel.getReligion();
+ if(data.religion == null) {
+ data.religion = demographics.getReligion();
+ if(data.religion == null) {
+ data.religion = demographics.getReligionName();
+ }
+ }
+
+ data.occupation = beneficiaryModel.getOccupation();
+ if(data.occupation == null) {
+ data.occupation = demographics.getOccupation();
+ }
+
+ data.education = demographics.getEducationName();
+
+ data.incomeStatus = beneficiaryModel.getIncomeStatus();
+ if(data.incomeStatus == null) {
+ data.incomeStatus = demographics.getIncomeStatus();
+ }
+ }
+ return data;
+ }
+
+ private void setDemographicDetails(IdentityEditDTO identityEditDTO, BeneficiaryModel beneficiaryModel) {
+ DemographicData data = extractDemographicData(beneficiaryModel);
+ if(data.community != null) {
+ identityEditDTO.setCommunity(data.community);
+ identityEditDTO.setCommunityName(data.community);
+ }
+ identityEditDTO.setReligion(data.religion);
+ identityEditDTO.setOccupationName(data.occupation);
+ identityEditDTO.setEducation(data.education);
+ identityEditDTO.setIncomeStatus(data.incomeStatus);
+ }
+
+ private void setSaveDemographicDetails(CommonIdentityDTO identityDTO, BeneficiaryModel beneficiaryModel) {
+ DemographicData data = extractDemographicData(beneficiaryModel);
+ identityDTO.setCommunity(data.community);
+ identityDTO.setReligion(data.religion);
+ identityDTO.setOccupationName(data.occupation);
+ identityDTO.setEducation(data.education);
+ identityDTO.setIncomeStatus(data.incomeStatus);
+ }
This refactoring:
- Eliminates code duplication
- Centralizes null checks
- Makes the code more maintainable
- Reduces the risk of inconsistencies between the two methods
Committable suggestion skipped: line range outside the PR's diff.
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.
Its unnessory to crate a new class for small cchanges
@coderabbitai
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.
@ravishanigarapu I understand your point. You're right - creating a new class would be overengineering for these small changes. The current implementation is more straightforward and easier to maintain.
βοΈ Learnings added
Learnt from: ravishanigarapu
PR: PSMRI/Common-API#146
File: src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java:200-220
Timestamp: 2025-01-07T11:12:41.730Z
Learning: For small changes with limited code duplication, prefer simpler and straightforward implementations over creating new abstractions like helper classes. This keeps the code more maintainable and avoids overengineering.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
private void setDemographicDetails(IdentityEditDTO identityEditDTO, BeneficiaryModel benificiaryDetails) { | ||
if(null != benificiaryDetails.getI_bendemographics()) { | ||
identityEditDTO.setCommunity(benificiaryDetails.getI_bendemographics().getCommunityName()); | ||
identityEditDTO.setCommunityName(benificiaryDetails.getI_bendemographics().getCommunityName()); | ||
if(null != benificiaryDetails.getReligion()) | ||
identityEditDTO.setReligion(benificiaryDetails.getReligion()); | ||
else if(null != benificiaryDetails.getI_bendemographics().getReligion()) | ||
identityEditDTO.setReligion(benificiaryDetails.getI_bendemographics().getReligion()); | ||
else | ||
identityEditDTO.setReligion(benificiaryDetails.getI_bendemographics().getReligionName()); | ||
if(null != benificiaryDetails.getOccupation()) | ||
identityEditDTO.setOccupationName(benificiaryDetails.getOccupation()); | ||
else | ||
identityEditDTO.setOccupationName(benificiaryDetails.getI_bendemographics().getOccupation()); | ||
identityEditDTO.setEducation(benificiaryDetails.getI_bendemographics().getEducationName()); | ||
if(null != benificiaryDetails.getIncomeStatus()) | ||
identityEditDTO.setIncomeStatus(benificiaryDetails.getIncomeStatus()); | ||
else | ||
identityEditDTO.setIncomeStatus(benificiaryDetails.getI_bendemographics().getIncomeStatus()); | ||
} | ||
|
||
} |
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.
Add consistent null checks to prevent NPEs.
The method has several potential null pointer issues:
- Missing null check for
educationName
on line 147 - Complex nested logic for religion field could be simplified
Consider this safer implementation:
private void setDemographicDetails(IdentityEditDTO identityEditDTO, BeneficiaryModel benificiaryDetails) {
if(null != benificiaryDetails.getI_bendemographics()) {
BeneficiaryDemographicsModel demographics = benificiaryDetails.getI_bendemographics();
String communityName = demographics.getCommunityName();
if(communityName != null) {
identityEditDTO.setCommunity(communityName);
identityEditDTO.setCommunityName(communityName);
}
// Simplified religion logic
String religion = benificiaryDetails.getReligion();
if(religion == null) {
religion = demographics.getReligion();
if(religion == null) {
religion = demographics.getReligionName();
}
}
identityEditDTO.setReligion(religion);
String occupation = benificiaryDetails.getOccupation();
identityEditDTO.setOccupationName(occupation != null ? occupation : demographics.getOccupation());
String education = demographics.getEducationName();
if(education != null) {
identityEditDTO.setEducation(education);
}
String incomeStatus = benificiaryDetails.getIncomeStatus();
identityEditDTO.setIncomeStatus(incomeStatus != null ? incomeStatus : demographics.getIncomeStatus());
}
}
π 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.
private void setDemographicDetails(IdentityEditDTO identityEditDTO, BeneficiaryModel benificiaryDetails) { | |
if(null != benificiaryDetails.getI_bendemographics()) { | |
identityEditDTO.setCommunity(benificiaryDetails.getI_bendemographics().getCommunityName()); | |
identityEditDTO.setCommunityName(benificiaryDetails.getI_bendemographics().getCommunityName()); | |
if(null != benificiaryDetails.getReligion()) | |
identityEditDTO.setReligion(benificiaryDetails.getReligion()); | |
else if(null != benificiaryDetails.getI_bendemographics().getReligion()) | |
identityEditDTO.setReligion(benificiaryDetails.getI_bendemographics().getReligion()); | |
else | |
identityEditDTO.setReligion(benificiaryDetails.getI_bendemographics().getReligionName()); | |
if(null != benificiaryDetails.getOccupation()) | |
identityEditDTO.setOccupationName(benificiaryDetails.getOccupation()); | |
else | |
identityEditDTO.setOccupationName(benificiaryDetails.getI_bendemographics().getOccupation()); | |
identityEditDTO.setEducation(benificiaryDetails.getI_bendemographics().getEducationName()); | |
if(null != benificiaryDetails.getIncomeStatus()) | |
identityEditDTO.setIncomeStatus(benificiaryDetails.getIncomeStatus()); | |
else | |
identityEditDTO.setIncomeStatus(benificiaryDetails.getI_bendemographics().getIncomeStatus()); | |
} | |
} | |
private void setDemographicDetails(IdentityEditDTO identityEditDTO, BeneficiaryModel benificiaryDetails) { | |
if(null != benificiaryDetails.getI_bendemographics()) { | |
BeneficiaryDemographicsModel demographics = benificiaryDetails.getI_bendemographics(); | |
String communityName = demographics.getCommunityName(); | |
if(communityName != null) { | |
identityEditDTO.setCommunity(communityName); | |
identityEditDTO.setCommunityName(communityName); | |
} | |
// Simplified religion logic | |
String religion = benificiaryDetails.getReligion(); | |
if(religion == null) { | |
religion = demographics.getReligion(); | |
if(religion == null) { | |
religion = demographics.getReligionName(); | |
} | |
} | |
identityEditDTO.setReligion(religion); | |
String occupation = benificiaryDetails.getOccupation(); | |
identityEditDTO.setOccupationName(occupation != null ? occupation : demographics.getOccupation()); | |
String education = demographics.getEducationName(); | |
if(education != null) { | |
identityEditDTO.setEducation(education); | |
} | |
String incomeStatus = benificiaryDetails.getIncomeStatus(); | |
identityEditDTO.setIncomeStatus(incomeStatus != null ? incomeStatus : demographics.getIncomeStatus()); | |
} | |
} |
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.
Actionable comments posted: 1
π§Ή Nitpick comments (1)
src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java (1)
200-221
: Consider consolidating duplicate demographic setting logic.This method shares significant logic with
setDemographicDetails
. While the previous feedback about avoiding helper classes is noted, we can still reduce duplication by extracting the common null-checking logic into private methods within this class.Example approach:
private String getReligion(BeneficiaryModel model) { if(null != model.getReligion()) return model.getReligion(); if(null != model.getI_bendemographics().getReligion()) return model.getI_bendemographics().getReligion(); return model.getI_bendemographics().getReligionName(); } private String getOccupation(BeneficiaryModel model) { return null != model.getOccupation() ? model.getOccupation() : model.getI_bendemographics().getOccupation(); }
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
π Files selected for processing (1)
src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java
(4 hunks)
π§° Additional context used
π Learnings (1)
src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java (1)
Learnt from: ravishanigarapu
PR: PSMRI/Common-API#146
File: src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java:200-220
Timestamp: 2025-01-07T11:12:41.885Z
Learning: For small changes with limited code duplication, prefer simpler and straightforward implementations over creating new abstractions like helper classes. This keeps the code more maintainable and avoids overengineering.
β° Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Analyze (java)
- GitHub Check: Package-test
- GitHub Check: Build
π Additional comments (3)
src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java (3)
117-118
: LGTM! Good separation of concerns.The extraction of demographic details setting logic into a separate method improves code organization and readability.
133-154
: Add consistent null checks to prevent NPEs.Similar to previous feedback, there are several potential null pointer issues:
- Missing null check for
communityName
before setting- Missing null check for
educationName
- Complex nested logic for religion field could be simplified
169-169
: LGTM! Good separation of concerns.The extraction of demographic details setting logic into a separate method improves code organization and readability.
identityDTO.setOccupationName(beneficiaryModel.getOccupation()); | ||
else | ||
identityDTO.setOccupationName(beneficiaryModel.getI_bendemographics().getOccupation()); | ||
if(null != beneficiaryModel.getI_bendemographics()) |
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.
π οΈ Refactor suggestion
Remove redundant null check.
The null check for beneficiaryModel.getI_bendemographics()
is redundant as it's already checked at line 201.
- if(null != beneficiaryModel.getI_bendemographics())
identityDTO.setEducation(beneficiaryModel.getI_bendemographics().getEducationName());
+ identityDTO.setEducation(beneficiaryModel.getI_bendemographics().getEducationName());
π 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.
if(null != beneficiaryModel.getI_bendemographics()) | |
identityDTO.setEducation(beneficiaryModel.getI_bendemographics().getEducationName()); |
Quality Gate passedIssues Measures |
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.
Actionable comments posted: 0
π§Ή Nitpick comments (2)
src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java (2)
137-142
: Simplify religion field logic.The nested if-else logic for religion can be simplified using a more concise approach.
- if(null != benificiaryDetails.getReligion()) - identityEditDTO.setReligion(benificiaryDetails.getReligion()); - else if(null != benificiaryDetails.getI_bendemographics().getReligion()) - identityEditDTO.setReligion(benificiaryDetails.getI_bendemographics().getReligion()); - else - identityEditDTO.setReligion(benificiaryDetails.getI_bendemographics().getReligionName()); + String religion = benificiaryDetails.getReligion(); + if(religion == null) { + religion = benificiaryDetails.getI_bendemographics().getReligion(); + if(religion == null) { + religion = benificiaryDetails.getI_bendemographics().getReligionName(); + } + } + identityEditDTO.setReligion(religion);
203-208
: Maintain consistency with setDemographicDetails religion logic.For better maintainability, the religion logic should follow the same pattern in both methods. Consider applying the same simplified approach suggested for
setDemographicDetails
.- if(null != beneficiaryModel.getReligion()) - identityDTO.setReligion(beneficiaryModel.getReligion()); - else if(null != beneficiaryModel.getI_bendemographics().getReligion()) - identityDTO.setReligion(beneficiaryModel.getI_bendemographics().getReligion()); - else - identityDTO.setReligion(beneficiaryModel.getI_bendemographics().getReligionName()); + String religion = beneficiaryModel.getReligion(); + if(religion == null) { + religion = beneficiaryModel.getI_bendemographics().getReligion(); + if(religion == null) { + religion = beneficiaryModel.getI_bendemographics().getReligionName(); + } + } + identityDTO.setReligion(religion);
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
π Files selected for processing (1)
src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java
(4 hunks)
π§° Additional context used
π Learnings (1)
src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java (1)
Learnt from: ravishanigarapu
PR: PSMRI/Common-API#146
File: src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java:200-220
Timestamp: 2025-01-07T11:12:41.885Z
Learning: For small changes with limited code duplication, prefer simpler and straightforward implementations over creating new abstractions like helper classes. This keeps the code more maintainable and avoids overengineering.
π Additional comments (3)
src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java (3)
117-118
: LGTM! Method call placement is appropriate.The
setDemographicDetails
call is well-placed, occurring before identity handling.
169-169
: LGTM! Method call placement is appropriate.The
setSaveDemographicDetails
call is well-placed, occurring before setting additional fields.
147-147
:β οΈ Potential issueAdd null check for educationName to prevent NPE.
The
educationName
field is accessed without a null check, which could lead to a NullPointerException.- identityEditDTO.setEducation(benificiaryDetails.getI_bendemographics().getEducationName()); + if(null != benificiaryDetails.getI_bendemographics().getEducationName()) + identityEditDTO.setEducation(benificiaryDetails.getI_bendemographics().getEducationName());Likely invalid or redundant comment.
AMM-1076 and AMM-1078 (PSMRI#146)
π Description
JIRA ID: AMM-1076, AMM-1078
Please provide a summary of the change and the motivation behind it. Include relevant context and details.
β Type of Change
βΉοΈ 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
New Features
religionName
field to beneficiary data models.Bug Fixes
Chores