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

/*
* SeocServiceHelper.java
* Copyright (c) 2017 Veterans Affairs.
*/
package gov.va.oneconsult.seoc.api.service.impl;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;

import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;

import org.apache.log4j.Logger;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;

import gov.va.oneconsult.seoc.api.exceptions.BusinessException;
import gov.va.oneconsult.seoc.api.exceptions.CodeRequiredNotValidException;
import gov.va.oneconsult.seoc.api.exceptions.InvalidSeocRequestException;
import gov.va.oneconsult.seoc.api.exceptions.SeocConstraintViolationException;
import gov.va.oneconsult.seoc.api.model.BillingCode;
import gov.va.oneconsult.seoc.api.model.ClinicalService;
import gov.va.oneconsult.seoc.api.model.CodeRequired;
import gov.va.oneconsult.seoc.api.model.Hptc;
import gov.va.oneconsult.seoc.api.model.PayableService;
import gov.va.oneconsult.seoc.api.model.Seoc;
import gov.va.oneconsult.seoc.api.model.Status;
import gov.va.oneconsult.seoc.api.util.ApiUtil;
import gov.va.oneconsult.seoc.api.util.EncodeLoggerFactory;
import gov.va.oneconsult.seoc.api.validation.SeocActivationValidator;

/**
* Helper class contains utility methods used by SeocService
*
* @author AbleVets
*
*/
public class SeocServiceHelper
{

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


/**
* Description:Compare source services with the request services. Deleted
* removed services from the source, update continuing services and add new
* services.
*
* @param sourceSeoc - Seoc before edit
* @param reqSeoc - Seoc after edit
* @return - Updated set of payable services
*/
public static List<PayableService> syncServices(Seoc sourceSeoc, Seoc reqSeoc)
{
List<PayableService> deletedServices = null;
List<PayableService> sourceServices = sourceSeoc.getServices();
List<PayableService> reqServices = reqSeoc.getServices();
List<PayableService> responseServices = new ArrayList<PayableService>();

logger.info("Start updating source service set with the request services");

// Both source and request service sets are empty. Services are not
// edited.
if ((reqServices == null || reqServices.isEmpty())
&& (sourceServices == null || sourceServices.isEmpty()))
{
logger.info("No change in the services");
return responseServices;
}

/*
* Find deleted services and remove from the source set. Covers partial
* edit(delete) and complete delete scenarios.
*/
deletedServices = findDeletedServices(sourceServices, reqServices);
// Remove each deleted service from the source list.
if (deletedServices != null && !deletedServices.isEmpty())
{
deletedServices.forEach(ds ->
{
// Remove service from the source list.
if (sourceServices.contains(ds))
{

sourceServices.remove(ds);
ds.setSeoc(null);
}

logger.info("Deleted service " + ds.getDescription()
+ " from source. Size after deletion " + sourceServices.size());
});

}

if (reqServices == null || reqServices.isEmpty())
{
// Request services set is empty and all services have been deleted
// from the source services in previous step.
logger.info("No new services added all existing services deleted.");
return sourceServices;
}

/*
* Update existing service data with data coming from the request and add new
* services Covers partial edit(add), update existing and complete new service
* scenarios.
*/

reqServices.forEach(reqService ->
{
// For each existing Service
// If the services is pre existing its Id is available
if (reqService != null && reqService.getId() > 0)
{
Optional<PayableService> sourceService = sourceServices.stream()
.filter(s -> s.getId() == reqService.getId()).findFirst();

sourceService.ifPresent(ss ->
{
ss.setDescription(reqService.getDescription());
ss.setClinicalServices(syncClinicalServices(ss, reqService));
ss.setFrequency(reqService.getFrequency());
ss.setFrequencyType(reqService.getFrequencyType());
ss.setVisits(reqService.getVisits());
ss.setCodeRequired(reqService.getCodeRequired());
ss.setCodedBy(reqService.getCodedBy());
ss.setCodedTimestamp(reqService.getCodedTimestamp());
ss.setBillingCodes(syncBillingCodes(ss, reqService));
logger.info("Updated data for service " + reqService.getId()
+ " from the request.");
});
if (!sourceService.isPresent())
{
// A continuing service in request not found in source
logger.error("No match found for existing service " + reqService.getId()
+ " in the source.");
throw new InvalidSeocRequestException("No match found for existing service "
+ reqService.getId() + " in the source.");
}

} else
{
logger.info("New Service added to the Seoc.");
// It is a new service from the request add to the source set.
if (reqService != null) {
reqService.setSeoc(sourceSeoc);
}
sourceServices.add(reqService);
}
});

logger.info("Completed updating source services with the request values.");
return sourceServices;
}

/**
* Description: Compare source services with the request services to find the
* services which are deleted from the request.
*
* @param sourceServices - services coming from the database. Set of services
* before editing the seoc.
* @param reqServices - services coming from the request. Current set of
* services for the seoc.
* @return - Deleted set of services from the seoc
*/
public static List<PayableService> findDeletedServices(List<PayableService> sourceServices,
List<PayableService> reqServices)
{
List<PayableService> deletedServices = new ArrayList<PayableService>();

logger.info("Finding deleted services");

// If both the sets are not null. Then find difference and update the
// source set.
if (sourceServices != null && !sourceServices.isEmpty() && reqServices != null
&& !reqServices.isEmpty())
{
// For each of the source service
sourceServices.forEach(ss ->
{
// check for a match in the request billing code. Finding match
// from existing services
boolean serviceMatch = reqServices.stream()
.anyMatch(rs -> (rs.getId() > 0 && rs.getId() == ss.getId()));
// if no match found
if (!serviceMatch)
{
logger.info("Service " + ss.getId() + " was deleted from the seoc.");
// mark this service for deletion
deletedServices.add(ss);
}
});
} else if (sourceServices != null && !sourceServices.isEmpty())
{
// Delete all services from the source set.
logger.info("Request service set is empty. Delete all services from the source seoc.");
deletedServices.addAll(sourceServices);
}

return deletedServices;
}

/**
* Description: Compare billing codes before and after edit request and update
* the database object before saving.
*
* @param sourceService - Service object from the database before edit.
* @param requestService - Service object from the request after edit.
* @return - Updated set of source billing codes
*/
public static Set<BillingCode> syncBillingCodes(PayableService sourceService,
PayableService requestService)
{
Set<BillingCode> deletedBillingCodes = null;
Set<BillingCode> newBillingCodes = null;
Set<BillingCode> sourceBillingCodes = sourceService.getBillingCodes();
Set<BillingCode> reqBillingCodes = requestService.getBillingCodes();

logger.info("Start updating source billing code set with the request values");

// Both source and request billing codes sets are empty. Billing codes
// not edited.
if ((reqBillingCodes == null || reqBillingCodes.isEmpty())
&& (sourceBillingCodes == null || sourceBillingCodes.isEmpty()))
{
logger.info("No change in the billing codes");
return null;
}

/*
* Find deleted billing codes and remove from the source set. Covers partial
* edit(delete) and complete delete scenarios.
*/
deletedBillingCodes = findDeletedBillingCodes(sourceBillingCodes, reqBillingCodes);
// For each of the deleted billing codes. Remove mutual association
// between two entities source service and billing code.
deletedBillingCodes.forEach(dbc ->
{
// Remove billing code from the source list.
sourceBillingCodes.remove(dbc);
});
/*
* Find new billing codes in the request and add them to the source set. Covers
* partial edit(add) and complete new scenarios.
*/
newBillingCodes = findNewBillingCodes(sourceBillingCodes, reqBillingCodes);
// For each new billing code establish association between billing code
// and source service
newBillingCodes.forEach(nbc ->
{
// Add billing code to the source service
sourceBillingCodes.add(nbc);
});

logger.info(
"Completed updating source billing code set to reflect changes in the request billing code set.");

return sourceBillingCodes;
}

/**
* Description: Compare Source Billing Codes set with Request Billing Codes set.
* If a billing code is available in source but not available in the request
* that will be added to the list of deleted billing codes.
*
* @param sourceBillingCodes - Billing Codes coming from the database. Set of
* billing code before editing the service.
* @param reqBillingCodes - BillingCodes coming from the request. Current set of
* billing codes for the service.
* @return - Deleted set of billing codes from the service
*/
public static Set<BillingCode> findDeletedBillingCodes(Set<BillingCode> sourceBillingCodes,
Set<BillingCode> reqBillingCodes)
{
Set<BillingCode> deletedBillingCodes = new HashSet<BillingCode>();

logger.info("Finding deleted billing codes");

// If both the sets are not null. Then find difference and update the
// source set.
if (sourceBillingCodes != null && !sourceBillingCodes.isEmpty() && reqBillingCodes != null
&& !reqBillingCodes.isEmpty())
{
// For each of the source billing code
sourceBillingCodes.forEach(sbc ->
{
// check for a match in the request billing code
boolean billingCodeMatch = reqBillingCodes.stream()
.anyMatch(rbc -> rbc.getBillingCode().equals(sbc.getBillingCode()));
// if no match found
if (!billingCodeMatch)
{
logger.info("BillingCode " + sbc.getBillingCode()
+ " was deleted from the service.");
// mark this billing code for deletion
deletedBillingCodes.add(sbc);
}
});
} else if (sourceBillingCodes != null && !sourceBillingCodes.isEmpty())
{
// Delete all billing codes from the source set.
logger.info(
"Request billing code set is empty. Delete all billing codes from the source service.");
deletedBillingCodes.addAll(sourceBillingCodes);
}

return deletedBillingCodes;
}

/**
* Description: Compare Source Billing Codes set with Request Billing Codes set.
* If a billing code is available in request but not available in the source
* that will be added to the list of new billing codes.
*
* @param sourceBillingCodes - Billing Codes coming from the database. Set of
* billing code before editing the service.
* @param reqBillingCodes - BillingCodes coming from the request. Current set of
* billing codes for the service.
* @return - newly added set of billing codes from the service
*/
public static Set<BillingCode> findNewBillingCodes(Set<BillingCode> sourceBillingCodes,
Set<BillingCode> reqBillingCodes)
{
Set<BillingCode> newBillingCodes = new HashSet<BillingCode>();

logger.info("Finding newly added billing codes");

// If both the sets are not null. Then find difference and update the
// source set.
if (sourceBillingCodes != null && !sourceBillingCodes.isEmpty() && reqBillingCodes != null
&& !reqBillingCodes.isEmpty())
{
// For each of the request billing code
reqBillingCodes.forEach(rbc ->
{
// check for a match in the source billing code
boolean billingCodeMatch = sourceBillingCodes.stream()
.anyMatch(sbc -> sbc.getBillingCode().equals(rbc.getBillingCode()));
// if no match found
if (!billingCodeMatch)
{
logger.info("BillingCode " + rbc.getBillingCode()
+ " is newly added to the service.");
// add this billing code to the new set
newBillingCodes.add(rbc);
}
});
} else if (reqBillingCodes != null && !reqBillingCodes.isEmpty())
{
// Add all billing codes from the source set.
logger.info(
"Source billing code set is empty. Add all billing codes from the request service.");
newBillingCodes.addAll(reqBillingCodes);
}

return newBillingCodes;
}

/**
* Description: Compare hptcs before and after edit request and update the
* database object before saving.
*
* @param sourceSeoc - Seoc object from the database before edit.
* @param reqSeoc - Seoc object from the request after edit.
* @return - Updated set of source hptcs
*/
public static Set<Hptc> syncHptcs(Seoc sourceSeoc, Seoc reqSeoc)
{
Set<Hptc> reqHptcs = reqSeoc.getHptcs();
Set<Hptc> sourceHptcs = sourceSeoc.getHptcs();
Set<Hptc> responseHptcs = new HashSet<Hptc>();
Set<Hptc> newHptcs = null;
Set<Hptc> deletedHptcs = null;

// Both source and request hptcs sets are empty. Hptcs are not
// edited.
if ((reqHptcs == null || reqHptcs.isEmpty())
&& (sourceHptcs == null || sourceHptcs.isEmpty()))
{
logger.info("No change in the services");
return responseHptcs;
}

/*
* Find deleted hptcs and remove from the source set. Covers partial
* edit(delete) and complete delete scenarios.
*/
deletedHptcs = findDeletedHptcs(sourceHptcs, reqHptcs);
// For each of the deleted hptc. Remove association
// between two entities source seoc and hptc.
deletedHptcs.forEach(hptc ->
{
// Remove hptc from the source set.
sourceHptcs.remove(hptc);
});

/*
* Find new hptcs in the request and add them to the source set. Covers partial
* edit(add) and complete new scenarios.
*/
newHptcs = findNewHptcs(sourceHptcs, reqHptcs);
// For each new hptc establish association between hptc
// and source seoc
newHptcs.forEach(nbc ->
{
// Add hptcs to the source seoc
sourceHptcs.add(nbc);
});

logger.info(
"Completed updating source hptc set to reflect changes in the request hptc set.");

return sourceHptcs;

}

/**
* Description: Compare Source HPTC set with Request HPTC set. If a hptc is
* available in request but not available in the source that will be added to
* the list of new HPTC set.
*
* @param sourceHptcs - Hptcs coming from the database. Set of hptcs before
* editing the seoc.
* @param reqHptcs - Hptcs coming from the request. Current set of hptcs for the
* seoc.
* @return - newly added set of hptcs from the seoc
*/
public static Set<Hptc> findNewHptcs(Set<Hptc> sourceHptcs, Set<Hptc> reqHptcs)
{
Set<Hptc> newHptcs = new HashSet<Hptc>();

logger.info("Finding newly added Hptcs");

// If both the sets are not null. Then find difference and update the
// source set.
if (sourceHptcs != null && !sourceHptcs.isEmpty() && reqHptcs != null
&& !reqHptcs.isEmpty())
{
// For each of the request hptcs
reqHptcs.forEach(rhptc ->
{
// check for a match in the source hptcs
boolean hptcMatch = sourceHptcs.stream()
.anyMatch(shptc -> shptc.getHptc().equals(rhptc.getHptc()));
// if no match found
if (!hptcMatch)
{
logger.info("Hptc " + rhptc.getHptc() + " is newly added to the seoc.");
// add this HPTC to the new set
newHptcs.add(rhptc);
}
});
} else if (reqHptcs != null && !reqHptcs.isEmpty())
{
// Add all hptcs from the request set.
logger.info("Source hptc set is empty. Add all hptcs from the request service.");
newHptcs.addAll(reqHptcs);
}

return newHptcs;
}

/**
* Description: Compare source Hptcs with request Hptcs. Hptc found in source
* not found in request will be considered as deleted Hptcs.
*
* @param sourceHptcs - Hptcs found in the seoc from database.
* @param reqHptcs - Hptcs found in the request.
* @return Set<Hptc> - Deleted Hptcs.
*/
public static Set<Hptc> findDeletedHptcs(Set<Hptc> sourceHptcs, Set<Hptc> reqHptcs)
{
Set<Hptc> deletedHptcs = new HashSet<Hptc>();

logger.info("Finding deleted hptcs");

// If both the sets are not null. Then find difference and update the
// source set.
if (sourceHptcs != null && !sourceHptcs.isEmpty() && reqHptcs != null
&& !reqHptcs.isEmpty())
{
// For each of the source hptc
sourceHptcs.forEach(shptc ->
{
// check for a match in the request hptc
boolean billingCodeMatch = reqHptcs.stream()
.anyMatch(rhptc -> rhptc.getHptc().equals(shptc.getHptc()));
// if no match found
if (!billingCodeMatch)
{
logger.info("Hptc " + shptc.getHptc() + " was deleted from the seoc.");
// mark this hptc for deletion
deletedHptcs.add(shptc);
}
});
} else if (sourceHptcs != null && !sourceHptcs.isEmpty())
{
// Delete all hptcs from the source set.
logger.info("Request hptc set is empty. Delete all hptcs from the source seoc.");
deletedHptcs.addAll(sourceHptcs);
}

return deletedHptcs;
}


/**
* Description: Compare Clinical Services before and after edit request and update
* the database object before saving.
*
* @param sourceService - Service object from the database before edit.
* @param requestService - Service object from the request after edit.
* @return - Updated set of source Clinical Services
*/
public static Set<ClinicalService> syncClinicalServices(PayableService sourceService,
PayableService requestService)
{
Set<ClinicalService> deletedClinicalServices = null;
Set<ClinicalService> newClinicalServices = null;
Set<ClinicalService> sourceClinicalServices = sourceService.getClinicalServices();
Set<ClinicalService> reqClinicalServices = requestService.getClinicalServices();

logger.info("Start updating source clinical services set with the request values");

// Both source and request clinical services sets are empty. clinical services
// not edited.
if ((reqClinicalServices == null || reqClinicalServices.isEmpty())
&& (sourceClinicalServices == null || sourceClinicalServices.isEmpty()))
{
logger.info("No change in the clinical services");
return null;
}

/*
* Find deleted clinical services and remove from the source set. Covers partial
* edit(delete) and complete delete scenarios.
*/
deletedClinicalServices = findDeletedClinicalServices(sourceClinicalServices, reqClinicalServices);
// For each of the deleted clinical services. Remove mutual association
// between two entities source service and clinical service.
deletedClinicalServices.forEach(dbc ->
{
// Remove clinical service from the source list.
sourceClinicalServices.remove(dbc);
});
/*
* Find new clinical services in the request and add them to the source set. Covers
* partial edit(add) and complete new scenarios.
*/
newClinicalServices = findNewClinicalServices(sourceClinicalServices, reqClinicalServices);
// For each new billing code establish association between clinical service
// and source service
newClinicalServices.forEach(nbc ->
{
// Add clinical service to the source service
sourceClinicalServices.add(nbc);
});

logger.info(
"Completed updating source clinical service set to reflect changes in the request clinical service set.");

return sourceClinicalServices;
}

/**
* Description: Compare Source Clinical Services set with Request Clinical Services set.
* If a clinical service is available in source but not available in the request
* that will be added to the list of deleted clinical services.
*
* @param sourceClinicalServices - Clinical Services coming from the database. Set of
* clinical services before editing the service.
* @param reqClinicalServices - Clinical Services coming from the request. Current set of
* clinical services for the service.
* @return - Deleted set of clinical services from the service
*/
public static Set<ClinicalService> findDeletedClinicalServices(
Set<ClinicalService> sourceClinicalServices, Set<ClinicalService> reqClinicalServices)
{
Set<ClinicalService> deletedClinicalServices = new HashSet<ClinicalService>();

logger.info("Finding deleted clinical services");

// If both the sets are not null. Then find difference and update the
// source set.
if (sourceClinicalServices != null && !sourceClinicalServices.isEmpty()
&& reqClinicalServices != null && !reqClinicalServices.isEmpty())
{
// For each of the source clinical service
sourceClinicalServices.forEach(scs ->
{
// check for a match in the request clinical service
boolean clinicServMatch = reqClinicalServices.stream()
.anyMatch(rcs -> (rcs.getId() == scs.getId()));
// if no match found
if (!clinicServMatch)
{
logger.info(
"Clinical Service " + scs.getId() + " was deleted from the service.");
// mark this clinical service for deletion
deletedClinicalServices.add(scs);
}
});

} else if (sourceClinicalServices != null && !sourceClinicalServices.isEmpty())
{
// Delete all clinical services from the source set.
logger.info(
"Request clinical service set is empty. Delete all clinical services from the source service.");
deletedClinicalServices.addAll(sourceClinicalServices);

}

return deletedClinicalServices;
}

/**
* Description: Compare Source Clinical Services set with Request Clinical Services set.
* If a clinical service is available in request but not available in the source
* that will be added to the list of new clinical services.
*
* @param sourceClinicalServices - Clinical Services coming from the database. Set of
* clinical service before editing the service.
* @param reqClinicalServices - ClinicalServices coming from the request. Current set of
* clinical services for the service.
* @return - newly added set of clinical services from the service
*/
public static Set<ClinicalService> findNewClinicalServices(
Set<ClinicalService> sourceClinicalServices, Set<ClinicalService> reqClinicalServices)
{
Set<ClinicalService> newClinicalServices = new HashSet<ClinicalService>();

logger.info("Finding newly added clinical services");

// If both the sets are not null. Then find difference and update the
// source set.
if (sourceClinicalServices != null && !sourceClinicalServices.isEmpty()
&& reqClinicalServices != null && !reqClinicalServices.isEmpty())
{
// For each of the request clinical service
reqClinicalServices.forEach(rcs ->
{
// check for a match in the source clinical service
boolean billingCodeMatch = sourceClinicalServices.stream()
.anyMatch(scs -> scs.getId() == rcs.getId());
// if no match found
if (!billingCodeMatch)
{
logger.info(
"ClinicalService " + rcs.getId() + " is newly added to the service.");
// add this clinical service to the new set
newClinicalServices.add(rcs);
}
});
}else if (reqClinicalServices != null && !reqClinicalServices.isEmpty())
{
// Add all clinical services from the source set.
logger.info(
"Source clinical service set is empty. Add all clinical services from the request service.");
newClinicalServices.addAll(reqClinicalServices);
}

return newClinicalServices;
}
/**
* Description: Check CodeRequired condition against the billing code values
* provided in the service
*
* @param codeReq
* @param billingCodes
*/
public static void codeRequiredBillingCodeValidation(String codeReq, Set<String> billingCodes)
{
if (codeReq != null) {
codeReq = codeReq.trim();
}

if (codeReq != null
&& (codeReq.equals(CodeRequired.ANY.getValue())
|| codeReq.equals(CodeRequired.NO.getValue()))
&& (billingCodes != null && !billingCodes.isEmpty()))
{
// Throw Validation Error - Billing codes are available when
// code required is ANY or NO
logger.error("Code required as the billing code list is not empty. No Billing code allowed with the given code required value.");
throw new CodeRequiredNotValidException("Code required value is " + codeReq
+ " where as the billing code list is not empty. No Billing code allowed with the given code required value.");
}
if (codeReq != null && codeReq.equals(CodeRequired.YES.getValue())
&& (billingCodes == null || billingCodes.isEmpty()))
{

// Throw Validation Error - Billing codes are not available when
// code required is YES
logger.error("Code required as the billing code list is empty.There should one or more billingcodes for the given code required.");
throw new CodeRequiredNotValidException("Code required value is " + codeReq
+ " where as the billing code list is empty.There should one or more billingcodes for the given code required.");
}
}

/**
* Description: Validate Seoc with {@link SeocActivationValidator}
*
* @param foundSeoc
*/
public static void validateSeocForActivation(Seoc foundSeoc, Status inProgress, Status dateHold)
{

// Set status of seoc to activate
foundSeoc.setStatus(dateHold);
// Validate the fields of SEOC
ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
Validator validator = validatorFactory.getValidator();
// Get the violation report
Set<ConstraintViolation<Seoc>> violations = validator.validate(foundSeoc);
if (!violations.isEmpty())
{
foundSeoc.setStatus(inProgress);
// Throw exception in case of violations
throw new SeocConstraintViolationException(
"Activation failed due to constraint violation.", violations);
}
foundSeoc.setStatus(inProgress);
}

/**
* Description:
*
* @param str
* @return
*/
/**
* Description: Obtain three parts of versionNumber split by using delimiter'.'
*
* @param str

* @return List<String> List of Strong after splitting
*/
public static String[] getPartsOfVersion(String str)
{
if (str != null && str.contains("."))
{
String[] partsOfVersion = str.split("[.]");
return partsOfVersion;
} else
{
return null;
}
}

/**
* Description:
* @param seoc
* @return String
*/
public static String getHashCodeOfSeoc(Seoc seoc) throws BusinessException
{
String hashValue = null;
try
{
ObjectMapper mapper = new ObjectMapper();
mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
String result = mapper.writeValueAsString(seoc);

hashValue = ApiUtil.getMD5(result);
} catch (JsonProcessingException e)
{
logger.error("Json Exception in getHashCodeOfSeoc(), SEOC as parameter." + e.getMessage());
throw new BusinessException("Json Exception in getHashCodeOfSeoc(), SEOC as parameter");
}
return hashValue;
}


public static String getHashCodeOfSeoc(String seocAsJson)
{
String hashValue = ApiUtil.getMD5(seocAsJson);

return hashValue;
}

public static String unpadEtag(String original)
{
String reqValue = (original!=null && original.contains("\""))?original.replace("\"",""):original;

return reqValue;
}

/**
* Description:
* @param seocSet
* @return Set<Seoc>
*/
public static List<Seoc> sortBySeocKeyEffectiveDate(Set<Seoc> seocSet)
{
List<Seoc> seocsList = new ArrayList<Seoc>();
seocsList.addAll(seocSet);

Comparator<Seoc> compareByKey = Comparator.comparing(Seoc::getSeocKey, Comparator.naturalOrder());
Comparator<Seoc> compareByKeyEffectiveDate = compareByKey.thenComparing(Seoc::getEffectiveDate,Comparator.reverseOrder());
Collections.sort(seocsList, compareByKeyEffectiveDate);

return seocsList;
}

}