use of gov.cms.bfd.model.rif.BeneficiaryHistory in project beneficiary-fhir-data by CMSgov.
the class R4ExplanationOfBenefitResourceProviderIT method searchForEobsByExistingPatientWithPageSizeZero.
/**
* Verifies that {@link
* gov.cms.bfd.server.war.r4.providers.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().createFhirClientV2();
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(TransformerUtilsV2.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.
*/
assertEachEob(searchResults, loadedRecords);
}
use of gov.cms.bfd.model.rif.BeneficiaryHistory in project beneficiary-fhir-data by CMSgov.
the class R4ExplanationOfBenefitResourceProviderIT method searchForEobsWithLargePageSizesOnFewerResults.
/**
* Verifies that {@link
* gov.cms.bfd.server.war.r4.providers.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().createFhirClientV2();
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(TransformerUtilsV2.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.
*/
assertEachEob(searchResults, loadedRecords);
}
use of gov.cms.bfd.model.rif.BeneficiaryHistory in project beneficiary-fhir-data by CMSgov.
the class R4PatientResourceProviderIT method readExistingPatientWithNoHistoryIncludeIdentifiersTrue.
/**
* Verifies that {@link
* gov.cms.bfd.server.war.r4.providers.R4PatientResourceProvider#read(org.hl7.fhir.r4.model.IdType)}
* works as expected for a {@link Patient} that does exist in the DB but has no {@link
* BeneficiaryHistory} or {@link MedicareBeneficiaryIdHistory} records when include identifiers
* value = ["true"].
*/
@Test
public void readExistingPatientWithNoHistoryIncludeIdentifiersTrue() {
List<Object> loadedRecords = ServerTestUtils.get().loadData(Arrays.asList(StaticRifResource.SAMPLE_A_BENES));
RequestHeaders requestHeader = RequestHeaders.getHeaderWrapper(R4PatientResourceProvider.HEADER_NAME_INCLUDE_IDENTIFIERS, "true", R4PatientResourceProvider.HEADER_NAME_INCLUDE_ADDRESS_FIELDS, "true");
IGenericClient fhirClient = createFhirClient(requestHeader);
Beneficiary beneficiary = loadedRecords.stream().filter(r -> r instanceof Beneficiary).map(r -> (Beneficiary) r).findFirst().get();
Patient patient = fhirClient.read().resource(Patient.class).withId(beneficiary.getBeneficiaryId()).execute();
comparePatient(beneficiary, patient, requestHeader);
/*
* Ensure the unhashed values for HICN and MBI are present.
*/
Boolean mbiUnhashedPresent = false;
Iterator<Identifier> identifiers = patient.getIdentifier().iterator();
while (identifiers.hasNext()) {
Identifier identifier = identifiers.next();
if (identifier.getSystem().equals(TransformerConstants.CODING_BBAPI_BENE_ID)) {
mbiUnhashedPresent = true;
}
}
assertTrue(mbiUnhashedPresent);
}
use of gov.cms.bfd.model.rif.BeneficiaryHistory in project beneficiary-fhir-data by CMSgov.
the class R4PatientResourceProviderIT method searchForExistingPatientByMbiHashWithBeneDups.
/**
* Verifies that the correct bene id or exception is returned when an MBI points to more than one
* bene id in either the Beneficiaries and/or BeneficiariesHistory table.
*/
@Test
public void searchForExistingPatientByMbiHashWithBeneDups() {
List<Object> loadedRecords = ServerTestUtils.get().loadData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
// load additional Beneficiary and Beneficiary History records for
// testing
loadedRecords.addAll(ServerTestUtils.get().loadData(Arrays.asList(StaticRifResourceGroup.SAMPLE_HICN_MULT_BENES.getResources())));
IGenericClient fhirClient = ServerTestUtils.get().createFhirClientV2();
Stream<Beneficiary> beneficiariesStream = loadedRecords.stream().filter(r -> r instanceof Beneficiary).map(r -> (Beneficiary) r);
List<Beneficiary> beneficiariesList = beneficiariesStream.collect(Collectors.toList());
Stream<BeneficiaryHistory> beneficiariesHistoryStream = loadedRecords.stream().filter(r -> r instanceof BeneficiaryHistory).map(r -> (BeneficiaryHistory) r);
List<BeneficiaryHistory> beneficiariesHistoryList = beneficiariesHistoryStream.collect(Collectors.toList());
boolean useMbiFromBeneficiaryTable;
boolean expectsSingleBeneMatch;
/*
* The following scenario tests when the same mbi is in the
* Beneficiaries table but points to different bene ids.
*/
useMbiFromBeneficiaryTable = true;
expectsSingleBeneMatch = false;
assertPatientByHashTypeMatch(fhirClient, beneficiariesList, beneficiariesHistoryList, "567834", "3456789", useMbiFromBeneficiaryTable, expectsSingleBeneMatch);
/*
* The following scenario tests when only one mbi is in the
* Beneficiaries table.
*/
useMbiFromBeneficiaryTable = true;
expectsSingleBeneMatch = true;
assertPatientByHashTypeMatch(fhirClient, beneficiariesList, beneficiariesHistoryList, "123456NULLREFYR", "3456789N", useMbiFromBeneficiaryTable, expectsSingleBeneMatch);
/*
* The following scenario tests when the same mbi is in the
* Beneficiaries and also in the BeneficiariesHistory table. The bene id
* is different between the tables so the bene record from the
* Beneficiaries table should be used.
*
* bene id=BENE1234 mbi=SAMEMBI rfrnc_yr=2019 should be pulled back.
*/
useMbiFromBeneficiaryTable = true;
expectsSingleBeneMatch = false;
assertPatientByHashTypeMatch(fhirClient, beneficiariesList, beneficiariesHistoryList, "BENE1234", "SAMEMBI", useMbiFromBeneficiaryTable, expectsSingleBeneMatch);
/*
* The following scenario tests when the requested mbi is only in the
* BeneficiariesHistory table. Use the bene id from the
* BeneficiariesHistory table to then read the Beneficiaries table.
*/
useMbiFromBeneficiaryTable = false;
expectsSingleBeneMatch = true;
assertPatientByHashTypeMatch(fhirClient, beneficiariesList, beneficiariesHistoryList, "55555", "HISTMBI", useMbiFromBeneficiaryTable, expectsSingleBeneMatch);
/*
* The following scenario tests when the requested mbi is only in the
* BeneficiariesHistory table but this mbi points to more than one bene
* id in history.
*/
useMbiFromBeneficiaryTable = false;
expectsSingleBeneMatch = false;
assertPatientByHashTypeMatch(fhirClient, beneficiariesList, beneficiariesHistoryList, "66666", "DUPHISTMBI", useMbiFromBeneficiaryTable, expectsSingleBeneMatch);
/*
* The following scenario tests when a mbi is not found in the
* Beneficiaries and BeneficiariesHistory table.
*
*/
Bundle searchResults = fhirClient.search().forResource(Patient.class).where(Patient.IDENTIFIER.exactly().systemAndIdentifier(TransformerConstants.CODING_BBAPI_BENE_MBI_HASH, "notfoundmbi")).returnBundle(Bundle.class).execute();
assertEquals(0, searchResults.getTotal());
}
use of gov.cms.bfd.model.rif.BeneficiaryHistory in project beneficiary-fhir-data by CMSgov.
the class R4PatientResourceProviderIT method searchForExistingPatientByMbiWithNoHistoryIncludeIdentifiersTrue.
/**
* Verifies that {@link
* gov.cms.bfd.server.war.r4.providers.R4PatientResourceProvider#searchByIdentifier(ca.uhn.fhir.rest.param.TokenParam)}
* works as expected for MBIs associated with {@link Beneficiary}s that have <strong>no</strong>
* {@link BeneficiaryHistory} records.
*/
@Test
public void searchForExistingPatientByMbiWithNoHistoryIncludeIdentifiersTrue() {
List<Object> loadedRecords = ServerTestUtils.get().loadData(Arrays.asList(StaticRifResource.SAMPLE_A_BENES));
IGenericClient fhirClient = createFhirClient("true", "true");
loadedRecords.stream().filter(r -> r instanceof Beneficiary).map(r -> (Beneficiary) r).forEach(h -> {
Bundle searchResults = fhirClient.search().forResource(Patient.class).where(Patient.IDENTIFIER.exactly().systemAndIdentifier(TransformerConstants.CODING_BBAPI_BENE_MBI_HASH, h.getMbiHash().get())).returnBundle(Bundle.class).execute();
assertNotNull(searchResults);
assertEquals(1, searchResults.getTotal());
Patient patientFromSearchResult = (Patient) searchResults.getEntry().get(0).getResource();
assertEquals(h.getBeneficiaryId(), patientFromSearchResult.getIdElement().getIdPart());
});
}
Aggregations