use of gov.cms.bfd.model.rif.RifRecordEvent in project beneficiary-fhir-data by CMSgov.
the class RifFilesProcessor method buildBeneficiaryHistoryEvent.
/**
* @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_HISTORY} {@link RifFile}
* @return a {@link RifRecordEvent} built from the specified {@link CSVRecord}s
*/
private static RifRecordEvent<BeneficiaryHistory> buildBeneficiaryHistoryEvent(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"));
BeneficiaryHistory beneficiaryHistoryRow = BeneficiaryHistoryParser.parseRif(csvRecords);
return new RifRecordEvent<BeneficiaryHistory>(fileEvent, csvRecords, recordAction, beneficiaryHistoryRow.getBeneficiaryId(), beneficiaryHistoryRow);
}
use of gov.cms.bfd.model.rif.RifRecordEvent in project beneficiary-fhir-data by CMSgov.
the class RifFilesProcessor method buildHospiceClaimEvent.
/**
* @param fileEvent the {@link RifFileEvent} being processed
* @param csvRecords the {@link CSVRecord}s to be mapped, which must be from a {@link
* RifFileType#HOSPICE} {@link RifFile}
* @return a {@link RifRecordEvent} built from the specified {@link CSVRecord}s
*/
private static RifRecordEvent<HospiceClaim> buildHospiceClaimEvent(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"));
HospiceClaim claim = HospiceClaimParser.parseRif(csvRecords);
return new RifRecordEvent<HospiceClaim>(fileEvent, csvRecords, recordAction, claim.getBeneficiaryId(), claim);
}
use of gov.cms.bfd.model.rif.RifRecordEvent in project beneficiary-fhir-data by CMSgov.
the class RifFilesProcessorTest method processBeneficiaryHistoryRecord_SAMPLE_A.
/**
* Ensures that {@link RifFilesProcessor} can correctly handle {@link
* StaticRifResource#SAMPLE_A_BENEFICIARY_HISTORY}.
*/
@Test
public void processBeneficiaryHistoryRecord_SAMPLE_A() {
RifFilesEvent filesEvent = new RifFilesEvent(Instant.now(), StaticRifResource.SAMPLE_A_BENEFICIARY_HISTORY.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_BENEFICIARY_HISTORY.getRecordCount(), rifEventsList.size());
RifRecordEvent<?> rifRecordEvent0 = rifEventsList.get(0);
assertEquals(StaticRifResource.SAMPLE_A_BENEFICIARY_HISTORY.getRifFileType(), rifRecordEvent0.getFileEvent().getFile().getFileType());
assertNotNull(rifRecordEvent0.getRecord());
assertTrue(rifRecordEvent0.getRecord() instanceof BeneficiaryHistory);
BeneficiaryHistory beneficiaryHistory0 = (BeneficiaryHistory) rifRecordEvent0.getRecord();
assertEquals(beneficiaryHistory0.getBeneficiaryId(), rifRecordEvent0.getBeneficiaryId());
assertEquals(RecordAction.INSERT, rifRecordEvent0.getRecordAction());
assertEquals("567834", beneficiaryHistory0.getBeneficiaryId());
assertEquals(LocalDate.of(1979, Month.MARCH, 17), beneficiaryHistory0.getBirthDate());
assertEquals(('2'), beneficiaryHistory0.getSex());
assertEquals("543217066Z", beneficiaryHistory0.getHicn());
assertEquals(Optional.of("3456689"), beneficiaryHistory0.getMedicareBeneficiaryId());
assertEquals(LocalDate.of(1990, Month.MARCH, 17), beneficiaryHistory0.getMbiEffectiveDate().get());
assertEquals(LocalDate.of(1995, Month.MARCH, 17), beneficiaryHistory0.getMbiObsoleteDate().get());
/*
* We should expect and be able to cope with BENEFICIARY_HISTORY records that
* are exact duplicates.
*/
for (RifRecordEvent<?> rifRecordEvent : new RifRecordEvent<?>[] { rifEventsList.get(1), rifEventsList.get(2) }) {
assertEquals(StaticRifResource.SAMPLE_A_BENEFICIARY_HISTORY.getRifFileType(), rifRecordEvent.getFileEvent().getFile().getFileType());
assertNotNull(rifRecordEvent.getRecord());
assertTrue(rifRecordEvent.getRecord() instanceof BeneficiaryHistory);
BeneficiaryHistory beneficiaryHistory = (BeneficiaryHistory) rifRecordEvent.getRecord();
assertEquals(RecordAction.INSERT, rifRecordEvent.getRecordAction());
assertEquals("567834", beneficiaryHistory.getBeneficiaryId());
assertEquals(LocalDate.of(1980, Month.MARCH, 17), beneficiaryHistory.getBirthDate());
assertEquals(('1'), beneficiaryHistory.getSex());
assertEquals("543217066T", beneficiaryHistory.getHicn());
assertEquals(Optional.of("3456789"), beneficiaryHistory.getMedicareBeneficiaryId());
assertEquals(LocalDate.of(1990, Month.MARCH, 17), beneficiaryHistory0.getMbiEffectiveDate().get());
assertEquals(LocalDate.of(1995, Month.MARCH, 17), beneficiaryHistory0.getMbiObsoleteDate().get());
}
}
use of gov.cms.bfd.model.rif.RifRecordEvent in project beneficiary-fhir-data by CMSgov.
the class RifFilesProcessorTest method process1MedicareBeneficiaryIdHistoryRecord.
/**
* Ensures that {@link RifFilesProcessor} can correctly handle {@link
* StaticRifResource#SAMPLE_A_MEDICARE_BENEFICIARY_ID_HISTORY}.
*/
@Test
public void process1MedicareBeneficiaryIdHistoryRecord() {
RifFilesEvent filesEvent = new RifFilesEvent(Instant.now(), StaticRifResource.SAMPLE_A_MEDICARE_BENEFICIARY_ID_HISTORY.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_MEDICARE_BENEFICIARY_ID_HISTORY.getRecordCount(), rifEventsList.size());
RifRecordEvent<?> rifRecordEvent0 = rifEventsList.get(0);
assertEquals(StaticRifResource.SAMPLE_A_MEDICARE_BENEFICIARY_ID_HISTORY.getRifFileType(), rifRecordEvent0.getFileEvent().getFile().getFileType());
assertNotNull(rifRecordEvent0.getRecord());
assertTrue(rifRecordEvent0.getRecord() instanceof MedicareBeneficiaryIdHistory);
MedicareBeneficiaryIdHistory medicareBeneficiaryIdHistory = (MedicareBeneficiaryIdHistory) rifRecordEvent0.getRecord();
assertEquals("567834", medicareBeneficiaryIdHistory.getBeneficiaryId().get());
assertEquals(LocalDate.of(2011, Month.APRIL, 16), medicareBeneficiaryIdHistory.getMbiEffectiveDate().get());
assertEquals("9AB2WW3GR44", medicareBeneficiaryIdHistory.getMedicareBeneficiaryId().get());
}
use of gov.cms.bfd.model.rif.RifRecordEvent in project beneficiary-fhir-data by CMSgov.
the class RifFilesProcessorTest method process1BeneRecord.
/**
* Ensures that {@link RifFilesProcessor} can correctly handle {@link
* StaticRifResource#SAMPLE_A_BENES}.
*/
@Test
public void process1BeneRecord() {
RifFilesEvent filesEvent = new RifFilesEvent(Instant.now(), StaticRifResource.SAMPLE_A_BENES.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.getRecordCount(), rifEventsList.size());
RifRecordEvent<?> rifRecordEvent = rifEventsList.get(0);
assertEquals(StaticRifResource.SAMPLE_A_BENES.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("567834", beneRow.getBeneficiaryId());
assertEquals("MO", beneRow.getStateCode());
assertEquals("123", beneRow.getCountyCode());
assertEquals("12345", beneRow.getPostalCode());
assertEquals(LocalDate.of(1981, Month.MARCH, 17), beneRow.getBirthDate());
assertEquals(('1'), beneRow.getSex());
assertEquals(new Character('1'), beneRow.getRace().get());
assertEquals(new Character('1'), beneRow.getEntitlementCodeOriginal().get());
assertEquals(new Character('1'), beneRow.getEntitlementCodeCurrent().get());
assertEquals(new Character('N'), beneRow.getEndStageRenalDiseaseCode().get());
assertEquals(new String("20"), beneRow.getMedicareEnrollmentStatusCode().get());
assertEquals(new Character('0'), beneRow.getPartBTerminationCode().get());
assertEquals(new Character('0'), beneRow.getPartBTerminationCode().get());
assertEquals("543217066U", beneRow.getHicnUnhashed().orElse(null));
assertEquals("Doe", beneRow.getNameSurname());
assertEquals("John", beneRow.getNameGiven());
assertEquals(new Character('A'), beneRow.getNameMiddleInitial().get());
assertEquals("3456789", beneRow.getMedicareBeneficiaryId().get());
assertEquals(LocalDate.of(1981, Month.MARCH, 17), beneRow.getBeneficiaryDateOfDeath().get());
assertEquals(LocalDate.of(1963, Month.OCTOBER, 3), beneRow.getMedicareCoverageStartDate().get());
assertEquals(new Character('1'), beneRow.getHmoIndicatorAprInd().get());
assertEquals(new BigDecimal(5), beneRow.getPartDMonthsCount().get());
assertEquals("00", beneRow.getPartDLowIncomeCostShareGroupFebCode().get());
assertEquals(new Character('N'), beneRow.getPartDRetireeDrugSubsidyDecInd().get());
assertEquals("204 SOUTH ST", beneRow.getDerivedMailingAddress1().get());
assertEquals("7560 123TH ST", beneRow.getDerivedMailingAddress2().get());
assertEquals("SURREY", beneRow.getDerivedMailingAddress3().get());
assertEquals("DAEJEON SI 34867", beneRow.getDerivedMailingAddress4().get());
assertEquals("COLOMBIA", beneRow.getDerivedMailingAddress5().get());
assertEquals("SURREY", beneRow.getDerivedMailingAddress6().get());
assertEquals("PODUNK", beneRow.getDerivedCityName().get());
assertEquals("IA", beneRow.getDerivedStateCode().get());
assertEquals("123456789", beneRow.getDerivedZipCode().get());
assertEquals(LocalDate.of(2020, Month.JULY, 30), beneRow.getMbiEffectiveDate().get());
assertEquals(new BigDecimal("1"), beneRow.getBeneLinkKey().get());
}
Aggregations