diff --git a/src/main/java/com/iemr/mmu/controller/common/main/InsertCommonController.java b/src/main/java/com/iemr/mmu/controller/common/main/InsertCommonController.java deleted file mode 100644 index 5c4544c1..00000000 --- a/src/main/java/com/iemr/mmu/controller/common/main/InsertCommonController.java +++ /dev/null @@ -1,70 +0,0 @@ -/* -* AMRIT – Accessible Medical Records via Integrated Technology -* Integrated EHR (Electronic Health Records) Solution -* -* Copyright (C) "Piramal Swasthya Management and Research Institute" -* -* This file is part of AMRIT. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see https://www.gnu.org/licenses/. -*/ -package com.iemr.mmu.controller.common.main; - -import java.util.Arrays; -import java.util.List; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.CrossOrigin; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import com.iemr.mmu.data.common.DocFileManager; -import com.iemr.mmu.service.common.transaction.CommonServiceImpl; -import com.iemr.mmu.utils.mapper.InputMapper; -import com.iemr.mmu.utils.response.OutputResponse; - -import io.swagger.v3.oas.annotations.Operation; - -@CrossOrigin -@RestController -@RequestMapping(value = "/commonInsert", headers = "Authorization") -public class InsertCommonController { - private Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); - @Autowired - private CommonServiceImpl commonServiceImpl; - - @CrossOrigin() - @Operation(summary = "Save beneficairy documents locally") - @PostMapping(value = { "/saveFiles" }, consumes = "application/json", produces = "application/json") - public String saveFiles(@RequestBody String request) { - OutputResponse response = new OutputResponse(); - - try { - DocFileManager[] docFileManager = InputMapper.gson().fromJson(request, DocFileManager[].class); - List docFileManagerList = Arrays.asList(docFileManager); - String s = commonServiceImpl.saveFiles(docFileManagerList); - if (s != null) - response.setResponse(s); - } catch (Exception e) { - logger.error("Error while saving files : " + e); - response.setError(5000, "Error while saving files : " + e); - } - - return response.toString(); - } -} diff --git a/src/main/java/com/iemr/mmu/repo/benFlowStatus/BeneficiaryFlowStatusRepo.java b/src/main/java/com/iemr/mmu/repo/benFlowStatus/BeneficiaryFlowStatusRepo.java index d996f43e..e492240c 100644 --- a/src/main/java/com/iemr/mmu/repo/benFlowStatus/BeneficiaryFlowStatusRepo.java +++ b/src/main/java/com/iemr/mmu/repo/benFlowStatus/BeneficiaryFlowStatusRepo.java @@ -204,7 +204,7 @@ public ArrayList 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) " + " ORDER BY consultationDate DESC ") public ArrayList getPharmaWorkListNew( @Param("providerServiceMapId") Integer providerServiceMapId, @Param("fromDate") Timestamp fromDate, diff --git a/src/main/java/com/iemr/mmu/service/common/transaction/CommonService.java b/src/main/java/com/iemr/mmu/service/common/transaction/CommonService.java index d8284bcc..eb7b679f 100644 --- a/src/main/java/com/iemr/mmu/service/common/transaction/CommonService.java +++ b/src/main/java/com/iemr/mmu/service/common/transaction/CommonService.java @@ -31,7 +31,6 @@ import com.iemr.mmu.utils.exception.IEMRException; public interface CommonService { - public String saveFiles(List docFileManagerList) throws IOException, Exception; public Resource loadFileAsResource(String file, String path) throws IOException; diff --git a/src/main/java/com/iemr/mmu/service/common/transaction/CommonServiceImpl.java b/src/main/java/com/iemr/mmu/service/common/transaction/CommonServiceImpl.java index 97975578..9f4d91d7 100644 --- a/src/main/java/com/iemr/mmu/service/common/transaction/CommonServiceImpl.java +++ b/src/main/java/com/iemr/mmu/service/common/transaction/CommonServiceImpl.java @@ -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; @@ -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; @@ -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 docFileManagerList) throws Exception { - ArrayList> 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 obj : responseList) { - String encryptedFilePath = aESEncryptionDecryption.encrypt(obj.get("filePath")); - obj.put("filePath",encryptedFilePath); - } - return new Gson().toJson(responseList); - } - - private ArrayList> createFile(List docFileManagerList, String basePath, - String currDate) throws IOException { - ArrayList> responseList = new ArrayList<>(); - Map 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