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