Search in sources :

Example 1 with CoverageSearchEvent

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

the class CoverageDriverTest method createEvent.

private CoverageSearchEvent createEvent(CoveragePeriod period, CoverageJobStatus status, OffsetDateTime created) {
    CoverageSearchEvent event = new CoverageSearchEvent();
    event.setCoveragePeriod(period);
    event.setNewStatus(status);
    event.setCreated(created);
    event.setDescription("testing");
    event = coverageSearchEventRepo.saveAndFlush(event);
    event.setCreated(created);
    coverageSearchEventRepo.saveAndFlush(event);
    return event;
}
Also used : CoverageSearchEvent(gov.cms.ab2d.coverage.model.CoverageSearchEvent)

Example 2 with CoverageSearchEvent

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

the class CoverageMappingCallableTest method filterYear.

@DisplayName("Filter out years that do not match the provided year")
@Test
void filterYear() {
    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());
        int pastYear = (int) ReflectionTestUtils.getField(coverageCallable, "pastReferenceYear");
        assertEquals(10, pastYear);
    } 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) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 3 with CoverageSearchEvent

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

the class CoverageMappingCallableTest method testNullMbi.

@Test
void testNullMbi() {
    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());
    Patient patient = new Patient();
    Identifiers ids = callable.extractPatientId(patient);
    assertNull(ids);
    Identifier beneId = new Identifier();
    beneId.setSystem(BENEFICIARY_ID);
    beneId.setValue("1");
    patient.getIdentifier().add(beneId);
    ids = callable.extractPatientId(patient);
    assertEquals(1L, ids.getBeneficiaryId());
    assertNull(ids.getCurrentMbi());
    assertEquals(0, ids.getHistoricMbis().size());
    Identifier mbiHist = new Identifier();
    mbiHist.setSystem(MBI_ID);
    mbiHist.setValue("HIST_MBI");
    Extension extension = new Extension();
    extension.setUrl(CURRENCY_IDENTIFIER);
    Coding code1 = new Coding();
    code1.setCode("historic");
    extension.setValue(code1);
    mbiHist.getExtension().add(extension);
    patient.getIdentifier().add(mbiHist);
    ids = callable.extractPatientId(patient);
    assertEquals(1L, ids.getBeneficiaryId());
    assertNull(ids.getCurrentMbi());
    assertEquals(1, ids.getHistoricMbis().size());
    assertEquals("HIST_MBI", ids.getHistoricMbis().stream().findAny().get());
    Identifier mbiCurrent = new Identifier();
    mbiCurrent.setSystem(MBI_ID);
    mbiCurrent.setValue("CURR_MBI");
    Extension extension2 = new Extension();
    extension2.setUrl(CURRENCY_IDENTIFIER);
    Coding code2 = new Coding();
    code2.setCode("current");
    extension2.setValue(code2);
    mbiCurrent.getExtension().add(extension2);
    patient.getIdentifier().add(mbiCurrent);
    ids = callable.extractPatientId(patient);
    assertEquals(1L, ids.getBeneficiaryId());
    assertEquals(1, ids.getHistoricMbis().size());
    assertEquals("CURR_MBI", ids.getCurrentMbi());
    assertEquals(1, ids.getHistoricMbis().size());
    assertEquals("HIST_MBI", ids.getHistoricMbis().stream().findAny().get());
}
Also used : Extension(org.hl7.fhir.dstu3.model.Extension) Identifier(org.hl7.fhir.dstu3.model.Identifier) ContractDTO(gov.cms.ab2d.common.dto.ContractDTO) Coding(org.hl7.fhir.dstu3.model.Coding) 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) Patient(org.hl7.fhir.dstu3.model.Patient) BundleUtils.createPatient(gov.cms.ab2d.worker.processor.BundleUtils.createPatient) CoverageSearchEvent(gov.cms.ab2d.coverage.model.CoverageSearchEvent) Identifiers(gov.cms.ab2d.coverage.model.Identifiers) Test(org.junit.jupiter.api.Test)

Example 4 with CoverageSearchEvent

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

the class CoverageMappingCallableTest method testTestContractYears.

@DisplayName("Test to see if it returns the correct year for test contracts")
@Test
void testTestContractYears() {
    ContractDTO contract = new ContractDTO("TESTING", "TESTING", OffsetDateTime.now(), Contract.ContractType.CLASSIC_TEST);
    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);
    // First test that the corrected year modification works
    CoverageMapping mapping = new CoverageMapping(cse, search);
    ContractToContractCoverageMapping contractToContractCoverageMapping = new ContractToContractCoverageMapping();
    ContractForCoverageDTO contractForCoverageDTO = contractToContractCoverageMapping.map(contract);
    CoverageMappingCallable callable = new CoverageMappingCallable(STU3, mapping, bfdClient, mapping.getPeriod().getYear());
    assertEquals(3, contractForCoverageDTO.getCorrectedYear(2020));
    // Test that the corrected year modification is not applied to Synthea
    contractForCoverageDTO.setContractType(ContractForCoverageDTO.ContractType.SYNTHEA);
    assertEquals(2020, contractForCoverageDTO.getCorrectedYear(2020));
}
Also used : ContractDTO(gov.cms.ab2d.common.dto.ContractDTO) ContractForCoverageDTO(gov.cms.ab2d.coverage.model.ContractForCoverageDTO) 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) 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 5 with CoverageSearchEvent

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

the class CoverageUpdateAndProcessorTest method createEvent.

private CoverageSearchEvent createEvent(CoveragePeriod period, CoverageJobStatus status, OffsetDateTime created) {
    CoverageSearchEvent event = new CoverageSearchEvent();
    event.setCoveragePeriod(period);
    event.setNewStatus(status);
    event.setCreated(created);
    event.setDescription("testing");
    event = coverageSearchEventRepo.saveAndFlush(event);
    event.setCreated(created);
    coverageSearchEventRepo.saveAndFlush(event);
    return event;
}
Also used : CoverageSearchEvent(gov.cms.ab2d.coverage.model.CoverageSearchEvent)

Aggregations

CoverageSearchEvent (gov.cms.ab2d.coverage.model.CoverageSearchEvent)55 Test (org.junit.jupiter.api.Test)38 DisplayName (org.junit.jupiter.api.DisplayName)37 CoveragePeriod (gov.cms.ab2d.coverage.model.CoveragePeriod)26 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)26 CoverageSearch (gov.cms.ab2d.coverage.model.CoverageSearch)22 Identifiers (gov.cms.ab2d.coverage.model.Identifiers)22 CoverageMapping (gov.cms.ab2d.coverage.model.CoverageMapping)20 LinkedHashSet (java.util.LinkedHashSet)15 CoverageCount (gov.cms.ab2d.coverage.model.CoverageCount)14 List (java.util.List)13 ContractDTO (gov.cms.ab2d.common.dto.ContractDTO)12 ContractForCoverageDTO (gov.cms.ab2d.coverage.model.ContractForCoverageDTO)12 CoverageJobStatus (gov.cms.ab2d.coverage.model.CoverageJobStatus)12 CoveragePagingRequest (gov.cms.ab2d.coverage.model.CoveragePagingRequest)12 CoveragePagingResult (gov.cms.ab2d.coverage.model.CoveragePagingResult)12 CoverageSearchDiff (gov.cms.ab2d.coverage.model.CoverageSearchDiff)12 CoverageSummary (gov.cms.ab2d.coverage.model.CoverageSummary)12 OffsetDateTime (java.time.OffsetDateTime)12 Collections.disjoint (java.util.Collections.disjoint)12