Skip to content
Closed
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
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
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 @@ public class BeneficiaryRegistrationController {
private BeneficiaryOccupationService beneficiaryOccupationService;
private GovtIdentityTypeService govtIdentityTypeService;

@Autowired
private JwtUtil jwtUtil;

@Autowired
public void setBenRelationshipTypeService(BenRelationshipTypeService benRelationshipTypeService) {
Expand Down Expand Up @@ -342,6 +347,54 @@ 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(
Expand All @@ -364,6 +417,41 @@ 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() {
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 @@ -1224,7 +1224,25 @@ 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);
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<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;

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

import com.google.gson.annotations.Expose;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Data;

@Entity
@Data
@Table(name = "t_prescription")
public class PrescriptionMMU {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Expose
@Column(name = "PrescriptionID", insertable = false, updatable = false)
private Long prescriptionID;

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

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

@Expose
@Column(name = "DiagnosisProvided")
private String diagnosisProvided;

@Expose
@Column(name = "Remarks")
private String remarks;

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

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class Translation {
private String english;
@Column(name = "hindi_translation")
private String hindiTranslation;
@Column(name = "assamese_translation")
private String assameseTranslation;
@Column(name = "is_active")
private Boolean isActive;
}
Loading
Loading