-
Notifications
You must be signed in to change notification settings - Fork 31
Modified the constructor for better handling #125
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
Changes from 42 commits
3814860
a2224b4
1a28c2b
fea418b
9d30d46
583594a
8d206ef
4c76193
c07d839
d26eeda
5e93901
e669df1
7a5c0d4
43683a2
8ead599
c1c5d38
497b3ff
d748156
811aef7
945d874
c1c96f4
d267c17
49c97fa
6d5298f
23b4a20
db670fc
5d6dd44
1d9835a
765d260
71c995d
fec6064
fa7cf00
7a21582
09913fc
8269c75
055525e
61506e6
a1df7fa
e2bec9a
88654c5
e44be6f
881bcbf
d116010
6237bad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,8 @@ | |
|
|
||
| import org.springframework.stereotype.Component; | ||
|
|
||
| import com.wipro.fhir.utils.exception.FHIRException; | ||
|
|
||
| import lombok.Data; | ||
|
|
||
| @Component | ||
|
|
@@ -38,35 +40,44 @@ public class OrganizationDataModel { | |
| public OrganizationDataModel() { | ||
| } | ||
|
|
||
| public OrganizationDataModel(Object[] objArr) { | ||
| public OrganizationDataModel(Object[] objArr) throws FHIRException { | ||
|
|
||
| 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; | ||
|
|
||
| } catch (Exception e) { | ||
| throw new FHIRException("Practioner resource failed with error - " + e.getMessage()); | ||
| } | ||
|
Comment on lines
73
to
75
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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 |
||
|
|
||
| this.psAddMapID = objArr[14] != null ? (Integer) objArr[14] : null; | ||
| this.providerServiceMapID = objArr[15] != null ? (Integer) objArr[15] : null; | ||
| } | ||
|
|
||
|
|
||
| public OrganizationDataModel getOrganization(Object[] resultSet) { | ||
| public OrganizationDataModel getOrganization(Object[] resultSet) throws FHIRException { | ||
|
|
||
| if (resultSet == null || resultSet.length == 0) { | ||
| return null; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,8 @@ | |||||||||||||
|
|
||||||||||||||
| import org.springframework.stereotype.Component; | ||||||||||||||
|
|
||||||||||||||
| import com.wipro.fhir.utils.exception.FHIRException; | ||||||||||||||
|
|
||||||||||||||
| import lombok.Data; | ||||||||||||||
|
|
||||||||||||||
| @Data | ||||||||||||||
|
|
@@ -37,27 +39,41 @@ public class PractitionerDataModel { | |||||||||||||
| public PractitionerDataModel() { | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| public PractitionerDataModel(Object[] objArr) { | ||||||||||||||
|
|
||||||||||||||
| this.benVisitID = objArr[0] != null ? ((Number) objArr[0]).intValue() : null; | ||||||||||||||
| this.userID = objArr[1] != null ? ((Number) objArr[1]).intValue() : null; | ||||||||||||||
| this.fullName = (String) objArr[2]; | ||||||||||||||
| this.dob = (Date) objArr[3]; | ||||||||||||||
| this.employeeID = (String) objArr[4]; | ||||||||||||||
| this.contactNo = (String) objArr[5]; | ||||||||||||||
| this.emailID = (String) objArr[6]; | ||||||||||||||
| this.qualificationName = (String) objArr[7]; | ||||||||||||||
| this.designationName = (String) objArr[8]; | ||||||||||||||
| this.genderName = (String) objArr[9]; | ||||||||||||||
| this.genderID = objArr[10] != null ? ((Number) objArr[10]).intValue() : null; | ||||||||||||||
| this.serviceProviderID = objArr[11] != null ? ((Number) objArr[11]).intValue() : null; | ||||||||||||||
| this.visitCode = objArr[12] != null ? ((Number) objArr[12]).longValue() : null; | ||||||||||||||
| this.createdBy = (String) objArr[13]; | ||||||||||||||
| this.createdDate = (Timestamp) objArr[14]; | ||||||||||||||
| public PractitionerDataModel(Object[] objArr) throws FHIRException { | ||||||||||||||
|
|
||||||||||||||
| 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()); | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
44
to
71
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing array bounds validation before element access. The constructor accesses π 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
Comment on lines
69
to
71
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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
Suggested change
π€ Prompt for AI Agents |
||||||||||||||
|
|
||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| public PractitionerDataModel getPractitioner(Object[] resultSet) { | ||||||||||||||
| public PractitionerDataModel getPractitioner(Object[] resultSet) throws FHIRException { | ||||||||||||||
| if (resultSet == null || resultSet.length == 0) { | ||||||||||||||
| return null; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
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.
Missing array bounds validation before element access.
The constructor accesses
objArr[0]throughobjArr[15](16 elements) without verifying that the array has sufficient length. AnArrayIndexOutOfBoundsExceptionwill be thrown for shorter arrays, which gets wrapped in a less informativeFHIRException.π 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