use of ca.uhn.fhir.rest.client.api.IGenericClient in project beneficiary-fhir-data by CMSgov.
the class R4ExplanationOfBenefitResourceProviderIT method searchForEobsByExistingPatient.
/**
* 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.
*
* @throws FHIRException (indicates test failure)
*/
@Test
public void searchForEobsByExistingPatient() 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))).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 ca.uhn.fhir.rest.client.api.IGenericClient in project beneficiary-fhir-data by CMSgov.
the class R4ExplanationOfBenefitResourceProviderIT method readEobForMissingOutpatientClaim.
/**
* Verifies that {@link
* gov.cms.bfd.server.war.r4.providers.ExplanationOfBenefitResourceProvider#read(org.hl7.fhir.r4.model.IdType)}
* works as expected for an {@link OutpatientClaim}-derived {@link ExplanationOfBenefit} that does
* not exist in the DB.
*/
@Test
public void readEobForMissingOutpatientClaim() {
IGenericClient fhirClient = ServerTestUtils.get().createFhirClientV2();
assertThrows(ResourceNotFoundException.class, () -> {
// No data is loaded, so this should return nothing.
fhirClient.read().resource(ExplanationOfBenefit.class).withId(TransformerUtilsV2.buildEobId(ClaimTypeV2.OUTPATIENT, "1234")).execute();
});
}
use of ca.uhn.fhir.rest.client.api.IGenericClient in project beneficiary-fhir-data by CMSgov.
the class R4ExplanationOfBenefitResourceProviderIT method readEobForMissingNegativePartDEvent.
/**
* Verifies that {@link
* gov.cms.bfd.server.war.r4.providers.ExplanationOfBenefitResourceProvider#read(org.hl7.fhir.r4.model.IdType)}
* works as expected for a {@link PartDEvent}-derived {@link ExplanationOfBenefit} that does not
* exist in the DB using a negative ID.
*/
@Test
public void readEobForMissingNegativePartDEvent() {
IGenericClient fhirClient = ServerTestUtils.get().createFhirClientV2();
assertThrows(ResourceNotFoundException.class, () -> {
// No data is loaded, so this should return nothing. Tests negative ID will pass regex
// pattern.
fhirClient.read().resource(ExplanationOfBenefit.class).withId(TransformerUtilsV2.buildEobId(ClaimTypeV2.PDE, "-1234")).execute();
});
}
use of ca.uhn.fhir.rest.client.api.IGenericClient in project beneficiary-fhir-data by CMSgov.
the class R4ExplanationOfBenefitResourceProviderIT method readEobForMissingDMEClaim.
/**
* Verifies that {@link
* gov.cms.bfd.server.war.r4.providers.ExplanationOfBenefitResourceProvider#read(org.hl7.fhir.r4.model.IdType)}
* works as expected for a {@link DMEClaim}-derived {@link ExplanationOfBenefit} that does not
* exist in the DB.
*/
@Test
public void readEobForMissingDMEClaim() {
IGenericClient fhirClient = ServerTestUtils.get().createFhirClientV2();
assertThrows(ResourceNotFoundException.class, () -> {
// No data is loaded, so this should return nothing.
fhirClient.read().resource(ExplanationOfBenefit.class).withId(TransformerUtilsV2.buildEobId(ClaimTypeV2.DME, "1234")).execute();
});
}
use of ca.uhn.fhir.rest.client.api.IGenericClient in project beneficiary-fhir-data by CMSgov.
the class R4ExplanationOfBenefitResourceProviderIT method readEobForExistingHospiceClaim.
/**
* Verifies that {@link
* gov.cms.bfd.server.war.r4.providers.ExplanationOfBenefitResourceProvider#read(org.hl7.fhir.r4.model.IdType)}
* works as expected for a {@link HospiceClaim}-derived {@link ExplanationOfBenefit} that does
* exist in the DB.
*
* @throws FHIRException (indicates test failure)
*/
@Test
public void readEobForExistingHospiceClaim() throws FHIRException {
List<Object> loadedRecords = ServerTestUtils.get().loadData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
IGenericClient fhirClient = ServerTestUtils.get().createFhirClientV2();
HospiceClaim claim = loadedRecords.stream().filter(r -> r instanceof HospiceClaim).map(r -> (HospiceClaim) r).findFirst().get();
ExplanationOfBenefit eob = fhirClient.read().resource(ExplanationOfBenefit.class).withId(TransformerUtilsV2.buildEobId(ClaimTypeV2.HOSPICE, claim.getClaimId())).execute();
assertNotNull(eob);
// Compare result to transformed EOB
compareEob(ClaimTypeV2.HOSPICE, eob, loadedRecords);
}
Aggregations