Search in sources :

Example 1 with McsDetail

use of gov.cms.mpsm.rda.v1.mcs.McsDetail 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 2 with McsDetail

use of gov.cms.mpsm.rda.v1.mcs.McsDetail in project beneficiary-fhir-data by CMSgov.

the class McsClaimTransformer method transformMessageArrays.

private void transformMessageArrays(McsClaim from, PreAdjMcsClaim to, DataTransformer transformer, Instant now, String namePrefix) {
    for (short index = 0; index < from.getMcsDetailsCount(); ++index) {
        final String itemNamePrefix = namePrefix + "detail" + "-" + index + "-";
        final McsDetail itemFrom = from.getMcsDetails(index);
        final PreAdjMcsDetail itemTo = transformMessageImpl(itemFrom, transformer, now, itemNamePrefix);
        itemTo.setIdrClmHdIcn(from.getIdrClmHdIcn());
        itemTo.setPriority(index);
        to.getDetails().add(itemTo);
    }
    for (short index = 0; index < from.getMcsDiagnosisCodesCount(); ++index) {
        final String itemNamePrefix = namePrefix + "diagCode" + "-" + index + "-";
        final McsDiagnosisCode itemFrom = from.getMcsDiagnosisCodes(index);
        final PreAdjMcsDiagnosisCode itemTo = transformMessageImpl(itemFrom, transformer, now, itemNamePrefix);
        itemTo.setIdrClmHdIcn(from.getIdrClmHdIcn());
        itemTo.setPriority(index);
        to.getDiagCodes().add(itemTo);
    }
    for (short index = 0; index < from.getMcsAdjustmentsCount(); ++index) {
        final String itemNamePrefix = namePrefix + "adjustment" + "-" + index + "-";
        final McsAdjustment itemFrom = from.getMcsAdjustments(index);
        final PreAdjMcsAdjustment itemTo = transformMessageImpl(itemFrom, transformer, now, itemNamePrefix);
        itemTo.setIdrClmHdIcn(from.getIdrClmHdIcn());
        itemTo.setPriority(index);
        to.getAdjustments().add(itemTo);
    }
    for (short index = 0; index < from.getMcsAuditsCount(); ++index) {
        final String itemNamePrefix = namePrefix + "audit" + "-" + index + "-";
        final McsAudit itemFrom = from.getMcsAudits(index);
        final PreAdjMcsAudit itemTo = transformMessageImpl(itemFrom, transformer, now, itemNamePrefix);
        itemTo.setIdrClmHdIcn(from.getIdrClmHdIcn());
        itemTo.setPriority(index);
        to.getAudits().add(itemTo);
    }
    for (short index = 0; index < from.getMcsLocationsCount(); ++index) {
        final String itemNamePrefix = namePrefix + "location" + "-" + index + "-";
        final McsLocation itemFrom = from.getMcsLocations(index);
        final PreAdjMcsLocation itemTo = transformMessageImpl(itemFrom, transformer, now, itemNamePrefix);
        itemTo.setIdrClmHdIcn(from.getIdrClmHdIcn());
        itemTo.setPriority(index);
        to.getLocations().add(itemTo);
    }
}
Also used : McsDiagnosisCode(gov.cms.mpsm.rda.v1.mcs.McsDiagnosisCode) PreAdjMcsDiagnosisCode(gov.cms.bfd.model.rda.PreAdjMcsDiagnosisCode) PreAdjMcsAudit(gov.cms.bfd.model.rda.PreAdjMcsAudit) McsAudit(gov.cms.mpsm.rda.v1.mcs.McsAudit) PreAdjMcsAudit(gov.cms.bfd.model.rda.PreAdjMcsAudit) PreAdjMcsAdjustment(gov.cms.bfd.model.rda.PreAdjMcsAdjustment) McsLocation(gov.cms.mpsm.rda.v1.mcs.McsLocation) PreAdjMcsLocation(gov.cms.bfd.model.rda.PreAdjMcsLocation) PreAdjMcsDetail(gov.cms.bfd.model.rda.PreAdjMcsDetail) McsDetail(gov.cms.mpsm.rda.v1.mcs.McsDetail) PreAdjMcsAdjustment(gov.cms.bfd.model.rda.PreAdjMcsAdjustment) McsAdjustment(gov.cms.mpsm.rda.v1.mcs.McsAdjustment) PreAdjMcsDiagnosisCode(gov.cms.bfd.model.rda.PreAdjMcsDiagnosisCode) PreAdjMcsLocation(gov.cms.bfd.model.rda.PreAdjMcsLocation) PreAdjMcsDetail(gov.cms.bfd.model.rda.PreAdjMcsDetail)

Aggregations

PreAdjMcsDetail (gov.cms.bfd.model.rda.PreAdjMcsDetail)2 PreAdjMcsDiagnosisCode (gov.cms.bfd.model.rda.PreAdjMcsDiagnosisCode)2 McsDetail (gov.cms.mpsm.rda.v1.mcs.McsDetail)2 McsDiagnosisCode (gov.cms.mpsm.rda.v1.mcs.McsDiagnosisCode)2 Mbi (gov.cms.bfd.model.rda.Mbi)1 PreAdjMcsAdjustment (gov.cms.bfd.model.rda.PreAdjMcsAdjustment)1 PreAdjMcsAudit (gov.cms.bfd.model.rda.PreAdjMcsAudit)1 PreAdjMcsClaim (gov.cms.bfd.model.rda.PreAdjMcsClaim)1 PreAdjMcsLocation (gov.cms.bfd.model.rda.PreAdjMcsLocation)1 McsClaimTransformer (gov.cms.bfd.pipeline.rda.grpc.source.McsClaimTransformer)1 IdHasher (gov.cms.bfd.pipeline.sharedutils.IdHasher)1 McsClaimChange (gov.cms.mpsm.rda.v1.McsClaimChange)1 McsAdjustment (gov.cms.mpsm.rda.v1.mcs.McsAdjustment)1 McsAudit (gov.cms.mpsm.rda.v1.mcs.McsAudit)1 McsClaim (gov.cms.mpsm.rda.v1.mcs.McsClaim)1 McsLocation (gov.cms.mpsm.rda.v1.mcs.McsLocation)1 Clock (java.time.Clock)1 Instant (java.time.Instant)1 LocalDate (java.time.LocalDate)1 Test (org.junit.jupiter.api.Test)1