Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QPPSE-2783: Added fix for the null TIN root id issue #1467

Merged
merged 4 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,21 @@ public SpecPiiValidator(PcfValidationInfoMap file) {

@Override
public void validateApmTinNpiCombination(Node node, NodeValidator validator) {
validateInvalidApmCombinations(node, validator);
validateMissingApmCombinations(node, validator);
List<String> npiList = Arrays.asList(
node.getValue(NATIONAL_PROVIDER_IDENTIFIER).split(","));
List<String> tinList = Arrays.asList(
node.getValue(TAX_PAYER_IDENTIFICATION_NUMBER).split(","));
if (npiList.size() != tinList.size()) {
validator.addError(Detail.forProblemAndNode(ProblemCode.INCORRECT_API_NPI_COMBINATION, node));
} else {
validateInvalidApmCombinations(node, validator, npiList, tinList);
validateMissingApmCombinations(node, validator, npiList, tinList);
}
}

private void validateInvalidApmCombinations(Node node, NodeValidator validator) {
private void validateInvalidApmCombinations(Node node, NodeValidator validator, List<String> npiList, List<String> tinList) {
String program = node.getValue(PROGRAM_NAME);
String apm = getApmEntityId(node, program);
List<String> npiList = Arrays.asList(
node.getValue(NATIONAL_PROVIDER_IDENTIFIER).split(","));
List<String> tinList = Arrays.asList(
node.getValue(TAX_PAYER_IDENTIFICATION_NUMBER).split(","));

Map<String, Map<String, List<String>>> apmToTinNpiMap = file.getApmTinNpiCombinationMap();
if (apmToTinNpiMap == null || StringUtils.isEmpty(apm)) {
Expand All @@ -59,16 +63,14 @@ private void validateInvalidApmCombinations(Node node, NodeValidator validator)
}
}

private void validateMissingApmCombinations(Node node, NodeValidator validator) {
private void validateMissingApmCombinations(Node node, NodeValidator validator, List<String> npiList, List<String> tinList) {
String program = node.getValue(PROGRAM_NAME);
String apm = getApmEntityId(node, program);
List<String> npiList = Arrays.asList(
node.getValue(NATIONAL_PROVIDER_IDENTIFIER).split(","));
List<String> tinList = Arrays.asList(
node.getValue(TAX_PAYER_IDENTIFICATION_NUMBER).split(","));

List<TinNpiCombination> tinNpiCombinations = createTinNpiMap(tinList, npiList);

// Adding some sonar exclusions, to avoid cognitive complexity.
// The conditions here would probably need to be checked in the specific order
Map<String, Map<String, List<String>>> apmToTinNpiMap = file.getApmTinNpiCombinationMap();
if (apmToTinNpiMap == null || StringUtils.isEmpty(apm)) {
validator.addWarning(Detail.forProblemAndNode(ProblemCode.MISSING_API_TIN_NPI_FILE, node));
Expand All @@ -77,25 +79,29 @@ private void validateMissingApmCombinations(Node node, NodeValidator validator)
if (tinNpisMap != null) {
for(final Map.Entry<String, List<String>> currentEntry: tinNpisMap.entrySet()) {
for (final String currentNpi : currentEntry.getValue()) {
boolean combinationExists = false;
for (TinNpiCombination currentCombination : tinNpiCombinations) {
if (currentEntry.getKey().equalsIgnoreCase((currentCombination.getTin())) &&
currentNpi.equalsIgnoreCase(currentCombination.getNpi())) {
combinationExists = true;
break;
}
}
if (!combinationExists) {
LocalizedProblem error = ProblemCode.PCF_MISSING_COMBINATION
.format(currentNpi, getMaskedTin(currentEntry.getKey()), apm);
validator.addWarning(Detail.forProblemAndNode(error, node));
}
checkTinNpiCombinations(node, validator, apm, currentEntry, tinNpiCombinations, currentNpi);
}
}
}
}
}

private void checkTinNpiCombinations(Node node, NodeValidator validator, String apm, Map.Entry<String, List<String>> currentEntry, List<TinNpiCombination> tinNpiCombinations, String currentNpi) {
boolean combinationExists = false;
for (TinNpiCombination currentCombination : tinNpiCombinations) {
if (currentEntry.getKey().equalsIgnoreCase((currentCombination.getTin())) &&
currentNpi.equalsIgnoreCase(currentCombination.getNpi())) {
combinationExists = true;
break;
}
}
if (!combinationExists) {
LocalizedProblem error = ProblemCode.PCF_MISSING_COMBINATION
.format(currentNpi, getMaskedTin(currentEntry.getKey()), apm);
validator.addWarning(Detail.forProblemAndNode(error, node));
}
}

private String getApmEntityId(final Node node, final String program) {
String apm;
if (PCF_PROGRAM_NAME.equalsIgnoreCase(program)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,21 @@ protected void performValidation(Node node) {
Truth.assertThat(nodeValidator.viewWarnings().get(0).getErrorCode()).isEqualTo(108);
}

@Test
void testNpiTinSizeMismatch() throws Exception {
SpecPiiValidator validator = validator("DogCow_APM", "DogCow_NPI");
Node node = node("Invalid_Apm", "DogCow_NPI,DogCow_NPI2", "DogCow", PCF_PROGRAM_NAME);
Comment on lines +115 to +116
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐶 🐮

System.out.println(node);
NodeValidator nodeValidator = new NodeValidator() {
@Override
protected void performValidation(Node node) {
// Empty Function. Just adding a comment to avoid sonar flag.
}
};
validator.validateApmTinNpiCombination(node, nodeValidator);
Truth.assertThat(nodeValidator.viewWarnings().get(0).getErrorCode()).isEqualTo(80);
}

private SpecPiiValidator validator(String apm, String npi) throws Exception {
return new SpecPiiValidator(createSpecFile(apm, npi));
}
Expand Down
Loading