use of org.hl7.fhir.dstu2016may.model.Bundle in project beneficiary-fhir-data by CMSgov.
the class ExplanationOfBenefitResourceProviderIT method searchForEobsIncludeTaxNumbersHandling.
/**
* Verifies that {@link ExplanationOfBenefitResourceProvider#findByPatient(ReferenceParam,
* TokenAndListParam, String, String, DateRangeParam, DateRangeParam, RequestDetails)} handles the
* {@link ExplanationOfBenefitResourceProvider#HEADER_NAME_INCLUDE_TAX_NUMBERS} header properly.
*
* @throws FHIRException (indicates test failure)
*/
@Test
public void searchForEobsIncludeTaxNumbersHandling() 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();
CarrierClaim carrierClaim = loadedRecords.stream().filter(r -> r instanceof CarrierClaim).map(r -> (CarrierClaim) r).findFirst().get();
DMEClaim dmeClaim = loadedRecords.stream().filter(r -> r instanceof DMEClaim).map(r -> (DMEClaim) r).findFirst().get();
Bundle searchResults;
ExplanationOfBenefit carrierEob;
ExplanationOfBenefit dmeEob;
// Run the search without requesting tax numbers.
searchResults = fhirClient.search().forResource(ExplanationOfBenefit.class).where(ExplanationOfBenefit.PATIENT.hasId(TransformerUtils.buildPatientId(beneficiary))).returnBundle(Bundle.class).execute();
assertNotNull(searchResults);
// Verify that tax numbers aren't present for carrier claims.
carrierEob = filterToClaimType(searchResults, ClaimType.CARRIER).get(0);
assertNull(TransformerTestUtils.findCareTeamEntryForProviderTaxNumber(carrierClaim.getLines().get(0).getProviderTaxNumber(), carrierEob.getCareTeam()));
// Verify that tax numbers aren't present for DME claims.
dmeEob = filterToClaimType(searchResults, ClaimType.DME).get(0);
assertNull(TransformerTestUtils.findCareTeamEntryForProviderTaxNumber(dmeClaim.getLines().get(0).getProviderTaxNumber(), dmeEob.getCareTeam()));
RequestHeaders requestHeader = RequestHeaders.getHeaderWrapper(CommonHeaders.HEADER_NAME_INCLUDE_TAX_NUMBERS, "true");
fhirClient = ServerTestUtils.get().createFhirClientWithHeaders(requestHeader);
searchResults = fhirClient.search().forResource(ExplanationOfBenefit.class).where(ExplanationOfBenefit.PATIENT.hasId(TransformerUtils.buildPatientId(beneficiary))).returnBundle(Bundle.class).execute();
assertNotNull(searchResults);
// Verify that tax numbers are present for carrier claims.
carrierEob = filterToClaimType(searchResults, ClaimType.CARRIER).get(0);
assertNotNull(TransformerTestUtils.findCareTeamEntryForProviderTaxNumber(carrierClaim.getLines().get(0).getProviderTaxNumber(), carrierEob.getCareTeam()));
// Verify that tax numbers are present for DME claims.
dmeEob = filterToClaimType(searchResults, ClaimType.DME).get(0);
assertNotNull(TransformerTestUtils.findCareTeamEntryForProviderTaxNumber(dmeClaim.getLines().get(0).getProviderTaxNumber(), dmeEob.getCareTeam()));
}
use of org.hl7.fhir.dstu2016may.model.Bundle in project beneficiary-fhir-data by CMSgov.
the class ExplanationOfBenefitResourceProviderIT method searchEobWithNullLastUpdated.
@Test
public void searchEobWithNullLastUpdated() throws FHIRException {
// Load a records and clear the lastUpdated field for one
List<Object> loadedRecords = ServerTestUtils.get().loadData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
String claimId = findFirstCarrierClaim(loadedRecords).getClaimId();
String beneId = findFirstBeneficary(loadedRecords).getBeneficiaryId();
clearCarrierClaimLastUpdated(claimId);
// Find all EOBs without lastUpdated
IGenericClient fhirClient = ServerTestUtils.get().createFhirClient();
Bundle searchAll = fhirClient.search().forResource(ExplanationOfBenefit.class).where(ExplanationOfBenefit.PATIENT.hasId(TransformerUtils.buildPatientId(beneId))).returnBundle(Bundle.class).execute();
assertEquals(Date.from(TransformerConstants.FALLBACK_LAST_UPDATED), filterToClaimType(searchAll, ClaimType.CARRIER).get(0).getMeta().getLastUpdated(), "Expect null lastUpdated fields to map to the FALLBACK_LAST_UPDATED");
// Find all EOBs with < now()
Bundle searchWithLessThan = fhirClient.search().forResource(ExplanationOfBenefit.class).where(ExplanationOfBenefit.PATIENT.hasId(TransformerUtils.buildPatientId(beneId))).lastUpdated(new DateRangeParam().setUpperBoundInclusive(new Date())).returnBundle(Bundle.class).execute();
assertEquals(Date.from(TransformerConstants.FALLBACK_LAST_UPDATED), filterToClaimType(searchWithLessThan, ClaimType.CARRIER).get(0).getMeta().getLastUpdated(), "Expect null lastUpdated fields to map to the FALLBACK_LAST_UPDATED");
assertEquals(searchAll.getTotal(), searchWithLessThan.getTotal(), "Expected the search for lastUpdated <= now() to include resources with fallback lastUpdated values");
// Find all EOBs with >= now()-100 seconds
Bundle searchWithGreaterThan = fhirClient.search().forResource(ExplanationOfBenefit.class).where(ExplanationOfBenefit.PATIENT.hasId(TransformerUtils.buildPatientId(beneId))).lastUpdated(new DateRangeParam().setLowerBoundInclusive(Date.from(Instant.now().minusSeconds(100)))).returnBundle(Bundle.class).execute();
assertEquals(searchAll.getTotal() - 1, searchWithGreaterThan.getTotal(), "Expected the search for lastUpdated >= now()-100 to not include null lastUpdated resources");
}
use of org.hl7.fhir.dstu2016may.model.Bundle in project beneficiary-fhir-data by CMSgov.
the class ExplanationOfBenefitResourceProviderIT method searchForNonSamhsaEobsWithExcludeSamhsaTrue.
/**
* Verifies that {@link ExplanationOfBenefitResourceProvider#findByPatient} with <code>
* excludeSAMHSA=true</code> properly returns claims that are not SAMHSA-related.
*
* @throws FHIRException (indicates test failure)
*/
@Test
public void searchForNonSamhsaEobsWithExcludeSamhsaTrue() throws FHIRException {
// Load the SAMPLE_A resources normally.
Beneficiary beneficiary = loadSampleA();
IGenericClient fhirClient = ServerTestUtils.get().createFhirClient();
Bundle searchResults = fhirClient.search().forResource(ExplanationOfBenefit.class).where(ExplanationOfBenefit.PATIENT.hasId(TransformerUtils.buildPatientId(beneficiary.getBeneficiaryId()))).and(new StringClientParam("excludeSAMHSA").matches().value("true")).returnBundle(Bundle.class).execute();
assertNotNull(searchResults);
for (ClaimType claimType : ClaimType.values()) {
// None of the claims are SAMHSA so we expect one record per claim type in the results.
assertEquals(1, filterToClaimType(searchResults, claimType).size(), String.format("Verify claims of type '%s' are present", claimType));
}
}
use of org.hl7.fhir.dstu2016may.model.Bundle 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 org.hl7.fhir.dstu2016may.model.Bundle in project beneficiary-fhir-data by CMSgov.
the class CoverageResourceProviderIT method searchByMissingBeneficiary.
/**
* Verifies that {@link
* gov.cms.bfd.server.war.stu3.providers.CoverageResourceProvider#searchByBeneficiary(ca.uhn.fhir.rest.param.ReferenceParam)}
* works as expected for a {@link Beneficiary} that does not exist in the DB.
*/
@Test
public void searchByMissingBeneficiary() {
IGenericClient fhirClient = ServerTestUtils.get().createFhirClient();
// No data is loaded, so this should return 0 matches.
Bundle searchResults = fhirClient.search().forResource(Coverage.class).where(Coverage.BENEFICIARY.hasId(TransformerUtils.buildPatientId("1234"))).returnBundle(Bundle.class).execute();
assertNotNull(searchResults);
assertEquals(0, searchResults.getTotal());
}
Aggregations