Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.compile.nullAnalysis.mode": "automatic"
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.iemr.common-API</groupId>
<artifactId>common-api</artifactId>
<version>3.6.0</version>
<version>3.6.1</version>
<packaging>war</packaging>

<name>Common-API</name>
Expand Down
1 change: 1 addition & 0 deletions src/main/environment/common_ci.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ [email protected]_API_BASE_PATH@
km-root-path=/okm:personal/users/
[email protected]_GUEST_USER@
[email protected]_GUEST_PASSWORD@
[email protected]_FILE_PATH@

# CTI Config
[email protected]_SERVER_IP@
Expand Down
2 changes: 1 addition & 1 deletion src/main/environment/common_docker.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/main/environment/common_example.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ km-root-path=/okm:personal/users/
km-guest-user=guest
km-guest-password=guest

tempFilePath=/opt/openkm

# CTI Config
cti-server-ip=10.208.122.99
cti-logger_base_url=http://10.208.122.99/logger
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/iemr/common/config/CorsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@Configuration
public class CorsConfig implements WebMvcConfigurer {

@Value("${cors.allowed-origin}")
@Value("${cors.allowed-origins}")
private String allowedOrigins;
@Override
public void addCorsMappings(CorsRegistry registry) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
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;
Expand Down Expand Up @@ -70,6 +71,8 @@
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;
Expand Down Expand Up @@ -103,6 +106,8 @@
private BeneficiaryOccupationService beneficiaryOccupationService;
private GovtIdentityTypeService govtIdentityTypeService;

@Autowired

Check warning on line 109 in src/main/java/com/iemr/common/controller/beneficiary/BeneficiaryRegistrationController.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this field injection and use constructor injection instead.

See more on https://sonarcloud.io/project/issues?id=PSMRI_Common-API&issues=AZzg21Iif_pk0iI2koXW&open=AZzg21Iif_pk0iI2koXW&pullRequest=372
private JwtUtil jwtUtil;

@Autowired
public void setBenRelationshipTypeService(BenRelationshipTypeService benRelationshipTypeService) {
Expand Down Expand Up @@ -324,7 +329,7 @@
BenPhoneMap benPhoneMap = OutputMapper.gson().fromJson(request, BenPhoneMap.class);
int pageNumber = requestObj.has("pageNo") ? (requestObj.getInt("pageNo") - 1) : 0;
int rows = requestObj.has("rowsPerPage") ? requestObj.getInt("rowsPerPage") : 1000;
if (requestObj.has("is1097") && requestObj.getBoolean("is1097") == true) {

Check failure on line 332 in src/main/java/com/iemr/common/controller/beneficiary/BeneficiaryRegistrationController.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "is1097" 5 times.

See more on https://sonarcloud.io/project/issues?id=PSMRI_Common-API&issues=AZzg21Iif_pk0iI2koXU&open=AZzg21Iif_pk0iI2koXU&pullRequest=372
benPhoneMap.setIs1097(true);
}

Expand All @@ -342,6 +347,54 @@
return response.toString();
}

@Operation(summary = "Provide the list of beneficiaries using Elasticsearch")
@RequestMapping(value = "/searchUser", method = RequestMethod.POST, headers = "Authorization")

Check warning on line 351 in src/main/java/com/iemr/common/controller/beneficiary/BeneficiaryRegistrationController.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace "@RequestMapping(method = RequestMethod.POST)" with "@PostMapping"

See more on https://sonarcloud.io/project/issues?id=PSMRI_Common-API&issues=AZzg21Iif_pk0iI2koXX&open=AZzg21Iif_pk0iI2koXX&pullRequest=372
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()) {

Check failure on line 361 in src/main/java/com/iemr/common/controller/beneficiary/BeneficiaryRegistrationController.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

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

See more on https://sonarcloud.io/project/issues?id=PSMRI_Common-API&issues=AZzg21Iif_pk0iI2koXV&open=AZzg21Iif_pk0iI2koXV&pullRequest=372
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(
Expand All @@ -364,6 +417,41 @@
return output.toString();
}

/**
* Elasticsearch-based advanced search endpoint
*/
@Operation(summary = "Advanced search beneficiaries using Elasticsearch")
@RequestMapping(value = "/searchBeneficiaryES", method = RequestMethod.POST, headers = "Authorization")

Check warning on line 424 in src/main/java/com/iemr/common/controller/beneficiary/BeneficiaryRegistrationController.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace "@RequestMapping(method = RequestMethod.POST)" with "@PostMapping"

See more on https://sonarcloud.io/project/issues?id=PSMRI_Common-API&issues=AZzg21Iif_pk0iI2koXY&open=AZzg21Iif_pk0iI2koXY&pullRequest=372
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);

Check warning on line 440 in src/main/java/com/iemr/common/controller/beneficiary/BeneficiaryRegistrationController.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Immediately return this expression instead of assigning it to the temporary variable "result".

See more on https://sonarcloud.io/project/issues?id=PSMRI_Common-API&issues=AZzg21Iif_pk0iI2koXT&open=AZzg21Iif_pk0iI2koXT&pullRequest=372

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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ public ResponseEntity<ApiResponse<?>> deleteField(@PathVariable Long fieldId) {
}

@GetMapping(value = "form/{formId}/fields")
public ResponseEntity<ApiResponse<?>> getStructuredForm(@PathVariable String formId, @RequestParam(name = "lang", defaultValue = "en") String lang) {
public ResponseEntity<ApiResponse<?>> getStructuredForm(@PathVariable String formId, @RequestParam(name = "lang", defaultValue = "en") String lang,@RequestHeader(value = "jwttoken") String token) {
try {
Object result = formMasterService.getStructuredFormByFormId(formId,lang);
Object result = formMasterService.getStructuredFormByFormId(formId,lang,token);
return ResponseEntity.status(HttpStatus.OK)
.body(ApiResponse.success("Form structure fetched successfully", HttpStatus.OK.value(), result));
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
* 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;
package com.iemr.common.controller.platform_feedback;

import com.iemr.common.dto.*;
import com.iemr.common.service.PlatformFeedbackService;
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@

// Get user details
// Get user details
String userId = claims.get("userId", String.class);

Check failure on line 279 in src/main/java/com/iemr/common/controller/users/IEMRAdminController.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

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

See more on https://sonarcloud.io/project/issues?id=PSMRI_Common-API&issues=AZzg21GWf_pk0iI2koXQ&open=AZzg21GWf_pk0iI2koXQ&pullRequest=372
User user = iemrAdminUserServiceImpl.getUserById(Long.parseLong(userId));

// Validate that the user still exists and is active
Expand Down Expand Up @@ -392,6 +392,7 @@
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()));
}
Expand Down Expand Up @@ -1220,10 +1221,28 @@
try {
List<User> users = iemrAdminUserServiceImpl.getUserIdbyUserName(userName);
if (users.isEmpty()) {
return new ResponseEntity<>(Map.of("error", "UserName Not Found"), HttpStatus.NOT_FOUND);

Check failure on line 1224 in src/main/java/com/iemr/common/controller/users/IEMRAdminController.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "error" 4 times.

See more on https://sonarcloud.io/project/issues?id=PSMRI_Common-API&issues=AZzg21GWf_pk0iI2koXR&open=AZzg21GWf_pk0iI2koXR&pullRequest=372
}
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);
}

}

@Operation(summary = "Get UserId based on userName")
@GetMapping(value = "/checkUserName/{userName}", produces = MediaType.APPLICATION_JSON, headers = "Authorization")
public ResponseEntity<?> checkUserDetails(@PathVariable("userName") String userName) {

Check failure on line 1237 in src/main/java/com/iemr/common/controller/users/IEMRAdminController.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove usage of generic wildcard type.

See more on https://sonarcloud.io/project/issues?id=PSMRI_Common-API&issues=AZzg21GWf_pk0iI2koXS&open=AZzg21GWf_pk0iI2koXS&pullRequest=372
try {
List<User> 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);
} catch (Exception e) {
return new ResponseEntity<>(Map.of("error", "Internal server error"), HttpStatus.INTERNAL_SERVER_ERROR);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,15 @@ public class FormField {
@Column(name = "sequence")
private Integer sequence;

@Column(name = "is_editable")
private Boolean isEditable;

@Column(name = "state_code")
private Integer stateCode;

@Column(name = "created_at")
private LocalDateTime createdAt = LocalDateTime.now();



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
package com.iemr.common.data.mmuDrugHistory;

import java.sql.Date;
import java.sql.Timestamp;

import com.google.gson.annotations.Expose;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import jakarta.persistence.Transient;
import lombok.Data;

@Entity
@Data
@Table(name = "t_prescribeddrug")
public class PrescribedMMUDrugDetail {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Expose
@Column(name = "PrescribedDrugID")
private Long prescribedDrugID;

@Expose
@Column(name = "BeneficiaryRegID")
private Long beneficiaryRegID;

@Expose
@Column(name = "BenVisitID")
private Long benVisitID;

@Expose
@Column(name = "ProviderServiceMapID")
private Integer providerServiceMapID;

@Expose
@Column(name = "VisitCode")
private Long visitCode;

@Expose
@Column(name = "PrescriptionID")
private Long prescriptionID;

@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "PrescriptionID", referencedColumnName = "PrescriptionID", insertable = false, updatable = false)
private PrescriptionMMU prescription;

@Expose
@Column(name = "DrugForm")
private String formName;

@Expose
@Column(name = "DrugTradeOrBrandName")
private String drugTradeOrBrandName;

@Expose
@Column(name = "DrugID")
private Integer drugID;

@Expose
@Column(name = "GenericDrugName")
private String drugName;

@Expose
@Column(name = "DrugStrength")
private String drugStrength;

@Expose
@Column(name = "Dose")
private String dose;

@Expose
@Column(name = "Route")
private String route;

@Expose
@Column(name = "Frequency")
private String frequency;

@Expose
@Column(name = "Duration")
private String duration;

@Expose
@Column(name = "DuartionUnit")
private String unit;

@Expose
@Column(name = "RelationToFood")
private String relationToFood;

@Expose
@Column(name = "SpecialInstruction")
private String instructions;

@Expose
@Column(name = "QtyPrescribed")
private Integer qtyPrescribed;

@Expose
@Column(name = "Deleted", insertable = false, updatable = true)
private Boolean deleted;

@Expose
@Column(name = "Processed", insertable = false, updatable = true)
private String processed;

@Expose
@Column(name = "CreatedBy")
private String createdBy;

}
Loading
Loading