use of gov.cms.bfd.pipeline.rda.grpc.RdaChange 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()));
}
use of gov.cms.bfd.pipeline.rda.grpc.RdaChange in project beneficiary-fhir-data by CMSgov.
the class FissClaimRdaSinkTest method createClaim.
private RdaChange<PreAdjFissClaim> createClaim(String dcn) {
PreAdjFissClaim claim = new PreAdjFissClaim();
claim.setDcn(dcn);
claim.setApiSource(VERSION);
return new RdaChange<>(nextSeq++, RdaChange.Type.INSERT, claim, clock.instant().minusMillis(12));
}
use of gov.cms.bfd.pipeline.rda.grpc.RdaChange in project beneficiary-fhir-data by CMSgov.
the class McsClaimRdaSinkTest method mergeSuccessful.
@Test
public void mergeSuccessful() throws Exception {
final List<RdaChange<PreAdjMcsClaim>> batch = ImmutableList.of(createClaim("1"), createClaim("2"), createClaim("3"));
final int count = sink.writeMessages(VERSION, messagesForBatch(batch));
assertEquals(3, count);
for (RdaChange<PreAdjMcsClaim> change : batch) {
PreAdjMcsClaim claim = change.getClaim();
verify(entityManager).merge(claim);
}
// the merge transaction will be committed
verify(transaction).commit();
final AbstractClaimRdaSink.Metrics metrics = sink.getMetrics();
assertMeterReading(1, "calls", metrics.getCalls());
assertMeterReading(0, "persists", metrics.getObjectsPersisted());
assertMeterReading(3, "merges", metrics.getObjectsMerged());
assertMeterReading(3, "writes", metrics.getObjectsWritten());
assertMeterReading(1, "successes", metrics.getSuccesses());
assertMeterReading(0, "failures", metrics.getFailures());
assertGaugeReading(2, "lastSeq", metrics.getLatestSequenceNumber());
}
use of gov.cms.bfd.pipeline.rda.grpc.RdaChange in project beneficiary-fhir-data by CMSgov.
the class McsClaimRdaSinkTest method createClaim.
private RdaChange<PreAdjMcsClaim> createClaim(String dcn) {
PreAdjMcsClaim claim = new PreAdjMcsClaim();
claim.setIdrClmHdIcn(dcn);
claim.setApiSource(VERSION);
return new RdaChange<>(nextSeq++, RdaChange.Type.INSERT, claim, clock.instant().minusMillis(12));
}
use of gov.cms.bfd.pipeline.rda.grpc.RdaChange in project beneficiary-fhir-data by CMSgov.
the class McsClaimTransformer method transformClaim.
public RdaChange<PreAdjMcsClaim> transformClaim(McsClaimChange change) {
McsClaim from = change.getClaim();
final DataTransformer transformer = new DataTransformer();
final PreAdjMcsClaim 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: clmHdIcn=%s errors=%s", errors.size(), from.getIdrClmHdIcn(), errors);
throw new DataTransformer.TransformationException(message, errors);
}
return new RdaChange<>(change.getSeq(), RdaApiUtils.mapApiChangeType(change.getChangeType()), to, transformer.instant(change.getTimestamp()));
}
Aggregations