Search in sources :

Example 76 with Claim

use of org.hl7.fhir.r4.model.Claim 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);
}
Also used : Arrays(java.util.Arrays) Date(java.util.Date) Constants(ca.uhn.fhir.rest.api.Constants) BenefitComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.BenefitComponent) InpatientClaim(gov.cms.bfd.model.rif.InpatientClaim) DateTimeDt(ca.uhn.fhir.model.primitive.DateTimeDt) Stu3EobSamhsaMatcherTest(gov.cms.bfd.server.war.stu3.providers.Stu3EobSamhsaMatcherTest) PartDEvent(gov.cms.bfd.model.rif.PartDEvent) SNFClaim(gov.cms.bfd.model.rif.SNFClaim) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) DateRangeParam(ca.uhn.fhir.rest.param.DateRangeParam) ItemComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.ItemComponent) BeforeAll(org.junit.jupiter.api.BeforeAll) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) SupportingInformationComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.SupportingInformationComponent) BeneficiaryHistory(gov.cms.bfd.model.rif.BeneficiaryHistory) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) Triple(org.apache.commons.lang3.tuple.Triple) OutpatientClaim(gov.cms.bfd.model.rif.OutpatientClaim) IdDt(ca.uhn.fhir.model.primitive.IdDt) InvalidRequestException(ca.uhn.fhir.rest.server.exceptions.InvalidRequestException) BenefitBalanceComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.BenefitBalanceComponent) Resource(org.hl7.fhir.r4.model.Resource) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) ExplanationOfBenefitResourceProvider(gov.cms.bfd.server.war.stu3.providers.ExplanationOfBenefitResourceProvider) Test(org.junit.jupiter.api.Test) Beneficiary(gov.cms.bfd.model.rif.Beneficiary) List(java.util.List) TransformerConstants(gov.cms.bfd.server.war.commons.TransformerConstants) EntityManagerFactory(javax.persistence.EntityManagerFactory) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) CarrierClaim(gov.cms.bfd.model.rif.CarrierClaim) Optional(java.util.Optional) Extension(org.hl7.fhir.r4.model.Extension) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) RequestHeaders(gov.cms.bfd.server.war.commons.RequestHeaders) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) Money(org.hl7.fhir.r4.model.Money) ArrayList(java.util.ArrayList) HHAClaim(gov.cms.bfd.model.rif.HHAClaim) PipelineTestUtils(gov.cms.bfd.pipeline.sharedutils.PipelineTestUtils) ImmutableList(com.google.common.collect.ImmutableList) DMEClaim(gov.cms.bfd.model.rif.DMEClaim) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) StaticRifResourceGroup(gov.cms.bfd.model.rif.samples.StaticRifResourceGroup) ServerTestUtils(gov.cms.bfd.server.war.ServerTestUtils) StringClientParam(ca.uhn.fhir.rest.gclient.StringClientParam) CommonHeaders(gov.cms.bfd.server.war.commons.CommonHeaders) ImmutableTriple(org.apache.commons.lang3.tuple.ImmutableTriple) TokenClientParam(ca.uhn.fhir.rest.gclient.TokenClientParam) HospiceClaim(gov.cms.bfd.model.rif.HospiceClaim) EntityManager(javax.persistence.EntityManager) MedicareBeneficiaryIdHistory(gov.cms.bfd.model.rif.MedicareBeneficiaryIdHistory) AdjudicationComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.AdjudicationComponent) AfterEach(org.junit.jupiter.api.AfterEach) ChronoUnit(java.time.temporal.ChronoUnit) ExplanationOfBenefit(org.hl7.fhir.r4.model.ExplanationOfBenefit) FHIRException(org.hl7.fhir.exceptions.FHIRException) Bundle(org.hl7.fhir.r4.model.Bundle) TotalComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.TotalComponent) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) HospiceClaim(gov.cms.bfd.model.rif.HospiceClaim) ExplanationOfBenefit(org.hl7.fhir.r4.model.ExplanationOfBenefit) Stu3EobSamhsaMatcherTest(gov.cms.bfd.server.war.stu3.providers.Stu3EobSamhsaMatcherTest) Test(org.junit.jupiter.api.Test)

Example 77 with Claim

use of org.hl7.fhir.r4.model.Claim in project beneficiary-fhir-data by CMSgov.

the class R4ClaimResourceProviderIT method shouldGetCorrectMcsClaimResourceById.

@Test
public void shouldGetCorrectMcsClaimResourceById() {
    IGenericClient fhirClient = ServerTestUtils.get().createFhirClientV2();
    Claim claimResult = fhirClient.read().resource(Claim.class).withId("m-654321").execute();
    String expected = testUtils.expectedResponseFor("claimMcsRead");
    String actual = FhirContext.forR4().newJsonParser().encodeResourceToString(claimResult);
    AssertUtils.assertJsonEquals(expected, actual, IGNORE_PATTERNS);
}
Also used : IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) Claim(org.hl7.fhir.r4.model.Claim) Test(org.junit.jupiter.api.Test)

Example 78 with Claim

use of org.hl7.fhir.r4.model.Claim in project beneficiary-fhir-data by CMSgov.

the class ExplanationOfBenefitResourceProviderIT method searchForSamhsaEobsWithExcludeSamhsaFalse.

/**
 * Verifies that {@link ExplanationOfBenefitResourceProvider#findByPatient} with <code>
 * excludeSAMHSA=false</code> does not filter out SAMHSA-related claims.
 *
 * @throws FHIRException (indicates test failure)
 */
@Test
public void searchForSamhsaEobsWithExcludeSamhsaFalse() throws FHIRException {
    Beneficiary beneficiary = loadSampleAWithSamhsa();
    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("false")).returnBundle(Bundle.class).execute();
    assertNotNull(searchResults);
    for (ClaimType claimType : ClaimType.values()) {
        // Without filtering we expect one claim for each claim type.
        assertEquals(1, filterToClaimType(searchResults, claimType).size());
    }
}
Also used : StringClientParam(ca.uhn.fhir.rest.gclient.StringClientParam) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) Bundle(org.hl7.fhir.dstu3.model.Bundle) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) Beneficiary(gov.cms.bfd.model.rif.Beneficiary) Test(org.junit.jupiter.api.Test)

Example 79 with Claim

use of org.hl7.fhir.r4.model.Claim 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));
    }
}
Also used : StringClientParam(ca.uhn.fhir.rest.gclient.StringClientParam) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) Bundle(org.hl7.fhir.dstu3.model.Bundle) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) Beneficiary(gov.cms.bfd.model.rif.Beneficiary) Test(org.junit.jupiter.api.Test)

Example 80 with Claim

use of org.hl7.fhir.r4.model.Claim 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));
}
Also used : Arrays(java.util.Arrays) Bundle(org.hl7.fhir.dstu3.model.Bundle) Date(java.util.Date) Constants(ca.uhn.fhir.rest.api.Constants) InpatientClaim(gov.cms.bfd.model.rif.InpatientClaim) DateTimeDt(ca.uhn.fhir.model.primitive.DateTimeDt) PartDEvent(gov.cms.bfd.model.rif.PartDEvent) SNFClaim(gov.cms.bfd.model.rif.SNFClaim) DateRangeParam(ca.uhn.fhir.rest.param.DateRangeParam) BeforeAll(org.junit.jupiter.api.BeforeAll) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) BeneficiaryHistory(gov.cms.bfd.model.rif.BeneficiaryHistory) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) Triple(org.apache.commons.lang3.tuple.Triple) OutpatientClaim(gov.cms.bfd.model.rif.OutpatientClaim) IdDt(ca.uhn.fhir.model.primitive.IdDt) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) InvalidRequestException(ca.uhn.fhir.rest.server.exceptions.InvalidRequestException) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) Beneficiary(gov.cms.bfd.model.rif.Beneficiary) List(java.util.List) TransformerConstants(gov.cms.bfd.server.war.commons.TransformerConstants) EntityManagerFactory(javax.persistence.EntityManagerFactory) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) CarrierClaim(gov.cms.bfd.model.rif.CarrierClaim) Optional(java.util.Optional) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) RequestHeaders(gov.cms.bfd.server.war.commons.RequestHeaders) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) ArrayList(java.util.ArrayList) HHAClaim(gov.cms.bfd.model.rif.HHAClaim) PipelineTestUtils(gov.cms.bfd.pipeline.sharedutils.PipelineTestUtils) RequestDetails(ca.uhn.fhir.rest.api.server.RequestDetails) ImmutableList(com.google.common.collect.ImmutableList) ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) DMEClaim(gov.cms.bfd.model.rif.DMEClaim) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) StaticRifResourceGroup(gov.cms.bfd.model.rif.samples.StaticRifResourceGroup) ServerTestUtils(gov.cms.bfd.server.war.ServerTestUtils) StringClientParam(ca.uhn.fhir.rest.gclient.StringClientParam) CommonHeaders(gov.cms.bfd.server.war.commons.CommonHeaders) ImmutableTriple(org.apache.commons.lang3.tuple.ImmutableTriple) TokenClientParam(ca.uhn.fhir.rest.gclient.TokenClientParam) HospiceClaim(gov.cms.bfd.model.rif.HospiceClaim) EntityManager(javax.persistence.EntityManager) MedicareBeneficiaryIdHistory(gov.cms.bfd.model.rif.MedicareBeneficiaryIdHistory) AfterEach(org.junit.jupiter.api.AfterEach) ChronoUnit(java.time.temporal.ChronoUnit) Patient(org.hl7.fhir.dstu3.model.Patient) FHIRException(org.hl7.fhir.exceptions.FHIRException) BeneficiaryHistory(gov.cms.bfd.model.rif.BeneficiaryHistory) InpatientClaim(gov.cms.bfd.model.rif.InpatientClaim) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) Bundle(org.hl7.fhir.dstu3.model.Bundle) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) OutpatientClaim(gov.cms.bfd.model.rif.OutpatientClaim) CarrierClaim(gov.cms.bfd.model.rif.CarrierClaim) MedicareBeneficiaryIdHistory(gov.cms.bfd.model.rif.MedicareBeneficiaryIdHistory) SNFClaim(gov.cms.bfd.model.rif.SNFClaim) PartDEvent(gov.cms.bfd.model.rif.PartDEvent) DMEClaim(gov.cms.bfd.model.rif.DMEClaim) HHAClaim(gov.cms.bfd.model.rif.HHAClaim) HospiceClaim(gov.cms.bfd.model.rif.HospiceClaim) Beneficiary(gov.cms.bfd.model.rif.Beneficiary) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)149 Coding (org.hl7.fhir.r4.model.Coding)92 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)62 Money (org.hl7.fhir.r4.model.Money)61 BenefitComponent (org.hl7.fhir.r4.model.ExplanationOfBenefit.BenefitComponent)56 Optional (java.util.Optional)50 Arrays (java.util.Arrays)49 List (java.util.List)49 ExplanationOfBenefit (org.hl7.fhir.r4.model.ExplanationOfBenefit)49 FHIRException (org.hl7.fhir.exceptions.FHIRException)48 SupportingInformationComponent (org.hl7.fhir.r4.model.ExplanationOfBenefit.SupportingInformationComponent)48 ExplanationOfBenefit (org.hl7.fhir.dstu3.model.ExplanationOfBenefit)47 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)47 StaticRifResourceGroup (gov.cms.bfd.model.rif.samples.StaticRifResourceGroup)45 ServerTestUtils (gov.cms.bfd.server.war.ServerTestUtils)45 TransformerConstants (gov.cms.bfd.server.war.commons.TransformerConstants)41 Instant (java.time.Instant)40 ArrayList (java.util.ArrayList)39 IGenericClient (ca.uhn.fhir.rest.client.api.IGenericClient)37 Beneficiary (gov.cms.bfd.model.rif.Beneficiary)37