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());
});
}
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());
});
}
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());
}
});
}
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);
}
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()));
}
Aggregations