Skip to content
Open
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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public ArrayList<BeneficiaryFlowStatus> getOncologistWorkListNew(

@Query("SELECT t from BeneficiaryFlowStatus t WHERE t.pharmacist_flag = 1 "
+ " AND t.benVisitDate >= Date(:fromDate) AND t.vanID = :vanID "
+ " AND t.providerServiceMapId= :providerServiceMapId AND (doctorFlag = 9 OR specialist_flag = 9) "
+ " AND t.providerServiceMapId= :providerServiceMapId AND (doctor_Flag = 9 OR specialist_flag = 9) "
Copy link

Choose a reason for hiding this comment

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

πŸ’‘ Verification agent

🧩 Analysis chain

Potential inconsistency in column naming.

The identifier has been changed from doctorFlag to doctor_Flag in this query condition, but all other occurrences of this field in the repository use doctorFlag (lines 56, 84-85, 93-94, 152, 163, 225, 229, 242). This inconsistency could lead to subtle bugs or confusion for developers.


🏁 Script executed:

#!/bin/bash
# Description: Check all occurrences of doctorFlag vs doctor_Flag in the codebase

echo "Checking doctorFlag occurrences in SQL queries:"
rg -p 'doctorFlag' --type java src/main/java

echo -e "\nChecking doctor_Flag occurrences in SQL queries:"
rg -p 'doctor_Flag' --type java src/main/java

echo -e "\nChecking database table schema (if available):"
fd -e sql -e ddl | xargs grep -l 'CREATE TABLE.*ben_flow' | xargs cat

Length of output: 3225


Fix Inconsistent Naming for doctorFlag in JPA Queries

It appears that in the SQL condition at line 207 of src/main/java/com/iemr/mmu/repo/benFlowStatus/BeneficiaryFlowStatusRepo.java, the field is referenced as doctor_Flag while every other occurrence throughout the repository (e.g., lines 56, 84-85, 93-94, 152, 163, 225, 242) uses doctorFlag. This inconsistency in naming may lead to subtle bugs or developer confusion when mapping entity fields to database columns.

  • Action Required: Update the query condition in line 207 to use doctorFlag instead of doctor_Flag.
  • Additional Check: Review similar queries (for example, in src/main/java/com/iemr/mmu/repo/nurse/ncdscreening/IDRSDataRepo.java at line 50) to ensure consistent usage across the codebase.

+ " ORDER BY consultationDate DESC ")
public ArrayList<BeneficiaryFlowStatus> getPharmaWorkListNew(
@Param("providerServiceMapId") Integer providerServiceMapId, @Param("fromDate") Timestamp fromDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import com.iemr.mmu.utils.exception.IEMRException;

public interface CommonService {
public String saveFiles(List<DocFileManager> docFileManagerList) throws IOException, Exception;

public Resource loadFileAsResource(String file, String path) throws IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,15 @@
*/
package com.iemr.mmu.service.common.transaction;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Base64;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -55,12 +48,10 @@
import org.springframework.web.context.request.ServletRequestAttributes;

import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.iemr.mmu.data.benFlowStatus.BeneficiaryFlowStatus;
import com.iemr.mmu.data.common.DocFileManager;
import com.iemr.mmu.data.nurse.CommonUtilityClass;
import com.iemr.mmu.data.syncActivity_syncLayer.DownloadedCaseSheet;
import com.iemr.mmu.data.syncActivity_syncLayer.EmployeeSignature;
Expand Down Expand Up @@ -491,96 +482,7 @@ public String getBenPreviousVisitDataForCaseRecord(String comingRequest) throws

// end of Fetch beneficiary previous visit details for case-record

// files upload/save start
@Override
public String saveFiles(List<DocFileManager> docFileManagerList) throws Exception {
ArrayList<Map<String, String>> responseList = new ArrayList<>();
// this will come from property file
// String basePath = "C:/apps/Neeraj/mmuDoc";
String basePath = fileBasePath;

String currDate = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));

if (docFileManagerList.size() > 0) {
basePath += docFileManagerList.get(0).getVanID();
File file = new File(basePath + "/" + currDate);

if (file.isDirectory()) {
responseList = createFile(docFileManagerList, basePath, currDate);
} else {
// create a new directory
Files.createDirectories(Paths.get(basePath + "/" + currDate));
responseList = createFile(docFileManagerList, basePath, currDate);
}
}
/*
*
*
AN40085822 - Internal path disclosure -encryption
*
*
*/
for (Map<String, String> obj : responseList) {
String encryptedFilePath = aESEncryptionDecryption.encrypt(obj.get("filePath"));
obj.put("filePath",encryptedFilePath);
}
return new Gson().toJson(responseList);
}

private ArrayList<Map<String, String>> createFile(List<DocFileManager> docFileManagerList, String basePath,
String currDate) throws IOException {
ArrayList<Map<String, String>> responseList = new ArrayList<>();
Map<String, String> responseMap;
FileOutputStream FOS = null;
try
{


for (DocFileManager dFM : docFileManagerList) {
if (dFM.getFileName() != null && dFM.getFileExtension() != null) {
responseMap = new HashMap<>();
dFM.setFileName(dFM.getFileName().replace("`", "").replace("'", "").replace("$", "").replace("\\", "")
.replace("/", "").replace("~", "").replace("`", "").replace("!", "").replace("@", "")
.replace("#", "").replace("$", "").replace("%", "").replace("^", "").replace("&", "")
.replace("*", "").replace("(", "").replace(")", "").replace("{", "").replace("}", "")
.replace("[", "").replace("]", "").replace("|", "").replace("\\", "").replace(":", "")
.replace(";", "").replace("-", "").replace("_", "").replace("+", "").replace("=", "")
.replace("\"", "").replace("'", ""));

Long currTimestamp = System.currentTimeMillis();
FOS = new FileOutputStream(
basePath + "/" + currDate + "/" + currTimestamp + dFM.getFileName());

FOS.write(Base64.getDecoder().decode(dFM.getFileContent()));

responseMap.put("fileName", dFM.getFileName());
responseMap.put("filePath", basePath + "/" + currDate + "/" + currTimestamp + dFM.getFileName());
// + System.currentTimeMillis() + dFM.getFileExtension());
// returnOBJ[i] = basePath + "/" + currDate + "/" + dFM.getFileName() + System.currentTimeMillis()
// + dFM.getFileExtension();

FOS.flush();


responseList.add(responseMap);
}

if(FOS!=null)
FOS.close();
}
}
catch(Exception e)
{
logger.error(e.getMessage());
}
finally
{
if(FOS!=null)
FOS.close();
}
return responseList;

}

// load file as resource
@Override
Expand Down
Loading