Skip to content

Conversation

@ravishanigarapu
Copy link
Contributor

@ravishanigarapu ravishanigarapu commented May 28, 2025

πŸ“‹ Description

JIRA ID:

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

  • Bug Fixes
    • Improved error handling to ensure that processing continues for all patients, even if an error occurs for one.
    • Added explicit notification when a patient's preferred phone number is missing, ensuring better visibility of skipped SMS notifications.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 28, 2025

Walkthrough

The processing logic for each patient in the processResourceOperation() method was refactored to wrap the entire per-patient operation in a try-catch block, ensuring that exceptions do not halt the processing of subsequent patients. Additionally, an explicit exception is now thrown if a patient's preferred phone number is missing during SMS sending.

Changes

File Change Summary
src/main/java/com/wipro/fhir/service/common/CommonServiceImpl.java Broadened try-catch to cover entire per-patient processing; added explicit exception throw for missing phone.

Poem

A rabbit hopped through code today,
Wrapping each patient in a safe array.
If a phone was missing, it gave a shoutβ€”
No more silent skipping out!
Now, even if one trip goes awry,
The rest of the bunnies still hop by. πŸ‡

✨ Finishing Touches
  • πŸ“ Generate Docstrings

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.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
C Maintainability Rating on New Code (required β‰₯ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@helenKaryamsetty helenKaryamsetty merged commit 80c2520 into PSMRI:develop May 28, 2025
5 of 7 checks passed
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: 0

🧹 Nitpick comments (2)
src/main/java/com/wipro/fhir/service/common/CommonServiceImpl.java (2)

176-179: Approve the resilience improvement but suggest logging enhancement.

The addition of the outer try-catch block successfully prevents individual patient processing failures from stopping the entire batch operation, which improves system resilience.

Consider enhancing the error logging to include patient identification details:

-		for (PatientEligibleForResourceCreation p : pList) {
-			try {
-				logger.info("Bundle creation is started for BenID : " + p.getBeneficiaryId() + " | BenRegID : "
-						+ p.getBeneficiaryRegID() + " | VisitCode : " + p.getVisitCode());
+		for (PatientEligibleForResourceCreation p : pList) {
+			try {
+				logger.info("Bundle creation is started for BenID : " + p.getBeneficiaryId() + " | BenRegID : "
+						+ p.getBeneficiaryRegID() + " | VisitCode : " + p.getVisitCode());

237-239: Fix logging message formatting.

The error logging message has a formatting issue that affects readability.

-			} catch (Exception e) {
-				logger.error("Fhir Schedule run failed " +e.getMessage());
-			}
+			} catch (Exception e) {
+				logger.error("FHIR Schedule run failed for BenID: " + p.getBeneficiaryId() 
+					+ " | BenRegID: " + p.getBeneficiaryRegID() 
+					+ " | VisitCode: " + p.getVisitCode() + " - " + e.getMessage(), e);
+			}

Improvements:

  • Fixed spacing in the log message
  • Added patient context for easier debugging
  • Included the full exception stack trace for better troubleshooting
  • Corrected "Fhir" to "FHIR" (standard capitalization)
πŸ“œ Review details

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

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 75b6f91 and 080dd67.

πŸ“’ Files selected for processing (1)
  • src/main/java/com/wipro/fhir/service/common/CommonServiceImpl.java (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (java)
πŸ”‡ Additional comments (2)
src/main/java/com/wipro/fhir/service/common/CommonServiceImpl.java (2)

212-234: Verify error handling strategy aligns with business requirements.

The bundle processing logic (OP consult, diagnostic report, prescription) now continues execution even if the demographics fetching or SMS sending fails due to the nested exception handling. This might not be the intended behavior.

Please verify whether the bundle processing should continue if demographics fetching fails. The current implementation will:

  1. Continue processing bundles even if addCareContextToMongo() fails
  2. Continue processing bundles even if patient demographics cannot be fetched
  3. Only skip SMS sending if phone number is missing

Is this the intended behavior, or should demographic fetching failures prevent bundle processing?


186-209: πŸ› οΈ Refactor suggestion

Refactor nested exception handling for better maintainability.

The nested try-catch structure creates complexity and potential for unexpected behavior. The inner catch block silently swallows exceptions, which could mask important failures during demographics fetching or SMS sending.

Consider refactoring to a more straightforward approach:

-				try {
-
-					logger.info("*****Fetch beneficiary Id: " + resourceRequestHandler.getBeneficiaryRegID());
-					List<Object[]> rsObjList = patientEligibleForResourceCreationRepo
-							.callPatientDemographicSP(resourceRequestHandler.getBeneficiaryRegID());
-					logger.info("*****Fetch beneficiary Id response recevied :", rsObjList);
-
-					PatientDemographic patientDemographicOBJ = patientDemographic.getPatientDemographic(rsObjList);
-					logger.info("*****Fetch patient after fetching demographics");
-					if (patientDemographicOBJ != null) {
-						addCareContextToMongo(patientDemographicOBJ, p);
-						logger.info("*****Add to mongo success done");
-						if (patientDemographicOBJ.getPreferredPhoneNo() != null)
-							sendAbdmAdvSMS(patientDemographicOBJ.getPreferredPhoneNo());
-						else
-							throw new FHIRException(
-									"Advertisement sms could not be sent as beneficiary phone no not found");
-					} else
-						throw new FHIRException(
-								"Beneficiary not found, benRegId = " + resourceRequestHandler.getBeneficiaryRegID());
-
-				} catch (Exception e) {
-					logger.error(e.getMessage());
-				}
+				logger.info("*****Fetch beneficiary Id: " + resourceRequestHandler.getBeneficiaryRegID());
+				List<Object[]> rsObjList = patientEligibleForResourceCreationRepo
+						.callPatientDemographicSP(resourceRequestHandler.getBeneficiaryRegID());
+				logger.info("*****Fetch beneficiary Id response recevied :", rsObjList);
+
+				PatientDemographic patientDemographicOBJ = patientDemographic.getPatientDemographic(rsObjList);
+				logger.info("*****Fetch patient after fetching demographics");
+				if (patientDemographicOBJ != null) {
+					addCareContextToMongo(patientDemographicOBJ, p);
+					logger.info("*****Add to mongo success done");
+					if (patientDemographicOBJ.getPreferredPhoneNo() != null) {
+						sendAbdmAdvSMS(patientDemographicOBJ.getPreferredPhoneNo());
+					} else {
+						logger.warn("Advertisement SMS could not be sent as beneficiary phone no not found for BenRegID: " 
+							+ resourceRequestHandler.getBeneficiaryRegID());
+					}
+				} else {
+					logger.error("Beneficiary not found, benRegId = " + resourceRequestHandler.getBeneficiaryRegID());
+				}

This approach:

  • Removes the nested try-catch complexity
  • Allows the outer try-catch to handle all exceptions consistently
  • Changes the missing phone number from an exception to a warning (since SMS is auxiliary functionality)
  • Improves error messages with context

Likely an incorrect or invalid review comment.

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