use of gov.cms.bfd.model.rif.RifRecordEvent in project beneficiary-fhir-data by CMSgov.
the class RifFilesProcessor method buildCarrierClaimEvent.
/**
* @param fileEvent the {@link RifFileEvent} being processed
* @param csvRecords the {@link CSVRecord}s to be mapped, which must be from a {@link
* RifFileType#CARRIER} {@link RifFile}
* @return a {@link RifRecordEvent} built from the specified {@link CSVRecord}s
*/
private static RifRecordEvent<CarrierClaim> buildCarrierClaimEvent(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"));
CarrierClaim claim = CarrierClaimParser.parseRif(csvRecords);
return new RifRecordEvent<CarrierClaim>(fileEvent, csvRecords, recordAction, claim.getBeneficiaryId(), claim);
}
use of gov.cms.bfd.model.rif.RifRecordEvent in project beneficiary-fhir-data by CMSgov.
the class RifLoaderIT method failOnUpdateBeneficiaryBeforeInsert.
/**
* Runs {@link RifLoader} against the {@link StaticRifResourceGroup#SAMPLE_A} data for an <code>
* UPDATE</code> {@link Beneficiary} record that there hasn't been a previous <code>INSERT</code>
* on, to verify that this fails as expected.
*/
@Test
public void failOnUpdateBeneficiaryBeforeInsert() {
// Tweak the SAMPLE_A beneficiary to be an UPDATE.
Stream<RifFile> samplesStream = filterSamples(r -> r.getFileType() == RifFileType.BENEFICIARY, StaticRifResourceGroup.SAMPLE_A.getResources());
Function<RifRecordEvent<?>, List<List<String>>> recordEditor = rifRecordEvent -> {
CSVRecord beneCsvRow = rifRecordEvent.getRawCsvRecords().get(0);
List<String> beneCsvValues = StreamSupport.stream(beneCsvRow.spliterator(), false).collect(Collectors.toList());
beneCsvValues.set(0, "UPDATE");
return List.of(beneCsvValues);
};
Function<RifFile, RifFile> fileEditor = sample -> editSampleRecords(sample, recordEditor);
Stream<RifFile> editedSample = editSamples(samplesStream, fileEditor);
// Load the edited sample to verify that it fails, as expected.
AssertionFailedError thrown = assertThrows(AssertionFailedError.class, () -> {
loadSample("SAMPLE_A, bene only, UPDATE", CcwRifLoadTestUtils.getLoadOptions(), editedSample);
});
assertTrue(thrown.getMessage().contains("Load errors encountered"));
}
Aggregations