Search in sources :

Example 1 with RdaChange

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

Example 2 with RdaChange

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));
}
Also used : RdaChange(gov.cms.bfd.pipeline.rda.grpc.RdaChange) PreAdjFissClaim(gov.cms.bfd.model.rda.PreAdjFissClaim)

Example 3 with RdaChange

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());
}
Also used : RdaChange(gov.cms.bfd.pipeline.rda.grpc.RdaChange) PreAdjMcsClaim(gov.cms.bfd.model.rda.PreAdjMcsClaim) Test(org.junit.jupiter.api.Test)

Example 4 with RdaChange

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));
}
Also used : RdaChange(gov.cms.bfd.pipeline.rda.grpc.RdaChange) PreAdjMcsClaim(gov.cms.bfd.model.rda.PreAdjMcsClaim)

Example 5 with RdaChange

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()));
}
Also used : RdaChange(gov.cms.bfd.pipeline.rda.grpc.RdaChange) PreAdjMcsClaim(gov.cms.bfd.model.rda.PreAdjMcsClaim) PreAdjMcsClaim(gov.cms.bfd.model.rda.PreAdjMcsClaim) McsClaim(gov.cms.mpsm.rda.v1.mcs.McsClaim)

Aggregations

RdaChange (gov.cms.bfd.pipeline.rda.grpc.RdaChange)5 PreAdjMcsClaim (gov.cms.bfd.model.rda.PreAdjMcsClaim)3 PreAdjFissClaim (gov.cms.bfd.model.rda.PreAdjFissClaim)2 FissClaim (gov.cms.mpsm.rda.v1.fiss.FissClaim)1 McsClaim (gov.cms.mpsm.rda.v1.mcs.McsClaim)1 Test (org.junit.jupiter.api.Test)1