Skip to content
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
41a4bc0
Modified tnxId keyword to txnId
Dec 13, 2024
55e4881
Abha-address search API changes
Dec 13, 2024
08f485f
Merge branch 'PSMRI:develop' into develop
helenKaryamsetty Dec 13, 2024
f3445cb
added validation for multiple phraddress
Dec 16, 2024
cb328f1
Merge branch 'PSMRI:develop' into develop
helenKaryamsetty Dec 16, 2024
f967118
Abha-address search response changes
Dec 17, 2024
8430a37
Save facility id variable change chnages
Jan 7, 2025
246bf2a
Merge branch 'develop' of https://github.com/helenKaryamsetty/FHIR-AP…
Jan 7, 2025
68a81b3
Added check to avoid multiple save of single care-context
Jan 9, 2025
65e3751
Merge branch 'develop' into develop
helenKaryamsetty Jan 9, 2025
44df923
removed unused variables
Jan 9, 2025
e329b5c
Merge branch 'develop' of https://github.com/helenKaryamsetty/FHIR-AP…
Jan 9, 2025
9c3b51f
Updated public key certificate API
Jan 30, 2025
82f88e6
Merge branch 'PSMRI:develop' into develop
helenKaryamsetty Jan 30, 2025
114cfff
Integrated Abha session v3 APIs and Profile login user verify APIs
Feb 24, 2025
e67eca9
Merge branch 'PSMRI:develop' into develop
helenKaryamsetty Feb 24, 2025
cc1b252
committed coderabitai suggested
Feb 25, 2025
cf66e78
Merge branch 'develop' of https://github.com/helenKaryamsetty/FHIR-AP…
Feb 25, 2025
c38d099
Revert "jwt implementation changes (#53)"
Feb 26, 2025
da3053d
data Sync for FLW API changes
Feb 26, 2025
c28dccb
Merge branch 'PSMRI:develop' into develop
helenKaryamsetty Feb 26, 2025
38dd846
Reapply "jwt implementation changes (#53)"
Feb 26, 2025
d9201ff
Merge branch 'develop' of https://github.com/helenKaryamsetty/FHIR-AP…
Feb 26, 2025
43d6b48
changed variable type default value as false
Feb 27, 2025
86a06f5
addition of isNewAbha in getHealthIdDetails API
Feb 27, 2025
c75dfdd
Merge branch 'PSMRI:develop' into develop
helenKaryamsetty Feb 27, 2025
4cbaf06
Merge branch 'develop' of https://github.com/helenKaryamsetty/FHIR-AP…
Feb 27, 2025
9f0372c
Revert "jwt implementation changes (#53)"
Feb 27, 2025
ebff8ad
verify abha issue with mobile number
Mar 21, 2025
ba89acc
Reapply "jwt implementation changes (#53)"
Mar 21, 2025
8661760
lombok version changes
Mar 21, 2025
f19e6ba
Merge branch 'develop' of https://github.com/helenKaryamsetty/FHIR-AP…
Mar 21, 2025
3e2c7b2
API to fetch beneficiary ID linked with HealthID
Apr 3, 2025
b90abec
Merge branch 'develop' of https://github.com/helenKaryamsetty/FHIR-AP…
Apr 3, 2025
d77f370
modified sending benIds
Apr 8, 2025
6681955
Merge branch 'PSMRI:develop' into develop
helenKaryamsetty Apr 8, 2025
925dad3
getServices API upgrade to V3
Apr 8, 2025
0a4881e
Updated environment files
Apr 8, 2025
cd8db5b
Merge branch 'develop' of https://github.com/helenKaryamsetty/FHIR-AP…
Apr 8, 2025
355e7f2
Merge branch 'develop' of https://github.com/helenKaryamsetty/FHIR-AP…
Apr 8, 2025
00e28eb
fix(bug): fhir bundle creation scheduler calling for every 5mins
helenKaryamsetty May 19, 2025
35733f9
Merge branch 'PSMRI:develop' into develop
helenKaryamsetty May 20, 2025
fa6ef69
fix(bug): changed to objectmapper to gson malformed error
May 20, 2025
4576776
resolved merge conflicts
May 20, 2025
35bd3f8
fix(bug): bymistake removed comment
helenKaryamsetty May 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.springframework.stereotype.Service;
import org.springframework.web.client.HttpClientErrorException;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
Expand Down Expand Up @@ -78,7 +79,8 @@ public String generateOTP(String request) throws FHIRException {

String ndhmAuthToken = generateSession_NDHM.getNDHMAuthToken();
Map<String, String> responseMap = new HashMap<String, String>();
SendOTPForCard obj = InputMapper.gson().fromJson(request, SendOTPForCard.class);
ObjectMapper objectMapper = new ObjectMapper();
SendOTPForCard obj = objectMapper.convertValue(request, SendOTPForCard.class);
Comment on lines +82 to +83
Copy link
Contributor

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

Potential incorrect usage of Jackson ObjectMapper

If request is a JSON string (as the method signature suggests), convertValue is not the appropriate method. The convertValue method is for converting between different Java object types, not for deserializing JSON strings.

If request is a JSON string, use readValue instead:

- SendOTPForCard obj = objectMapper.convertValue(request, SendOTPForCard.class);
+ SendOTPForCard obj = objectMapper.readValue(request, SendOTPForCard.class);
πŸ“ 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
ObjectMapper objectMapper = new ObjectMapper();
SendOTPForCard obj = objectMapper.convertValue(request, SendOTPForCard.class);
ObjectMapper objectMapper = new ObjectMapper();
- SendOTPForCard obj = objectMapper.convertValue(request, SendOTPForCard.class);
+ SendOTPForCard obj = objectMapper.readValue(request, SendOTPForCard.class);
πŸ€– Prompt for AI Agents
In
src/main/java/com/wipro/fhir/service/ndhm/GenerateHealthID_CardServiceImpl.java
around lines 82 to 83, the code uses ObjectMapper's convertValue to convert a
JSON string to a Java object, which is incorrect. Replace convertValue with
readValue to properly deserialize the JSON string 'request' into a
SendOTPForCard object.

πŸ› οΈ Refactor suggestion

Missing exception handling for Jackson deserialization

The code doesn't handle potential exceptions that could be thrown by Jackson during deserialization (like JsonProcessingException). This could lead to unexpected runtime errors.

Add explicit exception handling for Jackson-specific exceptions:

 ObjectMapper objectMapper = new ObjectMapper();
-SendOTPForCard obj = objectMapper.convertValue(request, SendOTPForCard.class);
+SendOTPForCard obj;
+try {
+    obj = objectMapper.readValue(request, SendOTPForCard.class);
+} catch (JsonProcessingException e) {
+    throw new FHIRException("Error parsing JSON request: " + e.getMessage(), e);
+}

Committable suggestion skipped: line range outside the PR's diff.

πŸ€– Prompt for AI Agents
In
src/main/java/com/wipro/fhir/service/ndhm/GenerateHealthID_CardServiceImpl.java
around lines 82 to 83, the Jackson deserialization using
ObjectMapper.convertValue does not handle exceptions like
JsonProcessingException, which can cause runtime errors. Wrap the
deserialization code in a try-catch block that catches Jackson-specific
exceptions such as JsonProcessingException, and handle or log the exception
appropriately to prevent unexpected crashes.

πŸ’‘ Verification agent

🧩 Analysis chain

Inconsistent JSON processing approaches within the same class

The code has been modified to use Jackson's ObjectMapper for deserialization instead of Gson, but the rest of the class still uses Gson for other JSON operations (lines 98, 114, 125, etc.). This creates an inconsistent approach to JSON handling within the same class.

Consider standardizing on either Jackson or Gson throughout the class for consistency and maintainability. If Jackson is preferred, replace all Gson usage:

- String requestOBJ = new Gson().toJson(requestMap);
+ String requestOBJ = objectMapper.writeValueAsString(requestMap);

- res = new Gson().toJson(responseMap);
+ res = objectMapper.writeValueAsString(responseMap);

Also, verify that request is already a parsed object and not a JSON string. If it's a JSON string, use readValue instead:


🏁 Script executed:

#!/bin/bash
# Check how the input parameter is used in the codebase
grep -r "generateOTP(" --include="*.java" .

Length of output: 3145


Standardize on Jackson and correct JSON parsing of request

The generateOTP(String request) parameter is a raw JSON string, so
objectMapper.convertValue(request, SendOTPForCard.class) will not parse it. Use readValue instead, and eliminate mixed use of Gson in this class:

β€’ In src/main/java/com/wipro/fhir/service/ndhm/GenerateHealthID_CardServiceImpl.java:
– Replace at lines 82–83:
diff - ObjectMapper objectMapper = new ObjectMapper(); - SendOTPForCard obj = objectMapper.convertValue(request, SendOTPForCard.class); + ObjectMapper objectMapper = new ObjectMapper(); + SendOTPForCard obj = objectMapper.readValue(request, SendOTPForCard.class);
β€’ Replace all remaining new Gson().toJson(...) calls (e.g. lines 98, 114, 125) with:

- String requestOBJ = new Gson().toJson(requestMap);
+ String requestOBJ = objectMapper.writeValueAsString(requestMap);

- res = new Gson().toJson(responseMap);
+ res = objectMapper.writeValueAsString(responseMap);

β€’ Remove or refactor any new Gson().fromJson(...) to objectMapper.readValue(...).

This will ensure a single, consistent JSON-handling library (Jackson) and correctly parse incoming JSON strings.

πŸ“ 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
ObjectMapper objectMapper = new ObjectMapper();
SendOTPForCard obj = objectMapper.convertValue(request, SendOTPForCard.class);
ObjectMapper objectMapper = new ObjectMapper();
SendOTPForCard obj = objectMapper.readValue(request, SendOTPForCard.class);
πŸ€– Prompt for AI Agents
In
src/main/java/com/wipro/fhir/service/ndhm/GenerateHealthID_CardServiceImpl.java
around lines 82 to 83, replace the use of ObjectMapper.convertValue with
ObjectMapper.readValue to correctly parse the raw JSON string parameter
'request' into a SendOTPForCard object. Then, throughout the class, replace all
Gson usages (such as new Gson().toJson and new Gson().fromJson) with equivalent
Jackson ObjectMapper methods like writeValueAsString and readValue to
standardize JSON processing on Jackson and maintain consistency.


Map<String, Object> requestMap = null;
requestMap = new HashMap<String, Object>();
Expand Down
Loading