Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
a7a9518
adding changes related to encryption and decryption
Oct 16, 2024
e1b5318
making final field static
Oct 16, 2024
eddabe3
making enclosing method static
Oct 16, 2024
6e626bb
adding beneficiaryConsent param to createFeedback API
Dec 10, 2024
6cf8550
Merge pull request #6 from PSMRI/develop
srishtigrp78 Dec 10, 2024
2303d60
Update src/main/java/com/iemr/common/data/feedback/FeedbackDetails.java
srishtigrp78 Dec 10, 2024
68d0483
Merge pull request #7 from PSMRI/develop
srishtigrp78 Dec 10, 2024
b7718c0
adding beneficiary consent param feedbacklist response
Dec 11, 2024
f9feef6
adding space
Dec 11, 2024
019d315
Merge pull request #8 from PSMRI/develop
srishtigrp78 Dec 20, 2024
507f830
Merge pull request #9 from PSMRI/develop
srishtigrp78 Jan 8, 2025
21be52e
adding code for schedule for grievance data sync
Jan 9, 2025
0a90728
adding code rabbit code suggestions
Jan 16, 2025
ea9ff9e
adding code rabbit suggestions
Jan 16, 2025
8825473
code rabbit suggested changes to Model classes
Jan 16, 2025
2d639c4
adding sonar quality changes
Jan 16, 2025
b0e039b
adding sonar quality code suggestions
Jan 16, 2025
9831500
adding sonar quality check suggestions
Jan 17, 2025
5cb6886
adding code rabbit suggestions
Jan 17, 2025
9e8e1f2
adding constant instead of duplicate literals
Jan 17, 2025
67b2f86
Merge pull request #10 from PSMRI/develop
srishtigrp78 Jan 19, 2025
7b3b990
adding cod changs to fetch unallocated grievance count
Jan 19, 2025
d834aa9
adding changes suggested by sonar quality check
Jan 20, 2025
734551a
adding code rabbit suggested changes
Jan 20, 2025
47ceb56
fixing config file
Jan 21, 2025
f26b8ff
fixing space
Jan 21, 2025
d3534d9
fixing space issue
Jan 21, 2025
6b58965
adding package for PrimaryDBConfig
Jan 22, 2025
8d97517
Merge pull request #11 from PSMRI/develop
srishtigrp78 Jan 22, 2025
b5798d2
adding code changes for allocate API for allocating grievance to agents
Jan 22, 2025
abe5bd3
removing space
Jan 22, 2025
3c8fbb9
Merge pull request #12 from PSMRI/develop
srishtigrp78 Jan 23, 2025
ef1021e
adding language related changes
Jan 23, 2025
3451ad5
add language related changes
Jan 23, 2025
fa02a49
adding name convention related changes
Jan 24, 2025
822ec19
adding code rabbit changes
Jan 24, 2025
c8e85ab
adding sonar quality check suggested changes
Jan 24, 2025
6557199
removing unused imports
Jan 24, 2025
9c8afce
Merge branch 'PSMRI:develop' into feature/version/upgrade
srishtigrp78 Jan 27, 2025
4c4cce0
Merge pull request #13 from PSMRI/develop
srishtigrp78 Feb 11, 2025
17a159f
Merge pull request #14 from PSMRI/develop
srishtigrp78 Feb 12, 2025
c20c9ab
Merge pull request #16 from PSMRI/develop
srishtigrp78 Feb 19, 2025
b2d99be
adding properties related to Grievance in properties file
Feb 19, 2025
76bf328
placing the placeholder for jwt secret key
Feb 19, 2025
eeaf00d
Update package.yml
srishtigrp78 Feb 19, 2025
b36477c
removing grievanc related properties from application properties file
Feb 20, 2025
48ac080
adding space
Feb 20, 2025
3fe65c4
removing extra space
Feb 20, 2025
b45a6da
Merge branch 'feature/version/upgrade' of https://github.com/srishtig…
Feb 20, 2025
55c469a
adding code for API that fetches grievance outbound worklist
Feb 20, 2025
e6acf34
Merge pull request #17 from PSMRI/develop
srishtigrp78 Feb 20, 2025
584f97e
adding code rabbit suggested changes
Feb 21, 2025
4a4de76
another addition of code rabbit suggested changes
Feb 21, 2025
650e573
fixing row no
Feb 21, 2025
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
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
package com.iemr.common.controller.grievance;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.ws.rs.core.MediaType;

import org.json.JSONException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.iemr.common.data.grievance.UnallocationRequest;
import com.iemr.common.dto.grivance.GrievanceWorklistDTO;
import com.iemr.common.service.grievance.GrievanceDataSync;
import com.iemr.common.service.grievance.GrievanceHandlingService;
import com.iemr.common.utils.exception.IEMRException;
Expand Down Expand Up @@ -117,5 +125,35 @@ public String moveToBin(@RequestBody String request) {
}
return response.toString();
}



@Operation(summary = "get grievance outbound worklist)")
@PostMapping(value = "/getGrievanceOutboundWorklist", consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization")
public ResponseEntity<List<GrievanceWorklistDTO>> getGrievanceOutboundWorklist(@Param(value = "{\"providerServiceMapId\":\" called service ID integer\", "
+ "\"userId\":\"Optional - Integer ID of user that is assigned to\"}") @RequestBody String request) {
logger.info("Request received for grievance worklist");
List<GrievanceWorklistDTO> response = new ArrayList<>();
try {
response = grievanceHandlingService.getFormattedGrievanceData(request);

}

catch (Exception e) {
logger.error("grievanceOutboundWorklist failed with error " + e.getMessage(), e);
List<GrievanceWorklistDTO> errorResponse = new ArrayList<>();
GrievanceWorklistDTO errorDTO = new GrievanceWorklistDTO();
errorDTO.setComplaint("Error fetching grievance data");
errorDTO.setSubjectOfComplaint(e.getMessage());

// Return error response with empty list and error message
errorResponse.add(errorDTO);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(errorResponse);
}


return ResponseEntity.ok(response);
}


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

import lombok.Data;

@Data
public class GetGrievanceWorklistRequest {
private Integer providerServiceMapID;
private Integer userId;

// Constructor
public GetGrievanceWorklistRequest(Integer providerServiceMapID, Integer userId) {
this.providerServiceMapID = providerServiceMapID;
this.userId = userId;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.iemr.common.dto.grivance;

import java.io.Serializable;
import java.sql.Timestamp;


import lombok.Data;

@Data
public class GrievanceTransactionDTO implements Serializable {
private static final long serialVersionUID = 1L;

private String fileName;
private String fileType;
private String redressed;
private Timestamp createdAt;
private Timestamp updatedAt;
private String comment;

// Constructor, Getters, and Setters

public GrievanceTransactionDTO(
String fileName, String fileType,
String redressed, Timestamp createdAt, Timestamp updatedAt, String comment) {
super();
this.fileName = fileName;
this.fileType = fileType;
this.redressed = redressed;
this.createdAt = createdAt;
this.updatedAt = updatedAt;
this.comment = comment;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.iemr.common.dto.grivance;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;


import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class GrievanceWorklistDTO implements Serializable {
private static final long serialVersionUID = 1L;

private String complaintID;
private String subjectOfComplaint;
private String complaint;
private Long beneficiaryRegID;
private Integer providerServiceMapID;
private String firstName;
private String lastName;
private String primaryNumber;
private List<GrievanceTransactionDTO> transactions = new ArrayList<>(); // transactions list
private String severety;
private String state;
private Integer userId;
private Boolean deleted;
private String createdBy;
private Timestamp createdDate;
private Timestamp lastModDate;
private Boolean isCompleted;
private String gender;
private String district;
private Long beneficiaryID;
private String age;
private Boolean retryNeeded;
private Integer callCounter;
// private String lastCall; // Add this field if you want


public GrievanceWorklistDTO(String complaintID, String subjectOfComplaint, String complaint,
Long beneficiaryRegID, Integer providerServiceMapID, String firstName, String lastName,
String primaryNumber, List<GrievanceTransactionDTO> transactions, String severety, String state,
Integer userId, Boolean deleted, String createdBy, Timestamp createdDate, Timestamp lastModDate,
Boolean isCompleted, String gender, String district, Long beneficiaryID, String age,
Boolean retryNeeded, Integer callCounter) {
super();
this.complaintID = complaintID;
this.subjectOfComplaint = subjectOfComplaint;
this.complaint = complaint;
this.beneficiaryRegID = beneficiaryRegID;
this.providerServiceMapID = providerServiceMapID;
this.firstName = firstName;
this.lastName = lastName;
this.primaryNumber = primaryNumber;
this.transactions = transactions;
this.severety = severety;
this.state = state;
this.userId = userId;
this.deleted = deleted;
this.createdBy = createdBy;
this.createdDate = createdDate;
this.lastModDate = lastModDate;
this.isCompleted = isCompleted;
this.gender = gender;
this.district = district;
this.beneficiaryID = beneficiaryID;
this.age = age;
this.retryNeeded = retryNeeded;
this.callCounter = callCounter;
}




}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.iemr.common.repository.grievance;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.query.Procedure;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.iemr.common.data.grievance.GrievanceDetails;


import jakarta.transaction.Transactional;

@Repository
public interface GrievanceOutboundRepository extends JpaRepository<GrievanceDetails, Long> {

@Transactional
@Procedure(procedureName = "Pr_Grievanceworklist")
List<Object[]> getGrievanceWorklistData(@Param("providerServiceMapId") Integer providerServiceMapId,
@Param("userId") Integer userId);

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.iemr.common.service.grievance;

import java.util.List;

import org.json.JSONException;
import org.springframework.stereotype.Service;

import com.iemr.common.dto.grivance.GrievanceWorklistDTO;
import com.iemr.common.utils.exception.IEMRException;

@Service
Expand All @@ -14,5 +17,7 @@ public interface GrievanceHandlingService {
public String reallocateGrievances(String request) throws Exception;

public String moveToBin(String request) throws Exception;

public List<GrievanceWorklistDTO> getFormattedGrievanceData(String request) throws Exception;

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.iemr.common.service.grievance;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
Expand All @@ -15,24 +16,32 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.iemr.common.data.grievance.GetGrievanceWorklistRequest;
import com.iemr.common.data.grievance.GrievanceAllocationRequest;
import com.iemr.common.data.grievance.GrievanceDetails;
import com.iemr.common.data.grievance.GrievanceReallocationRequest;
import com.iemr.common.data.grievance.MoveToBinRequest;
import com.iemr.common.dto.grivance.GrievanceTransactionDTO;
import com.iemr.common.dto.grivance.GrievanceWorklistDTO;
import com.iemr.common.repository.grievance.GrievanceDataRepo;
import com.iemr.common.repository.grievance.GrievanceOutboundRepository;
import com.iemr.common.utils.exception.IEMRException;
import com.iemr.common.utils.mapper.InputMapper;

import jakarta.transaction.Transactional;

@Service
public class GrievanceHandlingServiceImpl implements GrievanceHandlingService {

private Logger logger = LoggerFactory.getLogger(GrievanceHandlingServiceImpl.class);

private final GrievanceDataRepo grievanceDataRepo;
private final GrievanceOutboundRepository grievanceOutboundRepo;

@Autowired
public GrievanceHandlingServiceImpl(GrievanceDataRepo grievanceDataRepo) {
public GrievanceHandlingServiceImpl(GrievanceDataRepo grievanceDataRepo, GrievanceOutboundRepository grievanceOutboundRepo) {
this.grievanceDataRepo = grievanceDataRepo;
this.grievanceOutboundRepo = grievanceOutboundRepo;
}

@Value("${grievanceAllocationRetryConfiguration}")
Expand Down Expand Up @@ -233,5 +242,88 @@ public String moveToBin(String request) throws Exception {
// Step 5: Return the response as count of successfully unassigned grievances
return totalUnassigned + " grievances successfully moved to bin.";
}


@Transactional
public List<GrievanceWorklistDTO> getFormattedGrievanceData(String request) throws Exception {
if (request == null || request.trim().isEmpty()) {
throw new IllegalArgumentException("Request cannot be null or empty");
}

GetGrievanceWorklistRequest getGrievanceWorklistRequest = InputMapper.gson().fromJson(request, GetGrievanceWorklistRequest.class);

List<GrievanceWorklistDTO> formattedGrievances = new ArrayList<>();

// Fetch grievance worklist data using @Procedure annotation
List<Object[]> worklistData;
try {
if (getGrievanceWorklistRequest.getProviderServiceMapID() == null ||
getGrievanceWorklistRequest.getUserId() == null) {
throw new IllegalArgumentException("ProviderServiceMapID and UserId are required");
}
worklistData = grievanceOutboundRepo.getGrievanceWorklistData(getGrievanceWorklistRequest.getProviderServiceMapID(), getGrievanceWorklistRequest.getUserId());
if (worklistData == null || worklistData.isEmpty()) {
logger.info("No grievance data found for the given criteria");
return new ArrayList<>();
}
}
catch (Exception e) {
logger.error("Failed to fetch grievance data: {}", e.getMessage());
throw new Exception("Failed to retrieve grievance data", e);
}

// Loop through the worklist data and format the response
for (Object[] row : worklistData) {
if (row == null || row.length < 28)
{
logger.warn("invalid row data received");
continue;
}
GrievanceWorklistDTO grievance = new GrievanceWorklistDTO(
(String) row[0], // complaintID
(String) row[1], // subjectOfComplaint
(String) row[2], // complaint
(Long) row[3], // beneficiaryRegID
(Integer) row[4],// providerServiceMapID
(String) row[5], // primaryNumber

(String) row[20], // firstName
(String) row[21], // lastName

new ArrayList<>(),// transactions (initially empty, will be populated later)
(String) row[12], // severety
(String) row[13], // state
(Integer) row[14],// userId
(Boolean) row[15],// deleted
(String) row[16],// createdBy
(Timestamp) row[17], // createdDate
(Timestamp) row[18], // lastModDate
(Boolean) row[19], // isCompleted
(String) row[22], // gender
(String) row[23], // district
(Long) row[24], // beneficiaryID
(String) row[25], // age
(Boolean) row[26], // retryNeeded
(Integer) row[27] // callCounter
);

// Extract transactions from the current row and add them to the grievance object
GrievanceTransactionDTO transaction = new GrievanceTransactionDTO(

(String) row[6], // fileName
(String) row[7], // fileType
(String) row[8], // redressed
(Timestamp) row[9], // createdAt
(Timestamp) row[10], // updatedAt
(String) row[11] // comment
);

grievance.getTransactions().add(transaction); // Add the transaction to the grievance's list

// Add the grievance to the result list
formattedGrievances.add(grievance);
}

return formattedGrievances;

}
}
Loading