Search in sources :

Example 11 with CoverageMapping

use of gov.cms.ab2d.coverage.model.CoverageMapping in project ab2d by CMSgov.

the class CoverageMappingCallableTest method trackYears.

@DisplayName("Track distribution of reference years returned to callable")
@Test
void trackYears() {
    org.hl7.fhir.dstu3.model.Bundle bundle1 = buildBundle(0, 10, 2020);
    bundle1.setLink(singletonList(new org.hl7.fhir.dstu3.model.Bundle.BundleLinkComponent().setRelation(org.hl7.fhir.dstu3.model.Bundle.LINK_NEXT)));
    org.hl7.fhir.dstu3.model.Bundle bundle2 = buildBundle(10, 20, 2019);
    when(bfdClient.requestPartDEnrolleesFromServer(eq(STU3), anyString(), anyInt(), anyInt())).thenReturn(bundle1);
    when(bfdClient.requestNextBundleFromServer(eq(STU3), any(org.hl7.fhir.dstu3.model.Bundle.class))).thenReturn(bundle2);
    ContractDTO contract = new ContractDTO("TESTING", "TESTING", null, null);
    CoveragePeriod period = new CoveragePeriod();
    period.setContractNumber(contract.getContractNumber());
    period.setYear(2020);
    period.setMonth(1);
    CoverageSearchEvent cse = new CoverageSearchEvent();
    cse.setCoveragePeriod(period);
    CoverageSearch search = new CoverageSearch();
    search.setPeriod(period);
    CoverageMapping mapping = new CoverageMapping(cse, search);
    CoverageMappingCallable coverageCallable = new CoverageMappingCallable(STU3, mapping, bfdClient, mapping.getPeriod().getYear());
    try {
        mapping = coverageCallable.call();
        assertEquals(10, mapping.getBeneficiaryIds().size());
        Map<Integer, Integer> referenceYears = (Map<Integer, Integer>) ReflectionTestUtils.getField(coverageCallable, "referenceYears");
        assertTrue(referenceYears.containsKey(2019));
        assertTrue(referenceYears.containsKey(2020));
        referenceYears.forEach((referenceYear, occurrences) -> {
            assertEquals(10, occurrences);
        });
    } catch (Exception exception) {
        fail("could not execute basic job with mock client", exception);
    }
}
Also used : ContractToContractCoverageMapping(gov.cms.ab2d.worker.config.ContractToContractCoverageMapping) CoverageMapping(gov.cms.ab2d.coverage.model.CoverageMapping) ContractDTO(gov.cms.ab2d.common.dto.ContractDTO) CoveragePeriod(gov.cms.ab2d.coverage.model.CoveragePeriod) CoverageSearch(gov.cms.ab2d.coverage.model.CoverageSearch) CoverageSearchEvent(gov.cms.ab2d.coverage.model.CoverageSearchEvent) Map(java.util.Map) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 12 with CoverageMapping

use of gov.cms.ab2d.coverage.model.CoverageMapping in project ab2d by CMSgov.

the class CoverageMappingCallableTest method callableFunctions.

@DisplayName("Successfully completing marks as done and transfers results")
@Test
void callableFunctions() {
    org.hl7.fhir.dstu3.model.Bundle bundle1 = buildBundle(0, 10, 2020);
    bundle1.setLink(singletonList(new org.hl7.fhir.dstu3.model.Bundle.BundleLinkComponent().setRelation(org.hl7.fhir.dstu3.model.Bundle.LINK_NEXT)));
    org.hl7.fhir.dstu3.model.Bundle bundle2 = buildBundle(10, 20, 2020);
    when(bfdClient.requestPartDEnrolleesFromServer(eq(STU3), anyString(), anyInt(), anyInt())).thenReturn(bundle1);
    when(bfdClient.requestNextBundleFromServer(eq(STU3), any(org.hl7.fhir.dstu3.model.Bundle.class))).thenReturn(bundle2);
    ContractDTO contract = new ContractDTO("TESTING", "TESTING", null, null);
    CoveragePeriod period = new CoveragePeriod();
    period.setContractNumber(contract.getContractNumber());
    period.setYear(2020);
    period.setMonth(1);
    CoverageSearchEvent cse = new CoverageSearchEvent();
    cse.setCoveragePeriod(period);
    CoverageSearch search = new CoverageSearch();
    search.setPeriod(period);
    ContractToContractCoverageMapping contractToContractCoverageMapping = new ContractToContractCoverageMapping();
    CoverageMapping mapping = new CoverageMapping(cse, search);
    CoverageMappingCallable callable = new CoverageMappingCallable(STU3, mapping, bfdClient, mapping.getPeriod().getYear());
    assertFalse(callable.isCompleted());
    CoverageMapping results = callable.call();
    assertEquals(mapping, results);
    assertTrue(callable.isCompleted());
    assertTrue(mapping.isSuccessful());
    assertEquals(20, results.getBeneficiaryIds().size());
}
Also used : ContractToContractCoverageMapping(gov.cms.ab2d.worker.config.ContractToContractCoverageMapping) CoverageMapping(gov.cms.ab2d.coverage.model.CoverageMapping) ContractDTO(gov.cms.ab2d.common.dto.ContractDTO) CoveragePeriod(gov.cms.ab2d.coverage.model.CoveragePeriod) CoverageSearch(gov.cms.ab2d.coverage.model.CoverageSearch) ContractToContractCoverageMapping(gov.cms.ab2d.worker.config.ContractToContractCoverageMapping) CoverageSearchEvent(gov.cms.ab2d.coverage.model.CoverageSearchEvent) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 13 with CoverageMapping

use of gov.cms.ab2d.coverage.model.CoverageMapping in project ab2d by CMSgov.

the class CoverageMappingCallableTest method multipleMbis.

@DisplayName("Multiple mbis captured")
@Test
void multipleMbis() {
    org.hl7.fhir.dstu3.model.Bundle bundle1 = buildBundle(0, 10, 3, 2020);
    bundle1.setLink(singletonList(new org.hl7.fhir.dstu3.model.Bundle.BundleLinkComponent().setRelation(org.hl7.fhir.dstu3.model.Bundle.LINK_NEXT)));
    org.hl7.fhir.dstu3.model.Bundle bundle2 = buildBundle(10, 20, 3, 2020);
    when(bfdClient.requestPartDEnrolleesFromServer(eq(STU3), anyString(), anyInt(), anyInt())).thenReturn(bundle1);
    when(bfdClient.requestNextBundleFromServer(eq(STU3), any(org.hl7.fhir.dstu3.model.Bundle.class))).thenReturn(bundle2);
    ContractDTO contract = new ContractDTO("TESTING", "TESTING", null, null);
    CoveragePeriod period = new CoveragePeriod();
    period.setContractNumber(contract.getContractNumber());
    period.setYear(2020);
    period.setMonth(1);
    CoverageSearchEvent cse = new CoverageSearchEvent();
    cse.setCoveragePeriod(period);
    CoverageSearch search = new CoverageSearch();
    search.setPeriod(period);
    CoverageMapping mapping = new CoverageMapping(cse, search);
    CoverageMappingCallable callable = new CoverageMappingCallable(STU3, mapping, bfdClient, mapping.getPeriod().getYear());
    try {
        callable.call();
        for (Identifiers patient : mapping.getBeneficiaryIds()) {
            assertNotNull(patient.getBeneficiaryId());
            assertNotNull(patient.getCurrentMbi());
            assertEquals(2, patient.getHistoricMbis().size());
        }
        assertEquals(20, mapping.getBeneficiaryIds().size());
    } catch (Exception exception) {
        fail("could not execute basic job with mock client", exception);
    }
}
Also used : ContractToContractCoverageMapping(gov.cms.ab2d.worker.config.ContractToContractCoverageMapping) CoverageMapping(gov.cms.ab2d.coverage.model.CoverageMapping) ContractDTO(gov.cms.ab2d.common.dto.ContractDTO) CoveragePeriod(gov.cms.ab2d.coverage.model.CoveragePeriod) CoverageSearch(gov.cms.ab2d.coverage.model.CoverageSearch) CoverageSearchEvent(gov.cms.ab2d.coverage.model.CoverageSearchEvent) Identifiers(gov.cms.ab2d.coverage.model.Identifiers) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 14 with CoverageMapping

use of gov.cms.ab2d.coverage.model.CoverageMapping in project ab2d by CMSgov.

the class CoverageMappingCallableTest method filterMissingIdentifier.

@DisplayName("Filter out patients without identifiers")
@Test
void filterMissingIdentifier() {
    org.hl7.fhir.dstu3.model.Bundle bundle1 = buildBundle(0, 10, 2020);
    bundle1.setLink(singletonList(new org.hl7.fhir.dstu3.model.Bundle.BundleLinkComponent().setRelation(org.hl7.fhir.dstu3.model.Bundle.LINK_NEXT)));
    org.hl7.fhir.dstu3.model.Bundle bundle2 = buildBundle(10, 20, 2020);
    bundle2.getEntry().forEach(ec -> {
        org.hl7.fhir.dstu3.model.Patient patient = (org.hl7.fhir.dstu3.model.Patient) ec.getResource();
        patient.setIdentifier(emptyList());
    });
    when(bfdClient.requestPartDEnrolleesFromServer(eq(STU3), anyString(), anyInt(), anyInt())).thenReturn(bundle1);
    when(bfdClient.requestNextBundleFromServer(eq(STU3), any(org.hl7.fhir.dstu3.model.Bundle.class))).thenReturn(bundle2);
    ContractDTO contract = new ContractDTO("TESTING", "TESTING", null, null);
    CoveragePeriod period = new CoveragePeriod();
    period.setContractNumber(contract.getContractNumber());
    period.setYear(2020);
    period.setMonth(1);
    CoverageSearchEvent cse = new CoverageSearchEvent();
    cse.setCoveragePeriod(period);
    CoverageSearch search = new CoverageSearch();
    search.setPeriod(period);
    CoverageMapping mapping = new CoverageMapping(cse, search);
    CoverageMappingCallable coverageCallable = new CoverageMappingCallable(STU3, mapping, bfdClient, mapping.getPeriod().getYear());
    try {
        mapping = coverageCallable.call();
        assertEquals(10, mapping.getBeneficiaryIds().size());
        int missingIdentifier = (int) ReflectionTestUtils.getField(coverageCallable, "missingBeneId");
        assertEquals(10, missingIdentifier);
    } catch (Exception exception) {
        fail("could not execute basic job with mock client", exception);
    }
}
Also used : ContractToContractCoverageMapping(gov.cms.ab2d.worker.config.ContractToContractCoverageMapping) CoverageMapping(gov.cms.ab2d.coverage.model.CoverageMapping) Patient(org.hl7.fhir.dstu3.model.Patient) BundleUtils.createPatient(gov.cms.ab2d.worker.processor.BundleUtils.createPatient) ContractDTO(gov.cms.ab2d.common.dto.ContractDTO) Patient(org.hl7.fhir.dstu3.model.Patient) CoveragePeriod(gov.cms.ab2d.coverage.model.CoveragePeriod) CoverageSearch(gov.cms.ab2d.coverage.model.CoverageSearch) CoverageSearchEvent(gov.cms.ab2d.coverage.model.CoverageSearchEvent) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 15 with CoverageMapping

use of gov.cms.ab2d.coverage.model.CoverageMapping in project ab2d by CMSgov.

the class CoverageMappingCallableTest method exceptionCaught.

@DisplayName("Exceptional behavior leads to failure")
@Test
void exceptionCaught() {
    when(bfdClient.requestPartDEnrolleesFromServer(eq(STU3), anyString(), anyInt())).thenThrow(new RuntimeException("exception"));
    ContractDTO contract = new ContractDTO("TESTING", "TESTING", null, null);
    CoveragePeriod period = new CoveragePeriod();
    period.setContractNumber(contract.getContractNumber());
    period.setYear(2020);
    period.setMonth(1);
    CoverageSearchEvent cse = new CoverageSearchEvent();
    cse.setCoveragePeriod(period);
    CoverageSearch search = new CoverageSearch();
    search.setPeriod(period);
    CoverageMapping mapping = new CoverageMapping(cse, search);
    CoverageMappingCallable callable = new CoverageMappingCallable(STU3, mapping, bfdClient, mapping.getPeriod().getYear());
    try {
        callable.call();
    } catch (Exception exception) {
    // ignore exception for sake of test
    }
    assertFalse(mapping.isSuccessful());
    assertTrue(callable.isCompleted());
}
Also used : ContractDTO(gov.cms.ab2d.common.dto.ContractDTO) ContractToContractCoverageMapping(gov.cms.ab2d.worker.config.ContractToContractCoverageMapping) CoverageMapping(gov.cms.ab2d.coverage.model.CoverageMapping) CoveragePeriod(gov.cms.ab2d.coverage.model.CoveragePeriod) CoverageSearch(gov.cms.ab2d.coverage.model.CoverageSearch) CoverageSearchEvent(gov.cms.ab2d.coverage.model.CoverageSearchEvent) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

CoverageMapping (gov.cms.ab2d.coverage.model.CoverageMapping)16 ContractToContractCoverageMapping (gov.cms.ab2d.worker.config.ContractToContractCoverageMapping)14 CoverageSearch (gov.cms.ab2d.coverage.model.CoverageSearch)13 CoveragePeriod (gov.cms.ab2d.coverage.model.CoveragePeriod)12 CoverageSearchEvent (gov.cms.ab2d.coverage.model.CoverageSearchEvent)12 Test (org.junit.jupiter.api.Test)11 ContractDTO (gov.cms.ab2d.common.dto.ContractDTO)10 DisplayName (org.junit.jupiter.api.DisplayName)10 Identifiers (gov.cms.ab2d.coverage.model.Identifiers)4 BundleUtils.createPatient (gov.cms.ab2d.worker.processor.BundleUtils.createPatient)3 ContractForCoverageDTO (gov.cms.ab2d.coverage.model.ContractForCoverageDTO)2 Patient (org.hl7.fhir.dstu3.model.Patient)2 Scheduled (org.springframework.scheduling.annotation.Scheduled)2 AB2D_EPOCH (gov.cms.ab2d.common.util.DateUtil.AB2D_EPOCH)1 CoverageCount (gov.cms.ab2d.coverage.model.CoverageCount)1 CoverageDelta (gov.cms.ab2d.coverage.model.CoverageDelta)1 CoverageJobStatus (gov.cms.ab2d.coverage.model.CoverageJobStatus)1 CoveragePagingRequest (gov.cms.ab2d.coverage.model.CoveragePagingRequest)1 CoveragePagingResult (gov.cms.ab2d.coverage.model.CoveragePagingResult)1 CoverageSearchDiff (gov.cms.ab2d.coverage.model.CoverageSearchDiff)1