Search in sources :

Example 21 with RifRecordEvent

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

the class RifFilesProcessorTest method process1BeneRecordWithBackslash.

/**
 * Ensures that {@link RifFilesProcessor} can correctly handle {@link
 * StaticRifResource#SAMPLE_A_BENES}.
 */
@Test
public void process1BeneRecordWithBackslash() {
    RifFilesEvent filesEvent = new RifFilesEvent(Instant.now(), StaticRifResource.SAMPLE_A_BENES_WITH_BACKSLASH.toRifFile());
    RifFilesProcessor processor = new RifFilesProcessor();
    RifFileRecords rifFileRecords = processor.produceRecords(filesEvent.getFileEvents().get(0));
    List<RifRecordEvent<?>> rifEventsList = rifFileRecords.getRecords().collect(Collectors.toList());
    assertEquals(StaticRifResource.SAMPLE_A_BENES_WITH_BACKSLASH.getRecordCount(), rifEventsList.size());
    RifRecordEvent<?> rifRecordEvent = rifEventsList.get(0);
    assertEquals(StaticRifResource.SAMPLE_A_BENES_WITH_BACKSLASH.getRifFileType(), rifRecordEvent.getFileEvent().getFile().getFileType());
    assertNotNull(rifRecordEvent.getRecord());
    assertTrue(rifRecordEvent.getRecord() instanceof Beneficiary);
    Beneficiary beneRow = (Beneficiary) rifRecordEvent.getRecord();
    assertEquals(beneRow.getBeneficiaryId(), rifRecordEvent.getBeneficiaryId());
    assertEquals(RecordAction.INSERT, rifRecordEvent.getRecordAction());
    assertEquals("DAEJEON SI 34867", beneRow.getDerivedMailingAddress4().get());
}
Also used : RifRecordEvent(gov.cms.bfd.model.rif.RifRecordEvent) RifFileRecords(gov.cms.bfd.model.rif.RifFileRecords) RifFilesEvent(gov.cms.bfd.model.rif.RifFilesEvent) Beneficiary(gov.cms.bfd.model.rif.Beneficiary) Test(org.junit.jupiter.api.Test)

Example 22 with RifRecordEvent

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

the class RifFilesProcessor method buildHHAClaimEvent.

/**
 * @param fileEvent the {@link RifFileEvent} being processed
 * @param csvRecords the {@link CSVRecord}s to be mapped, which must be from a {@link
 *     RifFileType#HHA} {@link RifFile}
 * @return a {@link RifRecordEvent} built from the specified {@link CSVRecord}s
 */
private static RifRecordEvent<HHAClaim> buildHHAClaimEvent(RifFileEvent fileEvent, List<CSVRecord> csvRecords) {
    if (LOGGER.isTraceEnabled())
        LOGGER.trace(csvRecords.toString());
    CSVRecord firstCsvRecord = csvRecords.get(0);
    RecordAction recordAction = RecordAction.match(firstCsvRecord.get("DML_IND"));
    HHAClaim claim = HHAClaimParser.parseRif(csvRecords);
    return new RifRecordEvent<HHAClaim>(fileEvent, csvRecords, recordAction, claim.getBeneficiaryId(), claim);
}
Also used : HHAClaim(gov.cms.bfd.model.rif.HHAClaim) RifRecordEvent(gov.cms.bfd.model.rif.RifRecordEvent) CSVRecord(org.apache.commons.csv.CSVRecord) RecordAction(gov.cms.bfd.model.rif.RecordAction)

Example 23 with RifRecordEvent

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

the class RifFilesProcessor method buildDMEClaimEvent.

/**
 * @param fileEvent the {@link RifFileEvent} being processed
 * @param csvRecords the {@link CSVRecord}s to be mapped, which must be from a {@link
 *     RifFileType#DME} {@link RifFile}
 * @return a {@link RifRecordEvent} built from the specified {@link CSVRecord}s
 */
private static RifRecordEvent<DMEClaim> buildDMEClaimEvent(RifFileEvent fileEvent, List<CSVRecord> csvRecords) {
    if (LOGGER.isTraceEnabled())
        LOGGER.trace(csvRecords.toString());
    CSVRecord firstCsvRecord = csvRecords.get(0);
    RecordAction recordAction = RecordAction.match(firstCsvRecord.get("DML_IND"));
    DMEClaim claim = DMEClaimParser.parseRif(csvRecords);
    return new RifRecordEvent<DMEClaim>(fileEvent, csvRecords, recordAction, claim.getBeneficiaryId(), claim);
}
Also used : DMEClaim(gov.cms.bfd.model.rif.DMEClaim) RifRecordEvent(gov.cms.bfd.model.rif.RifRecordEvent) CSVRecord(org.apache.commons.csv.CSVRecord) RecordAction(gov.cms.bfd.model.rif.RecordAction)

Example 24 with RifRecordEvent

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

the class RifFilesProcessor method buildBeneficiaryEvent.

/**
 * @param fileEvent the {@link RifFileEvent} being processed
 * @param csvRecords the {@link CSVRecord} to be mapped (in a single-element {@link List}), which
 *     must be from a {@link RifFileType#BENEFICIARY} {@link RifFile}
 * @return a {@link RifRecordEvent} built from the specified {@link CSVRecord}s
 */
private static RifRecordEvent<Beneficiary> buildBeneficiaryEvent(RifFileEvent fileEvent, List<CSVRecord> csvRecords) {
    if (csvRecords.size() != 1)
        throw new BadCodeMonkeyException();
    CSVRecord csvRecord = csvRecords.get(0);
    if (LOGGER.isTraceEnabled())
        LOGGER.trace(csvRecord.toString());
    RecordAction recordAction = RecordAction.match(csvRecord.get("DML_IND"));
    Beneficiary beneficiaryRow = BeneficiaryParser.parseRif(csvRecords);
    // Swap the unhashed HICN into the correct field.
    beneficiaryRow.setHicnUnhashed(Optional.ofNullable(beneficiaryRow.getHicn()));
    beneficiaryRow.setHicn(null);
    return new RifRecordEvent<Beneficiary>(fileEvent, csvRecords, recordAction, beneficiaryRow.getBeneficiaryId(), beneficiaryRow);
}
Also used : BadCodeMonkeyException(gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException) RifRecordEvent(gov.cms.bfd.model.rif.RifRecordEvent) CSVRecord(org.apache.commons.csv.CSVRecord) RecordAction(gov.cms.bfd.model.rif.RecordAction) Beneficiary(gov.cms.bfd.model.rif.Beneficiary)

Example 25 with RifRecordEvent

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

the class RifFilesProcessor method buildMedicareBeneficiaryIdHistoryEvent.

/**
 * @param fileEvent the {@link RifFileEvent} being processed
 * @param csvRecords the {@link CSVRecord} to be mapped (in a single-element {@link List}), which
 *     must be from a {@link RifFileType#Medicare_Beneficiary_Id_History} {@link RifFile}
 * @return a {@link RifRecordEvent} built from the specified {@link CSVRecord}s
 */
private static RifRecordEvent<MedicareBeneficiaryIdHistory> buildMedicareBeneficiaryIdHistoryEvent(RifFileEvent fileEvent, List<CSVRecord> csvRecords) {
    if (csvRecords.size() != 1)
        throw new BadCodeMonkeyException();
    CSVRecord csvRecord = csvRecords.get(0);
    if (LOGGER.isTraceEnabled())
        LOGGER.trace(csvRecord.toString());
    RecordAction recordAction = RecordAction.INSERT;
    MedicareBeneficiaryIdHistory medicareBeneficiaryIdHistoryRow = MedicareBeneficiaryIdHistoryParser.parseRif(csvRecords);
    return new RifRecordEvent<MedicareBeneficiaryIdHistory>(fileEvent, csvRecords, recordAction, medicareBeneficiaryIdHistoryRow.getBeneficiaryId().get(), medicareBeneficiaryIdHistoryRow);
}
Also used : BadCodeMonkeyException(gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException) RifRecordEvent(gov.cms.bfd.model.rif.RifRecordEvent) CSVRecord(org.apache.commons.csv.CSVRecord) RecordAction(gov.cms.bfd.model.rif.RecordAction) MedicareBeneficiaryIdHistory(gov.cms.bfd.model.rif.MedicareBeneficiaryIdHistory)

Aggregations

RifRecordEvent (gov.cms.bfd.model.rif.RifRecordEvent)27 RifFileRecords (gov.cms.bfd.model.rif.RifFileRecords)16 RifFilesEvent (gov.cms.bfd.model.rif.RifFilesEvent)15 CSVRecord (org.apache.commons.csv.CSVRecord)14 RecordAction (gov.cms.bfd.model.rif.RecordAction)13 Test (org.junit.jupiter.api.Test)13 BigDecimal (java.math.BigDecimal)11 Beneficiary (gov.cms.bfd.model.rif.Beneficiary)6 BadCodeMonkeyException (gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException)6 BeneficiaryHistory (gov.cms.bfd.model.rif.BeneficiaryHistory)5 CarrierClaim (gov.cms.bfd.model.rif.CarrierClaim)5 CarrierClaimLine (gov.cms.bfd.model.rif.CarrierClaimLine)4 RifFileEvent (gov.cms.bfd.model.rif.RifFileEvent)4 IOException (java.io.IOException)4 List (java.util.List)4 BeneficiaryMonthly (gov.cms.bfd.model.rif.BeneficiaryMonthly)3 LoadedBatch (gov.cms.bfd.model.rif.LoadedBatch)3 LoadedFile (gov.cms.bfd.model.rif.LoadedFile)3 RifFileType (gov.cms.bfd.model.rif.RifFileType)3 SkippedRifRecord (gov.cms.bfd.model.rif.SkippedRifRecord)3