diff --git a/src/main/environment/common_ci.properties b/src/main/environment/common_ci.properties index 9f54a35d..a6451109 100644 --- a/src/main/environment/common_ci.properties +++ b/src/main/environment/common_ci.properties @@ -19,7 +19,6 @@ km-base-path=@env.KM_API_BASE_PATH@ km-root-path=/okm:personal/users/ km-guest-user=@env.KM_GUEST_USER@ km-guest-password=@env.KM_GUEST_PASSWORD@ -tempFilePath=@env.TEMP_FILE_PATH@ # CTI Config cti-server-ip=@env.CTI_SERVER_IP@ @@ -193,15 +192,4 @@ cors.allowed-origins=@env.CORS_ALLOWED_ORIGINS@ video-call-url=@env.VIDEO_CALL_URL@ jibri.output.path=@env.JIBRI_OUTPUT_PATH@ video.recording.path=@env.VIDEO_RECORDING_PATH@ - -platform.feedback.ratelimit.enabled=@env.PLATFORM_FEEDBACK_RATELIMIT_ENABLED@ -platform.feedback.ratelimit.pepper=@env.PLATFORM_FEEDBACK_RATELIMIT_PEPPER@ -platform.feedback.ratelimit.trust-forwarded-for=@env.PLATFORM_FEEDBACK_RATELIMIT_TRUST_FORWARDED_FOR@ -platform.feedback.ratelimit.forwarded-for-header=@env.PLATFORM_FEEDBACK_RATELIMIT_FORWARDED_FOR_HEADER@ -platform.feedback.ratelimit.minute-limit=@env.PLATFORM_FEEDBACK_RATELIMIT_MINUTE_LIMIT@ -platform.feedback.ratelimit.day-limit=@env.PLATFORM_FEEDBACK_RATELIMIT_DAY_LIMIT@ -platform.feedback.ratelimit.user-day-limit=@env.PLATFORM_FEEDBACK_RATELIMIT_USER_DAY_LIMIT@ -platform.feedback.ratelimit.fail-window-minutes=@env.PLATFORM_FEEDBACK_RATELIMIT_FAIL_WINDOW_MINUTES@ -platform.feedback.ratelimit.backoff-minutes=@env.PLATFORM_FEEDBACK_RATELIMIT_BACKOFF_MINUTES@ generateBeneficiaryIDs-api-url=@env.GEN_BENEFICIARY_IDS_API_URL@ - diff --git a/src/main/environment/common_docker.properties b/src/main/environment/common_docker.properties index 59cb580d..1035af57 100644 --- a/src/main/environment/common_docker.properties +++ b/src/main/environment/common_docker.properties @@ -126,7 +126,7 @@ everwellRegisterBenficiary = ${COMMON_API_BASE_URL}/beneficiary/create ## LungAssessment credentials lungAssessmentEmail = ${SWAASA_EMAIL} lungAssessmentPassword =${SWAASA_PASSWORD} -tempFilePath=${TEMP_FILE_PATH} + ## SWASSA APIs lungAssessmentAdminLogin = ${SWAASA_BASE_URL}/api/adminLogin @@ -195,15 +195,4 @@ firebase.credential-file=${FIREBASE_CREDENTIAL} video-call-url=${VIDEO_CALL_URL} jibri.output.path={JIBRI_OUTPUT_PATH} video.recording.path={VIDEO_RECORDING_PATH} - -# Platform Feedback module -platform.feedback.ratelimit.enabled=${PLATFORM_FEEDBACK_RATELIMIT_ENABLED} -platform.feedback.ratelimit.pepper=${PLATFORM_FEEDBACK_RATELIMIT_PEPPER} -platform.feedback.ratelimit.trust-forwarded-for=${PLATFORM_FEEDBACK_RATELIMIT_TRUST_FORWARDED_FOR} -platform.feedback.ratelimit.forwarded-for-header=${PLATFORM_FEEDBACK_RATELIMIT_FORWARDED_FOR_HEADER} -platform.feedback.ratelimit.minute-limit=${PLATFORM_FEEDBACK_RATELIMIT_MINUTE_LIMIT} -platform.feedback.ratelimit.day-limit=${PLATFORM_FEEDBACK_RATELIMIT_DAY_LIMIT} -platform.feedback.ratelimit.user-day-limit=${PLATFORM_FEEDBACK_RATELIMIT_USER_DAY_LIMIT} -platform.feedback.ratelimit.fail-window-minutes=${PLATFORM_FEEDBACK_RATELIMIT_FAIL_WINDOW_MINUTES} -platform.feedback.ratelimit.backoff-minutes=${PLATFORM_FEEDBACK_RATELIMIT_BACKOFF_MINUTES} generateBeneficiaryIDs-api-url={GEN_BENEFICIARY_IDS_API_URL} diff --git a/src/main/environment/common_example.properties b/src/main/environment/common_example.properties index aca73ddb..bea76523 100644 --- a/src/main/environment/common_example.properties +++ b/src/main/environment/common_example.properties @@ -208,21 +208,5 @@ captcha.enable-captcha=true cors.allowed-origins=http://localhost:* -# ---Platform Feedback module --- -# Rate limiter OFF locally (no Redis required) -platform.feedback.ratelimit.enabled=true -platform.feedback.ratelimit.pepper=dev-pepper-123 # dummy - -# trust forwarded-for locally is harmless (localhost only) -platform.feedback.ratelimit.trust-forwarded-for=false -platform.feedback.ratelimit.forwarded-for-header=X-Forwarded-For - -# Optional overrides (not needed if disabled) -platform.feedback.ratelimit.minute-limit=10 -platform.feedback.ratelimit.day-limit=100 -platform.feedback.ratelimit.user-day-limit=50 -platform.feedback.ratelimit.fail-window-minutes=5 -platform.feedback.ratelimit.backoff-minutes=15 - ### generate Beneficiary IDs URL generateBeneficiaryIDs-api-url=/generateBeneficiaryController/generateBeneficiaryIDs diff --git a/src/main/java/com/iemr/common/CommonApplication.java b/src/main/java/com/iemr/common/CommonApplication.java index dff5d809..e4a59994 100644 --- a/src/main/java/com/iemr/common/CommonApplication.java +++ b/src/main/java/com/iemr/common/CommonApplication.java @@ -29,7 +29,6 @@ import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; -import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.web.client.RestTemplate; @@ -41,7 +40,6 @@ @SpringBootApplication @EnableScheduling -@EnableAsync public class CommonApplication extends SpringBootServletInitializer { @Bean diff --git a/src/main/java/com/iemr/common/config/RedisConfig.java b/src/main/java/com/iemr/common/config/RedisConfig.java index 796ad557..e812b3f9 100644 --- a/src/main/java/com/iemr/common/config/RedisConfig.java +++ b/src/main/java/com/iemr/common/config/RedisConfig.java @@ -33,7 +33,6 @@ import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.iemr.common.data.users.User; -import org.springframework.data.redis.core.StringRedisTemplate; @Configuration public class RedisConfig { @@ -58,10 +57,4 @@ public RedisTemplate redisTemplate(RedisConnectionFactory factor return template; } - // new bean for rate limiting & counters - @Bean - public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory factory) { - return new StringRedisTemplate(factory); - } - } diff --git a/src/main/java/com/iemr/common/config/encryption/SecurePassword.java b/src/main/java/com/iemr/common/config/encryption/SecurePassword.java index 95cdd7f3..15463b7a 100644 --- a/src/main/java/com/iemr/common/config/encryption/SecurePassword.java +++ b/src/main/java/com/iemr/common/config/encryption/SecurePassword.java @@ -26,8 +26,10 @@ import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.security.spec.InvalidKeySpecException; + import javax.crypto.SecretKeyFactory; import javax.crypto.spec.PBEKeySpec; + import org.springframework.stereotype.Service; @Service 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 3784f3a9..8f573d6d 100644 --- a/src/main/java/com/iemr/common/controller/beneficiary/BeneficiaryRegistrationController.java +++ b/src/main/java/com/iemr/common/controller/beneficiary/BeneficiaryRegistrationController.java @@ -36,7 +36,6 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; 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; @@ -71,8 +70,6 @@ import com.iemr.common.service.userbeneficiarydata.MaritalStatusService; import com.iemr.common.service.userbeneficiarydata.StatusService; import com.iemr.common.service.userbeneficiarydata.TitleService; -import com.iemr.common.utils.CookieUtil; -import com.iemr.common.utils.JwtUtil; import com.iemr.common.utils.mapper.InputMapper; import com.iemr.common.utils.mapper.OutputMapper; import com.iemr.common.utils.response.OutputResponse; @@ -106,8 +103,6 @@ public class BeneficiaryRegistrationController { private BeneficiaryOccupationService beneficiaryOccupationService; private GovtIdentityTypeService govtIdentityTypeService; - @Autowired - private JwtUtil jwtUtil; @Autowired public void setBenRelationshipTypeService(BenRelationshipTypeService benRelationshipTypeService) { @@ -347,54 +342,6 @@ public String searchUserByPhone( return response.toString(); } - @Operation(summary = "Provide the list of beneficiaries using Elasticsearch") - @RequestMapping(value = "/searchUser", method = RequestMethod.POST, headers = "Authorization") - public String searchUser(@RequestBody String request, HttpServletRequest httpRequest) { - OutputResponse response = new OutputResponse(); - try { - logger.info("Universal search request received"); - - JsonParser parser = new JsonParser(); - JsonObject requestObj = parser.parse(request).getAsJsonObject(); - - String searchQuery = null; - if (requestObj.has("search") && !requestObj.get("search").isJsonNull()) { - searchQuery = requestObj.get("search").getAsString(); - } - - if (searchQuery == null || searchQuery.trim().isEmpty()) { - response.setError(400, "Search query is required"); - return response.toString(); - } - - String auth = httpRequest.getHeader("Authorization"); - - Integer userID = jwtUtil.getUserIdFromRequest(httpRequest); - - logger.info("ES search for userId: {}", userID); - - Boolean is1097 = false; - if (requestObj.has("is1097") && !requestObj.get("is1097").isJsonNull()) { - is1097 = requestObj.get("is1097").getAsBoolean(); - } - - logger.info("Searching with query: {}, userId: {}, is1097: {}", searchQuery, userID, is1097); - String result = iemrSearchUserService.searchUser(searchQuery, userID, auth, is1097); - - if (result == null || result.trim().isEmpty()) { - response.setError(200, "No beneficiaries found"); - return response.toString(); - } - - return result; - - } catch (Exception e) { - logger.error("Error in universal search: {}", e.getMessage(), e); - response.setError(400, "Error searching beneficiaries: " + e.getMessage()); - 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( @@ -417,41 +364,6 @@ public String searchBeneficiary( return output.toString(); } - /** - * Elasticsearch-based advanced search endpoint - */ - @Operation(summary = "Advanced search beneficiaries using Elasticsearch") - @RequestMapping(value = "/searchBeneficiaryES", method = RequestMethod.POST, headers = "Authorization") - public String searchBeneficiaryES( - @RequestBody BeneficiaryModel request, - HttpServletRequest httpRequest) { - - logger.info("searchBeneficiaryES request: {}", request); - OutputResponse output = new OutputResponse(); - - try { - - String auth = httpRequest.getHeader("Authorization"); - - Integer userID = jwtUtil.getUserIdFromRequest(httpRequest); - - logger.info("ES Advanced search for userId: {}", userID); - - String result = iemrSearchUserService.findBeneficiaryES(request, userID, auth); - - return result; - - } catch (NumberFormatException ne) { - logger.error("searchBeneficiaryES failed with number format error: {}", ne.getMessage(), ne); - output.setError(400, "Invalid number format in search criteria"); - return output.toString(); - } catch (Exception e) { - logger.error("searchBeneficiaryES failed with error: {}", e.getMessage(), e); - output.setError(500, "Error searching beneficiaries: " + e.getMessage()); - 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() { diff --git a/src/main/java/com/iemr/common/controller/dynamicForm/DynamicFormController.java b/src/main/java/com/iemr/common/controller/dynamicForm/DynamicFormController.java index c24651c6..cd83246f 100644 --- a/src/main/java/com/iemr/common/controller/dynamicForm/DynamicFormController.java +++ b/src/main/java/com/iemr/common/controller/dynamicForm/DynamicFormController.java @@ -84,7 +84,7 @@ public ResponseEntity> deleteField(@PathVariable Long fieldId) { } @GetMapping(value = "form/{formId}/fields") - public ResponseEntity> getStructuredForm(@PathVariable String formId, @RequestParam(name = "lang", defaultValue = "en") String lang,@RequestHeader(value = "jwttoken") String token) { + public ResponseEntity> getStructuredForm(@PathVariable String formId, @RequestParam(name = "lang", defaultValue = "en") String lang,@RequestHeader(value = "JwtToken") String token) { try { Object result = formMasterService.getStructuredFormByFormId(formId,lang,token); return ResponseEntity.status(HttpStatus.OK) @@ -97,6 +97,4 @@ public ResponseEntity> getStructuredForm(@PathVariable String for } - - } diff --git a/src/main/java/com/iemr/common/controller/platform_feedback/PlatformFeedbackController.java b/src/main/java/com/iemr/common/controller/platform_feedback/PlatformFeedbackController.java deleted file mode 100644 index 556561cf..00000000 --- a/src/main/java/com/iemr/common/controller/platform_feedback/PlatformFeedbackController.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * AMRIT – Accessible Medical Records via Integrated Technology - * Integrated EHR (Electronic Health Records) Solution - * - * Copyright (C) "Piramal Swasthya Management and Research Institute" - * - * This file is part of AMRIT. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see https://www.gnu.org/licenses/. - */ -package com.iemr.common.controller.platform_feedback; - -import com.iemr.common.dto.platform_feedback.CategoryResponse; -import com.iemr.common.dto.platform_feedback.FeedbackRequest; -import com.iemr.common.dto.platform_feedback.FeedbackResponse; -import com.iemr.common.service.platform_feedback.PlatformFeedbackService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.media.Content; -import org.springframework.http.ResponseEntity; -import org.springframework.http.HttpStatus; -import org.springframework.validation.annotation.Validated; -import jakarta.validation.Valid; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -@Tag(name = "Platform Feedback", description = "Feedback ingestion and category listing for platform-wide feedback") -@RestController -@RequestMapping("/platform-feedback") -@Validated -public class PlatformFeedbackController { - - private final PlatformFeedbackService service; - - public PlatformFeedbackController(PlatformFeedbackService service) { - this.service = service; - } - - @Operation(summary = "Submit feedback (public endpoint)", - description = "Accepts feedback (anonymous or identified). Accepts categoryId or categorySlug; slug is preferred.") - @ApiResponse(responseCode = "201", description = "Feedback accepted") - @ApiResponse(responseCode = "400", description = "Validation or business error", content = @Content) - @PostMapping - public ResponseEntity submit( - @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Feedback payload") - @Valid @RequestBody FeedbackRequest req) { - FeedbackResponse resp = service.submitFeedback(req); - return ResponseEntity.status(HttpStatus.CREATED).body(resp); - } - - @Operation(summary = "List active categories", - description = "Returns active categories. Optionally filter by serviceLine (frontend convenience).") - @ApiResponse(responseCode = "200", description = "List of categories") - @GetMapping("/categories") - public ResponseEntity> list( - @Parameter(description = "Optional serviceLine to prefer scopes (1097|104|AAM|MMU|TM|ECD)") - @RequestParam(required = false) String serviceLine) { - if (serviceLine == null) serviceLine = "GLOBAL"; - List list = service.listCategories(serviceLine); - return ResponseEntity.ok(list); - } -} 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 554500f3..55e2f93f 100644 --- a/src/main/java/com/iemr/common/controller/users/IEMRAdminController.java +++ b/src/main/java/com/iemr/common/controller/users/IEMRAdminController.java @@ -392,7 +392,6 @@ private void createUserMapping(User mUser, JSONObject resMap, JSONObject service resMap.put("agentPassword", mUser.getAgentPassword()); resMap.put("m_UserLangMappings", new JSONArray(mUser.getM_UserLangMappings().toString())); resMap.put("designationID", mUser.getDesignationID()); - resMap.put("dhistoken",mUser.getDhistoken()); if (mUser.getDesignation() != null) { resMap.put("designation", new JSONObject(mUser.getDesignation().toString())); } @@ -1224,25 +1223,7 @@ public ResponseEntity getUserDetails(@PathVariable("userName") String userNam return new ResponseEntity<>(Map.of("error", "UserName Not Found"), HttpStatus.NOT_FOUND); } User user = users.get(0); - return new ResponseEntity<>(Map.of("userName", user.getUserName(), "userId", user.getUserID()), - HttpStatus.OK); - } catch (Exception e) { - return new ResponseEntity<>(Map.of("error", "Internal server error"), HttpStatus.INTERNAL_SERVER_ERROR); - } - - } - - @Operation(summary = "Get UserId based on userName") - @GetMapping(value = "/checkUserName/{userName}", produces = MediaType.APPLICATION_JSON, headers = "Authorization") - public ResponseEntity checkUserDetails(@PathVariable("userName") String userName) { - try { - List users = iemrAdminUserServiceImpl.findUserIdByUserName(userName); - if (users.isEmpty()) { - return new ResponseEntity<>(Map.of("error", "UserName Not Found"), HttpStatus.NOT_FOUND); - } - User user = users.get(0); - return new ResponseEntity<>(Map.of("userName", user.getUserName(), "userId", user.getUserID()), - HttpStatus.OK); + return new ResponseEntity<>(Map.of("userName", user.getUserName(), "userId", user.getUserID()), HttpStatus.OK); } catch (Exception e) { return new ResponseEntity<>(Map.of("error", "Internal server error"), HttpStatus.INTERNAL_SERVER_ERROR); } diff --git a/src/main/java/com/iemr/common/data/platform_feedback/Feedback.java b/src/main/java/com/iemr/common/data/platform_feedback/Feedback.java deleted file mode 100644 index 776d3c08..00000000 --- a/src/main/java/com/iemr/common/data/platform_feedback/Feedback.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * AMRIT – Accessible Medical Records via Integrated Technology - * Integrated EHR (Electronic Health Records) Solution - * - * Copyright (C) "Piramal Swasthya Management and Research Institute" - * - * This file is part of AMRIT. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see https://www.gnu.org/licenses/. - */ -package com.iemr.common.data.platform_feedback; - -import jakarta.persistence.*; -import jakarta.validation.constraints.Max; -import jakarta.validation.constraints.Min; -import jakarta.validation.constraints.Size; -import java.time.LocalDateTime; -import java.util.UUID; - -@Entity -@Table(name = "m_platform_feedback") -public class Feedback { - - @Id - @Column(name = "FeedbackID", length = 36, updatable = false, nullable = false) - private String feedbackId; - - @Column(name = "CreatedAt", nullable = false, insertable = false, updatable = false) - private LocalDateTime createdAt; - - @Column(name = "UpdatedAt", nullable = false, insertable = false, updatable = false) - private LocalDateTime updatedAt; - - @Min(1) - @Max(5) - @Column(name = "Rating", nullable = false) - private int rating; - - @Size(max = 2000) - @Column(name = "Comment", columnDefinition = "TEXT", nullable = true) - private String comment; - - @Column(name = "ServiceLine", nullable = false, length = 10) - private String serviceLine; - - @Column(name = "IsAnonymous", nullable = false) - private boolean isAnonymous = true; - - @ManyToOne(fetch = FetchType.LAZY, optional = false) - @JoinColumn(name = "CategoryID", referencedColumnName = "CategoryID", nullable = false) - private FeedbackCategory category; - - @Column(name = "UserID", nullable = true) - private Integer userId; - - public Feedback() { - this.feedbackId = UUID.randomUUID().toString(); - } - - public Feedback(int rating, String comment, String serviceLine, boolean isAnonymous, FeedbackCategory category, Integer userId) { - this(); // ensures feedbackId - this.setRating(rating); - this.setComment(comment); - this.setServiceLine(serviceLine); - this.isAnonymous = isAnonymous; - this.category = category; - this.userId = userId; - } - - public String getFeedbackId() { - return feedbackId; - } - - // Don't usually set feedbackId externally, but keep setter for testing/migration if needed - public void setFeedbackId(String feedbackId) { - this.feedbackId = feedbackId; - } - - public LocalDateTime getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(LocalDateTime createdAt) { - this.createdAt = createdAt; - } - - public LocalDateTime getUpdatedAt() { - return updatedAt; - } - - public void setUpdatedAt(LocalDateTime updatedAt) { - this.updatedAt = updatedAt; - } - - public int getRating() { - return rating; - } - - public void setRating(int rating) { - if (rating < 1 || rating > 5) { - throw new IllegalArgumentException("Rating must be between 1 and 5."); - } - this.rating = rating; - } - - public String getComment() { - return comment; - } - - public void setComment(String comment) { - if (comment != null && comment.length() > 2000) { - throw new IllegalArgumentException("Comment cannot exceed 2000 characters"); - } - this.comment = (comment == null || comment.trim().isEmpty()) ? null : comment.trim(); - } - - public String getServiceLine() { - return serviceLine; - } - - public void setServiceLine(String serviceLine) { - if (serviceLine == null || serviceLine.trim().isEmpty()) { - throw new IllegalArgumentException("ServiceLine must not be null or empty."); - } - this.serviceLine = serviceLine; - } - - public boolean isAnonymous() { - return isAnonymous; - } - - public void setAnonymous(boolean anonymous) { - isAnonymous = anonymous; - if (anonymous) { - this.userId = null; - } - } - - public FeedbackCategory getCategory() { - return category; - } - - public void setCategory(FeedbackCategory category) { - if (category == null) { - throw new IllegalArgumentException("Category must not be null."); - } - this.category = category; - } - - public Integer getUserId() { - return userId; - } - - public void setUserId(Integer userId) { - this.userId = userId; - if (userId != null) { - this.isAnonymous = false; - } - } -} diff --git a/src/main/java/com/iemr/common/data/platform_feedback/FeedbackCategory.java b/src/main/java/com/iemr/common/data/platform_feedback/FeedbackCategory.java deleted file mode 100644 index a3e4c692..00000000 --- a/src/main/java/com/iemr/common/data/platform_feedback/FeedbackCategory.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * AMRIT – Accessible Medical Records via Integrated Technology - * Integrated EHR (Electronic Health Records) Solution - * - * Copyright (C) "Piramal Swasthya Management and Research Institute" - * - * This file is part of AMRIT. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see https://www.gnu.org/licenses/. - */ -package com.iemr.common.data.platform_feedback; - -import jakarta.persistence.*; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.Pattern; -import jakarta.validation.constraints.Size; -import java.time.LocalDateTime; -import java.util.UUID; - -/** - * FeedbackCategory maps to the m_feedback_category table. - */ -@Entity -@Table(name = "m_feedback_category", uniqueConstraints = { - @UniqueConstraint(name = "uq_category_slug", columnNames = "Slug") -}) -public class FeedbackCategory { - - @Id - @Column(name = "CategoryID", length = 36, updatable = false, nullable = false) - private String categoryId; - - @NotBlank - @Pattern(regexp = "^[a-z0-9]+(?:-[a-z0-9]+)*$", message = "Slug must be lowercase alphanumeric with optional single dashes") - @Size(max = 64) - @Column(name = "Slug", nullable = false, length = 64) - private String slug; - - @NotBlank - @Size(max = 128) - @Column(name = "Label", nullable = false, length = 128) - private String label; - - @NotBlank - @Size(max = 20) - @Column(name = "Scope", nullable = false, length = 20) - private String scope; - - @Column(name = "Active", nullable = false) - private boolean active = true; - - - @Column(name = "CreatedAt", nullable = false, insertable = false, updatable = false) - private LocalDateTime createdAt; - - @Column(name = "UpdatedAt", nullable = false, insertable = false, updatable = false) - private LocalDateTime updatedAt; - - // ===== Constructors ===== - public FeedbackCategory() { - // nothing — categoryId will be generated at persist if not provided - } - - public FeedbackCategory(String slug, String label, String scope, boolean active) { - this.slug = slug; - this.label = label; - this.scope = scope; - this.active = active; - } - - // ===== JPA lifecycle hooks ===== - /** - * Ensure CategoryID exists for new rows created via JPA. If DB seeding provides IDs, - * those will be used instead (we only set if null). - */ - @PrePersist - protected void ensureId() { - if (this.categoryId == null || this.categoryId.trim().isEmpty()) { - this.categoryId = UUID.randomUUID().toString(); - } - } - - // ===== Getters & Setters ===== - public String getCategoryId() { - return categoryId; - } - - // categoryId is generated at persist; setter kept for migration/tests - public void setCategoryId(String categoryId) { - this.categoryId = categoryId; - } - - public String getSlug() { - return slug; - } - - public void setSlug(String slug) { - this.slug = slug; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public String getScope() { - return scope; - } - - public void setScope(String scope) { - this.scope = scope; - } - - public boolean isActive() { - return active; - } - - public void setActive(boolean active) { - this.active = active; - } - - public LocalDateTime getCreatedAt() { - return createdAt; - } - - // CreatedAt normally set by DB; setter available for tests/migrations - public void setCreatedAt(LocalDateTime createdAt) { - this.createdAt = createdAt; - } - - public LocalDateTime getUpdatedAt() { - return updatedAt; - } - - // UpdatedAt normally managed by DB - public void setUpdatedAt(LocalDateTime updatedAt) { - this.updatedAt = updatedAt; - } -} diff --git a/src/main/java/com/iemr/common/data/translation/Translation.java b/src/main/java/com/iemr/common/data/translation/Translation.java index 52cb8027..0dad116d 100644 --- a/src/main/java/com/iemr/common/data/translation/Translation.java +++ b/src/main/java/com/iemr/common/data/translation/Translation.java @@ -22,5 +22,4 @@ public class Translation { private String assameseTranslation; @Column(name = "is_active") private Boolean isActive; - } diff --git a/src/main/java/com/iemr/common/data/users/User.java b/src/main/java/com/iemr/common/data/users/User.java index 275b0ec6..e6184e60 100644 --- a/src/main/java/com/iemr/common/data/users/User.java +++ b/src/main/java/com/iemr/common/data/users/User.java @@ -55,7 +55,6 @@ @Entity @Table(name = "m_user") @Data -@JsonIgnoreProperties(ignoreUnknown = true) public class User implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -209,10 +208,6 @@ public class User implements Serializable { @Column(name = "failed_attempt") private Integer failedAttempt; - @Expose - @Column(name = "dhistoken") - private String dhistoken; - /* * protected User() { } */ @@ -222,7 +217,7 @@ public static User initializeUsers(Long userID, Integer titleID, String firstNam Timestamp dOJ, Integer qualificationID, String userName, String password, String emailID, Status m_Status, List m_UserServiceRoleMapping, String emergencyContactPerson, String emergencyContactNo, Boolean isSupervisor, Boolean deleted, String createdBy, Timestamp createdDate, - String modifiedBy, Timestamp lastModDate, String newPassword, String dhistoken) { + String modifiedBy, Timestamp lastModDate, String newPassword) { User user = new User(); user.userID = userID; user.titleID = titleID; @@ -249,7 +244,6 @@ public static User initializeUsers(Long userID, Integer titleID, String firstNam user.modifiedBy = modifiedBy; user.lastModDate = lastModDate; user.newPassword = newPassword; - user.dhistoken = dhistoken; return user; } @@ -536,9 +530,6 @@ public Integer getDesignationID() { public Designation getDesignation() { return designation; } - public String getDhistoken() { - return dhistoken; - } /* * public User(String userName, String password) { this.userName = userName; diff --git a/src/main/java/com/iemr/common/data/users/UserServiceRole.java b/src/main/java/com/iemr/common/data/users/UserServiceRole.java index 27c044cf..63af40dd 100644 --- a/src/main/java/com/iemr/common/data/users/UserServiceRole.java +++ b/src/main/java/com/iemr/common/data/users/UserServiceRole.java @@ -365,5 +365,4 @@ public void setVillagename(String villagename) { public int hashCode() { return Objects.hash(userId, usrMappingId, name, userName, serviceId, serviceName, isNational, stateId, stateName, workingDistrictId, workingDistrictName, workingLocationId, serviceProviderId, locationName, workingLocationAddress, roleId, roleName, providerServiceMapId, agentId, psmStatusId, psmStatus, userServciceRoleDeleted, userDeleted, serviceProviderDeleted, roleDeleted, providerServiceMappingDeleted, isInbound, isOutbound, blockid, blockname, villageid, villagename); } - } diff --git a/src/main/java/com/iemr/common/dto/platform_feedback/CategoryResponse.java b/src/main/java/com/iemr/common/dto/platform_feedback/CategoryResponse.java deleted file mode 100644 index c01ff197..00000000 --- a/src/main/java/com/iemr/common/dto/platform_feedback/CategoryResponse.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * AMRIT – Accessible Medical Records via Integrated Technology - * Integrated EHR (Electronic Health Records) Solution - * - * Copyright (C) "Piramal Swasthya Management and Research Institute" - * - * This file is part of AMRIT. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see https://www.gnu.org/licenses/. - */ -package com.iemr.common.dto.platform_feedback; - -public record CategoryResponse(String categoryId, String slug, String label, String scope, boolean active) {} \ No newline at end of file diff --git a/src/main/java/com/iemr/common/dto/platform_feedback/FeedbackRequest.java b/src/main/java/com/iemr/common/dto/platform_feedback/FeedbackRequest.java deleted file mode 100644 index 02c52c3a..00000000 --- a/src/main/java/com/iemr/common/dto/platform_feedback/FeedbackRequest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * AMRIT – Accessible Medical Records via Integrated Technology - * Integrated EHR (Electronic Health Records) Solution - * - * Copyright (C) "Piramal Swasthya Management and Research Institute" - * - * This file is part of AMRIT. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see https://www.gnu.org/licenses/. - */ -package com.iemr.common.dto.platform_feedback; - -import jakarta.validation.constraints.Max; -import jakarta.validation.constraints.Min; -import jakarta.validation.constraints.Pattern; -import jakarta.validation.constraints.Size; - -public record FeedbackRequest( - @Min(1) @Max(5) int rating, - String categoryId, - String categorySlug, - @Size(max = 2000) String comment, - boolean isAnonymous, - @Pattern(regexp = "^(1097|104|AAM|MMU|TM|ECD)$") String serviceLine, - Integer userId -) {} \ No newline at end of file diff --git a/src/main/java/com/iemr/common/dto/platform_feedback/FeedbackResponse.java b/src/main/java/com/iemr/common/dto/platform_feedback/FeedbackResponse.java deleted file mode 100644 index 51003353..00000000 --- a/src/main/java/com/iemr/common/dto/platform_feedback/FeedbackResponse.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * AMRIT – Accessible Medical Records via Integrated Technology - * Integrated EHR (Electronic Health Records) Solution - * - * Copyright (C) "Piramal Swasthya Management and Research Institute" - * - * This file is part of AMRIT. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see https://www.gnu.org/licenses/. - */ -package com.iemr.common.dto.platform_feedback; -import java.time.LocalDateTime; - - -public record FeedbackResponse(String id, LocalDateTime createdAt) {} \ No newline at end of file diff --git a/src/main/java/com/iemr/common/exception/BadRequestException.java b/src/main/java/com/iemr/common/exception/BadRequestException.java deleted file mode 100644 index 65d146a6..00000000 --- a/src/main/java/com/iemr/common/exception/BadRequestException.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * AMRIT – Accessible Medical Records via Integrated Technology - * Integrated EHR (Electronic Health Records) Solution - * - * Copyright (C) "Piramal Swasthya Management and Research Institute" - * - * This file is part of AMRIT. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see https://www.gnu.org/licenses/. - */ -package com.iemr.common.exception; - -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.ResponseStatus; - -@ResponseStatus(HttpStatus.BAD_REQUEST) -public class BadRequestException extends RuntimeException { - public BadRequestException(String message) { super(message); } - public BadRequestException(String message, Throwable cause) { super(message, cause); } -} diff --git a/src/main/java/com/iemr/common/filter/PlatformFeedbackRateLimitFilter.java b/src/main/java/com/iemr/common/filter/PlatformFeedbackRateLimitFilter.java deleted file mode 100644 index d6dddf55..00000000 --- a/src/main/java/com/iemr/common/filter/PlatformFeedbackRateLimitFilter.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * AMRIT – Accessible Medical Records via Integrated Technology - * Integrated EHR (Electronic Health Records) Solution - * - * Copyright (C) "Piramal Swasthya Management and Research Institute" - * - * This file is part of AMRIT. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see https://www.gnu.org/licenses/. - */ -package com.iemr.common.filter; - -import jakarta.servlet.FilterChain; -import jakarta.servlet.ServletException; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import org.springframework.core.Ordered; -import org.springframework.core.annotation.Order; -import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.http.MediaType; -import org.springframework.stereotype.Component; -import org.springframework.util.StringUtils; -import org.springframework.web.filter.OncePerRequestFilter; - -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.security.MessageDigest; -import java.time.Duration; -import java.time.LocalDate; -import java.time.ZoneId; -import java.util.Base64; -import java.util.concurrent.TimeUnit; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; - - -@Component -@ConditionalOnProperty(prefix = "platform.feedback.ratelimit", name = "enabled", havingValue = "true", matchIfMissing = false) -@Order(Ordered.HIGHEST_PRECEDENCE + 10) // run early (adjust order as needed) -public class PlatformFeedbackRateLimitFilter extends OncePerRequestFilter { - - private final StringRedisTemplate redis; - private final String pepper; - private final boolean trustForwardedFor; - private final String forwardedForHeader; - - // Limits & TTLs (tweak if needed) - private static final int MINUTE_LIMIT = 10; - private static final int DAY_LIMIT = 100; - private static final int USER_DAY_LIMIT = 50; // for identified users - private static final Duration MINUTE_WINDOW = Duration.ofMinutes(1); - private static final Duration DAY_WINDOW = Duration.ofHours(48); // keep key TTL ~48h - private static final Duration FAIL_COUNT_WINDOW = Duration.ofMinutes(5); - private static final int FAILS_TO_BACKOFF = 3; - private static final Duration BACKOFF_WINDOW = Duration.ofMinutes(15); - - public PlatformFeedbackRateLimitFilter(StringRedisTemplate redis, - org.springframework.core.env.Environment env) { - this.redis = redis; - this.pepper = env.getProperty("platform.feedback.pepper", ""); - this.trustForwardedFor = Boolean.parseBoolean(env.getProperty("platform.feedback.trust-forwarded-for", "true")); - this.forwardedForHeader = env.getProperty("platform.feedback.forwarded-for-header", "X-Forwarded-For"); - } - - @Override - protected boolean shouldNotFilter(HttpServletRequest request) throws ServletException { - // Only filter specific endpoints (POST to platform-feedback). Keep it narrow. - String path = request.getRequestURI(); - String method = request.getMethod(); - // adjust path as needed (supports /common-api/platform-feedback and subpaths) - return !("POST".equalsIgnoreCase(method) && path != null && path.matches("^/platform-feedback(?:/.*)?$")); - } - - @Override - protected void doFilterInternal(HttpServletRequest request, - HttpServletResponse response, - FilterChain filterChain) throws ServletException, IOException { - // compute day key - String clientIp = extractClientIp(request); - if (clientIp == null || clientIp.isBlank()) { - // If we can't identify an IP, be conservative and allow but log (or optionally block) - filterChain.doFilter(request, response); - return; - } - - String today = LocalDate.now(ZoneId.of("Asia/Kolkata")).toString().replaceAll("-", ""); // yyyyMMdd - String ipHash = sha256Base64(clientIp + pepper + today); // base64 shorter storage; not reversible without pepper - String minKey = "rl:fb:min:" + ipHash + ":" + (System.currentTimeMillis() / 60000L); // minute-slotted - String dayKey = "rl:fb:day:" + today + ":" + ipHash; - String failKey = "rl:fb:fail:" + ipHash; - String backoffKey = "rl:fb:backoff:" + ipHash; - - // If under backoff -> respond 429 with Retry-After = TTL - Long backoffTtl = getTtlSeconds(backoffKey); - if (backoffTtl != null && backoffTtl > 0) { - sendTooMany(response, backoffTtl); - return; - } - - // Minute window check (INCR + TTL if first) - long minuteCount = incrementWithExpire(minKey, 1, MINUTE_WINDOW.getSeconds()); - if (minuteCount > MINUTE_LIMIT) { - handleFailureAndMaybeBackoff(failKey, backoffKey, response, minKey, dayKey); - return; - } - - // Day window check - long dayCount = incrementWithExpire(dayKey, 1, DAY_WINDOW.getSeconds()); - if (dayCount > DAY_LIMIT) { - handleFailureAndMaybeBackoff(failKey, backoffKey, response, minKey, dayKey); - return; - } - - // Optional: per-user daily cap if we can extract an authenticated user id from header/jwt - Integer userId = extractUserIdFromRequest(request); // implement extraction as per your JWT scheme - if (userId != null) { - String userDayKey = "rl:fb:user:" + today + ":" + userId; - long ucount = incrementWithExpire(userDayKey, 1, DAY_WINDOW.getSeconds()); - if (ucount > USER_DAY_LIMIT) { - handleFailureAndMaybeBackoff(failKey, backoffKey, response, minKey, userDayKey); - return; - } - } - - // All checks passed — proceed to controller - filterChain.doFilter(request, response); - } - - // increments key by delta; sets TTL when key is new (INCR returns 1) - private long incrementWithExpire(String key, long delta, long ttlSeconds) { - Long value = redis.opsForValue().increment(key, delta); - if (value != null && value == 1L) { - redis.expire(key, ttlSeconds, TimeUnit.SECONDS); - } - return value == null ? 0L : value; - } - - private void handleFailureAndMaybeBackoff(String failKey, String backoffKey, HttpServletResponse response, String trigKey, String dayKey) throws IOException { - // increment fail counter and possibly set backoff - Long fails = redis.opsForValue().increment(failKey, 1); - if (fails != null && fails == 1L) { - redis.expire(failKey, FAIL_COUNT_WINDOW.getSeconds(), TimeUnit.SECONDS); - } - if (fails != null && fails >= FAILS_TO_BACKOFF) { - // set backoff flag - redis.opsForValue().set(backoffKey, "1", BACKOFF_WINDOW.getSeconds(), TimeUnit.SECONDS); - sendTooMany(response, BACKOFF_WINDOW.getSeconds()); - return; - } - - // otherwise respond with Retry-After for the triggering key TTL (minute/day) - Long retryAfter = getTtlSeconds(trigKey); - if (retryAfter == null || retryAfter <= 0) retryAfter = 60L; - sendTooMany(response, retryAfter); - } - - private void sendTooMany(HttpServletResponse response, long retryAfterSeconds) throws IOException { - response.setStatus(429); - response.setHeader("Retry-After", String.valueOf(retryAfterSeconds)); - response.setContentType(MediaType.APPLICATION_JSON_VALUE); - String body = String.format("{\"code\":\"RATE_LIMITED\",\"message\":\"Too many requests\",\"retryAfter\":%d}", retryAfterSeconds); - response.getWriter().write(body); - } - - private Long getTtlSeconds(String key) { - Long ttl = redis.getExpire(key, TimeUnit.SECONDS); - return ttl == null || ttl < 0 ? null : ttl; - } - - private String extractClientIp(HttpServletRequest request) { - if (trustForwardedFor) { - String header = request.getHeader(forwardedForHeader); - if (StringUtils.hasText(header)) { - // X-Forwarded-For may contain comma-separated list; take the first (client) entry - String[] parts = header.split(","); - if (parts.length > 0) { - String ip = parts[0].trim(); - if (StringUtils.hasText(ip)) return ip; - } - } - } - return request.getRemoteAddr(); - } - - private Integer extractUserIdFromRequest(HttpServletRequest request) { - // implement based on how you propagate JWT or user info. - // Example: if your gateway injects header X-User-Id for authenticated requests: - String s = request.getHeader("X-User-Id"); - if (StringUtils.hasText(s)) { - try { return Integer.valueOf(s); } catch (NumberFormatException ignored) {} - } - // If JWT parsing required, do it here, but keep this filter light — prefer upstream auth filter to populate a header. - return null; - } - - private static String sha256Base64(String input) { - try { - MessageDigest digest = MessageDigest.getInstance("SHA-256"); - byte[] hashed = digest.digest(input.getBytes(StandardCharsets.UTF_8)); - // base64 url-safe or normal base64 — either is fine; base64 is shorter than hex - return Base64.getUrlEncoder().withoutPadding().encodeToString(hashed); - } catch (Exception ex) { - throw new RuntimeException("sha256 failure", ex); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/iemr/common/repository/dynamic_form/FieldRepository.java b/src/main/java/com/iemr/common/repository/dynamic_form/FieldRepository.java index 50e84248..4aea5698 100644 --- a/src/main/java/com/iemr/common/repository/dynamic_form/FieldRepository.java +++ b/src/main/java/com/iemr/common/repository/dynamic_form/FieldRepository.java @@ -9,10 +9,4 @@ @Repository public interface FieldRepository extends JpaRepository { List findByForm_FormIdOrderBySequenceAsc(String formId); - List findByForm_FormIdAndStateCodeOrderBySequenceAsc( - String formId, - Integer stateCode - ); - - } diff --git a/src/main/java/com/iemr/common/repository/platform_feedback/PlatformFeedbackCategoryRepository.java b/src/main/java/com/iemr/common/repository/platform_feedback/PlatformFeedbackCategoryRepository.java deleted file mode 100644 index 43096490..00000000 --- a/src/main/java/com/iemr/common/repository/platform_feedback/PlatformFeedbackCategoryRepository.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * AMRIT – Accessible Medical Records via Integrated Technology - * Integrated EHR (Electronic Health Records) Solution - * - * Copyright (C) "Piramal Swasthya Management and Research Institute" - * - * This file is part of AMRIT. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see https://www.gnu.org/licenses/. - */ -package com.iemr.common.repository.platform_feedback; - -import java.util.List; -import java.util.Optional; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; -import com.iemr.common.data.platform_feedback.FeedbackCategory; - -@Repository -public interface PlatformFeedbackCategoryRepository extends JpaRepository { - Optional findBySlugIgnoreCase(String slug); - List findByActiveTrueOrderByLabelAsc(); -} diff --git a/src/main/java/com/iemr/common/repository/platform_feedback/PlatformFeedbackRepository.java b/src/main/java/com/iemr/common/repository/platform_feedback/PlatformFeedbackRepository.java deleted file mode 100644 index 020a7997..00000000 --- a/src/main/java/com/iemr/common/repository/platform_feedback/PlatformFeedbackRepository.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * AMRIT – Accessible Medical Records via Integrated Technology - * Integrated EHR (Electronic Health Records) Solution - * - * Copyright (C) "Piramal Swasthya Management and Research Institute" - * - * This file is part of AMRIT. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see https://www.gnu.org/licenses/. - */ -package com.iemr.common.repository.platform_feedback; - -import com.iemr.common.data.platform_feedback.Feedback; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -@Repository -public interface PlatformFeedbackRepository extends JpaRepository { -} diff --git a/src/main/java/com/iemr/common/repository/translation/TranslationRepo.java b/src/main/java/com/iemr/common/repository/translation/TranslationRepo.java index 139b5ee9..f6a5dcb0 100644 --- a/src/main/java/com/iemr/common/repository/translation/TranslationRepo.java +++ b/src/main/java/com/iemr/common/repository/translation/TranslationRepo.java @@ -10,5 +10,4 @@ public interface TranslationRepo extends JpaRepository { Optional findByLabelKeyAndIsActive(String labelKey, boolean isActive); - } diff --git a/src/main/java/com/iemr/common/repository/users/IEMRUserRepositoryCustom.java b/src/main/java/com/iemr/common/repository/users/IEMRUserRepositoryCustom.java index cc1abccc..3ee48ab3 100644 --- a/src/main/java/com/iemr/common/repository/users/IEMRUserRepositoryCustom.java +++ b/src/main/java/com/iemr/common/repository/users/IEMRUserRepositoryCustom.java @@ -78,7 +78,4 @@ UserSecurityQMapping verifySecurityQuestionAnswers(@Param("UserID") Long UserID, User findByUserID(Long userID); - @Query("SELECT u FROM User u WHERE LOWER(u.userName) = LOWER(:userName)") - List findUserName(@Param("userName") String username); - } diff --git a/src/main/java/com/iemr/common/repository/users/UserServiceRoleRepo.java b/src/main/java/com/iemr/common/repository/users/UserServiceRoleRepo.java index d4ed3ed3..ee7db934 100644 --- a/src/main/java/com/iemr/common/repository/users/UserServiceRoleRepo.java +++ b/src/main/java/com/iemr/common/repository/users/UserServiceRoleRepo.java @@ -10,8 +10,7 @@ @Repository public interface UserServiceRoleRepo extends JpaRepository { - List findByUserName(String userName); - - + UserServiceRole findByUserName(String userName); + UserServiceRole findByUserId(Integer userId); } diff --git a/src/main/java/com/iemr/common/service/beneficiary/IEMRSearchUserService.java b/src/main/java/com/iemr/common/service/beneficiary/IEMRSearchUserService.java index e39cfcab..6e7848cd 100644 --- a/src/main/java/com/iemr/common/service/beneficiary/IEMRSearchUserService.java +++ b/src/main/java/com/iemr/common/service/beneficiary/IEMRSearchUserService.java @@ -38,10 +38,6 @@ String findByBeneficiaryPhoneNo(BenPhoneMap benPhoneMap, Integer pageNo, Integer String findBeneficiary(BeneficiaryModel request, String auth) throws Exception; - String searchUser(String searchQuery, Integer userId, String auth, Boolean is1097) throws Exception; - - String findBeneficiaryES(BeneficiaryModel i_beneficiary, Integer userId, String auth) throws Exception; - List userExitsCheckWithId(String beneficiaryID, String auth, Boolean is1097) throws Exception; public List userExitsCheckWithHealthId_ABHAId(String healthID, String auth, Boolean is1097) diff --git a/src/main/java/com/iemr/common/service/beneficiary/IEMRSearchUserServiceImpl.java b/src/main/java/com/iemr/common/service/beneficiary/IEMRSearchUserServiceImpl.java index 28d664c8..f67d7815 100644 --- a/src/main/java/com/iemr/common/service/beneficiary/IEMRSearchUserServiceImpl.java +++ b/src/main/java/com/iemr/common/service/beneficiary/IEMRSearchUserServiceImpl.java @@ -25,7 +25,6 @@ import java.sql.Timestamp; import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.Objects; import org.slf4j.Logger; @@ -77,7 +76,7 @@ import com.iemr.common.repository.userbeneficiarydata.MaritalStatusRepository; import com.iemr.common.repository.userbeneficiarydata.SexualOrientationRepository; import com.iemr.common.repository.userbeneficiarydata.TitleRepository; -import com.iemr.common.utils.exception.IEMRException; +import com.iemr.common.utils.mapper.OutputMapper; /** * @@ -199,7 +198,7 @@ private void addCreatedDateToOtherFields(BeneficiaryModel beneficiaryModel) { JsonNode otherFieldsNode = objectMapper.readTree(beneficiaryModel.getOtherFields()); // Convert createdDate to a string - String createdDateString = beneficiaryModel.getCreatedDate().toString(); + String createdDateString = beneficiaryModel.getCreatedDate().toString(); // Add createdDate to the JSON node ((ObjectNode) otherFieldsNode).put("createdDate", createdDateString); @@ -220,10 +219,10 @@ public List userExitsCheckWithHealthId_ABHAId(String healthID, List beneficiaryList = new ArrayList(); // search patient by ben id, call Identity API List listBen = null; - if (healthID.contains("@")) { + if(healthID.contains("@")) { listBen = identityBeneficiaryService.getBeneficiaryListByHealthID_ABHAAddress(healthID, auth, is1097); - } else { + }else { String healthIdNumber = getHealthId(healthID); listBen = identityBeneficiaryService.getBeneficiaryListByHealthIDNo_ABHAIDNo(healthIdNumber, auth, is1097); } @@ -233,7 +232,6 @@ public List userExitsCheckWithHealthId_ABHAId(String healthID, } return beneficiaryList; } - private String getHealthId(String healthID) { String healthIdNumber = null; if (null != healthID) { @@ -251,7 +249,6 @@ private String getHealthId(String healthID) { } return healthIdNumber; } - // search patient by healthidNo / ABHA Id No @Override public List userExitsCheckWithHealthIdNo_ABHAIdNo(String healthIDNo, String auth, Boolean is1097) @@ -325,90 +322,6 @@ private void setBeneficiaryGender(List iBeneficiary) { } - /** - * Universal search using Elasticsearch - */ - @Override - public String searchUser(String searchQuery, Integer userId, String auth, Boolean is1097) throws Exception { - - try { - if (searchQuery == null || searchQuery.trim().isEmpty()) { - throw new IEMRException("Search query is required"); - } - - logger.info("Universal search with query: {}, userId: {}", searchQuery, userId); - - Map response = identityBeneficiaryService.searchBeneficiariesUsingES( - searchQuery, userId, auth, is1097); - - ObjectMapper mapper = new ObjectMapper(); - return mapper.writeValueAsString(response); - - } catch (Exception e) { - logger.error("Error in universal search", e); - throw new Exception("Error searching beneficiaries: " + e.getMessage(), e); - } - } - - /** - * Advanced search using Elasticsearch with multiple criteria - */ - - @Override - public String findBeneficiaryES( - BeneficiaryModel i_beneficiary, - Integer userId, - String auth) throws Exception { - - try { - IdentitySearchDTO identitySearchDTO = identityBenEditMapper.getidentitysearchModel(i_beneficiary); - - if (i_beneficiary.getDOB() != null) { - identitySearchDTO.setDob(i_beneficiary.getDOB()); - } - - if (i_beneficiary.getHouseHoldID() != null) { - identitySearchDTO.setHouseHoldID(i_beneficiary.getHouseHoldID()); - } - - if (i_beneficiary.getIsD2D() != null) { - identitySearchDTO.setIsD2D(i_beneficiary.getIsD2D()); - } - - if (i_beneficiary.getBenPhoneMaps() != null - && !i_beneficiary.getBenPhoneMaps().isEmpty()) { - identitySearchDTO.setContactNumber( - i_beneficiary.getBenPhoneMaps().get(0).getPhoneNo()); - } - - if (i_beneficiary.getBeneficiaryID() != null - && !i_beneficiary.getBeneficiaryID().isEmpty()) { - identitySearchDTO.setBeneficiaryId( - new BigInteger(i_beneficiary.getBeneficiaryID())); - } - - i_beneficiary.setIs1097(Boolean.TRUE.equals(i_beneficiary.getIs1097())); - - Gson gson = new GsonBuilder() - .setDateFormat("yyyy-MM-dd") - .create(); - - String requestJson = gson.toJson(identitySearchDTO); - - Map response = identityBeneficiaryService.searchBeneficiaryListES( - requestJson, - auth, - i_beneficiary.getIs1097()); - - ObjectMapper mapper = new ObjectMapper(); - return mapper.writeValueAsString(response); - - } catch (Exception e) { - logger.error("Error in ES advance search", e); - throw new Exception("Error searching beneficiaries using ES", e); - } - } - // Advance search @Override public String findBeneficiary(BeneficiaryModel i_beneficiary, String auth) throws Exception { @@ -451,7 +364,7 @@ public String findBeneficiary(BeneficiaryModel i_beneficiary, String auth) throw + (beneficiaryList != null ? beneficiaryList.size() : "No Beneficiary Found")); ObjectMapper mapper = new ObjectMapper(); return mapper.writeValueAsString(beneficiaryList); - + } // get response mapper @@ -461,7 +374,7 @@ public List getBeneficiaryListFromMapper(List { BeneficiaryModel beneficiary = benCompleteMapper.benDetailForOutboundDTOToIBeneficiary(beneficiaryModel); - if (null != beneficiaryModel && null != beneficiaryModel.getBeneficiaryDetails()) { + if(null != beneficiaryModel && null != beneficiaryModel.getBeneficiaryDetails()) { beneficiary.setCommunityName(beneficiaryModel.getBeneficiaryDetails().getCommunity()); beneficiary.setReligion(beneficiaryModel.getBeneficiaryDetails().getReligion()); beneficiary.setReligionName(beneficiaryModel.getBeneficiaryDetails().getReligion()); diff --git a/src/main/java/com/iemr/common/service/beneficiary/IdentityBeneficiaryService.java b/src/main/java/com/iemr/common/service/beneficiary/IdentityBeneficiaryService.java index 41a132b0..8b84bc8a 100644 --- a/src/main/java/com/iemr/common/service/beneficiary/IdentityBeneficiaryService.java +++ b/src/main/java/com/iemr/common/service/beneficiary/IdentityBeneficiaryService.java @@ -23,7 +23,6 @@ import java.util.HashSet; import java.util.List; -import java.util.Map; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonMappingException; @@ -54,8 +53,6 @@ List getBeneficiaryListByBenRegID(Long benRegId, String auth, List searchBeneficiaryList(String identitySearchDTO, String auth, Boolean is1097) throws IEMRException; - public Map searchBeneficiaryListES(String identitySearchDTO, String auth, Boolean is1097) throws IEMRException ; - Integer editIdentityEditDTOCommunityorEducation(IdentityEditDTO identityEditDTO, String auth, Boolean is1097) throws IEMRException; @@ -72,8 +69,4 @@ public List getBeneficiaryListByFamilyId(String familyId, Stri public List getBeneficiaryListByGovId(String identity, String auth, Boolean is1097) throws IEMRException; - - public Map searchBeneficiariesUsingES(String query, Integer userId, String auth, Boolean is1097) throws IEMRException; - - } diff --git a/src/main/java/com/iemr/common/service/beneficiary/IdentityBeneficiaryServiceImpl.java b/src/main/java/com/iemr/common/service/beneficiary/IdentityBeneficiaryServiceImpl.java index 350f2527..2e6ac1d4 100644 --- a/src/main/java/com/iemr/common/service/beneficiary/IdentityBeneficiaryServiceImpl.java +++ b/src/main/java/com/iemr/common/service/beneficiary/IdentityBeneficiaryServiceImpl.java @@ -21,19 +21,15 @@ */ package com.iemr.common.service.beneficiary; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; -import java.util.Map; import com.google.gson.*; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import com.iemr.common.dto.identity.BeneficiariesDTO; @@ -47,12 +43,6 @@ import com.iemr.common.utils.mapper.OutputMapper; import com.iemr.common.utils.response.OutputResponse; -import org.springframework.beans.factory.annotation.Value; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - @Service public class IdentityBeneficiaryServiceImpl implements IdentityBeneficiaryService { @@ -69,10 +59,12 @@ public class IdentityBeneficiaryServiceImpl implements IdentityBeneficiaryServic private static final String IDENTITY_BASE_URL = "IDENTITY_BASE_URL"; @Value("${genben-api}") - private String BEN_GEN; + private String BEN_GEN ; + @Value("${generateBeneficiaryIDs-api-url}") - private String BEN_GEN_API_URL; + private String BEN_GEN_API_URL ; + @Override // public List getBeneficiaryListByIDs() {// search by regID @@ -96,10 +88,13 @@ public List getBeneficiaryListByIDs(HashSet benIdList, String } if (null != result) { JsonObject responseObj = (JsonObject) parser.parse(result); + // JsonArray data = (JsonArray) parser.parse( JsonObject data1 = (JsonObject) responseObj.get("response"); String s = data1.get("data").getAsString(); JsonArray responseArray = parser.parse(s).getAsJsonArray(); + // String data="s"; + // JsonArray responseArray = (JsonArray) parser.parse(data); for (JsonElement jsonElement : responseArray) { @@ -112,79 +107,10 @@ public List getBeneficiaryListByIDs(HashSet benIdList, String return listBenDetailForOutboundDTO; } - /** - * Call Identity API's Elasticsearch universal search - */ - @Override - public Map searchBeneficiariesUsingES(String query, Integer userId, String auth, Boolean is1097) - throws IEMRException { - - Map response = new HashMap<>(); - - try { - HashMap headers = new HashMap<>(); - if (auth != null && !auth.isEmpty()) { - headers.put("Authorization", auth); - } - - String baseUrl = ConfigProperties - .getPropertyByName("identity-api-url-searchByES") - .replace( - IDENTITY_BASE_URL, - (Boolean.TRUE.equals(is1097)) ? identity1097BaseURL : identityBaseURL - ); - - StringBuilder url = new StringBuilder(baseUrl) - .append("?query=").append(URLEncoder.encode(query, StandardCharsets.UTF_8)); - - if (userId != null) { - url.append("&userId=").append(userId); - } - - logger.info("Calling Identity ES search URL: {}", url); - - String result = httpUtils.get(url.toString()); - - if (result == null || result.isEmpty()) { - response.put("data", Collections.emptyList()); - response.put("statusCode", 200); - response.put("status", "Success"); - response.put("errorMessage", "Success"); - return response; - } - - ObjectMapper mapper = new ObjectMapper(); - - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false); - - JsonNode rootNode = mapper.readTree(result); - - if (rootNode.has("statusCode") && rootNode.get("statusCode").asInt() != 200) { - String errMsg = rootNode.has("errorMessage") - ? rootNode.get("errorMessage").asText() - : "Identity ES search failed"; - throw new IEMRException(errMsg); - } - - response.put("data", rootNode.path("data")); - response.put("statusCode", 200); - response.put("status", "Success"); - response.put("errorMessage", "Success"); - - return response; - - } catch (IEMRException e) { - throw e; - } catch (Exception e) { - logger.error("Error calling Identity ES search API", e); - throw new IEMRException("Error calling Identity ES search API"); - } - } - @Override public List getPartialBeneficiaryListByIDs(HashSet benIdList, String auth, Boolean is1097) throws IEMRException { + // TODO Auto-generated method stub List listBenDetailForOutboundDTO = new ArrayList<>(); JsonParser parser = new JsonParser(); @@ -204,10 +130,13 @@ public List getPartialBeneficiaryListByIDs(HashSet benI throw new IEMRException(identityResponse.getErrorMessage()); } JsonObject responseObj = (JsonObject) parser.parse(result); + // JsonArray data = (JsonArray) parser.parse( JsonObject data1 = (JsonObject) responseObj.get("response"); String s = data1.get("data").getAsString(); JsonArray responseArray = parser.parse(s).getAsJsonArray(); + // String data="s"; + // JsonArray responseArray = (JsonArray) parser.parse(data); for (JsonElement jsonElement : responseArray) { @@ -222,9 +151,6 @@ public List getPartialBeneficiaryListByIDs(HashSet benI // search beneficiaries by phone number public List getBeneficiaryListByPhone(String phoneNo, String auth, Boolean is1097) throws IEMRException { - logger.info("Phone no from getBeneficiaryListByPhone: " + phoneNo); - String cleanedPhoneNo = cleanPhoneNumber(phoneNo); - logger.info("Cleaned phone no: " + cleanedPhoneNo); List listBenDetailForOutboundDTO = new ArrayList<>(); @@ -236,13 +162,8 @@ public List getBeneficiaryListByPhone(String phoneNo, String a if (auth != null) { header.put("Authorization", auth); } - - logger.info("Result=" + (ConfigProperties.getPropertyByName("identity-api-url-getByPhoneNum") - .replace(IDENTITY_BASE_URL, (is1097 ? identity1097BaseURL : identityBaseURL))) + cleanedPhoneNo); - result = httpUtils.post((ConfigProperties.getPropertyByName("identity-api-url-getByPhoneNum") - .replace(IDENTITY_BASE_URL, (is1097 ? identity1097BaseURL : identityBaseURL))) + cleanedPhoneNo, "", - header); + .replace(IDENTITY_BASE_URL, (is1097 ? identity1097BaseURL : identityBaseURL))) + phoneNo, "", header); OutputResponse identityResponse = InputMapper.gson().fromJson(result, OutputResponse.class); if (identityResponse.getStatusCode() == OutputResponse.USERID_FAILURE) { @@ -262,25 +183,6 @@ public List getBeneficiaryListByPhone(String phoneNo, String a return listBenDetailForOutboundDTO; } - private String cleanPhoneNumber(String phoneNumber) { - if (phoneNumber == null || phoneNumber.trim().isEmpty()) { - return phoneNumber; - } - - String cleaned = phoneNumber.trim(); - - // Remove +91 prefix - if (cleaned.startsWith("+91")) { - cleaned = cleaned.substring(3); - } - // Remove 91 prefix if it's a 12-digit number (91 + 10 digit mobile) - else if (cleaned.startsWith("91") && cleaned.length() == 12) { - cleaned = cleaned.substring(2); - } - - return cleaned.trim(); - } - @Override // search beneficiary by beneficiary id public List getBeneficiaryListByBenID(String benId, String auth, Boolean is1097) @@ -525,6 +427,7 @@ public String getIdentityResponse(String request, String auth, Boolean is1097) t return result; } + public Integer editIdentityEditDTO(IdentityEditDTO identityEditDTO, String auth, Boolean is1097) throws IEMRException { JsonParser parser = new JsonParser(); @@ -569,10 +472,13 @@ public List searchBeneficiaryList(String identitySearchDTO, St IDENTITY_BASE_URL, (is1097 ? identity1097BaseURL : identityBaseURL)), identitySearchDTO, header); JsonObject responseObj = (JsonObject) parser.parse(result); + // JsonArray data = (JsonArray) parser.parse( JsonObject data1 = (JsonObject) responseObj.get("response"); String s = data1.get("data").getAsString(); JsonArray responseArray = parser.parse(s).getAsJsonArray(); + // String data="s"; + // JsonArray responseArray = (JsonArray) parser.parse(data); for (JsonElement jsonElement : responseArray) { @@ -584,68 +490,6 @@ public List searchBeneficiaryList(String identitySearchDTO, St return listBenDetailForOutboundDTO; } - @Override - public Map searchBeneficiaryListES(String identitySearchDTO, String auth, Boolean is1097) - throws IEMRException { - - Map response = new HashMap<>(); - - try { - HashMap headers = new HashMap<>(); - if (auth != null && !auth.isEmpty()) { - headers.put("Authorization", auth); - } - - String url = ConfigProperties - .getPropertyByName("identity-api-url-advancesearch-es") - .replace( - IDENTITY_BASE_URL, - Boolean.TRUE.equals(is1097) - ? identity1097BaseURL - : identityBaseURL); - - logger.info("Calling Identity ES Advance Search API"); - - String result = httpUtils.post(url, identitySearchDTO, headers); - - if (result == null || result.isEmpty()) { - response.put("data", Collections.emptyList()); - response.put("statusCode", 200); - response.put("status", "Success"); - response.put("errorMessage", "Success"); - return response; - } - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - JsonNode rootNode = mapper.readTree(result); - - if (rootNode.has("statusCode") - && rootNode.get("statusCode").asInt() != 200) { - - String errMsg = rootNode.has("errorMessage") - ? rootNode.get("errorMessage").asText() - : "Identity ES advance search failed"; - - throw new IEMRException(errMsg); - } - - response.put("data", rootNode.path("data")); - response.put("statusCode", 200); - response.put("status", "Success"); - response.put("errorMessage", "Success"); - - return response; - - } catch (IEMRException e) { - throw e; - } catch (Exception e) { - logger.error("Error calling Identity ES advance search API", e); - throw new IEMRException("Error calling Identity ES advance search API", e); - } - } - @Override public Integer editIdentityEditDTOCommunityorEducation(IdentityEditDTO identityEditDTO, String auth, Boolean is1097) throws IEMRException { @@ -685,11 +529,11 @@ public List generateBeneficiaryIDs(String request, String a if (auth != null) { header.put("Authorization", auth); } - + logger.info("Request to generate ben IDs: " + request); logger.info("Generating ben IDs API URL: " + BEN_GEN + BEN_GEN_API_URL); result = httpUtils.post(BEN_GEN + BEN_GEN_API_URL, request, header); - logger.info("Response from generate ben IDs: " + result); +logger.info("Response from generate ben IDs: " + result); OutputResponse identityResponse = inputMapper.gson().fromJson(result, OutputResponse.class); if (identityResponse.getStatusCode() == OutputResponse.USERID_FAILURE) { @@ -711,4 +555,4 @@ public List generateBeneficiaryIDs(String request, String a return listBen; } -} \ No newline at end of file +} diff --git a/src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java b/src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java index 1dd0b533..54637a4c 100644 --- a/src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java +++ b/src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java @@ -29,7 +29,6 @@ import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.CompletableFuture; import com.iemr.common.model.beneficiary.RMNCHBeneficiaryDetailsRmnch; import com.iemr.common.service.welcomeSms.WelcomeBenificarySmsService; @@ -141,7 +140,18 @@ public Integer updateBenificiary(BeneficiaryModel benificiaryDetails, String aut //updateDeathOfBenificiary(benificiaryDetails); return updatedRows; } - + private void updateDeathOfBenificiary(BeneficiaryModel beneficiaryModel){ + RMNCHBeneficiaryDetailsRmnch rmnchBeneficiaryDetailsRmnch = new RMNCHBeneficiaryDetailsRmnch(); + rmnchBeneficiaryDetailsRmnch.setIsDeath(beneficiaryModel.getIsDeath()); + rmnchBeneficiaryDetailsRmnch.setPlaceOfDeathId(beneficiaryModel.getPlaceOfDeathId()); + rmnchBeneficiaryDetailsRmnch.setPlaceOfDeath(beneficiaryModel.getPlaceOfDeath()); + rmnchBeneficiaryDetailsRmnch.setOtherPlaceOfDeath(beneficiaryModel.getOtherPlaceOfDeath()); + rmnchBeneficiaryDetailsRmnch.setReasonOfDeath(beneficiaryModel.getReasonOfDeath()); + rmnchBeneficiaryDetailsRmnch.setTimeOfDeath(beneficiaryModel.getTimeOfDeath()); + rmnchBeneficiaryDetailsRmnch.setDateOfDeath(beneficiaryModel.getDateOfDeath()); + + //beneficiaryDetailsRmnchRepository.save(rmnchBeneficiaryDetailsRmnch); + } private void setDemographicDetails(IdentityEditDTO identityEditDTO, BeneficiaryModel benificiaryDetails) { if(null != benificiaryDetails.getI_bendemographics()) { @@ -224,27 +234,9 @@ public String save(BeneficiaryModel beneficiaryModel, HttpServletRequest servlet } else { return response.toString(); } - // ========== SEND SMS BUT DON'T FAIL IF IT ERRORS ========== - if (beneficiary != null && beneficiary.getBenPhoneMaps() != null && !beneficiary.getBenPhoneMaps().isEmpty()) { - String phoneNo = beneficiary.getBenPhoneMaps().get(0).getPhoneNo(); - - if (phoneNo != null && !phoneNo.trim().isEmpty()) { - String beneficiaryName = (beneficiary.getFirstName() != null ? beneficiary.getFirstName() : "") + " " + - (beneficiary.getLastName() != null ? beneficiary.getLastName() : ""); - - try { - logger.info("[SMS] Attempting to send welcome SMS to: " + phoneNo); - String smsResult = welcomeBenificarySmsService.sendWelcomeSMStoBenificiary( - phoneNo, - beneficiaryName.trim(), - beneficiary.getBeneficiaryID() - ); - logger.info("[SMS] Result: " + smsResult); - } catch (Exception smsError) { - // SMS failed but beneficiary is already created - don't fail the request - logger.warn("[SMS] Failed to send SMS: " + smsError.getMessage() + - " - But beneficiary already created successfully"); - } + if(beneficiary!=null){ + if(beneficiary.getBenPhoneMaps().get(0).getPhoneNo()!=null){ + welcomeBenificarySmsService.sendWelcomeSMStoBenificiary(beneficiary.getBenPhoneMaps().get(0).getPhoneNo(),beneficiary.getFirstName()+" "+beneficiary.getLastName(),beneficiary.getBeneficiaryID()); } } diff --git a/src/main/java/com/iemr/common/service/callhandling/CalltypeServiceImpl.java b/src/main/java/com/iemr/common/service/callhandling/CalltypeServiceImpl.java index 7d2d7e62..1cf9ce32 100644 --- a/src/main/java/com/iemr/common/service/callhandling/CalltypeServiceImpl.java +++ b/src/main/java/com/iemr/common/service/callhandling/CalltypeServiceImpl.java @@ -42,14 +42,11 @@ import com.iemr.common.data.notification.Notification; import com.iemr.common.repository.callhandling.IEMRCalltypeRepositoryImplCustom; import com.iemr.common.utils.exception.IEMRException; -import com.iemr.common.utils.mapper.CallTypeMapper; import com.iemr.common.utils.mapper.InputMapper; @Service -public class CalltypeServiceImpl implements CalltypeService { - - @Autowired - private CallTypeMapper callTypeMapper; +public class CalltypeServiceImpl implements CalltypeService +{ private Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); InputMapper inputMapper = new InputMapper(); @@ -58,8 +55,9 @@ public class CalltypeServiceImpl implements CalltypeService { private IEMRCalltypeRepositoryImplCustom iEMRCalltypeRepositoryImplCustom; @Override - public List getAllCalltypes(String request) throws IEMRException { - CallType provider = callTypeMapper.fromJson(request, CallType.class); + public List getAllCalltypes(String request) throws IEMRException + { + CallType provider = inputMapper.gson().fromJson(request, CallType.class); List callTypes = new ArrayList(); Set callTypesArray = new HashSet(); if (provider.getIsInbound() != null && provider.getIsOutbound() != null) diff --git a/src/main/java/com/iemr/common/service/dynamicForm/FormMasterService.java b/src/main/java/com/iemr/common/service/dynamicForm/FormMasterService.java index 78b5520f..2f7360b8 100644 --- a/src/main/java/com/iemr/common/service/dynamicForm/FormMasterService.java +++ b/src/main/java/com/iemr/common/service/dynamicForm/FormMasterService.java @@ -18,7 +18,5 @@ public interface FormMasterService { FormResponseDTO getStructuredFormByFormId(String formId,String lang,String token); - - void deleteField(Long fieldId); } diff --git a/src/main/java/com/iemr/common/service/dynamicForm/FormMasterServiceImpl.java b/src/main/java/com/iemr/common/service/dynamicForm/FormMasterServiceImpl.java index ab71eed9..76a414a3 100644 --- a/src/main/java/com/iemr/common/service/dynamicForm/FormMasterServiceImpl.java +++ b/src/main/java/com/iemr/common/service/dynamicForm/FormMasterServiceImpl.java @@ -117,17 +117,12 @@ public FormField updateField(FieldDTO dto) { @Override public FormResponseDTO getStructuredFormByFormId(String formId,String lang,String token) { int stateId =0 ; + try { - if(!token.isEmpty()){ - List userServiceRole= userServiceRoleRepo.findByUserName(jwtUtil.getUsernameFromToken(token)); - if(userServiceRole!=null){ - stateId = userServiceRole.get(0).getStateId(); - logger.info("State:Id"+stateId); - } + UserServiceRole userServiceRole= userServiceRoleRepo.findByUserName(jwtUtil.getUsernameFromToken(token)); + if(userServiceRole!=null){ + stateId = userServiceRole.getStateId(); } - - - FormDefinition form = formRepo.findByFormId(formId) .orElseThrow(() -> new IllegalArgumentException("Invalid form ID")); @@ -135,7 +130,7 @@ public FormResponseDTO getStructuredFormByFormId(String formId,String lang,Strin ObjectMapper objectMapper = new ObjectMapper(); int finalStateId = stateId; - List fieldDtos = fields.stream().filter(formField -> (formField.getStateCode()==0 || formField.getStateCode().equals(finalStateId))) + List fieldDtos = fields.stream().filter(formField -> formField.getStateCode()== 0 || formField.getStateCode()== finalStateId) .map(field -> { String labelKey = field.getFieldId(); // field label already contains label_key diff --git a/src/main/java/com/iemr/common/service/platform_feedback/PlatformFeedbackService.java b/src/main/java/com/iemr/common/service/platform_feedback/PlatformFeedbackService.java deleted file mode 100644 index c4cccb42..00000000 --- a/src/main/java/com/iemr/common/service/platform_feedback/PlatformFeedbackService.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * AMRIT – Accessible Medical Records via Integrated Technology - * Integrated EHR (Electronic Health Records) Solution - * - * Copyright (C) "Piramal Swasthya Management and Research Institute" - * - * This file is part of AMRIT. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see https://www.gnu.org/licenses/. - */ -package com.iemr.common.service.platform_feedback; - -import com.iemr.common.data.platform_feedback.Feedback; -import com.iemr.common.data.platform_feedback.FeedbackCategory; -import com.iemr.common.dto.platform_feedback.CategoryResponse; -import com.iemr.common.dto.platform_feedback.FeedbackRequest; -import com.iemr.common.dto.platform_feedback.FeedbackResponse; -import com.iemr.common.repository.platform_feedback.PlatformFeedbackCategoryRepository; -import com.iemr.common.repository.platform_feedback.PlatformFeedbackRepository; -import com.iemr.common.exception.BadRequestException; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import java.time.LocalDateTime; -import java.util.List; -import java.util.UUID; - -@Service -public class PlatformFeedbackService { - - private final PlatformFeedbackRepository feedbackRepo; - private final PlatformFeedbackCategoryRepository categoryRepo; - - public PlatformFeedbackService(PlatformFeedbackRepository feedbackRepo, - PlatformFeedbackCategoryRepository categoryRepo) { - this.feedbackRepo = feedbackRepo; - this.categoryRepo = categoryRepo; - } - - @Transactional - public FeedbackResponse submitFeedback(FeedbackRequest req) { - // basic validations - if (req.rating() < 1 || req.rating() > 5) { - throw new BadRequestException("rating must be between 1 and 5"); - } - if (!req.isAnonymous() && req.userId() == null) { - throw new BadRequestException("userId required when isAnonymous=false"); - } - - FeedbackCategory category = resolveCategory(req.categoryId(), req.categorySlug(), req.serviceLine()); - - Feedback fb = new Feedback(); - fb.setFeedbackId(UUID.randomUUID().toString()); - fb.setCreatedAt(LocalDateTime.now()); - fb.setUpdatedAt(LocalDateTime.now()); - fb.setRating(req.rating()); - fb.setComment(req.comment() == null ? "" : req.comment()); - fb.setServiceLine(req.serviceLine()); - fb.setAnonymous(req.isAnonymous()); - fb.setCategory(category); - fb.setUserId(req.userId()); - - feedbackRepo.save(fb); - return new FeedbackResponse(fb.getFeedbackId(), fb.getCreatedAt()); - } - - private FeedbackCategory resolveCategory(String categoryId, String categorySlug, String serviceLine) { - if (categoryId != null && categorySlug != null) { - FeedbackCategory byId = categoryRepo.findById(categoryId) - .orElseThrow(() -> new BadRequestException("invalid categoryId")); - if (!byId.getSlug().equalsIgnoreCase(categorySlug)) { - throw new BadRequestException("categoryId and categorySlug mismatch"); - } - if (!byId.isActive()) throw new BadRequestException("category inactive"); - // optional: check scope matches serviceLine or GLOBAL - return byId; - } - - if (categoryId != null) { - FeedbackCategory byId = categoryRepo.findById(categoryId) - .orElseThrow(() -> new BadRequestException("invalid categoryId")); - if (!byId.isActive()) throw new BadRequestException("category inactive"); - return byId; - } - - if (categorySlug != null) { - FeedbackCategory bySlug = categoryRepo.findBySlugIgnoreCase(categorySlug) - .orElseThrow(() -> new BadRequestException("invalid categorySlug")); - if (!bySlug.isActive()) throw new BadRequestException("category inactive"); - return bySlug; - } - - throw new BadRequestException("categoryId or categorySlug required"); - } - - @Transactional(readOnly = true) - public List listCategories(String serviceLine) { - List all = categoryRepo.findByActiveTrueOrderByLabelAsc(); - // filter by scope or return all; FE can filter further - return all.stream() - .filter(c -> "GLOBAL".equals(c.getScope()) || c.getScope().equalsIgnoreCase(serviceLine)) - .map(c -> new CategoryResponse(c.getCategoryId(), c.getSlug(), c.getLabel(), c.getScope(), c.isActive())) - .toList(); - } -} diff --git a/src/main/java/com/iemr/common/service/users/EmployeeSignatureServiceImpl.java b/src/main/java/com/iemr/common/service/users/EmployeeSignatureServiceImpl.java index eff5c8e4..115970ed 100644 --- a/src/main/java/com/iemr/common/service/users/EmployeeSignatureServiceImpl.java +++ b/src/main/java/com/iemr/common/service/users/EmployeeSignatureServiceImpl.java @@ -33,6 +33,8 @@ public class EmployeeSignatureServiceImpl implements EmployeeSignatureService { @Autowired EmployeeSignatureRepo employeeSignatureRepo; + + @Override public EmployeeSignature fetchSignature(Long userSignID) { // TODO Auto-generated method stub @@ -42,12 +44,12 @@ public EmployeeSignature fetchSignature(Long userSignID) { @Override public EmployeeSignature fetchActiveSignature(Long userSignID) { // New method - fetches only non-deleted records - return employeeSignatureRepo.findOneByUserID(userSignID); + return employeeSignatureRepo.findOneByUserIDAndDeleted(userSignID, false); } public Boolean existSignature(Long userID) { // TODO Auto-generated method stub - return employeeSignatureRepo.countByUserIDAndSignatureNotNull(userID) > 0; + return employeeSignatureRepo.countByUserIDAndSignatureNotNull(userID)>0; } } diff --git a/src/main/java/com/iemr/common/service/users/IEMRAdminUserService.java b/src/main/java/com/iemr/common/service/users/IEMRAdminUserService.java index 26b7bb15..d7dc6e2e 100644 --- a/src/main/java/com/iemr/common/service/users/IEMRAdminUserService.java +++ b/src/main/java/com/iemr/common/service/users/IEMRAdminUserService.java @@ -123,8 +123,6 @@ public List getUserServiceRoleMappingForProvider(Integ List getUserIdbyUserName(String userName) throws IEMRException; - List findUserIdByUserName(String userName) throws IEMRException; - } diff --git a/src/main/java/com/iemr/common/service/users/IEMRAdminUserServiceImpl.java b/src/main/java/com/iemr/common/service/users/IEMRAdminUserServiceImpl.java index 71d72c97..44bd2247 100644 --- a/src/main/java/com/iemr/common/service/users/IEMRAdminUserServiceImpl.java +++ b/src/main/java/com/iemr/common/service/users/IEMRAdminUserServiceImpl.java @@ -1224,10 +1224,4 @@ public List getUserIdbyUserName(String userName) { return iEMRUserRepositoryCustom.findByUserName(userName); } - - @Override - public List findUserIdByUserName(String userName) { - - return iEMRUserRepositoryCustom.findUserName(userName); - } } diff --git a/src/main/java/com/iemr/common/service/welcomeSms/WelcomeBenificarySmsServiceImpl.java b/src/main/java/com/iemr/common/service/welcomeSms/WelcomeBenificarySmsServiceImpl.java index a80a98e8..67b642ab 100644 --- a/src/main/java/com/iemr/common/service/welcomeSms/WelcomeBenificarySmsServiceImpl.java +++ b/src/main/java/com/iemr/common/service/welcomeSms/WelcomeBenificarySmsServiceImpl.java @@ -12,7 +12,6 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; @@ -47,57 +46,58 @@ public class WelcomeBenificarySmsServiceImpl implements WelcomeBenificarySmsServ private String smsTemplateName = "welcome_sms"; - private String smsTemplate =null; + private String smsTemplate; @Override - @Async public String sendWelcomeSMStoBenificiary(String contactNo, String beneficiaryName, String beneficiaryId) { + final RestTemplate restTemplate = new RestTemplate(); - try { - String sendSMSAPI = SMS_GATEWAY_URL; + Optional smsTemplateData = smsTemplateRepository.findBySmsTemplateName(smsTemplateName); + if (smsTemplateData.isPresent()) { + smsTemplate = smsTemplateRepository.findBySmsTemplateID(smsTemplateData.get().getSmsTemplateID()).getSmsTemplate(); - final RestTemplate restTemplate = new RestTemplate(); + } - Optional smsTemplateData = smsTemplateRepository.findBySmsTemplateName(smsTemplateName); - if (smsTemplateData.isPresent()) { - smsTemplate = smsTemplateRepository.findBySmsTemplateID(smsTemplateData.get().getSmsTemplateID()).getSmsTemplate(); - } - if(smsTemplate!=null){ - String message = smsTemplate.replace("$$BENE_NAME$$", beneficiaryName).replace("$$BEN_ID$$", beneficiaryId); - // Build payload - Map payload = new HashMap<>(); - payload.put("customerId", smsUserName); - payload.put("destinationAddress", contactNo); - payload.put("message", message); - payload.put("sourceAddress", smsSourceAddress); - payload.put("messageType", "SERVICE_IMPLICIT"); - payload.put("dltTemplateId", smsTemplateData.get().getDltTemplateId()); - payload.put("entityId", smsEntityId); - // Set headers - HttpHeaders headers = new HttpHeaders(); - String auth = smsUserName + ":" + smsPassword; - headers.add("Authorization", - "Basic " + Base64.getEncoder().encodeToString(auth.getBytes())); + logger.info("sms template" + smsTemplate); + + + String sendSMSAPI = SMS_GATEWAY_URL; + + try { + + String message = smsTemplate.replace("$$BENE_NAME$$", beneficiaryName).replace("$$BEN_ID$$", beneficiaryId); + // Build payload + Map payload = new HashMap<>(); + payload.put("customerId", smsUserName); + payload.put("destinationAddress", contactNo); + payload.put("message", message); + payload.put("sourceAddress", smsSourceAddress); + payload.put("messageType", "SERVICE_IMPLICIT"); + payload.put("dltTemplateId", smsTemplateData.get().getDltTemplateId()); + payload.put("entityId", smsEntityId); + // Set headers + HttpHeaders headers = new HttpHeaders(); + String auth = smsUserName + ":" + smsPassword; + headers.add("Authorization", + "Basic " + Base64.getEncoder().encodeToString(auth.getBytes())); headers.setContentType(MediaType.APPLICATION_JSON); logger.info("payload: " + payload); HttpEntity> request = new HttpEntity<>(payload, headers); - // Call API - ResponseEntity response = restTemplate.postForEntity(sendSMSAPI, request, String.class); - logger.info("sms-response:" + response.getBody()); - if (response.getStatusCode().value() == 200) { - return "OTP sent successfully on register mobile number"; - } else { - return "Fail"; + // Call API + ResponseEntity response = restTemplate.postForEntity(sendSMSAPI, request, String.class); + logger.info("sms-response:" + response.getBody()); + if (response.getStatusCode().value() == 200) { + return "OTP sent successfully on register mobile number"; + } else { + return "Fail"; - } } - } catch (Exception e) { return "Error sending SMS: " + e.getMessage().toString(); } - return null; + } } diff --git a/src/main/java/com/iemr/common/utils/FilterConfig.java b/src/main/java/com/iemr/common/utils/FilterConfig.java index 42bd04ad..9f6efb13 100644 --- a/src/main/java/com/iemr/common/utils/FilterConfig.java +++ b/src/main/java/com/iemr/common/utils/FilterConfig.java @@ -1,102 +1,28 @@ -/* - * 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.utils; -import com.iemr.common.filter.PlatformFeedbackRateLimitFilter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.Ordered; -import org.springframework.core.env.Environment; -import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.beans.factory.annotation.Value; @Configuration public class FilterConfig { - private static final Logger log = LoggerFactory.getLogger(FilterConfig.class); - - @Value("${cors.allowed-origins}") - private String allowedOrigins; - - @Bean - public FilterRegistrationBean jwtUserIdValidationFilter( - JwtAuthenticationUtil jwtAuthenticationUtil) { - FilterRegistrationBean registrationBean = new FilterRegistrationBean<>(); - - // Pass allowedOrigins explicitly to the filter constructor - JwtUserIdValidationFilter filter = new JwtUserIdValidationFilter(jwtAuthenticationUtil, allowedOrigins); - - registrationBean.setFilter(filter); - registrationBean.setOrder(Ordered.HIGHEST_PRECEDENCE); - registrationBean.addUrlPatterns("/*"); // Apply filter to all API endpoints - log.info("Registered JwtUserIdValidationFilter on /* with order {}", Ordered.HIGHEST_PRECEDENCE); - return registrationBean; - } - - /** - * Register the platform feedback rate-limit filter in a non-invasive way. - * - * - The filter is mapped only to the public feedback endpoints to avoid affecting other routes. - * - Order is intentionally set after the Jwt filter so authentication runs first. - */ - @Bean - public FilterRegistrationBean platformFeedbackRateLimitFilter( - StringRedisTemplate stringRedisTemplate, - Environment env) { - - // Read flag from environment (property file or env var) - boolean enabled = Boolean.parseBoolean(env.getProperty("platform.feedback.ratelimit.enabled", "false")); - - // Allow optional override for order if needed - int defaultOrder = Ordered.HIGHEST_PRECEDENCE + 10; - int order = defaultOrder; - String orderStr = env.getProperty("platform.feedback.ratelimit.order"); - if (orderStr != null) { - try { - order = Integer.parseInt(orderStr); - } catch (NumberFormatException e) { - log.warn("Invalid platform.feedback.ratelimit.order value '{}', using default {}", orderStr, defaultOrder); - } - } - - PlatformFeedbackRateLimitFilter filter = new PlatformFeedbackRateLimitFilter(stringRedisTemplate, env); - - FilterRegistrationBean reg = new FilterRegistrationBean<>(filter); - - reg.addUrlPatterns( - "/platform-feedback/*", - "/platform-feedback" - ); + @Value("${cors.allowed-origins}") + private String allowedOrigins; - reg.setOrder(order); - // Do not remove the bean from context when disabled; keep registration but disable execution - reg.setEnabled(enabled); + @Bean + public FilterRegistrationBean jwtUserIdValidationFilter( + JwtAuthenticationUtil jwtAuthenticationUtil) { + FilterRegistrationBean registrationBean = new FilterRegistrationBean<>(); - log.info("Registered PlatformFeedbackRateLimitFilter (enabled={}, order={}) mapped to {}", - enabled, order, reg.getUrlPatterns()); + // Pass allowedOrigins explicitly to the filter constructor + JwtUserIdValidationFilter filter = new JwtUserIdValidationFilter(jwtAuthenticationUtil, allowedOrigins); - return reg; - } -} \ No newline at end of file + registrationBean.setFilter(filter); + registrationBean.setOrder(Ordered.HIGHEST_PRECEDENCE); + registrationBean.addUrlPatterns("/*"); // Apply filter to all API endpoints + return registrationBean; + } +} diff --git a/src/main/java/com/iemr/common/utils/JwtUserIdValidationFilter.java b/src/main/java/com/iemr/common/utils/JwtUserIdValidationFilter.java index 81d79221..412352fc 100644 --- a/src/main/java/com/iemr/common/utils/JwtUserIdValidationFilter.java +++ b/src/main/java/com/iemr/common/utils/JwtUserIdValidationFilter.java @@ -1,24 +1,3 @@ -/* - * 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.utils; import java.io.IOException; @@ -120,13 +99,6 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo logger.info("JwtUserIdValidationFilter invoked for path: " + path); - // NEW: if this is a platform-feedback endpoint, treat it as public (skip auth) - // and also ensure we don't clear any user cookies for these requests. - if (isPlatformFeedbackPath(path, contextPath)) { - logger.debug("Platform-feedback path detected - skipping authentication and leaving cookies intact: {}", path); - filterChain.doFilter(servletRequest, servletResponse); - return; - } // Log cookies for debugging Cookie[] cookies = request.getCookies(); if (cookies != null) { @@ -194,19 +166,6 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo } } - /** - * New helper: identifies platform-feedback endpoints so we can treat them - * specially (public + preserve cookies). - */ - private boolean isPlatformFeedbackPath(String path, String contextPath) { - if (path == null) return false; - String normalized = path.toLowerCase(); - String base = (contextPath == null ? "" : contextPath).toLowerCase(); - // match /platform-feedback and anything under it - return normalized.startsWith(base + "/platform-feedback"); - } - - private boolean isOriginAllowed(String origin) { if (origin == null || allowedOrigins == null || allowedOrigins.trim().isEmpty()) { logger.warn("No allowed origins configured or origin is null"); diff --git a/src/main/java/com/iemr/common/utils/JwtUtil.java b/src/main/java/com/iemr/common/utils/JwtUtil.java index 5d37a990..d8414968 100644 --- a/src/main/java/com/iemr/common/utils/JwtUtil.java +++ b/src/main/java/com/iemr/common/utils/JwtUtil.java @@ -2,7 +2,6 @@ import io.jsonwebtoken.*; import io.jsonwebtoken.security.Keys; -import jakarta.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -162,58 +161,4 @@ public String getUserIdFromToken(String token) { public long getRefreshTokenExpiration() { return REFRESH_EXPIRATION_TIME; } - - /** - * Extract user ID from JWT token in the request (checks header and cookie) - * @param request the HTTP request - * @return the user ID, or null if not found - */ -public Integer getUserIdFromRequest(HttpServletRequest request) { - try { - String jwtToken = request.getHeader("Jwttoken"); - String cookieToken = CookieUtil.getJwtTokenFromCookie(request); - - // Prefer header token, fallback to cookie - String token = (jwtToken != null && !jwtToken.isEmpty()) ? jwtToken : cookieToken; - - if (token == null || token.isEmpty()) { - return null; - } - - Claims claims = validateToken(token); - if (claims == null) { - return null; - } - - String userId = claims.get("userId", String.class); - return userId != null ? Integer.parseInt(userId) : null; - - } catch (Exception e) { - return null; - } -} - -/** - * Extract username from JWT token in the request (checks header and cookie) - * @param request the HTTP request - * @return the username, or null if not found - */ -public String getUsernameFromRequest(HttpServletRequest request) { - try { - String jwtToken = request.getHeader("Jwttoken"); - String cookieToken = CookieUtil.getJwtTokenFromCookie(request); - - String token = (jwtToken != null && !jwtToken.isEmpty()) ? jwtToken : cookieToken; - - if (token == null || token.isEmpty()) { - return null; - } - - Claims claims = validateToken(token); - return claims != null ? claims.getSubject() : null; - - } catch (Exception e) { - return null; - } -} } diff --git a/src/main/java/com/iemr/common/utils/RestTemplateUtil.java b/src/main/java/com/iemr/common/utils/RestTemplateUtil.java index 4e4fa483..447ba80f 100644 --- a/src/main/java/com/iemr/common/utils/RestTemplateUtil.java +++ b/src/main/java/com/iemr/common/utils/RestTemplateUtil.java @@ -10,17 +10,14 @@ import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; -import com.iemr.common.constant.Constants; - import jakarta.servlet.http.HttpServletRequest; public class RestTemplateUtil { private final static Logger logger = LoggerFactory.getLogger(RestTemplateUtil.class); - + public static HttpEntity createRequestEntity(Object body, String authorization) { - - ServletRequestAttributes servletRequestAttributes = ((ServletRequestAttributes) RequestContextHolder - .getRequestAttributes()); + + ServletRequestAttributes servletRequestAttributes = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()); if (servletRequestAttributes == null) { MultiValueMap headers = new LinkedMultiValueMap<>(); headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8"); @@ -28,61 +25,29 @@ public static HttpEntity createRequestEntity(Object body, String authori return new HttpEntity<>(body, headers); } HttpServletRequest requestHeader = servletRequestAttributes.getRequest(); - - String jwtTokenFromCookie = extractJwttoken(requestHeader); - - MultiValueMap headers = new LinkedMultiValueMap<>(); - headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8"); - if (null != UserAgentContext.getUserAgent()) { - headers.add(HttpHeaders.USER_AGENT, UserAgentContext.getUserAgent()); - } - headers.add(HttpHeaders.AUTHORIZATION, authorization); - if (null != requestHeader.getHeader(Constants.JWT_TOKEN)) { - headers.add(Constants.JWT_TOKEN, requestHeader.getHeader(Constants.JWT_TOKEN)); - headers.add(HttpHeaders.COOKIE, "Jwttoken=" + requestHeader.getHeader(Constants.JWT_TOKEN)); - - } - if (null != jwtTokenFromCookie) { - headers.add(HttpHeaders.COOKIE, "Jwttoken=" + jwtTokenFromCookie); - } - - return new HttpEntity<>(body, headers); - } - - private static String extractJwttoken(HttpServletRequest requestHeader) { - String jwtTokenFromCookie = null; + String jwtTokenFromCookie = null; try { jwtTokenFromCookie = CookieUtil.getJwtTokenFromCookie(requestHeader); - + } catch (Exception e) { - logger.error("Error while getting jwtToken from Cookie" + e.getMessage()); - } - return jwtTokenFromCookie; - } - - public static void getJwttokenFromHeaders(HttpHeaders headers) { - ServletRequestAttributes servletRequestAttributes = ((ServletRequestAttributes) RequestContextHolder - .getRequestAttributes()); - if (servletRequestAttributes == null) { - return; - } - HttpServletRequest requestHeader = servletRequestAttributes.getRequest(); - String jwtTokenFromCookie = extractJwttoken(requestHeader); - if (!headers.containsKey(HttpHeaders.CONTENT_TYPE)) { - headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8"); - } - if (null != UserAgentContext.getUserAgent()) { - if (!headers.containsKey(HttpHeaders.USER_AGENT)) { - headers.add(HttpHeaders.USER_AGENT, UserAgentContext.getUserAgent()); - } - } - if (null != jwtTokenFromCookie) { - headers.add(HttpHeaders.COOKIE, Constants.JWT_TOKEN + "=" + jwtTokenFromCookie); - } else if (null != requestHeader.getHeader(Constants.JWT_TOKEN)) { - headers.add(Constants.JWT_TOKEN, requestHeader.getHeader(Constants.JWT_TOKEN)); - headers.add(HttpHeaders.COOKIE, Constants.JWT_TOKEN + "=" + requestHeader.getHeader(Constants.JWT_TOKEN)); - - } - } - -} + logger.error("Error while getting jwtToken from Cookie" + e.getMessage() ); + } + + MultiValueMap headers = new LinkedMultiValueMap<>(); + headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8"); + if(null != UserAgentContext.getUserAgent()) { + logger.info("Common-API getting User-Agent as : "+UserAgentContext.getUserAgent()); + headers.add(HttpHeaders.USER_AGENT, UserAgentContext.getUserAgent()); + } + headers.add(HttpHeaders.AUTHORIZATION, authorization); + if(null != requestHeader.getHeader("JwtToken")) { + headers.add("JwtToken",requestHeader.getHeader("JwtToken")); + } + if(null != jwtTokenFromCookie) { + headers.add(HttpHeaders.COOKIE, "Jwttoken=" + jwtTokenFromCookie); + } + + return new HttpEntity<>(body, headers); + } + +} \ No newline at end of file diff --git a/src/main/java/com/iemr/common/utils/http/HTTPRequestInterceptor.java b/src/main/java/com/iemr/common/utils/http/HTTPRequestInterceptor.java index b4aaad60..0c609839 100644 --- a/src/main/java/com/iemr/common/utils/http/HTTPRequestInterceptor.java +++ b/src/main/java/com/iemr/common/utils/http/HTTPRequestInterceptor.java @@ -36,14 +36,10 @@ import com.iemr.common.utils.sessionobject.SessionObject; import com.iemr.common.utils.validator.Validator; -import com.iemr.common.utils.JwtUtil; -import io.jsonwebtoken.Claims; -import com.iemr.common.utils.CookieUtil; import jakarta.servlet.ServletOutputStream; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; - @Configuration @Component public class HTTPRequestInterceptor implements HandlerInterceptor { @@ -54,9 +50,6 @@ public class HTTPRequestInterceptor implements HandlerInterceptor { @Value("${cors.allowed-origins}") private String allowedOrigins; - @Autowired - private JwtUtil jwtUtil; - @Autowired public void setValidator(Validator validator) { this.validator = validator; @@ -74,101 +67,100 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons boolean status = true; logger.info("In info preHandle we are Intercepting the Request"); logger.debug("In preHandle we are Intercepting the Request"); - // String authorization = request.getHeader("Authorization"); + // String authorization = request.getHeader("Authorization"); String authorization = null; String preAuth = request.getHeader("Authorization"); - if (null != preAuth && preAuth.contains("Bearer ")) - authorization = preAuth.replace("Bearer ", ""); + if(null != preAuth && preAuth.contains("Bearer ")) + authorization=preAuth.replace("Bearer ", ""); else authorization = preAuth; - + if (authorization == null || authorization.isEmpty()) { - logger.info("Authorization header is null or empty. Skipping HTTPRequestInterceptor."); - return true; // Allow the request to proceed without validation - } - - logger.debug("RequestURI::" + request.getRequestURI() + " || Authorization ::" + authorization + logger.info("Authorization header is null or empty. Skipping HTTPRequestInterceptor."); + return true; // Allow the request to proceed without validation + } + logger.debug("RequestURI::" + request.getRequestURI() + " || Authorization ::" + authorization + " || method :: " + request.getMethod()); if (!request.getMethod().equalsIgnoreCase("OPTIONS")) { try { String[] requestURIParts = request.getRequestURI().split("/"); String requestAPI = requestURIParts[requestURIParts.length - 1]; switch (requestAPI) { - case "userAuthenticate": - case "superUserAuthenticate": - case "userAuthenticateNew": - case "userAuthenticateV1": - case "forgetPassword": - case "setForgetPassword": - case "changePassword": - case "saveUserSecurityQuesAns": - case "doAgentLogout": - case "userLogout": - case "swagger-ui.html": - case "index.html": - case "index.css": - case "swagger-initializer.js": - case "swagger-config": - case "swagger-ui-bundle.js": - case "swagger-ui.css": - case "ui": - case "swagger-ui-standalone-preset.js": - case "favicon-32x32.png": - case "favicon-16x16.png": - case "swagger-resources": - case "api-docs": - case "updateBenCallIdsInPhoneBlock": - case "userAuthenticateByEncryption": - case "sendOTP": - case "validateOTP": - case "resendOTP": - case "validateSecurityQuestionAndAnswer": - case "logOutUserFromConcurrentSession": - case "refreshToken": - break; - case "error": - status = false; - break; - default: - String remoteAddress = request.getHeader("X-FORWARDED-FOR"); - if (remoteAddress == null || remoteAddress.trim().length() == 0) { - remoteAddress = request.getRemoteAddr(); - } - validator.checkKeyExists(authorization, remoteAddress); - break; + case "userAuthenticate": + case "superUserAuthenticate": + case "userAuthenticateNew": + case "userAuthenticateV1": + case "forgetPassword": + case "setForgetPassword": + case "changePassword": + case "saveUserSecurityQuesAns": + case "doAgentLogout": + case "userLogout": + case "swagger-ui.html": + case "index.html": + case "index.css": + case "swagger-initializer.js": + case "swagger-config": + case "swagger-ui-bundle.js": + case "swagger-ui.css": + case "ui": + case "swagger-ui-standalone-preset.js": + case "favicon-32x32.png": + case "favicon-16x16.png": + case "swagger-resources": + case "api-docs": + case "updateBenCallIdsInPhoneBlock": + case "userAuthenticateByEncryption": + case "sendOTP": + case "validateOTP": + case "resendOTP": + case "validateSecurityQuestionAndAnswer": + case "logOutUserFromConcurrentSession": + case "refreshToken": + break; + case "error": + status = false; + break; + default: + String remoteAddress = request.getHeader("X-FORWARDED-FOR"); + if (remoteAddress == null || remoteAddress.trim().length() == 0) { + remoteAddress = request.getRemoteAddr(); + } + validator.checkKeyExists(authorization, remoteAddress); + break; } } catch (Exception e) { logger.error("Authorization failed: {}", e.getMessage(), e); - String errorMessage = e.getMessage(); - if (errorMessage == null || errorMessage.trim().isEmpty()) { - errorMessage = "Unauthorized access or session expired."; - } - - String jsonErrorResponse = "{" - + "\"status\": \"Unauthorized\"," - + "\"statusCode\": 401," - + "\"errorMessage\": \"" + errorMessage.replace("\"", "\\\"") + "\"" - + "}"; - - response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); // 401 - response.setContentType(MediaType.APPLICATION_JSON); - - String origin = request.getHeader("Origin"); - if (origin != null && isOriginAllowed(origin)) { - response.setHeader("Access-Control-Allow-Origin", origin); - response.setHeader("Access-Control-Allow-Credentials", "true"); - } else if (origin != null) { - logger.warn("CORS headers NOT added for error response | Unauthorized origin: {}", origin); - } - - // Better to use getBytes().length for accurate byte size - byte[] responseBytes = jsonErrorResponse.getBytes(StandardCharsets.UTF_8); - response.setContentLength(responseBytes.length); - - ServletOutputStream out = response.getOutputStream(); - out.write(responseBytes); - out.flush(); + String errorMessage = e.getMessage(); + if (errorMessage == null || errorMessage.trim().isEmpty()) { + errorMessage = "Unauthorized access or session expired."; + } + + String jsonErrorResponse = "{" + + "\"status\": \"Unauthorized\"," + + "\"statusCode\": 401," + + "\"errorMessage\": \"" + errorMessage.replace("\"", "\\\"") + "\"" + + "}"; + + response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); // 401 + response.setContentType(MediaType.APPLICATION_JSON); + + String origin = request.getHeader("Origin"); + if (origin != null && isOriginAllowed(origin)) { + response.setHeader("Access-Control-Allow-Origin", origin); + response.setHeader("Access-Control-Allow-Credentials", "true"); + } else if (origin != null) { + logger.warn("CORS headers NOT added for error response | Unauthorized origin: {}", origin); + } + + // Better to use getBytes().length for accurate byte size + byte[] responseBytes = jsonErrorResponse.getBytes(StandardCharsets.UTF_8); + response.setContentLength(responseBytes.length); + + ServletOutputStream out = response.getOutputStream(); + out.write(responseBytes); + out.flush(); status = false; } } @@ -180,14 +172,15 @@ public void postHandle(HttpServletRequest request, HttpServletResponse response, throws Exception { try { logger.debug("In postHandle we are Intercepting the Request"); + // String authorization = request.getHeader("Authorization"); String authorization = null; String postAuth = request.getHeader("Authorization"); - if (null != postAuth && postAuth.contains("Bearer ")) - authorization = postAuth.replace("Bearer ", ""); + if(null != postAuth && postAuth.contains("Bearer ")) + authorization=postAuth.replace("Bearer ", ""); else authorization = postAuth; logger.debug("RequestURI::" + request.getRequestURI() + " || Authorization ::" + authorization); - + if (authorization != null && !authorization.equals("")) { sessionObject.updateSessionObject(authorization, sessionObject.getSessionObject(authorization)); } @@ -219,10 +212,8 @@ private boolean isOriginAllowed(String origin) { .anyMatch(pattern -> { String regex = pattern .replace(".", "\\.") - .replace("*", ".*"); + .replace("*", ".*"); return origin.matches(regex); }); } - - } diff --git a/src/main/java/com/iemr/common/utils/http/HttpUtils.java b/src/main/java/com/iemr/common/utils/http/HttpUtils.java index 4f49e662..0f308619 100644 --- a/src/main/java/com/iemr/common/utils/http/HttpUtils.java +++ b/src/main/java/com/iemr/common/utils/http/HttpUtils.java @@ -40,7 +40,6 @@ import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; -import com.iemr.common.utils.RestTemplateUtil; import com.sun.jersey.multipart.FormDataBodyPart; import com.sun.jersey.multipart.FormDataMultiPart; @@ -55,6 +54,9 @@ public class HttpUtils { // @Autowired private HttpStatus status; private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + + // @Autowired(required = true) + // @Qualifier("hibernateCriteriaBuilder") public HttpUtils() { if (rest == null) { rest = new RestTemplate(); @@ -62,22 +64,33 @@ public HttpUtils() { headers.add("Content-Type", "application/json"); } } - + // public HttpUtils() { + // if (rest == null) { + // rest = new RestTemplate(); + // headers = new HttpHeaders(); + // headers.add("Content-Type", "application/json"); + // } + // } + + // @Bean + // public HttpUtils httpUtils() { + // return new HttpUtils(); + // } + public String get(String uri) { String body; - HttpHeaders requestHeaders = new HttpHeaders(); - requestHeaders.add("Content-Type", "application/json"); - RestTemplateUtil.getJwttokenFromHeaders(requestHeaders); - HttpEntity requestEntity = new HttpEntity("", requestHeaders); + HttpEntity requestEntity = new HttpEntity("", headers); ResponseEntity responseEntity = rest.exchange(uri, HttpMethod.GET, requestEntity, String.class); setStatus((HttpStatus) responseEntity.getStatusCode()); + // if (status == HttpStatus.OK){ body = responseEntity.getBody(); - + // }else{ + // responseEntity + // } return body; } public ResponseEntity getV1(String uri) throws URISyntaxException, MalformedURLException { - RestTemplateUtil.getJwttokenFromHeaders(headers); HttpEntity requestEntity = new HttpEntity("", headers); ResponseEntity responseEntity = rest.exchange(uri, HttpMethod.GET, requestEntity, String.class); return responseEntity; @@ -94,7 +107,6 @@ public String get(String uri, HashMap header) { } else { headers.add("Content-Type", MediaType.APPLICATION_JSON); } - RestTemplateUtil.getJwttokenFromHeaders(headers); HttpEntity requestEntity = new HttpEntity("", headers); ResponseEntity responseEntity = rest.exchange(uri, HttpMethod.GET, requestEntity, String.class); setStatus((HttpStatus) responseEntity.getStatusCode()); @@ -104,7 +116,6 @@ public String get(String uri, HashMap header) { public String post(String uri, String json) { String body; - RestTemplateUtil.getJwttokenFromHeaders(headers); HttpEntity requestEntity = new HttpEntity(json, headers); ResponseEntity responseEntity = rest.exchange(uri, HttpMethod.POST, requestEntity, String.class); setStatus((HttpStatus) responseEntity.getStatusCode()); @@ -118,7 +129,9 @@ public String post(String uri, String data, HashMap header) { if (header.containsKey(headers.AUTHORIZATION)) { headers.add(headers.AUTHORIZATION, header.get(headers.AUTHORIZATION).toString()); } - RestTemplateUtil.getJwttokenFromHeaders(headers); + + // headers.add("Content-Type", MediaType.APPLICATION_JSON); + headers.add("Content-Type", MediaType.APPLICATION_JSON + ";charset=utf-8"); ResponseEntity responseEntity = new ResponseEntity(HttpStatus.BAD_REQUEST); HttpEntity requestEntity; diff --git a/src/main/java/com/iemr/common/utils/mapper/CallTypeMapper.java b/src/main/java/com/iemr/common/utils/mapper/CallTypeMapper.java deleted file mode 100644 index ace82367..00000000 --- a/src/main/java/com/iemr/common/utils/mapper/CallTypeMapper.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.iemr.common.utils.mapper; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -@Service -public class CallTypeMapper { - private static GsonBuilder builder; - private static Gson gsonInstance; - private Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); - - public CallTypeMapper() { - if (builder == null) { - builder = new GsonBuilder(); - // Only serialize/deserialize fields with @Expose annotation - builder.excludeFieldsWithoutExposeAnnotation(); - - logger.info("CallTypeMapper initialized - Only @Expose fields will be processed"); - } - } - - public static Gson gson() { - if (gsonInstance == null) { - gsonInstance = builder.create(); - } - return gsonInstance; - } - - public T fromJson(String json, Class classOfT) { - try { - T result = gson().fromJson(json, classOfT); - logger.info("Successfully deserialized to class: {}", classOfT.getSimpleName()); - return result; - } catch (Exception e) { - logger.error("Error deserializing JSON to {}: {}", classOfT.getSimpleName(), e.getMessage(), e); - throw e; - } - } -} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index a3de6772..57652e66 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -76,14 +76,14 @@ get-details-call-report-URL=http://CTI_SERVER/apps/customize_apps/piramil_report #============================================================================ # Configure Main Scheduler Properties #============================================================================ - + org.quartz.scheduler.instanceId = AUTO org.quartz.scheduler.makeSchedulerThreadDaemon = true - + #============================================================================ # Configure ThreadPool #============================================================================ - + org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool org.quartz.threadPool.makeThreadsDaemons = true org.quartz.threadPool.threadCount: 20 @@ -110,7 +110,6 @@ iemr.extend.expiry.time.changePassword=true iemr.session.expiry.time.changePassword=600 identity-api-url-advancesearch =IDENTITY_BASE_URL/id/advanceSearch -identity-api-url-advancesearch-es =IDENTITY_BASE_URL/beneficiary/advancedSearchES identity-api-url-getByBenRegIdList =IDENTITY_BASE_URL/id/getByBenRegIdList identity-api-url-getByPartialBenRegIdList =IDENTITY_BASE_URL/id/getByPartialBenRegIdList identity-api-url-getByPhoneNum =IDENTITY_BASE_URL/id/getByPhoneNum?phoneNum= @@ -119,7 +118,6 @@ identity-api-url-getByBenRegId =IDENTITY_BASE_URL/id/getByBenRegId?benRegId= identity-api-url-benCreate =IDENTITY_BASE_URL/id/create identity-api-url-benEdit =IDENTITY_BASE_URL/id/edit identity-api-url-benEditEducationCommunity=IDENTITY_BASE_URL/id/editEducationOrCommunity -identity-api-url-searchByES=IDENTITY_BASE_URL/beneficiary/search identity-api-url-getByFamilyId=IDENTITY_BASE_URL/id/searchByFamilyId?familyId= identity-api-url-getByGovIdentity=IDENTITY_BASE_URL/id/searchByGovIdentity?identity= @@ -374,5 +372,3 @@ allowed.file.extensions=msg,pdf,png,jpeg,doc,docx,xlsx,xls,csv,txt ##sms details for beneficiary otp cosent sms-template-name = otp_consent - -cors.allowed-origin =