logic modified save section-fields API#125
logic modified save section-fields API#125helenKaryamsetty merged 2 commits intoPSMRI:developfrom ravishanigarapu:develop
Conversation
WalkthroughThe changes involve modifications to the Changes
Possibly related PRs
Suggested reviewers
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (4)
src/main/java/com/iemr/common/secondary/repository/callreport/CallReportSecondaryRepo.java (1)
Line range hint
1-158: Summary of changes and recommendationsThe changes in this file primarily involve removing the
db_iemrschema prefix from stored procedure calls, which appears to be part of a broader effort to standardize database access patterns. However, there are a few points that require attention:
Consistency: Most methods have had the schema prefix removed entirely, but
getAllReportsByDatenow uses thedb_reportingschema. This inconsistency needs to be addressed or explained.Schema verification: For all modified methods, it's crucial to verify that the stored procedures are accessible in the default schema or that the correct schema is set for the database connection. This ensures that the changes won't break existing functionality.
Testing: Given that these changes affect database access patterns, thorough testing should be conducted to ensure that all methods still function correctly and return the expected results.
Documentation: If these changes are part of a larger refactoring effort, it would be beneficial to update any relevant documentation to reflect the new approach to schema management.
Please address these points to ensure the changes are complete, consistent, and well-understood by the team.
src/main/java/com/iemr/common/service/customization/CustomizationServiceImpl.java (3)
Line range hint
179-228: Improved error handling and response consistency. Consider using constants for error messages.The changes in the
saveSectionAndFieldsmethod have significantly improved error handling and response consistency. The new response map initialization, simplified field name check, and conditional response message are all positive changes that enhance the method's clarity and maintainability.Consider defining constant strings for error messages to improve maintainability:
private static final String INVALID_REQUEST_FIELD_EXISTS = "Invalid request: Field name already exists"; private static final String INVALID_REQUEST_EMPTY = "Invalid request: Please pass valid request";Then use these constants in your error messages:
throw new IllegalArgumentException(INVALID_REQUEST_FIELD_EXISTS); // and throw new IllegalArgumentException(INVALID_REQUEST_EMPTY);This approach will make it easier to maintain consistent error messages across the codebase.
Line range hint
1-428: Improved consistency in error handling and response format. Consider using a common method for response creation.The changes in the
updateSectionAndFieldsmethod have improved consistency in error handling and response format. The standardized use ofIllegalArgumentExceptionfor invalid requests and the adoption of a response map for success messages align well with the patterns used in other methods likesaveSectionAndFields.To further improve consistency and reduce code duplication, consider creating a helper method for generating response maps:
private Map<String, Object> createResponseMap(String message) { Map<String, Object> responseMap = new HashMap<>(); responseMap.put("response", message); return responseMap; }Then use this method in both
saveSectionAndFieldsandupdateSectionAndFields:return new Gson().toJson(createResponseMap("section and fields mapping updated successfully"));This approach will ensure consistent response formatting across all methods and make it easier to modify the response structure in the future if needed.
Line range hint
1-428: Overall improvements in error handling and response consistencyThe changes made to the
CustomizationServiceImplclass, particularly in thesaveSectionAndFieldsandupdateSectionAndFieldsmethods, demonstrate a commendable effort to improve error handling and maintain consistency in response formats. These modifications enhance the overall maintainability and readability of the code.Key improvements include:
- Standardized error handling using
IllegalArgumentException.- Consistent use of response maps for success messages.
- More precise error messages for invalid requests.
These changes align well with best practices in Java development and will likely make the code easier to maintain and extend in the future.
To further enhance the code, consider the following architectural improvements:
- Implement a custom exception hierarchy for more granular error handling.
- Use a response object pattern instead of Map for more type-safe and structured responses.
- Consider implementing a validation layer using a library like Hibernate Validator to centralize and standardize input validation.
These suggestions could be implemented in future iterations to further improve the robustness and maintainability of the codebase.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- src/main/java/com/iemr/common/secondary/repository/callreport/CallReportSecondaryRepo.java (2 hunks)
- src/main/java/com/iemr/common/service/customization/CustomizationServiceImpl.java (2 hunks)
🔇 Additional comments (5)
src/main/java/com/iemr/common/secondary/repository/callreport/CallReportSecondaryRepo.java (5)
Line range hint
104-108: LGTM. Verify stored procedure location.The removal of the
db_iemrschema prefix from the stored procedure call looks good. This change standardizes the procedure calls across the repository. However, please ensure that thePr_1097Sexualorientationstored procedure is accessible in the default schema or the correct schema is set for the database connection.To verify the stored procedure location, you can run the following SQL query:
SELECT ROUTINE_SCHEMA, ROUTINE_NAME FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE = 'PROCEDURE' AND ROUTINE_NAME = 'Pr_1097Sexualorientation';This will show you the schema where the procedure is located.
135-139: LGTM. Verify stored procedure location.The removal of the
db_iemrschema prefix from thePr_1097LanguageDistributionstored procedure call is consistent with the changes made to other methods. This standardization is good for maintainability. However, please confirm that the stored procedure is accessible in the default schema or that the correct schema is set for the database connection.To verify the stored procedure location, you can run the following SQL query:
SELECT ROUTINE_SCHEMA, ROUTINE_NAME FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE = 'PROCEDURE' AND ROUTINE_NAME = 'Pr_1097LanguageDistribution';This will show you the schema where the procedure is located.
142-145: LGTM. Verify stored procedure location.The removal of the
db_iemrschema prefix from thePr_1097AgegroupDistributionstored procedure call is in line with the changes made to other methods. This consistency is good for code maintainability. As with the previous methods, please ensure that the stored procedure is accessible in the default schema or that the correct schema is set for the database connection.To verify the stored procedure location, you can run the following SQL query:
SELECT ROUTINE_SCHEMA, ROUTINE_NAME FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE = 'PROCEDURE' AND ROUTINE_NAME = 'Pr_1097AgegroupDistribution';This will show you the schema where the procedure is located.
153-156: LGTM. Verify stored procedure location.The removal of the
db_iemrschema prefix from thePr_1097GenderDistributionstored procedure call is consistent with the changes made to most other methods in this file. This standardization improves code maintainability. As with the previous methods, please ensure that the stored procedure is accessible in the default schema or that the correct schema is set for the database connection.To verify the stored procedure location, you can run the following SQL query:
SELECT ROUTINE_SCHEMA, ROUTINE_NAME FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE = 'PROCEDURE' AND ROUTINE_NAME = 'Pr_1097GenderDistribution';This will show you the schema where the procedure is located.
147-151:⚠️ Potential issueClarify the use of
db_reportingschema.Unlike the changes made to other methods where the schema prefix was removed entirely, this method now uses the
db_reportingschema instead ofdb_iemr. This inconsistency raises a few questions:
- Is this intentional? If so, why is this stored procedure in a different schema?
- If it's not intentional, should this also have the schema prefix removed to be consistent with other changes?
Please clarify the reasoning behind this difference to ensure it's not an oversight and that it aligns with the overall database schema strategy.
To verify the stored procedure location and compare with others, you can run the following SQL query:
SELECT ROUTINE_SCHEMA, ROUTINE_NAME FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE = 'PROCEDURE' AND ROUTINE_NAME IN ('Pr_1097calltypeReport', 'Pr_1097Sexualorientation', 'Pr_1097LanguageDistribution', 'Pr_1097AgegroupDistribution');This will show you the schemas where these procedures are located, allowing you to compare and ensure consistency.



📋 Description
JIRA ID: AMM-998
logic modified save section-fields API
✅ 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
Bug Fixes
Documentation