Search in sources :

Example 11 with InpatientClaim

use of gov.cms.bfd.model.rif.InpatientClaim in project beneficiary-fhir-data by CMSgov.

the class InpatientClaimTransformerTest method transformSampleARecord.

/**
 * Verifies that {@link
 * gov.cms.bfd.server.war.stu3.providers.InpatientClaimTransformer#transform(Object)} works as
 * expected when run against the {@link StaticRifResource#SAMPLE_A_INPATIENT} {@link
 * InpatientClaim}.
 *
 * @throws FHIRException (indicates test failure)
 */
@Test
public void transformSampleARecord() throws FHIRException {
    List<Object> parsedRecords = ServerTestUtils.parseData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
    InpatientClaim claim = parsedRecords.stream().filter(r -> r instanceof InpatientClaim).map(r -> (InpatientClaim) r).findFirst().get();
    claim.setLastUpdated(Instant.now());
    ExplanationOfBenefit eob = InpatientClaimTransformer.transform(new MetricRegistry(), claim, Optional.empty());
    assertMatches(claim, eob);
}
Also used : Arrays(java.util.Arrays) MetricRegistry(com.codahale.metrics.MetricRegistry) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) StaticRifResource(gov.cms.bfd.model.rif.samples.StaticRifResource) MedicareSegment(gov.cms.bfd.server.war.commons.MedicareSegment) ItemComponent(org.hl7.fhir.dstu3.model.ExplanationOfBenefit.ItemComponent) InpatientClaim(gov.cms.bfd.model.rif.InpatientClaim) InpatientClaimLine(gov.cms.bfd.model.rif.InpatientClaimLine) Instant(java.time.Instant) Test(org.junit.jupiter.api.Test) BigDecimal(java.math.BigDecimal) List(java.util.List) CcwCodebookVariable(gov.cms.bfd.model.codebook.data.CcwCodebookVariable) Optional(java.util.Optional) CCWProcedure(gov.cms.bfd.server.war.commons.CCWProcedure) FHIRException(org.hl7.fhir.exceptions.FHIRException) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) StaticRifResourceGroup(gov.cms.bfd.model.rif.samples.StaticRifResourceGroup) ServerTestUtils(gov.cms.bfd.server.war.ServerTestUtils) Diagnosis(gov.cms.bfd.server.war.commons.Diagnosis) InpatientClaim(gov.cms.bfd.model.rif.InpatientClaim) MetricRegistry(com.codahale.metrics.MetricRegistry) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) Test(org.junit.jupiter.api.Test)

Example 12 with InpatientClaim

use of gov.cms.bfd.model.rif.InpatientClaim in project beneficiary-fhir-data by CMSgov.

the class ClaimTypeTest method verifyServiceEndAttributeFunc.

/**
 * Verifies that our service end date function is working as expected. Since we are type casting
 * our claim object, we need to verify that every ClaimType is tested.
 */
@Test
public void verifyServiceEndAttributeFunc() {
    LocalDate start = LocalDate.now();
    LocalDate end = start.plusDays(10);
    CarrierClaim carrierClaim = new CarrierClaim();
    carrierClaim.setDateFrom(start);
    carrierClaim.setDateThrough(end);
    DMEClaim dmeClaim = new DMEClaim();
    dmeClaim.setDateFrom(start);
    dmeClaim.setDateThrough(end);
    HHAClaim hhaClaim = new HHAClaim();
    hhaClaim.setDateFrom(start);
    hhaClaim.setDateThrough(end);
    HospiceClaim hospiceClaim = new HospiceClaim();
    hospiceClaim.setDateFrom(start);
    hospiceClaim.setDateThrough(end);
    InpatientClaim inpatientClaim = new InpatientClaim();
    inpatientClaim.setDateFrom(start);
    inpatientClaim.setDateThrough(end);
    OutpatientClaim outpatientClaim = new OutpatientClaim();
    outpatientClaim.setDateFrom(start);
    outpatientClaim.setDateThrough(end);
    PartDEvent partDEvent = new PartDEvent();
    partDEvent.setPrescriptionFillDate(end);
    SNFClaim snfClaim = new SNFClaim();
    snfClaim.setDateFrom(start);
    snfClaim.setDateThrough(end);
    ImmutableMap.Builder<ClaimType, Object> builder = ImmutableMap.builder();
    builder.put(ClaimType.CARRIER, carrierClaim);
    builder.put(ClaimType.DME, dmeClaim);
    builder.put(ClaimType.HHA, hhaClaim);
    builder.put(ClaimType.HOSPICE, hospiceClaim);
    builder.put(ClaimType.INPATIENT, inpatientClaim);
    builder.put(ClaimType.OUTPATIENT, outpatientClaim);
    builder.put(ClaimType.PDE, partDEvent);
    builder.put(ClaimType.SNF, snfClaim);
    Map<ClaimType, Object> claimTypeToClaim = builder.build();
    // Verify that we're testing all of the ClaimTypes that are defined
    EnumSet.allOf(ClaimType.class).stream().forEach(claimType -> assertTrue(claimTypeToClaim.containsKey(claimType), String.format("ClaimType %s not tested", claimType.name())));
    claimTypeToClaim.entrySet().forEach(entry -> assertEquals(end, entry.getKey().getServiceEndAttributeFunction().apply(entry.getValue()), String.format("Claim type %s does not match expectations", entry.getKey().name())));
}
Also used : InpatientClaim(gov.cms.bfd.model.rif.InpatientClaim) OutpatientClaim(gov.cms.bfd.model.rif.OutpatientClaim) CarrierClaim(gov.cms.bfd.model.rif.CarrierClaim) SNFClaim(gov.cms.bfd.model.rif.SNFClaim) LocalDate(java.time.LocalDate) PartDEvent(gov.cms.bfd.model.rif.PartDEvent) ImmutableMap(com.google.common.collect.ImmutableMap) DMEClaim(gov.cms.bfd.model.rif.DMEClaim) HHAClaim(gov.cms.bfd.model.rif.HHAClaim) HospiceClaim(gov.cms.bfd.model.rif.HospiceClaim) Test(org.junit.jupiter.api.Test)

Example 13 with InpatientClaim

use of gov.cms.bfd.model.rif.InpatientClaim in project beneficiary-fhir-data by CMSgov.

the class ExplanationOfBenefitResourceProviderIT method searchForEobsByExistingPatientWithEvenPaging.

/**
 * Verifies that {@link ExplanationOfBenefitResourceProvider#findByPatient} works as expected for
 * a {@link Patient} that does exist in the DB, with paging. This test uses a count of 2 to verify
 * our code will not run into an IndexOutOfBoundsException on odd bundle sizes.
 *
 * @throws FHIRException (indicates test failure)
 */
@Test
public void searchForEobsByExistingPatientWithEvenPaging() 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();
    List<IBaseResource> combinedResults = new ArrayList<>();
    Bundle searchResults = fhirClient.search().forResource(ExplanationOfBenefit.class).where(ExplanationOfBenefit.PATIENT.hasId(TransformerUtils.buildPatientId(beneficiary))).count(2).returnBundle(Bundle.class).execute();
    searchResults.getEntry().forEach(e -> combinedResults.add(e.getResource()));
    assertNotNull(searchResults);
    assertEquals(2, searchResults.getEntry().size());
    /*
     * 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 links to the first and last page exist.
     */
    assertNotNull(searchResults.getLink(Constants.LINK_LAST));
    assertNotNull(searchResults.getLink(Constants.LINK_FIRST));
    /*
     * Verify that accessing all next links, eventually leading to the last page,
     * will not encounter an IndexOutOfBoundsException.
     */
    while (searchResults.getLink(Constants.LINK_NEXT) != null) {
        searchResults = fhirClient.loadPage().next(searchResults).execute();
        assertNotNull(searchResults);
        assertTrue(searchResults.hasEntry());
        /*
       * Each page after the first should have a first, previous, and last links.
       */
        assertNotNull(searchResults.getLink(Constants.LINK_FIRST));
        assertNotNull(searchResults.getLink(Constants.LINK_PREVIOUS));
        assertNotNull(searchResults.getLink(Constants.LINK_LAST));
        searchResults.getEntry().forEach(e -> combinedResults.add(e.getResource()));
    }
    /*
     * Verify that the combined results are the same size as
     * "all of the claim records in the sample."
     */
    assertEquals(loadedRecords.stream().filter(r -> !(r instanceof Beneficiary)).filter(r -> !(r instanceof BeneficiaryHistory)).filter(r -> !(r instanceof MedicareBeneficiaryIdHistory)).count(), combinedResults.size());
    /*
     * 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, filterToClaimTypeFromList(combinedResults, ClaimType.CARRIER).size());
    CarrierClaimTransformerTest.assertMatches(carrierClaim, filterToClaimTypeFromList(combinedResults, ClaimType.CARRIER).get(0), Optional.empty());
    DMEClaim dmeClaim = loadedRecords.stream().filter(r -> r instanceof DMEClaim).map(r -> (DMEClaim) r).findFirst().get();
    DMEClaimTransformerTest.assertMatches(dmeClaim, filterToClaimTypeFromList(combinedResults, ClaimType.DME).get(0), Optional.empty());
    HHAClaim hhaClaim = loadedRecords.stream().filter(r -> r instanceof HHAClaim).map(r -> (HHAClaim) r).findFirst().get();
    HHAClaimTransformerTest.assertMatches(hhaClaim, filterToClaimTypeFromList(combinedResults, ClaimType.HHA).get(0));
    HospiceClaim hospiceClaim = loadedRecords.stream().filter(r -> r instanceof HospiceClaim).map(r -> (HospiceClaim) r).findFirst().get();
    HospiceClaimTransformerTest.assertMatches(hospiceClaim, filterToClaimTypeFromList(combinedResults, ClaimType.HOSPICE).get(0));
    InpatientClaim inpatientClaim = loadedRecords.stream().filter(r -> r instanceof InpatientClaim).map(r -> (InpatientClaim) r).findFirst().get();
    InpatientClaimTransformerTest.assertMatches(inpatientClaim, filterToClaimTypeFromList(combinedResults, ClaimType.INPATIENT).get(0));
    OutpatientClaim outpatientClaim = loadedRecords.stream().filter(r -> r instanceof OutpatientClaim).map(r -> (OutpatientClaim) r).findFirst().get();
    OutpatientClaimTransformerTest.assertMatches(outpatientClaim, filterToClaimTypeFromList(combinedResults, ClaimType.OUTPATIENT).get(0));
    PartDEvent partDEvent = loadedRecords.stream().filter(r -> r instanceof PartDEvent).map(r -> (PartDEvent) r).findFirst().get();
    PartDEventTransformerTest.assertMatches(partDEvent, filterToClaimTypeFromList(combinedResults, ClaimType.PDE).get(0));
    SNFClaim snfClaim = loadedRecords.stream().filter(r -> r instanceof SNFClaim).map(r -> (SNFClaim) r).findFirst().get();
    SNFClaimTransformerTest.assertMatches(snfClaim, filterToClaimTypeFromList(combinedResults, 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) ArrayList(java.util.ArrayList) 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) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Beneficiary(gov.cms.bfd.model.rif.Beneficiary) Test(org.junit.jupiter.api.Test)

Example 14 with InpatientClaim

use of gov.cms.bfd.model.rif.InpatientClaim in project beneficiary-fhir-data by CMSgov.

the class ExplanationOfBenefitResourceProviderIT method readEobForExistingInpatientClaim.

/**
 * Verifies that {link ExplanationOfBenefitResourceProvider#read(IdType, RequestDetails)} works as
 * expected for an {@link InpatientClaim}-derived {@link ExplanationOfBenefit} that does exist in
 * the DB.
 *
 * @throws FHIRException (indicates test failure)
 */
@Test
public void readEobForExistingInpatientClaim() throws FHIRException {
    List<Object> loadedRecords = ServerTestUtils.get().loadData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
    IGenericClient fhirClient = ServerTestUtils.get().createFhirClient();
    InpatientClaim claim = loadedRecords.stream().filter(r -> r instanceof InpatientClaim).map(r -> (InpatientClaim) r).findFirst().get();
    ExplanationOfBenefit eob = fhirClient.read().resource(ExplanationOfBenefit.class).withId(TransformerUtils.buildEobId(ClaimType.INPATIENT, claim.getClaimId())).execute();
    assertNotNull(eob);
    InpatientClaimTransformerTest.assertMatches(claim, eob);
}
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) InpatientClaim(gov.cms.bfd.model.rif.InpatientClaim) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) Test(org.junit.jupiter.api.Test)

Example 15 with InpatientClaim

use of gov.cms.bfd.model.rif.InpatientClaim in project beneficiary-fhir-data by CMSgov.

the class ExplanationOfBenefitResourceProviderIT method searchForEobsByExistingPatient.

/**
 * Verifies that {@link 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().createFhirClient();
    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(TransformerUtils.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.
     */
    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) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) 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

InpatientClaim (gov.cms.bfd.model.rif.InpatientClaim)19 Arrays (java.util.Arrays)13 Optional (java.util.Optional)13 Test (org.junit.jupiter.api.Test)13 CarrierClaim (gov.cms.bfd.model.rif.CarrierClaim)12 DMEClaim (gov.cms.bfd.model.rif.DMEClaim)12 HHAClaim (gov.cms.bfd.model.rif.HHAClaim)12 HospiceClaim (gov.cms.bfd.model.rif.HospiceClaim)12 OutpatientClaim (gov.cms.bfd.model.rif.OutpatientClaim)12 PartDEvent (gov.cms.bfd.model.rif.PartDEvent)12 SNFClaim (gov.cms.bfd.model.rif.SNFClaim)12 StaticRifResourceGroup (gov.cms.bfd.model.rif.samples.StaticRifResourceGroup)12 ServerTestUtils (gov.cms.bfd.server.war.ServerTestUtils)12 TransformerConstants (gov.cms.bfd.server.war.commons.TransformerConstants)12 List (java.util.List)12 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)12 IGenericClient (ca.uhn.fhir.rest.client.api.IGenericClient)10 Beneficiary (gov.cms.bfd.model.rif.Beneficiary)10 PipelineTestUtils (gov.cms.bfd.pipeline.sharedutils.PipelineTestUtils)10 CommonHeaders (gov.cms.bfd.server.war.commons.CommonHeaders)10