Search in sources :

Example 1 with Contract

use of gov.cms.ab2d.common.model.Contract in project ab2d by CMSgov.

the class BulkDataAccessAPIUnusualDataTests method testPatientExportWithNoAttestation.

@Test
void testPatientExportWithNoAttestation() throws Exception {
    // Valid contract number for sponsor, but no attestation
    String token = testUtil.setupContractWithNoAttestation(List.of(SPONSOR_ROLE));
    Optional<Contract> contractOptional = contractRepository.findContractByContractNumber(VALID_CONTRACT_NUMBER);
    Contract contract = contractOptional.get();
    this.mockMvc.perform(get(API_PREFIX_V1 + FHIR_PREFIX + "/Group/" + contract.getContractNumber() + "/$export").contentType(MediaType.APPLICATION_JSON).header("Authorization", "Bearer " + token)).andExpect(status().is(403));
    List<LoggableEvent> apiRequestEvents = loggerEventRepository.load(ApiRequestEvent.class);
    ApiRequestEvent requestEvent = (ApiRequestEvent) apiRequestEvents.get(0);
    List<LoggableEvent> apiResponseEvents = loggerEventRepository.load(ApiResponseEvent.class);
    ApiResponseEvent responseEvent = (ApiResponseEvent) apiResponseEvents.get(0);
    assertEquals(requestEvent.getRequestId(), responseEvent.getRequestId());
    List<LoggableEvent> errorEvents = loggerEventRepository.load(ErrorEvent.class);
    ErrorEvent errorEvent = (ErrorEvent) errorEvents.get(0);
    assertEquals(ErrorEvent.ErrorType.UNAUTHORIZED_CONTRACT, errorEvent.getErrorType());
    assertTrue(UtilMethods.allEmpty(loggerEventRepository.load(ReloadEvent.class), loggerEventRepository.load(ContractSearchEvent.class), loggerEventRepository.load(JobStatusChangeEvent.class), loggerEventRepository.load(FileEvent.class)));
}
Also used : LoggableEvent(gov.cms.ab2d.eventlogger.LoggableEvent) Contract(gov.cms.ab2d.common.model.Contract) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with Contract

use of gov.cms.ab2d.common.model.Contract in project ab2d by CMSgov.

the class CoverageDriverTest method discoverCoveragePeriodsIgnoresTestContracts.

@DisplayName("Ignore contracts marked test")
@Test
void discoverCoveragePeriodsIgnoresTestContracts() {
    Contract testContract = dataSetup.setupContract("TST-AFTER-EPOCH", AB2D_EPOCH.toOffsetDateTime().plusMonths(3));
    testContract.setUpdateMode(Contract.UpdateMode.NONE);
    contractRepo.saveAndFlush(testContract);
    try {
        driver.discoverCoveragePeriods();
    } catch (CoverageDriverException | InterruptedException exception) {
        fail("could not queue periods due to driver exception", exception);
    }
    List<CoveragePeriod> periods = coveragePeriodRepo.findAllByContractNumber(testContract.getContractNumber());
    assertTrue(periods.isEmpty());
}
Also used : CoveragePeriod(gov.cms.ab2d.coverage.model.CoveragePeriod) Contract(gov.cms.ab2d.common.model.Contract) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 3 with Contract

use of gov.cms.ab2d.common.model.Contract in project ab2d by CMSgov.

the class CoverageDriverTest method availableCoverageWhenSinceContainsOnlySuccessful.

/**
 * The since date is only relevant for claims data not enrollment data. So even though the since date
 * is set the enrollment data must all be up to date before a job can start.
 */
@DisplayName("Do not start an eob job if periods before since are being worked on. Ignore since.")
@Test
void availableCoverageWhenSinceContainsOnlySuccessful() {
    Job job = new Job();
    job.setCreatedAt(OffsetDateTime.now());
    Contract temp = contractRepo.findContractByContractNumber(contractForCoverageDTO.getContractNumber()).get();
    job.setContractNumber(temp.getContractNumber());
    OffsetDateTime since = OffsetDateTime.of(LocalDate.of(2020, 3, 1), LocalTime.of(0, 0, 0), AB2D_ZONE.getRules().getOffset(Instant.now()));
    try {
        changeStatus(contractForCoverageDTO, since, CoverageJobStatus.SUCCESSFUL);
        LocalDate startMonth = LocalDate.of(2020, 3, 1);
        LocalTime startDay = LocalTime.of(0, 0, 0);
        job.setSince(OffsetDateTime.of(startMonth, startDay, AB2D_ZONE.getRules().getOffset(Instant.now())));
        boolean inProgressBeginningMonth = driver.isCoverageAvailable(job, contract.toDTO());
        assertFalse(inProgressBeginningMonth, "eob searches should run when only month after since is successful");
        LocalDate endMonth = LocalDate.of(2020, 3, 31);
        LocalTime endDay = LocalTime.of(23, 59, 59);
        job.setSince(OffsetDateTime.of(endMonth, endDay, AB2D_ZONE.getRules().getOffset(Instant.now())));
        boolean inProgressEndMonth = driver.isCoverageAvailable(job, contract.toDTO());
        assertFalse(inProgressEndMonth, "eob searches should run when only month after since is successful");
    } catch (InterruptedException | CoverageDriverException exception) {
        fail("could not check for available coverage", exception);
    }
}
Also used : LocalTime(java.time.LocalTime) OffsetDateTime(java.time.OffsetDateTime) Job(gov.cms.ab2d.common.model.Job) Contract(gov.cms.ab2d.common.model.Contract) LocalDate(java.time.LocalDate) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 4 with Contract

use of gov.cms.ab2d.common.model.Contract in project ab2d by CMSgov.

the class ContractProcessorUnitTest method createContract.

private Contract createContract() {
    Contract contract = new Contract();
    contract.setContractName("CONTRACT_NM_00000");
    contract.setContractNumber("CONTRACT_00000");
    contract.setAttestedOn(OffsetDateTime.now().minusDays(10));
    return contract;
}
Also used : Contract(gov.cms.ab2d.common.model.Contract)

Example 5 with Contract

use of gov.cms.ab2d.common.model.Contract in project ab2d by CMSgov.

the class JobPreProcessorIntegrationTest method setUp.

@BeforeEach
void setUp() {
    MockitoAnnotations.openMocks(this);
    LogManager manager = new LogManager(sqlEventLogger, kinesisEventLogger, slackLogger);
    cut = new JobPreProcessorImpl(contractWorkerClient, jobRepository, manager, coverageDriver);
    Contract tmpContract = new Contract();
    tmpContract.setContractNumber(UUID.randomUUID().toString());
    tmpContract.setContractName(UUID.randomUUID().toString());
    contract = contractRepository.save(tmpContract);
    pdpClient = createClient(tmpContract);
    job = createJob(pdpClient, contract.getContractNumber());
}
Also used : LogManager(gov.cms.ab2d.eventlogger.LogManager) Contract(gov.cms.ab2d.common.model.Contract) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

Contract (gov.cms.ab2d.common.model.Contract)36 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)15 Test (org.junit.jupiter.api.Test)13 PdpClient (gov.cms.ab2d.common.model.PdpClient)6 CoveragePeriod (gov.cms.ab2d.coverage.model.CoveragePeriod)6 Job (gov.cms.ab2d.common.model.Job)5 ContractDTO (gov.cms.ab2d.common.dto.ContractDTO)4 OffsetDateTime (java.time.OffsetDateTime)4 ArrayList (java.util.ArrayList)4 DisplayName (org.junit.jupiter.api.DisplayName)4 PdpClientDTO (gov.cms.ab2d.common.dto.PdpClientDTO)3 PdpClientService (gov.cms.ab2d.common.service.PdpClientService)3 PropertiesService (gov.cms.ab2d.common.service.PropertiesService)3 Constants (gov.cms.ab2d.common.util.Constants)3 ContractForCoverageDTO (gov.cms.ab2d.coverage.model.ContractForCoverageDTO)3 CoverageMapping (gov.cms.ab2d.coverage.model.CoverageMapping)3 CoverageSearch (gov.cms.ab2d.coverage.model.CoverageSearch)3 CoverageSearchRepository (gov.cms.ab2d.coverage.repository.CoverageSearchRepository)3 CoverageService (gov.cms.ab2d.coverage.service.CoverageService)3 ContractToContractCoverageMapping (gov.cms.ab2d.worker.config.ContractToContractCoverageMapping)3