Skip to content

Conversation

@helenKaryamsetty
Copy link
Member

@helenKaryamsetty helenKaryamsetty commented Dec 23, 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

Release Notes

  • Refactor
    • Enhanced error handling and exception management in healthcare data models to provide more robust and informative error reporting when parsing facility and practitioner data.
    • Improved data parsing logic with strengthened null-safety and validation checks during object-to-model conversions.
    • Extended data model initialization to support additional fields with safer type conversion and error recovery.

✏️ Tip: You can customize this high-level summary in your review settings.

KA40094929 and others added 30 commits September 19, 2024 18:49
Removed unnecessary 'order by 1 desc' clause from queries.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 23, 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

Walkthrough

These changes enhance error handling and data parsing robustness in two FHIR data model classes by adding FHIRException throws declarations, wrapping constructor logic in try-catch blocks, and replacing direct casts with safer parsing operations for multiple fields.

Changes

Cohort / File(s) Summary
Data Model Exception Handling
src/main/java/com/wipro/fhir/data/resource_model/OrganizationDataModel.java, src/main/java/com/wipro/fhir/data/resource_model/PractitionerDataModel.java
Added FHIRException import and updated constructors to declare throws FHIRException. Replaced direct casting with robust parsing logic for multiple fields (stateID, stateName, districtID, districtName, locationName, address, serviceID, serviceName, isNational, abdmFacilityId, abdmFacilityName, psAddMapID, providerServiceMapID in OrganizationDataModel; equivalent fields in PractitionerDataModel). Wrapped population logic in try-catch blocks that convert errors to descriptive FHIRException instances. Updated corresponding getter methods to declare throws FHIRException for exception propagation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 With whiskers twitched and nose held high,
We parse with care, no casting die,
Exceptions caught in fuzzy paws,
Data flows now free of flaws! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'Modified the constructor for better handling' is too vague and generic. It does not convey specific information about which constructors were modified, what changes were made, or why the handling is 'better'. Clarify the title with specific details, such as 'Add exception handling to OrganizationDataModel and PractitionerDataModel constructors' or 'Update data model constructors to declare FHIRException throws clause'.
βœ… Passed checks (1 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@helenKaryamsetty
Copy link
Member Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 23, 2025

βœ… Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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: 4

πŸ“œ Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 32ba209 and 881bcbf.

πŸ“’ Files selected for processing (2)
  • src/main/java/com/wipro/fhir/data/resource_model/OrganizationDataModel.java
  • src/main/java/com/wipro/fhir/data/resource_model/PractitionerDataModel.java
πŸ”‡ Additional comments (3)
src/main/java/com/wipro/fhir/data/resource_model/PractitionerDataModel.java (1)

76-81: LGTM!

The method correctly propagates FHIRException and maintains proper null/empty array guard before delegating to the constructor.

src/main/java/com/wipro/fhir/data/resource_model/OrganizationDataModel.java (2)

63-65: Good defensive parsing for boolean field.

The isNational parsing correctly handles multiple representations ("true", "1") which is robust when dealing with heterogeneous data sources.


80-87: LGTM!

The method correctly propagates FHIRException and maintains proper null/empty array guard before delegating to the constructor.

Comment on lines +45 to +72
try {

this.benVisitID = objArr[0] != null ? Long.parseLong(objArr[0].toString()) : null;
this.serviceProviderID = objArr[1] != null ? Short.parseShort(objArr[1].toString()) : null;
this.serviceProviderName = objArr[2] != null ? objArr[2].toString() : null;

this.benVisitID = objArr[0] != null ? (Long) objArr[0] : null;
this.serviceProviderID = objArr[1] != null ? (Short) objArr[1] : null;
this.serviceProviderName = objArr[2] != null ? (String) objArr[2] : null;
this.stateID = objArr[3] != null ? Integer.parseInt(objArr[3].toString()) : null;
this.stateName = objArr[4] != null ? objArr[4].toString() : null;

this.stateID = objArr[3] != null ? (Integer) objArr[3] : null;
this.stateName = objArr[4] != null ? (String) objArr[4] : null;
this.districtID = objArr[5] != null ? Integer.parseInt(objArr[5].toString()) : null;
this.districtName = objArr[6] != null ? objArr[6].toString() : null;

this.districtID = objArr[5] != null ? (Integer) objArr[5] : null;
this.districtName = objArr[6] != null ? (String) objArr[6] : null;
this.locationName = objArr[7] != null ? objArr[7].toString() : null;
this.address = objArr[8] != null ? objArr[8].toString() : null;

this.locationName = objArr[7] != null ? (String) objArr[7] : null;
this.address = objArr[8] != null ? (String) objArr[8] : null;
this.serviceID = objArr[9] != null ? Short.parseShort(objArr[9].toString()) : null;
this.serviceName = objArr[10] != null ? objArr[10].toString() : null;

this.serviceID = objArr[9] != null ? (Short) objArr[9] : null;
this.serviceName = objArr[10] != null ? (String) objArr[10] : null;
this.isNational = objArr[11] != null
? objArr[11].toString().equalsIgnoreCase("true") || objArr[11].toString().equals("1")
: null;

this.isNational = objArr[11] != null ? (Boolean) objArr[11] : null;
this.abdmFacilityId = objArr[12] != null ? objArr[12].toString() : null;
this.abdmFacilityName = objArr[13] != null ? objArr[13].toString() : null;

this.abdmFacilityId = objArr[12] != null ? (String) objArr[12] : null;
this.abdmFacilityName = objArr[13] != null ? (String) objArr[13] : null;
this.psAddMapID = objArr[14] != null ? Integer.parseInt(objArr[14].toString()) : null;
this.providerServiceMapID = objArr[15] != null ? Integer.parseInt(objArr[15].toString()) : null;

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Missing array bounds validation before element access.

The constructor accesses objArr[0] through objArr[15] (16 elements) without verifying that the array has sufficient length. An ArrayIndexOutOfBoundsException will be thrown for shorter arrays, which gets wrapped in a less informative FHIRException.

πŸ”Ž Proposed fix: Add bounds check at the start of try block
 	try {
+		if (objArr.length < 16) {
+			throw new FHIRException("Organization resource requires at least 16 elements, but got " + objArr.length);
+		}

 		this.benVisitID = objArr[0] != null ? Long.parseLong(objArr[0].toString()) : null;
πŸ€– Prompt for AI Agents
In src/main/java/com/wipro/fhir/data/resource_model/OrganizationDataModel.java
around lines 45 to 72, the constructor directly accesses objArr[0]..objArr[15]
without validating the array length; add a guard at the start of the try block
to verify objArr is not null and objArr.length >= 16 and if not, throw a
FHIRException (or return/handle) with a clear message indicating the missing
elements; keep the rest of the parsing logic the same so downstream parsing only
runs when the array has the expected 16 elements.

Comment on lines 73 to 75
} catch (Exception e) {
throw new FHIRException("Practioner resource failed with error - " + e.getMessage());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Incorrect error message: copy-paste error references "Practioner" instead of "Organization".

This will cause confusion during debugging since the exception message incorrectly identifies the resource type.

πŸ”Ž Proposed fix
-		throw new FHIRException("Practioner resource failed with error - " + e.getMessage());
+		throw new FHIRException("Organization resource failed with error - " + e.getMessage());
πŸ€– Prompt for AI Agents
In src/main/java/com/wipro/fhir/data/resource_model/OrganizationDataModel.java
around lines 73 to 75, the catch block throws a FHIRException with a copy-paste
message referencing "Practioner" instead of "Organization"; update the message
to correctly reference "Organization" (and fix the "Practitioner" spelling if
needed) and include the original exception details (e.g., append e.getMessage()
or rethrow with e as the cause) so the thrown FHIRException accurately
identifies the resource and preserves error context.

Comment on lines 44 to 71
try {

this.benVisitID = objArr[0] != null ? Integer.parseInt(objArr[0].toString()) : null;
this.userID = objArr[1] != null ? Integer.parseInt(objArr[1].toString()) : null;

this.fullName = objArr[2] != null ? objArr[2].toString() : null;

this.dob = objArr[3] != null ? (objArr[3] instanceof Date ? (Date) objArr[3] : null) : null;

this.employeeID = objArr[4] != null ? objArr[4].toString() : null;
this.contactNo = objArr[5] != null ? objArr[5].toString() : null;
this.emailID = objArr[6] != null ? objArr[6].toString() : null;
this.qualificationName = objArr[7] != null ? objArr[7].toString() : null;
this.designationName = objArr[8] != null ? objArr[8].toString() : null;
this.genderName = objArr[9] != null ? objArr[9].toString() : null;

this.genderID = objArr[10] != null ? Integer.parseInt(objArr[10].toString()) : null;
this.serviceProviderID = objArr[11] != null ? Integer.parseInt(objArr[11].toString()) : null;

this.visitCode = objArr[12] != null ? Long.parseLong(objArr[12].toString()) : null;

this.createdBy = objArr[13] != null ? objArr[13].toString() : null;

this.createdDate = objArr[14] != null ? (objArr[14] instanceof Timestamp ? (Timestamp) objArr[14] : null)
: null;
} catch (Exception e) {
throw new FHIRException("Practioner resource failed with error - " + e.getMessage());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Missing array bounds validation before element access.

The constructor accesses objArr[0] through objArr[14] (15 elements) without verifying that the array has sufficient length. If a shorter array is passed, an ArrayIndexOutOfBoundsException will be thrown, which gets wrapped in a less informative FHIRException.

πŸ”Ž Proposed fix: Add bounds check at the start of try block
 	try {
+		if (objArr.length < 15) {
+			throw new FHIRException("Practitioner resource requires at least 15 elements, but got " + objArr.length);
+		}

 		this.benVisitID = objArr[0] != null ? Integer.parseInt(objArr[0].toString()) : null;
πŸ€– Prompt for AI Agents
In src/main/java/com/wipro/fhir/data/resource_model/PractitionerDataModel.java
around lines 44 to 71, the constructor indexes objArr[0]..objArr[14] without
verifying objArr is non-null and has at least 15 elements; add an explicit
pre-check at the start of the try block: if objArr is null or objArr.length <
15, throw a FHIRException with a clear message (e.g., "Invalid objArr: expected
at least 15 elements, got X") so we avoid ArrayIndexOutOfBoundsException and
provide a useful error; keep the existing parsing logic unchanged after the
guard.

Comment on lines 69 to 71
} catch (Exception e) {
throw new FHIRException("Practioner resource failed with error - " + e.getMessage());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟑 Minor

Typo in error message: "Practioner" should be "Practitioner".

πŸ”Ž Proposed fix
-		throw new FHIRException("Practioner resource failed with error - " + e.getMessage());
+		throw new FHIRException("Practitioner resource failed with error - " + e.getMessage());
πŸ“ 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.

Suggested change
} catch (Exception e) {
throw new FHIRException("Practioner resource failed with error - " + e.getMessage());
}
} catch (Exception e) {
throw new FHIRException("Practitioner resource failed with error - " + e.getMessage());
}
πŸ€– Prompt for AI Agents
In src/main/java/com/wipro/fhir/data/resource_model/PractitionerDataModel.java
around lines 69 to 71, the exception message contains a typo ("Practioner");
update the thrown FHIRException message to use the correct spelling
"Practitioner" while preserving the rest of the message and concatenated error
details so the log remains informative.

@sonarqubecloud
Copy link

@helenKaryamsetty helenKaryamsetty merged commit 81dda6d into PSMRI:abdmV3 Dec 23, 2025
2 of 3 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.

1 participant