Search in sources :

Example 6 with McsClaim

use of gov.cms.mpsm.rda.v1.mcs.McsClaim 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)

Example 7 with McsClaim

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

the class RandomMcsClaimSourceTest method threeMaxToReturn.

@Test
public void threeMaxToReturn() throws Exception {
    RandomMcsClaimSource source = new RandomMcsClaimSource(0, 3);
    assertTrue(source.hasNext());
    McsClaim claim = source.next();
    assertTrue(claim.getIdrClmHdIcn().length() > 0);
    assertTrue(source.hasNext());
    claim = source.next();
    assertTrue(claim.getIdrClmHdIcn().length() > 0);
    assertTrue(source.hasNext());
    claim = source.next();
    assertTrue(claim.getIdrClmHdIcn().length() > 0);
    assertFalse(source.hasNext());
    assertNextPastEndOfDataThrowsException(source);
}
Also used : McsClaim(gov.cms.mpsm.rda.v1.mcs.McsClaim) Test(org.junit.jupiter.api.Test)

Example 8 with McsClaim

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

the class RandomMcsClaimSourceTest method oneMaxToReturn.

@Test
public void oneMaxToReturn() throws Exception {
    RandomMcsClaimSource source = new RandomMcsClaimSource(0, 1);
    assertTrue(source.hasNext());
    McsClaim claim = source.next();
    assertTrue(claim.getIdrClmHdIcn().length() > 0);
    assertFalse(source.hasNext());
    assertNextPastEndOfDataThrowsException(source);
}
Also used : McsClaim(gov.cms.mpsm.rda.v1.mcs.McsClaim) Test(org.junit.jupiter.api.Test)

Example 9 with McsClaim

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

the class WrappedClaimSourceTest method skipStartingClaims.

@Test
public void skipStartingClaims() throws Exception {
    final List<McsClaim> claims = ImmutableList.of(McsClaim.newBuilder().setIdrHic("a").build(), McsClaim.newBuilder().setIdrHic("b").build(), McsClaim.newBuilder().setIdrHic("c").build(), McsClaim.newBuilder().setIdrHic("d").build(), McsClaim.newBuilder().setIdrHic("e").build(), McsClaim.newBuilder().setIdrHic("f").build(), McsClaim.newBuilder().setIdrHic("g").build());
    final MessageSource<McsClaim> realSource = fromList(claims);
    final MessageSource<McsClaimChange> wrapped = WrappedClaimSource.wrapMcsClaims(realSource, Clock.systemUTC(), 1000L).skip(3);
    for (int index = 3; index < claims.size(); ++index) {
        assertTrue(wrapped.hasNext());
        McsClaimChange change = wrapped.next();
        assertEquals(1000L + index, change.getSeq());
        assertSame(claims.get(index), change.getClaim());
    }
    assertFalse(wrapped.hasNext());
}
Also used : McsClaim(gov.cms.mpsm.rda.v1.mcs.McsClaim) McsClaimChange(gov.cms.mpsm.rda.v1.McsClaimChange) Test(org.junit.jupiter.api.Test)

Example 10 with McsClaim

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

the class WrappedClaimSourceTest method testChangeType.

@Test
public void testChangeType() throws Exception {
    final List<McsClaim> claims = ImmutableList.of(McsClaim.newBuilder().setIdrHic("a").build(), McsClaim.newBuilder().setIdrHic("b").build(), McsClaim.newBuilder().setIdrHic("c").build(), McsClaim.newBuilder().setIdrHic("a").build(), McsClaim.newBuilder().setIdrHic("e").build(), McsClaim.newBuilder().setIdrHic("f").build(), McsClaim.newBuilder().setIdrHic("g").build(), McsClaim.newBuilder().setIdrHic("a").build());
    final MessageSource<McsClaim> realSource = fromList(claims);
    final MessageSource<McsClaimChange> wrapped = new WrappedClaimSource<>(realSource, Clock.systemUTC(), 1000L, // set a cache size of 3 so we can verify updates are reported correctly
    3, String::valueOf, (timestamp, type, seq, claim) -> McsClaimChange.newBuilder().setTimestamp(timestamp).setChangeType(type).setSeq(seq).setClaim(claim).build());
    assertTrue(wrapped.hasNext());
    McsClaimChange change = wrapped.next();
    assertEquals("a", change.getClaim().getIdrHic());
    assertEquals(ChangeType.CHANGE_TYPE_INSERT, change.getChangeType());
    assertTrue(wrapped.hasNext());
    change = wrapped.next();
    assertEquals("b", change.getClaim().getIdrHic());
    assertEquals(ChangeType.CHANGE_TYPE_INSERT, change.getChangeType());
    assertTrue(wrapped.hasNext());
    change = wrapped.next();
    assertEquals("c", change.getClaim().getIdrHic());
    assertEquals(ChangeType.CHANGE_TYPE_INSERT, change.getChangeType());
    // a is not an UPDATE since it's in the cache
    assertTrue(wrapped.hasNext());
    change = wrapped.next();
    assertEquals("a", change.getClaim().getIdrHic());
    assertEquals(ChangeType.CHANGE_TYPE_UPDATE, change.getChangeType());
    // reading three more will cause a to fall out of the cache
    assertTrue(wrapped.hasNext());
    change = wrapped.next();
    assertEquals("e", change.getClaim().getIdrHic());
    assertEquals(ChangeType.CHANGE_TYPE_INSERT, change.getChangeType());
    assertTrue(wrapped.hasNext());
    change = wrapped.next();
    assertEquals("f", change.getClaim().getIdrHic());
    assertEquals(ChangeType.CHANGE_TYPE_INSERT, change.getChangeType());
    assertTrue(wrapped.hasNext());
    change = wrapped.next();
    assertEquals("g", change.getClaim().getIdrHic());
    assertEquals(ChangeType.CHANGE_TYPE_INSERT, change.getChangeType());
    // now a is an INSERT again since it's not cached
    assertTrue(wrapped.hasNext());
    change = wrapped.next();
    assertEquals("a", change.getClaim().getIdrHic());
    assertEquals(ChangeType.CHANGE_TYPE_INSERT, change.getChangeType());
}
Also used : McsClaim(gov.cms.mpsm.rda.v1.mcs.McsClaim) McsClaimChange(gov.cms.mpsm.rda.v1.McsClaimChange) Test(org.junit.jupiter.api.Test)

Aggregations

McsClaim (gov.cms.mpsm.rda.v1.mcs.McsClaim)8 Test (org.junit.jupiter.api.Test)7 McsClaimChange (gov.cms.mpsm.rda.v1.McsClaimChange)5 PreAdjMcsClaim (gov.cms.bfd.model.rda.PreAdjMcsClaim)3 McsDiagnosisCode (gov.cms.mpsm.rda.v1.mcs.McsDiagnosisCode)3 PreAdjMcsDetail (gov.cms.bfd.model.rda.PreAdjMcsDetail)2 PreAdjMcsDiagnosisCode (gov.cms.bfd.model.rda.PreAdjMcsDiagnosisCode)2 McsDetail (gov.cms.mpsm.rda.v1.mcs.McsDetail)2 Clock (java.time.Clock)2 Mbi (gov.cms.bfd.model.rda.Mbi)1 PreAdjMcsAdjustment (gov.cms.bfd.model.rda.PreAdjMcsAdjustment)1 PreAdjMcsAudit (gov.cms.bfd.model.rda.PreAdjMcsAudit)1 PreAdjMcsLocation (gov.cms.bfd.model.rda.PreAdjMcsLocation)1 RdaChange (gov.cms.bfd.pipeline.rda.grpc.RdaChange)1 JsonMessageSource (gov.cms.bfd.pipeline.rda.grpc.server.JsonMessageSource)1 McsClaimTransformer (gov.cms.bfd.pipeline.rda.grpc.source.McsClaimTransformer)1 IdHasher (gov.cms.bfd.pipeline.sharedutils.IdHasher)1 ClaimRequest (gov.cms.mpsm.rda.v1.ClaimRequest)1 McsAdjustment (gov.cms.mpsm.rda.v1.mcs.McsAdjustment)1 McsAudit (gov.cms.mpsm.rda.v1.mcs.McsAudit)1