use of gov.cms.bfd.model.rif.InpatientClaim in project beneficiary-fhir-data by CMSgov.
the class R4ExplanationOfBenefitResourceProviderIT method readEobForExistingInpatientClaim.
/**
* Verifies that {@link
* gov.cms.bfd.server.war.r4.providers.ExplanationOfBenefitResourceProvider#read(org.hl7.fhir.r4.model.IdType)}
* works as expected for an {@link InpatientClaim}-derived {@link ExplanationOfBenefit} that does
* exist in the DB.
*
* @throws FHIRException (indicates test failure)
*/
@Test
public void readEobForExistingInpatientClaim() throws FHIRException {
List<Object> loadedRecords = ServerTestUtils.get().loadData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
IGenericClient fhirClient = ServerTestUtils.get().createFhirClientV2();
InpatientClaim claim = loadedRecords.stream().filter(r -> r instanceof InpatientClaim).map(r -> (InpatientClaim) r).findFirst().get();
ExplanationOfBenefit eob = fhirClient.read().resource(ExplanationOfBenefit.class).withId(TransformerUtilsV2.buildEobId(ClaimTypeV2.INPATIENT, claim.getClaimId())).execute();
assertNotNull(eob);
// Compare result to transformed EOB
compareEob(ClaimTypeV2.INPATIENT, eob, loadedRecords);
}
use of gov.cms.bfd.model.rif.InpatientClaim 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.InpatientClaim in project beneficiary-fhir-data by CMSgov.
the class ExplanationOfBenefitResourceProviderIT method adjustInpatientRecordForSamhsaDiagnosis.
/**
* Adjusts the first inpatient record to support samhsa.
*
* @param loadedRecords the loaded records
* @param entityManager the entity manager
*/
private void adjustInpatientRecordForSamhsaDiagnosis(List<Object> loadedRecords, EntityManager entityManager) {
InpatientClaim inpatientRifRecord = loadedRecords.stream().filter(r -> r instanceof InpatientClaim).map(r -> (InpatientClaim) r).findFirst().get();
entityManager.getTransaction().begin();
inpatientRifRecord = entityManager.find(InpatientClaim.class, inpatientRifRecord.getClaimId());
inpatientRifRecord.setDiagnosis2Code(Optional.of(Stu3EobSamhsaMatcherTest.SAMPLE_SAMHSA_ICD_9_DIAGNOSIS_CODE));
inpatientRifRecord.setDiagnosis2CodeVersion(Optional.of('9'));
entityManager.merge(inpatientRifRecord);
entityManager.getTransaction().commit();
}
use of gov.cms.bfd.model.rif.InpatientClaim in project beneficiary-fhir-data by CMSgov.
the class RifFilesProcessorTest method process1InpatientClaimRecord.
/**
* Ensures that {@link RifFilesProcessor} can correctly handle {@link
* StaticRifResource#SAMPLE_A_INPATIENT}.
*/
@Test
public void process1InpatientClaimRecord() {
RifFilesEvent filesEvent = new RifFilesEvent(Instant.now(), StaticRifResource.SAMPLE_A_INPATIENT.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_INPATIENT.getRecordCount(), rifEventsList.size());
RifRecordEvent<?> rifRecordEvent = rifEventsList.get(0);
assertEquals(StaticRifResource.SAMPLE_A_INPATIENT.getRifFileType(), rifRecordEvent.getFileEvent().getFile().getFileType());
assertNotNull(rifRecordEvent.getRecord());
assertTrue(rifRecordEvent.getRecord() instanceof InpatientClaim);
// Verify the claim header.
InpatientClaim claimGroup = (InpatientClaim) rifRecordEvent.getRecord();
assertEquals(RecordAction.INSERT, rifRecordEvent.getRecordAction());
assertEquals(claimGroup.getBeneficiaryId(), rifRecordEvent.getBeneficiaryId());
assertEquals("567834", claimGroup.getBeneficiaryId());
assertEquals("333333222222", claimGroup.getClaimId());
assertEquals(new BigDecimal(900), claimGroup.getClaimGroupId());
assertEquals('V', claimGroup.getNearLineRecordIdCode());
assertEquals("60", claimGroup.getClaimTypeCode());
assertEquals(LocalDate.of(2016, 01, 15), claimGroup.getDateFrom());
assertEquals(LocalDate.of(2016, 01, 27), claimGroup.getDateThrough());
assertEquals('3', claimGroup.getClaimQueryCode());
assertEquals("777776", claimGroup.getProviderNumber());
assertEquals('1', claimGroup.getClaimServiceClassificationTypeCode());
assertTrue(claimGroup.getClaimNonPaymentReasonCode().isPresent());
assertEquals(new BigDecimal("7699.48"), claimGroup.getPaymentAmount());
assertEquals(new BigDecimal("11.00"), claimGroup.getPrimaryPayerPaidAmount());
assertEquals("IA", claimGroup.getProviderStateCode());
assertEquals("5555553305", claimGroup.getOrganizationNpi().get());
assertEquals("161999999", claimGroup.getAttendingPhysicianNpi().get());
assertEquals("3333444555", claimGroup.getOperatingPhysicianNpi().get());
assertEquals("161943433", claimGroup.getOtherPhysicianNpi().get());
assertEquals("51", claimGroup.getPatientDischargeStatusCode());
assertEquals(new BigDecimal("84999.37"), claimGroup.getTotalChargeAmount());
assertEquals(LocalDate.of(2016, 1, 15), claimGroup.getClaimAdmissionDate().get());
assertEquals('1', claimGroup.getAdmissionTypeCd());
assertEquals(new Character('4'), claimGroup.getSourceAdmissionCd().get());
assertEquals(new BigDecimal("10.00"), claimGroup.getPassThruPerDiemAmount());
assertEquals(new BigDecimal("112.00"), claimGroup.getDeductibleAmount());
assertEquals(new BigDecimal("5.00"), claimGroup.getPartACoinsuranceLiabilityAmount());
assertEquals(new BigDecimal("6.00"), claimGroup.getBloodDeductibleLiabilityAmount());
assertEquals(new BigDecimal("4.00"), claimGroup.getProfessionalComponentCharge());
assertEquals(new BigDecimal("33.00"), claimGroup.getNoncoveredCharge());
assertEquals(new BigDecimal("14.00"), claimGroup.getTotalDeductionAmount());
assertEquals(new BigDecimal("646.23"), claimGroup.getClaimTotalPPSCapitalAmount().get());
assertEquals(new BigDecimal("552.56"), claimGroup.getClaimPPSCapitalFSPAmount().get());
assertEquals(new BigDecimal("0"), claimGroup.getClaimPPSCapitalOutlierAmount().get());
assertEquals(new BigDecimal("68.58"), claimGroup.getClaimPPSCapitalIMEAmount().get());
assertEquals(new BigDecimal("0"), claimGroup.getClaimPPSCapitalExceptionAmount().get());
assertEquals(new BigDecimal("0"), claimGroup.getClaimPPSOldCapitalHoldHarmlessAmount().get());
assertEquals(new BigDecimal(12), claimGroup.getUtilizationDayCount());
assertEquals(new BigDecimal(0), claimGroup.getCoinsuranceDayCount());
assertEquals(new BigDecimal(0), claimGroup.getNonUtilizationDayCount());
assertEquals(new BigDecimal(19), claimGroup.getBloodPintsFurnishedQty());
assertEquals(LocalDate.of(2016, 1, 27), claimGroup.getBeneficiaryDischargeDate().get());
assertEquals(new BigDecimal("23.99"), claimGroup.getDrgOutlierApprovedPaymentAmount().get());
assertEquals("R4444", claimGroup.getDiagnosisAdmittingCode().get());
assertEquals('0', claimGroup.getDiagnosisAdmittingCodeVersion().get().charValue());
assertEquals("R5555", claimGroup.getDiagnosisPrincipalCode().get());
assertEquals('0', claimGroup.getDiagnosisPrincipalCodeVersion().get().charValue());
assertEquals("R5555", claimGroup.getDiagnosis1Code().get());
assertEquals('0', claimGroup.getDiagnosis1CodeVersion().get().charValue());
assertEquals('Y', claimGroup.getDiagnosis1PresentOnAdmissionCode().get().charValue());
assertEquals("0TCDDEE", claimGroup.getProcedure1Code().get());
assertEquals('0', claimGroup.getProcedure1CodeVersion().get().charValue());
assertEquals(LocalDate.of(2016, 1, 16), claimGroup.getProcedure1Date().get());
assertEquals(new BigDecimal("120.56"), claimGroup.getClaimUncompensatedCareAmount().get());
assertEquals("28486613848", claimGroup.getFiDocumentClaimControlNumber().get());
assertEquals("261660474641024", claimGroup.getFiOriginalClaimControlNumber().get());
assertEquals(1, claimGroup.getLines().size());
// Verify one of the claim lines.
InpatientClaimLine claimLine = claimGroup.getLines().get(0);
assertEquals(new BigDecimal("84888.88"), claimLine.getTotalChargeAmount());
assertEquals(new BigDecimal("3699.00"), claimLine.getNonCoveredChargeAmount());
assertEquals("345345345", claimLine.getRevenueCenterRenderingPhysicianNPI().get());
}
use of gov.cms.bfd.model.rif.InpatientClaim 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