Summary Table
Categories |
Total Count |
PII |
0 |
URL |
0 |
DNS |
1 |
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.math.BigInteger;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import gov.va.med.ars.exceptions.EntityNotFoundException;
import gov.va.med.ars.exceptions.GenericException;
import gov.va.med.ars.exceptions.ValidationException;
import gov.va.med.ars.model.response.RfaiResponse;
import gov.va.med.ars.service.IRfaiPopulateClaimService;
import gov.va.med.ars.validators.NumberValidator;
import net.minidev.json.JSONObject;
/**
* @author
DNS
*
*/
@RestController
@RequestMapping("api/v1/populateClaim")
public class RfaiPopulateClaimController extends NumberValidator {
private static final Logger logger = LogManager.getLogger(RfaiPopulateClaimController.class);
@Autowired
IRfaiPopulateClaimService rfaiService;
@GetMapping("/{id}")
public ResponseEntity<?> getClaim(@Valid @PathVariable("id") String id)
throws ValidationException, GenericException, EntityNotFoundException {
JSONObject response = null;
// Boolean isValid;
try {
if (id != null && !id.isEmpty()) {
if (isValidNumber(id) != null) {
logger.info("RfaiController:getClaim() received the request for claim Number :" + id);
logger.debug("RfaiController:getClaim() invoking the rfaiService.populateRfaiInfo() for claim index"
+ id);
RfaiResponse rfaiResponse = rfaiService.populateRfaiInfo(new BigInteger(id));
if (rfaiResponse == null) {
return new ResponseEntity<>("No Claim found for ID " + id, HttpStatus.NOT_FOUND);
}
return new ResponseEntity<>(rfaiResponse, HttpStatus.OK);
} else {
return new ResponseEntity<>("No Claim found for ID " + id, HttpStatus.NOT_FOUND);
}
} else {
response = new JSONObject();
logger.warn("getClaim : no Claim Number passed for " + id);
response.put("errorCode", "Un-Authorized");
response.put("message",
"The entered user has no populate claims in the application since the claim Number is empty");
return new ResponseEntity<>(response, HttpStatus.NOT_FOUND);
}
} catch (GenericException e) {
logger.error(
"RfaiController:getClaim() exception occured for claim index : " + id + " - " + e.getMessage());
throw e;
}
}
@GetMapping("pendingSubmission/{id}")
public ResponseEntity<?> checkPendingSubmissions(@Valid @PathVariable("id") String id)
throws ValidationException, GenericException, EntityNotFoundException {
JSONObject response = new JSONObject();
try {
if (id != null && !id.isEmpty()) {
if (isValidNumber(id) != null) {
logger.info("checkPendingSubmissions() received the request for claim Number :" + (id));
Boolean pendingSubmission = rfaiService.getClaimSubmissionStatus(new BigInteger(id));
if (pendingSubmission == true) {
response.put("pendingSubmission", Boolean.TRUE);
} else {
response.put("pendingSubmission", Boolean.FALSE);
}
return new ResponseEntity<>(response, HttpStatus.OK);
} else {
return new ResponseEntity<>("No Claim found for ID " + id, HttpStatus.NOT_FOUND);
}
} else {
logger.warn("checkPendingSubmissions(): no Claim Number passed for " + id);
response.put("errorCode", "Un-Authorized");
response.put("message",
"The entered user has no populate claims in the application since the claim Number is empty");
return new ResponseEntity<>(response, HttpStatus.NOT_FOUND);
}
} catch (GenericException e) {
logger.error(
"checkPendingSubmissions() exception occured for claim index : " + id + " - " + e.getMessage());
throw e;
}
}
}