Search in sources :

Example 6 with CoverageSearch

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

the class CoverageServiceImplTest method submitSearches.

@DisplayName("Coverage period searches are successfully submitted")
@Test
void submitSearches() {
    CoverageSearchEvent cs1 = coverageService.submitSearch(period1Jan.getId(), "testing").get();
    CoverageSearchEvent cs1Copy = coverageSearchEventRepo.findById(cs1.getId()).get();
    CoverageSearch coverageSearch = coverageSearchRepo.findFirstByOrderByCreatedAsc().get();
    assertEquals(CoverageJobStatus.SUBMITTED, cs1Copy.getNewStatus());
    // Make sure that coverage search and search event match
    assertEquals(cs1Copy.getCoveragePeriod(), coverageSearch.getPeriod());
    startSearchAndPullEvent();
}
Also used : CoverageSearch(gov.cms.ab2d.coverage.model.CoverageSearch) CoverageSearchEvent(gov.cms.ab2d.coverage.model.CoverageSearchEvent) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 7 with CoverageSearch

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

the class InsertionJob method call.

public CoverageSearchEvent call() {
    // Add in progress event as foreign key for all inserts
    coverageService.submitSearch(period.getId(), "testing");
    CoverageSearch search = new CoverageSearch();
    search.setPeriod(period);
    search.setAttempts(0);
    search.setCreated(OffsetDateTime.now());
    CoverageSearchEvent inProgress = coverageService.startSearch(search, "testing").get().getCoverageSearchEvent();
    // Run inserts
    // If number of experiments is greater than 1 then data will be erased after each experiment
    List<Long> timings = performExperiments(period, inProgress, dataPoints, experiments);
    // Average and print times of experiments
    long averageTime = timings.stream().reduce(0L, Long::sum) / timings.size();
    System.out.println("Average milliseconds " + averageTime);
    System.out.println("Times " + timings.stream().map(Object::toString).collect(joining(", ")));
    return inProgress;
}
Also used : CoverageSearch(gov.cms.ab2d.coverage.model.CoverageSearch) CoverageSearchEvent(gov.cms.ab2d.coverage.model.CoverageSearchEvent)

Example 8 with CoverageSearch

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

the class CoverageServiceImpl method resubmitSearch.

@Override
public CoverageSearchEvent resubmitSearch(int periodId, int attempts, String failedDescription, String restartDescription, boolean prioritize) {
    CoveragePeriod period = findCoveragePeriod(periodId);
    updateStatus(period, failedDescription, CoverageJobStatus.FAILED, false);
    // Add to queue of jobs to do
    CoverageSearch search = new CoverageSearch();
    search.setPeriod(period);
    search.setAttempts(attempts);
    // Force to front of the queue if necessary
    if (prioritize) {
        search.setCreated(OffsetDateTime.of(2000, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC));
    }
    coverageSearchRepo.saveAndFlush(search);
    return updateStatus(period, restartDescription, CoverageJobStatus.SUBMITTED);
}
Also used : CoveragePeriod(gov.cms.ab2d.coverage.model.CoveragePeriod) CoverageSearch(gov.cms.ab2d.coverage.model.CoverageSearch)

Example 9 with CoverageSearch

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

the class CoverageServiceImpl method submitSearch.

@Override
public Optional<CoverageSearchEvent> submitSearch(int periodId, int attempts, String description) {
    CoveragePeriod period = findCoveragePeriod(periodId);
    CoverageJobStatus coverageJobStatus = period.getStatus();
    if (coverageJobStatus == CoverageJobStatus.IN_PROGRESS || coverageJobStatus == CoverageJobStatus.SUBMITTED) {
        return Optional.empty();
    }
    // Add to queue of jobs to do
    CoverageSearch search = new CoverageSearch();
    search.setPeriod(period);
    search.setAttempts(attempts);
    coverageSearchRepo.saveAndFlush(search);
    return Optional.of(updateStatus(period, description, CoverageJobStatus.SUBMITTED));
}
Also used : CoveragePeriod(gov.cms.ab2d.coverage.model.CoveragePeriod) CoverageSearch(gov.cms.ab2d.coverage.model.CoverageSearch) CoverageJobStatus(gov.cms.ab2d.coverage.model.CoverageJobStatus)

Example 10 with CoverageSearch

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

the class CoverageServiceImplTest method verifyDBStructure.

@DisplayName("DB structure matches JPA")
@Test
void verifyDBStructure() {
    CoverageSearchEvent cs1 = coverageService.submitSearch(period1Jan.getId(), "testing").get();
    assertNotNull(cs1.getId());
    CoverageSearchEvent csCopy = coverageSearchEventRepo.findById(cs1.getId()).get();
    assertNotNull(csCopy.getCoveragePeriod());
    assertNull(csCopy.getOldStatus());
    assertNotNull(csCopy.getNewStatus());
    assertNotNull(csCopy.getDescription());
    assertEquals(cs1.getCoveragePeriod(), csCopy.getCoveragePeriod());
    assertEquals(cs1.getDescription(), csCopy.getDescription());
    assertEquals(cs1.getNewStatus(), csCopy.getNewStatus());
    // Submitting a coverage search added row to coverage search table
    Optional<CoverageSearch> search = coverageSearchRepo.findFirstByOrderByCreatedAsc();
    assertTrue(search.isPresent());
    assertNotNull(search.get().getCreated());
    assertEquals(period1Jan, search.get().getPeriod());
}
Also used : CoverageSearch(gov.cms.ab2d.coverage.model.CoverageSearch) CoverageSearchEvent(gov.cms.ab2d.coverage.model.CoverageSearchEvent) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

CoverageSearch (gov.cms.ab2d.coverage.model.CoverageSearch)22 CoveragePeriod (gov.cms.ab2d.coverage.model.CoveragePeriod)15 Test (org.junit.jupiter.api.Test)15 CoverageSearchEvent (gov.cms.ab2d.coverage.model.CoverageSearchEvent)14 DisplayName (org.junit.jupiter.api.DisplayName)14 CoverageMapping (gov.cms.ab2d.coverage.model.CoverageMapping)13 ContractToContractCoverageMapping (gov.cms.ab2d.worker.config.ContractToContractCoverageMapping)12 ContractDTO (gov.cms.ab2d.common.dto.ContractDTO)10 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)5 Identifiers (gov.cms.ab2d.coverage.model.Identifiers)4 CoverageJobStatus (gov.cms.ab2d.coverage.model.CoverageJobStatus)3 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 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 CoveragePagingRequest (gov.cms.ab2d.coverage.model.CoveragePagingRequest)1 CoveragePagingResult (gov.cms.ab2d.coverage.model.CoveragePagingResult)1 CoverageSearchDiff (gov.cms.ab2d.coverage.model.CoverageSearchDiff)1