diff --git a/src/main/environment/common_ci.properties b/src/main/environment/common_ci.properties index 1f82e9ea..bc54687c 100644 --- a/src/main/environment/common_ci.properties +++ b/src/main/environment/common_ci.properties @@ -167,5 +167,7 @@ grievanceAllocationRetryConfiguration=3 start-grievancedatasync-scheduler=false cron-scheduler-grievancedatasync=0 0/2 * * * ? +cors.allowed-origins= + diff --git a/src/main/java/com/iemr/common/config/CorsConfig.java b/src/main/java/com/iemr/common/config/CorsConfig.java new file mode 100644 index 00000000..e4f484a0 --- /dev/null +++ b/src/main/java/com/iemr/common/config/CorsConfig.java @@ -0,0 +1,25 @@ +package com.iemr.common.config; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class CorsConfig implements WebMvcConfigurer { + + @Value("${cors.allowed-origins}") + private String allowedOrigins; + + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**") + .allowedOrigins(allowedOrigins.split(",")) + .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") + .allowedHeaders("*") + .exposedHeaders("Authorization", "Jwttoken") // Explicitly expose headers if needed + .allowCredentials(true) + .maxAge(3600) + ; + } +} \ No newline at end of file diff --git a/src/main/java/com/iemr/common/controller/abdmfacility/AbdmFacilityController.java b/src/main/java/com/iemr/common/controller/abdmfacility/AbdmFacilityController.java index 9ec79f65..970a2770 100644 --- a/src/main/java/com/iemr/common/controller/abdmfacility/AbdmFacilityController.java +++ b/src/main/java/com/iemr/common/controller/abdmfacility/AbdmFacilityController.java @@ -3,18 +3,15 @@ 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.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; - import com.iemr.common.service.abdmfacility.AbdmFacilityService; import com.iemr.common.utils.response.OutputResponse; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.parameters.RequestBody; @RequestMapping({ "/facility" }) @RestController @@ -24,8 +21,7 @@ public class AbdmFacilityController { @Autowired private AbdmFacilityService abdmFacilityService; - - @CrossOrigin + @Operation(summary = "Get Abdm facility mapped to worklocation") @GetMapping(value = { "/getWorklocationMappedAbdmFacility/{workLocationId}" }) public String getAbdmFacilityDetails(@PathVariable int workLocationId, @RequestHeader(value = "Authorization") String Authorization) { diff --git a/src/main/java/com/iemr/common/controller/beneficiary/BeneficiaryRegistrationController.java b/src/main/java/com/iemr/common/controller/beneficiary/BeneficiaryRegistrationController.java index 49ff938e..ee20c7e4 100644 --- a/src/main/java/com/iemr/common/controller/beneficiary/BeneficiaryRegistrationController.java +++ b/src/main/java/com/iemr/common/controller/beneficiary/BeneficiaryRegistrationController.java @@ -1,24 +1,24 @@ /* -* 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/. -*/ + * 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.common.controller.beneficiary; import java.lang.reflect.Field; @@ -26,21 +26,17 @@ import java.util.List; import java.util.Map; import java.util.Set; - import javax.ws.rs.core.MediaType; - import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; 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.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; - import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonMappingException; @@ -74,522 +70,509 @@ import com.iemr.common.utils.mapper.InputMapper; import com.iemr.common.utils.mapper.OutputMapper; import com.iemr.common.utils.response.OutputResponse; - import io.lettuce.core.dynamic.annotation.Param; import io.swagger.v3.oas.annotations.Operation; import jakarta.servlet.http.HttpServletRequest; -@RequestMapping({ "/beneficiary" }) +@RequestMapping({"/beneficiary"}) @RestController public class BeneficiaryRegistrationController { - private InputMapper inputMapper = new InputMapper(); - - private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); - private static final String AUTHORIZATION = "authorization"; - private RegisterBenificiaryService registerBenificiaryService; - private IEMRBeneficiaryTypeService iemrBeneficiaryTypeService; - private IEMRSearchUserService iemrSearchUserService; - private EducationService educationService; - private TitleService titleService; - private StatusService statusService; - private LocationService locationService; - private GenderService genderService; - private MaritalStatusService maritalStatusService; - private CommunityService communityService; - private DirectoryService directoryService; - private SexualOrientationService sexualOrientationService; - private LanguageService languageService; - private BenRelationshipTypeService benRelationshipTypeService; - private BeneficiaryOccupationService beneficiaryOccupationService; - private GovtIdentityTypeService govtIdentityTypeService; - - @Autowired - public void setBenRelationshipTypeService(BenRelationshipTypeService benRelationshipTypeService) { - this.benRelationshipTypeService = benRelationshipTypeService; - } - - @Autowired - public void setBeneficiaryOccupationService(BeneficiaryOccupationService beneficiaryOccupationService) { - this.beneficiaryOccupationService = beneficiaryOccupationService; - } - - @Autowired - public void setIEMRSearchUserService(IEMRSearchUserService iemrSearchUserService) { - this.iemrSearchUserService = iemrSearchUserService; - } - - @Autowired - public void setIEMRBeneficiaryTypeService(IEMRBeneficiaryTypeService iemrBeneficiaryTypeService) { - this.iemrBeneficiaryTypeService = iemrBeneficiaryTypeService; - } - - @Autowired - public void setRegisterBenificiaryService(RegisterBenificiaryService registerBenificiaryService) { - this.registerBenificiaryService = registerBenificiaryService; - } - - @Autowired - public void setEducationService(EducationService educationService1) { - this.educationService = educationService1; - } - - @Autowired - public void setTitleService(TitleService titleService1) { - this.titleService = titleService1; - } - - @Autowired - public void setStatusService(StatusService statusService1) { - this.statusService = statusService1; - } - - @Autowired - public void setLocationService(LocationService locationService1) { - this.locationService = locationService1; - } - - @Autowired - public void setGenderService(GenderService genderService) { - this.genderService = genderService; - } - - @Autowired - public void setMaritalStatusService(MaritalStatusService maritalStatusService) { - this.maritalStatusService = maritalStatusService; - } - - @Autowired - public void setCommunityService(CommunityService communityService) { - this.communityService = communityService; - } - - @Autowired - public void setLanguageService(LanguageService languageService) { - this.languageService = languageService; - } - - @Autowired - public void setDirectoryService(DirectoryService directoryService) { - this.directoryService = directoryService; - } - - @Autowired - public void setSexualOrientationService(SexualOrientationService sexualOrientationService) { - this.sexualOrientationService = sexualOrientationService; - } - - @Autowired - public void setGovtIdentityTypeService(GovtIdentityTypeService govtIdentityTypeService) { - this.govtIdentityTypeService = govtIdentityTypeService; - } - - @Autowired - private CallReportsService callReportsService; - - @Operation(summary = "Create a new beneficiary") - @CrossOrigin() - @RequestMapping(value = "/create", method = RequestMethod.POST, produces = "application/json", consumes = "application/json", headers = "Authorization") - - public String createBeneficiary( - @Param(value = "{\"providerServiceMapID\":\"Integer\",\"firstName\":\"String\",\"lastName\":\"String\",\"dOB\":\"Timestamp\"," - + "\"ageUnits\":\"String\",\"fatherName\":\"String\",\"spouseName\":\"String\",\"govtIdentityNo\":\"String\"," - + "\"govtIdentityTypeID\":\"Integer\",\"emergencyRegistration\":\"Boolean\",\"createdBy\":\"String\"," - + "\"titleId\":\"Short\",\"statusID\":\"Short\",\"registeredServiceID\":\"Short\",\"maritalStatusID\":\"Short\"," - + "\"genderID\":\"Integer\",\"i_bendemographics\":{\"educationID\":\"Long\",\"occupationID\":\"Integer\"," - + "\"healthCareWorkerID\":\"Short\",\"communityID\":\"Integer\",\"districtID\":\"Integer\",\"stateID\":\"Integer\"," - + "\"pinCode\":\"String\",\"blockID\":\"Integer\",\"districtBranchID\":\"Integer\",\"createdBy\":\"String\"," - + "\"addressLine1\":\"String\"},\"benPhoneMaps\":{\"parentBenRegID\":\"Long\",\"phoneNo\":\"String\"," - + "\"phoneTypeID\":\"Integer\",\"benRelationshipID\":\"Integer\",\"deleted\":\"Boolean\",\"createdBy\":\"String\"}," - + "\"faceEmbedding\":[\"Float\"]}") @RequestBody BeneficiaryModel beneficiaryModel, - HttpServletRequest httpRequest) { - OutputResponse response = new OutputResponse(); - - logger.info("Create beneficiary request " + beneficiaryModel); - try { - - response.setResponse(registerBenificiaryService.save(beneficiaryModel, httpRequest)); - } catch (Exception e) { - logger.error("create beneficiary failed with error " + e.getMessage(), e); - response.setError(e); - } - - logger.info("create beneficiary response " + response.toString()); - return response.toString(); - } - - @Operation(summary = "Create a new beneficiary for customization") - @CrossOrigin() - @RequestMapping(value = "/createBeneficiary", method = RequestMethod.POST, produces = "application/json", consumes = "application/json", headers = "Authorization") - public String createBeneficiary(@RequestBody String request, HttpServletRequest httpRequest) - throws JsonMappingException, JsonProcessingException { - OutputResponse response = new OutputResponse(); - ObjectMapper objectMapper = new ObjectMapper(); - JsonElement json = JsonParser.parseString(request); - String otherFields = checkExtraFields(json); - objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - BeneficiaryModel beneficiaryModel = objectMapper.readValue(request, BeneficiaryModel.class); - beneficiaryModel.setOtherFields(otherFields); - - logger.info("Create beneficiary request for customization " + beneficiaryModel); - try { - - response.setResponse(registerBenificiaryService.save(beneficiaryModel, httpRequest)); - } catch (Exception e) { - logger.error("create beneficiary failed with error " + e.getMessage(), e); - response.setError(e); - } - - logger.info("create beneficiary response for customization " + response.toString()); - return response.toString(); - } - - private String checkExtraFields(JsonElement json) { - String identityJson = new Gson().toJson(json); - JsonObject identityJsonObject = new Gson().fromJson(identityJson, JsonObject.class); - JsonObject otherFieldsJson = new JsonObject(); - Set beneficiaryFieldNames = new HashSet<>(); - for (Field field : BeneficiaryModel.class.getDeclaredFields()) { - beneficiaryFieldNames.add(field.getName()); - } - for (Map.Entry entry : identityJsonObject.entrySet()) { - String fieldName = entry.getKey(); - - // Check if the field is not present in either class - if (!beneficiaryFieldNames.contains(fieldName)) { - otherFieldsJson.add(fieldName, entry.getValue()); - } - } - if (identityJsonObject.has("createdDate")) { - otherFieldsJson.add("createdDate", identityJsonObject.get("createdDate")); - } - return otherFieldsJson.toString(); - } - - @CrossOrigin() - @Operation(summary = "Provide the list of beneficiaries based on beneficiary id") - @RequestMapping(value = "/searchUserByID", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String searchUserByID( - @Param(value = "{\"beneficiaryRegID\":\"Long\", \"beneficiaryID\":\"Long\", \"HealthID\":\"String\", \"HealthIDNo\":\"String\"} ") @RequestBody String request, - HttpServletRequest httpRequest) { - OutputResponse response = new OutputResponse(); - ObjectMapper objectMapper = new ObjectMapper(); - - String auth = httpRequest.getHeader(AUTHORIZATION); - logger.info("Search user by ID request " + request); - try { - Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); - BeneficiaryModel benificiaryDetails = gson.fromJson(request, BeneficiaryModel.class); - logger.debug(benificiaryDetails.toString()); - List iBeneficiary = null; - if (benificiaryDetails.getBeneficiaryID() != null) { - iBeneficiary = iemrSearchUserService.userExitsCheckWithId(benificiaryDetails.getBeneficiaryID(), auth, - benificiaryDetails.getIs1097()); - } else if (benificiaryDetails.getBeneficiaryRegID() != null) { - iBeneficiary = iemrSearchUserService.userExitsCheckWithId(benificiaryDetails.getBeneficiaryRegID(), - auth, benificiaryDetails.getIs1097()); - } else if (benificiaryDetails.getHealthID() != null) { - iBeneficiary = iemrSearchUserService.userExitsCheckWithHealthId_ABHAId(benificiaryDetails.getHealthID(), - auth, benificiaryDetails.getIs1097()); - } else if (benificiaryDetails.getHealthIDNumber() != null) { - iBeneficiary = iemrSearchUserService.userExitsCheckWithHealthIdNo_ABHAIdNo( - benificiaryDetails.getHealthIDNumber(), auth, benificiaryDetails.getIs1097()); - } else if (benificiaryDetails.getFamilyId() != null) { - iBeneficiary = iemrSearchUserService.userExitsCheckWithFamilyId(benificiaryDetails.getFamilyId(), auth, - benificiaryDetails.getIs1097()); - } else if (benificiaryDetails.getIdentity() != null) { - iBeneficiary = iemrSearchUserService.userExitsCheckWithGovIdentity(benificiaryDetails.getIdentity(), - auth, benificiaryDetails.getIs1097()); - } - setBeneficiaryGender(iBeneficiary); - ObjectMapper mapper = new ObjectMapper(); - String result = mapper.writeValueAsString(iBeneficiary); - response.setResponse(result); - logger.info("Search user by ID response size " - + (iBeneficiary != null ? iBeneficiary.size() : "No Beneficiary Found")); - } catch (Exception e) { - logger.error("search user failed with error " + e.getMessage()); - response.setError(e); - } - return response.toString(); - } - - @Operation(summary = "Provide the list of beneficiaries based on phone number") - @CrossOrigin() - @RequestMapping(value = "/searchUserByPhone", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String searchUserByPhone( - @Param(value = "{\"phoneNo\":\"String\",\"pageNo\":\"Integer\",\"rowsPerPage\":\"Integer\"}") @RequestBody String request, - HttpServletRequest httpRequest) { - OutputResponse response = new OutputResponse(); - String auth = httpRequest.getHeader(AUTHORIZATION); - logger.info("Serach user by phone no request " + request); - try { - JSONObject requestObj = new JSONObject(request); - BenPhoneMap benPhoneMap = OutputMapper.gson().fromJson(request, BenPhoneMap.class); - int pageNumber = requestObj.has("pageNo") ? (requestObj.getInt("pageNo") - 1) : 0; - int rows = requestObj.has("rowsPerPage") ? requestObj.getInt("rowsPerPage") : 1000; - if (requestObj.has("is1097") && requestObj.getBoolean("is1097") == true) { - benPhoneMap.setIs1097(true); - } - - logger.info("benef iciary request:" + benPhoneMap); - response.setResponse( - iemrSearchUserService.findByBeneficiaryPhoneNo(benPhoneMap, pageNumber, rows, auth).toString()); - } catch (JSONException e) { - logger.error("serach user by phone NO failed with error " + e.getMessage(), e); - response.setError(e); - } catch (Exception e) { - logger.error("serach user by phone NO failed with error " + e.getMessage(), e); - response.setError(e); - } - - return response.toString(); - } - - @CrossOrigin() - @Operation(summary = "Provide the list of beneficiaries based on search criteria") - @RequestMapping(value = "/searchBeneficiary", method = RequestMethod.POST, headers = "Authorization") - public String searchBeneficiary( - @Param(value = "{\"firstName\":\"String\",\"lastName\":\"String\",\"genderID\":\"Integer\",\"beneficiaryID\":\"String\"," - + "\"i_bendemographics\":{\"stateID\":\"Integer\",\"districtID\":\"Integer\",\"districtBranchID\":\"Integer\"}}") @RequestBody BeneficiaryModel request, - HttpServletRequest httpRequest) { - logger.info("searchBeneficiary request " + request); - OutputResponse output = new OutputResponse(); - String auth = httpRequest.getHeader(AUTHORIZATION); - try { - output.setResponse(iemrSearchUserService.findBeneficiary(request, auth)); - } catch (NumberFormatException ne) { - logger.error("searchBeneficiary failed with error " + ne.getMessage(), ne); - output.setError(ne); - } catch (Exception e) { - logger.error("searchBeneficiary failed with error " + e.getMessage(), e); - output.setError(e); - } - - return output.toString(); - } - - @CrossOrigin() - @Operation(summary = "Provide all common data list needed for beneficiary registration") - @RequestMapping(value = "/getRegistrationData", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String getRegistrationData() { - OutputResponse response = new OutputResponse(); - logger.info("Received get user registration data request"); - try { - BeneficiaryRegistrationData beneficiaryRegistrationData = new BeneficiaryRegistrationData(); - beneficiaryRegistrationData.setM_Status(statusService.getActiveStatus()); - beneficiaryRegistrationData.setM_Title(titleService.getActiveTitles()); - beneficiaryRegistrationData.setI_BeneficiaryEducation(educationService.getActiveEducations()); - beneficiaryRegistrationData.setStates(locationService.getStates(1)); - beneficiaryRegistrationData.setM_genders(genderService.getActiveGenders()); - beneficiaryRegistrationData.setM_maritalStatuses(maritalStatusService.getActiveMaritalStatus()); - beneficiaryRegistrationData.setM_communities(communityService.getActiveCommunities()); - beneficiaryRegistrationData.setM_language(languageService.getActiveLanguages()); - beneficiaryRegistrationData.setDirectory(directoryService.getDirectories()); - beneficiaryRegistrationData.setSexualOrientations(sexualOrientationService.getSexualOrientations()); - beneficiaryRegistrationData - .setBenRelationshipTypes(benRelationshipTypeService.getActiveRelationshipTypes()); - beneficiaryRegistrationData.setBeneficiaryOccupations(beneficiaryOccupationService.getActiveOccupations()); - beneficiaryRegistrationData.setGovtIdentityTypes(govtIdentityTypeService.getActiveIDTypes()); - response.setResponse(beneficiaryRegistrationData.toString()); - } catch (Exception e) { - response.setError(e); - logger.error("get user registration data failed with error " + e.getMessage(), e); - } - logger.info("get user registration data response " + response.toString()); - return response.toString(); - } - - @CrossOrigin() - @Operation(summary = "Provide all common data V1 list needed for beneficiary registration") - @RequestMapping(value = "/getRegistrationDataV1", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String getRegistrationDataV1( - @Param(value = "{\"providerServiceMapID\":\"Integer\"}") @RequestBody String request) { - OutputResponse response = new OutputResponse(); - logger.info("Received get user registration data request"); - try { - ObjectMapper objectMapper = new ObjectMapper(); - Directory instituteDirectory = objectMapper.readValue(request, Directory.class); - BeneficiaryRegistrationData beneficiaryRegistrationData = new BeneficiaryRegistrationData(); - beneficiaryRegistrationData.setM_Status(statusService.getActiveStatus()); - beneficiaryRegistrationData.setM_Title(titleService.getActiveTitles()); - beneficiaryRegistrationData.setI_BeneficiaryEducation(educationService.getActiveEducations()); - beneficiaryRegistrationData.setStates(locationService.getStates(1)); - beneficiaryRegistrationData.setM_genders(genderService.getActiveGenders()); - beneficiaryRegistrationData.setM_maritalStatuses(maritalStatusService.getActiveMaritalStatus()); - beneficiaryRegistrationData.setM_communities(communityService.getActiveCommunities()); - beneficiaryRegistrationData.setM_language(languageService.getActiveLanguages()); - beneficiaryRegistrationData - .setDirectory(directoryService.getDirectories(instituteDirectory.getProviderServiceMapID())); - beneficiaryRegistrationData.setSexualOrientations(sexualOrientationService.getSexualOrientations()); - beneficiaryRegistrationData - .setBenRelationshipTypes(benRelationshipTypeService.getActiveRelationshipTypes()); - beneficiaryRegistrationData.setBeneficiaryOccupations(beneficiaryOccupationService.getActiveOccupations()); - beneficiaryRegistrationData.setGovtIdentityTypes(govtIdentityTypeService.getActiveIDTypes()); - response.setResponse(beneficiaryRegistrationData.toString()); - } catch (Exception e) { - response.setError(e); - logger.error("get user registration data failed with error " + e.getMessage(), e); - } - logger.info("get user registration data response " + response.toString()); - return response.toString(); - } - - @CrossOrigin() - @Operation(summary = "Update beneficiary details") - @RequestMapping(value = "/update", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String updateBenefciary( - @Param(value = "{\"beneficiaryRegID\":\"Long\",\"firstName\":\"String\",\"lastName\":\"String\"," - + "\"dOB\":\"Timestamp\",\"ageUnits\":\"String\",\"fatherName\":\"String\",\"spouseName\":\"String\"," - + "\"govtIdentityNo\":\"String\",\"govtIdentityTypeID\":\"Integer\",\"emergencyRegistration\":\"Boolean\"," - + "\"createdBy\":\"String\",\"titleId\":\"Short\",\"statusID\":\"Short\",\"registeredServiceID\":\"Short\"," - + "\"maritalStatusID\":\"Short\",\"genderID\":\"Integer\",\"i_bendemographics\":{\"educationID\":\"Long\"," - + "\"beneficiaryRegID\":\"Long\",\"occupationID\":\"Integer\",\"healthCareWorkerID\":\"Short\",\"incomeStatusID\":\"Integer\"," - + "\"communityID\":\"Integer\",\"preferredLangID\":\"Integer\",\"districtID\":\"Integer\",\"stateID\":\"Integer\"," - + "\"pinCode\":\"String\",\"blockID\":\"Integer\",\"districtBranchID\":\"Integer\",\"createdBy\":\"String\",\"addressLine1\":\"String\"}," - + "\"benPhoneMaps\":{\"parentBenRegID\":\"Long\",\"phoneNo\":\"String\",\"phoneTypeID\":\"Integer\",\"benRelationshipID\":\"Integer\"," - + "\"deleted\":\"Boolean\",\"createdBy\":\"String\"},\"changeInSelfDetails\":\"Boolean\",\"changeInIdentities\":\"Boolean\"," - + "\"changeInOtherDetails\":\"Boolean\",\"changeInAddress\":\"Boolean\",\"changeInContacts\":\"Boolean\"," - + "\"changeInFamilyDetails\":\"Boolean\"}") @RequestBody String benificiaryRequest, - HttpServletRequest httpRequest) { - OutputResponse response = new OutputResponse(); - String auth = httpRequest.getHeader(AUTHORIZATION); - Integer updateCount = 0; - try { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - BeneficiaryModel benificiaryDetails = objectMapper.readValue(benificiaryRequest, BeneficiaryModel.class); - updateCount = registerBenificiaryService.updateBenificiary(benificiaryDetails, auth); - if (updateCount > 0) { - List userExitsCheckWithId = iemrSearchUserService.userExitsCheckWithId( - benificiaryDetails.getBeneficiaryRegID(), auth, benificiaryDetails.getIs1097()); - BeneficiaryModel beneficiaryModel = userExitsCheckWithId.get(0); - JSONObject responseObj = new JSONObject(beneficiaryModel); - responseObj.put("updateCount", updateCount); - response.setResponse(responseObj.toString()); - } - } catch (JSONException e) { - logger.error("Update beneficiary failed with error " + e.getMessage(), e); - response.setError(e); - } catch (Exception e) { - logger.error("Update beneficiary failed with error " + e.getMessage(), e); - response.setError(e); - } - logger.info("update beneficiary response " + response.toString()); - return response.toString(); - } - - @CrossOrigin() - @Operation(summary = "Update beneficiary details") - @RequestMapping(value = "/updateBenefciaryDetails", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String updateBenefciaryDetails(@RequestBody String benificiaryRequest, HttpServletRequest httpRequest) { - OutputResponse response = new OutputResponse(); - String auth = httpRequest.getHeader(AUTHORIZATION); - Integer updateCount = 0; - try { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - JsonElement json = JsonParser.parseString(benificiaryRequest); - String otherFields = checkExtraFields(json); - objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - BeneficiaryModel benificiaryDetails = objectMapper.readValue(benificiaryRequest, BeneficiaryModel.class); - benificiaryDetails.setOtherFields(otherFields); - updateCount = registerBenificiaryService.updateBenificiary(benificiaryDetails, auth); - if (updateCount > 0) { - List userExitsCheckWithId = iemrSearchUserService.userExitsCheckWithId( - benificiaryDetails.getBeneficiaryRegID(), auth, benificiaryDetails.getIs1097()); - BeneficiaryModel beneficiaryModel = userExitsCheckWithId.get(0); - JSONObject responseObj = new JSONObject(beneficiaryModel); - responseObj.put("updateCount", updateCount); - response.setResponse(responseObj.toString()); - } - } catch (JSONException e) { - logger.error("Update beneficiary failed with error " + e.getMessage(), e); - response.setError(e); - } catch (Exception e) { - logger.error("Update beneficiary failed with error " + e.getMessage(), e); - response.setError(e); - } - logger.info("update beneficiary response " + response.toString()); - return response.toString(); - } - - @CrossOrigin() - @Operation(summary = "Fetch beneficiary details by phone no") - @RequestMapping(value = "/getBeneficiariesByPhoneNo", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String getBeneficiariesByPhone(@Param(value = "{\"phoneNo\":\"String\"}") @RequestBody String request, - HttpServletRequest httpRequest) { - OutputResponse response = new OutputResponse(); - String auth = httpRequest.getHeader(AUTHORIZATION); - logger.info("getBeneficiariesByPhoneNo request " + request); - try { - BenPhoneMap benPhoneMap = inputMapper.gson().fromJson(request, BenPhoneMap.class); - int pageNumber = 0; - int rows = 1000; - response.setResponse(iemrSearchUserService.findByBeneficiaryPhoneNo(benPhoneMap, pageNumber, rows, auth)); - } catch (Exception e) { - response.setError(e); - logger.error("getBeneficiariesByPhoneNo failed with error " + e.getMessage(), e); - } - return response.toString(); - } - - @CrossOrigin() - @Operation(summary = "Update beneficiary community or education") - @RequestMapping(value = "/updateCommunityorEducation", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String updateBenefciaryCommunityorEducation( - @Param(value = "{\"beneficiaryRegID\":\"Long\",\"i_bendemographics\":{\"communityID\":\"Integer\"," - + "\"educationID\":\"Integer\"}}") @RequestBody String benificiaryRequest, - HttpServletRequest httpRequest) { - OutputResponse response = new OutputResponse(); - ObjectMapper objectMapper = new ObjectMapper(); - String auth = httpRequest.getHeader(AUTHORIZATION); - Integer updateCount = 0; - try { - BeneficiaryModel benificiaryDetails = objectMapper.readValue(benificiaryRequest, BeneficiaryModel.class); - updateCount = registerBenificiaryService.updateCommunityorEducation(benificiaryDetails, auth); - if (updateCount > 0) { - List userExitsCheckWithId = iemrSearchUserService.userExitsCheckWithId( - benificiaryDetails.getBeneficiaryRegID(), auth, benificiaryDetails.getIs1097()); - JSONArray updatedUserData = new JSONArray(userExitsCheckWithId); - JSONObject responseObj = new JSONObject(updatedUserData.getJSONObject(0).toString()); - responseObj.put("updateCount", updateCount); - response.setResponse(responseObj.toString()); - } - } catch (Exception e) { - logger.error("Update beneficiary failed with error " + e.getMessage(), e); - response.setError(e); - } - logger.info("update beneficiary response " + response.toString()); - return response.toString(); - } - - @CrossOrigin() - @Operation(summary = "Generate beneficiary id") - @RequestMapping(value = "/generateBeneficiaryIDs", headers = "Authorization", method = { - RequestMethod.POST }, produces = { "application/json" }) - public String getBeneficiaryIDs( - @Param("{\"benIDRequired\":\"Integer\",\"vanID\":\"Integer\"}") @RequestBody String request, - HttpServletRequest httpRequest) { - logger.info("generateBeneficiaryIDs request " + request); - OutputResponse response = new OutputResponse(); - try { - - String res = registerBenificiaryService.generateBeneficiaryIDs(request, httpRequest); - response.setResponse(res); - logger.info("generateBeneficiaryIDs response " + response.toString()); - } catch (Exception e) { - logger.error(e.getMessage()); - response.setError(e); - } - return response.toString(); - } - - private void setBeneficiaryGender(List iBeneficiary) { - for (BeneficiaryModel beneficiaryModel : iBeneficiary) { - if (null != beneficiaryModel.getM_gender() && beneficiaryModel.getM_gender().getGenderName() != null) - beneficiaryModel.setGenderName(beneficiaryModel.getM_gender().getGenderName()); - } - - } + private InputMapper inputMapper = new InputMapper(); + + private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + private static final String AUTHORIZATION = "authorization"; + private RegisterBenificiaryService registerBenificiaryService; + private IEMRBeneficiaryTypeService iemrBeneficiaryTypeService; + private IEMRSearchUserService iemrSearchUserService; + private EducationService educationService; + private TitleService titleService; + private StatusService statusService; + private LocationService locationService; + private GenderService genderService; + private MaritalStatusService maritalStatusService; + private CommunityService communityService; + private DirectoryService directoryService; + private SexualOrientationService sexualOrientationService; + private LanguageService languageService; + private BenRelationshipTypeService benRelationshipTypeService; + private BeneficiaryOccupationService beneficiaryOccupationService; + private GovtIdentityTypeService govtIdentityTypeService; + + @Autowired + public void setBenRelationshipTypeService(BenRelationshipTypeService benRelationshipTypeService) { + this.benRelationshipTypeService = benRelationshipTypeService; + } + + @Autowired + public void setBeneficiaryOccupationService(BeneficiaryOccupationService beneficiaryOccupationService) { + this.beneficiaryOccupationService = beneficiaryOccupationService; + } + + @Autowired + public void setIEMRSearchUserService(IEMRSearchUserService iemrSearchUserService) { + this.iemrSearchUserService = iemrSearchUserService; + } + + @Autowired + public void setIEMRBeneficiaryTypeService(IEMRBeneficiaryTypeService iemrBeneficiaryTypeService) { + this.iemrBeneficiaryTypeService = iemrBeneficiaryTypeService; + } + + @Autowired + public void setRegisterBenificiaryService(RegisterBenificiaryService registerBenificiaryService) { + this.registerBenificiaryService = registerBenificiaryService; + } + + @Autowired + public void setEducationService(EducationService educationService1) { + this.educationService = educationService1; + } + + @Autowired + public void setTitleService(TitleService titleService1) { + this.titleService = titleService1; + } + + @Autowired + public void setStatusService(StatusService statusService1) { + this.statusService = statusService1; + } + + @Autowired + public void setLocationService(LocationService locationService1) { + this.locationService = locationService1; + } + + @Autowired + public void setGenderService(GenderService genderService) { + this.genderService = genderService; + } + + @Autowired + public void setMaritalStatusService(MaritalStatusService maritalStatusService) { + this.maritalStatusService = maritalStatusService; + } + + @Autowired + public void setCommunityService(CommunityService communityService) { + this.communityService = communityService; + } + + @Autowired + public void setLanguageService(LanguageService languageService) { + this.languageService = languageService; + } + + @Autowired + public void setDirectoryService(DirectoryService directoryService) { + this.directoryService = directoryService; + } + + @Autowired + public void setSexualOrientationService(SexualOrientationService sexualOrientationService) { + this.sexualOrientationService = sexualOrientationService; + } + + @Autowired + public void setGovtIdentityTypeService(GovtIdentityTypeService govtIdentityTypeService) { + this.govtIdentityTypeService = govtIdentityTypeService; + } + + @Autowired + private CallReportsService callReportsService; + + @Operation(summary = "Create a new beneficiary") + @RequestMapping(value = "/create", method = RequestMethod.POST, produces = "application/json", consumes = "application/json", headers = "Authorization") + + public String createBeneficiary( + @Param(value = "{\"providerServiceMapID\":\"Integer\",\"firstName\":\"String\",\"lastName\":\"String\",\"dOB\":\"Timestamp\"," + + "\"ageUnits\":\"String\",\"fatherName\":\"String\",\"spouseName\":\"String\",\"govtIdentityNo\":\"String\"," + + "\"govtIdentityTypeID\":\"Integer\",\"emergencyRegistration\":\"Boolean\",\"createdBy\":\"String\"," + + "\"titleId\":\"Short\",\"statusID\":\"Short\",\"registeredServiceID\":\"Short\",\"maritalStatusID\":\"Short\"," + + "\"genderID\":\"Integer\",\"i_bendemographics\":{\"educationID\":\"Long\",\"occupationID\":\"Integer\"," + + "\"healthCareWorkerID\":\"Short\",\"communityID\":\"Integer\",\"districtID\":\"Integer\",\"stateID\":\"Integer\"," + + "\"pinCode\":\"String\",\"blockID\":\"Integer\",\"districtBranchID\":\"Integer\",\"createdBy\":\"String\"," + + "\"addressLine1\":\"String\"},\"benPhoneMaps\":{\"parentBenRegID\":\"Long\",\"phoneNo\":\"String\"," + + "\"phoneTypeID\":\"Integer\",\"benRelationshipID\":\"Integer\",\"deleted\":\"Boolean\",\"createdBy\":\"String\"}," + + "\"faceEmbedding\":[\"Float\"]}") @RequestBody BeneficiaryModel beneficiaryModel, + HttpServletRequest httpRequest) { + OutputResponse response = new OutputResponse(); + + logger.info("Create beneficiary request " + beneficiaryModel); + try { + + response.setResponse(registerBenificiaryService.save(beneficiaryModel, httpRequest)); + } catch (Exception e) { + logger.error("create beneficiary failed with error " + e.getMessage(), e); + response.setError(e); + } + + logger.info("create beneficiary response " + response.toString()); + return response.toString(); + } + + @Operation(summary = "Create a new beneficiary for customization") + @RequestMapping(value = "/createBeneficiary", method = RequestMethod.POST, produces = "application/json", consumes = "application/json", headers = "Authorization") + public String createBeneficiary(@RequestBody String request, HttpServletRequest httpRequest) + throws JsonMappingException, JsonProcessingException { + OutputResponse response = new OutputResponse(); + ObjectMapper objectMapper = new ObjectMapper(); + JsonElement json = JsonParser.parseString(request); + String otherFields = checkExtraFields(json); + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + BeneficiaryModel beneficiaryModel = objectMapper.readValue(request, BeneficiaryModel.class); + beneficiaryModel.setOtherFields(otherFields); + + logger.info("Create beneficiary request for customization " + beneficiaryModel); + try { + + response.setResponse(registerBenificiaryService.save(beneficiaryModel, httpRequest)); + } catch (Exception e) { + logger.error("create beneficiary failed with error " + e.getMessage(), e); + response.setError(e); + } + + logger.info("create beneficiary response for customization " + response.toString()); + return response.toString(); + } + + private String checkExtraFields(JsonElement json) { + String identityJson = new Gson().toJson(json); + JsonObject identityJsonObject = new Gson().fromJson(identityJson, JsonObject.class); + JsonObject otherFieldsJson = new JsonObject(); + Set beneficiaryFieldNames = new HashSet<>(); + for (Field field : BeneficiaryModel.class.getDeclaredFields()) { + beneficiaryFieldNames.add(field.getName()); + } + for (Map.Entry entry : identityJsonObject.entrySet()) { + String fieldName = entry.getKey(); + + // Check if the field is not present in either class + if (!beneficiaryFieldNames.contains(fieldName)) { + otherFieldsJson.add(fieldName, entry.getValue()); + } + } + if (identityJsonObject.has("createdDate")) { + otherFieldsJson.add("createdDate", identityJsonObject.get("createdDate")); + } + return otherFieldsJson.toString(); + } + + @Operation(summary = "Provide the list of beneficiaries based on beneficiary id") + @RequestMapping(value = "/searchUserByID", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String searchUserByID( + @Param(value = "{\"beneficiaryRegID\":\"Long\", \"beneficiaryID\":\"Long\", \"HealthID\":\"String\", \"HealthIDNo\":\"String\"} ") @RequestBody String request, + HttpServletRequest httpRequest) { + OutputResponse response = new OutputResponse(); + ObjectMapper objectMapper = new ObjectMapper(); + + String auth = httpRequest.getHeader(AUTHORIZATION); + logger.info("Search user by ID request " + request); + try { + Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); + BeneficiaryModel benificiaryDetails = gson.fromJson(request, BeneficiaryModel.class); + logger.debug(benificiaryDetails.toString()); + List iBeneficiary = null; + if (benificiaryDetails.getBeneficiaryID() != null) { + iBeneficiary = iemrSearchUserService.userExitsCheckWithId(benificiaryDetails.getBeneficiaryID(), auth, + benificiaryDetails.getIs1097()); + } else if (benificiaryDetails.getBeneficiaryRegID() != null) { + iBeneficiary = iemrSearchUserService.userExitsCheckWithId(benificiaryDetails.getBeneficiaryRegID(), + auth, benificiaryDetails.getIs1097()); + } else if (benificiaryDetails.getHealthID() != null) { + iBeneficiary = iemrSearchUserService.userExitsCheckWithHealthId_ABHAId(benificiaryDetails.getHealthID(), + auth, benificiaryDetails.getIs1097()); + } else if (benificiaryDetails.getHealthIDNumber() != null) { + iBeneficiary = iemrSearchUserService.userExitsCheckWithHealthIdNo_ABHAIdNo( + benificiaryDetails.getHealthIDNumber(), auth, benificiaryDetails.getIs1097()); + } else if (benificiaryDetails.getFamilyId() != null) { + iBeneficiary = iemrSearchUserService.userExitsCheckWithFamilyId(benificiaryDetails.getFamilyId(), auth, + benificiaryDetails.getIs1097()); + } else if (benificiaryDetails.getIdentity() != null) { + iBeneficiary = iemrSearchUserService.userExitsCheckWithGovIdentity(benificiaryDetails.getIdentity(), + auth, benificiaryDetails.getIs1097()); + } + setBeneficiaryGender(iBeneficiary); + ObjectMapper mapper = new ObjectMapper(); + String result = mapper.writeValueAsString(iBeneficiary); + response.setResponse(result); + logger.info("Search user by ID response size " + + (iBeneficiary != null ? iBeneficiary.size() : "No Beneficiary Found")); + } catch (Exception e) { + logger.error("search user failed with error " + e.getMessage()); + response.setError(e); + } + return response.toString(); + } + + @Operation(summary = "Provide the list of beneficiaries based on phone number") + @RequestMapping(value = "/searchUserByPhone", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String searchUserByPhone( + @Param(value = "{\"phoneNo\":\"String\",\"pageNo\":\"Integer\",\"rowsPerPage\":\"Integer\"}") @RequestBody String request, + HttpServletRequest httpRequest) { + OutputResponse response = new OutputResponse(); + String auth = httpRequest.getHeader(AUTHORIZATION); + logger.info("Serach user by phone no request " + request); + try { + JSONObject requestObj = new JSONObject(request); + BenPhoneMap benPhoneMap = OutputMapper.gson().fromJson(request, BenPhoneMap.class); + int pageNumber = requestObj.has("pageNo") ? (requestObj.getInt("pageNo") - 1) : 0; + int rows = requestObj.has("rowsPerPage") ? requestObj.getInt("rowsPerPage") : 1000; + if (requestObj.has("is1097") && requestObj.getBoolean("is1097") == true) { + benPhoneMap.setIs1097(true); + } + + logger.info("benef iciary request:" + benPhoneMap); + response.setResponse( + iemrSearchUserService.findByBeneficiaryPhoneNo(benPhoneMap, pageNumber, rows, auth).toString()); + } catch (JSONException e) { + logger.error("serach user by phone NO failed with error " + e.getMessage(), e); + response.setError(e); + } catch (Exception e) { + logger.error("serach user by phone NO failed with error " + e.getMessage(), e); + response.setError(e); + } + + return response.toString(); + } + + @Operation(summary = "Provide the list of beneficiaries based on search criteria") + @RequestMapping(value = "/searchBeneficiary", method = RequestMethod.POST, headers = "Authorization") + public String searchBeneficiary( + @Param(value = "{\"firstName\":\"String\",\"lastName\":\"String\",\"genderID\":\"Integer\",\"beneficiaryID\":\"String\"," + + "\"i_bendemographics\":{\"stateID\":\"Integer\",\"districtID\":\"Integer\",\"districtBranchID\":\"Integer\"}}") @RequestBody BeneficiaryModel request, + HttpServletRequest httpRequest) { + logger.info("searchBeneficiary request " + request); + OutputResponse output = new OutputResponse(); + String auth = httpRequest.getHeader(AUTHORIZATION); + try { + output.setResponse(iemrSearchUserService.findBeneficiary(request, auth)); + } catch (NumberFormatException ne) { + logger.error("searchBeneficiary failed with error " + ne.getMessage(), ne); + output.setError(ne); + } catch (Exception e) { + logger.error("searchBeneficiary failed with error " + e.getMessage(), e); + output.setError(e); + } + + return output.toString(); + } + + @Operation(summary = "Provide all common data list needed for beneficiary registration") + @RequestMapping(value = "/getRegistrationData", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String getRegistrationData() { + OutputResponse response = new OutputResponse(); + logger.info("Received get user registration data request"); + try { + BeneficiaryRegistrationData beneficiaryRegistrationData = new BeneficiaryRegistrationData(); + beneficiaryRegistrationData.setM_Status(statusService.getActiveStatus()); + beneficiaryRegistrationData.setM_Title(titleService.getActiveTitles()); + beneficiaryRegistrationData.setI_BeneficiaryEducation(educationService.getActiveEducations()); + beneficiaryRegistrationData.setStates(locationService.getStates(1)); + beneficiaryRegistrationData.setM_genders(genderService.getActiveGenders()); + beneficiaryRegistrationData.setM_maritalStatuses(maritalStatusService.getActiveMaritalStatus()); + beneficiaryRegistrationData.setM_communities(communityService.getActiveCommunities()); + beneficiaryRegistrationData.setM_language(languageService.getActiveLanguages()); + beneficiaryRegistrationData.setDirectory(directoryService.getDirectories()); + beneficiaryRegistrationData.setSexualOrientations(sexualOrientationService.getSexualOrientations()); + beneficiaryRegistrationData + .setBenRelationshipTypes(benRelationshipTypeService.getActiveRelationshipTypes()); + beneficiaryRegistrationData.setBeneficiaryOccupations(beneficiaryOccupationService.getActiveOccupations()); + beneficiaryRegistrationData.setGovtIdentityTypes(govtIdentityTypeService.getActiveIDTypes()); + response.setResponse(beneficiaryRegistrationData.toString()); + } catch (Exception e) { + response.setError(e); + logger.error("get user registration data failed with error " + e.getMessage(), e); + } + logger.info("get user registration data response " + response.toString()); + return response.toString(); + } + + @Operation(summary = "Provide all common data V1 list needed for beneficiary registration") + @RequestMapping(value = "/getRegistrationDataV1", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String getRegistrationDataV1( + @Param(value = "{\"providerServiceMapID\":\"Integer\"}") @RequestBody String request) { + OutputResponse response = new OutputResponse(); + logger.info("Received get user registration data request"); + try { + ObjectMapper objectMapper = new ObjectMapper(); + Directory instituteDirectory = objectMapper.readValue(request, Directory.class); + BeneficiaryRegistrationData beneficiaryRegistrationData = new BeneficiaryRegistrationData(); + beneficiaryRegistrationData.setM_Status(statusService.getActiveStatus()); + beneficiaryRegistrationData.setM_Title(titleService.getActiveTitles()); + beneficiaryRegistrationData.setI_BeneficiaryEducation(educationService.getActiveEducations()); + beneficiaryRegistrationData.setStates(locationService.getStates(1)); + beneficiaryRegistrationData.setM_genders(genderService.getActiveGenders()); + beneficiaryRegistrationData.setM_maritalStatuses(maritalStatusService.getActiveMaritalStatus()); + beneficiaryRegistrationData.setM_communities(communityService.getActiveCommunities()); + beneficiaryRegistrationData.setM_language(languageService.getActiveLanguages()); + beneficiaryRegistrationData + .setDirectory(directoryService.getDirectories(instituteDirectory.getProviderServiceMapID())); + beneficiaryRegistrationData.setSexualOrientations(sexualOrientationService.getSexualOrientations()); + beneficiaryRegistrationData + .setBenRelationshipTypes(benRelationshipTypeService.getActiveRelationshipTypes()); + beneficiaryRegistrationData.setBeneficiaryOccupations(beneficiaryOccupationService.getActiveOccupations()); + beneficiaryRegistrationData.setGovtIdentityTypes(govtIdentityTypeService.getActiveIDTypes()); + response.setResponse(beneficiaryRegistrationData.toString()); + } catch (Exception e) { + response.setError(e); + logger.error("get user registration data failed with error " + e.getMessage(), e); + } + logger.info("get user registration data response " + response.toString()); + return response.toString(); + } + + @Operation(summary = "Update beneficiary details") + @RequestMapping(value = "/update", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String updateBenefciary( + @Param(value = "{\"beneficiaryRegID\":\"Long\",\"firstName\":\"String\",\"lastName\":\"String\"," + + "\"dOB\":\"Timestamp\",\"ageUnits\":\"String\",\"fatherName\":\"String\",\"spouseName\":\"String\"," + + "\"govtIdentityNo\":\"String\",\"govtIdentityTypeID\":\"Integer\",\"emergencyRegistration\":\"Boolean\"," + + "\"createdBy\":\"String\",\"titleId\":\"Short\",\"statusID\":\"Short\",\"registeredServiceID\":\"Short\"," + + "\"maritalStatusID\":\"Short\",\"genderID\":\"Integer\",\"i_bendemographics\":{\"educationID\":\"Long\"," + + "\"beneficiaryRegID\":\"Long\",\"occupationID\":\"Integer\",\"healthCareWorkerID\":\"Short\",\"incomeStatusID\":\"Integer\"," + + "\"communityID\":\"Integer\",\"preferredLangID\":\"Integer\",\"districtID\":\"Integer\",\"stateID\":\"Integer\"," + + "\"pinCode\":\"String\",\"blockID\":\"Integer\",\"districtBranchID\":\"Integer\",\"createdBy\":\"String\",\"addressLine1\":\"String\"}," + + "\"benPhoneMaps\":{\"parentBenRegID\":\"Long\",\"phoneNo\":\"String\",\"phoneTypeID\":\"Integer\",\"benRelationshipID\":\"Integer\"," + + "\"deleted\":\"Boolean\",\"createdBy\":\"String\"},\"changeInSelfDetails\":\"Boolean\",\"changeInIdentities\":\"Boolean\"," + + "\"changeInOtherDetails\":\"Boolean\",\"changeInAddress\":\"Boolean\",\"changeInContacts\":\"Boolean\"," + + "\"changeInFamilyDetails\":\"Boolean\"}") @RequestBody String benificiaryRequest, + HttpServletRequest httpRequest) { + OutputResponse response = new OutputResponse(); + String auth = httpRequest.getHeader(AUTHORIZATION); + Integer updateCount = 0; + try { + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + BeneficiaryModel benificiaryDetails = objectMapper.readValue(benificiaryRequest, BeneficiaryModel.class); + updateCount = registerBenificiaryService.updateBenificiary(benificiaryDetails, auth); + if (updateCount > 0) { + List userExitsCheckWithId = iemrSearchUserService.userExitsCheckWithId( + benificiaryDetails.getBeneficiaryRegID(), auth, benificiaryDetails.getIs1097()); + BeneficiaryModel beneficiaryModel = userExitsCheckWithId.get(0); + JSONObject responseObj = new JSONObject(beneficiaryModel); + responseObj.put("updateCount", updateCount); + response.setResponse(responseObj.toString()); + } + } catch (JSONException e) { + logger.error("Update beneficiary failed with error " + e.getMessage(), e); + response.setError(e); + } catch (Exception e) { + logger.error("Update beneficiary failed with error " + e.getMessage(), e); + response.setError(e); + } + logger.info("update beneficiary response " + response.toString()); + return response.toString(); + } + + @Operation(summary = "Update beneficiary details") + @RequestMapping(value = "/updateBenefciaryDetails", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String updateBenefciaryDetails(@RequestBody String benificiaryRequest, HttpServletRequest httpRequest) { + OutputResponse response = new OutputResponse(); + String auth = httpRequest.getHeader(AUTHORIZATION); + Integer updateCount = 0; + try { + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + JsonElement json = JsonParser.parseString(benificiaryRequest); + String otherFields = checkExtraFields(json); + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + BeneficiaryModel benificiaryDetails = objectMapper.readValue(benificiaryRequest, BeneficiaryModel.class); + benificiaryDetails.setOtherFields(otherFields); + updateCount = registerBenificiaryService.updateBenificiary(benificiaryDetails, auth); + if (updateCount > 0) { + List userExitsCheckWithId = iemrSearchUserService.userExitsCheckWithId( + benificiaryDetails.getBeneficiaryRegID(), auth, benificiaryDetails.getIs1097()); + BeneficiaryModel beneficiaryModel = userExitsCheckWithId.get(0); + JSONObject responseObj = new JSONObject(beneficiaryModel); + responseObj.put("updateCount", updateCount); + response.setResponse(responseObj.toString()); + } + } catch (JSONException e) { + logger.error("Update beneficiary failed with error " + e.getMessage(), e); + response.setError(e); + } catch (Exception e) { + logger.error("Update beneficiary failed with error " + e.getMessage(), e); + response.setError(e); + } + logger.info("update beneficiary response " + response.toString()); + return response.toString(); + } + + @Operation(summary = "Fetch beneficiary details by phone no") + @RequestMapping(value = "/getBeneficiariesByPhoneNo", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String getBeneficiariesByPhone(@Param(value = "{\"phoneNo\":\"String\"}") @RequestBody String request, + HttpServletRequest httpRequest) { + OutputResponse response = new OutputResponse(); + String auth = httpRequest.getHeader(AUTHORIZATION); + logger.info("getBeneficiariesByPhoneNo request " + request); + try { + BenPhoneMap benPhoneMap = inputMapper.gson().fromJson(request, BenPhoneMap.class); + int pageNumber = 0; + int rows = 1000; + response.setResponse(iemrSearchUserService.findByBeneficiaryPhoneNo(benPhoneMap, pageNumber, rows, auth)); + } catch (Exception e) { + response.setError(e); + logger.error("getBeneficiariesByPhoneNo failed with error " + e.getMessage(), e); + } + return response.toString(); + } + + @Operation(summary = "Update beneficiary community or education") + @RequestMapping(value = "/updateCommunityorEducation", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String updateBenefciaryCommunityorEducation( + @Param(value = "{\"beneficiaryRegID\":\"Long\",\"i_bendemographics\":{\"communityID\":\"Integer\"," + + "\"educationID\":\"Integer\"}}") @RequestBody String benificiaryRequest, + HttpServletRequest httpRequest) { + OutputResponse response = new OutputResponse(); + ObjectMapper objectMapper = new ObjectMapper(); + String auth = httpRequest.getHeader(AUTHORIZATION); + Integer updateCount = 0; + try { + BeneficiaryModel benificiaryDetails = objectMapper.readValue(benificiaryRequest, BeneficiaryModel.class); + updateCount = registerBenificiaryService.updateCommunityorEducation(benificiaryDetails, auth); + if (updateCount > 0) { + List userExitsCheckWithId = iemrSearchUserService.userExitsCheckWithId( + benificiaryDetails.getBeneficiaryRegID(), auth, benificiaryDetails.getIs1097()); + JSONArray updatedUserData = new JSONArray(userExitsCheckWithId); + JSONObject responseObj = new JSONObject(updatedUserData.getJSONObject(0).toString()); + responseObj.put("updateCount", updateCount); + response.setResponse(responseObj.toString()); + } + } catch (Exception e) { + logger.error("Update beneficiary failed with error " + e.getMessage(), e); + response.setError(e); + } + logger.info("update beneficiary response " + response.toString()); + return response.toString(); + } + + @Operation(summary = "Generate beneficiary id") + @RequestMapping(value = "/generateBeneficiaryIDs", headers = "Authorization", method = { + RequestMethod.POST}, produces = {"application/json"}) + public String getBeneficiaryIDs( + @Param("{\"benIDRequired\":\"Integer\",\"vanID\":\"Integer\"}") @RequestBody String request, + HttpServletRequest httpRequest) { + logger.info("generateBeneficiaryIDs request " + request); + OutputResponse response = new OutputResponse(); + try { + + String res = registerBenificiaryService.generateBeneficiaryIDs(request, httpRequest); + response.setResponse(res); + logger.info("generateBeneficiaryIDs response " + response.toString()); + } catch (Exception e) { + logger.error(e.getMessage()); + response.setError(e); + } + return response.toString(); + } + + private void setBeneficiaryGender(List iBeneficiary) { + for (BeneficiaryModel beneficiaryModel : iBeneficiary) { + if (null != beneficiaryModel.getM_gender() && beneficiaryModel.getM_gender().getGenderName() != null) + beneficiaryModel.setGenderName(beneficiaryModel.getM_gender().getGenderName()); + } + + } } diff --git a/src/main/java/com/iemr/common/controller/brd/BRDIntegrationController.java b/src/main/java/com/iemr/common/controller/brd/BRDIntegrationController.java index cf1a2453..005295b2 100644 --- a/src/main/java/com/iemr/common/controller/brd/BRDIntegrationController.java +++ b/src/main/java/com/iemr/common/controller/brd/BRDIntegrationController.java @@ -27,20 +27,16 @@ 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.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; - import com.iemr.common.service.brd.BRDIntegrationService; import com.iemr.common.utils.response.OutputResponse; - import io.swagger.v3.oas.annotations.Operation; @RestController @RequestMapping("/brd") -@CrossOrigin() public class BRDIntegrationController { private Logger logger = LoggerFactory.getLogger(BRDIntegrationController.class); @@ -50,7 +46,6 @@ public class BRDIntegrationController { @Operation(summary = "Get integration data") @RequestMapping(value = "/getIntegrationData", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - @CrossOrigin() public String getDetails(@RequestBody String request) { OutputResponse response = new OutputResponse(); String brdDetails = null; diff --git a/src/main/java/com/iemr/common/controller/callhandling/CallController.java b/src/main/java/com/iemr/common/controller/callhandling/CallController.java index 56deb1a2..be6de067 100644 --- a/src/main/java/com/iemr/common/controller/callhandling/CallController.java +++ b/src/main/java/com/iemr/common/controller/callhandling/CallController.java @@ -22,26 +22,19 @@ package com.iemr.common.controller.callhandling; import java.util.List; - - import javax.ws.rs.core.MediaType; - import org.json.JSONException; import org.json.JSONObject; 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.RequestMethod; import org.springframework.web.bind.annotation.RestController; - -import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; -import com.google.gson.Gson; import com.iemr.common.data.callhandling.BeneficiaryCall; import com.iemr.common.data.callhandling.CallType; import com.iemr.common.data.users.ProviderServiceMapping; @@ -50,10 +43,8 @@ import com.iemr.common.service.callhandling.BeneficiaryCallService; import com.iemr.common.service.callhandling.CalltypeServiceImpl; import com.iemr.common.utils.mapper.InputMapper; -import com.iemr.common.utils.mapper.OutputMapper; import com.iemr.common.utils.response.OutputResponse; import com.iemr.common.utils.sessionobject.SessionObject; - import io.lettuce.core.dynamic.annotation.Param; import io.swagger.v3.oas.annotations.Operation; import jakarta.servlet.http.HttpServletRequest; @@ -79,7 +70,7 @@ public void setBeneficiaryCallService(BeneficiaryCallService beneficiaryCallServ this.beneficiaryCallService = beneficiaryCallService; } - @CrossOrigin() + @Operation(summary = "Get call types") @PostMapping(value = "/getCallTypes", consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getAllCallTypes( @@ -97,7 +88,7 @@ public String getAllCallTypes( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get call types V1") @PostMapping(value = "/getCallTypesV1", consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getCallTypesV1( @@ -114,7 +105,7 @@ public String getCallTypesV1( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Start call") @PostMapping(value = "/startCall", consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String startCall( @@ -143,7 +134,7 @@ public String startCall( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Update beneficiary in call") @PostMapping(value = "/updatebeneficiaryincall", consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String updateBeneficiaryIDInCall(@Param(value = "{\"benCallID\":\"Integer - callID as in CRM\", " @@ -165,7 +156,7 @@ public String updateBeneficiaryIDInCall(@Param(value = "{\"benCallID\":\"Integer return response.toString(); } - @CrossOrigin() + @Operation(summary = "Close call") @PostMapping(value = "/closeCall", consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String closeCall( @@ -206,7 +197,7 @@ public String closeCall( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Outbound call list") @PostMapping(value = "/outboundCallList", consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String outboundCallList(@Param(value = "{\"providerServiceMapID\":\" called service ID integer\", " @@ -227,7 +218,7 @@ public String outboundCallList(@Param(value = "{\"providerServiceMapID\":\" call return response.toString(); } - @CrossOrigin() + @Operation(summary = "Outbound call count") @PostMapping(value = "/outboundCallCount", consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String outboundCallCount(@Param(value = "{\"providerServiceMapID\":\"called service ID integer\", " @@ -245,7 +236,7 @@ public String outboundCallCount(@Param(value = "{\"providerServiceMapID\":\"call return response.toString(); } - @CrossOrigin() + @Operation(summary = "Filter call list") @RequestMapping(value = "/filterCallList", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String filterCallList( @@ -267,7 +258,7 @@ public String filterCallList( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Filter call list page") @RequestMapping(value = "/filterCallListPage", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String filterCallListPaginated(@Param(value = "{\"calledServiceID\":\" called service ID integer\", " @@ -288,7 +279,7 @@ public String filterCallListPaginated(@Param(value = "{\"calledServiceID\":\" ca return response.toString(); } - @CrossOrigin() + @Operation(summary = "Outbound allocation") @RequestMapping(value = "/outboundAllocation", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String outboundAllocation(@Param(value = "{\"userID\":[Integer Array list of user IDs], " @@ -305,7 +296,7 @@ public String outboundAllocation(@Param(value = "{\"userID\":[Integer Array list return response.toString(); } - @CrossOrigin() + @Operation(summary = "Complete outbound call") @RequestMapping(value = "/completeOutboundCall", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String completeOutboundCall(@Param(value = "{\"outboundCallReqID\":\"Integer - Outbound call id\", " @@ -322,7 +313,7 @@ public String completeOutboundCall(@Param(value = "{\"outboundCallReqID\":\"Inte return response.toString(); } - @CrossOrigin() + @Operation(summary = "Update outbound call") @RequestMapping(value = "/updateOutboundCall", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String updateOutboundCall(@Param(value = "{\"outboundCallReqID\":\"Integer - Outbound call id\", " @@ -340,7 +331,7 @@ public String updateOutboundCall(@Param(value = "{\"outboundCallReqID\":\"Intege return response.toString(); } - @CrossOrigin() + @Operation(summary = "Reset outbound call") @RequestMapping(value = "/resetOutboundCall", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String resetOutboundCall( @@ -356,7 +347,7 @@ public String resetOutboundCall( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get blacklist numbers") @RequestMapping(value = "/getBlacklistNumbers", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getBlacklistNumbers( @@ -375,7 +366,7 @@ public String getBlacklistNumbers( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Unblock blocked numbers") @RequestMapping(value = "/unblockBlockedNumbers", method = RequestMethod.GET, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String unblockBlockedNumbers() { @@ -390,7 +381,7 @@ public String unblockBlockedNumbers() { return response.toString(); } - @CrossOrigin() + @Operation(summary = "Block phone number") @RequestMapping(value = "/blockPhoneNumber", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String blockPhoneNumber( @@ -406,7 +397,7 @@ public String blockPhoneNumber( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Unblock phone number") @RequestMapping(value = "/unblockPhoneNumber", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String unblockPhoneNumber( @@ -422,7 +413,7 @@ public String unblockPhoneNumber( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Update beneficiary call CDI status") @RequestMapping(value = "/updateBeneficiaryCallCDIStatus", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String updateBeneficiaryCallCDIStatus(@Param(value = "{\"benCallID\":\"Integer - callID as in CRM\", " @@ -443,7 +434,7 @@ public String updateBeneficiaryCallCDIStatus(@Param(value = "{\"benCallID\":\"In return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get call history by call id") @RequestMapping(value = "/getCallHistoryByCallID", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getCallHistoryByCallID( @@ -459,7 +450,7 @@ public String getCallHistoryByCallID( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Outbound call list by call id") @RequestMapping(value = "/outboundCallListByCallID", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String outboundCallListByCallID(@Param(value = "{\"providerServiceMapID\":\"called service ID integer\", " @@ -475,7 +466,7 @@ public String outboundCallListByCallID(@Param(value = "{\"providerServiceMapID\" return response.toString(); } - @CrossOrigin() + @Operation(summary = "Nuisance call history") @RequestMapping(value = "/nueisanceCallHistory", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String nueisanceCallHistory( @@ -495,7 +486,7 @@ public String nueisanceCallHistory( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Beneficiary by call id") @RequestMapping(value = "/beneficiaryByCallID", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String beneficiaryByCallID(@Param("{\"callID\":\"String\"}") @RequestBody CallRequestByIDModel request, @@ -515,7 +506,7 @@ public String beneficiaryByCallID(@Param("{\"callID\":\"String\"}") @RequestBody return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get calls by beneficiary regitration id and received role name") @RequestMapping(value = "/isAvailed", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String isAvailed(@Param(value = "{\"beneficiaryRegID\":\"beneficiary reg id\", " @@ -533,7 +524,7 @@ public String isAvailed(@Param(value = "{\"beneficiaryRegID\":\"beneficiary reg return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get beneficiary requested outbound call") @RequestMapping(value = "/getBenRequestedOutboundCall", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getBenRequestedOutboundCall(@Param(value = "{\"beneficiaryRegID\":\"beneficiary reg id\", " @@ -552,7 +543,7 @@ public String getBenRequestedOutboundCall(@Param(value = "{\"beneficiaryRegID\": return response.toString(); } - @CrossOrigin() + @Operation(summary = "Auto preview dialing") @RequestMapping(value = "/isAutoPreviewDialing", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String isAutoPreviewDialing(@Param(value = "{\"providerServiceMapID\":\"called service ID integer\", " @@ -571,7 +562,7 @@ public String isAutoPreviewDialing(@Param(value = "{\"providerServiceMapID\":\"c return response.toString(); } - @CrossOrigin() + @Operation(summary = "Check auto preview dialing") @RequestMapping(value = "/checkAutoPreviewDialing", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String checkAutoPreviewDialing( @@ -590,7 +581,7 @@ public String checkAutoPreviewDialing( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get file path CTI") @RequestMapping(value = "/getFilePathCTI", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getFilePathCTI( @@ -614,7 +605,7 @@ public String getFilePathCTI( @Autowired private SessionObject s; - @CrossOrigin() + @Operation(summary = "Redis insert") @RequestMapping(value = "/redisInsert", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String redisInsert(@RequestBody String request) { @@ -630,7 +621,7 @@ public String redisInsert(@RequestBody String request) { } - @CrossOrigin() + @Operation(summary = "Redis fetch") @RequestMapping(value = "/redisFetch", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String redisFetch(@Param("{\"sessionID\":\"sessionID/callID String\"}") @RequestBody String request) { diff --git a/src/main/java/com/iemr/common/controller/carestream/CareStreamCreateOrderController.java b/src/main/java/com/iemr/common/controller/carestream/CareStreamCreateOrderController.java index 5aa78cd9..738e6b99 100644 --- a/src/main/java/com/iemr/common/controller/carestream/CareStreamCreateOrderController.java +++ b/src/main/java/com/iemr/common/controller/carestream/CareStreamCreateOrderController.java @@ -26,21 +26,16 @@ import java.io.OutputStream; import java.net.Socket; import java.net.UnknownHostException; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.PropertySource; -import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; - import com.iemr.common.data.carestream.CreateOrderData; import com.iemr.common.utils.mapper.InputMapper; import com.iemr.common.utils.response.OutputResponse; - import io.lettuce.core.dynamic.annotation.Param; import io.swagger.v3.oas.annotations.Operation; @@ -60,7 +55,6 @@ public class CareStreamCreateOrderController { @Value("${carestream_socket_port}") private int carestreamSocketPort; - @CrossOrigin() @Operation(summary = "Create order") @RequestMapping(value = "/createOrder", headers = "Authorization", method = { RequestMethod.POST }, produces = { "application/json" }) @@ -122,7 +116,6 @@ public String createOrder(@Param("{\"firstName\":\"String\",\"middleName\":\"Str return response.toString(); } - @CrossOrigin() @Operation(summary = "Update order") @RequestMapping(value = "/UpdateOrder", headers = "Authorization", method = { RequestMethod.POST }, produces = { "application/json" }) @@ -184,7 +177,6 @@ public String updateOrder(@Param("{\"firstName\":\"String\",\"middleName\":\"Str return response.toString(); } - @CrossOrigin() @Operation(summary = "Delete order") @RequestMapping(value = "/deleteOrder", headers = "Authorization", method = { RequestMethod.POST }, produces = { "application/json" }) diff --git a/src/main/java/com/iemr/common/controller/covid/CovidVaccinationController.java b/src/main/java/com/iemr/common/controller/covid/CovidVaccinationController.java index a144e7c4..cb98145a 100644 --- a/src/main/java/com/iemr/common/controller/covid/CovidVaccinationController.java +++ b/src/main/java/com/iemr/common/controller/covid/CovidVaccinationController.java @@ -59,7 +59,7 @@ public class CovidVaccinationController { * @return list of vaccination type and dose taken */ - @CrossOrigin + @Operation(summary = "Master Data for Vaccination Type & Dose Taken") @GetMapping(value = { "/master/VaccinationTypeAndDoseTaken" }, produces = MediaType.APPLICATION_JSON) @@ -84,7 +84,7 @@ public String getVaccinationTypeAndDoseTaken(@RequestHeader(value = "Authorizati * @param Authorization * @return Covid vaccination details of a beneficiary */ - @CrossOrigin + @Operation(summary = "Getting beneficiary covid vaccination details") @PostMapping(value = { "/getCovidVaccinationDetails" }) @@ -128,7 +128,7 @@ public String getCovidVaccinationDetails( * @return Saving beneficiary vaccination details */ - @CrossOrigin + @Operation(summary = "Save beneficiary covid vaccination details") @PostMapping(value = { "/saveCovidVaccinationDetails" }) public String saveCovidVaccinationDetails( diff --git a/src/main/java/com/iemr/common/controller/cti/ComputerTelephonyIntegrationController.java b/src/main/java/com/iemr/common/controller/cti/ComputerTelephonyIntegrationController.java index 61c8ec19..85935c56 100644 --- a/src/main/java/com/iemr/common/controller/cti/ComputerTelephonyIntegrationController.java +++ b/src/main/java/com/iemr/common/controller/cti/ComputerTelephonyIntegrationController.java @@ -56,7 +56,7 @@ public void setCtiService(CTIService ctiService) { this.ctiService = ctiService; } - @CrossOrigin() + @Operation(summary = "Get campaign skills") @PostMapping(value = "/getCampaignSkills", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getCampaignSkills( @@ -78,7 +78,7 @@ public String getCampaignSkills( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get agent state") @PostMapping(value = "/getAgentState", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getAgentState(@Param("{\"agent_id\":\"String: agent id\"}") @RequestBody String request, @@ -99,7 +99,7 @@ public String getAgentState(@Param("{\"agent_id\":\"String: agent id\"}") @Reque return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get agent call stats") @PostMapping(value = "/getAgentCallStats", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getAgentCallStats(@Param("{\"agent_id\":\"String: agent id\"}") @RequestBody String request, @@ -120,7 +120,7 @@ public String getAgentCallStats(@Param("{\"agent_id\":\"String: agent id\"}") @R return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get campaign names") @PostMapping(value = "/getCampaignNames", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getCampaignNames( @@ -143,7 +143,7 @@ public String getCampaignNames( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get login key") @PostMapping(value = "/getLoginKey", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getLoginKey( @@ -165,7 +165,7 @@ public String getLoginKey( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Do agent logout") @PostMapping(value = "/doAgentLogout", produces = MediaType.APPLICATION_JSON) public String doAgentLogout(@Param("{\"agent_id\":\"String: agent id\"}") @RequestBody String request, @@ -186,7 +186,7 @@ public String doAgentLogout(@Param("{\"agent_id\":\"String: agent id\"}") @Reque return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get online agents") @PostMapping(value = "/getOnlineAgents", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getOnlineAgents(@Param("{\"agent_id\":\"String: agent id\"}") @RequestBody String request, @@ -207,7 +207,7 @@ public String getOnlineAgents(@Param("{\"agent_id\":\"String: agent id\"}") @Req return response.toString(); } - @CrossOrigin() + @Operation(summary = "Call beneficiary") @PostMapping(value = "/callBeneficiary", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String callBeneficiary( @@ -229,7 +229,7 @@ public String callBeneficiary( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Add update user data") @PostMapping(value = "/addUpdateUserData", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String addUpdateUserData( @@ -254,7 +254,7 @@ public String addUpdateUserData( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get transfer campaigns") @PostMapping(value = "/getTransferCampaigns", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getTransferCampaigns(@Param("{\"agent_id\":\"String: agentID\"}") @RequestBody String request, @@ -275,7 +275,7 @@ public String getTransferCampaigns(@Param("{\"agent_id\":\"String: agentID\"}") return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get campaign roles") @PostMapping(value = "/getCampaignRoles", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getCampaignRoles(@Param("{\"campaign\":\"String: campaign name\"}") @RequestBody String request, @@ -296,7 +296,7 @@ public String getCampaignRoles(@Param("{\"campaign\":\"String: campaign name\"}" return response.toString(); } - @CrossOrigin() + @Operation(summary = "Set call disposition") @PostMapping(value = "/setCallDisposition", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String setCallDisposition( @@ -319,7 +319,7 @@ public String setCallDisposition( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Create voice file") @PostMapping(value = "/createVoiceFile", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String createVoiceFile( @@ -342,7 +342,7 @@ public String createVoiceFile( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get voice file") @PostMapping(value = "/getVoiceFile", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getVoiceFile( @@ -365,7 +365,7 @@ public String getVoiceFile( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Disconnect call") @PostMapping(value = "/disconnectCall", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String disconnectCall(@Param("{\"agent_id\":\"String: agentID\"}") @RequestBody String request, @@ -386,7 +386,7 @@ public String disconnectCall(@Param("{\"agent_id\":\"String: agentID\"}") @Reque return response.toString(); } - @CrossOrigin() + @Operation(summary = "Switch to inbound") @PostMapping(value = "/switchToInbound", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String switchToInbound(@Param("{\"agent_id\":\"String: agentID\"}") @RequestBody String request, @@ -407,7 +407,7 @@ public String switchToInbound(@Param("{\"agent_id\":\"String: agentID\"}") @Requ return response.toString(); } - @CrossOrigin() + @Operation(summary = "Switch to outbound") @PostMapping(value = "/switchToOutbound", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String switchToOutbound(@Param("{\"agent_id\":\"String: agentID\"}") @RequestBody String request, @@ -428,7 +428,7 @@ public String switchToOutbound(@Param("{\"agent_id\":\"String: agentID\"}") @Req return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get agent IP address") @PostMapping(value = "/getAgentIPAddress", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getAgentIPAddress(@Param("{\"agent_id\":\"String: agentID\"}") @RequestBody String request, @@ -449,7 +449,7 @@ public String getAgentIPAddress(@Param("{\"agent_id\":\"String: agentID\"}") @Re return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get available agent skills") @PostMapping(value = "/getAvailableAgentSkills", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getAvailableAgentSkills( @@ -472,7 +472,7 @@ public String getAvailableAgentSkills( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Transfer call") @PostMapping(value = "/transferCall", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String transferCall(@Param("{\"transfer_from\":\"String - agent id who is transferring call\", " @@ -498,7 +498,7 @@ public String transferCall(@Param("{\"transfer_from\":\"String - agent id who is return response.toString(); } - @CrossOrigin() + @Operation(summary = "Customer preferred language") @PostMapping(value = "/customerPreferredLanguage", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String customerPreferredLanguage( @@ -524,7 +524,7 @@ public String customerPreferredLanguage( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get IVRS path details") @PostMapping(value = "/getIVRSPathDetails", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getIVRSPathDetails(@Param("{\"agent_id\":\"Integer\"}") @RequestBody String request, diff --git a/src/main/java/com/iemr/common/controller/customization/CustomizationController.java b/src/main/java/com/iemr/common/controller/customization/CustomizationController.java index f51c01b9..0c160a3c 100644 --- a/src/main/java/com/iemr/common/controller/customization/CustomizationController.java +++ b/src/main/java/com/iemr/common/controller/customization/CustomizationController.java @@ -30,7 +30,7 @@ public class CustomizationController { private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); - @CrossOrigin() + @Operation(summary = "Add project") @RequestMapping(value = "/addProject", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String addProject(@RequestBody String request, @@ -47,7 +47,7 @@ public String addProject(@RequestBody String request, return response.toString(); } - @CrossOrigin + @Operation(summary = "Fetch project names") @RequestMapping(value = "/get/projectNames/{serviceProviderId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getProjectNames(@PathVariable Integer serviceProviderId) { @@ -63,7 +63,7 @@ public String getProjectNames(@PathVariable Integer serviceProviderId) { return response.toString(); } - @CrossOrigin() + @Operation(summary = "Update project") @RequestMapping(value = "/updateProject", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") @@ -80,7 +80,7 @@ public String updateProject(@RequestBody String request, return response.toString(); } - @CrossOrigin() + @Operation(summary = "Save project to serviceline") @RequestMapping(value = "/saveProjectToServiceline", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String saveProjectToServiceline(@RequestBody String request, @@ -97,7 +97,7 @@ public String saveProjectToServiceline(@RequestBody String request, return response.toString(); } - @CrossOrigin() + @Operation(summary = "Fetch project serviceline") @RequestMapping(value = "/fetchProjectServiceline", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String fetchProjectServiceline(@RequestBody String request, @@ -114,7 +114,7 @@ public String fetchProjectServiceline(@RequestBody String request, return response.toString(); } - @CrossOrigin() + @Operation(summary = "Update project to serviceline") @RequestMapping(value = "/updateProjectToServiceline", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String updateProjectToServiceline(@RequestBody String request, @@ -131,7 +131,7 @@ public String updateProjectToServiceline(@RequestBody String request, return response.toString(); } - @CrossOrigin + @Operation(summary = "Fetch section masters") @RequestMapping(value = "/get/sections", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getSections() { @@ -147,7 +147,7 @@ public String getSections() { return response.toString(); } - @CrossOrigin() + @Operation(summary = "Update section and fields") @RequestMapping(value = "/updateSectionAndFields", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String updateSectionAndFields(@RequestBody String request, @@ -163,7 +163,7 @@ public String updateSectionAndFields(@RequestBody String request, return response.toString(); } - @CrossOrigin() + @Operation(summary = "Save section and fields") @RequestMapping(value = "/saveSectionAndFields", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String saveSectionAndFields(@RequestBody SectionFieldsMappingDTO sectionFieldsMappingDTO, @@ -179,7 +179,7 @@ public String saveSectionAndFields(@RequestBody SectionFieldsMappingDTO sectionF return response.toString(); } - @CrossOrigin() + @Operation(summary = "Section and project mapping") @RequestMapping(value = "/mapSectionToProject", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String mapSectionToProject(@RequestBody SectionProjectMappingDTO sectionProjectMappingDTO, @@ -196,7 +196,7 @@ public String mapSectionToProject(@RequestBody SectionProjectMappingDTO sectionP return response.toString(); } - @CrossOrigin() + @Operation(summary = "Fetch mapped sections in project") @RequestMapping(value = "/fetchMappedSectionsInProject", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String fetchMappedSectionsInProject(@RequestBody String request, @@ -213,7 +213,7 @@ public String fetchMappedSectionsInProject(@RequestBody String request, return response.toString(); } - @CrossOrigin() + @Operation(summary = "Fetch mapped fields") @RequestMapping(value = "/fetchMappedFields", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String fetchMappedFields(@RequestBody String request, @@ -230,7 +230,7 @@ public String fetchMappedFields(@RequestBody String request, return response.toString(); } - @CrossOrigin() + @Operation(summary = "Fetch all data") @RequestMapping(value = "/fetchAllData", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String fetchAllData(@RequestBody String request, @@ -247,7 +247,7 @@ public String fetchAllData(@RequestBody String request, return response.toString(); } - @CrossOrigin + @Operation(summary = "Fetch field masters") @RequestMapping(value = "/get/fileldType", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getfileldType() { diff --git a/src/main/java/com/iemr/common/controller/directory/DirectoryController.java b/src/main/java/com/iemr/common/controller/directory/DirectoryController.java index 96d2b0b9..510855d9 100644 --- a/src/main/java/com/iemr/common/controller/directory/DirectoryController.java +++ b/src/main/java/com/iemr/common/controller/directory/DirectoryController.java @@ -79,7 +79,7 @@ public void setDirectoryMappingService(DirectoryMappingService directoryMappingS private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); - @CrossOrigin() + @Operation(summary = "Get directory") @RequestMapping(value = "/getDirectory", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") @@ -100,7 +100,7 @@ public String getDirectory() return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get directory V1") @RequestMapping(value = "/getDirectoryV1", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") @@ -124,7 +124,7 @@ public String getDirectoryV1( return response.toString(); } - @CrossOrigin() + @Operation(summary = "This API is used for getting subdirectories for a given institute directory") @RequestMapping(value = "/getSubDirectory", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization") @@ -148,7 +148,7 @@ public String getSubDirectory(@Param("{\"instituteDirectoryID\":\"Integer\"}") @ return response.toString(); } - @CrossOrigin() + @Operation(summary = "This API is used for getting institutes for a given directory, subdirectory and location") @RequestMapping(value = "/getInstitutesDirectories", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization") diff --git a/src/main/java/com/iemr/common/controller/door_to_door_app/DoorToDoorAppController.java b/src/main/java/com/iemr/common/controller/door_to_door_app/DoorToDoorAppController.java index ed373995..d187a868 100644 --- a/src/main/java/com/iemr/common/controller/door_to_door_app/DoorToDoorAppController.java +++ b/src/main/java/com/iemr/common/controller/door_to_door_app/DoorToDoorAppController.java @@ -39,7 +39,7 @@ import io.swagger.v3.oas.annotations.Operation; -@CrossOrigin + @RestController @RequestMapping(value = "/doortodoorapp", headers = "Authorization") public class DoorToDoorAppController { @@ -49,7 +49,7 @@ public class DoorToDoorAppController { @Autowired private DoorToDoorService doorToDoorService; - @CrossOrigin + @Operation(summary = "Get user details") @RequestMapping(value = { "/getUserDetails" }, method = { RequestMethod.POST }, consumes = "application/json", produces = "application/json") public String getUserDetails(@RequestBody String requestObj) { @@ -70,7 +70,7 @@ public String getUserDetails(@RequestBody String requestObj) { return response.toString(); } - @CrossOrigin + @Operation(summary = "Get NCD TB HRP suspected status") @PostMapping(value = { "/getSuspectedData_HRP_TB_NCD" }, consumes = "application/json", produces = "application/json") public String getSuspectedData_HRP_TB_NCD(@RequestBody String requestObj) { diff --git a/src/main/java/com/iemr/common/controller/eausadha/EAusadhaController.java b/src/main/java/com/iemr/common/controller/eausadha/EAusadhaController.java index 2af9f6d2..791c43fb 100644 --- a/src/main/java/com/iemr/common/controller/eausadha/EAusadhaController.java +++ b/src/main/java/com/iemr/common/controller/eausadha/EAusadhaController.java @@ -24,7 +24,7 @@ public class EAusadhaController { private Logger logger = LoggerFactory.getLogger(this.getClass().getName()); - @CrossOrigin + @PostMapping(value = { "/create-eAusadha" }) public String createEAusadha(@RequestBody EAusadhaDTO eAusadhaDTO, @RequestHeader(value = "Authorization") String Authorization) { OutputResponse response = new OutputResponse(); diff --git a/src/main/java/com/iemr/common/controller/email/EmailController.java b/src/main/java/com/iemr/common/controller/email/EmailController.java index 4e654ada..89c54a8e 100644 --- a/src/main/java/com/iemr/common/controller/email/EmailController.java +++ b/src/main/java/com/iemr/common/controller/email/EmailController.java @@ -55,7 +55,7 @@ public void setEmailService(EmailService emailService) { this.emailService = emailService; } - @CrossOrigin + @Operation(summary = "Send email") @PostMapping(value = "/SendEmail", headers = "Authorization") public String SendEmail( @@ -74,7 +74,7 @@ public String SendEmail( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get authority email id") @PostMapping(value = "/getAuthorityEmailID", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getAuthorityEmailID(@Param(value = "{districtID : Integer}") @RequestBody String severityRequest) { @@ -89,7 +89,7 @@ public String getAuthorityEmailID(@Param(value = "{districtID : Integer}") @Requ return response.toString(); } - @CrossOrigin + @Operation(summary = "Send email general") @PostMapping(value = "/sendEmailGeneral", headers = "Authorization") public String sendEmailGeneral( diff --git a/src/main/java/com/iemr/common/controller/esanjeevani/ESanjeevaniController.java b/src/main/java/com/iemr/common/controller/esanjeevani/ESanjeevaniController.java index 85fdbb28..c00d0aa2 100644 --- a/src/main/java/com/iemr/common/controller/esanjeevani/ESanjeevaniController.java +++ b/src/main/java/com/iemr/common/controller/esanjeevani/ESanjeevaniController.java @@ -18,7 +18,6 @@ import io.swagger.v3.oas.annotations.Operation; -@CrossOrigin @RestController @RequestMapping(value = "/esanjeevani", headers = "Authorization") public class ESanjeevaniController { @@ -28,7 +27,6 @@ public class ESanjeevaniController { private Logger logger = LoggerFactory.getLogger(this.getClass().getName()); - @CrossOrigin @Operation(summary = "Register patient in E-Sanjeevani and send portal url to route") @GetMapping(value = { "/getESanjeevaniUrl/{beneficiaryReqId}" }, consumes = "application/json", produces = "application/json") public String registerESanjeevaniPatient(@PathVariable Long beneficiaryReqId) { diff --git a/src/main/java/com/iemr/common/controller/everwell/callhandle/EverwellCallController.java b/src/main/java/com/iemr/common/controller/everwell/callhandle/EverwellCallController.java index 787c7654..1c8e0e37 100644 --- a/src/main/java/com/iemr/common/controller/everwell/callhandle/EverwellCallController.java +++ b/src/main/java/com/iemr/common/controller/everwell/callhandle/EverwellCallController.java @@ -26,16 +26,13 @@ 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.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; - import com.iemr.common.service.everwell.EverwellCallHandlingService; import com.iemr.common.utils.mapper.InputMapper; import com.iemr.common.utils.response.OutputResponse; - import io.lettuce.core.dynamic.annotation.Param; import io.swagger.v3.oas.annotations.Operation; @@ -48,7 +45,6 @@ public class EverwellCallController { InputMapper inputMapper = new InputMapper(); final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); - @CrossOrigin() @Operation(summary = "Outbound call count") @RequestMapping(value = "/outboundCallCount", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String outboundCallCount(@Param(value = "{\"providerServiceMapID\":\"called service ID integer\", " @@ -65,7 +61,6 @@ public String outboundCallCount(@Param(value = "{\"providerServiceMapID\":\"call return response.toString(); } - @CrossOrigin() @Operation(summary = "Outbound allocation") @RequestMapping(value = "/outboundAllocation", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String outboundAllocation(@Param(value = "{\"AgentID\":[Integer Array list of Agent IDs], " @@ -82,7 +77,6 @@ public String outboundAllocation(@Param(value = "{\"AgentID\":[Integer Array lis return response.toString(); } - @CrossOrigin() @Operation(summary = "Outbound call list") @RequestMapping(value = "/outboundCallList", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String outboundCallList(@Param(value = "{\"providerServiceMapID\":\" called service ID integer\", " @@ -99,7 +93,6 @@ public String outboundCallList(@Param(value = "{\"providerServiceMapID\":\" call return response.toString(); } - @CrossOrigin() @Operation(summary = "Reset outbound call") @RequestMapping(value = "/resetOutboundCall", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String resetOutboundCall( @@ -115,7 +108,6 @@ public String resetOutboundCall( return response.toString(); } - @CrossOrigin() @Operation(summary = "Save feedback") @RequestMapping(value = "/saveFeedback", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String saveCallDetails( @@ -131,7 +123,6 @@ public String saveCallDetails( return response.toString(); } - @CrossOrigin() @Operation(summary = "Complete outbound call") @RequestMapping(value = "/completeOutboundCall", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String completeOutboundCall(@Param(value = "{\"EAPIID\":\"Integer - Outbound call id\", " @@ -150,7 +141,6 @@ public String completeOutboundCall(@Param(value = "{\"EAPIID\":\"Integer - Outbo return response.toString(); } - @CrossOrigin() @Operation(summary = "Get everwell feedback details") @RequestMapping(value = "/getEverwellfeedbackDetails", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getEverwellfeedbackDetails( @@ -169,7 +159,6 @@ public String getEverwellfeedbackDetails( return response.toString(); } - @CrossOrigin() @Operation(summary = "Outbound call list with mobile number") @RequestMapping(value = "/outboundCallListWithMobileNumber", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String outboundCallListWithMobileNumber( @@ -184,7 +173,6 @@ public String outboundCallListWithMobileNumber( return response.toString(); } - @CrossOrigin() @Operation(summary = "Check if already called") @RequestMapping(value = "/checkIfAlreadyCalled", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String checkIfCalledOrNot(@Param(value = "{\"providerServiceMapID\":\" called service ID integer\", " diff --git a/src/main/java/com/iemr/common/controller/everwellTest/EverwellController.java b/src/main/java/com/iemr/common/controller/everwellTest/EverwellController.java index 8fd48bb2..eb9c1c0b 100644 --- a/src/main/java/com/iemr/common/controller/everwellTest/EverwellController.java +++ b/src/main/java/com/iemr/common/controller/everwellTest/EverwellController.java @@ -25,17 +25,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; - import com.iemr.common.model.user.LoginRequestModelEverwell; import com.iemr.common.utils.mapper.InputMapper; import com.iemr.common.utils.response.OutputResponse; - import io.swagger.v3.oas.annotations.Operation; @@ -45,7 +42,6 @@ public class EverwellController { InputMapper inputMapper = new InputMapper(); Logger logger = LoggerFactory.getLogger(this.getClass().getName()); - @CrossOrigin() @Operation(summary = "Get data") @RequestMapping(value = "/getjson", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getdata() { @@ -74,7 +70,6 @@ public String getdata() { return response.toString(); } - @CrossOrigin() @Operation(summary = "Add support action") @RequestMapping(value = { "/addSupportAction/{id}" }, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") @@ -95,7 +90,6 @@ public String addSupportAction(@PathVariable("id") Long id, @RequestBody String return response.toString(); } - @CrossOrigin() @Operation(summary = "Edit manual doses") @RequestMapping(value = { "/editManualDoses/{id}" }, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") @@ -112,7 +106,6 @@ public String editManualDoses(@PathVariable("id") Long id, @RequestBody String r return response.toString(); } - @CrossOrigin() @Operation(summary = "Everwell login") @RequestMapping(value = "/login", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String everwellLogin(@RequestBody LoginRequestModelEverwell login) { diff --git a/src/main/java/com/iemr/common/controller/feedback/FeedbackController.java b/src/main/java/com/iemr/common/controller/feedback/FeedbackController.java index 421d1202..a892d66e 100644 --- a/src/main/java/com/iemr/common/controller/feedback/FeedbackController.java +++ b/src/main/java/com/iemr/common/controller/feedback/FeedbackController.java @@ -1,45 +1,40 @@ /* -* 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/. -*/ + * 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.common.controller.feedback; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; - - import javax.ws.rs.core.MediaType; - 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.PathVariable; 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.RequestMethod; import org.springframework.web.bind.annotation.RestController; - import com.fasterxml.jackson.databind.ObjectMapper; import com.iemr.common.data.feedback.FeedbackDetails; import com.iemr.common.data.feedback.FeedbackLog; @@ -55,7 +50,6 @@ import com.iemr.common.utils.mapper.InputMapper; import com.iemr.common.utils.mapper.OutputMapper; import com.iemr.common.utils.response.OutputResponse; - import io.lettuce.core.dynamic.annotation.Param; import io.swagger.v3.oas.annotations.Operation; import jakarta.servlet.http.HttpServletRequest; @@ -63,445 +57,445 @@ @RequestMapping(value = "/feedback") @RestController public class FeedbackController { - InputMapper inputMapper = new InputMapper(); - final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); - - private FeedbackService feedbackService; - - @Autowired - public void setFeedbackService(FeedbackService feedbackService) { - - this.feedbackService = feedbackService; - } - - private FeedbackTypeService feedbackTypeService; - - @Autowired - public void setfeedbackTypeService(FeedbackTypeService feedbackTypeService) { - - this.feedbackTypeService = feedbackTypeService; - } - - private FeedbackResponseService feedbackResponseService; - - @Autowired - public void setFeedbackResponseService(FeedbackResponseService feedbackResponseService) { - this.feedbackResponseService = feedbackResponseService; - } - - private FeedbackRequestService feedbackRequestService; - - @Autowired - public void setFeedbackRequestService(FeedbackRequestService feedbackRequestService) { - this.feedbackRequestService = feedbackRequestService; - } - - @CrossOrigin() - @Operation(summary = "Beneficiary request") - @RequestMapping(value = "/beneficiaryRequests", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String feedbackRequest(@RequestBody String request) { - OutputResponse response = new OutputResponse(); - try { - FeedbackDetails feedbackDetails = inputMapper.gson().fromJson(request, FeedbackDetails.class); - List feedbackList = feedbackService - .getFeedbackRequests(feedbackDetails.getBeneficiaryRegID()); - response.setResponse(feedbackList.toString()); - } catch (Exception e) { - logger.error("getfeedbacklist failed with error " + e.getMessage(), e); - response.setError(e); - } - return response.toString(); - } - - @CrossOrigin() - @Operation(summary = "Get feedback from feedback id") - @RequestMapping(value = "/getfeedback/{feedbackID}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String getFeedbackByPost(@PathVariable("feedbackID") Long feedbackID) { - OutputResponse response = new OutputResponse(); - try { - logger.info("" + feedbackID); - List savedDetails = feedbackService.getFeedbackRequests(feedbackID); - response.setResponse(savedDetails.toString()); - } catch (Exception e) { - logger.error("getfeedback failed with error " + e.getMessage(), e); - response.setError(e); - } - return response.toString(); - } - - @CrossOrigin() - @Operation(summary = "Create feedback") - @RequestMapping(value = "/createFeedback", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String createFeedback(@RequestBody String feedbackDetails) { - - OutputResponse response = new OutputResponse(); - try { - String feedbackResponse = feedbackService.saveFeedback(feedbackDetails); - response.setResponse(feedbackResponse); - } catch (Exception e) { - logger.error("createFeedback failed with error " + e.getMessage(), e); - response.setError(e); - } - return response.toString(); - } - - @CrossOrigin() - @Operation(summary = "Feedback list") - @RequestMapping(value = "/feedbacksList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String feedbacksList(@RequestBody String request) { - - OutputResponse response = new OutputResponse(); - try { - FeedbackDetails feedbackDetails = inputMapper.gson().fromJson(request, FeedbackDetails.class); - List feedbackList = feedbackService - .getFeedbackRequests(feedbackDetails.getBeneficiaryRegID()); - response.setResponse(feedbackList.toString()); - } catch (Exception e) { - logger.error("createFeedback failed with error " + e.getMessage(), e); - response.setError(e); - } - return response.toString(); - } - - @CrossOrigin - @Operation(summary = "Get feedback") - @RequestMapping(value = "/getFeedback", method = RequestMethod.POST, headers = "Authorization") - public String getFeedback(@RequestBody String feedbackRequest) { - OutputResponse response = new OutputResponse(); - try { - response.setResponse(feedbackService.getAllData(feedbackRequest)); - } catch (Exception e) { - logger.error("createFeedback failed with error " + e.getMessage(), e); - response.setError(e); - - } - return response.toString(); - } - - @CrossOrigin() - @Operation(summary = "Update feedback") - @RequestMapping(value = "/updatefeedback", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String updateFeedback(@RequestBody String feedbackDetails) { - OutputResponse response = new OutputResponse(); - try { - response.setResponse(feedbackService.updateFeedback(feedbackDetails).toString()); - } catch (Exception e) { - logger.error("updatefeedback failed with error " + e.getMessage(), e); - response.setError(e); - } - return response.toString(); - } - - @CrossOrigin - @Operation(summary = "Create a new beneficiary") - @RequestMapping(value = "/updateFeedbackStatus", method = RequestMethod.POST, headers = "Authorization") - public String updateFeedbackStatus(@RequestBody String feedbackDetails) { - OutputResponse response = new OutputResponse(); - logger.info("updateFeedbackStatus request " + feedbackDetails); - try { - response.setResponse(feedbackService.updateFeedbackStatus(feedbackDetails).toString()); - } catch (Exception e) { - logger.error("updateFeedbackStatus failed with error " + e.getMessage(), e); - response.setError(e); - } - logger.info("updateFeedbackStatus response " + response.toString()); - return response.toString(); - } - - @CrossOrigin - @Operation(summary = "Search feedback") - @RequestMapping(value = "/searchFeedback", method = RequestMethod.POST, headers = "Authorization") - public String searchFeedback(@RequestBody String feedbackDetails) { - OutputResponse response = new OutputResponse(); - logger.info("searchFeedback request " + feedbackDetails); - try { - response.setResponse(feedbackService.searchFeedback(feedbackDetails)); - } catch (Exception e) { - logger.error("searchFeedback failed with error " + e.getMessage(), e); - response.setError(e); - } - logger.info("searchFeedback response " + response.toString()); - return response.toString(); - } - - @CrossOrigin - @Operation(summary = "Search feedback1") - @RequestMapping(value = "/searchFeedback1", method = RequestMethod.POST, headers = "Authorization") - public String searchFeedback1(@RequestBody String feedbackDetails) { - OutputResponse response = new OutputResponse(); - logger.info("searchFeedback1 request " + feedbackDetails); - try { - response.setResponse(feedbackService.searchFeedback1(feedbackDetails)); - } catch (Exception e) { - logger.error("searchFeedback1 failed with error " + e.getMessage(), e); - response.setError(e); - } - logger.info("searchFeedback1 response " + response.toString()); - return response.toString(); - } - - @CrossOrigin - @Operation(summary = "Get all feedback") - @RequestMapping(value = "/getAllFeedbackById", method = RequestMethod.POST, headers = "Authorization") - public String getAllFeedbackById(@RequestBody String feedbackrequest) { - OutputResponse response = new OutputResponse(); - logger.info("getAllFeedbackById request " + feedbackrequest); - try { - response.setResponse(feedbackRequestService.getAllFeedback(feedbackrequest)); - } catch (Exception e) { - logger.error("getAllFeedbackById failed with error " + e.getMessage(), e); - response.setError(e); - } - logger.info("getAllFeedbackById response " + response.toString()); - return response.toString(); - } - - @CrossOrigin - @Operation(summary = "Get all feedback by id") - @RequestMapping(value = "/getAllFeedbackById1", method = RequestMethod.POST, headers = "Authorization") - public String getAllfeedback(@RequestBody FeedbackResponse tfeedbackresponce) { - Map resMap = null; - List> resList = new ArrayList<>(); - ArrayList data2 = feedbackResponseService.getdataById(tfeedbackresponce.getFeedbackID()); - - if (data2 != null && data2.size() > 0) { - for (Object[] objList : data2) { - resMap = new HashMap<>(); - resMap.put("ResponseSummary", objList[0]); - resMap.put("FeedbackRequestID", objList[1]); - resMap.put("Comments", objList[2]); - resMap.put("AuthName", objList[3]); - resMap.put("AuthDesignation", objList[4]); - resMap.put("FeedbackID", objList[5]); - resMap.put("FeedbackSupSummary", objList[6]); - resMap.put("Feedback", objList[8]); - resList.add(resMap); - - } - } - - return OutputMapper.gsonWithoutExposeRestriction().toJson(resList); - } - - @CrossOrigin - @Operation(summary = "Get feedback status") - @RequestMapping(value = "/getFeedbackStatus", method = RequestMethod.POST, headers = "Authorization") - public String getFeedbackStatusTypes(@RequestBody String request) { - OutputResponse response = new OutputResponse(); - try { - response.setResponse(feedbackService.getFeedbackStatus(request)); - } catch (Exception e) { - response.setError(e); - } - return response.toString(); - } - - @CrossOrigin - @Operation(summary = "Get email status") - @RequestMapping(value = "/getEmailStatus", method = RequestMethod.POST, headers = "Authorization") - public String getEmailStatus(@RequestBody String request) { - OutputResponse response = new OutputResponse(); - try { - response.setResponse(feedbackService.getEmailStatus(request)); - } catch (Exception e) { - response.setError(e); - } - return response.toString(); - } - - @CrossOrigin - @Operation(summary = "Get feedback request by id") - @RequestMapping(value = "/getFeedbackRequestById", method = RequestMethod.POST, headers = "Authorization") - public String getFeedbackRequestById(@RequestBody String feedbackrequest) { - OutputResponse response = new OutputResponse(); - logger.info("getAllFeedbackById request " + feedbackrequest); - try { - response.setResponse(feedbackRequestService.getAllFeedback(feedbackrequest)); - } catch (Exception e) { - logger.error("getAllFeedbackById failed with error " + e.getMessage(), e); - response.setError(e); - } - logger.info("getAllFeedbackById response " + response.toString()); - return response.toString(); - } - - @CrossOrigin - @Operation(summary = "Get feedback response by id") - @RequestMapping(value = "/getFeedbackResponseById", method = RequestMethod.POST, headers = "Authorization") - public String getFeedbackResponseById(@RequestBody String feedbackrequest) { - OutputResponse response = new OutputResponse(); - logger.info("getAllFeedbackById request " + feedbackrequest); - try { - response.setResponse(feedbackRequestService.getAllFeedback(feedbackrequest)); - } catch (Exception e) { - logger.error("getAllFeedbackById failed with error " + e.getMessage(), e); - response.setError(e); - } - logger.info("getAllFeedbackById response " + response.toString()); - return response.toString(); - } - - @CrossOrigin - @Operation(summary = "Get feedback list") - @RequestMapping(value = "/getFeedbacksList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization") - public String getFeedbacksList(@RequestBody FeedbackListRequestModel feedbackDetails, - HttpServletRequest httpRequest) { - OutputResponse response = new OutputResponse(); - logger.info("getFeedbacksList request " + feedbackDetails); - try { - response.setResponse( - feedbackService.getFeedbacksList(feedbackDetails, httpRequest.getHeader("Authorization"))); - } catch (Exception e) { - logger.error("getFeedbacksList failed with error " + e.getMessage(), e); - response.setError(e); - } - logger.debug("getFeedbacksList response " + response.toString()); - logger.info("getFeedbacksList response code " + response.getStatusCode()); - return response.toString(); - - } - - @CrossOrigin - @Operation(summary = "Update response") - @PostMapping(value = "/updateResponse", headers = "Authorization") - public String updateResponse(@RequestBody String feedbackresponce) { - OutputResponse response = new OutputResponse(); - logger.info("updateResponse request " + feedbackresponce); - try { - response.setResponse(feedbackService.updateResponse(feedbackresponce)); - } catch (Exception e) { - logger.error("responceFeedback failed with error " + e.getMessage(), e); - response.setError(e); - } - logger.debug("updateResponse response " + response.toString()); - logger.info("updateResponse response " + response.getStatusCode()); - return response.toString(); - } - - @CrossOrigin - @Operation(summary = "Request feedback") - @RequestMapping(value = "/requestFeedback", method = RequestMethod.POST, headers = "Authorization") - public String requestFeedback(@RequestBody String feedbackRequest) { - OutputResponse response = new OutputResponse(); - logger.info("requestFeedback request " + feedbackRequest); - try { - response.setResponse(feedbackService.createFeedbackRequest(feedbackRequest)); - } catch (Exception e) { - logger.error("requestFeedback failed with error " + e.getMessage(), e); - response.setError(e); - } - logger.debug("requestFeedback response " + response.toString()); - logger.info("requestFeedback response " + response.getStatusCode()); - return response.toString(); - } - - FeedbackSeverityServiceImpl feedbackSeverityService; - - @Autowired - public void setFeedbackSeverityService(FeedbackSeverityServiceImpl feedbackSeverityService) { - this.feedbackSeverityService = feedbackSeverityService; - } - - @CrossOrigin() - @Operation(summary = "Get severity") - @RequestMapping(value = "/getSeverity", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String getFeedbackSeverity( - @Param(value = "{providerServiceMapID : Integer}") @RequestBody String severityRequest) { - - OutputResponse response = new OutputResponse(); - try { - ObjectMapper objectMapper = new ObjectMapper(); - FeedbackSeverity severity = objectMapper.readValue(severityRequest, FeedbackSeverity.class); - response.setResponse( - feedbackSeverityService.getActiveFeedbackSeverity(severity.getProviderServiceMapID()).toString()); - } catch (Exception e) { - logger.error("", e); - response.setError(e); - } - return response.toString(); - } - - @CrossOrigin() - @Operation(summary = "Get feedback type") - @RequestMapping(value = "/getFeedbackType", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String getFeedbackType( - @Param(value = "{providerServiceMapID : Integer}") @RequestBody String severityRequest) { - - OutputResponse response = new OutputResponse(); - try { - ObjectMapper objectMapper = new ObjectMapper(); - FeedbackType feedbackType = objectMapper.readValue(severityRequest, FeedbackType.class); - response.setResponse( - feedbackTypeService.getActiveFeedbackTypes(feedbackType.getProviderServiceMapID()).toString()); - } catch (Exception e) { - logger.error("", e); - response.setError(e); - } - return response.toString(); - } - - @CrossOrigin - @Operation(summary = "Get grievances by created date") - @RequestMapping(value = "/getGrievancesByCreatedDate", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization") - public String getGrievancesByCreatedDate(@RequestBody FeedbackListRequestModel feedbackDetails, - HttpServletRequest httpRequest) { - OutputResponse response = new OutputResponse(); - logger.info("getGrievancesByCreatedDate request " + feedbackDetails); - try { - response.setResponse(feedbackService.getGrievancesByCreatedDate(feedbackDetails, - httpRequest.getHeader("Authorization"))); - } catch (Exception e) { - logger.error("getGrievancesByCreatedDate failed with error " + e.getMessage(), e); - response.setError(e); - } - return response.toString(); - } - - @CrossOrigin - @Operation(summary = "Get grievances by updated date") - @RequestMapping(value = "/getGrievancesByUpdatedDate", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization") - public String getGrievancesByUpdatedDate(@RequestBody FeedbackListRequestModel feedbackDetails, - HttpServletRequest httpRequest) { - OutputResponse response = new OutputResponse(); - logger.info("getGrievancesByUpdatedDate request " + feedbackDetails); - try { - response.setResponse(feedbackService.getGrievancesByUpdatedDate(feedbackDetails, - httpRequest.getHeader("Authorization"))); - } catch (Exception e) { - logger.error("getGrievancesByUpdatedDate failed with error " + e.getMessage(), e); - response.setError(e); - } - return response.toString(); - } - - @CrossOrigin - @Operation(summary = "Save feedback request") - @RequestMapping(value = "/saveFeedbackRequest", method = RequestMethod.POST, headers = "Authorization") - public String createFeedbackRequest(@RequestBody String feedbackRequest) { - OutputResponse response = new OutputResponse(); - logger.info("saveFeedbackRequest request " + feedbackRequest); - try { - response.setResponse(feedbackService.saveFeedbackRequest(feedbackRequest)); - } catch (Exception e) { - logger.error("saveFeedbackRequest failed with error " + e.getMessage(), e); - response.setError(e); - } - return response.toString(); - } - - @CrossOrigin - @Operation(summary = "Get feedback logs") - @RequestMapping(value = "/getFeedbackLogs", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization") - public String getFeedbackLogs(@RequestBody String request) { - OutputResponse response = new OutputResponse(); - logger.info("getFeedbackLogs request " + request); - try { - FeedbackLog feedbackLogs = inputMapper.gson().fromJson(request, FeedbackLog.class); - response.setResponse(feedbackService.getFeedbackLogs(feedbackLogs)); - } catch (Exception e) { - logger.error("getFeedbackLogs failed with error " + e.getMessage(), e); - response.setError(e); - } - return response.toString(); - } + InputMapper inputMapper = new InputMapper(); + final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + + private FeedbackService feedbackService; + + @Autowired + public void setFeedbackService(FeedbackService feedbackService) { + + this.feedbackService = feedbackService; + } + + private FeedbackTypeService feedbackTypeService; + + @Autowired + public void setfeedbackTypeService(FeedbackTypeService feedbackTypeService) { + + this.feedbackTypeService = feedbackTypeService; + } + + private FeedbackResponseService feedbackResponseService; + + @Autowired + public void setFeedbackResponseService(FeedbackResponseService feedbackResponseService) { + this.feedbackResponseService = feedbackResponseService; + } + + private FeedbackRequestService feedbackRequestService; + + @Autowired + public void setFeedbackRequestService(FeedbackRequestService feedbackRequestService) { + this.feedbackRequestService = feedbackRequestService; + } + + + @Operation(summary = "Beneficiary request") + @RequestMapping(value = "/beneficiaryRequests", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String feedbackRequest(@RequestBody String request) { + OutputResponse response = new OutputResponse(); + try { + FeedbackDetails feedbackDetails = inputMapper.gson().fromJson(request, FeedbackDetails.class); + List feedbackList = feedbackService + .getFeedbackRequests(feedbackDetails.getBeneficiaryRegID()); + response.setResponse(feedbackList.toString()); + } catch (Exception e) { + logger.error("getfeedbacklist failed with error " + e.getMessage(), e); + response.setError(e); + } + return response.toString(); + } + + + @Operation(summary = "Get feedback from feedback id") + @RequestMapping(value = "/getfeedback/{feedbackID}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String getFeedbackByPost(@PathVariable("feedbackID") Long feedbackID) { + OutputResponse response = new OutputResponse(); + try { + logger.info("" + feedbackID); + List savedDetails = feedbackService.getFeedbackRequests(feedbackID); + response.setResponse(savedDetails.toString()); + } catch (Exception e) { + logger.error("getfeedback failed with error " + e.getMessage(), e); + response.setError(e); + } + return response.toString(); + } + + + @Operation(summary = "Create feedback") + @RequestMapping(value = "/createFeedback", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String createFeedback(@RequestBody String feedbackDetails) { + + OutputResponse response = new OutputResponse(); + try { + String feedbackResponse = feedbackService.saveFeedback(feedbackDetails); + response.setResponse(feedbackResponse); + } catch (Exception e) { + logger.error("createFeedback failed with error " + e.getMessage(), e); + response.setError(e); + } + return response.toString(); + } + + + @Operation(summary = "Feedback list") + @RequestMapping(value = "/feedbacksList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String feedbacksList(@RequestBody String request) { + + OutputResponse response = new OutputResponse(); + try { + FeedbackDetails feedbackDetails = inputMapper.gson().fromJson(request, FeedbackDetails.class); + List feedbackList = feedbackService + .getFeedbackRequests(feedbackDetails.getBeneficiaryRegID()); + response.setResponse(feedbackList.toString()); + } catch (Exception e) { + logger.error("createFeedback failed with error " + e.getMessage(), e); + response.setError(e); + } + return response.toString(); + } + + + @Operation(summary = "Get feedback") + @RequestMapping(value = "/getFeedback", method = RequestMethod.POST, headers = "Authorization") + public String getFeedback(@RequestBody String feedbackRequest) { + OutputResponse response = new OutputResponse(); + try { + response.setResponse(feedbackService.getAllData(feedbackRequest)); + } catch (Exception e) { + logger.error("createFeedback failed with error " + e.getMessage(), e); + response.setError(e); + + } + return response.toString(); + } + + + @Operation(summary = "Update feedback") + @RequestMapping(value = "/updatefeedback", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String updateFeedback(@RequestBody String feedbackDetails) { + OutputResponse response = new OutputResponse(); + try { + response.setResponse(feedbackService.updateFeedback(feedbackDetails).toString()); + } catch (Exception e) { + logger.error("updatefeedback failed with error " + e.getMessage(), e); + response.setError(e); + } + return response.toString(); + } + + + @Operation(summary = "Create a new beneficiary") + @RequestMapping(value = "/updateFeedbackStatus", method = RequestMethod.POST, headers = "Authorization") + public String updateFeedbackStatus(@RequestBody String feedbackDetails) { + OutputResponse response = new OutputResponse(); + logger.info("updateFeedbackStatus request " + feedbackDetails); + try { + response.setResponse(feedbackService.updateFeedbackStatus(feedbackDetails).toString()); + } catch (Exception e) { + logger.error("updateFeedbackStatus failed with error " + e.getMessage(), e); + response.setError(e); + } + logger.info("updateFeedbackStatus response " + response.toString()); + return response.toString(); + } + + + @Operation(summary = "Search feedback") + @RequestMapping(value = "/searchFeedback", method = RequestMethod.POST, headers = "Authorization") + public String searchFeedback(@RequestBody String feedbackDetails) { + OutputResponse response = new OutputResponse(); + logger.info("searchFeedback request " + feedbackDetails); + try { + response.setResponse(feedbackService.searchFeedback(feedbackDetails)); + } catch (Exception e) { + logger.error("searchFeedback failed with error " + e.getMessage(), e); + response.setError(e); + } + logger.info("searchFeedback response " + response.toString()); + return response.toString(); + } + + + @Operation(summary = "Search feedback1") + @RequestMapping(value = "/searchFeedback1", method = RequestMethod.POST, headers = "Authorization") + public String searchFeedback1(@RequestBody String feedbackDetails) { + OutputResponse response = new OutputResponse(); + logger.info("searchFeedback1 request " + feedbackDetails); + try { + response.setResponse(feedbackService.searchFeedback1(feedbackDetails)); + } catch (Exception e) { + logger.error("searchFeedback1 failed with error " + e.getMessage(), e); + response.setError(e); + } + logger.info("searchFeedback1 response " + response.toString()); + return response.toString(); + } + + + @Operation(summary = "Get all feedback") + @RequestMapping(value = "/getAllFeedbackById", method = RequestMethod.POST, headers = "Authorization") + public String getAllFeedbackById(@RequestBody String feedbackrequest) { + OutputResponse response = new OutputResponse(); + logger.info("getAllFeedbackById request " + feedbackrequest); + try { + response.setResponse(feedbackRequestService.getAllFeedback(feedbackrequest)); + } catch (Exception e) { + logger.error("getAllFeedbackById failed with error " + e.getMessage(), e); + response.setError(e); + } + logger.info("getAllFeedbackById response " + response.toString()); + return response.toString(); + } + + + @Operation(summary = "Get all feedback by id") + @RequestMapping(value = "/getAllFeedbackById1", method = RequestMethod.POST, headers = "Authorization") + public String getAllfeedback(@RequestBody FeedbackResponse tfeedbackresponce) { + Map resMap = null; + List> resList = new ArrayList<>(); + ArrayList data2 = feedbackResponseService.getdataById(tfeedbackresponce.getFeedbackID()); + + if (data2 != null && data2.size() > 0) { + for (Object[] objList : data2) { + resMap = new HashMap<>(); + resMap.put("ResponseSummary", objList[0]); + resMap.put("FeedbackRequestID", objList[1]); + resMap.put("Comments", objList[2]); + resMap.put("AuthName", objList[3]); + resMap.put("AuthDesignation", objList[4]); + resMap.put("FeedbackID", objList[5]); + resMap.put("FeedbackSupSummary", objList[6]); + resMap.put("Feedback", objList[8]); + resList.add(resMap); + + } + } + + return OutputMapper.gsonWithoutExposeRestriction().toJson(resList); + } + + + @Operation(summary = "Get feedback status") + @RequestMapping(value = "/getFeedbackStatus", method = RequestMethod.POST, headers = "Authorization") + public String getFeedbackStatusTypes(@RequestBody String request) { + OutputResponse response = new OutputResponse(); + try { + response.setResponse(feedbackService.getFeedbackStatus(request)); + } catch (Exception e) { + response.setError(e); + } + return response.toString(); + } + + + @Operation(summary = "Get email status") + @RequestMapping(value = "/getEmailStatus", method = RequestMethod.POST, headers = "Authorization") + public String getEmailStatus(@RequestBody String request) { + OutputResponse response = new OutputResponse(); + try { + response.setResponse(feedbackService.getEmailStatus(request)); + } catch (Exception e) { + response.setError(e); + } + return response.toString(); + } + + + @Operation(summary = "Get feedback request by id") + @RequestMapping(value = "/getFeedbackRequestById", method = RequestMethod.POST, headers = "Authorization") + public String getFeedbackRequestById(@RequestBody String feedbackrequest) { + OutputResponse response = new OutputResponse(); + logger.info("getAllFeedbackById request " + feedbackrequest); + try { + response.setResponse(feedbackRequestService.getAllFeedback(feedbackrequest)); + } catch (Exception e) { + logger.error("getAllFeedbackById failed with error " + e.getMessage(), e); + response.setError(e); + } + logger.info("getAllFeedbackById response " + response.toString()); + return response.toString(); + } + + + @Operation(summary = "Get feedback response by id") + @RequestMapping(value = "/getFeedbackResponseById", method = RequestMethod.POST, headers = "Authorization") + public String getFeedbackResponseById(@RequestBody String feedbackrequest) { + OutputResponse response = new OutputResponse(); + logger.info("getAllFeedbackById request " + feedbackrequest); + try { + response.setResponse(feedbackRequestService.getAllFeedback(feedbackrequest)); + } catch (Exception e) { + logger.error("getAllFeedbackById failed with error " + e.getMessage(), e); + response.setError(e); + } + logger.info("getAllFeedbackById response " + response.toString()); + return response.toString(); + } + + + @Operation(summary = "Get feedback list") + @RequestMapping(value = "/getFeedbacksList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization") + public String getFeedbacksList(@RequestBody FeedbackListRequestModel feedbackDetails, + HttpServletRequest httpRequest) { + OutputResponse response = new OutputResponse(); + logger.info("getFeedbacksList request " + feedbackDetails); + try { + response.setResponse( + feedbackService.getFeedbacksList(feedbackDetails, httpRequest.getHeader("Authorization"))); + } catch (Exception e) { + logger.error("getFeedbacksList failed with error " + e.getMessage(), e); + response.setError(e); + } + logger.debug("getFeedbacksList response " + response.toString()); + logger.info("getFeedbacksList response code " + response.getStatusCode()); + return response.toString(); + + } + + + @Operation(summary = "Update response") + @PostMapping(value = "/updateResponse", headers = "Authorization") + public String updateResponse(@RequestBody String feedbackresponce) { + OutputResponse response = new OutputResponse(); + logger.info("updateResponse request " + feedbackresponce); + try { + response.setResponse(feedbackService.updateResponse(feedbackresponce)); + } catch (Exception e) { + logger.error("responceFeedback failed with error " + e.getMessage(), e); + response.setError(e); + } + logger.debug("updateResponse response " + response.toString()); + logger.info("updateResponse response " + response.getStatusCode()); + return response.toString(); + } + + + @Operation(summary = "Request feedback") + @RequestMapping(value = "/requestFeedback", method = RequestMethod.POST, headers = "Authorization") + public String requestFeedback(@RequestBody String feedbackRequest) { + OutputResponse response = new OutputResponse(); + logger.info("requestFeedback request " + feedbackRequest); + try { + response.setResponse(feedbackService.createFeedbackRequest(feedbackRequest)); + } catch (Exception e) { + logger.error("requestFeedback failed with error " + e.getMessage(), e); + response.setError(e); + } + logger.debug("requestFeedback response " + response.toString()); + logger.info("requestFeedback response " + response.getStatusCode()); + return response.toString(); + } + + FeedbackSeverityServiceImpl feedbackSeverityService; + + @Autowired + public void setFeedbackSeverityService(FeedbackSeverityServiceImpl feedbackSeverityService) { + this.feedbackSeverityService = feedbackSeverityService; + } + + + @Operation(summary = "Get severity") + @RequestMapping(value = "/getSeverity", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String getFeedbackSeverity( + @Param(value = "{providerServiceMapID : Integer}") @RequestBody String severityRequest) { + + OutputResponse response = new OutputResponse(); + try { + ObjectMapper objectMapper = new ObjectMapper(); + FeedbackSeverity severity = objectMapper.readValue(severityRequest, FeedbackSeverity.class); + response.setResponse( + feedbackSeverityService.getActiveFeedbackSeverity(severity.getProviderServiceMapID()).toString()); + } catch (Exception e) { + logger.error("", e); + response.setError(e); + } + return response.toString(); + } + + + @Operation(summary = "Get feedback type") + @RequestMapping(value = "/getFeedbackType", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String getFeedbackType( + @Param(value = "{providerServiceMapID : Integer}") @RequestBody String severityRequest) { + + OutputResponse response = new OutputResponse(); + try { + ObjectMapper objectMapper = new ObjectMapper(); + FeedbackType feedbackType = objectMapper.readValue(severityRequest, FeedbackType.class); + response.setResponse( + feedbackTypeService.getActiveFeedbackTypes(feedbackType.getProviderServiceMapID()).toString()); + } catch (Exception e) { + logger.error("", e); + response.setError(e); + } + return response.toString(); + } + + + @Operation(summary = "Get grievances by created date") + @RequestMapping(value = "/getGrievancesByCreatedDate", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization") + public String getGrievancesByCreatedDate(@RequestBody FeedbackListRequestModel feedbackDetails, + HttpServletRequest httpRequest) { + OutputResponse response = new OutputResponse(); + logger.info("getGrievancesByCreatedDate request " + feedbackDetails); + try { + response.setResponse(feedbackService.getGrievancesByCreatedDate(feedbackDetails, + httpRequest.getHeader("Authorization"))); + } catch (Exception e) { + logger.error("getGrievancesByCreatedDate failed with error " + e.getMessage(), e); + response.setError(e); + } + return response.toString(); + } + + + @Operation(summary = "Get grievances by updated date") + @RequestMapping(value = "/getGrievancesByUpdatedDate", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization") + public String getGrievancesByUpdatedDate(@RequestBody FeedbackListRequestModel feedbackDetails, + HttpServletRequest httpRequest) { + OutputResponse response = new OutputResponse(); + logger.info("getGrievancesByUpdatedDate request " + feedbackDetails); + try { + response.setResponse(feedbackService.getGrievancesByUpdatedDate(feedbackDetails, + httpRequest.getHeader("Authorization"))); + } catch (Exception e) { + logger.error("getGrievancesByUpdatedDate failed with error " + e.getMessage(), e); + response.setError(e); + } + return response.toString(); + } + + + @Operation(summary = "Save feedback request") + @RequestMapping(value = "/saveFeedbackRequest", method = RequestMethod.POST, headers = "Authorization") + public String createFeedbackRequest(@RequestBody String feedbackRequest) { + OutputResponse response = new OutputResponse(); + logger.info("saveFeedbackRequest request " + feedbackRequest); + try { + response.setResponse(feedbackService.saveFeedbackRequest(feedbackRequest)); + } catch (Exception e) { + logger.error("saveFeedbackRequest failed with error " + e.getMessage(), e); + response.setError(e); + } + return response.toString(); + } + + + @Operation(summary = "Get feedback logs") + @RequestMapping(value = "/getFeedbackLogs", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization") + public String getFeedbackLogs(@RequestBody String request) { + OutputResponse response = new OutputResponse(); + logger.info("getFeedbackLogs request " + request); + try { + FeedbackLog feedbackLogs = inputMapper.gson().fromJson(request, FeedbackLog.class); + response.setResponse(feedbackService.getFeedbackLogs(feedbackLogs)); + } catch (Exception e) { + logger.error("getFeedbackLogs failed with error " + e.getMessage(), e); + response.setError(e); + } + return response.toString(); + } } diff --git a/src/main/java/com/iemr/common/controller/grievance/GrievanceController.java b/src/main/java/com/iemr/common/controller/grievance/GrievanceController.java index bf243f69..aae4e10f 100644 --- a/src/main/java/com/iemr/common/controller/grievance/GrievanceController.java +++ b/src/main/java/com/iemr/common/controller/grievance/GrievanceController.java @@ -1,250 +1,223 @@ package com.iemr.common.controller.grievance; -import java.lang.reflect.Type; -import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; - import javax.ws.rs.core.MediaType; - import org.json.JSONException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonElement; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; import com.iemr.common.data.grievance.UnallocationRequest; import com.iemr.common.dto.grivance.GrievanceWorklistDTO; import com.iemr.common.service.grievance.GrievanceDataSync; import com.iemr.common.service.grievance.GrievanceHandlingService; import com.iemr.common.utils.exception.IEMRException; import com.iemr.common.utils.response.OutputResponse; - import io.lettuce.core.dynamic.annotation.Param; import io.swagger.v3.oas.annotations.Operation; @RestController public class GrievanceController { - final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); - - private GrievanceDataSync grievanceDataSync; - - private final GrievanceHandlingService grievanceHandlingService; - - @Autowired - public GrievanceController(GrievanceHandlingService grievanceHandlingService, GrievanceDataSync grievanceDataSync) { - this.grievanceDataSync = grievanceDataSync; - this.grievanceHandlingService = grievanceHandlingService; - } - - @Operation(summary = "/unallocatedGrievanceCount") - @PostMapping(value = "/unallocatedGrievanceCount", consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String fetchUnallocatedGrievanceCount(@RequestBody UnallocationRequest request) { - OutputResponse responseData = new OutputResponse(); - try { - responseData.setResponse(grievanceDataSync.fetchUnallocatedGrievanceCount(request.getPreferredLanguageName(), request.getFilterStartDate(), request.getFilterEndDate(), request.getProviderServiceMapID())); - } catch (IEMRException e) { - logger.error("Business logic error in UnallocatedGrievanceCount" + e.getMessage(), e); - responseData.setError(e); - } catch (JSONException e) { - logger.error("JSON processing error in UnallocatedGrievanceCount" + e.getMessage(), e); - responseData.setError(e); - } catch (Exception e) { - logger.error("UnallocatedGrievanceCount failed with error" + e.getMessage(), e); - responseData.setError(e); - } - return responseData.toString(); - - } - - @Operation(summary = "Allocate grievances to users") - @PostMapping(value = "/allocateGrievances", consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String allocateGrievances( - @Param(value = "{\"startDate\":\"ISO-8601 format start date (e.g., 2022-12-01T07:49:00.000Z)\", " - + "\"endDate\":\"ISO-8601 format end date (e.g., 2025-01-16T07:49:30.561)\", " - + "\"userID\":\"Array list of User IDs (agents to be allocated grievances)\", " - + "\"allocateNo\":\"Integer - number of grievances to be allocated to each user\"," - + "\"language\":\"String - language to filter grievances by\"}") - - @RequestBody String request) { - OutputResponse response = new OutputResponse(); - try { - // Call the service to allocate grievances based on the incoming JSON request - response.setResponse(grievanceHandlingService.allocateGrievances(request)); - } catch (Exception e) { - logger.error("Grievance allocation failed with error: " + e.getMessage(), e); - response.setError(e); - } - return response.toString(); - } - - @Operation(summary = "Allocated Grievance Records Count") - @PostMapping(value = "/allocatedGrievanceRecordsCount", consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String allocatedGrievanceRecordsCount(@Param(value = "{\"providerServiceMapID\":\"Service ID integer\", " - + "\"userID\":\"Optional - Integer user ID to whom grievances are assigned\"}") @RequestBody String request) { - OutputResponse response = new OutputResponse(); - try { - response.setResponse(grievanceHandlingService.allocatedGrievanceRecordsCount(request)); - } catch (Exception e) { - logger.error("allocatedGrievanceRecordsCount failed with error " + e.getMessage(), e); - response.setError(e); - } - return response.toString(); - } - - @Operation(summary = "Reallocate grievances to other users") - @PostMapping(value = "/reallocateGrievances", consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String reallocateGrievances(@RequestBody String request) { - OutputResponse response = new OutputResponse(); - try { - // Call the service to reallocate grievances based on the incoming JSON request - response.setResponse(grievanceHandlingService.reallocateGrievances(request)); - } catch (Exception e) { - logger.error("Grievance reallocation failed with error: " + e.getMessage(), e); - response.setError(e); - } - return response.toString(); - } - - @Operation(summary = "Move grievances to bin (unassign from agent)") - @PostMapping(value = "/moveToBin", consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String moveToBin(@RequestBody String request) { - - OutputResponse response = new OutputResponse(); - try { - response.setResponse(grievanceHandlingService.moveToBin(request)); - } catch (Exception e) { - logger.error("Move to bin failed with error: " + e.getMessage(), e); - response.setError(e); - } - return response.toString(); - } - - - - @Operation(summary = "get grievance outbound worklist)") - @PostMapping(value = "/getGrievanceOutboundWorklist", consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String getGrievanceOutboundWorklist(@Param(value = "{\"providerServiceMapId\":\" called service ID integer\", " - + "\"userId\":\"Optional - Integer ID of user that is assigned to\"}") @RequestBody String request) throws JsonProcessingException { - logger.info("Request received for grievance worklist"); - List response = new ArrayList<>(); - Map responseMap = new HashMap<>(); - ObjectMapper objectMapper = new ObjectMapper(); - - try { - response = grievanceHandlingService.getFormattedGrievanceData(request); - // Prepare the success response structure - responseMap.put("data", response); - responseMap.put("statusCode", HttpStatus.OK.value()); - responseMap.put("errorMessage", "Success"); - responseMap.put("status", "Success"); - } - - catch (Exception e) { - logger.error("grievanceOutboundWorklist failed with error " + e.getMessage(), e); - List errorResponse = new ArrayList<>(); - GrievanceWorklistDTO errorDTO = new GrievanceWorklistDTO(); - errorDTO.setComplaint("Error fetching grievance data"); - errorDTO.setSubjectOfComplaint(e.getMessage()); - - // Return error response with empty list and error message - errorResponse.add(errorDTO); - - responseMap.put("data", errorResponse); - responseMap.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); - responseMap.put("errorMessage", e.getMessage()); - responseMap.put("status", "Error"); - } - Gson gson = new GsonBuilder() - .registerTypeAdapter(Date.class, new JsonSerializer() { - @Override - public JsonElement serialize(Date date, Type typeOfSrc, JsonSerializationContext context) { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - return context.serialize(sdf.format(date)); // Format date - } - }) - .create(); - - return gson.toJson(responseMap); - } - - - - @Operation(summary = "Save complaint resolution and remarks") - @PostMapping(value = "/saveComplaintResolution", consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String saveComplaintResolution( @Param(value = "{\"complaintID\":\"Complaint ID string\", " + - "\"complaintResolution\":\"Resolution text\", " + - "\"remarks\":\"Optional remarks\", " + - "\"beneficiaryRegID\":\"Beneficiary registration ID\", " + - "\"providerServiceMapID\":\"Provider service map ID\", " + - "\"userID\":\"Assigned user ID\", " + - "\"createdBy\":\"Creator of the complaint\", " + - "\"benCallID\":\"Beneficiary call ID\"}") - @RequestBody String request) { - OutputResponse response = new OutputResponse(); - try { - response.setResponse(grievanceHandlingService.saveComplaintResolution(request)); - } catch (Exception e) { - logger.error("saveComplaintResolution failed with error " + e.getMessage(), e); - response.setError(e); - } - return response.toString(); - } - - - // Controller method to handle reattempt logic - @Operation(summary = "Check reattempt logic for grievance") - @PostMapping(value = "/completeGrievanceCall", consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String completeGrievanceCall( - @Param(value = "{\"complaintID\":\"String - ComplaintID\", " - + "\"userID\":\"Integer - Assigned UserID\", " - + "\"isCompleted\":\"Boolean - completion status of call\", " - + "\"beneficiaryRegId\":\"Long - Beneficiary Registration ID\", " - + "\"callTypeID\":\"Integer - Call Type ID\", " - + "\"benCallID\":\"Long - Beneficiary Call ID\", " - +"\"callID\":\"String - call ID by czentrix\", " - + "\"providerServiceMapID\":\"Integer - providerServiceMapID\", " - + "\"createdBy\":\"String - Creator\"}") - @RequestBody String request) { - - OutputResponse response = new OutputResponse(); - - try { - String s = grievanceDataSync.completeGrievanceCall(request); - response.setResponse(s); - - } catch (Exception e) { - logger.error("complete grievance outbound call failed with error " + e.getMessage(), e); - response.setError(e); - } - return response.toString(); - } - - - @Operation(summary = "Get Grievance Details with Remarks") - @PostMapping(value = "/getCompleteGrievanceDetails", consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String getGrievanceDetailsWithRemarks(@RequestBody String request) { - OutputResponse response = new OutputResponse(); - try { - response.setResponse(grievanceHandlingService.getGrievanceDetailsWithRemarks(request)); - } catch (Exception e) { - logger.error("getGrievanceDetailsWithRemarks failed with error " + e.getMessage(), e); - response.setError(e); - } - return response.toString(); - } + final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + + private GrievanceDataSync grievanceDataSync; + + private final GrievanceHandlingService grievanceHandlingService; + + @Autowired + public GrievanceController(GrievanceHandlingService grievanceHandlingService, GrievanceDataSync grievanceDataSync) { + this.grievanceDataSync = grievanceDataSync; + this.grievanceHandlingService = grievanceHandlingService; + } + + @Operation(summary = "/unallocatedGrievanceCount") + @PostMapping(value = "/unallocatedGrievanceCount", consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String fetchUnallocatedGrievanceCount(@RequestBody UnallocationRequest request) { + OutputResponse responseData = new OutputResponse(); + try { + responseData.setResponse(grievanceDataSync.fetchUnallocatedGrievanceCount(request.getPreferredLanguageName(), request.getFilterStartDate(), request.getFilterEndDate(), request.getProviderServiceMapID())); + } catch (IEMRException e) { + logger.error("Business logic error in UnallocatedGrievanceCount" + e.getMessage(), e); + responseData.setError(e); + } catch (JSONException e) { + logger.error("JSON processing error in UnallocatedGrievanceCount" + e.getMessage(), e); + responseData.setError(e); + } catch (Exception e) { + logger.error("UnallocatedGrievanceCount failed with error" + e.getMessage(), e); + responseData.setError(e); + } + return responseData.toString(); + + } + + @Operation(summary = "Allocate grievances to users") + @PostMapping(value = "/allocateGrievances", consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String allocateGrievances( + @Param(value = "{\"startDate\":\"ISO-8601 format start date (e.g., 2022-12-01T07:49:00.000Z)\", " + + "\"endDate\":\"ISO-8601 format end date (e.g., 2025-01-16T07:49:30.561)\", " + + "\"userID\":\"Array list of User IDs (agents to be allocated grievances)\", " + + "\"allocateNo\":\"Integer - number of grievances to be allocated to each user\"," + + "\"language\":\"String - language to filter grievances by\"}") + + @RequestBody String request) { + OutputResponse response = new OutputResponse(); + try { + // Call the service to allocate grievances based on the incoming JSON request + response.setResponse(grievanceHandlingService.allocateGrievances(request)); + } catch (Exception e) { + logger.error("Grievance allocation failed with error: " + e.getMessage(), e); + response.setError(e); + } + return response.toString(); + } + + @Operation(summary = "Allocated Grievance Records Count") + @PostMapping(value = "/allocatedGrievanceRecordsCount", consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String allocatedGrievanceRecordsCount(@Param(value = "{\"providerServiceMapID\":\"Service ID integer\", " + + "\"userID\":\"Optional - Integer user ID to whom grievances are assigned\"}") @RequestBody String request) { + OutputResponse response = new OutputResponse(); + try { + response.setResponse(grievanceHandlingService.allocatedGrievanceRecordsCount(request)); + } catch (Exception e) { + logger.error("allocatedGrievanceRecordsCount failed with error " + e.getMessage(), e); + response.setError(e); + } + return response.toString(); + } + + @Operation(summary = "Reallocate grievances to other users") + @PostMapping(value = "/reallocateGrievances", consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String reallocateGrievances(@RequestBody String request) { + OutputResponse response = new OutputResponse(); + try { + // Call the service to reallocate grievances based on the incoming JSON request + response.setResponse(grievanceHandlingService.reallocateGrievances(request)); + } catch (Exception e) { + logger.error("Grievance reallocation failed with error: " + e.getMessage(), e); + response.setError(e); + } + return response.toString(); + } + + @Operation(summary = "Move grievances to bin (unassign from agent)") + @PostMapping(value = "/moveToBin", consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String moveToBin(@RequestBody String request) { + + OutputResponse response = new OutputResponse(); + try { + response.setResponse(grievanceHandlingService.moveToBin(request)); + } catch (Exception e) { + logger.error("Move to bin failed with error: " + e.getMessage(), e); + response.setError(e); + } + return response.toString(); + } + + @Operation(summary = "get grievance outbound worklist)") + @PostMapping(value = "/getGrievanceOutboundWorklist", consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public ResponseEntity> getGrievanceOutboundWorklist(@Param(value = "{\"providerServiceMapId\":\" called service ID integer\", " + + "\"userId\":\"Optional - Integer ID of user that is assigned to\"}") @RequestBody String request) { + logger.info("Request received for grievance worklist"); + List response = new ArrayList<>(); + Map responseMap = new HashMap<>(); + + try { + response = grievanceHandlingService.getFormattedGrievanceData(request); + // Prepare the success response structure + responseMap.put("data", response); + responseMap.put("statusCode", HttpStatus.OK.value()); + responseMap.put("errorMessage", "Success"); + responseMap.put("status", "Success"); + } catch (Exception e) { + logger.error("grievanceOutboundWorklist failed with error " + e.getMessage(), e); + List errorResponse = new ArrayList<>(); + GrievanceWorklistDTO errorDTO = new GrievanceWorklistDTO(); + errorDTO.setComplaint("Error fetching grievance data"); + errorDTO.setSubjectOfComplaint(e.getMessage()); + + // Return error response with empty list and error message + errorResponse.add(errorDTO); + + responseMap.put("data", errorResponse); + responseMap.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); + responseMap.put("errorMessage", e.getMessage()); + responseMap.put("status", "Error"); + } + + + return ResponseEntity.ok(responseMap); + } + + + @Operation(summary = "Save complaint resolution and remarks") + @PostMapping(value = "/saveComplaintResolution", consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String saveComplaintResolution(@Param(value = "{\"complaintID\":\"Complaint ID string\", " + + "\"complaintResolution\":\"Resolution text\", " + + "\"remarks\":\"Optional remarks\", " + + "\"beneficiaryRegID\":\"Beneficiary registration ID\", " + + "\"providerServiceMapID\":\"Provider service map ID\", " + + "\"userID\":\"Assigned user ID\", " + + "\"createdBy\":\"Creator of the complaint\", " + + "\"benCallID\":\"Beneficiary call ID\"}") + @RequestBody String request) { + OutputResponse response = new OutputResponse(); + try { + response.setResponse(grievanceHandlingService.saveComplaintResolution(request)); + } catch (Exception e) { + logger.error("saveComplaintResolution failed with error " + e.getMessage(), e); + response.setError(e); + } + return response.toString(); + } + + + // Controller method to handle reattempt logic + @Operation(summary = "Check reattempt logic for grievance") + @PostMapping(value = "/completeGrievanceCall", consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String completeGrievanceCall( + @Param(value = "{\"complaintID\":\"String - ComplaintID\", " + + "\"userID\":\"Integer - Assigned UserID\", " + + "\"isCompleted\":\"Boolean - completion status of call\", " + + "\"beneficiaryRegId\":\"Long - Beneficiary Registration ID\", " + + "\"callTypeID\":\"Integer - Call Type ID\", " + + "\"benCallID\":\"Long - Beneficiary Call ID\", " + + "\"callID\":\"String - call ID by czentrix\", " + + "\"providerServiceMapID\":\"Integer - providerServiceMapID\", " + + "\"createdBy\":\"String - Creator\"}") + @RequestBody String request) { + + OutputResponse response = new OutputResponse(); + + try { + String s = grievanceDataSync.completeGrievanceCall(request); + response.setResponse(s); + + } catch (Exception e) { + logger.error("complete grievance outbound call failed with error " + e.getMessage(), e); + response.setError(e); + } + return response.toString(); + } + + + @Operation(summary = "Get Grievance Details with Remarks") + @PostMapping(value = "/getCompleteGrievanceDetails", consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String getGrievanceDetailsWithRemarks(@RequestBody String request) { + OutputResponse response = new OutputResponse(); + try { + response.setResponse(grievanceHandlingService.getGrievanceDetailsWithRemarks(request)); + } catch (Exception e) { + logger.error("getGrievanceDetailsWithRemarks failed with error " + e.getMessage(), e); + response.setError(e); + } + return response.toString(); + } } diff --git a/src/main/java/com/iemr/common/controller/helpline104history/Helpline104BeneficiaryHistoryController.java b/src/main/java/com/iemr/common/controller/helpline104history/Helpline104BeneficiaryHistoryController.java index bdbcfa12..2156d99a 100644 --- a/src/main/java/com/iemr/common/controller/helpline104history/Helpline104BeneficiaryHistoryController.java +++ b/src/main/java/com/iemr/common/controller/helpline104history/Helpline104BeneficiaryHistoryController.java @@ -1,86 +1,76 @@ /* -* 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/. -*/ + * 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.common.controller.helpline104history; import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; 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.RequestMethod; import org.springframework.web.bind.annotation.RestController; - import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; import com.iemr.common.data.helpline104history.H104BenMedHistory; import com.iemr.common.service.helpline104history.H104BenHistoryServiceImpl; import com.iemr.common.utils.mapper.InputMapper; import com.iemr.common.utils.response.OutputResponse; - import io.lettuce.core.dynamic.annotation.Param; import io.swagger.v3.oas.annotations.Operation; - @RequestMapping(value = "/beneficiary") @RestController public class Helpline104BeneficiaryHistoryController { - InputMapper inputMapper = new InputMapper(); - private Logger logger = LoggerFactory.getLogger(Helpline104BeneficiaryHistoryController.class); - - @Autowired - private H104BenHistoryServiceImpl smpleBenHistoryServiceImpl; - - @CrossOrigin - @Operation(summary= "Retrieve beneficiary case record") - @PostMapping(value = "/get104BenMedHistory", headers = "Authorization", consumes = "application/json", - produces = "application/json") - public String getBenCaseSheet(@Param( - value = "{\"beneficiaryRegID\":\"long\"}") @RequestBody String request) { - OutputResponse output= new OutputResponse(); - try { - ObjectMapper objectMapper = new ObjectMapper(); - H104BenMedHistory smpleBenreq = objectMapper.readValue(request, H104BenMedHistory.class); - logger.info("getBenCaseSheet request " + smpleBenreq.toString()); - - ArrayList smpleBenHistory = smpleBenHistoryServiceImpl.geSmpleBenHistory(smpleBenreq.getBeneficiaryRegID()); - - output.setResponse(smpleBenHistory.toString()); - logger.info("getBenCaseSheet response: " + output); - } catch (Exception e) { - logger.error("getBenCaseSheet failed with error " + e.getMessage(), e); - output.setError(e); - } - return output.toString(); - } + InputMapper inputMapper = new InputMapper(); + private Logger logger = LoggerFactory.getLogger(Helpline104BeneficiaryHistoryController.class); + + @Autowired + private H104BenHistoryServiceImpl smpleBenHistoryServiceImpl; + + + @Operation(summary = "Retrieve beneficiary case record") + @PostMapping(value = "/get104BenMedHistory", headers = "Authorization", consumes = "application/json", + produces = "application/json") + public String getBenCaseSheet(@Param( + value = "{\"beneficiaryRegID\":\"long\"}") @RequestBody String request) { + OutputResponse output = new OutputResponse(); + try { + ObjectMapper objectMapper = new ObjectMapper(); + H104BenMedHistory smpleBenreq = objectMapper.readValue(request, H104BenMedHistory.class); + logger.info("getBenCaseSheet request " + smpleBenreq.toString()); + + ArrayList smpleBenHistory = smpleBenHistoryServiceImpl.geSmpleBenHistory(smpleBenreq.getBeneficiaryRegID()); + + output.setResponse(smpleBenHistory.toString()); + logger.info("getBenCaseSheet response: " + output); + } catch (Exception e) { + logger.error("getBenCaseSheet failed with error " + e.getMessage(), e); + output.setError(e); + } + return output.toString(); + } } diff --git a/src/main/java/com/iemr/common/controller/honeywell/HoneywellController.java b/src/main/java/com/iemr/common/controller/honeywell/HoneywellController.java index 892f4d5b..11bf00d9 100644 --- a/src/main/java/com/iemr/common/controller/honeywell/HoneywellController.java +++ b/src/main/java/com/iemr/common/controller/honeywell/HoneywellController.java @@ -1,95 +1,91 @@ /* -* 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/. -*/ + * 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.common.controller.honeywell; import javax.ws.rs.core.MediaType; - 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.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; - import com.iemr.common.service.honeywell.HoneywellService; import com.iemr.common.utils.mapper.InputMapper; import com.iemr.common.utils.response.OutputResponse; - import io.swagger.v3.oas.annotations.Operation; import jakarta.servlet.http.HttpServletRequest; -@CrossOrigin -@RequestMapping({ "/honeywell" }) + +@RequestMapping({"/honeywell"}) @RestController public class HoneywellController { - private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); - InputMapper inputMapper = new InputMapper(); - @Autowired - private HoneywellService honeywellService; + private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + InputMapper inputMapper = new InputMapper(); + @Autowired + private HoneywellService honeywellService; + + + @Operation(summary = "Get real time district wise call report") + @RequestMapping(value = "/realtimeDistrictDistribution", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String getRealtimeDistrictWiseCallReport() { + OutputResponse response = new OutputResponse(); + try { + response.setResponse(honeywellService.getRealtimeDistrictWiseCallReport()); + } catch (Exception e) { + logger.error("getDistrictWiseCallReport failed with error " + e.getMessage(), e); + response.setError(e); + } + return response.toString(); + } + - @CrossOrigin - @Operation(summary = "Get real time district wise call report") - @RequestMapping(value = "/realtimeDistrictDistribution", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String getRealtimeDistrictWiseCallReport() { - OutputResponse response = new OutputResponse(); - try { - response.setResponse(honeywellService.getRealtimeDistrictWiseCallReport()); - } catch (Exception e) { - logger.error("getDistrictWiseCallReport failed with error " + e.getMessage(), e); - response.setError(e); - } - return response.toString(); - } + @Operation(summary = "District wise call distribution") + @RequestMapping(value = "/districtWiseCallDistribution", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization") + public String getDistrictWiseCallReport(@RequestBody String request, HttpServletRequest httpRequest) { + OutputResponse response = new OutputResponse(); + logger.info("getDistrictWiseCallReport request " + request); + try { + response.setResponse(honeywellService.getDistrictWiseCallReport(request)); + } catch (Exception e) { + logger.error("getDistrictWiseCallReport failed with error " + e.getMessage(), e); + response.setError(e); + } + return response.toString(); + } - @CrossOrigin - @Operation(summary = "District wise call distribution") - @RequestMapping(value = "/districtWiseCallDistribution", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization") - public String getDistrictWiseCallReport(@RequestBody String request, HttpServletRequest httpRequest) { - OutputResponse response = new OutputResponse(); - logger.info("getDistrictWiseCallReport request " + request); - try { - response.setResponse(honeywellService.getDistrictWiseCallReport(request)); - } catch (Exception e) { - logger.error("getDistrictWiseCallReport failed with error " + e.getMessage(), e); - response.setError(e); - } - return response.toString(); - } - @CrossOrigin - @Operation(summary = "Urban and rural calls") - @RequestMapping(value = "/urban_rural_calls", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization") - public String getUrbanRuralCallReport(@RequestBody String request, HttpServletRequest httpRequest) { - OutputResponse response = new OutputResponse(); - logger.info("getUrbanRuralCallReport request " + request); - try { - response.setResponse(honeywellService.getUrbanRuralCallReport(request)); - } catch (Exception e) { - logger.error("getUrbanRuralCallReport failed with error " + e.getMessage(), e); - response.setError(e); - } - return response.toString(); - } + @Operation(summary = "Urban and rural calls") + @RequestMapping(value = "/urban_rural_calls", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization") + public String getUrbanRuralCallReport(@RequestBody String request, HttpServletRequest httpRequest) { + OutputResponse response = new OutputResponse(); + logger.info("getUrbanRuralCallReport request " + request); + try { + response.setResponse(honeywellService.getUrbanRuralCallReport(request)); + } catch (Exception e) { + logger.error("getUrbanRuralCallReport failed with error " + e.getMessage(), e); + response.setError(e); + } + return response.toString(); + } } diff --git a/src/main/java/com/iemr/common/controller/institute/InstituteController.java b/src/main/java/com/iemr/common/controller/institute/InstituteController.java index 39658077..18d71f3d 100644 --- a/src/main/java/com/iemr/common/controller/institute/InstituteController.java +++ b/src/main/java/com/iemr/common/controller/institute/InstituteController.java @@ -1,24 +1,24 @@ /* -* 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/. -*/ + * 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.common.controller.institute; import javax.ws.rs.core.MediaType; @@ -27,161 +27,157 @@ 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.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; - import com.iemr.common.data.institute.Institute; import com.iemr.common.service.institute.DesignationService; import com.iemr.common.service.institute.InstituteService; import com.iemr.common.service.institute.InstituteTypeService; import com.iemr.common.utils.mapper.InputMapper; import com.iemr.common.utils.response.OutputResponse; - import io.lettuce.core.dynamic.annotation.Param; import io.swagger.v3.oas.annotations.Operation; - -@RequestMapping({ "/institute" }) +@RequestMapping({"/institute"}) @RestController public class InstituteController { - private OutputResponse response; - private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); - - private InstituteService instituteService; - - private InputMapper inputMapper = new InputMapper(); - - @Autowired - public void setInstituteService(InstituteService instituteService) { - this.instituteService = instituteService; - } - - private InstituteTypeService instituteTypeService; - - @Autowired - public void setInstituteTypeService(InstituteTypeService instituteTypeService) { - this.instituteTypeService = instituteTypeService; - } - - private DesignationService designationService; - - @Autowired - public void setDesignationService(DesignationService designationService) { - this.designationService = designationService; - } - - @CrossOrigin() - @Operation(summary = "Get institutes by location") - @RequestMapping(value = "/getInstitutesByLocation", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String getInstitutesByLocation(@RequestBody String instituteRequest) { - JSONObject responseObj = new JSONObject(); - OutputResponse response = new OutputResponse(); - logger.info("getInstitutesByLocation request " + instituteRequest); - try { - Institute instituteQuery = inputMapper.gson().fromJson(instituteRequest, Institute.class); - responseObj.put("institute", - instituteService.getInstitutesByStateDistrictBranch(instituteQuery.getStateID(), - instituteQuery.getDistrictID(), instituteQuery.getDistrictBranchMappingID())); - response.setResponse(responseObj.toString()); - } catch (Exception e) { - logger.error("getInstitutesByLocation failed with error " + e.getMessage(), e); - response.setError(e); - } - - return response.toString(); - } - - @CrossOrigin() - @Operation(summary = "Get institute by branch") - @RequestMapping(value = { - "/getInstituteByBranch" }, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String getInstituteByBranch(@RequestBody String instituteRequest) { - JSONObject responseObj = new JSONObject(); - OutputResponse response = new OutputResponse(); - logger.info("getInstituteByBranch request " + instituteRequest); - try { - Institute instituteQuery = inputMapper.gson().fromJson(instituteRequest, Institute.class); - responseObj.put("institute", - instituteService.getInstitutesByBranch(instituteQuery.getDistrictBranchMappingID())); - response.setResponse(responseObj.toString()); - } catch (Exception e) { - response.setError(e); - logger.error("getInstituteByBranch failed with error " + e.getMessage(), e); - } - - return responseObj.toString(); - } - - @CrossOrigin() - @Operation(summary = "Get institute type") - @RequestMapping(value = "/getInstituteTypes", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String getInstituteTypes( - @Param(value = "{\"providerServiceMapID\": \"Optional Integer\"}") @RequestBody String instituteTypeRequest) { - OutputResponse response = new OutputResponse(); - try { - logger.info("getInstituteTypes request " + instituteTypeRequest); - - response.setResponse(instituteTypeService.getInstitutionTypes(instituteTypeRequest).toString()); - } catch (Exception e) { - logger.error("getInstituteTypes failed with error " + e.getMessage(), e); - } - logger.info("getInstituteTypes response " + response.toString()); - return response.toString(); - } - - @CrossOrigin() - @Operation(summary = "Get institute name") - @RequestMapping(value = "/getInstituteName/{institutionTypeID}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String getInstituteName(@PathVariable("institutionTypeID") Integer institutionTypeID) { - OutputResponse response = new OutputResponse(); - try { - logger.info("getInstituteTypes request " + institutionTypeID); - - response.setResponse(instituteTypeService.getInstitutionName(institutionTypeID).toString()); - } catch (Exception e) { - logger.error("getInstituteTypes failed with error " + e.getMessage(), e); - } - logger.info("getInstituteTypes response " + response.toString()); - return response.toString(); - } - - @CrossOrigin() - @Operation(summary = "Get designation") - @RequestMapping(value = { - "/getDesignations" }, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String getDesignations() { - - OutputResponse response = new OutputResponse(); - try { - response.setResponse(designationService.getDesignations().toString()); - } catch (Exception e) { - logger.error("getDesignations failed with error " + e.getMessage(), e); - response.setError(e); - } - return response.toString(); - - } - - @CrossOrigin() - @Operation(summary = "Get institute name by type and district") - @RequestMapping(value = "/getInstituteNameByTypeAndDistrict/{institutionTypeID}/{districtID}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String getInstituteNameByTypeAndDistrict(@PathVariable("institutionTypeID") Integer institutionTypeID, - @PathVariable("districtID") Integer districtID) { - OutputResponse response = new OutputResponse(); - try { - logger.info("getInstituteTypes request " + institutionTypeID + "," + districtID); - - response.setResponse( - instituteTypeService.getInstitutionNameByTypeAndDistrict(institutionTypeID, districtID).toString()); - } catch (Exception e) { - logger.error("getInstituteTypes failed with error " + e.getMessage(), e); - } - logger.info("getInstituteTypes response " + response.toString()); - return response.toString(); - } + private OutputResponse response; + private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + + private InstituteService instituteService; + + private InputMapper inputMapper = new InputMapper(); + + @Autowired + public void setInstituteService(InstituteService instituteService) { + this.instituteService = instituteService; + } + + private InstituteTypeService instituteTypeService; + + @Autowired + public void setInstituteTypeService(InstituteTypeService instituteTypeService) { + this.instituteTypeService = instituteTypeService; + } + + private DesignationService designationService; + + @Autowired + public void setDesignationService(DesignationService designationService) { + this.designationService = designationService; + } + + + @Operation(summary = "Get institutes by location") + @RequestMapping(value = "/getInstitutesByLocation", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String getInstitutesByLocation(@RequestBody String instituteRequest) { + JSONObject responseObj = new JSONObject(); + OutputResponse response = new OutputResponse(); + logger.info("getInstitutesByLocation request " + instituteRequest); + try { + Institute instituteQuery = inputMapper.gson().fromJson(instituteRequest, Institute.class); + responseObj.put("institute", + instituteService.getInstitutesByStateDistrictBranch(instituteQuery.getStateID(), + instituteQuery.getDistrictID(), instituteQuery.getDistrictBranchMappingID())); + response.setResponse(responseObj.toString()); + } catch (Exception e) { + logger.error("getInstitutesByLocation failed with error " + e.getMessage(), e); + response.setError(e); + } + + return response.toString(); + } + + + @Operation(summary = "Get institute by branch") + @RequestMapping(value = { + "/getInstituteByBranch"}, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String getInstituteByBranch(@RequestBody String instituteRequest) { + JSONObject responseObj = new JSONObject(); + OutputResponse response = new OutputResponse(); + logger.info("getInstituteByBranch request " + instituteRequest); + try { + Institute instituteQuery = inputMapper.gson().fromJson(instituteRequest, Institute.class); + responseObj.put("institute", + instituteService.getInstitutesByBranch(instituteQuery.getDistrictBranchMappingID())); + response.setResponse(responseObj.toString()); + } catch (Exception e) { + response.setError(e); + logger.error("getInstituteByBranch failed with error " + e.getMessage(), e); + } + + return responseObj.toString(); + } + + + @Operation(summary = "Get institute type") + @RequestMapping(value = "/getInstituteTypes", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String getInstituteTypes( + @Param(value = "{\"providerServiceMapID\": \"Optional Integer\"}") @RequestBody String instituteTypeRequest) { + OutputResponse response = new OutputResponse(); + try { + logger.info("getInstituteTypes request " + instituteTypeRequest); + + response.setResponse(instituteTypeService.getInstitutionTypes(instituteTypeRequest).toString()); + } catch (Exception e) { + logger.error("getInstituteTypes failed with error " + e.getMessage(), e); + } + logger.info("getInstituteTypes response " + response.toString()); + return response.toString(); + } + + + @Operation(summary = "Get institute name") + @RequestMapping(value = "/getInstituteName/{institutionTypeID}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String getInstituteName(@PathVariable("institutionTypeID") Integer institutionTypeID) { + OutputResponse response = new OutputResponse(); + try { + logger.info("getInstituteTypes request " + institutionTypeID); + + response.setResponse(instituteTypeService.getInstitutionName(institutionTypeID).toString()); + } catch (Exception e) { + logger.error("getInstituteTypes failed with error " + e.getMessage(), e); + } + logger.info("getInstituteTypes response " + response.toString()); + return response.toString(); + } + + + @Operation(summary = "Get designation") + @RequestMapping(value = { + "/getDesignations"}, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String getDesignations() { + + OutputResponse response = new OutputResponse(); + try { + response.setResponse(designationService.getDesignations().toString()); + } catch (Exception e) { + logger.error("getDesignations failed with error " + e.getMessage(), e); + response.setError(e); + } + return response.toString(); + + } + + + @Operation(summary = "Get institute name by type and district") + @RequestMapping(value = "/getInstituteNameByTypeAndDistrict/{institutionTypeID}/{districtID}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String getInstituteNameByTypeAndDistrict(@PathVariable("institutionTypeID") Integer institutionTypeID, + @PathVariable("districtID") Integer districtID) { + OutputResponse response = new OutputResponse(); + try { + logger.info("getInstituteTypes request " + institutionTypeID + "," + districtID); + + response.setResponse( + instituteTypeService.getInstitutionNameByTypeAndDistrict(institutionTypeID, districtID).toString()); + } catch (Exception e) { + logger.error("getInstituteTypes failed with error " + e.getMessage(), e); + } + logger.info("getInstituteTypes response " + response.toString()); + return response.toString(); + } } diff --git a/src/main/java/com/iemr/common/controller/kmfilemanager/KMFileManagerController.java b/src/main/java/com/iemr/common/controller/kmfilemanager/KMFileManagerController.java index cc142706..476749dc 100644 --- a/src/main/java/com/iemr/common/controller/kmfilemanager/KMFileManagerController.java +++ b/src/main/java/com/iemr/common/controller/kmfilemanager/KMFileManagerController.java @@ -1,147 +1,137 @@ /* -* 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/. -*/ + * 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.common.controller.kmfilemanager; import java.util.Arrays; import java.util.List; - import javax.ws.rs.core.MediaType; 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.RequestMethod; import org.springframework.web.bind.annotation.RestController; - import com.iemr.common.data.kmfilemanager.KMFileManager; import com.iemr.common.mapper.utils.InputMapper; - import com.iemr.common.service.kmfilemanager.KMFileManagerService; import com.iemr.common.service.scheme.SchemeServiceImpl; import com.iemr.common.service.services.CommonServiceImpl; import com.iemr.common.utils.response.OutputResponse; - import io.lettuce.core.dynamic.annotation.Param; import io.swagger.v3.oas.annotations.Operation; - import com.fasterxml.jackson.databind.ObjectMapper; import com.iemr.common.data.common.DocFileManager; -@RequestMapping({ "/kmfilemanager" }) +@RequestMapping({"/kmfilemanager"}) @RestController public class KMFileManagerController { - private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); - private KMFileManagerService kmFileManagerService; - - @Autowired - private CommonServiceImpl commonServiceImpl; - @Autowired - private ObjectMapper objectMapper; - - @Autowired - public void setKmFileManagerService(KMFileManagerService kmFileManagerService) { - this.kmFileManagerService = kmFileManagerService; - } - - @Autowired - private SchemeServiceImpl schemeServiceImpl; - - - - public KMFileManagerController(CommonServiceImpl commonServiceImpl) { - this.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.getInstance().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 : {0}" , e); - response.setError(5000, "Error while saving files : " + e); - } - - return response.toString(); - } - - - - @CrossOrigin - @Operation(summary = "Add file") - @RequestMapping(value = "/addFile", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization") - public String addFile( - @Param(value = "{\"fileName\":\"String: name of file\", \"fileExtension:\"String: file extension\", " - + "\"providerServiceMapID\":\"Integer: service provider map ID\", " - + "userID:\"Integer: user ID of the supervisor\", " - + "\"validFrom\":\"Epoch date time: Document validity start time\", " - + "\"validUpto\":\"Epoch date time: Document validity end time\", " - + "\"fileContent\":\"String: base64encoded binary file content\", " - + "\"createdBy\":\"String: username of supervisor\", " - + "\"categoryID\":\"Optional: Integer: category ID selected\", " - + "\"subCategoryID\":\"Optional: Integer: sub-category ID selected\"}") @RequestBody String addFileRequest) { - OutputResponse response = new OutputResponse(); - logger.info("add file request is " + addFileRequest); - try { - response.setResponse(kmFileManagerService.addKMFile(addFileRequest)); - } catch (Exception e) { - logger.error("add file failed with exception: " + e.getMessage(), e); - response.setError(e); - } - logger.debug("add file response is " + response.toString()); - logger.info("add file response sent with status code " + response.getStatusCode()); - return response.toString(); - } - - @CrossOrigin - @Operation(summary = "Get KM file download URL") - @RequestMapping(value = "/getKMFileDownloadURL", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization") - public String getKMFileDownloadURL(@Param(value = "{}") @RequestBody String request) { - OutputResponse response = new OutputResponse(); - logger.info("add file request is " + request); - try { - KMFileManager kmFileManager = objectMapper.readValue(request, KMFileManager.class); - String s = schemeServiceImpl.getFilePath(kmFileManager); - if (s != null) - response.setResponse(s); - } catch (Exception e) { - logger.error("Error while getting file download url : " + e); - response.setError(5000, "Error while getting file download url : " + e); - } - return response.toString(); - } + private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + private KMFileManagerService kmFileManagerService; + + @Autowired + private CommonServiceImpl commonServiceImpl; + @Autowired + private ObjectMapper objectMapper; + + @Autowired + public void setKmFileManagerService(KMFileManagerService kmFileManagerService) { + this.kmFileManagerService = kmFileManagerService; + } + + @Autowired + private SchemeServiceImpl schemeServiceImpl; + + + public KMFileManagerController(CommonServiceImpl commonServiceImpl) { + this.commonServiceImpl = commonServiceImpl; + + } + + + @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.getInstance().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 : {0}", e); + response.setError(5000, "Error while saving files : " + e); + } + + return response.toString(); + } + + + @Operation(summary = "Add file") + @RequestMapping(value = "/addFile", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization") + public String addFile( + @Param(value = "{\"fileName\":\"String: name of file\", \"fileExtension:\"String: file extension\", " + + "\"providerServiceMapID\":\"Integer: service provider map ID\", " + + "userID:\"Integer: user ID of the supervisor\", " + + "\"validFrom\":\"Epoch date time: Document validity start time\", " + + "\"validUpto\":\"Epoch date time: Document validity end time\", " + + "\"fileContent\":\"String: base64encoded binary file content\", " + + "\"createdBy\":\"String: username of supervisor\", " + + "\"categoryID\":\"Optional: Integer: category ID selected\", " + + "\"subCategoryID\":\"Optional: Integer: sub-category ID selected\"}") @RequestBody String addFileRequest) { + OutputResponse response = new OutputResponse(); + logger.info("add file request is " + addFileRequest); + try { + response.setResponse(kmFileManagerService.addKMFile(addFileRequest)); + } catch (Exception e) { + logger.error("add file failed with exception: " + e.getMessage(), e); + response.setError(e); + } + logger.debug("add file response is " + response.toString()); + logger.info("add file response sent with status code " + response.getStatusCode()); + return response.toString(); + } + + + @Operation(summary = "Get KM file download URL") + @RequestMapping(value = "/getKMFileDownloadURL", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization") + public String getKMFileDownloadURL(@Param(value = "{}") @RequestBody String request) { + OutputResponse response = new OutputResponse(); + logger.info("add file request is " + request); + try { + KMFileManager kmFileManager = objectMapper.readValue(request, KMFileManager.class); + String s = schemeServiceImpl.getFilePath(kmFileManager); + if (s != null) + response.setResponse(s); + } catch (Exception e) { + logger.error("Error while getting file download url : " + e); + response.setError(5000, "Error while getting file download url : " + e); + } + return response.toString(); + } } diff --git a/src/main/java/com/iemr/common/controller/language/LanguageController.java b/src/main/java/com/iemr/common/controller/language/LanguageController.java index 77204df1..804417e3 100644 --- a/src/main/java/com/iemr/common/controller/language/LanguageController.java +++ b/src/main/java/com/iemr/common/controller/language/LanguageController.java @@ -30,10 +30,8 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; - import com.iemr.common.service.userbeneficiarydata.LanguageService; import com.iemr.common.utils.response.OutputResponse; - import io.swagger.v3.oas.annotations.Operation; diff --git a/src/main/java/com/iemr/common/controller/location/LocationController.java b/src/main/java/com/iemr/common/controller/location/LocationController.java index f5e04dad..76e1404c 100644 --- a/src/main/java/com/iemr/common/controller/location/LocationController.java +++ b/src/main/java/com/iemr/common/controller/location/LocationController.java @@ -28,12 +28,10 @@ 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.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; - import com.iemr.common.data.location.Country; import com.iemr.common.data.location.DistrictBlock; import com.iemr.common.data.location.DistrictBranchMapping; @@ -41,7 +39,6 @@ import com.iemr.common.data.location.States; import com.iemr.common.service.location.LocationService; import com.iemr.common.utils.response.OutputResponse; - import io.swagger.v3.oas.annotations.Operation; @@ -51,7 +48,7 @@ public class LocationController { private LocationService locationService; private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); - @CrossOrigin + @Operation(summary = "Get states") @RequestMapping(value = "/states/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getStates(@PathVariable("id") Integer id) { @@ -67,7 +64,7 @@ public String getStates(@PathVariable("id") Integer id) { return response.toString(); } - @CrossOrigin + @Operation(summary = "Get districts") @RequestMapping(value = "/districts/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getDistricts(@PathVariable("id") int id) { @@ -83,7 +80,7 @@ public String getDistricts(@PathVariable("id") int id) { return response.toString(); } - @CrossOrigin + @Operation(summary = "Fetch state and district by id") @RequestMapping(value = "/statesDistricts/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getStatetDistricts(@PathVariable("id") int id) { @@ -100,7 +97,7 @@ public String getStatetDistricts(@PathVariable("id") int id) { return response.toString(); } - @CrossOrigin + @Operation(summary = "Get district blocks") @RequestMapping(value = "/taluks/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getDistrictBlocks(@PathVariable("id") int id) { @@ -116,7 +113,7 @@ public String getDistrictBlocks(@PathVariable("id") int id) { return response.toString(); } - @CrossOrigin + @Operation(summary = "Get city") @RequestMapping(value = "/city/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getCity(@PathVariable("id") int id) { @@ -133,7 +130,7 @@ public String getCity(@PathVariable("id") int id) { return response.toString(); } - @CrossOrigin + @Operation(summary = "Get villages") @RequestMapping(value = "/village/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getVillages(@PathVariable("id") int id) { @@ -154,7 +151,7 @@ public void setLocationService(LocationService locationService) { this.locationService = locationService; } - @CrossOrigin + @Operation(summary = "Get countries") @RequestMapping(value = "/getCountries", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getCountries() { diff --git a/src/main/java/com/iemr/common/controller/lonic/LonicController.java b/src/main/java/com/iemr/common/controller/lonic/LonicController.java index 07a4d86e..fd15d7d4 100644 --- a/src/main/java/com/iemr/common/controller/lonic/LonicController.java +++ b/src/main/java/com/iemr/common/controller/lonic/LonicController.java @@ -1,83 +1,77 @@ /* -* 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/. -*/ + * 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.common.controller.lonic; 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.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; - import com.iemr.common.data.lonic.LonicDescription; import com.iemr.common.service.lonic.LonicService; import com.iemr.common.utils.mapper.InputMapper; import com.iemr.common.utils.response.OutputResponse; - import io.lettuce.core.dynamic.annotation.Param; import io.swagger.v3.oas.annotations.Operation; - @RequestMapping(value = "/lonic") @RestController - public class LonicController { - private Logger logger = LoggerFactory.getLogger(LonicController.class); + private Logger logger = LoggerFactory.getLogger(LonicController.class); - private LonicService lonicService; + private LonicService lonicService; - @Autowired - public void setLonicService(LonicService lonicService) { - this.lonicService = lonicService; - } + @Autowired + public void setLonicService(LonicService lonicService) { + this.lonicService = lonicService; + } - @CrossOrigin - @Operation(summary = "Get lonic record list") - @RequestMapping(value = "/getlonicRecordList", method = RequestMethod.POST, headers = "Authorization", consumes = "application/json", produces = "application/json") - public String getLonicRecordList( - @Param("{\"term\":\"String\",\"pageNo\":\"Integer\"}") @RequestBody String request) { - OutputResponse output = new OutputResponse(); - try { + @Operation(summary = "Get lonic record list") + @RequestMapping(value = "/getlonicRecordList", method = RequestMethod.POST, headers = "Authorization", consumes = "application/json", produces = "application/json") + public String getLonicRecordList( + @Param("{\"term\":\"String\",\"pageNo\":\"Integer\"}") @RequestBody String request) { + OutputResponse output = new OutputResponse(); + try { - LonicDescription lonicDescription = InputMapper.gson().fromJson(request, LonicDescription.class); + LonicDescription lonicDescription = InputMapper.gson().fromJson(request, LonicDescription.class); - logger.info("getLonicRecord request " + lonicDescription.toString()); + logger.info("getLonicRecord request " + lonicDescription.toString()); - String lonicList = lonicService.findLonicRecordList(lonicDescription); + String lonicList = lonicService.findLonicRecordList(lonicDescription); - if (lonicList != null) - output.setResponse(lonicList); - else - output.setResponse("No Records Found"); + if (lonicList != null) + output.setResponse(lonicList); + else + output.setResponse("No Records Found"); - logger.info("getLonicRecord response: " + output); - } catch (Exception e) { - logger.error("getLonicRecord failed with error " + e.getMessage(), e); - output.setError(e); - } - return output.toString(); - } + logger.info("getLonicRecord response: " + output); + } catch (Exception e) { + logger.error("getLonicRecord failed with error " + e.getMessage(), e); + output.setError(e); + } + return output.toString(); + } } diff --git a/src/main/java/com/iemr/common/controller/lungassessment/LungAssessmentController.java b/src/main/java/com/iemr/common/controller/lungassessment/LungAssessmentController.java index 6e5e0397..197119cd 100644 --- a/src/main/java/com/iemr/common/controller/lungassessment/LungAssessmentController.java +++ b/src/main/java/com/iemr/common/controller/lungassessment/LungAssessmentController.java @@ -24,17 +24,14 @@ 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.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; - import com.iemr.common.service.lungassessment.LungAssessmentService; import com.iemr.common.utils.response.OutputResponse; - import io.swagger.v3.oas.annotations.Operation; @@ -47,7 +44,7 @@ public class LungAssessmentController { private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); - @CrossOrigin() + @Operation(summary = "Start assesment") @RequestMapping(value = "/startAssesment", method = RequestMethod.POST, headers = "Authorization") public String startAssesment(@RequestParam("file") MultipartFile file, @RequestParam("request") String request) { @@ -65,7 +62,7 @@ public String startAssesment(@RequestParam("file") MultipartFile file, @RequestP return output.toString(); } - @CrossOrigin() + @Operation(summary = "Get assesment") @RequestMapping(value = "/getAssesment/{assessmentId}", method = RequestMethod.GET, headers = "Authorization") public String getAssessment(@PathVariable("assessmentId") String assessmentId) { @@ -83,7 +80,7 @@ public String getAssessment(@PathVariable("assessmentId") String assessmentId) { return output.toString(); } - @CrossOrigin() + @Operation(summary = "Get assesment details") @RequestMapping(value = "/getAssesmentDetails/{patientId}", method = RequestMethod.GET, headers = "Authorization") public String getAssessmentDetails(@PathVariable("patientId") Long patientId) { diff --git a/src/main/java/com/iemr/common/controller/mctshistory/OutboundHistoryController.java b/src/main/java/com/iemr/common/controller/mctshistory/OutboundHistoryController.java index 6edb5077..2446eafd 100644 --- a/src/main/java/com/iemr/common/controller/mctshistory/OutboundHistoryController.java +++ b/src/main/java/com/iemr/common/controller/mctshistory/OutboundHistoryController.java @@ -22,15 +22,12 @@ package com.iemr.common.controller.mctshistory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; - import com.iemr.common.service.mctshistory.OutboundHistoryService; import com.iemr.common.utils.response.OutputResponse; - import io.lettuce.core.dynamic.annotation.Param; import io.swagger.v3.oas.annotations.Operation; @@ -47,7 +44,7 @@ public void setOutboundHistoryService(OutboundHistoryService outboundHistoryServ this.outboundHistoryService = outboundHistoryService; } - @CrossOrigin() + @Operation(summary = "Get MCTS call history") @RequestMapping(value = "/getMctsCallHistory", method = RequestMethod.POST, headers = "Authorization") public String getCallHistory(@Param("{\"beneficiaryRegID\":\"Long\"}") @RequestBody String request) { @@ -63,7 +60,7 @@ public String getCallHistory(@Param("{\"beneficiaryRegID\":\"Long\"}") @RequestB return response.toStringWithSerialization(); } - @CrossOrigin() + @Operation(summary = "Get MCTS call response") @RequestMapping(value = "/getMctsCallResponse", method = RequestMethod.POST, headers = "Authorization") public String getMctsCallResponse(@Param("{\"callDetailID\":\"Long\"}") @RequestBody String request) { diff --git a/src/main/java/com/iemr/common/controller/nhmdashboard/NHMDetailCallReportScheduler.java b/src/main/java/com/iemr/common/controller/nhmdashboard/NHMDetailCallReportScheduler.java index 5fd3e281..c028b5ac 100644 --- a/src/main/java/com/iemr/common/controller/nhmdashboard/NHMDetailCallReportScheduler.java +++ b/src/main/java/com/iemr/common/controller/nhmdashboard/NHMDetailCallReportScheduler.java @@ -1,13 +1,10 @@ package com.iemr.common.controller.nhmdashboard; -import java.sql.Date; import java.sql.Timestamp; import java.time.LocalDateTime; import java.util.HashSet; import java.util.List; -import java.util.Objects; import java.util.Set; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -15,13 +12,11 @@ import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; - import com.iemr.common.data.callhandling.BeneficiaryCall; import com.iemr.common.data.nhm_dashboard.DetailedCallReport; import com.iemr.common.repository.callhandling.IEMRCalltypeRepositoryImplCustom; import com.iemr.common.repository.nhm_dashboard.DetailedCallReportRepo; import com.iemr.common.repository.report.CallReportRepo; -import com.iemr.common.utils.config.ConfigProperties; @EnableScheduling @Configuration diff --git a/src/main/java/com/iemr/common/controller/nhmdashboard/NationalHealthMissionDashboardController.java b/src/main/java/com/iemr/common/controller/nhmdashboard/NationalHealthMissionDashboardController.java index 6c4e4919..40572aa8 100644 --- a/src/main/java/com/iemr/common/controller/nhmdashboard/NationalHealthMissionDashboardController.java +++ b/src/main/java/com/iemr/common/controller/nhmdashboard/NationalHealthMissionDashboardController.java @@ -21,24 +21,16 @@ */ package com.iemr.common.controller.nhmdashboard; -import java.util.Arrays; - 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.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; - import com.iemr.common.data.nhm_dashboard.AbandonCallSummary; -import com.iemr.common.data.nhm_dashboard.AgentSummaryReport; -import com.iemr.common.data.nhm_dashboard.DetailedCallReport; import com.iemr.common.service.nhm_dashboard.NHM_DashboardService; -import com.iemr.common.utils.mapper.InputMapper; import com.iemr.common.utils.response.OutputResponse; - import io.swagger.v3.oas.annotations.Operation; @@ -50,7 +42,7 @@ public class NationalHealthMissionDashboardController { @Autowired private NHM_DashboardService nHM_DashboardService; - @CrossOrigin() + @Operation(summary = "Push abandoned calls from call centre") @RequestMapping(value = "/push/abandon_calls", method = RequestMethod.POST, headers = "Authorization") public String pushAbandonCallsFromC_Zentrix(@RequestBody AbandonCallSummary abandonCallSummary) { @@ -67,7 +59,6 @@ public String pushAbandonCallsFromC_Zentrix(@RequestBody AbandonCallSummary aban } @Operation(summary = "Get abandoned call information") - @CrossOrigin() @RequestMapping(value = "/get/abandon_calls", method = RequestMethod.GET, headers = "Authorization") public String getAbandonCalls() { OutputResponse output = new OutputResponse(); @@ -83,7 +74,6 @@ public String getAbandonCalls() { } @Operation(summary = "Get agent wise staff & idle time") - @CrossOrigin() @RequestMapping(value = "/get/agentsummaryreport", method = RequestMethod.GET, headers = "Authorization") public String getAgentSummaryReport() { OutputResponse output = new OutputResponse(); @@ -99,7 +89,6 @@ public String getAgentSummaryReport() { } @Operation(summary = "Get detailed call report") - @CrossOrigin() @RequestMapping(value = "/get/detailedCallReport", method = RequestMethod.GET, headers = "Authorization") public String getDetailedCallReport() { OutputResponse output = new OutputResponse(); diff --git a/src/main/java/com/iemr/common/controller/notification/NotificationController.java b/src/main/java/com/iemr/common/controller/notification/NotificationController.java index 430eb7f4..a98fc1cb 100644 --- a/src/main/java/com/iemr/common/controller/notification/NotificationController.java +++ b/src/main/java/com/iemr/common/controller/notification/NotificationController.java @@ -22,19 +22,15 @@ package com.iemr.common.controller.notification; import javax.ws.rs.core.MediaType; - 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.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; - import com.iemr.common.service.notification.NotificationService; import com.iemr.common.utils.response.OutputResponse; - import io.lettuce.core.dynamic.annotation.Param; import io.swagger.v3.oas.annotations.Operation; @@ -52,7 +48,7 @@ public void setNotificationService(NotificationService notificationService) { this.notificationService = notificationService; } - @CrossOrigin() + @Operation(summary = "Get notification") @RequestMapping(value = "/getNotification", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization") public String getNotification(@Param(value = "{\"providerServiceMapID\": \"integer-provider service map id\", " @@ -72,7 +68,7 @@ public String getNotification(@Param(value = "{\"providerServiceMapID\": \"integ return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get supervisor notification") @RequestMapping(value = "/getSupervisorNotification", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization") public String getSupervisorNotification( @@ -92,7 +88,7 @@ public String getSupervisorNotification( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Create notification") @RequestMapping(value = "/createNotification", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization") public String createNotification( @@ -120,7 +116,7 @@ public String createNotification( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Update notification") @RequestMapping(value = "/updateNotification", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization") public String updateNotification( @@ -146,7 +142,7 @@ public String updateNotification( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get notification type") @RequestMapping(value = "/getNotificationType", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization") public String getNotificationType( @@ -163,7 +159,7 @@ public String getNotificationType( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Create notification type") @RequestMapping(value = "/createNotificationType", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization") public String createNotificationType( @@ -182,7 +178,7 @@ public String createNotificationType( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Update notification type") @RequestMapping(value = "/updateNotificationType", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization") public String updateNotificationType( @@ -201,7 +197,7 @@ public String updateNotificationType( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get emergency contacts") @RequestMapping(value = "/getEmergencyContacts", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization") public String getEmergencyContacts( @@ -219,7 +215,7 @@ public String getEmergencyContacts( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get supervisor emergency contacts") @RequestMapping(value = "/getSupervisorEmergencyContacts", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization") public String getSupervisorEmergencyContacts( @@ -236,7 +232,7 @@ public String getSupervisorEmergencyContacts( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Create emergency contact") @RequestMapping(value = "/createEmergencyContacts", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization") public String createEmergencyContacts( @@ -258,7 +254,7 @@ public String createEmergencyContacts( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Update emergency contacts") @RequestMapping(value = "/updateEmergencyContacts", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON, headers = "Authorization") public String updateEmergencyContacts( diff --git a/src/main/java/com/iemr/common/controller/otp/OTPGateway.java b/src/main/java/com/iemr/common/controller/otp/OTPGateway.java index 42371a88..452e01ff 100644 --- a/src/main/java/com/iemr/common/controller/otp/OTPGateway.java +++ b/src/main/java/com/iemr/common/controller/otp/OTPGateway.java @@ -22,22 +22,18 @@ package com.iemr.common.controller.otp; import javax.ws.rs.core.MediaType; - import org.json.JSONObject; 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.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; - import com.iemr.common.data.otp.OTPRequestParsor; import com.iemr.common.service.otp.OTPHandler; import com.iemr.common.utils.mapper.InputMapper; import com.iemr.common.utils.response.OutputResponse; - import io.lettuce.core.dynamic.annotation.Param; import io.swagger.v3.oas.annotations.Operation; @@ -51,7 +47,7 @@ public class OTPGateway { @Autowired private OTPHandler otpHandler; - @CrossOrigin() + @Operation(summary = "Send OTP") @RequestMapping(value = "/sendOTP", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String sendOTP(@Param(value = "{\"mobNo\":\"String\"}") @RequestBody String requestOBJ) { @@ -74,7 +70,7 @@ public String sendOTP(@Param(value = "{\"mobNo\":\"String\"}") @RequestBody Stri return response.toString(); } - @CrossOrigin() + @Operation(summary = "Validate OTP") @RequestMapping(value = "/validateOTP", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String validateOTP( @@ -98,7 +94,7 @@ public String validateOTP( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Resend OTP") @RequestMapping(value = "/resendOTP", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String resendOTP(@Param(value = "{\"mobNo\":\"String\"}") @RequestBody String requestOBJ) { diff --git a/src/main/java/com/iemr/common/controller/questionconfig/QuestionTypeController.java b/src/main/java/com/iemr/common/controller/questionconfig/QuestionTypeController.java index f9251cc0..7944df1a 100644 --- a/src/main/java/com/iemr/common/controller/questionconfig/QuestionTypeController.java +++ b/src/main/java/com/iemr/common/controller/questionconfig/QuestionTypeController.java @@ -22,7 +22,6 @@ package com.iemr.common.controller.questionconfig; import javax.ws.rs.core.MediaType; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -31,10 +30,8 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; - import com.iemr.common.service.questionconfig.QuestionTypeService; import com.iemr.common.utils.response.OutputResponse; - import io.lettuce.core.dynamic.annotation.Param; import io.swagger.v3.oas.annotations.Operation; diff --git a/src/main/java/com/iemr/common/controller/questionconfig/QuestionnaireController.java b/src/main/java/com/iemr/common/controller/questionconfig/QuestionnaireController.java index f984f468..028d399e 100644 --- a/src/main/java/com/iemr/common/controller/questionconfig/QuestionnaireController.java +++ b/src/main/java/com/iemr/common/controller/questionconfig/QuestionnaireController.java @@ -25,15 +25,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; - import com.iemr.common.service.questionconfig.QuestionnaireService; import com.iemr.common.utils.response.OutputResponse; - import io.swagger.v3.oas.annotations.Operation; @@ -56,7 +53,7 @@ public void setQuestionnaireService(QuestionnaireService questionnaireService) { this.questionnaireService = questionnaireService; } - @CrossOrigin() + @Operation(summary = "Create questionnaire") @RequestMapping(value = "/put/questionnaire", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String createQuestionnaire(@RequestBody String request) { @@ -71,7 +68,7 @@ public String createQuestionnaire(@RequestBody String request) { return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get questionnaire list") @RequestMapping(value = "/get/questionnaireList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String questionTypeList() { diff --git a/src/main/java/com/iemr/common/controller/report/CustomerRelationshipReports.java b/src/main/java/com/iemr/common/controller/report/CustomerRelationshipReports.java index 094f2ac2..c4726457 100644 --- a/src/main/java/com/iemr/common/controller/report/CustomerRelationshipReports.java +++ b/src/main/java/com/iemr/common/controller/report/CustomerRelationshipReports.java @@ -22,16 +22,13 @@ package com.iemr.common.controller.report; import javax.ws.rs.core.MediaType; - 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.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; - import com.iemr.common.mapper.Report1097Mapper; import com.iemr.common.service.reports.CallReportsService; import com.iemr.common.utils.mapper.InputMapper; @@ -40,7 +37,6 @@ import io.swagger.v3.oas.annotations.Operation; -@CrossOrigin @RequestMapping({ "/crmReports" }) @RestController public class CustomerRelationshipReports { @@ -58,7 +54,7 @@ public void setCallReportsService(CallReportsService callReportsService) { @Autowired Report1097Mapper mapper; - @CrossOrigin() + @Operation(summary = "QA report type master data") @RequestMapping(value = "/getReportTypes/{providerServiceMapID}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON) public String patientAppChiefComplaintsMasterData( diff --git a/src/main/java/com/iemr/common/controller/scheme/SchemeController.java b/src/main/java/com/iemr/common/controller/scheme/SchemeController.java index e1c0a261..6b884005 100644 --- a/src/main/java/com/iemr/common/controller/scheme/SchemeController.java +++ b/src/main/java/com/iemr/common/controller/scheme/SchemeController.java @@ -22,24 +22,19 @@ package com.iemr.common.controller.scheme; import java.util.List; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; - import com.fasterxml.jackson.databind.ObjectMapper; import com.iemr.common.data.scheme.Scheme; -import com.iemr.common.data.users.UserServiceRoleMapping; import com.iemr.common.service.scheme.SchemeServiceImpl; import com.iemr.common.utils.mapper.InputMapper; import com.iemr.common.utils.response.OutputResponse; - import io.lettuce.core.dynamic.annotation.Param; import io.swagger.v3.oas.annotations.Operation; @@ -56,7 +51,7 @@ public class SchemeController { InputMapper mapper = new InputMapper(); - @CrossOrigin + @Operation(summary = "Save scheme details") @RequestMapping(value = "/save/schemeDetails", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE, headers = "Authorization") public String saveSchemeDetails(@Param(value = "{\"providerServiceMapID\": \"integer-provider service map id\", " @@ -83,7 +78,7 @@ public String saveSchemeDetails(@Param(value = "{\"providerServiceMapID\": \"int return output.toString(); } - @CrossOrigin + @Operation(summary = "Get scheme list") @RequestMapping(value = "/get/schemeList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE, headers = "Authorization") public String getSchemeList( @@ -109,7 +104,7 @@ public String getSchemeList( return output.toString(); } - @CrossOrigin + @Operation(summary = "Delete scheme") @RequestMapping(value = "/scheme/deleteScheme", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE, headers = "Authorization") public String deleteScheme( diff --git a/src/main/java/com/iemr/common/controller/secondaryReport/CustomerRelationshipSecondaryReports.java b/src/main/java/com/iemr/common/controller/secondaryReport/CustomerRelationshipSecondaryReports.java index 82a73ce3..2a85436c 100644 --- a/src/main/java/com/iemr/common/controller/secondaryReport/CustomerRelationshipSecondaryReports.java +++ b/src/main/java/com/iemr/common/controller/secondaryReport/CustomerRelationshipSecondaryReports.java @@ -29,25 +29,21 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; - import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.iemr.common.data.report.CallQualityReport; import com.iemr.common.service.reportSecondary.SecondaryReportService; -import com.iemr.common.utils.mapper.InputMapper; - import io.lettuce.core.dynamic.annotation.Param; import io.swagger.v3.oas.annotations.Operation; import jakarta.servlet.http.HttpServletRequest; -@CrossOrigin + @RequestMapping({ "/crmReports" }) @RestController public class CustomerRelationshipSecondaryReports { @@ -55,7 +51,7 @@ public class CustomerRelationshipSecondaryReports { @Autowired private SecondaryReportService secondaryReportService; - @CrossOrigin() + @Operation(summary = "Get quality report") @RequestMapping(value = "/getQualityReport", method = RequestMethod.POST, headers = "Authorization") public ResponseEntity getQualityReport( @@ -81,7 +77,7 @@ public ResponseEntity getQualityReport( } } - @CrossOrigin() + @Operation(summary = "Get complaint detail report") @RequestMapping(value = "/getComplaintDetailReport", method = RequestMethod.POST, headers = "Authorization") public ResponseEntity getComplaintDetailReport( @@ -108,7 +104,7 @@ public ResponseEntity getComplaintDetailReport( } } - @CrossOrigin() + @Operation(summary = "Get call summary report") @RequestMapping(value = "/getCallSummaryReport", method = RequestMethod.POST, headers = "Authorization") public ResponseEntity getCallSummaryReport( @@ -137,7 +133,7 @@ public ResponseEntity getCallSummaryReport( } } - @CrossOrigin() + @Operation(summary = "Get all by sexual orientation") @RequestMapping(value = "/getAllBySexualOrientation", method = RequestMethod.POST, headers = "Authorization") public ResponseEntity getAllBySexualOrientation( @@ -164,7 +160,7 @@ public ResponseEntity getAllBySexualOrientation( } - @CrossOrigin + @Operation(summary = "Get district wise call report") @RequestMapping(value = "/getDistrictWiseCallReport", method = RequestMethod.POST, headers = "Authorization") public ResponseEntity getDistrictWiseCallReport( @@ -190,7 +186,7 @@ public ResponseEntity getDistrictWiseCallReport( } } - @CrossOrigin + @Operation(summary = "Get unblocked user report") @RequestMapping(value = "/getUnblockedUserReport", method = RequestMethod.POST, headers = "Authorization") public ResponseEntity getUnblockedUserReport( @@ -215,7 +211,7 @@ public ResponseEntity getUnblockedUserReport( } } - @CrossOrigin + @Operation(summary = "Get call quality report") @RequestMapping(value = "/getCallQualityReport", method = RequestMethod.POST, headers = "Authorization") public ResponseEntity getCallQualityReport( @@ -244,7 +240,7 @@ public ResponseEntity getCallQualityReport( } } - @CrossOrigin() + @Operation(summary = "Get counts by preferred language") @RequestMapping(value = "/getCountsByPreferredLanguage", method = RequestMethod.POST, headers = "Authorization") public ResponseEntity getCountsByPreferredLanguage( @@ -272,7 +268,7 @@ public ResponseEntity getCountsByPreferredLanguage( } } - @CrossOrigin + @Operation(summary = "Get caller by age group") @RequestMapping(value = "/getAllByAgeGroup", method = RequestMethod.POST, headers = "Authorization") public ResponseEntity getAllByAgeGroup( @@ -298,7 +294,7 @@ public ResponseEntity getAllByAgeGroup( } } - @CrossOrigin() + @Operation(summary = "Get all reports by date") @RequestMapping(value = "/getAllReportsByDate", method = RequestMethod.POST, headers = "Authorization") public ResponseEntity getAllReportsByDate( @@ -326,7 +322,7 @@ public ResponseEntity getAllReportsByDate( } } - @CrossOrigin() + @Operation(summary = "Get all by gender") @RequestMapping(value = "/getAllByGender", method = RequestMethod.POST, headers = "Authorization") public ResponseEntity getAllByGender( diff --git a/src/main/java/com/iemr/common/controller/services/CategoryController.java b/src/main/java/com/iemr/common/controller/services/CategoryController.java index 7129577c..e8fed802 100644 --- a/src/main/java/com/iemr/common/controller/services/CategoryController.java +++ b/src/main/java/com/iemr/common/controller/services/CategoryController.java @@ -23,26 +23,19 @@ import java.util.ArrayList; import java.util.List; - import javax.ws.rs.core.MediaType; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.repository.query.Param; -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.RequestMethod; import org.springframework.web.bind.annotation.RestController; - import com.iemr.common.data.category.CategoryDetails; -import com.iemr.common.data.cti.CustomerLanguage; import com.iemr.common.service.category.CategoryService; import com.iemr.common.utils.mapper.InputMapper; import com.iemr.common.utils.response.OutputResponse; - import io.swagger.v3.oas.annotations.Operation; @@ -54,7 +47,7 @@ public class CategoryController { InputMapper inputMapper = new InputMapper(); final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); - @CrossOrigin() + @Operation(summary = "Get all categries") @PostMapping(value = "/categories", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getAllCategries( diff --git a/src/main/java/com/iemr/common/controller/services/CommonController.java b/src/main/java/com/iemr/common/controller/services/CommonController.java index 3813acda..6720b5db 100644 --- a/src/main/java/com/iemr/common/controller/services/CommonController.java +++ b/src/main/java/com/iemr/common/controller/services/CommonController.java @@ -31,13 +31,11 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; - import com.iemr.common.service.services.CommonService; import com.iemr.common.service.services.Services; import com.iemr.common.service.services.ServicesImpl; import com.iemr.common.utils.mapper.InputMapper; import com.iemr.common.utils.response.OutputResponse; - import io.lettuce.core.dynamic.annotation.Param; import io.swagger.v3.oas.annotations.Operation; diff --git a/src/main/java/com/iemr/common/controller/sms/SMSController.java b/src/main/java/com/iemr/common/controller/sms/SMSController.java index 139b4d75..720e3a7e 100644 --- a/src/main/java/com/iemr/common/controller/sms/SMSController.java +++ b/src/main/java/com/iemr/common/controller/sms/SMSController.java @@ -28,13 +28,10 @@ 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.RequestMethod; import org.springframework.web.bind.annotation.RestController; - import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonMappingException; @@ -48,7 +45,6 @@ import com.iemr.common.utils.mapper.InputMapper; import com.iemr.common.utils.mapper.OutputMapper; import com.iemr.common.utils.response.OutputResponse; - import io.lettuce.core.dynamic.annotation.Param; import io.swagger.v3.oas.annotations.Operation; import jakarta.servlet.http.HttpServletRequest; @@ -63,7 +59,7 @@ public class SMSController { InputMapper inputMapper = new InputMapper(); - @CrossOrigin() + @Operation(summary = "Get SMS templates") @PostMapping(value = "/getSMSTemplates", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getSMSTemplates( @@ -82,7 +78,7 @@ public String getSMSTemplates( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get full SMS template") @PostMapping(value = "/getFullSMSTemplate", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getFullSMSTemplate( @@ -101,7 +97,7 @@ public String getFullSMSTemplate( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Save SMS template") @PostMapping(value = "/saveSMSTemplate", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String saveSMSTemplate( @@ -120,7 +116,7 @@ public String saveSMSTemplate( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Update SMS template") @PostMapping(value = "/updateSMSTemplate", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String updateSMSTemplate( @@ -144,7 +140,7 @@ public String updateSMSTemplate( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get SMS types") @PostMapping(value = "/getSMSTypes", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getSMSTypes( @@ -164,7 +160,7 @@ public String getSMSTypes( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get SMS parameters") @PostMapping(value = "/getSMSParameters", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getSMSParameters( @@ -184,7 +180,7 @@ public String getSMSParameters( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Send SMS") @PostMapping(value = "/sendSMS", produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String sendSMS( diff --git a/src/main/java/com/iemr/common/controller/snomedct/SnomedController.java b/src/main/java/com/iemr/common/controller/snomedct/SnomedController.java index 23a451af..4af622cc 100644 --- a/src/main/java/com/iemr/common/controller/snomedct/SnomedController.java +++ b/src/main/java/com/iemr/common/controller/snomedct/SnomedController.java @@ -24,18 +24,15 @@ 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.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; - import com.google.gson.Gson; import com.iemr.common.data.snomedct.SCTDescription; import com.iemr.common.service.snomedct.SnomedService; import com.iemr.common.utils.mapper.InputMapper; import com.iemr.common.utils.response.OutputResponse; - import io.lettuce.core.dynamic.annotation.Param; import io.swagger.v3.oas.annotations.Operation; @@ -53,7 +50,7 @@ public void setSnomedService(SnomedService snomedService) { this.snomedService = snomedService; } - @CrossOrigin + @Operation(summary = "Retrives snomed CT record") @RequestMapping(value = "/getSnomedCTRecord", method = RequestMethod.POST, headers = "Authorization", consumes = "application/json", produces = "application/json") public String getSnomedCTRecord(@Param(value = "{\"term\":\"String\"}") @RequestBody String request) { @@ -79,7 +76,7 @@ public String getSnomedCTRecord(@Param(value = "{\"term\":\"String\"}") @Request return output.toString(); } - @CrossOrigin + @Operation(summary = "Retrives snomed CT record list") @RequestMapping(value = "/getSnomedCTRecordList", method = RequestMethod.POST, headers = "Authorization", consumes = "application/json", produces = "application/json") public String getSnomedCTRecordList(@Param(value = "{\"term\":\"String\"}") @RequestBody String request) { diff --git a/src/main/java/com/iemr/common/controller/uptsu/UPTechnicalSupportController.java b/src/main/java/com/iemr/common/controller/uptsu/UPTechnicalSupportController.java index 25321d2d..2eacfaad 100644 --- a/src/main/java/com/iemr/common/controller/uptsu/UPTechnicalSupportController.java +++ b/src/main/java/com/iemr/common/controller/uptsu/UPTechnicalSupportController.java @@ -1,24 +1,24 @@ /* -* 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/. -*/ + * 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.common.controller.uptsu; import javax.ws.rs.core.MediaType; @@ -26,61 +26,58 @@ 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.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; - import com.iemr.common.service.uptsu.UptsuService; import com.iemr.common.utils.response.OutputResponse; - import io.swagger.v3.oas.annotations.Operation; -@RequestMapping({ "/uptsu" }) +@RequestMapping({"/uptsu"}) @RestController public class UPTechnicalSupportController { - @Autowired - private UptsuService uptsuService; - private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + @Autowired + private UptsuService uptsuService; + private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + + + @Operation(summary = "Get facility master") + @RequestMapping(value = "/get/facilityMaster/{providerServiceMapID}/{blockName}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String getFacility(@PathVariable Integer providerServiceMapID, @PathVariable String blockName) { + OutputResponse response = new OutputResponse(); + logger.info("getFacility request "); + try { - @CrossOrigin - @Operation(summary = "Get facility master") - @RequestMapping(value = "/get/facilityMaster/{providerServiceMapID}/{blockName}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String getFacility(@PathVariable Integer providerServiceMapID, @PathVariable String blockName) { - OutputResponse response = new OutputResponse(); - logger.info("getFacility request "); - try { + response.setResponse(uptsuService.getFacility(providerServiceMapID, blockName)); + } catch (Exception e) { + logger.info("getFacility failed with error " + e.getMessage(), e); + response.setError(e); + } - response.setResponse(uptsuService.getFacility(providerServiceMapID, blockName)); - } catch (Exception e) { - logger.info("getFacility failed with error " + e.getMessage(), e); - response.setError(e); - } + return response.toString(); + } - return response.toString(); - } - @CrossOrigin - @Operation(summary = "Save appointment details") - @RequestMapping(value = "/save/appointment-details", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public String saveAppointmentDetails(@RequestBody String request, - @RequestHeader(value = "Authorization") String Authorization) { - OutputResponse response = new OutputResponse(); + @Operation(summary = "Save appointment details") + @RequestMapping(value = "/save/appointment-details", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") + public String saveAppointmentDetails(@RequestBody String request, + @RequestHeader(value = "Authorization") String Authorization) { + OutputResponse response = new OutputResponse(); - try { + try { - response.setResponse(uptsuService.saveAppointmentDetails(request, Authorization)); - } catch (Exception e) { + response.setResponse(uptsuService.saveAppointmentDetails(request, Authorization)); + } catch (Exception e) { - response.setError(5000, e.getLocalizedMessage()); - } + response.setError(5000, e.getLocalizedMessage()); + } - return response.toString(); - } + return response.toString(); + } } diff --git a/src/main/java/com/iemr/common/controller/users/EmployeeSignatureController.java b/src/main/java/com/iemr/common/controller/users/EmployeeSignatureController.java index 8a81d09b..40536c99 100644 --- a/src/main/java/com/iemr/common/controller/users/EmployeeSignatureController.java +++ b/src/main/java/com/iemr/common/controller/users/EmployeeSignatureController.java @@ -28,18 +28,15 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; - import com.google.gson.Gson; import com.iemr.common.data.users.EmployeeSignature; import com.iemr.common.service.users.EmployeeSignatureServiceImpl; import com.iemr.common.utils.mapper.InputMapper; import com.iemr.common.utils.response.OutputResponse; - import io.swagger.v3.oas.annotations.Operation; @@ -56,7 +53,7 @@ public class EmployeeSignatureController { private Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); - @CrossOrigin() + @Operation(summary = "Fetch file") @RequestMapping(value = "/{userID}", headers = "Authorization", method = { RequestMethod.GET }) public ResponseEntity fetchFile(@PathVariable("userID") Long userID) throws Exception { @@ -78,7 +75,7 @@ public ResponseEntity fetchFile(@PathVariable("userID") Long userID) thr } - @CrossOrigin() + @Operation(summary = "Fetch file from central") @RequestMapping(value = "/getSignClass/{userID}", headers = "Authorization", method = { RequestMethod.GET }) public String fetchFileFromCentral(@PathVariable("userID") Long userID) throws Exception { @@ -100,7 +97,7 @@ public String fetchFileFromCentral(@PathVariable("userID") Long userID) throws E return response.toString(); } - @CrossOrigin() + @Operation(summary = "Download file based on userID") @RequestMapping(value = "/signexist/{userID}", headers = "Authorization", method = { RequestMethod.GET }) public String existFile(@PathVariable("userID") Long userID) throws Exception { diff --git a/src/main/java/com/iemr/common/controller/users/IEMRAdminController.java b/src/main/java/com/iemr/common/controller/users/IEMRAdminController.java index e26f15dd..32bfe42b 100644 --- a/src/main/java/com/iemr/common/controller/users/IEMRAdminController.java +++ b/src/main/java/com/iemr/common/controller/users/IEMRAdminController.java @@ -23,9 +23,7 @@ import java.util.*; import java.util.concurrent.TimeUnit; - import javax.ws.rs.core.MediaType; - import com.iemr.common.utils.UserAgentUtil; import io.jsonwebtoken.Claims; import io.jsonwebtoken.ExpiredJwtException; @@ -38,7 +36,6 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; - import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -63,7 +60,6 @@ import com.iemr.common.utils.redis.RedisSessionException; import com.iemr.common.utils.response.OutputResponse; import com.iemr.common.utils.sessionobject.SessionObject; - import io.lettuce.core.dynamic.annotation.Param; import io.swagger.v3.oas.annotations.Operation; import jakarta.servlet.http.Cookie; @@ -106,7 +102,7 @@ public void setSessionObject(SessionObject sessionObject) { @Autowired SecurePassword securePassword; - @CrossOrigin() + @Operation(summary = "New user authentication") @RequestMapping(value = "/userAuthenticateNew", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON) public String userAuthenticateNew( @@ -121,7 +117,7 @@ public String userAuthenticateNew( return response.toString(); } - @CrossOrigin() + @Operation(summary = "User authentication") @RequestMapping(value = "/userAuthenticate", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON) public String userAuthenticate( @@ -281,7 +277,7 @@ public ResponseEntity refreshToken(@RequestBody Map request) } } - @CrossOrigin() + @Operation(summary = "Log out user from concurrent session") @RequestMapping(value = "/logOutUserFromConcurrentSession", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON) public String logOutUserFromConcurrentSession( @@ -390,10 +386,6 @@ private void createUserMapping(User mUser, JSONObject resMap, JSONObject service resMap.put("Previlege", serviceRoleList); } - @CrossOrigin(/* - * allowedHeaders = "Authorization", exposedHeaders = "Authorization", methods = - * RequestMethod.POST - */) @RequestMapping(value = "/superUserAuthenticate", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON) public String superUserAuthenticate( @Param(value = "\"{\\\"userName\\\":\\\"String\\\",\\\"doLogout\\\":\\\"Boolean\\\"}\"") @RequestBody LoginRequestModel m_User, @@ -450,7 +442,7 @@ public String superUserAuthenticate( return response.toString(); } -// @CrossOrigin() +// // @Operation(summary = "User authentication V1") // @RequestMapping(value = "/userAuthenticateV1", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON) // public String userAuthenticateV1( @@ -478,7 +470,7 @@ public String superUserAuthenticate( // return response.toString(); // } - @CrossOrigin() + @Operation(summary = "Get login response") @RequestMapping(value = "/getLoginResponse", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getLoginResponse(HttpServletRequest request) { @@ -491,10 +483,7 @@ public String getLoginResponse(HttpServletRequest request) { return response.toString(); } - @CrossOrigin(/* - * allowedHeaders = "Authorization", exposedHeaders = "Authorization", methods = - * RequestMethod.POST - */) + @Operation(summary = "Forget password") @RequestMapping(value = "/forgetPassword", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON) public String forgetPassword( @@ -534,7 +523,7 @@ else if (mUsers.size() == 1) { return response.toString(); } - @CrossOrigin() + @Operation(summary = "Set forget password") @RequestMapping(value = "/setForgetPassword", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON) public String setPassword( @@ -573,7 +562,7 @@ public String setPassword( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Change password") @RequestMapping(value = "/changePassword", method = RequestMethod.POST, produces = "application/json") public String changePassword( @@ -620,7 +609,7 @@ public String changePassword( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Save user security questions & answers") @RequestMapping(value = "/saveUserSecurityQuesAns", method = RequestMethod.POST, produces = "application/json") public String saveUserSecurityQuesAns( @@ -643,10 +632,7 @@ public String saveUserSecurityQuesAns( * * @return security qtns */ - @CrossOrigin(/* - * allowedHeaders = "Authorization", exposedHeaders = "Authorization", methods = - * RequestMethod.GET - */) + @Operation(summary = "Get security quetions") @RequestMapping(value = "/getsecurityquetions", method = RequestMethod.GET) public String getSecurityts() { @@ -663,10 +649,6 @@ public String getSecurityts() { return response.toString(); } - @CrossOrigin(/* - * allowedHeaders = "Authorization", exposedHeaders = "Authorization", methods = - * RequestMethod.POST - */) @Operation(summary = "Get roles by provider id") @RequestMapping(value = "/getRolesByProviderID", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getRolesByProviderID( @@ -683,10 +665,7 @@ public String getRolesByProviderID( return response.toString(); } - @CrossOrigin(/* - * allowedHeaders = "Authorization", exposedHeaders = "Authorization", methods = - * RequestMethod.POST - */) + @Operation(summary = "Get role screen mapping by provider id") @RequestMapping(value = "/getRoleScreenMappingByProviderID", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getRoleScreenMappingByProviderID( @@ -711,10 +690,6 @@ public String getRoleScreenMappingByProviderID( return response.toString(); } - @CrossOrigin(/* - * allowedHeaders = "Authorization", exposedHeaders = "Authorization", methods = - * RequestMethod.POST - */) @Operation(summary = "Get users by provider id") @RequestMapping(value = "/getUsersByProviderID", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getUsersByProviderID(@Param(value = "{\"providerServiceMapID\":\"Integer - providerServiceMapID\", " @@ -732,10 +707,7 @@ public String getUsersByProviderID(@Param(value = "{\"providerServiceMapID\":\"I return response.toString(); } - @CrossOrigin(/* - * allowedHeaders = "Authorization", exposedHeaders = "Authorization", methods = - * RequestMethod.POST - */) + @Operation(summary = "Get user service point van details") @RequestMapping(value = "/getUserServicePointVanDetails", method = RequestMethod.POST, produces = "application/json", headers = "Authorization") public String getUserServicePointVanDetails( @@ -756,7 +728,7 @@ public String getUserServicePointVanDetails( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get service point villages") @RequestMapping(value = "/getServicepointVillages", method = RequestMethod.POST, produces = "application/json", headers = "Authorization") public String getServicepointVillages( @@ -777,7 +749,7 @@ public String getServicepointVillages( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get locations by provider id") @RequestMapping(value = "/getLocationsByProviderID", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getLocationsByProviderID( @@ -795,7 +767,7 @@ public String getLocationsByProviderID( return response.toString(); } - @CrossOrigin() + @Operation(summary = "User log out") @RequestMapping(value = "/userLogout", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String userLogout(HttpServletRequest request) { @@ -843,7 +815,7 @@ private void deleteSessionObject(String key) { } } - @CrossOrigin() + @Operation(summary = "Force log out") @RequestMapping(value = "/forceLogout", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String forceLogout(@Param(value = "{\"userName\":\"String user name to force logout\", " @@ -858,7 +830,7 @@ public String forceLogout(@Param(value = "{\"userName\":\"String user name to fo return response.toString(); } - @CrossOrigin() + @Operation(summary = "User force log out") @RequestMapping(value = "/userForceLogout", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String userForceLogout( @@ -873,7 +845,7 @@ public String userForceLogout( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get agent by role id") @RequestMapping(value = "/getAgentByRoleID", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getAgentByRoleID(@Param(value = "{\"providerServiceMapID\":\"Integer - providerServiceMapID\", " @@ -890,7 +862,7 @@ public String getAgentByRoleID(@Param(value = "{\"providerServiceMapID\":\"Integ return response.toString(); } - @CrossOrigin() + @Operation(summary = "User authenticate by encryption") @RequestMapping(value = "/userAuthenticateByEncryption", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON) public String userAuthenticateByEncryption( @@ -935,7 +907,7 @@ public String userAuthenticateByEncryption( return response.toString(); } - @CrossOrigin() + @Operation(summary = "Get role wrap up time") @RequestMapping(value = "/role/{roleID}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON, headers = "Authorization") public String getrolewrapuptime(@PathVariable("roleID") Integer roleID) { @@ -957,7 +929,7 @@ public String getrolewrapuptime(@PathVariable("roleID") Integer roleID) { * @param request * @return transaction Id for password change */ - @CrossOrigin + @Operation(summary = "Validating security question and answers for password change") @RequestMapping(value = { "/validateSecurityQuestionAndAnswer" }, method = { RequestMethod.POST }) public String validateSecurityQuestionAndAnswer( @@ -983,7 +955,7 @@ public String validateSecurityQuestionAndAnswer( return response.toString(); } - @CrossOrigin() + @Operation(summary = "User authentication") @RequestMapping(value = "/bhavya/userAuthenticate", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON) public String userAuthenticateBhavya( diff --git a/src/main/java/com/iemr/common/controller/version/VersionController.java b/src/main/java/com/iemr/common/controller/version/VersionController.java index 39c065df..91d215d7 100644 --- a/src/main/java/com/iemr/common/controller/version/VersionController.java +++ b/src/main/java/com/iemr/common/controller/version/VersionController.java @@ -25,10 +25,8 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @@ -43,7 +41,6 @@ public class VersionController { private Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); - @CrossOrigin() @Operation(summary = "Get version") @RequestMapping(value = "/version", method = { RequestMethod.GET }) public String versionInformation() { diff --git a/src/main/java/com/iemr/common/utils/DynamicCorsFilter.java b/src/main/java/com/iemr/common/utils/DynamicCorsFilter.java new file mode 100644 index 00000000..f1e30bd5 --- /dev/null +++ b/src/main/java/com/iemr/common/utils/DynamicCorsFilter.java @@ -0,0 +1,37 @@ +package com.iemr.common.utils; + +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import org.springframework.web.filter.OncePerRequestFilter; + +import java.io.IOException; +import java.util.Arrays; + +@Component +public class DynamicCorsFilter extends OncePerRequestFilter { + + @Value("${cors.allowed-origins}") + private String[] allowedOrigins; + + @Override + protected void doFilterInternal(HttpServletRequest request, + HttpServletResponse response, + FilterChain filterChain) + throws ServletException, IOException { + + String origin = request.getHeader("Origin"); + if (origin != null && Arrays.asList(allowedOrigins).contains(origin)) { + response.setHeader("Access-Control-Allow-Origin", origin); + } + + if ("OPTIONS".equalsIgnoreCase(request.getMethod())) { + response.setStatus(HttpServletResponse.SC_OK); + } else { + filterChain.doFilter(request, response); + } + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 9418e973..c8439416 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -183,3 +183,4 @@ failedLoginAttempt=5 #Jwt Token configuration jwt.access.expiration=900000 jwt.refresh.expiration=604800000 +