use of gov.cms.bfd.model.rif.SNFClaim in project beneficiary-fhir-data by CMSgov.
the class SNFClaimTransformer method transform.
/**
* @param metricRegistry the {@link MetricRegistry} to use
* @param claim the CCW {@link SNFClaim} to transform
* @param includeTaxNumbers whether or not to include tax numbers in the result (see {@link
* ExplanationOfBenefitResourceProvider#HEADER_NAME_INCLUDE_TAX_NUMBERS}, defaults to <code>
* false</code>)
* @return a FHIR {@link ExplanationOfBenefit} resource that represents the specified {@link
* SNFClaim}
*/
@Trace
static ExplanationOfBenefit transform(MetricRegistry metricRegistry, Object claim, Optional<Boolean> includeTaxNumbers) {
Timer.Context timer = metricRegistry.timer(MetricRegistry.name(SNFClaimTransformer.class.getSimpleName(), "transform")).time();
if (!(claim instanceof SNFClaim))
throw new BadCodeMonkeyException();
timer.stop();
return transformClaim((SNFClaim) claim);
}
use of gov.cms.bfd.model.rif.SNFClaim in project beneficiary-fhir-data by CMSgov.
the class ClaimTypeV2Test method verifyServiceEndAttributeFunc.
/**
* Verifies that our service end date function is working as expected. Since we are type casting
* our claim object, we need to verify that every ClaimType is tested.
*/
@Test
public void verifyServiceEndAttributeFunc() {
LocalDate start = LocalDate.now();
LocalDate end = start.plusDays(10);
CarrierClaim carrierClaim = new CarrierClaim();
carrierClaim.setDateFrom(start);
carrierClaim.setDateThrough(end);
DMEClaim dmeClaim = new DMEClaim();
dmeClaim.setDateFrom(start);
dmeClaim.setDateThrough(end);
HospiceClaim hospiceClaim = new HospiceClaim();
hospiceClaim.setDateFrom(start);
hospiceClaim.setDateThrough(end);
PartDEvent partDEvent = new PartDEvent();
partDEvent.setPrescriptionFillDate(end);
InpatientClaim inpatientClaim = new InpatientClaim();
inpatientClaim.setDateFrom(start);
inpatientClaim.setDateThrough(end);
OutpatientClaim outpatientClaim = new OutpatientClaim();
outpatientClaim.setDateFrom(start);
outpatientClaim.setDateThrough(end);
SNFClaim snfClaim = new SNFClaim();
snfClaim.setDateFrom(start);
snfClaim.setDateThrough(end);
HHAClaim hhaClaim = new HHAClaim();
hhaClaim.setDateFrom(start);
hhaClaim.setDateThrough(end);
ImmutableMap.Builder<ClaimTypeV2, Object> builder = ImmutableMap.builder();
builder.put(ClaimTypeV2.CARRIER, carrierClaim);
builder.put(ClaimTypeV2.DME, dmeClaim);
builder.put(ClaimTypeV2.PDE, partDEvent);
builder.put(ClaimTypeV2.INPATIENT, inpatientClaim);
builder.put(ClaimTypeV2.OUTPATIENT, outpatientClaim);
builder.put(ClaimTypeV2.HOSPICE, hospiceClaim);
builder.put(ClaimTypeV2.SNF, snfClaim);
builder.put(ClaimTypeV2.HHA, hhaClaim);
Map<ClaimTypeV2, Object> claimTypeToClaim = builder.build();
// Verify that we're testing all of the ClaimTypes that are defined
EnumSet.allOf(ClaimTypeV2.class).stream().forEach(claimType -> assertTrue(claimTypeToClaim.containsKey(claimType), String.format("ClaimType %s not tested", claimType.name())));
claimTypeToClaim.entrySet().forEach(entry -> assertEquals(end, entry.getKey().getServiceEndAttributeFunction().apply(entry.getValue()), String.format("Claim type %s does not match expectations", entry.getKey().name())));
}
use of gov.cms.bfd.model.rif.SNFClaim in project beneficiary-fhir-data by CMSgov.
the class RifFilesProcessor method buildSNFClaimEvent.
/**
* @param fileEvent the {@link RifFileEvent} being processed
* @param csvRecords the {@link CSVRecord}s to be mapped, which must be from a {@link
* RifFileType#SNF} {@link RifFile}
* @return a {@link RifRecordEvent} built from the specified {@link CSVRecord}s
*/
private static RifRecordEvent<SNFClaim> buildSNFClaimEvent(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"));
SNFClaim claim = SNFClaimParser.parseRif(csvRecords);
return new RifRecordEvent<SNFClaim>(fileEvent, csvRecords, recordAction, claim.getBeneficiaryId(), claim);
}
use of gov.cms.bfd.model.rif.SNFClaim in project beneficiary-fhir-data by CMSgov.
the class ExplanationOfBenefitResourceProviderIT method searchForEobsByExistingPatientWithPageSizeZero.
/**
* Verifies that {@link ExplanationOfBenefitResourceProvider#findByPatient} works as expected for
* a {@link Patient} that does exist in the DB, with paging on a page size of 0.
*
* @throws FHIRException (indicates test failure)
*/
@Test
public void searchForEobsByExistingPatientWithPageSizeZero() throws FHIRException {
List<Object> loadedRecords = ServerTestUtils.get().loadData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
IGenericClient fhirClient = ServerTestUtils.get().createFhirClient();
Beneficiary beneficiary = loadedRecords.stream().filter(r -> r instanceof Beneficiary).map(r -> (Beneficiary) r).findFirst().get();
/*
* FIXME: According the the FHIR spec, paging for _count=0 should not return any
* claim entries in the bundle, but instead just a total for the number of
* entries that match the search criteria. This functionality does no work
* currently (see https://github.com/jamesagnew/hapi-fhir/issues/1074) and so
* for now paging with _count=0 should behave as though paging was not
* requested.
*/
Bundle searchResults = fhirClient.search().forResource(ExplanationOfBenefit.class).where(ExplanationOfBenefit.PATIENT.hasId(TransformerUtils.buildPatientId(beneficiary))).count(0).returnBundle(Bundle.class).execute();
assertNotNull(searchResults);
/*
* Verify the bundle contains a key for total and that the value matches the
* number of entries in the bundle
*/
assertEquals(loadedRecords.stream().filter(r -> !(r instanceof Beneficiary)).filter(r -> !(r instanceof BeneficiaryHistory)).filter(r -> !(r instanceof MedicareBeneficiaryIdHistory)).count(), searchResults.getTotal());
/*
* Verify that no paging links exist in the bundle.
*/
assertNull(searchResults.getLink(Constants.LINK_NEXT));
assertNull(searchResults.getLink(Constants.LINK_PREVIOUS));
assertNull(searchResults.getLink(Constants.LINK_FIRST));
assertNull(searchResults.getLink(Constants.LINK_LAST));
/*
* Verify that each of the expected claims (one for every claim type) is present
* and looks correct.
*/
CarrierClaim carrierClaim = loadedRecords.stream().filter(r -> r instanceof CarrierClaim).map(r -> (CarrierClaim) r).findFirst().get();
assertEquals(1, filterToClaimType(searchResults, ClaimType.CARRIER).size());
CarrierClaimTransformerTest.assertMatches(carrierClaim, filterToClaimType(searchResults, ClaimType.CARRIER).get(0), Optional.empty());
DMEClaim dmeClaim = loadedRecords.stream().filter(r -> r instanceof DMEClaim).map(r -> (DMEClaim) r).findFirst().get();
DMEClaimTransformerTest.assertMatches(dmeClaim, filterToClaimType(searchResults, ClaimType.DME).get(0), Optional.empty());
HHAClaim hhaClaim = loadedRecords.stream().filter(r -> r instanceof HHAClaim).map(r -> (HHAClaim) r).findFirst().get();
HHAClaimTransformerTest.assertMatches(hhaClaim, filterToClaimType(searchResults, ClaimType.HHA).get(0));
HospiceClaim hospiceClaim = loadedRecords.stream().filter(r -> r instanceof HospiceClaim).map(r -> (HospiceClaim) r).findFirst().get();
HospiceClaimTransformerTest.assertMatches(hospiceClaim, filterToClaimType(searchResults, ClaimType.HOSPICE).get(0));
InpatientClaim inpatientClaim = loadedRecords.stream().filter(r -> r instanceof InpatientClaim).map(r -> (InpatientClaim) r).findFirst().get();
InpatientClaimTransformerTest.assertMatches(inpatientClaim, filterToClaimType(searchResults, ClaimType.INPATIENT).get(0));
OutpatientClaim outpatientClaim = loadedRecords.stream().filter(r -> r instanceof OutpatientClaim).map(r -> (OutpatientClaim) r).findFirst().get();
OutpatientClaimTransformerTest.assertMatches(outpatientClaim, filterToClaimType(searchResults, ClaimType.OUTPATIENT).get(0));
PartDEvent partDEvent = loadedRecords.stream().filter(r -> r instanceof PartDEvent).map(r -> (PartDEvent) r).findFirst().get();
PartDEventTransformerTest.assertMatches(partDEvent, filterToClaimType(searchResults, ClaimType.PDE).get(0));
SNFClaim snfClaim = loadedRecords.stream().filter(r -> r instanceof SNFClaim).map(r -> (SNFClaim) r).findFirst().get();
SNFClaimTransformerTest.assertMatches(snfClaim, filterToClaimType(searchResults, ClaimType.SNF).get(0));
}
use of gov.cms.bfd.model.rif.SNFClaim in project beneficiary-fhir-data by CMSgov.
the class ExplanationOfBenefitResourceProviderIT method adjustSnfRecordForSamhsaDiagnosis.
/**
* Adjusts the first SNF record to support samhsa.
*
* @param loadedRecords the loaded records
* @param entityManager the entity manager
*/
private void adjustSnfRecordForSamhsaDiagnosis(List<Object> loadedRecords, EntityManager entityManager) {
SNFClaim snfRifRecord = loadedRecords.stream().filter(r -> r instanceof SNFClaim).map(r -> (SNFClaim) r).findFirst().get();
entityManager.getTransaction().begin();
snfRifRecord = entityManager.find(SNFClaim.class, snfRifRecord.getClaimId());
snfRifRecord.setDiagnosis2Code(Optional.of(Stu3EobSamhsaMatcherTest.SAMPLE_SAMHSA_ICD_9_DIAGNOSIS_CODE));
snfRifRecord.setDiagnosis2CodeVersion(Optional.of('9'));
entityManager.merge(snfRifRecord);
entityManager.getTransaction().commit();
}
Aggregations