use of gov.cms.mpsm.rda.v1.mcs.McsDetail 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.mcs.McsDetail in project beneficiary-fhir-data by CMSgov.
the class McsClaimTransformer method transformMessageArrays.
private void transformMessageArrays(McsClaim from, PreAdjMcsClaim to, DataTransformer transformer, Instant now, String namePrefix) {
for (short index = 0; index < from.getMcsDetailsCount(); ++index) {
final String itemNamePrefix = namePrefix + "detail" + "-" + index + "-";
final McsDetail itemFrom = from.getMcsDetails(index);
final PreAdjMcsDetail itemTo = transformMessageImpl(itemFrom, transformer, now, itemNamePrefix);
itemTo.setIdrClmHdIcn(from.getIdrClmHdIcn());
itemTo.setPriority(index);
to.getDetails().add(itemTo);
}
for (short index = 0; index < from.getMcsDiagnosisCodesCount(); ++index) {
final String itemNamePrefix = namePrefix + "diagCode" + "-" + index + "-";
final McsDiagnosisCode itemFrom = from.getMcsDiagnosisCodes(index);
final PreAdjMcsDiagnosisCode itemTo = transformMessageImpl(itemFrom, transformer, now, itemNamePrefix);
itemTo.setIdrClmHdIcn(from.getIdrClmHdIcn());
itemTo.setPriority(index);
to.getDiagCodes().add(itemTo);
}
for (short index = 0; index < from.getMcsAdjustmentsCount(); ++index) {
final String itemNamePrefix = namePrefix + "adjustment" + "-" + index + "-";
final McsAdjustment itemFrom = from.getMcsAdjustments(index);
final PreAdjMcsAdjustment itemTo = transformMessageImpl(itemFrom, transformer, now, itemNamePrefix);
itemTo.setIdrClmHdIcn(from.getIdrClmHdIcn());
itemTo.setPriority(index);
to.getAdjustments().add(itemTo);
}
for (short index = 0; index < from.getMcsAuditsCount(); ++index) {
final String itemNamePrefix = namePrefix + "audit" + "-" + index + "-";
final McsAudit itemFrom = from.getMcsAudits(index);
final PreAdjMcsAudit itemTo = transformMessageImpl(itemFrom, transformer, now, itemNamePrefix);
itemTo.setIdrClmHdIcn(from.getIdrClmHdIcn());
itemTo.setPriority(index);
to.getAudits().add(itemTo);
}
for (short index = 0; index < from.getMcsLocationsCount(); ++index) {
final String itemNamePrefix = namePrefix + "location" + "-" + index + "-";
final McsLocation itemFrom = from.getMcsLocations(index);
final PreAdjMcsLocation itemTo = transformMessageImpl(itemFrom, transformer, now, itemNamePrefix);
itemTo.setIdrClmHdIcn(from.getIdrClmHdIcn());
itemTo.setPriority(index);
to.getLocations().add(itemTo);
}
}
Aggregations