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