Search in sources :

Example 1 with McsClaimChange

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

the class McsClaimStreamCallerIT method sequenceNumbers.

@Test
public void sequenceNumbers() throws Exception {
    RdaServer.InProcessConfig.builder().serverName(getClass().getSimpleName()).mcsSourceFactory(sequenceNumber -> new RandomMcsClaimSource(1000L, 15).toClaimChanges().skip(sequenceNumber)).build().runWithChannelParam(channel -> {
        final McsClaimStreamCaller caller = new McsClaimStreamCaller();
        final GrpcResponseStream<McsClaimChange> results = caller.callService(channel, CallOptions.DEFAULT, 10L);
        assertEquals(Long.valueOf(10), transform(results.next()).getSequenceNumber());
        assertEquals(Long.valueOf(11), transform(results.next()).getSequenceNumber());
        assertEquals(Long.valueOf(12), transform(results.next()).getSequenceNumber());
        assertEquals(Long.valueOf(13), transform(results.next()).getSequenceNumber());
        assertEquals(Long.valueOf(14), transform(results.next()).getSequenceNumber());
        assertFalse(results.hasNext());
    });
}
Also used : RandomMcsClaimSource(gov.cms.bfd.pipeline.rda.grpc.server.RandomMcsClaimSource) McsClaimChange(gov.cms.mpsm.rda.v1.McsClaimChange) Test(org.junit.jupiter.api.Test)

Example 2 with McsClaimChange

use of gov.cms.mpsm.rda.v1.McsClaimChange 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 McsClaimChange

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

the class RdaLoadJobIT method mcsClaimsTest.

@Test
public void mcsClaimsTest() throws Exception {
    RdaPipelineTestUtils.runTestWithTemporaryDb(RdaLoadJobIT.class, clock, (appState, entityManager) -> {
        assertTablesAreEmpty(entityManager);
        RdaServer.InProcessConfig.builder().serverName(RdaServerJob.Config.DEFAULT_SERVER_NAME).mcsSourceFactory(mcsJsonSource(mcsClaimJson)).build().runWithNoParam(() -> {
            final RdaLoadOptions config = createRdaLoadOptions(-1);
            final PipelineJob<?> job = config.createMcsClaimsLoadJob(appState);
            job.call();
        });
        final ImmutableList<McsClaimChange> expectedClaims = JsonMessageSource.parseAll(mcsClaimJson, JsonMessageSource::parseMcsClaimChange);
        List<PreAdjMcsClaim> claims = getPreAdjMcsClaims(entityManager);
        assertEquals(expectedClaims.size(), claims.size());
        for (PreAdjMcsClaim resultClaim : claims) {
            McsClaim expected = findMatchingMcsClaim(expectedClaims, resultClaim);
            assertNotNull(expected);
            assertEquals(expected.getIdrHic(), Strings.nullToEmpty(resultClaim.getIdrHic()));
            assertEquals(expected.getIdrClaimMbi(), Strings.nullToEmpty(resultClaim.getIdrClaimMbi()));
            assertEquals(expected.getMcsDetailsCount(), resultClaim.getDetails().size());
            assertEquals(expected.getMcsDiagnosisCodesCount(), resultClaim.getDiagCodes().size());
        }
    });
}
Also used : JsonMessageSource(gov.cms.bfd.pipeline.rda.grpc.server.JsonMessageSource) 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 4 with McsClaimChange

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

the class RdaLoadJobIT method mcsClaimsAreValid.

/**
 * All of our test claims should be valid for our IT tests to succeed. This test ensures this is
 * the case and catches any incompatibility issues when a new RDA API version contains breaking
 * changes.
 */
@Test
public void mcsClaimsAreValid() throws Exception {
    final ImmutableList<McsClaimChange> expectedClaims = JsonMessageSource.parseAll(mcsClaimJson, JsonMessageSource::parseMcsClaimChange);
    final McsClaimTransformer transformer = new McsClaimTransformer(clock, MbiCache.computedCache(new IdHasher.Config(1, "testing")));
    for (McsClaimChange claim : expectedClaims) {
        try {
            transformer.transformClaim(claim);
        } catch (DataTransformer.TransformationException ex) {
            fail(String.format("bad sample claim: seq=%d error=%s", claim.getSeq(), ex.getErrors()));
        }
    }
}
Also used : JsonMessageSource(gov.cms.bfd.pipeline.rda.grpc.server.JsonMessageSource) McsClaimTransformer(gov.cms.bfd.pipeline.rda.grpc.source.McsClaimTransformer) DataTransformer(gov.cms.bfd.pipeline.rda.grpc.source.DataTransformer) McsClaimChange(gov.cms.mpsm.rda.v1.McsClaimChange) Test(org.junit.jupiter.api.Test)

Example 5 with McsClaimChange

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

the class McsClaimStreamCaller method callService.

/**
 * Calls the getMcsClaims RPC. The Iterator from the RPC call is wrapped with a transforming
 * Iterator that converts the API McsClaim objects into database PreAdjMcsClaim entity objects.
 *
 * @param channel an already open channel to the service being called
 * @param startingSequenceNumber specifies the sequence number to send to the RDA API server
 * @return a blocking GrpcResponseStream of PreAdjMcsClaim entity objects
 * @throws Exception passes through any gRPC framework exceptions
 */
@Override
public GrpcResponseStream<McsClaimChange> callService(ManagedChannel channel, CallOptions callOptions, long startingSequenceNumber) throws Exception {
    logger.info("calling service");
    Preconditions.checkNotNull(channel);
    final ClaimRequest request = ClaimRequest.newBuilder().setSince(startingSequenceNumber).build();
    final MethodDescriptor<ClaimRequest, McsClaimChange> method = RDAServiceGrpc.getGetMcsClaimsMethod();
    final ClientCall<ClaimRequest, McsClaimChange> call = channel.newCall(method, callOptions);
    final Iterator<McsClaimChange> apiResults = ClientCalls.blockingServerStreamingCall(call, request);
    return new GrpcResponseStream<>(call, apiResults);
}
Also used : ClaimRequest(gov.cms.mpsm.rda.v1.ClaimRequest) McsClaimChange(gov.cms.mpsm.rda.v1.McsClaimChange)

Aggregations

McsClaimChange (gov.cms.mpsm.rda.v1.McsClaimChange)9 Test (org.junit.jupiter.api.Test)9 PreAdjMcsClaim (gov.cms.bfd.model.rda.PreAdjMcsClaim)5 McsClaim (gov.cms.mpsm.rda.v1.mcs.McsClaim)5 McsClaimTransformer (gov.cms.bfd.pipeline.rda.grpc.source.McsClaimTransformer)3 JsonMessageSource (gov.cms.bfd.pipeline.rda.grpc.server.JsonMessageSource)2 RandomMcsClaimSource (gov.cms.bfd.pipeline.rda.grpc.server.RandomMcsClaimSource)2 IdHasher (gov.cms.bfd.pipeline.sharedutils.IdHasher)2 FissClaimChange (gov.cms.mpsm.rda.v1.FissClaimChange)2 Clock (java.time.Clock)2 MessageOrBuilder (com.google.protobuf.MessageOrBuilder)1 Mbi (gov.cms.bfd.model.rda.Mbi)1 PreAdjFissClaim (gov.cms.bfd.model.rda.PreAdjFissClaim)1 PreAdjMcsDetail (gov.cms.bfd.model.rda.PreAdjMcsDetail)1 PreAdjMcsDiagnosisCode (gov.cms.bfd.model.rda.PreAdjMcsDiagnosisCode)1 Sink (gov.cms.bfd.pipeline.bridge.io.Sink)1 BeneficiaryData (gov.cms.bfd.pipeline.bridge.model.BeneficiaryData)1 WrappedCounter (gov.cms.bfd.pipeline.bridge.util.WrappedCounter)1 RdaChange (gov.cms.bfd.pipeline.rda.grpc.RdaChange)1 DataTransformer (gov.cms.bfd.pipeline.rda.grpc.source.DataTransformer)1