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.oneconsult.seoc.api.controller;

import java.util.Set;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;

import gov.va.oneconsult.seoc.api.model.BillingCode;
import gov.va.oneconsult.seoc.api.model.CategoryOfCare;
import gov.va.oneconsult.seoc.api.model.ClinicalService;
import gov.va.oneconsult.seoc.api.model.Hptc;
import gov.va.oneconsult.seoc.api.model.Qasp;
import gov.va.oneconsult.seoc.api.model.ServiceLine;
import gov.va.oneconsult.seoc.api.serializer.StringSerializer;
import gov.va.oneconsult.seoc.api.service.GenericService;
import gov.va.oneconsult.seoc.api.util.EncodeLoggerFactory;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;

@CrossOrigin
@RestController
@RequestMapping(value = "v1/lookup")
@Api(value = "LookupController", description = "Allows to list All lookup values")
public class LookUpController
{

@Autowired
private GenericService genericService;

public static final Logger logger = EncodeLoggerFactory.getLogger(LookUpController.class);


private static ObjectMapper mapper = new ObjectMapper();
private static SimpleModule module = new SimpleModule("StringSerializer",
new Version(1, 0, 0, null, null, null));


static {
module.addSerializer((Class<String>) String.class,
new StringSerializer());
mapper.registerModule(module);
}

/**
* Description:
* @return
*/
@ApiOperation(value = "readAllCategoryOfCare", notes = "Get all Category Of Care look up values", nickname = "getall")
@ApiResponses(value = { @ApiResponse(code = 204, message = "No Content Found"),
@ApiResponse(code = 200, message = "Successful retrieval", response = SeocController.class, responseContainer = "Set") })
@RequestMapping(value = "/categoryofcare", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<String> getAllCategoryOfCare()
{

logger.info("Get all categoryOfCare : {}");

Set<CategoryOfCare> completeSet = genericService.getAllCategoryOfCare();

try
{
String result = mapper.writeValueAsString(completeSet);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
return new ResponseEntity<String>(result, headers, HttpStatus.OK);
} catch (JsonProcessingException e)
{
logger.error("Json Exception occured in retreiving category of care data."+ e.getMessage());
return new ResponseEntity<String>("Unable to Retreive CategoryOfCare Data", HttpStatus.NO_CONTENT);
}

}

/**
* Description:
* @return
*/
@ApiOperation(value = "readAllServiceLine", notes = "Get all Service Line look up values", nickname = "getall")
@ApiResponses(value = { @ApiResponse(code = 204, message = "No Content Found"),
@ApiResponse(code = 200, message = "Successful retrieval", response = SeocController.class, responseContainer = "Set") })
@RequestMapping(value = "/serviceline", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<String> getAllServiceLine()
{

logger.info("Get all ServiceLine : {}");

try
{
Set<ServiceLine> completeSet = genericService.getAllServiceLine();
String result = mapper.writeValueAsString(completeSet);

HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
return new ResponseEntity<String>(result, headers, HttpStatus.OK);
} catch (JsonProcessingException e)
{
logger.error("Json Exception occured in retreiving service line data."+ e.getMessage());
return new ResponseEntity<String>("Unable to Retreive ServiceLine Data", HttpStatus.NO_CONTENT);
}

}

/**
* Description:
* @param desc
* @return
*/
@ApiOperation(value = "readServiceLineByDescription", notes = "Service Line by description", nickname = "ServiceByDesc")
@ApiResponses(value = { @ApiResponse(code = 204, message = "No Content Found"),
@ApiResponse(code = 200, message = "Successful retrieval", response = SeocController.class, responseContainer = "Set") })
@RequestMapping(value = "/serviceline/{desc:.+}", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<String> getByServiceLineByDesc(
@PathVariable("desc") String desc)
{

logger.info("Get by ServiceLine description: {}");

try
{
Set<ServiceLine> completeSet = genericService.getServiceLineByDescription(desc);
String result = mapper.writeValueAsString(completeSet);

HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
return new ResponseEntity<String>(result, headers, HttpStatus.OK);
} catch (JsonProcessingException e)
{
logger.error("Json Exception occured in retreiving service line by desccription."+ e.getMessage());
return new ResponseEntity<String>("Unable to Retreive ServiceLine by description", HttpStatus.NO_CONTENT);
}

}

/**
* Description:
* @return
*/
@ApiOperation(value = "readAllClinicalService", notes = "Get all ClinicalService look up values", nickname = "getall")
@ApiResponses(value = { @ApiResponse(code = 204, message = "No Content Found"),
@ApiResponse(code = 200, message = "Successful retrieval", response = SeocController.class, responseContainer = "Set") })
@RequestMapping(value = "/clinicalservice", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<String> getAllClinicalService()
{

logger.info("Get all clinical Service : {}");

try
{
Set<ClinicalService> completeSet = genericService.getAllClinicalService();
String result = mapper.writeValueAsString(completeSet);

HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
return new ResponseEntity<String>(result, headers, HttpStatus.OK);
} catch (JsonProcessingException e)
{
logger.error("Json Exception occured in retreiving clinical service data."+ e.getMessage());
return new ResponseEntity<String>("Unable to Retreive ClinicalService Data", HttpStatus.NO_CONTENT);
}

}


/**
* Description: Read all active BillingCodes
* @return Returns {@link ResponseEntity} with the list of {@link BillingCode} objects
* and status of the response
*/
@ApiOperation(value = "readAllBillingCode", notes = "Get all Billing Code look up values", nickname = "getall")
@ApiResponses(value = { @ApiResponse(code = 204, message = "No Content Found"),
@ApiResponse(code = 200, message = "Successful retrieval", response = SeocController.class, responseContainer = "Set") })
@RequestMapping(value = "/billingcode", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<String> getAllBillingCode()
{
logger.info("Get all Billing Code : {}");

try
{
Set<BillingCode> completeSet = genericService.getAllBillingCode();
String result = mapper.writeValueAsString(completeSet);

HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
return new ResponseEntity<String>(result, headers, HttpStatus.OK);
} catch (JsonProcessingException e)
{
logger.error("Json Exception occured in retreiving billing code data"+ e.getMessage());
return new ResponseEntity<String>("Unable to Retreive BillingCode Data", HttpStatus.NO_CONTENT);
}

}


/**
* Description: Retrieve BillingCode by billingCode
* @param billingCode
* - billingCode of the billing code object to be retrieved
* @return Returns {@link ResponseEntity} with the {@link BillingCode} object found and
* status of the response
*/
@ApiOperation(value = "ReadByBillingCode", notes = "Get Billing Code by Billing Code", nickname = "getByBillingCode")
@ApiResponses(value = { @ApiResponse(code = 204, message = "No Content Found"),
@ApiResponse(code = 200, message = "Successful retrieval", response = SeocController.class, responseContainer = "Set") })
@RequestMapping(value = "/billingcode/{billingcode:.+}", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<String> getBillingCodeBybillingCode(
@PathVariable("billingcode") String billingcode)
{

logger.info("Get by BillingCode billingcode: {}");

try
{
Set<BillingCode> completeSet = genericService.getBillingCodeBybillingCode(billingcode);
String result = mapper.writeValueAsString(completeSet);

HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
return new ResponseEntity<String>(result, headers, HttpStatus.OK);
} catch (JsonProcessingException e)
{
logger.error("Json Exception occured in retreiving billing code data by billing code."+ e.getMessage());
return new ResponseEntity<String>("Unable to Retreive BillingCode ", HttpStatus.NO_CONTENT);
}

}


/**
* Description: Read all QASPs
* @return Returns {@link ResponseEntity} with the list of {@link Qasp} objects
* and status of the response
*/
@ApiOperation(value = "readAllQasp", notes = "Get all QASP look up values", nickname = "getall")
@ApiResponses(value = { @ApiResponse(code = 204, message = "No Content Found"),
@ApiResponse(code = 200, message = "Successful retrieval", response = SeocController.class, responseContainer = "Set") })
@RequestMapping(value = "/qasp", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<String> getAllQasp()
{

logger.info("Get all QASP : {}");

try
{
Set<Qasp> completeSet = genericService.getAllQasp();
String result = mapper.writeValueAsString(completeSet);

HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
return new ResponseEntity<String>(result, headers, HttpStatus.OK);
} catch (JsonProcessingException e)
{
logger.error("Json Exception occured in retreiving QASP data."+ e.getMessage());
return new ResponseEntity<String>("Unable to Retreive Qasp data ", HttpStatus.NO_CONTENT);
}

}



/**
* Description: Read all HPTCs
* @return Returns {@link ResponseEntity} with the list of {@link Hptc} objects
* and status of the response
*/
@ApiOperation(value = "readAllHptc", notes = "Get all HPTC look up values", nickname = "getall")
@ApiResponses(value = { @ApiResponse(code = 204, message = "No Content Found"),
@ApiResponse(code = 200, message = "Successful retrieval", response = LookUpController.class, responseContainer = "Set") })
@RequestMapping(value = "/hptc", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<String> getAllHptc()
{

logger.info("Get all HPTC : {}");

try
{
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);

Set<Hptc> completeSet = genericService.getAllHptc();

if (completeSet == null || completeSet.isEmpty())
{
return new ResponseEntity<String>("HPTC data is not available.",
HttpStatus.NO_CONTENT);
} else
{
String result = mapper.writeValueAsString(completeSet);
return new ResponseEntity<String>(result, headers, HttpStatus.OK);
}
} catch (JsonProcessingException e)
{
logger.error("Json Exception occured in retreiving HPTC data" + e.getMessage());
return new ResponseEntity<String>("Unable to Retreive HPTC data ", HttpStatus.NO_CONTENT);
}

}

}