Search in sources :

Example 11 with StaticRifResource

use of gov.cms.bfd.model.rif.samples.StaticRifResource in project beneficiary-fhir-data by CMSgov.

the class InpatientClaimTransformerTest method transformSampleARecord.

/**
 * Verifies that {@link
 * gov.cms.bfd.server.war.stu3.providers.InpatientClaimTransformer#transform(Object)} works as
 * expected when run against the {@link StaticRifResource#SAMPLE_A_INPATIENT} {@link
 * InpatientClaim}.
 *
 * @throws FHIRException (indicates test failure)
 */
@Test
public void transformSampleARecord() throws FHIRException {
    List<Object> parsedRecords = ServerTestUtils.parseData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
    InpatientClaim claim = parsedRecords.stream().filter(r -> r instanceof InpatientClaim).map(r -> (InpatientClaim) r).findFirst().get();
    claim.setLastUpdated(Instant.now());
    ExplanationOfBenefit eob = InpatientClaimTransformer.transform(new MetricRegistry(), claim, Optional.empty());
    assertMatches(claim, eob);
}
Also used : Arrays(java.util.Arrays) MetricRegistry(com.codahale.metrics.MetricRegistry) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) StaticRifResource(gov.cms.bfd.model.rif.samples.StaticRifResource) MedicareSegment(gov.cms.bfd.server.war.commons.MedicareSegment) ItemComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.ItemComponent) InpatientClaim(gov.cms.bfd.model.rif.InpatientClaim) InpatientClaimLine(gov.cms.bfd.model.rif.InpatientClaimLine) Instant(java.time.Instant) Test(org.junit.jupiter.api.Test) BigDecimal(java.math.BigDecimal) List(java.util.List) CcwCodebookVariable(gov.cms.bfd.model.codebook.data.CcwCodebookVariable) Optional(java.util.Optional) CCWProcedure(gov.cms.bfd.server.war.commons.CCWProcedure) FHIRException(org.hl7.fhir.exceptions.FHIRException) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) StaticRifResourceGroup(gov.cms.bfd.model.rif.samples.StaticRifResourceGroup) ServerTestUtils(gov.cms.bfd.server.war.ServerTestUtils) Diagnosis(gov.cms.bfd.server.war.commons.Diagnosis) InpatientClaim(gov.cms.bfd.model.rif.InpatientClaim) MetricRegistry(com.codahale.metrics.MetricRegistry) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) Test(org.junit.jupiter.api.Test)

Example 12 with StaticRifResource

use of gov.cms.bfd.model.rif.samples.StaticRifResource in project beneficiary-fhir-data by CMSgov.

the class OutpatientClaimTransformerTest method transformSampleARecord.

/**
 * Verifies that {@link
 * gov.cms.bfd.server.war.stu3.providers.OutpatientClaimTransformer#transform(Object)} works as
 * expected when run against the {@link StaticRifResource#SAMPLE_A_OUTPATIENT} {@link
 * OutpatientClaim}.
 *
 * @throws FHIRException (indicates test failure)
 */
@Test
public void transformSampleARecord() throws FHIRException {
    List<Object> parsedRecords = ServerTestUtils.parseData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
    OutpatientClaim claim = parsedRecords.stream().filter(r -> r instanceof OutpatientClaim).map(r -> (OutpatientClaim) r).findFirst().get();
    ExplanationOfBenefit eob = OutpatientClaimTransformer.transform(new MetricRegistry(), claim, Optional.empty());
    assertMatches(claim, eob);
}
Also used : IntStream(java.util.stream.IntStream) Arrays(java.util.Arrays) RifFileType(gov.cms.bfd.model.rif.RifFileType) StaticRifResource(gov.cms.bfd.model.rif.samples.StaticRifResource) LoggerFactory(org.slf4j.LoggerFactory) Disabled(org.junit.jupiter.api.Disabled) OutpatientClaimLine(gov.cms.bfd.model.rif.OutpatientClaimLine) CcwCodebookVariable(gov.cms.bfd.model.codebook.data.CcwCodebookVariable) CCWProcedure(gov.cms.bfd.server.war.commons.CCWProcedure) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) StaticRifResourceGroup(gov.cms.bfd.model.rif.samples.StaticRifResourceGroup) ServerTestUtils(gov.cms.bfd.server.war.ServerTestUtils) OutpatientClaim(gov.cms.bfd.model.rif.OutpatientClaim) MetricRegistry(com.codahale.metrics.MetricRegistry) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) MedicareSegment(gov.cms.bfd.server.war.commons.MedicareSegment) ItemComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.ItemComponent) Collectors(java.util.stream.Collectors) ZoneId(java.time.ZoneId) Test(org.junit.jupiter.api.Test) List(java.util.List) Stream(java.util.stream.Stream) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Optional(java.util.Optional) FHIRException(org.hl7.fhir.exceptions.FHIRException) OutpatientClaim(gov.cms.bfd.model.rif.OutpatientClaim) MetricRegistry(com.codahale.metrics.MetricRegistry) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) Test(org.junit.jupiter.api.Test)

Example 13 with StaticRifResource

use of gov.cms.bfd.model.rif.samples.StaticRifResource in project beneficiary-fhir-data by CMSgov.

the class CarrierClaimTransformerTest method transformSampleURecord.

/**
 * Verifies that {@link
 * gov.cms.bfd.server.war.stu3.providers.CarrierClaimTransformer#transform(Object)} works as
 * expected when run against the {@link StaticRifResource#SAMPLE_U_CARRIER} {@link CarrierClaim}.
 *
 * @throws FHIRException (indicates test failure)
 */
@Test
public void transformSampleURecord() throws FHIRException {
    List<Object> parsedRecords = ServerTestUtils.parseData(Arrays.asList(StaticRifResourceGroup.SAMPLE_U.getResources()));
    CarrierClaim claim = parsedRecords.stream().filter(r -> r instanceof CarrierClaim).map(r -> (CarrierClaim) r).findFirst().get();
    ExplanationOfBenefit eob = CarrierClaimTransformer.transform(new MetricRegistry(), claim, Optional.of(true));
    assertMatches(claim, eob, Optional.of(true));
}
Also used : Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Arrays(java.util.Arrays) MetricRegistry(com.codahale.metrics.MetricRegistry) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) StaticRifResource(gov.cms.bfd.model.rif.samples.StaticRifResource) MedicareSegment(gov.cms.bfd.server.war.commons.MedicareSegment) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) ItemComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.ItemComponent) Instant(java.time.Instant) ClaimCareteamrole(org.hl7.fhir.dstu3.model.codesystems.ClaimCareteamrole) Test(org.junit.jupiter.api.Test) BigDecimal(java.math.BigDecimal) List(java.util.List) CareTeamComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.CareTeamComponent) TransformerConstants(gov.cms.bfd.server.war.commons.TransformerConstants) CcwCodebookVariable(gov.cms.bfd.model.codebook.data.CcwCodebookVariable) CarrierClaim(gov.cms.bfd.model.rif.CarrierClaim) CarrierClaimLine(gov.cms.bfd.model.rif.CarrierClaimLine) Optional(java.util.Optional) FHIRException(org.hl7.fhir.exceptions.FHIRException) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) StaticRifResourceGroup(gov.cms.bfd.model.rif.samples.StaticRifResourceGroup) ServerTestUtils(gov.cms.bfd.server.war.ServerTestUtils) MetricRegistry(com.codahale.metrics.MetricRegistry) CarrierClaim(gov.cms.bfd.model.rif.CarrierClaim) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) Test(org.junit.jupiter.api.Test)

Example 14 with StaticRifResource

use of gov.cms.bfd.model.rif.samples.StaticRifResource in project beneficiary-fhir-data by CMSgov.

the class RifLoaderIT method verifyRecordPrimaryKeysPresent.

/**
 * Runs the {@link RifFilesProcessor} to extract RIF records from the specified {@link
 * StaticRifResource}s, and then calls {@link #assertAreInDatabase(LoadAppOptions,
 * EntityManagerFactory, Stream)} on each record to verify that it's present in the database.
 * Basically: this is a decent smoke test to verify that {@link RifLoader} did what it should have
 * -- not thorough, but something.
 *
 * @param sampleResources the {@link StaticRifResource}s to go check for in the DB
 */
private void verifyRecordPrimaryKeysPresent(List<StaticRifResource> sampleResources) {
    EntityManagerFactory entityManagerFactory = PipelineTestUtils.get().getPipelineApplicationState().getEntityManagerFactory();
    RifFilesProcessor processor = new RifFilesProcessor();
    LoadAppOptions options = CcwRifLoadTestUtils.getLoadOptions();
    /*
     * Run the extraction an extra time and verify that each record can now
     * be found in the database.
     */
    for (StaticRifResource rifResource : sampleResources) {
        /*
       * This is too slow to run against larger data sets: for instance,
       * it took 45 minutes to run against the synthetic data. So, we skip
       * it for some things.
       */
        if (rifResource.getRecordCount() > 10000) {
            LOGGER.info("Skipping DB records check for: {}", rifResource);
            continue;
        }
        LOGGER.info("Checking DB for records for: {}", rifResource);
        RifFilesEvent rifFilesEventSingle = new RifFilesEvent(Instant.now(), rifResource.toRifFile());
        RifFileRecords rifFileRecordsCopy = processor.produceRecords(rifFilesEventSingle.getFileEvents().get(0));
        assertAreInDatabase(options, entityManagerFactory, rifFileRecordsCopy.getRecords().map(r -> r.getRecord()));
    }
    LOGGER.info("All records found in DB.");
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) RifFileType(gov.cms.bfd.model.rif.RifFileType) StaticRifResource(gov.cms.bfd.model.rif.samples.StaticRifResource) CSVRecord(org.apache.commons.csv.CSVRecord) LoggerFactory(org.slf4j.LoggerFactory) IdHasher(gov.cms.bfd.pipeline.sharedutils.IdHasher) Disabled(org.junit.jupiter.api.Disabled) RifFilesProcessor(gov.cms.bfd.pipeline.ccw.rif.extract.RifFilesProcessor) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) CSVFormat(org.apache.commons.csv.CSVFormat) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AssertionFailedError(org.opentest4j.AssertionFailedError) CarrierClaimLine(gov.cms.bfd.model.rif.CarrierClaimLine) CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) BeneficiaryHistory(gov.cms.bfd.model.rif.BeneficiaryHistory) Path(java.nio.file.Path) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) Predicate(java.util.function.Predicate) RifFileRecords(gov.cms.bfd.model.rif.RifFileRecords) RifFile(gov.cms.bfd.model.rif.RifFile) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) BeneficiaryMonthly(gov.cms.bfd.model.rif.BeneficiaryMonthly) TestInfo(org.junit.jupiter.api.TestInfo) RifFilesEvent(gov.cms.bfd.model.rif.RifFilesEvent) UncheckedIOException(java.io.UncheckedIOException) Test(org.junit.jupiter.api.Test) Beneficiary(gov.cms.bfd.model.rif.Beneficiary) LoadedBatch(gov.cms.bfd.model.rif.LoadedBatch) List(java.util.List) BeneficiaryHistory_(gov.cms.bfd.model.rif.BeneficiaryHistory_) Stream(java.util.stream.Stream) EntityManagerFactory(javax.persistence.EntityManagerFactory) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) CarrierClaim(gov.cms.bfd.model.rif.CarrierClaim) LocalDate(java.time.LocalDate) Slf4jReporter(com.codahale.metrics.Slf4jReporter) LoadedFile(gov.cms.bfd.model.rif.LoadedFile) Optional(java.util.Optional) RifParsingUtils(gov.cms.bfd.model.rif.parse.RifParsingUtils) BeneficiaryColumn(gov.cms.bfd.model.rif.BeneficiaryColumn) RifRecordEvent(gov.cms.bfd.model.rif.RifRecordEvent) CSVPrinter(org.apache.commons.csv.CSVPrinter) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) SkippedRifRecord(gov.cms.bfd.model.rif.SkippedRifRecord) LocalRifFile(gov.cms.bfd.pipeline.ccw.rif.extract.LocalRifFile) Function(java.util.function.Function) PipelineTestUtils(gov.cms.bfd.pipeline.sharedutils.PipelineTestUtils) StreamSupport(java.util.stream.StreamSupport) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) StaticRifResourceGroup(gov.cms.bfd.model.rif.samples.StaticRifResourceGroup) Root(javax.persistence.criteria.Root) RifFileEvent(gov.cms.bfd.model.rif.RifFileEvent) Logger(org.slf4j.Logger) Files(java.nio.file.Files) Month(java.time.Month) FileWriter(java.io.FileWriter) IOException(java.io.IOException) EntityManager(javax.persistence.EntityManager) AfterEach(org.junit.jupiter.api.AfterEach) ChronoUnit(java.time.temporal.ChronoUnit) EntityTransaction(javax.persistence.EntityTransaction) StaticRifResource(gov.cms.bfd.model.rif.samples.StaticRifResource) EntityManagerFactory(javax.persistence.EntityManagerFactory) RifFileRecords(gov.cms.bfd.model.rif.RifFileRecords) RifFilesProcessor(gov.cms.bfd.pipeline.ccw.rif.extract.RifFilesProcessor) RifFilesEvent(gov.cms.bfd.model.rif.RifFilesEvent)

Aggregations

StaticRifResource (gov.cms.bfd.model.rif.samples.StaticRifResource)14 List (java.util.List)13 Optional (java.util.Optional)13 StaticRifResourceGroup (gov.cms.bfd.model.rif.samples.StaticRifResourceGroup)12 Arrays (java.util.Arrays)12 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)12 Test (org.junit.jupiter.api.Test)12 MetricRegistry (com.codahale.metrics.MetricRegistry)11 CcwCodebookVariable (gov.cms.bfd.model.codebook.data.CcwCodebookVariable)11 ServerTestUtils (gov.cms.bfd.server.war.ServerTestUtils)11 MedicareSegment (gov.cms.bfd.server.war.commons.MedicareSegment)11 FHIRException (org.hl7.fhir.exceptions.FHIRException)11 ExplanationOfBenefit (org.hl7.fhir.dstu3.model.ExplanationOfBenefit)10 ItemComponent (org.hl7.fhir.dstu3.model.ExplanationOfBenefit.ItemComponent)10 BigDecimal (java.math.BigDecimal)7 Instant (java.time.Instant)6 CCWProcedure (gov.cms.bfd.server.war.commons.CCWProcedure)5 Collectors (java.util.stream.Collectors)5 LoggerFactory (org.slf4j.LoggerFactory)5 RifFileType (gov.cms.bfd.model.rif.RifFileType)4