use of gov.cms.bfd.pipeline.rda.grpc.source.McsClaimTransformer 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.bfd.pipeline.rda.grpc.source.McsClaimTransformer in project beneficiary-fhir-data by CMSgov.
the class RdaLoadJobIT method mcsClaimsAreValid.
/**
* All of our test claims should be valid for our IT tests to succeed. This test ensures this is
* the case and catches any incompatibility issues when a new RDA API version contains breaking
* changes.
*/
@Test
public void mcsClaimsAreValid() throws Exception {
final ImmutableList<McsClaimChange> expectedClaims = JsonMessageSource.parseAll(mcsClaimJson, JsonMessageSource::parseMcsClaimChange);
final McsClaimTransformer transformer = new McsClaimTransformer(clock, MbiCache.computedCache(new IdHasher.Config(1, "testing")));
for (McsClaimChange claim : expectedClaims) {
try {
transformer.transformClaim(claim);
} catch (DataTransformer.TransformationException ex) {
fail(String.format("bad sample claim: seq=%d error=%s", claim.getSeq(), ex.getErrors()));
}
}
}
use of gov.cms.bfd.pipeline.rda.grpc.source.McsClaimTransformer in project beneficiary-fhir-data by CMSgov.
the class RDABridgeIT method shouldProduceValidClaimStructures.
/**
* Ensures that no exceptions are thrown while transforming Fiss and MCS claims.
*
* @throws IOException if there is a setup issue loading the test data
*/
@Test
void shouldProduceValidClaimStructures() throws IOException {
RDABridge bridge = new RDABridge();
Path resourcesDir = getResourcePath();
String inpatientData = "inpatient.csv";
String carrierData = "carrier.csv";
Map<String, BeneficiaryData> mbiMap = bridge.parseMbiNumbers(resourcesDir.resolve("beneficiary_history.csv"));
List<MessageOrBuilder> results = new ArrayList<>();
Sink<MessageOrBuilder> testSink = new Sink<>() {
@Override
public void write(MessageOrBuilder value) {
results.add(value);
}
@Override
public void close() throws IOException {
}
};
final int FISS_ID = 0;
final int MCS_ID = 1;
DataSampler<String> dataSampler = DataSampler.<String>builder().maxValues(10_000).registerSampleSet(FISS_ID, 0.5f).registerSampleSet(MCS_ID, 0.5f).build();
assertDoesNotThrow(() -> {
bridge.executeTransformation(RDABridge.SourceType.FISS, resourcesDir, inpatientData, new WrappedCounter(0), mbiMap, testSink, dataSampler, FISS_ID);
bridge.executeTransformation(RDABridge.SourceType.MCS, resourcesDir, carrierData, new WrappedCounter(0), mbiMap, testSink, dataSampler, MCS_ID);
Clock clock = Clock.fixed(Instant.ofEpochMilli(1622743357000L), ZoneOffset.UTC);
IdHasher.Config hasherConfig = new IdHasher.Config(10, "justsomestring");
FissClaimTransformer fissTransformer = new FissClaimTransformer(clock, MbiCache.computedCache(hasherConfig));
McsClaimTransformer mcsTransformer = new McsClaimTransformer(clock, MbiCache.computedCache(hasherConfig));
for (MessageOrBuilder message : results) {
if (message instanceof FissClaimChange) {
fissTransformer.transformClaim((FissClaimChange) message);
} else {
mcsTransformer.transformClaim((McsClaimChange) message);
}
}
});
}
Aggregations