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.ewv.service.impl;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
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.stereotype.Service;
import gov.va.med.ars.dao.ewv.IEwvClaimRepository;
import gov.va.med.ars.dao.ewv.IEwvHealthInformationRepository;
import gov.va.med.ars.exceptions.GenericException;
import gov.va.med.domain.ewv.EwvClaims;
import gov.va.med.domain.ewv.EwvHealthInformation;
import gov.va.med.ewv.model.response.HealthCareInfoResponse;
import gov.va.med.ewv.model.response.HealthCareInformationLine;
import gov.va.med.ewv.service.IEwvHealthCareInfoService;
import gov.va.med.ewv.util.HealthInfoType;
import gov.va.med.ewv.util.PdiFilterUtil;
@Service
public class EwvHealthCareInfoServiceImpl implements IEwvHealthCareInfoService {
private static final Logger logger = LogManager.getLogger(EwvHealthCareInfoServiceImpl.class);
@Autowired
IEwvHealthInformationRepository ewvHealthInformationRepository;
@Autowired
IEwvClaimRepository ewvClaimRepository;
@Override
public List<HealthCareInformationLine> populateHealthCareInfoLine(HealthInfoType healthInfoType,
EwvClaims claim) {
// if (healthInfoType == null) {
// logger.info("Invoked populateHealthCareInfoLine(null, ) for claim guid :"+claim.getGuid());
// } else {
logger.info("Invoked populateHealthCareInfoLine(" + healthInfoType + ",) for claim guid :"+claim.getGuid());
// }
Set<EwvHealthInformation> healthInfo = ewvHealthInformationRepository.getHealthInformationoByClaimGuid(claim.getGuid());
ArrayList<HealthCareInformationLine> returnList = new ArrayList<HealthCareInformationLine>(0);
for (EwvHealthInformation info : healthInfo)
{
// TODO Greg was indicating this as a temp solution, will need to be changed
HealthInfoType typeOf = HealthInfoType.typeOf(info.getQualifier());
if (typeOf != null && typeOf.equals(healthInfoType))
{
returnList.add(createHealthCareInformationList(info, typeOf));
}
}
//if ((!accumulated) && (healthCareInformationLineList.size() > 0))
if (returnList.size() > 1)
{
// based on sequence (info.getHiSeq() if it exists, else 0L)
// Sequence seems like a strange Natural Order. Probably wrongly conceived.
Collections.sort(returnList);
}
logger.info("Exiting populateHealthCareInfoLine(" + healthInfoType + ",) for claim guid :" +
claim.getGuid() + " [" + returnList.size() + "]");
return returnList;
}
@Override
public HealthCareInformationLine createHealthCareInformationList
(EwvHealthInformation info, HealthInfoType typeOf)
{
logger.info("Invoked createHealthCareInformationList(, " + typeOf + ") ");
String qualifier = info.getQualifier();
String description = info.getDescription();
String code = info.getCode();
String date = info.getClaimDate();
String format = info.getFormat();
String amount = info.getAmount();
Long sequence = 0L;
if (info.getHiSeq() != null )
sequence = info.getHiSeq().longValue();
HealthCareInformationLine bean = new HealthCareInformationLine(
sequence,
typeOf,
qualifier,
description,
code,
date,
format,
amount);
logger.info("Exiting createHealthCareInformationList(, " + typeOf + ") ");
return bean;
}
@Override
public HealthCareInfoResponse populateHealthCareInfoResponse(String unfilteredPdiNumber) throws GenericException {
logger.info("Invoked populateHealthCareInfoResponse() for pdiNumber :"+unfilteredPdiNumber);
PdiFilterUtil ewvFilterUtil = new PdiFilterUtil();
String pdiNumber = ewvFilterUtil.filterPdiNumber(unfilteredPdiNumber);
EwvClaims claim = ewvClaimRepository.getEwvClaimByPdiNumber(pdiNumber);
if(claim == null) {
String errorDescription = "PDI number "+unfilteredPdiNumber+" cannot be found.";
logger.error(errorDescription);
throw new GenericException("ERROR", errorDescription, HttpStatus.NOT_FOUND);
}
List<HealthCareInformationLine> healthCareValueInformationBeanList
= populateHealthCareInfoLine(HealthInfoType.VALUE, claim);
List<HealthCareInformationLine> healthCareConditionInformationBeanList
= populateHealthCareInfoLine(HealthInfoType.CONDITION, claim);
List<HealthCareInformationLine> healthCareOccurranceSpanInformationBeanList
= populateHealthCareInfoLine(HealthInfoType.OCCUR_SPAN, claim);
List<HealthCareInformationLine> healthCareOccurranceInformationBeanList
= populateHealthCareInfoLine(HealthInfoType.OCCUR, claim);
List<HealthCareInformationLine> healthCareDRGInformationBeanList
= populateHealthCareInfoLine(HealthInfoType.DRG, claim);
HealthCareInfoResponse healthCareInfoResponse = new HealthCareInfoResponse();
healthCareInfoResponse.setHealthCareConditionInformationBeanList(healthCareConditionInformationBeanList);
healthCareInfoResponse.setHealthCareDRGInformationBeanList(healthCareDRGInformationBeanList);
healthCareInfoResponse.setHealthCareOccurranceInformationBeanList(healthCareOccurranceInformationBeanList);
healthCareInfoResponse.setHealthCareOccurranceSpanInformationBeanList(healthCareOccurranceSpanInformationBeanList);;
healthCareInfoResponse.setHealthCareValueInformationBeanList(healthCareValueInformationBeanList);
logger.info("Exiting populateHealthCareInfoResponse() for pdiNumber :"+unfilteredPdiNumber);
return healthCareInfoResponse;
}
@Override
public HealthCareInfoResponse populateHealthCareInfoResponse(EwvClaims claim) throws GenericException {
logger.info("Invoked populateHealthCareInfoResponse() for claim guid :"+claim.getGuid());
List<HealthCareInformationLine> healthCareValueInformationBeanList
= populateHealthCareInfoLine(HealthInfoType.VALUE, claim);
List<HealthCareInformationLine> healthCareConditionInformationBeanList
= populateHealthCareInfoLine(HealthInfoType.CONDITION, claim);
List<HealthCareInformationLine> healthCareOccurranceSpanInformationBeanList
= populateHealthCareInfoLine(HealthInfoType.OCCUR_SPAN, claim);
List<HealthCareInformationLine> healthCareOccurranceInformationBeanList
= populateHealthCareInfoLine(HealthInfoType.OCCUR, claim);
List<HealthCareInformationLine> healthCareDRGInformationBeanList
= populateHealthCareInfoLine(HealthInfoType.DRG, claim);
HealthCareInfoResponse healthCareInfoResponse = new HealthCareInfoResponse();
healthCareInfoResponse.setHealthCareConditionInformationBeanList(healthCareConditionInformationBeanList);
healthCareInfoResponse.setHealthCareDRGInformationBeanList(healthCareDRGInformationBeanList);
healthCareInfoResponse.setHealthCareOccurranceInformationBeanList(healthCareOccurranceInformationBeanList);
healthCareInfoResponse.setHealthCareOccurranceSpanInformationBeanList(healthCareOccurranceSpanInformationBeanList);;
healthCareInfoResponse.setHealthCareValueInformationBeanList(healthCareValueInformationBeanList);
logger.info("Exiting populateHealthCareInfoResponse() for claim guid :"+claim.getGuid());
return healthCareInfoResponse;
}
}