Summary Table
Categories |
Total Count |
PII |
0 |
URL |
0 |
DNS |
0 |
EKL |
0 |
IP |
0 |
PORT |
0 |
VsID |
0 |
CF |
0 |
AI |
0 |
VPD |
0 |
PL |
0 |
Other |
0 |
File Content
package gov.va.med.ars.controller;
import java.util.List;
import javax.validation.Valid;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import gov.va.med.ars.exceptions.GenericException;
import gov.va.med.ars.model.request.SearchClaimAttachments275Request;
import gov.va.med.ars.model.response.GenericResponse;
import gov.va.med.ars.model.response.PdiRelatedInfoResponse;
import gov.va.med.ars.service.IPdiRelatedAttachmentsService;
import gov.va.med.ars.service.ISearchClaimAttachments275Service;
import net.minidev.json.JSONObject;
@RestController
@RequestMapping("api/v1/searchClaimAttachments275")
public class SearchClaimAttachments275Controller {
private static final Logger logger = LogManager.getLogger(SearchClaimAttachments275Controller.class);
@Autowired
ISearchClaimAttachments275Service searchClaimAttachments275Service;
@Autowired
IPdiRelatedAttachmentsService pdiRelatedAttachmentsService;
@PostMapping(value = "/search")
public ResponseEntity<?> searchClaimAttachments(
@Valid @RequestBody SearchClaimAttachments275Request searchClaimAttachments275Request)
throws GenericException {
try {
logger.info("searching 275");
if (searchClaimAttachments275Request == null) {
logger.info("searchClaimAttachments275Request is null");
}
GenericResponse myResponse = searchClaimAttachments275Service
.getAll275SearchResult(searchClaimAttachments275Request);
if (myResponse != null)
logger.info("getAll275SearchResult().getpageNumber()= " + myResponse.getpageNumber());
else {
logger.info("getAll275SearchResult() is null, returning SERVICE_UNAVAILABLE");
return new ResponseEntity<>(null, HttpStatus.SERVICE_UNAVAILABLE);
}
return new ResponseEntity<>(myResponse, HttpStatus.OK);
} catch (Exception e) {
logger.error("searchClaimAttachments() exception occured " + e.getMessage());
throw e;
}
}
@GetMapping(value = "/{pdiNumber}")
public ResponseEntity<?> getPdiRelatedAttachmentsDetails(@PathVariable("pdiNumber") String pdiNumber) {
JSONObject response = new JSONObject();
try {
List<PdiRelatedInfoResponse> pdiRelatedInfoResponse = pdiRelatedAttachmentsService
.getPdiRelatedAttachments(pdiNumber);
if (pdiRelatedInfoResponse != null && !pdiRelatedInfoResponse.isEmpty()) {
response.put("pdiRelatedResponse", pdiRelatedInfoResponse);
return new ResponseEntity<>(response, HttpStatus.OK);
} else if (pdiRelatedInfoResponse != null && pdiRelatedInfoResponse.isEmpty()) {
response.put("errorCode", "No attachments found");
response.put("message", "Entered Pdi doesn't have any attachments");
return new ResponseEntity<>(response, HttpStatus.OK);
}
response.put("errorCode", "Entered Pdi is not valid");
response.put("message", "Pdi is not valid");
return new ResponseEntity<>(response, HttpStatus.NOT_FOUND);
} catch (Exception e) {
logger.error("getPdiRelatedAttachmentsDetails() exception occured " + e.getMessage());
logger.error("searchAllUsers() exception occured " + e.getMessage());
response.put("errorCode", "Error in Server");
response.put("message", "Server Error");
return new ResponseEntity<JSONObject>(response, HttpStatus.INTERNAL_SERVER_ERROR);
}
}
}