SamhsaMatcher implements Predicate<ExplanationOfBenefit> { @Override public boolean test(ExplanationOfBenefit eob) { ClaimType claimType = TransformerUtils.getClaimType(eob); if (claimType == ClaimType.CARRIER) { return testCarrierOrDmeClaim(eob); } else if (claimType == ClaimType.DME) { return testCarrierOrDmeClaim(eob); } else if (claimType == ClaimType.HHA) { return testHhaClaim(eob); } else if (claimType == ClaimType.HOSPICE) { return testHospiceClaim(eob); } else if (claimType == ClaimType.INPATIENT) { return testInpatientClaim(eob); } else if (claimType == ClaimType.OUTPATIENT) { return testOutpatientClaim(eob); } else if (claimType == ClaimType.SNF) { return testSnfClaim(eob); } else if (claimType == ClaimType.PDE) { return testPartDEvent(eob); } else throw new BadCodeMonkeyException("Unsupported claim type: " + claimType); } SamhsaMatcher(); @Override boolean test(ExplanationOfBenefit eob);  }
@Test public void nonSamhsaRelatedClaims() { SamhsaMatcher matcher = new SamhsaMatcher(); List<Object> sampleRifRecords = ServerTestUtils .parseData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources())); List<ExplanationOfBenefit> sampleEobs = sampleRifRecords.stream().map(r -> { if (r instanceof Beneficiary) return null; else if (r instanceof BeneficiaryHistory) return null; else if (r instanceof MedicareBeneficiaryIdHistory) return null; return TransformerUtils.transformRifRecordToEob(new MetricRegistry(), r); }).filter(ExplanationOfBenefit.class::isInstance).collect(Collectors.toList()); for (ExplanationOfBenefit sampleEob : sampleEobs) Assert.assertFalse("Unexpected SAMHSA filtering of EOB: " + sampleEob.getId(), matcher.test(sampleEob)); }
@Test public void matchInpatientClaimsByIcd10Procedure() throws FHIRException { SamhsaMatcher matcher = new SamhsaMatcher(); ExplanationOfBenefit sampleEob = getSampleAClaim(ClaimType.INPATIENT); Coding sampleEobDiagnosis = sampleEob.getProcedureFirstRep().getProcedureCodeableConcept().getCodingFirstRep(); sampleEobDiagnosis.setSystem(IcdCode.CODING_SYSTEM_ICD_10).setCode(SAMPLE_SAMHSA_ICD_10_PROCEDURE_CODE); Assert.assertTrue(matcher.test(sampleEob)); }
@Test public void matchInpatientClaimsByDrg() throws FHIRException { SamhsaMatcher matcher = new SamhsaMatcher(); ExplanationOfBenefit sampleEob = getSampleAClaim(ClaimType.INPATIENT); sampleEob.getDiagnosisFirstRep().getPackageCode().addCoding().setSystem(SamhsaMatcherTest.DRG) .setCode(SAMPLE_SAMHSA_DRG_CODE); Assert.assertTrue(matcher.test(sampleEob)); }
@Test public void matchOutpatientClaimsByIcd9Diagnosis() throws FHIRException { SamhsaMatcher matcher = new SamhsaMatcher(); ExplanationOfBenefit sampleEob = getSampleAClaim(ClaimType.OUTPATIENT); Coding sampleEobDiagnosis = sampleEob.getDiagnosisFirstRep().getDiagnosisCodeableConcept().getCodingFirstRep(); sampleEobDiagnosis.setSystem(IcdCode.CODING_SYSTEM_ICD_9).setCode(SAMPLE_SAMHSA_ICD_9_DIAGNOSIS_CODE); Assert.assertTrue(matcher.test(sampleEob)); }
@Test public void matchOutpatientClaimsByIcd10Diagnosis() throws FHIRException { SamhsaMatcher matcher = new SamhsaMatcher(); ExplanationOfBenefit sampleEob = getSampleAClaim(ClaimType.OUTPATIENT); Coding sampleEobDiagnosis = sampleEob.getDiagnosisFirstRep().getDiagnosisCodeableConcept().getCodingFirstRep(); sampleEobDiagnosis.setSystem(IcdCode.CODING_SYSTEM_ICD_10).setCode(SAMPLE_SAMHSA_ICD_10_DIAGNOSIS_CODE); Assert.assertTrue(matcher.test(sampleEob)); }
@Test public void matchOutpatientClaimsByCptProcedure() throws FHIRException { SamhsaMatcher matcher = new SamhsaMatcher(); ExplanationOfBenefit sampleEob = getSampleAClaim(ClaimType.OUTPATIENT); Coding sampleEobService = sampleEob.getItemFirstRep().getService().getCodingFirstRep(); sampleEobService.setCode(SAMPLE_SAMHSA_CPT_CODE); Assert.assertTrue(matcher.test(sampleEob)); }
@Test public void matchOutpatientClaimsByIcd9Procedure() throws FHIRException { SamhsaMatcher matcher = new SamhsaMatcher(); ExplanationOfBenefit sampleEob = getSampleAClaim(ClaimType.OUTPATIENT); Coding sampleEobDiagnosis = sampleEob.getProcedureFirstRep().getProcedureCodeableConcept().getCodingFirstRep(); sampleEobDiagnosis.setSystem(IcdCode.CODING_SYSTEM_ICD_9).setCode(SAMPLE_SAMHSA_ICD_9_PROCEDURE_CODE); Assert.assertTrue(matcher.test(sampleEob)); }
@Test public void matchOutpatientClaimsByIcd10Procedure() throws FHIRException { SamhsaMatcher matcher = new SamhsaMatcher(); ExplanationOfBenefit sampleEob = getSampleAClaim(ClaimType.OUTPATIENT); Coding sampleEobDiagnosis = sampleEob.getProcedureFirstRep().getProcedureCodeableConcept().getCodingFirstRep(); sampleEobDiagnosis.setSystem(IcdCode.CODING_SYSTEM_ICD_10).setCode(SAMPLE_SAMHSA_ICD_10_PROCEDURE_CODE); Assert.assertTrue(matcher.test(sampleEob)); }
@Test public void matchHhaClaimsByIcd9Diagnosis() throws FHIRException { SamhsaMatcher matcher = new SamhsaMatcher(); ExplanationOfBenefit sampleEob = getSampleAClaim(ClaimType.HHA); Coding sampleEobDiagnosis = sampleEob.getDiagnosisFirstRep().getDiagnosisCodeableConcept().getCodingFirstRep(); sampleEobDiagnosis.setSystem(IcdCode.CODING_SYSTEM_ICD_9).setCode(SAMPLE_SAMHSA_ICD_9_DIAGNOSIS_CODE); Assert.assertTrue(matcher.test(sampleEob)); }
@Test public void matchHhaClaimsByIcd10Diagnosis() throws FHIRException { SamhsaMatcher matcher = new SamhsaMatcher(); ExplanationOfBenefit sampleEob = getSampleAClaim(ClaimType.HHA); Coding sampleEobDiagnosis = sampleEob.getDiagnosisFirstRep().getDiagnosisCodeableConcept().getCodingFirstRep(); sampleEobDiagnosis.setSystem(IcdCode.CODING_SYSTEM_ICD_10).setCode(SAMPLE_SAMHSA_ICD_10_DIAGNOSIS_CODE); Assert.assertTrue(matcher.test(sampleEob)); }
@Test public void matchHhaClaimsByCptProcedure() throws FHIRException { SamhsaMatcher matcher = new SamhsaMatcher(); ExplanationOfBenefit sampleEob = getSampleAClaim(ClaimType.HHA); Coding sampleEobService = sampleEob.getItemFirstRep().getService().getCodingFirstRep(); sampleEobService.setCode(SAMPLE_SAMHSA_CPT_CODE); Assert.assertTrue(matcher.test(sampleEob)); }
@Test public void matchCarrierClaimsByIcd9Diagnosis() throws FHIRException { SamhsaMatcher matcher = new SamhsaMatcher(); ExplanationOfBenefit sampleEob = getSampleAClaim(ClaimType.CARRIER); Coding sampleEobDiagnosis = sampleEob.getDiagnosisFirstRep().getDiagnosisCodeableConcept().getCodingFirstRep(); sampleEobDiagnosis.setSystem(IcdCode.CODING_SYSTEM_ICD_9).setCode(SAMPLE_SAMHSA_ICD_9_DIAGNOSIS_CODE); Assert.assertTrue(matcher.test(sampleEob)); }
@Test public void matchHospiceClaimsByIcd9Diagnosis() throws FHIRException { SamhsaMatcher matcher = new SamhsaMatcher(); ExplanationOfBenefit sampleEob = getSampleAClaim(ClaimType.HOSPICE); Coding sampleEobDiagnosis = sampleEob.getDiagnosisFirstRep().getDiagnosisCodeableConcept().getCodingFirstRep(); sampleEobDiagnosis.setSystem(IcdCode.CODING_SYSTEM_ICD_9).setCode(SAMPLE_SAMHSA_ICD_9_DIAGNOSIS_CODE); Assert.assertTrue(matcher.test(sampleEob)); }
@Test public void matchHospiceClaimsByIcd10Diagnosis() throws FHIRException { SamhsaMatcher matcher = new SamhsaMatcher(); ExplanationOfBenefit sampleEob = getSampleAClaim(ClaimType.HOSPICE); Coding sampleEobDiagnosis = sampleEob.getDiagnosisFirstRep().getDiagnosisCodeableConcept().getCodingFirstRep(); sampleEobDiagnosis.setSystem(IcdCode.CODING_SYSTEM_ICD_10).setCode(SAMPLE_SAMHSA_ICD_10_DIAGNOSIS_CODE); Assert.assertTrue(matcher.test(sampleEob)); }
@Test public void matchHospiceClaimsByCptProcedure() throws FHIRException { SamhsaMatcher matcher = new SamhsaMatcher(); ExplanationOfBenefit sampleEob = getSampleAClaim(ClaimType.HOSPICE); Coding sampleEobService = sampleEob.getItemFirstRep().getService().getCodingFirstRep(); sampleEobService.setCode(SAMPLE_SAMHSA_CPT_CODE); Assert.assertTrue(matcher.test(sampleEob)); }
@Test public void matchSnfClaimsByIcd9Diagnosis() throws FHIRException { SamhsaMatcher matcher = new SamhsaMatcher(); ExplanationOfBenefit sampleEob = getSampleAClaim(ClaimType.SNF); Coding sampleEobDiagnosis = sampleEob.getDiagnosis().get(1).getDiagnosisCodeableConcept().getCodingFirstRep(); sampleEobDiagnosis.setSystem(IcdCode.CODING_SYSTEM_ICD_9).setCode(SAMPLE_SAMHSA_ICD_9_DIAGNOSIS_CODE); Assert.assertTrue(matcher.test(sampleEob)); }
@Test public void matchSnfClaimsByIcd10Diagnosis() throws FHIRException { SamhsaMatcher matcher = new SamhsaMatcher(); ExplanationOfBenefit sampleEob = getSampleAClaim(ClaimType.SNF); Coding sampleEobDiagnosis = sampleEob.getDiagnosis().get(1).getDiagnosisCodeableConcept().getCodingFirstRep(); sampleEobDiagnosis.setSystem(IcdCode.CODING_SYSTEM_ICD_10).setCode(SAMPLE_SAMHSA_ICD_10_DIAGNOSIS_CODE); Assert.assertTrue(matcher.test(sampleEob)); }
@Test public void matchSnfClaimsByCptProcedure() throws FHIRException { SamhsaMatcher matcher = new SamhsaMatcher(); ExplanationOfBenefit sampleEob = getSampleAClaim(ClaimType.SNF); Coding sampleEobService = sampleEob.getItemFirstRep().getService().getCodingFirstRep(); sampleEobService.setCode(SAMPLE_SAMHSA_CPT_CODE); Assert.assertTrue(matcher.test(sampleEob)); }
@Test public void matchSnfClaimsByIcd9Procedure() throws FHIRException { SamhsaMatcher matcher = new SamhsaMatcher(); ExplanationOfBenefit sampleEob = getSampleAClaim(ClaimType.SNF); Coding sampleEobDiagnosis = sampleEob.getProcedureFirstRep().getProcedureCodeableConcept().getCodingFirstRep(); sampleEobDiagnosis.setSystem(IcdCode.CODING_SYSTEM_ICD_9).setCode(SAMPLE_SAMHSA_ICD_9_PROCEDURE_CODE); Assert.assertTrue(matcher.test(sampleEob)); }
@Test public void matchSnfClaimsByIcd10Procedure() throws FHIRException { SamhsaMatcher matcher = new SamhsaMatcher(); ExplanationOfBenefit sampleEob = getSampleAClaim(ClaimType.SNF); Coding sampleEobDiagnosis = sampleEob.getProcedureFirstRep().getProcedureCodeableConcept().getCodingFirstRep(); sampleEobDiagnosis.setSystem(IcdCode.CODING_SYSTEM_ICD_10).setCode(SAMPLE_SAMHSA_ICD_10_PROCEDURE_CODE); Assert.assertTrue(matcher.test(sampleEob)); }
@Test public void matchSnfClaimsByDrg() throws FHIRException { SamhsaMatcher matcher = new SamhsaMatcher(); ExplanationOfBenefit sampleEob = getSampleAClaim(ClaimType.SNF); sampleEob.getDiagnosisFirstRep().getPackageCode().addCoding().setSystem(SamhsaMatcherTest.DRG) .setCode(SAMPLE_SAMHSA_DRG_CODE); Assert.assertTrue(matcher.test(sampleEob)); }
@Test public void matchCarrierClaimsByIcd10Diagnosis() throws FHIRException { SamhsaMatcher matcher = new SamhsaMatcher(); ExplanationOfBenefit sampleEob = getSampleAClaim(ClaimType.CARRIER); Coding sampleEobDiagnosis = sampleEob.getDiagnosisFirstRep().getDiagnosisCodeableConcept().getCodingFirstRep(); sampleEobDiagnosis.setSystem(IcdCode.CODING_SYSTEM_ICD_10).setCode(SAMPLE_SAMHSA_ICD_10_DIAGNOSIS_CODE); Assert.assertTrue(matcher.test(sampleEob)); }
@Test public void matchCarrierClaimsByCptProcedure() throws FHIRException { SamhsaMatcher matcher = new SamhsaMatcher(); ExplanationOfBenefit sampleEob = getSampleAClaim(ClaimType.CARRIER); Coding sampleEobService = sampleEob.getItemFirstRep().getService().getCodingFirstRep(); sampleEobService.setCode(SAMPLE_SAMHSA_CPT_CODE); Assert.assertTrue(matcher.test(sampleEob)); }
@Test public void matchDmeClaimsByIcd9Diagnosis() throws FHIRException { SamhsaMatcher matcher = new SamhsaMatcher(); ExplanationOfBenefit sampleEob = getSampleAClaim(ClaimType.DME); Coding sampleEobDiagnosis = sampleEob.getDiagnosisFirstRep().getDiagnosisCodeableConcept().getCodingFirstRep(); sampleEobDiagnosis.setSystem(IcdCode.CODING_SYSTEM_ICD_9).setCode(SAMPLE_SAMHSA_ICD_9_DIAGNOSIS_CODE); Assert.assertTrue(matcher.test(sampleEob)); }
@Test public void matchDmeClaimsByIcd10Diagnosis() throws FHIRException { SamhsaMatcher matcher = new SamhsaMatcher(); ExplanationOfBenefit sampleEob = getSampleAClaim(ClaimType.DME); Coding sampleEobDiagnosis = sampleEob.getDiagnosisFirstRep().getDiagnosisCodeableConcept().getCodingFirstRep(); sampleEobDiagnosis.setSystem(IcdCode.CODING_SYSTEM_ICD_10).setCode(SAMPLE_SAMHSA_ICD_10_DIAGNOSIS_CODE); Assert.assertTrue(matcher.test(sampleEob)); }
@Test public void matchDmeClaimsByCptProcedure() throws FHIRException { SamhsaMatcher matcher = new SamhsaMatcher(); ExplanationOfBenefit sampleEob = getSampleAClaim(ClaimType.DME); Coding sampleEobService = sampleEob.getItemFirstRep().getService().getCodingFirstRep(); sampleEobService.setCode(SAMPLE_SAMHSA_CPT_CODE); Assert.assertTrue(matcher.test(sampleEob)); }
@Test public void matchInpatientClaimsByIcd9Diagnosis() throws FHIRException { SamhsaMatcher matcher = new SamhsaMatcher(); ExplanationOfBenefit sampleEob = getSampleAClaim(ClaimType.INPATIENT); Coding sampleEobDiagnosis = sampleEob.getDiagnosis().get(1).getDiagnosisCodeableConcept().getCodingFirstRep(); sampleEobDiagnosis.setSystem(IcdCode.CODING_SYSTEM_ICD_9).setCode(SAMPLE_SAMHSA_ICD_9_DIAGNOSIS_CODE); Assert.assertTrue(matcher.test(sampleEob)); }
@Test public void matchInpatientClaimsByIcd10Diagnosis() throws FHIRException { SamhsaMatcher matcher = new SamhsaMatcher(); ExplanationOfBenefit sampleEob = getSampleAClaim(ClaimType.INPATIENT); Coding sampleEobDiagnosis = sampleEob.getDiagnosis().get(1).getDiagnosisCodeableConcept().getCodingFirstRep(); sampleEobDiagnosis.setSystem(IcdCode.CODING_SYSTEM_ICD_10).setCode(SAMPLE_SAMHSA_ICD_10_DIAGNOSIS_CODE); Assert.assertTrue(matcher.test(sampleEob)); }
@Test public void matchInpatientClaimsByIcd9Procedure() throws FHIRException { SamhsaMatcher matcher = new SamhsaMatcher(); ExplanationOfBenefit sampleEob = getSampleAClaim(ClaimType.INPATIENT); Coding sampleEobDiagnosis = sampleEob.getProcedureFirstRep().getProcedureCodeableConcept().getCodingFirstRep(); sampleEobDiagnosis.setSystem(IcdCode.CODING_SYSTEM_ICD_9).setCode(SAMPLE_SAMHSA_ICD_9_PROCEDURE_CODE); Assert.assertTrue(matcher.test(sampleEob)); }