Skip to content

Commit

Permalink
BFD-3164: Bugfix for SAMHSA filter not filtering illegal DRG codes fo…
Browse files Browse the repository at this point in the history
…r V2 (SNF/Inpatient) (#2130)
  • Loading branch information
lsmitchell authored Jan 4, 2024
1 parent 7c43fba commit 8c79f69
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package gov.cms.bfd.server.war.adapters;

/**
* Interface for creating SupportingInfoComponent wrapper implementations for different FHIR
* resource implementations.
*/
public interface SupportingInfoComponent {

/**
* Gets the supporting info codeable concept.
*
* @return the supporting info codeable concept
*/
CodeableConcept getSupportingInfoCodeableConcept();
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import gov.cms.bfd.server.war.adapters.FhirResource;
import gov.cms.bfd.server.war.adapters.ItemComponent;
import gov.cms.bfd.server.war.adapters.ProcedureComponent;
import gov.cms.bfd.server.war.adapters.SupportingInfoComponent;
import java.util.List;
import java.util.stream.Collectors;
import org.hl7.fhir.r4.model.ExplanationOfBenefit;
Expand Down Expand Up @@ -47,6 +48,36 @@ public List<ItemComponent> getItem() {
return eob.getItem().stream().map(ItemComponentAdapter::new).collect(Collectors.toList());
}

/** {@inheritDoc} */
public List<SupportingInfoComponent> getSupportingInfo() {
return eob.getSupportingInfo().stream()
.map(SupportingInfoAdapter::new)
.collect(Collectors.toList());
}

/** Adapter for creating R4 FHIR supporting info components. */
public static class SupportingInfoAdapter implements SupportingInfoComponent {

/** The eob's supporting information component. */
private final ExplanationOfBenefit.SupportingInformationComponent supportingInfoComponent;

/**
* Instantiates a new SupportingInfo component adapter.
*
* @param supportingInfoComponent the supporting info component
*/
public SupportingInfoAdapter(
ExplanationOfBenefit.SupportingInformationComponent supportingInfoComponent) {
this.supportingInfoComponent = supportingInfoComponent;
}

/** {@inheritDoc} */
@Override
public CodeableConcept getSupportingInfoCodeableConcept() {
return new CodeableConceptAdapter(supportingInfoComponent.getCode());
}
}

/** Adapter for creating R4 FHIR procedure components. */
public static class ProcedureComponentAdapter implements ProcedureComponent {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import gov.cms.bfd.server.war.adapters.FhirResource;
import gov.cms.bfd.server.war.adapters.ItemComponent;
import gov.cms.bfd.server.war.adapters.ProcedureComponent;
import gov.cms.bfd.server.war.adapters.SupportingInfoComponent;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import org.hl7.fhir.dstu3.model.ExplanationOfBenefit;
Expand Down Expand Up @@ -50,6 +52,12 @@ public List<ItemComponent> getItem() {
return eob.getItem().stream().map(ItemComponentAdapter::new).collect(Collectors.toList());
}

/** {@inheritDoc} */
public List<SupportingInfoComponent> getSupportingInfo() {
// V1 doesn't have supportingInfo, so return an empty list
return new ArrayList<>();
}

/** Adapter for creating stu3 FHIR procedure components. */
public static class ProcedureComponentAdapter implements ProcedureComponent {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import gov.cms.bfd.server.war.adapters.DiagnosisComponent;
import gov.cms.bfd.server.war.adapters.ItemComponent;
import gov.cms.bfd.server.war.adapters.ProcedureComponent;
import gov.cms.bfd.server.war.adapters.SupportingInfoComponent;
import gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -156,6 +157,18 @@ protected boolean containsSamhsaIcdProcedureCode(List<ProcedureComponent> proced
return procedure.stream().anyMatch(this::isSamhsaIcdProcedure);
}

/**
* Checks if the given {@link SupportingInfoComponent} list contains any SAMHSA data.
*
* @param supportingInformationComponents the supporting information components
* @return {@code true} if any of the specified {@link SupportingInfoComponent}s match any of the
* {@link AbstractSamhsaMatcher#drgCodes}, {@code false} if they all do not
*/
protected boolean containsSamhsaSupportingInfo(
List<SupportingInfoComponent> supportingInformationComponents) {
return supportingInformationComponents.stream().anyMatch(this::isSamhsaSupportingInfo);
}

/**
* Checks if the given {@link DiagnosisComponent} list contains any SAMHSA data.
*
Expand Down Expand Up @@ -224,6 +237,24 @@ boolean isSamhsaDiagnosis(DiagnosisComponent diagnosis) {
}
}

/**
* Checks if the given {@link SupportingInfoComponent} contains SAMHSA data.
*
* @param supportingInfo the {@link SupportingInfoComponent} to check
* @return {@code true} if the specified {@link SupportingInfoComponent} matches one of the {@link
* AbstractSamhsaMatcher#drgCodes} entries, <code>false</code> if it does not
*/
@VisibleForTesting
boolean isSamhsaSupportingInfo(SupportingInfoComponent supportingInfo) {
try {
return supportingInfo.getSupportingInfoCodeableConcept().getCoding().stream()
.filter(s -> s.getSystem().equals(AbstractSamhsaMatcher.DRG))
.anyMatch(this::isSamhsaDrgCode);
} catch (FHIRException e) {
throw new BadCodeMonkeyException(e);
}
}

/**
* Checks that for the specified {@link CodeableConcept}, the Codings (if any) within, contain a
* blacklisted SAMHSA procedure code. If any of the systems within the {@link CodeableConcept} are
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ public boolean test(ExplanationOfBenefit eob) {
case INPATIENT:
case OUTPATIENT:
case SNF:
containsSamhsa = containsSamhsaIcdProcedureCode(adapter.getProcedure());
containsSamhsa =
containsSamhsaIcdProcedureCode(adapter.getProcedure())
|| containsSamhsaSupportingInfo(adapter.getSupportingInfo());
case CARRIER:
case DME:
case HHA:
Expand Down

0 comments on commit 8c79f69

Please sign in to comment.