Search in sources :

Example 1 with FissClaimTransformer

use of gov.cms.bfd.pipeline.rda.grpc.source.FissClaimTransformer 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);
            }
        }
    });
}
Also used : Path(java.nio.file.Path) McsClaimTransformer(gov.cms.bfd.pipeline.rda.grpc.source.McsClaimTransformer) ArrayList(java.util.ArrayList) WrappedCounter(gov.cms.bfd.pipeline.bridge.util.WrappedCounter) FissClaimChange(gov.cms.mpsm.rda.v1.FissClaimChange) Clock(java.time.Clock) MessageOrBuilder(com.google.protobuf.MessageOrBuilder) Sink(gov.cms.bfd.pipeline.bridge.io.Sink) IdHasher(gov.cms.bfd.pipeline.sharedutils.IdHasher) BeneficiaryData(gov.cms.bfd.pipeline.bridge.model.BeneficiaryData) FissClaimTransformer(gov.cms.bfd.pipeline.rda.grpc.source.FissClaimTransformer) Test(org.junit.jupiter.api.Test)

Example 2 with FissClaimTransformer

use of gov.cms.bfd.pipeline.rda.grpc.source.FissClaimTransformer in project beneficiary-fhir-data by CMSgov.

the class FissClaimRdaSinkIT method fissClaim.

@Test
public void fissClaim() throws Exception {
    RdaPipelineTestUtils.runTestWithTemporaryDb(FissClaimRdaSinkIT.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 PreAdjFissClaim claim = new PreAdjFissClaim();
        claim.setSequenceNumber(3L);
        claim.setDcn("1");
        claim.setHicNo("h1");
        claim.setCurrStatus('T');
        claim.setCurrLoc1('A');
        claim.setCurrLoc2("1A");
        claim.setPracLocCity("city name can be very long indeed");
        claim.setMbiRecord(new Mbi(1L, "12345678901", "hash-of-12345678901"));
        final PreAdjFissProcCode procCode0 = new PreAdjFissProcCode();
        procCode0.setDcn(claim.getDcn());
        procCode0.setPriority((short) 0);
        procCode0.setProcCode("P");
        procCode0.setProcFlag("F");
        procCode0.setProcDate(today);
        claim.getProcCodes().add(procCode0);
        final PreAdjFissDiagnosisCode diagCode0 = new PreAdjFissDiagnosisCode();
        diagCode0.setDcn(claim.getDcn());
        diagCode0.setPriority((short) 0);
        diagCode0.setDiagCd2("cd2");
        diagCode0.setDiagPoaInd("Q");
        claim.getDiagCodes().add(diagCode0);
        final FissProcedureCode procCodeMessage = FissProcedureCode.newBuilder().setProcCd("P").setProcFlag("F").setProcDt("2022-01-03").build();
        final FissDiagnosisCode diagCodeMessage = FissDiagnosisCode.newBuilder().setDiagCd2("cd2").setDiagPoaIndUnrecognized("Q").build();
        final FissClaim claimMessage = FissClaim.newBuilder().setDcn(claim.getDcn()).setHicNo(claim.getHicNo()).setCurrStatusEnum(FissClaimStatus.CLAIM_STATUS_RTP).setCurrLoc1Unrecognized(String.valueOf(claim.getCurrLoc1())).setCurrLoc2Unrecognized(claim.getCurrLoc2()).setPracLocCity("city name can be very long indeed").addFissProcCodes(0, procCodeMessage).addFissDiagCodes(0, diagCodeMessage).setMbi(claim.getMbi()).build();
        final FissClaimChange message = FissClaimChange.newBuilder().setSeq(claim.getSequenceNumber()).setDcn(claim.getDcn()).setClaim(claimMessage).build();
        final IdHasher defaultIdHasher = new IdHasher(new IdHasher.Config(1, "notarealpepper"));
        final FissClaimTransformer transformer = new FissClaimTransformer(clock, MbiCache.computedCache(defaultIdHasher.getConfig()));
        final FissClaimRdaSink sink = new FissClaimRdaSink(appState, transformer, true);
        final String expectedMbiHash = defaultIdHasher.computeIdentifierHash(claim.getMbi());
        assertEquals(Optional.empty(), sink.readMaxExistingSequenceNumber());
        int count = sink.writeMessage("version", message);
        assertEquals(1, count);
        List<PreAdjFissClaim> claims = entityManager.createQuery("select c from PreAdjFissClaim c", PreAdjFissClaim.class).getResultList();
        assertEquals(1, claims.size());
        PreAdjFissClaim resultClaim = claims.get(0);
        assertEquals(Long.valueOf(3), resultClaim.getSequenceNumber());
        assertEquals(claim.getHicNo(), resultClaim.getHicNo());
        assertEquals(claim.getPracLocCity(), resultClaim.getPracLocCity());
        assertEquals(claim.getMbi(), resultClaim.getMbi());
        assertEquals(expectedMbiHash, resultClaim.getMbiHash());
        assertEquals(claim.getProcCodes().size(), resultClaim.getProcCodes().size());
        assertEquals(claim.getDiagCodes().size(), resultClaim.getDiagCodes().size());
        assertEquals(Optional.of(claim.getSequenceNumber()), sink.readMaxExistingSequenceNumber());
        Mbi databaseMbiEntity = RdaPipelineTestUtils.lookupCachedMbi(entityManager, claimMessage.getMbi());
        assertNotNull(databaseMbiEntity);
        assertEquals(claim.getMbi(), databaseMbiEntity.getMbi());
        assertEquals(expectedMbiHash, databaseMbiEntity.getHash());
    });
}
Also used : FissProcedureCode(gov.cms.mpsm.rda.v1.fiss.FissProcedureCode) Instant(java.time.Instant) PreAdjFissClaim(gov.cms.bfd.model.rda.PreAdjFissClaim) FissClaim(gov.cms.mpsm.rda.v1.fiss.FissClaim) FissClaimChange(gov.cms.mpsm.rda.v1.FissClaimChange) PreAdjFissClaim(gov.cms.bfd.model.rda.PreAdjFissClaim) FissDiagnosisCode(gov.cms.mpsm.rda.v1.fiss.FissDiagnosisCode) PreAdjFissDiagnosisCode(gov.cms.bfd.model.rda.PreAdjFissDiagnosisCode) Clock(java.time.Clock) LocalDate(java.time.LocalDate) PreAdjFissDiagnosisCode(gov.cms.bfd.model.rda.PreAdjFissDiagnosisCode) Mbi(gov.cms.bfd.model.rda.Mbi) PreAdjFissProcCode(gov.cms.bfd.model.rda.PreAdjFissProcCode) IdHasher(gov.cms.bfd.pipeline.sharedutils.IdHasher) FissClaimTransformer(gov.cms.bfd.pipeline.rda.grpc.source.FissClaimTransformer) Test(org.junit.jupiter.api.Test)

Example 3 with FissClaimTransformer

use of gov.cms.bfd.pipeline.rda.grpc.source.FissClaimTransformer in project beneficiary-fhir-data by CMSgov.

the class RdaLoadJobIT method fissClaimsAreValid.

/**
 * 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 fissClaimsAreValid() throws Exception {
    final ImmutableList<FissClaimChange> expectedClaims = JsonMessageSource.parseAll(fissClaimJson, JsonMessageSource::parseFissClaimChange);
    final FissClaimTransformer transformer = new FissClaimTransformer(clock, MbiCache.computedCache(new IdHasher.Config(1, "testing")));
    for (FissClaimChange claim : expectedClaims) {
        try {
            transformer.transformClaim(claim);
        } catch (DataTransformer.TransformationException ex) {
            fail(String.format("bad sample claim: seq=%d error=%s", claim.getSeq(), ex.getErrors()));
        }
    }
}
Also used : JsonMessageSource(gov.cms.bfd.pipeline.rda.grpc.server.JsonMessageSource) DataTransformer(gov.cms.bfd.pipeline.rda.grpc.source.DataTransformer) FissClaimChange(gov.cms.mpsm.rda.v1.FissClaimChange) FissClaimTransformer(gov.cms.bfd.pipeline.rda.grpc.source.FissClaimTransformer) Test(org.junit.jupiter.api.Test)

Aggregations

FissClaimTransformer (gov.cms.bfd.pipeline.rda.grpc.source.FissClaimTransformer)3 FissClaimChange (gov.cms.mpsm.rda.v1.FissClaimChange)3 Test (org.junit.jupiter.api.Test)3 IdHasher (gov.cms.bfd.pipeline.sharedutils.IdHasher)2 Clock (java.time.Clock)2 MessageOrBuilder (com.google.protobuf.MessageOrBuilder)1 Mbi (gov.cms.bfd.model.rda.Mbi)1 PreAdjFissClaim (gov.cms.bfd.model.rda.PreAdjFissClaim)1 PreAdjFissDiagnosisCode (gov.cms.bfd.model.rda.PreAdjFissDiagnosisCode)1 PreAdjFissProcCode (gov.cms.bfd.model.rda.PreAdjFissProcCode)1 Sink (gov.cms.bfd.pipeline.bridge.io.Sink)1 BeneficiaryData (gov.cms.bfd.pipeline.bridge.model.BeneficiaryData)1 WrappedCounter (gov.cms.bfd.pipeline.bridge.util.WrappedCounter)1 JsonMessageSource (gov.cms.bfd.pipeline.rda.grpc.server.JsonMessageSource)1 DataTransformer (gov.cms.bfd.pipeline.rda.grpc.source.DataTransformer)1 McsClaimTransformer (gov.cms.bfd.pipeline.rda.grpc.source.McsClaimTransformer)1 FissClaim (gov.cms.mpsm.rda.v1.fiss.FissClaim)1 FissDiagnosisCode (gov.cms.mpsm.rda.v1.fiss.FissDiagnosisCode)1 FissProcedureCode (gov.cms.mpsm.rda.v1.fiss.FissProcedureCode)1 Path (java.nio.file.Path)1