Search in sources :

Example 1 with PreAdjMcsDiagnosisCode

use of gov.cms.bfd.model.rda.PreAdjMcsDiagnosisCode in project beneficiary-fhir-data by CMSgov.

the class McsClaimTransformerTest method basicFieldsTestForDiagCodeObjectTransformation.

/**
 * Basic smoke test for transformation of diagnosis code objects prior to all of the individual
 * field tests.
 */
@Test
public void basicFieldsTestForDiagCodeObjectTransformation() {
    claim.setIdrClmHdIcn("123456789012345");
    claim.setIdrContrId("12345");
    claim.setIdrClaimType("3");
    claim.setLastUpdated(clock.instant());
    PreAdjMcsDiagnosisCode diagCode = new PreAdjMcsDiagnosisCode();
    diagCode.setIdrClmHdIcn(claim.getIdrClmHdIcn());
    diagCode.setPriority((short) 0);
    diagCode.setIdrDiagIcdType("9");
    diagCode.setIdrDiagCode("1234567");
    diagCode.setLastUpdated(clock.instant());
    claim.getDiagCodes().add(diagCode);
    diagCode = new PreAdjMcsDiagnosisCode();
    diagCode.setIdrClmHdIcn(claim.getIdrClmHdIcn());
    diagCode.setPriority((short) 1);
    diagCode.setIdrDiagIcdType("0");
    diagCode.setIdrDiagCode("jdsyejs");
    diagCode.setLastUpdated(clock.instant());
    claim.getDiagCodes().add(diagCode);
    claimBuilder.setIdrClmHdIcn("123456789012345").setIdrContrId("12345").setIdrClaimTypeEnum(McsClaimType.CLAIM_TYPE_MEDICAL).addMcsDiagnosisCodes(McsDiagnosisCode.newBuilder().setIdrClmHdIcn("123456789012345").setIdrDiagCode("1234567").setIdrDiagIcdTypeEnum(McsDiagnosisIcdType.DIAGNOSIS_ICD_TYPE_ICD9).build()).addMcsDiagnosisCodes(McsDiagnosisCode.newBuilder().setIdrClmHdIcn("123456789012345").setIdrDiagCode("jdsyejs").setIdrDiagIcdTypeEnum(McsDiagnosisIcdType.DIAGNOSIS_ICD_TYPE_ICD10).build());
    changeBuilder.setChangeType(ChangeType.CHANGE_TYPE_INSERT).setClaim(claimBuilder.build());
    assertChangeMatches(RdaChange.Type.INSERT);
    PreAdjMcsClaim transformed = transformer.transformClaim(changeBuilder.build()).getClaim();
    assertListContentsHaveSamePropertyValues(claim.getDetails(), transformed.getDetails(), PreAdjMcsDetail::getPriority);
}
Also used : PreAdjMcsClaim(gov.cms.bfd.model.rda.PreAdjMcsClaim) PreAdjMcsDiagnosisCode(gov.cms.bfd.model.rda.PreAdjMcsDiagnosisCode) PreAdjMcsDetail(gov.cms.bfd.model.rda.PreAdjMcsDetail) Test(org.junit.jupiter.api.Test)

Example 2 with PreAdjMcsDiagnosisCode

use of gov.cms.bfd.model.rda.PreAdjMcsDiagnosisCode in project beneficiary-fhir-data by CMSgov.

the class McsClaimRdaSinkIT method mcsClaim.

@Test
public void mcsClaim() throws Exception {
    RdaPipelineTestUtils.runTestWithTemporaryDb(McsClaimRdaSinkIT.class, Clock.systemUTC(), (appState, entityManager) -> {
        final LocalDate today = LocalDate.of(2022, 1, 3);
        final Instant now = today.atStartOfDay().toInstant(ZoneOffset.UTC);
        final Clock clock = Clock.fixed(now, ZoneOffset.UTC);
        final PreAdjMcsClaim claim = new PreAdjMcsClaim();
        claim.setSequenceNumber(7L);
        claim.setIdrClmHdIcn("3");
        claim.setIdrContrId("c1");
        claim.setIdrHic("hc");
        claim.setIdrClaimType("c");
        claim.setMbiRecord(new Mbi(1L, "12345678901", "hash-of-12345678901"));
        final PreAdjMcsDetail detail = new PreAdjMcsDetail();
        detail.setIdrClmHdIcn(claim.getIdrClmHdIcn());
        detail.setPriority((short) 0);
        detail.setIdrDtlStatus("P");
        claim.getDetails().add(detail);
        final PreAdjMcsDiagnosisCode diagCode = new PreAdjMcsDiagnosisCode();
        diagCode.setIdrClmHdIcn(claim.getIdrClmHdIcn());
        diagCode.setPriority((short) 0);
        diagCode.setIdrDiagIcdType("T");
        diagCode.setIdrDiagCode("D");
        claim.getDiagCodes().add(diagCode);
        final McsDetail detailMessage = McsDetail.newBuilder().setIdrDtlStatusUnrecognized(detail.getIdrDtlStatus()).build();
        final McsDiagnosisCode diagCodeMessage = McsDiagnosisCode.newBuilder().setIdrDiagIcdTypeUnrecognized(diagCode.getIdrDiagIcdType()).setIdrDiagCode(diagCode.getIdrDiagCode()).build();
        final McsClaim claimMessage = McsClaim.newBuilder().setIdrClmHdIcn(claim.getIdrClmHdIcn()).setIdrContrId(claim.getIdrContrId()).setIdrClaimMbi(claim.getIdrClaimMbi()).setIdrHic(claim.getIdrHic()).setIdrClaimTypeUnrecognized(claim.getIdrClaimType()).addMcsDetails(detailMessage).addMcsDiagnosisCodes(diagCodeMessage).build();
        final McsClaimChange message = McsClaimChange.newBuilder().setSeq(claim.getSequenceNumber()).setIcn(claim.getIdrClmHdIcn()).setClaim(claimMessage).build();
        final IdHasher hasher = new IdHasher(new IdHasher.Config(1, "notarealpepper"));
        final McsClaimTransformer transformer = new McsClaimTransformer(clock, MbiCache.computedCache(hasher.getConfig()));
        final McsClaimRdaSink sink = new McsClaimRdaSink(appState, transformer, true);
        final String expectedMbiHash = hasher.computeIdentifierHash(claim.getIdrClaimMbi());
        assertEquals(Optional.empty(), sink.readMaxExistingSequenceNumber());
        int count = sink.writeMessage("version", message);
        assertEquals(1, count);
        List<PreAdjMcsClaim> resultClaims = entityManager.createQuery("select c from PreAdjMcsClaim c", PreAdjMcsClaim.class).getResultList();
        assertEquals(1, resultClaims.size());
        PreAdjMcsClaim resultClaim = resultClaims.get(0);
        assertEquals(Long.valueOf(7), resultClaim.getSequenceNumber());
        assertEquals(claim.getIdrHic(), resultClaim.getIdrHic());
        assertEquals(claim.getIdrClaimMbi(), resultClaim.getIdrClaimMbi());
        assertEquals(expectedMbiHash, resultClaim.getIdrClaimMbiHash());
        assertEquals(claim.getDetails().size(), resultClaim.getDetails().size());
        assertEquals(claim.getDiagCodes().size(), resultClaim.getDiagCodes().size());
        assertEquals(Optional.of(claim.getSequenceNumber()), sink.readMaxExistingSequenceNumber());
        Mbi databaseMbiEntity = RdaPipelineTestUtils.lookupCachedMbi(entityManager, claimMessage.getIdrClaimMbi());
        assertNotNull(databaseMbiEntity);
        assertEquals(claim.getIdrClaimMbi(), databaseMbiEntity.getMbi());
        assertEquals(expectedMbiHash, databaseMbiEntity.getHash());
    });
}
Also used : McsClaimTransformer(gov.cms.bfd.pipeline.rda.grpc.source.McsClaimTransformer) Instant(java.time.Instant) PreAdjMcsDetail(gov.cms.bfd.model.rda.PreAdjMcsDetail) McsDetail(gov.cms.mpsm.rda.v1.mcs.McsDetail) Clock(java.time.Clock) LocalDate(java.time.LocalDate) PreAdjMcsDiagnosisCode(gov.cms.bfd.model.rda.PreAdjMcsDiagnosisCode) PreAdjMcsDetail(gov.cms.bfd.model.rda.PreAdjMcsDetail) McsDiagnosisCode(gov.cms.mpsm.rda.v1.mcs.McsDiagnosisCode) PreAdjMcsDiagnosisCode(gov.cms.bfd.model.rda.PreAdjMcsDiagnosisCode) Mbi(gov.cms.bfd.model.rda.Mbi) IdHasher(gov.cms.bfd.pipeline.sharedutils.IdHasher) PreAdjMcsClaim(gov.cms.bfd.model.rda.PreAdjMcsClaim) PreAdjMcsClaim(gov.cms.bfd.model.rda.PreAdjMcsClaim) McsClaim(gov.cms.mpsm.rda.v1.mcs.McsClaim) McsClaimChange(gov.cms.mpsm.rda.v1.McsClaimChange) Test(org.junit.jupiter.api.Test)

Example 3 with PreAdjMcsDiagnosisCode

use of gov.cms.bfd.model.rda.PreAdjMcsDiagnosisCode in project beneficiary-fhir-data by CMSgov.

the class RDATestUtils method mcsTestDataA.

/**
 * One MCS claim for testing
 *
 * @return The MCS test claim A
 */
private PreAdjMcsClaim mcsTestDataA(Mbi mbi) {
    PreAdjMcsClaim claim = PreAdjMcsClaim.builder().sequenceNumber(1L).idrClmHdIcn("654321").idrContrId("contr").idrHic("HicValue").idrClaimType("R").idrDtlCnt(56).idrBeneLast_1_6("SMITH").idrBeneFirstInit("J").idrBeneMidInit("D").idrBeneSex("M").idrStatusCode("5").idrStatusDate(LocalDate.ofEpochDay(191)).idrBillProvNpi("9876789102").idrBillProvNum("4444422222").idrBillProvEin("1231231231").idrBillProvType("AB").idrBillProvSpec("BA").idrBillProvGroupInd("A").idrBillProvPriceSpec("FF").idrBillProvCounty("GG").idrBillProvLoc("HH").idrTotAllowed(new BigDecimal("323.45")).idrCoinsurance(new BigDecimal("300.45")).idrDeductible(new BigDecimal("23.00")).idrBillProvStatusCd("Z").idrTotBilledAmt(new BigDecimal("23.00")).idrClaimReceiptDate(LocalDate.ofEpochDay(54)).mbiRecord(mbi).idrHdrFromDateOfSvc(LocalDate.ofEpochDay(210)).idrHdrToDateOfSvc(LocalDate.ofEpochDay(210)).lastUpdated(Instant.ofEpochMilli(4000)).build();
    Set<PreAdjMcsDetail> procCodes = Set.of(PreAdjMcsDetail.builder().priority((short) 0).idrClmHdIcn("654321").idrDtlToDate(LocalDate.ofEpochDay(208)).idrProcCode("FDSAE").idrModOne("A").build(), PreAdjMcsDetail.builder().priority((short) 1).idrClmHdIcn("654321").idrProcCode("FDAAA").idrModTwo("B").build());
    claim.setDetails(procCodes);
    claim.setDiagCodes(Set.of(new PreAdjMcsDiagnosisCode("654321", (short) 0, "0", "HF3IJIF", Instant.ofEpochMilli(4000)), new PreAdjMcsDiagnosisCode("654321", (short) 1, "1", "HF3IJIG", Instant.ofEpochMilli(4000))));
    return claim;
}
Also used : PreAdjMcsClaim(gov.cms.bfd.model.rda.PreAdjMcsClaim) PreAdjMcsDiagnosisCode(gov.cms.bfd.model.rda.PreAdjMcsDiagnosisCode) BigDecimal(java.math.BigDecimal) PreAdjMcsDetail(gov.cms.bfd.model.rda.PreAdjMcsDetail)

Example 4 with PreAdjMcsDiagnosisCode

use of gov.cms.bfd.model.rda.PreAdjMcsDiagnosisCode in project beneficiary-fhir-data by CMSgov.

the class RDATestUtils method mcsTestDataB.

/**
 * One MCS claim for testing
 *
 * @return The MCS test claim B
 */
private PreAdjMcsClaim mcsTestDataB(Mbi mbi) {
    PreAdjMcsClaim claim = PreAdjMcsClaim.builder().sequenceNumber(1L).idrClmHdIcn("654323").idrContrId("contr").idrHic("HicValue").idrClaimType("R").idrDtlCnt(56).idrBeneLast_1_6("SMITH").idrBeneFirstInit("J").idrBeneMidInit("D").idrBeneSex("M").idrStatusCode(null).idrStatusDate(LocalDate.ofEpochDay(2)).idrBillProvNpi("9876789102").idrBillProvNum("4444422222").idrBillProvEin("1231231231").idrBillProvType("AB").idrBillProvSpec("BA").idrBillProvGroupInd("A").idrBillProvPriceSpec("FF").idrBillProvCounty("GG").idrBillProvLoc("HH").idrTotAllowed(new BigDecimal("224.41")).idrCoinsurance(new BigDecimal("14.32")).idrDeductible(new BigDecimal("11.00")).idrBillProvStatusCd(null).idrTotBilledAmt(new BigDecimal("23.00")).idrClaimReceiptDate(LocalDate.ofEpochDay(54)).mbiRecord(mbi).idrHdrFromDateOfSvc(LocalDate.ofEpochDay(200)).idrHdrToDateOfSvc(LocalDate.ofEpochDay(200)).lastUpdated(Instant.ofEpochMilli(4000)).build();
    Set<PreAdjMcsDetail> procCodes = Set.of(PreAdjMcsDetail.builder().priority((short) 0).idrClmHdIcn("654323").idrDtlToDate(LocalDate.ofEpochDay(208)).idrProcCode("FDSAE").idrModOne("A").build(), PreAdjMcsDetail.builder().priority((short) 1).idrClmHdIcn("654323").idrProcCode("FDAAA").idrModTwo("B").build());
    claim.setDetails(procCodes);
    claim.setDiagCodes(Set.of(new PreAdjMcsDiagnosisCode("654323", (short) 0, "0", "HF3IJIF", Instant.ofEpochMilli(4000)), new PreAdjMcsDiagnosisCode("654323", (short) 1, "1", "HF3IJIG", Instant.ofEpochMilli(4000))));
    return claim;
}
Also used : PreAdjMcsClaim(gov.cms.bfd.model.rda.PreAdjMcsClaim) PreAdjMcsDiagnosisCode(gov.cms.bfd.model.rda.PreAdjMcsDiagnosisCode) BigDecimal(java.math.BigDecimal) PreAdjMcsDetail(gov.cms.bfd.model.rda.PreAdjMcsDetail)

Example 5 with PreAdjMcsDiagnosisCode

use of gov.cms.bfd.model.rda.PreAdjMcsDiagnosisCode in project beneficiary-fhir-data by CMSgov.

the class R4ClaimSamhsaMatcherTransformerTest method mcsTest.

/**
 * These tests check if the transformed MCS claims result in the expected SAMHSA filtering
 * outcomes.
 */
@ParameterizedTest(name = "{index}: {0}")
@MethodSource
public void mcsTest(String testName, List<String> diagCodes, List<String> procCodes, boolean expectedResult, String errorMessagePostFix) {
    PreAdjMcsClaim entity = new PreAdjMcsClaim();
    entity.setLastUpdated(Instant.ofEpochMilli(1));
    Set<PreAdjMcsDiagnosisCode> diagnoses = IntStream.range(0, diagCodes.size()).mapToObj(i -> {
        String[] dx = diagCodes.get(i).split(":");
        PreAdjMcsDiagnosisCode diagCode = new PreAdjMcsDiagnosisCode();
        diagCode.setPriority((short) i);
        diagCode.setIdrDiagIcdType(dx[0]);
        diagCode.setIdrDiagCode(dx[1]);
        return diagCode;
    }).collect(Collectors.toSet());
    entity.setDiagCodes(diagnoses);
    Set<PreAdjMcsDetail> procedures = IntStream.range(0, procCodes.size()).mapToObj(i -> {
        PreAdjMcsDetail procCode = new PreAdjMcsDetail();
        procCode.setIdrDtlToDate(LocalDate.EPOCH);
        procCode.setPriority((short) i);
        procCode.setIdrProcCode(procCodes.get(i));
        return procCode;
    }).collect(Collectors.toSet());
    entity.setDetails(procedures);
    Claim claim = McsClaimTransformerV2.transform(new MetricRegistry(), entity);
    R4ClaimSamhsaMatcher matcher = new R4ClaimSamhsaMatcher();
    assertEquals(expectedResult, matcher.test(claim), testName + " " + errorMessagePostFix);
}
Also used : PreAdjFissClaim(gov.cms.bfd.model.rda.PreAdjFissClaim) IntStream(java.util.stream.IntStream) MetricRegistry(com.codahale.metrics.MetricRegistry) PreAdjFissProcCode(gov.cms.bfd.model.rda.PreAdjFissProcCode) Set(java.util.Set) Instant(java.time.Instant) Arguments(org.junit.jupiter.params.provider.Arguments) Collectors(java.util.stream.Collectors) PreAdjMcsClaim(gov.cms.bfd.model.rda.PreAdjMcsClaim) List(java.util.List) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Stream(java.util.stream.Stream) PreAdjMcsDetail(gov.cms.bfd.model.rda.PreAdjMcsDetail) PreAdjMcsDiagnosisCode(gov.cms.bfd.model.rda.PreAdjMcsDiagnosisCode) LocalDate(java.time.LocalDate) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Arguments.arguments(org.junit.jupiter.params.provider.Arguments.arguments) PreAdjFissDiagnosisCode(gov.cms.bfd.model.rda.PreAdjFissDiagnosisCode) Claim(org.hl7.fhir.r4.model.Claim) MethodSource(org.junit.jupiter.params.provider.MethodSource) MetricRegistry(com.codahale.metrics.MetricRegistry) PreAdjMcsClaim(gov.cms.bfd.model.rda.PreAdjMcsClaim) PreAdjMcsDiagnosisCode(gov.cms.bfd.model.rda.PreAdjMcsDiagnosisCode) PreAdjFissClaim(gov.cms.bfd.model.rda.PreAdjFissClaim) PreAdjMcsClaim(gov.cms.bfd.model.rda.PreAdjMcsClaim) Claim(org.hl7.fhir.r4.model.Claim) PreAdjMcsDetail(gov.cms.bfd.model.rda.PreAdjMcsDetail) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

PreAdjMcsDiagnosisCode (gov.cms.bfd.model.rda.PreAdjMcsDiagnosisCode)8 PreAdjMcsDetail (gov.cms.bfd.model.rda.PreAdjMcsDetail)7 PreAdjMcsClaim (gov.cms.bfd.model.rda.PreAdjMcsClaim)6 MetricRegistry (com.codahale.metrics.MetricRegistry)2 McsDetail (gov.cms.mpsm.rda.v1.mcs.McsDetail)2 McsDiagnosisCode (gov.cms.mpsm.rda.v1.mcs.McsDiagnosisCode)2 BigDecimal (java.math.BigDecimal)2 Instant (java.time.Instant)2 LocalDate (java.time.LocalDate)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 IntStream (java.util.stream.IntStream)2 Claim (org.hl7.fhir.r4.model.Claim)2 Test (org.junit.jupiter.api.Test)2 Timer (com.codahale.metrics.Timer)1 Trace (com.newrelic.api.agent.Trace)1 Mbi (gov.cms.bfd.model.rda.Mbi)1 PreAdjFissClaim (gov.cms.bfd.model.rda.PreAdjFissClaim)1 PreAdjFissDiagnosisCode (gov.cms.bfd.model.rda.PreAdjFissDiagnosisCode)1 PreAdjFissProcCode (gov.cms.bfd.model.rda.PreAdjFissProcCode)1