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());
}
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);
}
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);
}
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);
}
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);
}
Aggregations