use of gov.cms.bfd.model.rif.HospiceClaim 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.HospiceClaim in project beneficiary-fhir-data by CMSgov.
the class EndpointJsonResponseComparatorIT method eobReadHospice.
/**
* @return the results of the {@link
* ExplanationOfBenefitResourceProvider#read(org.hl7.fhir.dstu3.model.IdType)} operation for
* Hospice claims
*/
public static String eobReadHospice() {
List<Object> loadedRecords = ServerTestUtils.get().loadData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
IGenericClient fhirClient = createFhirClientAndSetEncoding();
JsonInterceptor jsonInterceptor = createAndRegisterJsonInterceptor(fhirClient);
HospiceClaim hosClaim = loadedRecords.stream().filter(r -> r instanceof HospiceClaim).map(r -> (HospiceClaim) r).findFirst().get();
fhirClient.read().resource(ExplanationOfBenefit.class).withId(TransformerUtils.buildEobId(ClaimType.HOSPICE, hosClaim.getClaimId())).execute();
return jsonInterceptor.getResponse();
}
use of gov.cms.bfd.model.rif.HospiceClaim in project beneficiary-fhir-data by CMSgov.
the class ExplanationOfBenefitResourceProviderIT method adjustHospiceRecordForSamhsaDiagnosis.
/**
* Adjusts the first Hospice record to support samhsa.
*
* @param loadedRecords the loaded records
* @param entityManager the entity manager
*/
private void adjustHospiceRecordForSamhsaDiagnosis(List<Object> loadedRecords, EntityManager entityManager) {
HospiceClaim hospiceRifRecord = loadedRecords.stream().filter(r -> r instanceof HospiceClaim).map(r -> (HospiceClaim) r).findFirst().get();
entityManager.getTransaction().begin();
hospiceRifRecord = entityManager.find(HospiceClaim.class, hospiceRifRecord.getClaimId());
hospiceRifRecord.setDiagnosis2Code(Optional.of(Stu3EobSamhsaMatcherTest.SAMPLE_SAMHSA_ICD_9_DIAGNOSIS_CODE));
hospiceRifRecord.setDiagnosis2CodeVersion(Optional.of('9'));
entityManager.merge(hospiceRifRecord);
entityManager.getTransaction().commit();
}
use of gov.cms.bfd.model.rif.HospiceClaim in project beneficiary-fhir-data by CMSgov.
the class RifFilesProcessorTest method process1HospiceClaimRecord.
/**
* Ensures that {@link RifFilesProcessor} can correctly handle {@link
* StaticRifResource#SAMPLE_A_HOSPICE}.
*/
@Test
public void process1HospiceClaimRecord() {
RifFilesEvent filesEvent = new RifFilesEvent(Instant.now(), StaticRifResource.SAMPLE_A_HOSPICE.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_HOSPICE.getRecordCount(), rifEventsList.size());
RifRecordEvent<?> rifRecordEvent = rifEventsList.get(0);
assertEquals(StaticRifResource.SAMPLE_A_HOSPICE.getRifFileType(), rifRecordEvent.getFileEvent().getFile().getFileType());
assertNotNull(rifRecordEvent.getRecord());
assertTrue(rifRecordEvent.getRecord() instanceof HospiceClaim);
// Verify the claim header.
HospiceClaim claimGroup = (HospiceClaim) rifRecordEvent.getRecord();
assertEquals(RecordAction.INSERT, rifRecordEvent.getRecordAction());
assertEquals(claimGroup.getBeneficiaryId(), rifRecordEvent.getBeneficiaryId());
assertEquals("567834", claimGroup.getBeneficiaryId());
assertEquals("9992223422", claimGroup.getClaimId());
assertEquals(new BigDecimal(900), claimGroup.getClaimGroupId());
assertEquals('V', claimGroup.getNearLineRecordIdCode());
assertEquals("50", claimGroup.getClaimTypeCode());
assertEquals(LocalDate.of(2014, 1, 01), claimGroup.getDateFrom());
assertEquals(LocalDate.of(2014, 1, 30), claimGroup.getDateThrough());
assertEquals("12345", claimGroup.getProviderNumber());
assertEquals("P", claimGroup.getClaimNonPaymentReasonCode().get());
assertEquals('1', claimGroup.getClaimServiceClassificationTypeCode());
assertEquals(new BigDecimal("130.32"), claimGroup.getPaymentAmount());
assertEquals(new BigDecimal("0"), claimGroup.getPrimaryPayerPaidAmount());
assertEquals("AZ", claimGroup.getProviderStateCode());
assertEquals("999999999", claimGroup.getOrganizationNpi().get());
assertEquals("8888888888", claimGroup.getAttendingPhysicianNpi().get());
assertEquals("30", claimGroup.getPatientDischargeStatusCode());
assertEquals(new BigDecimal("199.99"), claimGroup.getTotalChargeAmount());
assertEquals(new Character('C'), claimGroup.getPatientStatusCd().get());
assertEquals(new BigDecimal(30), claimGroup.getUtilizationDayCount());
assertEquals(LocalDate.of(2015, 6, 29), claimGroup.getBeneficiaryDischargeDate().get());
assertEquals("R5555", claimGroup.getDiagnosisPrincipalCode().get());
assertEquals('9', claimGroup.getDiagnosisPrincipalCodeVersion().get().charValue());
assertEquals(LocalDate.of(2014, 7, 06), claimGroup.getClaimHospiceStartDate().get());
assertEquals("38875439343923937", claimGroup.getFiOriginalClaimControlNumber().get());
assertEquals("2718813985998", claimGroup.getFiDocumentClaimControlNumber().get());
assertEquals(1, claimGroup.getLines().size());
// Verify one of the claim lines.
HospiceClaimLine claimLine = claimGroup.getLines().get(0);
assertEquals(new BigDecimal(1), claimLine.getLineNumber());
assertEquals("651", claimLine.getRevenueCenterCode());
assertEquals(new BigDecimal("26.00"), claimGroup.getLines().get(0).getPaymentAmount());
assertEquals(new BigDecimal("300.00"), claimGroup.getLines().get(0).getNonCoveredChargeAmount().get());
assertEquals("Q9999", claimGroup.getLines().get(0).getHcpcsInitialModifierCode().get());
assertEquals("345345345", claimLine.getRevenueCenterRenderingPhysicianNPI().get());
}
use of gov.cms.bfd.model.rif.HospiceClaim in project beneficiary-fhir-data by CMSgov.
the class ExplanationOfBenefitResourceProviderIT method searchForEobsWithLargePageSizesOnFewerResults.
/**
* Verifies that {@link ExplanationOfBenefitResourceProvider#findByPatient} works as expected for
* a {@link Patient} that does exist in the DB, with a page size of 50 with fewer (8) results.
*
* @throws FHIRException (indicates test failure)
*/
@Test
public void searchForEobsWithLargePageSizesOnFewerResults() 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();
Bundle searchResults = fhirClient.search().forResource(ExplanationOfBenefit.class).where(ExplanationOfBenefit.PATIENT.hasId(TransformerUtils.buildPatientId(beneficiary))).count(50).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 only the first and last links exist as there are no previous or
* next pages.
*/
assertNotNull(searchResults.getLink(Constants.LINK_FIRST));
assertNotNull(searchResults.getLink(Constants.LINK_LAST));
assertNull(searchResults.getLink(Constants.LINK_NEXT));
assertNull(searchResults.getLink(Constants.LINK_PREVIOUS));
/*
* 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));
}
Aggregations