Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.iemr.hwc</groupId>
<artifactId>hwc-api</artifactId>
<version>3.2.1</version>
<version>3.4.0</version>
<packaging>war</packaging>

<name>HWC-API</name>
Expand Down Expand Up @@ -490,4 +490,4 @@
</plugins>
</build>

</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,19 @@
public ResponseEntity<String> getOutreachMasterForState(@PathVariable("stateID") Integer stateID) {
logger.info("get Outreach programs for state with Id ..." + stateID);

OutputResponse outputResponse = new OutputResponse();
OutputResponse response = new OutputResponse();

Check warning on line 201 in src/main/java/com/iemr/hwc/controller/wo/LocationControllerWo.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename "response" which hides the field declared at line 46.

See more on https://sonarcloud.io/project/issues?id=PSMRI_HWC-API&issues=AZrjn_6BNjXiJ6hv6kjI&open=AZrjn_6BNjXiJ6hv6kjI&pullRequest=172
HttpStatus statusCode = HttpStatus.OK;
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
headers.add("Content-Type", "application/json");

try {
String resList = locationServiceImpl.getOutreachProgramsList(stateID);
outputResponse.setResponse(resList);
response.setResponse(resList);
} catch (Exception e) {
logger.error("Error while fetching outreach list for stateId" + stateID);
response.setError(500, "Unable to fetch outreach list for stateId" + stateID + "Exception - " + e);
statusCode = HttpStatus.INTERNAL_SERVER_ERROR;
}
return new ResponseEntity<>(outputResponse.toStringWithSerializeNulls(), headers, statusCode);
return new ResponseEntity<>(response.toStringWithSerializeNulls(), headers, statusCode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
import java.util.ArrayList;
import java.util.List;

import com.google.gson.annotations.Expose;
import com.iemr.hwc.annotation.sqlInjectionSafe.SQLInjectionSafe;
import com.iemr.hwc.data.login.MasterVan;
import com.iemr.hwc.data.masterdata.registrar.GenderMaster;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
Expand All @@ -36,11 +41,6 @@
import jakarta.persistence.Table;
import jakarta.persistence.Transient;

import com.google.gson.annotations.Expose;
import com.iemr.hwc.annotation.sqlInjectionSafe.SQLInjectionSafe;
import com.iemr.hwc.data.login.MasterVan;
import com.iemr.hwc.data.masterdata.registrar.GenderMaster;

/***
*
* @author NE298657
Expand Down Expand Up @@ -296,6 +296,19 @@
@Column(name = "referred_visit_id")
private Long referred_visit_id;


@Transient
Boolean is_high_risk;

Check warning on line 301 in src/main/java/com/iemr/hwc/data/benFlowStatus/BeneficiaryFlowStatus.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this field "is_high_risk" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.

See more on https://sonarcloud.io/project/issues?id=PSMRI_HWC-API&issues=AZrjn_zcNjXiJ6hv6ki_&open=AZrjn_zcNjXiJ6hv6ki_&pullRequest=172


public Boolean isIs_high_risk() {

Check warning on line 304 in src/main/java/com/iemr/hwc/data/benFlowStatus/BeneficiaryFlowStatus.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this method name to match the regular expression '^[a-z][a-zA-Z0-9]*$'.

See more on https://sonarcloud.io/project/issues?id=PSMRI_HWC-API&issues=AZrjn_zcNjXiJ6hv6kjA&open=AZrjn_zcNjXiJ6hv6kjA&pullRequest=172
return is_high_risk;
}

public void setIs_high_risk(boolean is_high_risk) {

Check warning on line 308 in src/main/java/com/iemr/hwc/data/benFlowStatus/BeneficiaryFlowStatus.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this method name to match the regular expression '^[a-z][a-zA-Z0-9]*$'.

See more on https://sonarcloud.io/project/issues?id=PSMRI_HWC-API&issues=AZrjn_zcNjXiJ6hv6kjB&open=AZrjn_zcNjXiJ6hv6kjB&pullRequest=172

Check warning on line 308 in src/main/java/com/iemr/hwc/data/benFlowStatus/BeneficiaryFlowStatus.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.

See more on https://sonarcloud.io/project/issues?id=PSMRI_HWC-API&issues=AZrjn_zcNjXiJ6hv6ki-&open=AZrjn_zcNjXiJ6hv6ki-&pullRequest=172
this.is_high_risk = is_high_risk;
}
Comment on lines +304 to +310
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix naming convention and method signature issues.

The getter method name isIs_high_risk() is unconventional and confusing. Additionally, the setter method parameter is a primitive boolean while the field is Boolean (nullable), which could lead to auto-boxing issues and prevents setting the field to null.

Apply this diff to fix the naming and type consistency:

-public Boolean isIs_high_risk() {
+public Boolean getIs_high_risk() {
    return is_high_risk;
}

-public void setIs_high_risk(boolean is_high_risk) {
+public void setIs_high_risk(Boolean is_high_risk) {
    this.is_high_risk = is_high_risk;
}
πŸ“ 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
public Boolean isIs_high_risk() {
return is_high_risk;
}
public void setIs_high_risk(boolean is_high_risk) {
this.is_high_risk = is_high_risk;
}
public Boolean getIs_high_risk() {
return is_high_risk;
}
public void setIs_high_risk(Boolean is_high_risk) {
this.is_high_risk = is_high_risk;
}
πŸ€– Prompt for AI Agents
In src/main/java/com/iemr/hwc/data/benFlowStatus/BeneficiaryFlowStatus.java
around lines 304-310, the getter name isIs_high_risk() is unconventional and the
setter uses a primitive boolean while the field is a nullable Boolean; rename
the getter to getIs_high_risk() (or a camelCase equivalent like
isHighRisk/getHighRisk consistently across the class) and change the setter
signature to accept a java.lang.Boolean parameter so the field can be set to
null without boxing issues.


@Transient
private I_bendemographics i_bendemographics;
@Transient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
public ArrayList<BeneficiaryFlowStatus> getNurseWorklistNew(
@Param("providerServiceMapId") Integer providerServiceMapId, @Param("vanID") Integer vanID,
@Param("fromDate") Timestamp fromDate);

// nurse worklist TC current date
@Query("SELECT t from BeneficiaryFlowStatus t WHERE (t.specialist_flag != 0 AND t.specialist_flag != 100 AND t.specialist_flag is not null)"
+ " AND t.deleted = false AND DATE(t.benVisitDate) >= DATE(:fromDate) "
Expand Down Expand Up @@ -458,5 +457,8 @@

@Query("SELECT COUNT(t) from BeneficiaryFlowStatus t WHERE t.villageID IN :villageIDs AND t.modified_date > :lastModDate ")
Long getFlowRecordsCount(@Param("villageIDs") List<Integer> villageID, @Param("lastModDate") Timestamp lastModDate);

@Query(value = "SELECT is_high_risk from t_anc_visit t WHERE t.ben_id = :ben_id order by 1 desc limit 1",nativeQuery = true)
public Boolean getIsHighrisk(@Param("ben_id") Long ben_id);

Check warning on line 462 in src/main/java/com/iemr/hwc/repo/benFlowStatus/BeneficiaryFlowStatusRepo.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.

See more on https://sonarcloud.io/project/issues?id=PSMRI_HWC-API&issues=AZrjn_5QNjXiJ6hv6kjH&open=AZrjn_5QNjXiJ6hv6kjH&pullRequest=172
Comment on lines +461 to +462
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Potential performance issue with unbounded query.

The query lacks an ORDER BY clause and uses LIMIT 1 without specifying which record to return when multiple ANC visits exist for a beneficiary. This could return inconsistent results. The AI summary mentions "order by 1 desc limit 1" but the actual code shows "order by 1 desc limit 1" where "1" refers to the first column (is_high_risk), which doesn't guarantee the most recent visit.

Consider ordering by a timestamp field to get the most recent ANC visit:

-@Query(value = "SELECT is_high_risk from t_anc_visit t WHERE t.ben_id = :ben_id order by 1 desc limit 1",nativeQuery = true)
+@Query(value = "SELECT is_high_risk from t_anc_visit t WHERE t.ben_id = :ben_id ORDER BY t.created_date DESC LIMIT 1",nativeQuery = true)
πŸ“ 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
@Query(value = "SELECT is_high_risk from t_anc_visit t WHERE t.ben_id = :ben_id order by 1 desc limit 1",nativeQuery = true)
public Boolean getIsHighrisk(@Param("ben_id") Long ben_id);
@Query(value = "SELECT is_high_risk from t_anc_visit t WHERE t.ben_id = :ben_id ORDER BY t.created_date DESC LIMIT 1",nativeQuery = true)
public Boolean getIsHighrisk(@Param("ben_id") Long ben_id);


}
165 changes: 94 additions & 71 deletions src/main/java/com/iemr/hwc/service/choApp/CHOAppSyncServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -604,36 +604,44 @@
return new ResponseEntity<>(outputResponse.toString(),headers,statusCode);
}

@Override
public ResponseEntity<String> savePrescriptionTemplatesToApp(Integer userID, String authorization) {
OutputResponse outputResponse = new OutputResponse();
HttpStatus statusCode = HttpStatus.OK;

MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
headers.add("Content-Type", "application/json");

List<PrescriptionTemplates> templateList = prescriptionTemplatesRepo.getPrescriptionTemplatesByUserID(userID);

outputResponse.setResponse(new GsonBuilder().excludeFieldsWithoutExposeAnnotation().serializeNulls().create().toJson(templateList));

return new ResponseEntity<>(outputResponse.toStringWithSerializeNulls(),headers,statusCode);
}

@Override
public ResponseEntity<String> deletePrescriptionTemplates(Integer userID, Integer tempID) {
OutputResponse outputResponse = new OutputResponse();
HttpStatus statusCode = HttpStatus.OK;

MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
headers.add("Content-Type", "application/json");

prescriptionTemplatesRepo.deletePrescriptionTemplatesByUserIDAndTempID(userID, tempID);

outputResponse.setResponse("Successfully deleted");

return new ResponseEntity<>(outputResponse.toString(),headers,statusCode);
}

@Override
public ResponseEntity<String> savePrescriptionTemplatesToApp(Integer userID, String authorization) {
OutputResponse outputResponse = new OutputResponse();
HttpStatus statusCode = HttpStatus.OK;

MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
headers.add("Content-Type", "application/json");
try {
List<PrescriptionTemplates> templateList = prescriptionTemplatesRepo
.getPrescriptionTemplatesByUserID(userID);
outputResponse.setResponse(new GsonBuilder().excludeFieldsWithoutExposeAnnotation().serializeNulls()
.create().toJson(templateList));
} catch (Exception e) {
logger.error("Error while fetching Prescription Templates userID : " + userID);

Check warning on line 620 in src/main/java/com/iemr/hwc/service/choApp/CHOAppSyncServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Format specifiers should be used instead of string concatenation.

See more on https://sonarcloud.io/project/issues?id=PSMRI_HWC-API&issues=AZrjn_4bNjXiJ6hv6kjD&open=AZrjn_4bNjXiJ6hv6kjD&pullRequest=172
outputResponse.setError(500, "Unable to fetch Prescription Templates userID" + userID + "Exception - " + e);
statusCode = HttpStatus.INTERNAL_SERVER_ERROR;

}
return new ResponseEntity<>(outputResponse.toStringWithSerializeNulls(), headers, statusCode);
}

@Override
public ResponseEntity<String> deletePrescriptionTemplates(Integer userID, Integer tempID) {
OutputResponse outputResponse = new OutputResponse();
HttpStatus statusCode = HttpStatus.OK;
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
headers.add("Content-Type", "application/json");
try {
prescriptionTemplatesRepo.deletePrescriptionTemplatesByUserIDAndTempID(userID, tempID);
outputResponse.setResponse("Successfully deleted");
} catch (Exception e) {
logger.error("Error while deleting Prescription Templates userID : " + userID + " tempID : " + tempID);

Check warning on line 638 in src/main/java/com/iemr/hwc/service/choApp/CHOAppSyncServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Format specifiers should be used instead of string concatenation.

See more on https://sonarcloud.io/project/issues?id=PSMRI_HWC-API&issues=AZrjn_4bNjXiJ6hv6kjE&open=AZrjn_4bNjXiJ6hv6kjE&pullRequest=172
outputResponse.setError(500, "Unable to delete Prescription Templates userID : " + userID + " tempID "
+ tempID + "Exception - " + e);
statusCode = HttpStatus.INTERNAL_SERVER_ERROR;
}
return new ResponseEntity<>(outputResponse.toString(), headers, statusCode);
}

@Override
public ResponseEntity<String> createNewOutreachActivity(OutreachActivity activity, String authorization) {
Expand Down Expand Up @@ -674,45 +682,60 @@
return new ResponseEntity<>(outputResponse.toString(),headers,statusCode);
}

@Override
public ResponseEntity<String> getActivitiesByUser(Integer userId, String authorization) {
OutputResponse outputResponse = new OutputResponse();
HttpStatus statusCode = HttpStatus.OK;

MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
headers.add("Content-Type", "application/json");

ArrayList<Object[]> activitiesObj = outreachActivityRepo.getActivitiesByUserID(userId);

ArrayList<OutreachActivity> activities = OutreachActivity.getActivitiesForUser(activitiesObj);

outputResponse.setResponse(new GsonBuilder().excludeFieldsWithoutExposeAnnotation().serializeNulls().create().toJson(activities));

return new ResponseEntity<>(outputResponse.toStringWithSerializeNulls(),headers,statusCode);
}

@Override
public ResponseEntity<String> getActivityById(Integer activityId, String authorization) {
OutputResponse outputResponse = new OutputResponse();
HttpStatus statusCode = HttpStatus.OK;

MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
headers.add("Content-Type", "application/json");

OutreachActivity activity = outreachActivityRepo.findById(activityId).get();

if (activity != null && activity.getImg1Data() != null){
String img1 = Base64.getEncoder().encodeToString(activity.getImg1Data());
activity.setImg1(img1);
}

if (activity != null && activity.getImg2Data() != null){
String img2 = Base64.getEncoder().encodeToString(activity.getImg2Data());
activity.setImg2(img2);
}

outputResponse.setResponse(new GsonBuilder().excludeFieldsWithoutExposeAnnotation().serializeNulls().create().toJson(activity));

return new ResponseEntity<>(outputResponse.toStringWithSerializeNulls(),headers,statusCode);
}
@Override
public ResponseEntity<String> getActivitiesByUser(Integer userId, String authorization) {
OutputResponse outputResponse = new OutputResponse();
HttpStatus statusCode = HttpStatus.OK;

MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
headers.add("Content-Type", "application/json");
try {
ArrayList<Object[]> activitiesObj = outreachActivityRepo.getActivitiesByUserID(userId);

ArrayList<OutreachActivity> activities = OutreachActivity.getActivitiesForUser(activitiesObj);

outputResponse.setResponse(new GsonBuilder().excludeFieldsWithoutExposeAnnotation().serializeNulls()
.create().toJson(activities));
} catch (Exception e) {
logger.error("Encountered exception while fetching activity userId : " + userId);

Check warning on line 700 in src/main/java/com/iemr/hwc/service/choApp/CHOAppSyncServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Format specifiers should be used instead of string concatenation.

See more on https://sonarcloud.io/project/issues?id=PSMRI_HWC-API&issues=AZrjn_4bNjXiJ6hv6kjF&open=AZrjn_4bNjXiJ6hv6kjF&pullRequest=172
outputResponse.setError(500, "Encountered exception while fetching activity. " + e);
statusCode = HttpStatus.INTERNAL_SERVER_ERROR;
}
return new ResponseEntity<>(outputResponse.toStringWithSerializeNulls(), headers, statusCode);
}

@Override
public ResponseEntity<String> getActivityById(Integer activityId, String authorization) {
OutputResponse outputResponse = new OutputResponse();
HttpStatus statusCode = HttpStatus.OK;

MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
headers.add("Content-Type", "application/json");
try {
Optional<OutreachActivity> activityOptional = outreachActivityRepo.findById(activityId);
if (activityOptional.isPresent()) {
OutreachActivity activity = activityOptional.get();
if (activity.getImg1Data() != null) {
String img1 = Base64.getEncoder().encodeToString(activity.getImg1Data());
activity.setImg1(img1);
}

if (activity.getImg2Data() != null) {
String img2 = Base64.getEncoder().encodeToString(activity.getImg2Data());
activity.setImg2(img2);
}

outputResponse.setResponse(new GsonBuilder().excludeFieldsWithoutExposeAnnotation().serializeNulls()
.create().toJson(activity));
}else {
outputResponse.setError(404, "Activity not found with ID : "+activityId);
statusCode = HttpStatus.NOT_FOUND;
}
} catch (Exception e) {
logger.error("Encountered exception while fetching activity activityId " + activityId);

Check warning on line 735 in src/main/java/com/iemr/hwc/service/choApp/CHOAppSyncServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Format specifiers should be used instead of string concatenation.

See more on https://sonarcloud.io/project/issues?id=PSMRI_HWC-API&issues=AZrjn_4bNjXiJ6hv6kjG&open=AZrjn_4bNjXiJ6hv6kjG&pullRequest=172
outputResponse.setError(500, "Encountered exception while fetching activity. " + e);
statusCode = HttpStatus.INTERNAL_SERVER_ERROR;
}
return new ResponseEntity<>(outputResponse.toStringWithSerializeNulls(), headers, statusCode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3541,10 +3541,15 @@ public String getNurseWorkListNew(Integer providerServiceMapId, Integer vanID) {
else
cal.add(Calendar.DAY_OF_YEAR, -7);
long sevenDaysAgo = cal.getTimeInMillis();
Timestamp fromDate = new Timestamp(sevenDaysAgo);

ArrayList<BeneficiaryFlowStatus> obj = beneficiaryFlowStatusRepo.getNurseWorklistNew(providerServiceMapId,
vanID, new Timestamp(sevenDaysAgo));

vanID, fromDate);
for (BeneficiaryFlowStatus beneficiaryFlowStatus : obj) {
Boolean isHighrisk = beneficiaryFlowStatusRepo.getIsHighrisk(beneficiaryFlowStatus.getBeneficiaryID());
if(null != isHighrisk)
beneficiaryFlowStatus.setIs_high_risk(isHighrisk);
}
return new Gson().toJson(obj);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,7 @@ public String fetchConfirmedScreeningDisease(Long beneficiaryRegId) throws IEMRE
List<Object[]> resultSet = hypertensionScreeningRepo.fetchConfirmedScreening(beneficiaryRegId);
if (resultSet != null && resultSet.size() > 0) {
for (Object[] obj : resultSet) {
map.put("beneficiaryRegId", obj[0] != null ? ((BigInteger) obj[0]).longValue() : null);
map.put("beneficiaryRegId", obj[0] != null ? ((Long) obj[0]) : null);
if (obj[1] != null && (Boolean) obj[1] == true)
response.add("Diabetes Mellitus");
Comment on lines 1699 to 1702
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Unsafe cast to Long can throw ClassCastException (likely BigInteger).

Native/aggregate queries often return BigInteger for numeric columns. Casting obj[0] to Long will break at runtime.

Use a robust conversion:

-                    map.put("beneficiaryRegId", obj[0] != null ? ((Long) obj[0]) : null);
+                    Object id0 = obj[0];
+                    Long beneficiaryRegId = null;
+                    if (id0 instanceof java.math.BigInteger) {
+                        beneficiaryRegId = ((java.math.BigInteger) id0).longValue();
+                    } else if (id0 instanceof Number) {
+                        beneficiaryRegId = ((Number) id0).longValue();
+                    }
+                    map.put("beneficiaryRegId", beneficiaryRegId);
πŸ“ 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
for (Object[] obj : resultSet) {
map.put("beneficiaryRegId", obj[0] != null ? ((BigInteger) obj[0]).longValue() : null);
map.put("beneficiaryRegId", obj[0] != null ? ((Long) obj[0]) : null);
if (obj[1] != null && (Boolean) obj[1] == true)
response.add("Diabetes Mellitus");
for (Object[] obj : resultSet) {
Object id0 = obj[0];
Long beneficiaryRegId = null;
if (id0 instanceof java.math.BigInteger) {
beneficiaryRegId = ((java.math.BigInteger) id0).longValue();
} else if (id0 instanceof Number) {
beneficiaryRegId = ((Number) id0).longValue();
}
map.put("beneficiaryRegId", beneficiaryRegId);
if (obj[1] != null && (Boolean) obj[1] == true)
response.add("Diabetes Mellitus");
πŸ€– Prompt for AI Agents
In src/main/java/com/iemr/hwc/service/ncdscreening/NCDScreeningServiceImpl.java
around lines 1699 to 1702, the code unsafely casts obj[0] to Long which can
throw ClassCastException (DB returns BigInteger/Integer/etc.); replace the
direct cast with a safe conversion that handles Number types (e.g., check if
obj[0] is an instance of Number and use ((Number)obj[0]).longValue(), or if null
leave null), and ensure you handle BigInteger specifically if needed so
beneficiaryRegId is set to a Long without risking ClassCastException.

if (obj[2] != null && (Boolean) obj[2] == true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.springframework.stereotype.Component;
import com.iemr.hwc.utils.http.AuthorizationHeaderRequestWrapper;

import com.iemr.hwc.utils.http.AuthorizationHeaderRequestWrapper;

Check warning on line 11 in src/main/java/com/iemr/hwc/utils/JwtUserIdValidationFilter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this duplicated import.

See more on https://sonarcloud.io/project/issues?id=PSMRI_HWC-API&issues=AZrjn_1LNjXiJ6hv6kjC&open=AZrjn_1LNjXiJ6hv6kjC&pullRequest=172

import jakarta.servlet.Filter;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
Expand Down Expand Up @@ -114,8 +116,8 @@
logger.warn("No valid authentication token found");
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized: Invalid or missing token");
} catch (Exception e) {
logger.error("Authorization error: ", e);
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Authorization error: " + e.getMessage());
logger.error("Authorization error: ", e);
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Authorization error: " + e.getMessage());
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/iemr/hwc/utils/RestTemplateUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public static HttpEntity<Object> createRequestEntity(Object body, String authori
headers.add(HttpHeaders.USER_AGENT, UserAgentContext.getUserAgent());
}
headers.add(HttpHeaders.AUTHORIZATION, authorization);
headers.add("JwtToken",requestHeader.getHeader("JwtToken"));
if(null != requestHeader.getHeader(Constants.JWT_TOKEN))
headers.add(Constants.JWT_TOKEN,requestHeader.getHeader(Constants.JWT_TOKEN));
if(null != jwtTokenFromCookie) {
headers.add(HttpHeaders.COOKIE, "Jwttoken=" + jwtTokenFromCookie);
}
Expand Down