use of ca.uhn.fhir.rest.client.api.IGenericClient in project beneficiary-fhir-data by CMSgov.
the class R4ExplanationOfBenefitResourceProviderIT method readEobForMissingInpatientClaim.
/**
* 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
* not exist in the DB.
*/
@Test
public void readEobForMissingInpatientClaim() {
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.INPATIENT, "1234")).execute();
});
}
use of ca.uhn.fhir.rest.client.api.IGenericClient in project beneficiary-fhir-data by CMSgov.
the class R4ExplanationOfBenefitResourceProviderIT method searchForEobsByExistingPatientAndType.
/**
* Verifies that {@link
* gov.cms.bfd.server.war.r4.providers.ExplanationOfBenefitResourceProvider#findByPatient(ca.uhn.fhir.rest.param.ReferenceParam)}
* works as expected for a {@link Patient} that does exist in the DB, with filtering by claim
* type.
*
* @throws FHIRException (indicates test failure)
*/
@Test
public void searchForEobsByExistingPatientAndType() 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))).where(new TokenClientParam("type").exactly().code(ClaimTypeV2.PDE.name())).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 PartDEvent)).filter(r -> !(r instanceof BeneficiaryHistory)).count(), searchResults.getTotal());
PartDEvent partDEvent = loadedRecords.stream().filter(r -> r instanceof PartDEvent).map(r -> (PartDEvent) r).findFirst().get();
// Compare result to transformed EOB
assertEobEquals(PartDEventTransformerV2.transform(PipelineTestUtils.get().getPipelineApplicationState().getMetrics(), partDEvent, Optional.of(false)), filterToClaimType(searchResults, ClaimTypeV2.PDE).get(0));
}
use of ca.uhn.fhir.rest.client.api.IGenericClient in project beneficiary-fhir-data by CMSgov.
the class R4ExplanationOfBenefitResourceProviderIT method readEobForExistingCarrierClaim.
/**
* Verifies that {@link
* gov.cms.bfd.server.war.r4.providers.ExplanationOfBenefitResourceProvider#read(org.hl7.fhir.r4.model.IdType)}
* works as expected for a {@link CarrierClaim}-derived {@link ExplanationOfBenefit} that does
* exist in the DB.
*
* @throws FHIRException (indicates test failure)
*/
@Test
public void readEobForExistingCarrierClaim() throws FHIRException {
List<Object> loadedRecords = ServerTestUtils.get().loadData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
IGenericClient fhirClient = ServerTestUtils.get().createFhirClientV2();
CarrierClaim claim = loadedRecords.stream().filter(r -> r instanceof CarrierClaim).map(r -> (CarrierClaim) r).findFirst().get();
ExplanationOfBenefit eob = fhirClient.read().resource(ExplanationOfBenefit.class).withId(TransformerUtilsV2.buildEobId(ClaimTypeV2.CARRIER, claim.getClaimId())).execute();
// Compare result to transformed EOB
compareEob(ClaimTypeV2.CARRIER, eob, loadedRecords);
}
use of ca.uhn.fhir.rest.client.api.IGenericClient in project beneficiary-fhir-data by CMSgov.
the class R4ExplanationOfBenefitResourceProviderIT method readEobForExistingHHAClaim.
/**
* Verifies that {@link
* gov.cms.bfd.server.war.r4.providers.ExplanationOfBenefitResourceProvider#read(org.hl7.fhir.r4.model.IdType)}
* works as expected for an {@link HHAClaim}-derived {@link ExplanationOfBenefit} that does exist
* in the DB.
*
* @throws FHIRException (indicates test failure)
*/
@Test
public void readEobForExistingHHAClaim() throws FHIRException {
List<Object> loadedRecords = ServerTestUtils.get().loadData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
IGenericClient fhirClient = ServerTestUtils.get().createFhirClientV2();
HHAClaim claim = loadedRecords.stream().filter(r -> r instanceof HHAClaim).map(r -> (HHAClaim) r).findFirst().get();
ExplanationOfBenefit eob = fhirClient.read().resource(ExplanationOfBenefit.class).withId(TransformerUtilsV2.buildEobId(ClaimTypeV2.HHA, claim.getClaimId())).execute();
assertNotNull(eob);
// Compare result to transformed EOB
compareEob(ClaimTypeV2.HHA, eob, loadedRecords);
}
use of ca.uhn.fhir.rest.client.api.IGenericClient in project beneficiary-fhir-data by CMSgov.
the class R4ExplanationOfBenefitResourceProviderIT method searchForEobsByMissingPatient.
/**
* Verifies that {@link
* gov.cms.bfd.server.war.r4.providers.ExplanationOfBenefitResourceProvider#findByPatient(ca.uhn.fhir.rest.param.ReferenceParam)}
* works as expected for a {@link Patient} that does not exist in the DB.
*/
@Test
public void searchForEobsByMissingPatient() {
IGenericClient fhirClient = ServerTestUtils.get().createFhirClientV2();
// No data is loaded, so this should return 0 matches.
Bundle searchResults = fhirClient.search().forResource(ExplanationOfBenefit.class).where(ExplanationOfBenefit.PATIENT.hasId(new IdDt("Patient", "1234"))).returnBundle(Bundle.class).execute();
assertNotNull(searchResults);
assertEquals(0, searchResults.getTotal());
}
Aggregations