use of gov.cms.ab2d.coverage.model.Identifiers 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());
}
use of gov.cms.ab2d.coverage.model.Identifiers in project ab2d by CMSgov.
the class FhirUtils method addMbiIdsToEobs.
public static void addMbiIdsToEobs(IBaseResource eob, CoverageSummary patient, FhirVersion version) {
if (eob == null) {
return;
}
// Add extesions only if beneficiary id is present and known to memberships
Long benId = EobUtils.getPatientId(eob);
if (benId != null && patient != null) {
Identifiers identifiers = patient.getIdentifiers();
// Add each mbi to each eob
if (identifiers.getCurrentMbi() != null) {
IBase currentMbiExtension = ExtensionUtils.createMbiExtension(identifiers.getCurrentMbi(), true, version);
ExtensionUtils.addExtension(eob, currentMbiExtension, version);
}
for (String mbi : identifiers.getHistoricMbis()) {
IBase mbiExtension = ExtensionUtils.createMbiExtension(mbi, false, version);
ExtensionUtils.addExtension(eob, mbiExtension, version);
}
}
}
use of gov.cms.ab2d.coverage.model.Identifiers 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.Identifiers in project ab2d by CMSgov.
the class CoverageServiceImplTest method coverageSummaryWholePeriod.
@DisplayName("Coverage summary whole period or nothing")
@Test
void coverageSummaryWholePeriod() {
/*
* testing-1 is a member for all months (January to April)
* testing-2 is a member for no periods
*/
// Bootstrap coverage periods
coverageService.submitSearch(period1Jan.getId(), "testing");
CoverageSearchEvent inProgressJan = startSearchAndPullEvent();
coverageService.submitSearch(period1Feb.getId(), "testing");
CoverageSearchEvent inProgressFeb = startSearchAndPullEvent();
coverageService.submitSearch(period1March.getId(), "testing");
CoverageSearchEvent inProgressMarch = startSearchAndPullEvent();
coverageService.submitSearch(period1April.getId(), "testing");
CoverageSearchEvent inProgressApril = startSearchAndPullEvent();
Identifiers testing1 = createIdentifier(1L);
coverageService.insertCoverage(inProgressJan.getId(), Set.of(testing1));
coverageService.insertCoverage(inProgressFeb.getId(), Set.of(testing1));
coverageService.insertCoverage(inProgressMarch.getId(), Set.of(testing1));
coverageService.insertCoverage(inProgressApril.getId(), Set.of(testing1));
CoveragePagingRequest pagingRequest = new CoveragePagingRequest(2, null, contract1, jobStartTime);
CoveragePagingResult pagingResult = coverageService.pageCoverage(pagingRequest);
List<CoverageSummary> coverageSummaries = pagingResult.getCoverageSummaries();
assertEquals(1, coverageSummaries.size());
CoverageSummary summary = coverageSummaries.get(0);
assertEquals(testing1.getBeneficiaryId(), summary.getIdentifiers().getBeneficiaryId());
assertEquals(testing1.getCurrentMbi(), summary.getIdentifiers().getCurrentMbi());
assertTrue(summary.getDateRanges().stream().anyMatch(dr -> dr.inRange(START_JAN)));
assertFalse(summary.getDateRanges().stream().anyMatch(dr -> dr.inRange(END_DEC)));
assertTrue(summary.getDateRanges().stream().anyMatch(dr -> dr.inRange(END_APRIL)));
assertFalse(summary.getDateRanges().stream().anyMatch(dr -> dr.inRange(START_MAY)));
}
use of gov.cms.ab2d.coverage.model.Identifiers in project ab2d by CMSgov.
the class CoverageServiceImplTest method diffCoverageWhenFirstSearch.
@DisplayName("Get differences between first search and empty")
@Test
void diffCoverageWhenFirstSearch() {
Set<Identifiers> results1 = Set.of(createIdentifier(1231L), createIdentifier(4561L), createIdentifier(7891L));
coverageService.submitSearch(period1Jan.getId(), "testing");
CoverageSearchEvent inProgress1 = startSearchAndPullEvent();
CoverageSearchEvent savedTo1 = coverageService.insertCoverage(inProgress1.getId(), results1);
assertEquals(inProgress1, savedTo1);
CoverageSearchDiff searchDiff = coverageService.searchDiff(period1Jan.getId());
List<CoverageDelta> deltas = coverageDeltaTestRepository.findAll();
assertTrue(deltas.isEmpty());
assertEquals(3, searchDiff.getCurrentCount());
assertEquals(0, searchDiff.getPreviousCount());
assertEquals(0, searchDiff.getUnchanged());
assertEquals(0, searchDiff.getDeletions());
assertEquals(3, searchDiff.getAdditions());
}
Aggregations