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
9 changes: 7 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,17 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<!-- <exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</exclusions> -->

Check warning on line 71 in pom.xml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this commented out code.

See more on https://sonarcloud.io/project/issues?id=PSMRI_TM-API&issues=AZ1nNTxybHT1rcuWw2Nl&open=AZ1nNTxybHT1rcuWw2Nl&pullRequest=145
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>co.elastic.logging</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,6 @@ public String getTCSpecialistWorklistFutureScheduled(
// openkm file download
@Operation(summary = "Add file as string to openKM")
@PostMapping(value = "/getKMFile", produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization")
@PreAuthorize("hasRole('NURSE') || hasRole('DOCTOR') ")
public String getKMFile(@Param(value = "{}") @RequestBody String request,
@RequestHeader(value = "Authorization") String Authorization) {
OutputResponse response = new OutputResponse();
Expand All @@ -819,6 +818,7 @@ public String getKMFile(@Param(value = "{}") @RequestBody String request,
}
} catch (Exception e) {
logger.error("Error while getting file download url : " + e);
response.setError(5000, "Error while getting file download url");
}
return response.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
@RestController
@RequestMapping(value = "/master", headers = "Authorization", produces = "application/json")
/** Objective: provides master data based on given visitCategory */
@PreAuthorize("hasRole('NURSE') || hasRole('DOCTOR') ")
@PreAuthorize("hasRole('NURSE') || hasRole('DOCTOR') || hasRole('LABTECHNICIAN') || hasRole('LAB_TECHNICIAN')")
public class CommonMasterController {

private Logger logger = LoggerFactory.getLogger(CommonMasterController.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,17 @@
import com.iemr.tm.utils.RestTemplateUtil;
import com.iemr.tm.utils.exception.IEMRException;
import com.iemr.tm.utils.mapper.InputMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import jakarta.servlet.http.HttpServletRequest;

@Service
@PropertySource("classpath:application.properties")
public class CommonServiceImpl implements CommonService {

private Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName());

@Value("${openkmDocUrl}")
private String openkmDocUrl;

Expand Down Expand Up @@ -550,23 +554,45 @@

// end

public String getOpenKMDocURL(String requestOBJ, String Authorization) throws JSONException {

Check failure on line 557 in src/main/java/com/iemr/tm/service/common/transaction/CommonServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this method to reduce its Cognitive Complexity from 23 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=PSMRI_TM-API&issues=AZ1nNTtvbHT1rcuWw2Ng&open=AZ1nNTtvbHT1rcuWw2Ng&pullRequest=145
RestTemplate restTemplate = new RestTemplate();
HttpServletRequest requestHeader = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
.getRequest();
String fileUUID = null;
JSONObject obj = new JSONObject(requestOBJ);
if (obj.has("fileID")) {

Check failure on line 563 in src/main/java/com/iemr/tm/service/common/transaction/CommonServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "fileID" 3 times.

See more on https://sonarcloud.io/project/issues?id=PSMRI_TM-API&issues=AZ1nNTtvbHT1rcuWw2Nf&open=AZ1nNTtvbHT1rcuWw2Nf&pullRequest=145
fileUUID = benVisitDetailRepo.getFileUUID(obj.getInt("fileID"));

logger.info("fileUUID for fileID " + obj.getInt("fileID") + " is " + fileUUID);

Check warning on line 566 in src/main/java/com/iemr/tm/service/common/transaction/CommonServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Invoke method(s) only conditionally. Use the built-in formatting to construct this argument.

See more on https://sonarcloud.io/project/issues?id=PSMRI_TM-API&issues=AZ1nNTtvbHT1rcuWw2Nd&open=AZ1nNTtvbHT1rcuWw2Nd&pullRequest=145

Check warning on line 566 in src/main/java/com/iemr/tm/service/common/transaction/CommonServiceImpl.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_TM-API&issues=AZ1nNTtvbHT1rcuWw2Nh&open=AZ1nNTtvbHT1rcuWw2Nh&pullRequest=145
logger.info("openkmDocUrl is " + openkmDocUrl);

Check warning on line 567 in src/main/java/com/iemr/tm/service/common/transaction/CommonServiceImpl.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_TM-API&issues=AZ1nNTtvbHT1rcuWw2Ni&open=AZ1nNTtvbHT1rcuWw2Ni&pullRequest=145

Check warning on line 567 in src/main/java/com/iemr/tm/service/common/transaction/CommonServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use the built-in formatting to construct this argument.

See more on https://sonarcloud.io/project/issues?id=PSMRI_TM-API&issues=AZ1nNTtvbHT1rcuWw2Ne&open=AZ1nNTtvbHT1rcuWw2Ne&pullRequest=145

if (fileUUID != null) {
Map<String, Object> requestBody = new HashMap<>();
requestBody.put("fileUID", fileUUID);

HttpEntity<Object> request = RestTemplateUtil.createRequestEntity(requestBody, Authorization);
ResponseEntity<String> response = restTemplate.exchange(openkmDocUrl, HttpMethod.POST, request,
String.class);
return response.getBody();
logger.info("Response=" + response.getBody());

Check warning on line 576 in src/main/java/com/iemr/tm/service/common/transaction/CommonServiceImpl.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_TM-API&issues=AZ1nNTtvbHT1rcuWw2Nj&open=AZ1nNTtvbHT1rcuWw2Nj&pullRequest=145

String responseBody = response.getBody();
if (responseBody != null) {
JSONObject responseObj = new JSONObject(responseBody);
if (responseObj.has("data")) {
Object dataVal = responseObj.get("data");
if (dataVal instanceof JSONObject) {

Check warning on line 583 in src/main/java/com/iemr/tm/service/common/transaction/CommonServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this instanceof check and cast with 'instanceof JSONObject dataObj'

See more on https://sonarcloud.io/project/issues?id=PSMRI_TM-API&issues=AZ1nNTtvbHT1rcuWw2Nk&open=AZ1nNTtvbHT1rcuWw2Nk&pullRequest=145
JSONObject dataObj = (JSONObject) dataVal;
if (dataObj.has("response")) {
String fileUrl = dataObj.getString("response");
// Fix malformed URL: https://user:pass@https://host -> https://user:pass@host
fileUrl = fileUrl.replaceAll("@https?://", "@");
return fileUrl;
}
}
return dataVal.toString();
}
}
return responseBody;
} else
return null;
} else
Expand Down
Loading