Search in sources :

Example 1 with FissClaimChange

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

the class FissClaimStreamCallerIT method sequenceNumbers.

@Test
public void sequenceNumbers() throws Exception {
    RdaServer.InProcessConfig.builder().serverName(getClass().getSimpleName()).fissSourceFactory(sequenceNumber -> new RandomFissClaimSource(1000L, 15).toClaimChanges().skip(sequenceNumber)).build().runWithChannelParam(channel -> {
        final FissClaimStreamCaller caller = new FissClaimStreamCaller();
        final GrpcResponseStream<FissClaimChange> 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 : RandomFissClaimSource(gov.cms.bfd.pipeline.rda.grpc.server.RandomFissClaimSource) FissClaimChange(gov.cms.mpsm.rda.v1.FissClaimChange) Test(org.junit.jupiter.api.Test)

Example 2 with FissClaimChange

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

the class FissClaimStreamCallerIT method basicCall.

@Test
public void basicCall() throws Exception {
    RdaServer.InProcessConfig.builder().serverName(getClass().getSimpleName()).fissSourceFactory(sequenceNumber -> WrappedClaimSource.wrapFissClaims(new JsonMessageSource<>(CLAIM_1 + System.lineSeparator() + CLAIM_2, JsonMessageSource::parseFissClaim), clock, sequenceNumber)).build().runWithChannelParam(channel -> {
        final FissClaimStreamCaller caller = new FissClaimStreamCaller();
        assertEquals(RdaService.RDA_PROTO_VERSION, caller.callVersionService(channel, CallOptions.DEFAULT));
        final GrpcResponseStream<FissClaimChange> results = caller.callService(channel, CallOptions.DEFAULT, 0L);
        assertTrue(results.hasNext());
        PreAdjFissClaim claim = transform(results.next());
        assertEquals("63843470", claim.getDcn());
        assertEquals(Long.valueOf(0), claim.getSequenceNumber());
        assertTrue(results.hasNext());
        claim = transform(results.next());
        assertEquals("2643602", claim.getDcn());
        assertEquals(Long.valueOf(1), claim.getSequenceNumber());
        assertFalse(results.hasNext());
    });
}
Also used : JsonMessageSource(gov.cms.bfd.pipeline.rda.grpc.server.JsonMessageSource) FissClaimChange(gov.cms.mpsm.rda.v1.FissClaimChange) PreAdjFissClaim(gov.cms.bfd.model.rda.PreAdjFissClaim) Test(org.junit.jupiter.api.Test)

Example 3 with FissClaimChange

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

the class RdaLoadJobIT method fissClaimsTest.

@Test
public void fissClaimsTest() throws Exception {
    RdaPipelineTestUtils.runTestWithTemporaryDb(RdaLoadJobIT.class, clock, (appState, entityManager) -> {
        assertTablesAreEmpty(entityManager);
        RdaServer.LocalConfig.builder().fissSourceFactory(fissJsonSource(fissClaimJson)).build().runWithPortParam(port -> {
            final RdaLoadOptions config = createRdaLoadOptions(port);
            final PipelineJob<?> job = config.createFissClaimsLoadJob(appState);
            job.call();
        });
        final ImmutableList<FissClaimChange> expectedClaims = JsonMessageSource.parseAll(fissClaimJson, JsonMessageSource::parseFissClaimChange);
        List<PreAdjFissClaim> claims = getPreAdjFissClaims(entityManager);
        assertEquals(expectedClaims.size(), claims.size());
        for (PreAdjFissClaim resultClaim : claims) {
            FissClaim expected = findMatchingFissClaim(expectedClaims, resultClaim);
            assertNotNull(expected);
            assertEquals(expected.getHicNo(), resultClaim.getHicNo());
            assertEquals(expected.getPracLocCity(), Strings.nullToEmpty(resultClaim.getPracLocCity()));
            assertEquals(expected.getFissProcCodesCount(), resultClaim.getProcCodes().size());
            assertEquals(expected.getFissDiagCodesCount(), resultClaim.getDiagCodes().size());
        }
    });
}
Also used : JsonMessageSource(gov.cms.bfd.pipeline.rda.grpc.server.JsonMessageSource) PreAdjFissClaim(gov.cms.bfd.model.rda.PreAdjFissClaim) FissClaim(gov.cms.mpsm.rda.v1.fiss.FissClaim) FissClaimChange(gov.cms.mpsm.rda.v1.FissClaimChange) PreAdjFissClaim(gov.cms.bfd.model.rda.PreAdjFissClaim) Test(org.junit.jupiter.api.Test)

Example 4 with FissClaimChange

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

the class FissClaimStreamCaller method callService.

/**
 * Calls the getFissClaims RPC. The Iterator from the RPC call is wrapped with a transforming
 * Iterator that converts the API FissClaim objects into database PreAdjFissClaim 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 PreAdjFissClaim entity objects
 * @throws Exception passes through any gRPC framework exceptions
 */
@Override
public GrpcResponseStream<FissClaimChange> 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, FissClaimChange> method = RDAServiceGrpc.getGetFissClaimsMethod();
    final ClientCall<ClaimRequest, FissClaimChange> call = channel.newCall(method, callOptions);
    final Iterator<FissClaimChange> apiResults = ClientCalls.blockingServerStreamingCall(call, request);
    return new GrpcResponseStream<>(call, apiResults);
}
Also used : ClaimRequest(gov.cms.mpsm.rda.v1.ClaimRequest) FissClaimChange(gov.cms.mpsm.rda.v1.FissClaimChange)

Example 5 with FissClaimChange

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

the class FissClaimTransformer method transformClaim.

public RdaChange<PreAdjFissClaim> transformClaim(FissClaimChange change) {
    FissClaim from = change.getClaim();
    final DataTransformer transformer = new DataTransformer();
    final PreAdjFissClaim to = transformMessage(from, transformer, clock.instant());
    to.setSequenceNumber(change.getSeq());
    final List<DataTransformer.ErrorMessage> errors = transformer.getErrors();
    if (errors.size() > 0) {
        String message = String.format("failed with %d errors: dcn=%s errors=%s", errors.size(), from.getDcn(), errors);
        throw new DataTransformer.TransformationException(message, errors);
    }
    return new RdaChange<>(change.getSeq(), RdaApiUtils.mapApiChangeType(change.getChangeType()), to, transformer.instant(change.getTimestamp()));
}
Also used : RdaChange(gov.cms.bfd.pipeline.rda.grpc.RdaChange) PreAdjFissClaim(gov.cms.bfd.model.rda.PreAdjFissClaim) FissClaim(gov.cms.mpsm.rda.v1.fiss.FissClaim) PreAdjFissClaim(gov.cms.bfd.model.rda.PreAdjFissClaim)

Aggregations

FissClaimChange (gov.cms.mpsm.rda.v1.FissClaimChange)9 Test (org.junit.jupiter.api.Test)8 PreAdjFissClaim (gov.cms.bfd.model.rda.PreAdjFissClaim)5 FissClaim (gov.cms.mpsm.rda.v1.fiss.FissClaim)4 JsonMessageSource (gov.cms.bfd.pipeline.rda.grpc.server.JsonMessageSource)3 FissClaimTransformer (gov.cms.bfd.pipeline.rda.grpc.source.FissClaimTransformer)3 IdHasher (gov.cms.bfd.pipeline.sharedutils.IdHasher)2 Clock (java.time.Clock)2 MessageOrBuilder (com.google.protobuf.MessageOrBuilder)1 Mbi (gov.cms.bfd.model.rda.Mbi)1 PreAdjFissDiagnosisCode (gov.cms.bfd.model.rda.PreAdjFissDiagnosisCode)1 PreAdjFissProcCode (gov.cms.bfd.model.rda.PreAdjFissProcCode)1 PreAdjMcsClaim (gov.cms.bfd.model.rda.PreAdjMcsClaim)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 RandomFissClaimSource (gov.cms.bfd.pipeline.rda.grpc.server.RandomFissClaimSource)1 DataTransformer (gov.cms.bfd.pipeline.rda.grpc.source.DataTransformer)1 FissClaimStreamCaller (gov.cms.bfd.pipeline.rda.grpc.source.FissClaimStreamCaller)1