use of gov.cms.ab2d.coverage.model.CoveragePeriod 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));
}
use of gov.cms.ab2d.coverage.model.CoveragePeriod in project ab2d by CMSgov.
the class CoverageUpdateAndProcessorTest method queueStaleCoverageTimeRanges.
@DisplayName("Queue stale coverages ignores coverage periods with last successful search after a boundary in time")
@Test
void queueStaleCoverageTimeRanges() throws CoverageDriverException, InterruptedException {
coveragePeriodRepo.deleteAll();
OffsetDateTime currentDate = OffsetDateTime.now(DateUtil.AB2D_ZONE);
OffsetDateTime previousSunday = currentDate.truncatedTo(ChronoUnit.DAYS).with(TemporalAdjusters.previousOrSame(DayOfWeek.SUNDAY)).plusSeconds(1);
OffsetDateTime oneMonthAgo = currentDate.minusMonths(1);
OffsetDateTime twoMonthsAgo = currentDate.minusMonths(2);
CoveragePeriod currentMonth = coverageDataSetup.createCoveragePeriod(contract.getContractNumber(), currentDate.getMonthValue(), currentDate.getYear());
currentMonth.setStatus(CoverageJobStatus.SUCCESSFUL);
currentMonth.setLastSuccessfulJob(previousSunday);
coveragePeriodRepo.saveAndFlush(currentMonth);
CoveragePeriod oneMonth = coverageDataSetup.createCoveragePeriod(contract.getContractNumber(), oneMonthAgo.getMonthValue(), oneMonthAgo.getYear());
oneMonth.setStatus(CoverageJobStatus.SUCCESSFUL);
oneMonth.setLastSuccessfulJob(previousSunday);
coveragePeriodRepo.saveAndFlush(oneMonth);
CoveragePeriod twoMonth = coverageDataSetup.createCoveragePeriod(contract.getContractNumber(), twoMonthsAgo.getMonthValue(), twoMonthsAgo.getYear());
twoMonth.setStatus(CoverageJobStatus.SUCCESSFUL);
twoMonth.setLastSuccessfulJob(previousSunday);
coveragePeriodRepo.saveAndFlush(twoMonth);
createEvent(currentMonth, CoverageJobStatus.SUCCESSFUL, previousSunday);
createEvent(oneMonth, CoverageJobStatus.SUCCESSFUL, previousSunday);
createEvent(twoMonth, CoverageJobStatus.SUCCESSFUL, previousSunday);
driver.queueStaleCoveragePeriods();
assertEquals(0, coverageSearchRepo.findAll().size());
}
use of gov.cms.ab2d.coverage.model.CoveragePeriod in project ab2d by CMSgov.
the class CoverageServiceImplTest method countForContracts.
@DisplayName("Count coverage records for a group of contracts")
@Test
void countForContracts() {
coverageService.submitSearch(period1Jan.getId(), "testing");
coverageService.submitSearch(period1Feb.getId(), "testing");
coverageService.submitSearch(period1March.getId(), "testing");
coverageService.submitSearch(period1April.getId(), "testing");
CoveragePeriod period2Feb = dataSetup.createCoveragePeriod("TST-34", 2, 2020);
CoveragePeriod period2March = dataSetup.createCoveragePeriod("TST-34", 3, 2020);
CoveragePeriod period2April = dataSetup.createCoveragePeriod("TST-34", 4, 2020);
CoveragePeriod period2May = dataSetup.createCoveragePeriod("TST-34", 5, 2020);
coverageService.submitSearch(period2Jan.getId(), "testing");
coverageService.submitSearch(period2Feb.getId(), "testing");
coverageService.submitSearch(period2March.getId(), "testing");
coverageService.submitSearch(period2April.getId(), "testing");
coverageService.submitSearch(period2May.getId(), "testing");
CoverageSearchEvent jan1Progress = startSearchAndPullEvent();
startSearchAndPullEvent();
CoverageSearchEvent march1Progress = startSearchAndPullEvent();
CoverageSearchEvent april1Progress = startSearchAndPullEvent();
CoverageSearchEvent jan2Progress = startSearchAndPullEvent();
startSearchAndPullEvent();
CoverageSearchEvent march2Progress = startSearchAndPullEvent();
startSearchAndPullEvent();
CoverageSearchEvent may2Progress = startSearchAndPullEvent();
// Number of beneficiaries shared between months
// large number to attempt to trigger indexing
// for more realistic results
int sharedBeneficiaries = 10000;
Set<Identifiers> fullIdentifiers = new LinkedHashSet<>();
for (long idx = 0; idx < sharedBeneficiaries; idx++) {
fullIdentifiers.add(createIdentifier(idx));
}
Set<Identifiers> halfIdentifiers = fullIdentifiers.stream().limit(5000).collect(toSet());
// Save shared beneficiaries between months
coverageService.insertCoverage(jan1Progress.getId(), fullIdentifiers);
coverageService.insertCoverage(march1Progress.getId(), halfIdentifiers);
coverageService.insertCoverage(april1Progress.getId(), fullIdentifiers);
coverageService.completeSearch(period1Jan.getId(), "testing");
coverageService.completeSearch(period1Feb.getId(), "testing");
coverageService.completeSearch(period1March.getId(), "testing");
coverageService.completeSearch(period1April.getId(), "testing");
coverageService.insertCoverage(jan2Progress.getId(), halfIdentifiers);
coverageService.insertCoverage(march2Progress.getId(), fullIdentifiers);
coverageService.insertCoverage(may2Progress.getId(), halfIdentifiers);
coverageService.completeSearch(period2Jan.getId(), "testing");
coverageService.completeSearch(period2Feb.getId(), "testing");
coverageService.completeSearch(period2March.getId(), "testing");
coverageService.completeSearch(period2April.getId(), "testing");
coverageService.completeSearch(period2May.getId(), "testing");
List<CoverageCount> coverageCounts = coverageService.countBeneficiariesForContracts(List.of(contract1, contract2));
assertNotNull(coverageCounts);
assertEquals(6, coverageCounts.size());
// No duplicate coverage periods or events
assertEquals(coverageCounts.size(), coverageCounts.stream().map(CoverageCount::getCoveragePeriodId).collect(toSet()).size());
assertEquals(coverageCounts.size(), coverageCounts.stream().map(CoverageCount::getCoverageEventId).collect(toSet()).size());
Map<Integer, CoverageCount> coverageCountMap = coverageCounts.stream().collect(Collectors.toMap(CoverageCount::getCoveragePeriodId, Function.identity()));
assertTrue(coverageCountMap.containsKey(period1Jan.getId()));
assertEquals(fullIdentifiers.size(), coverageCountMap.get(period1Jan.getId()).getBeneficiaryCount());
assertFalse(coverageCountMap.containsKey(period1Feb.getId()));
assertTrue(coverageCountMap.containsKey(period1March.getId()));
assertEquals(halfIdentifiers.size(), coverageCountMap.get(period1March.getId()).getBeneficiaryCount());
assertTrue(coverageCountMap.containsKey(period1April.getId()));
assertEquals(fullIdentifiers.size(), coverageCountMap.get(period1April.getId()).getBeneficiaryCount());
assertTrue(coverageCountMap.containsKey(period2Jan.getId()));
assertEquals(halfIdentifiers.size(), coverageCountMap.get(period2Jan.getId()).getBeneficiaryCount());
assertFalse(coverageCountMap.containsKey(period2Feb.getId()));
assertTrue(coverageCountMap.containsKey(period2March.getId()));
assertEquals(fullIdentifiers.size(), coverageCountMap.get(period2March.getId()).getBeneficiaryCount());
assertFalse(coverageCountMap.containsKey(period2April.getId()));
assertTrue(coverageCountMap.containsKey(period2May.getId()));
assertEquals(halfIdentifiers.size(), coverageCountMap.get(period2May.getId()).getBeneficiaryCount());
}
use of gov.cms.ab2d.coverage.model.CoveragePeriod in project ab2d by CMSgov.
the class CoverageServiceImplTest method getCoveragePeriod.
@DisplayName("Get a coverage period")
@Test
void getCoveragePeriod() {
CoveragePeriod period = coverageService.getCoveragePeriod(contract1, JANUARY, YEAR);
assertEquals(period1Jan, period);
}
use of gov.cms.ab2d.coverage.model.CoveragePeriod in project ab2d by CMSgov.
the class CoverageServiceImplTest method getOrCreateInsertsNew.
@DisplayName("Get or create does not insert duplicate period")
@Test
void getOrCreateInsertsNew() {
CoveragePeriod period = coverageService.getCreateIfAbsentCoveragePeriod(contract1, 12, 2020);
coveragePeriodRepo.delete(period);
}
Aggregations