use of gov.cms.ab2d.coverage.model.CoverageSummary in project ab2d by CMSgov.
the class ContractProcessorInvalidPatientTest method testInvalidBenes.
@Test
void testInvalidBenes() throws IOException {
when(mapping.map(any(ContractDTO.class))).thenReturn(new ContractForCoverageDTO(contract.getContractNumber(), contract.getAttestedOn(), ContractForCoverageDTO.ContractType.NORMAL));
org.hl7.fhir.dstu3.model.Bundle b1 = BundleUtils.createBundle(createBundleEntry("1"));
org.hl7.fhir.dstu3.model.Bundle b2 = BundleUtils.createBundle(createBundleEntry("2"));
org.hl7.fhir.dstu3.model.Bundle b4 = BundleUtils.createBundle(createBundleEntry("4"));
when(bfdClient.requestEOBFromServer(eq(STU3), eq(1L), any())).thenReturn(b1);
when(bfdClient.requestEOBFromServer(eq(STU3), eq(2L), any())).thenReturn(b2);
when(bfdClient.requestEOBFromServer(eq(STU3), eq(3L), any())).thenReturn(b4);
when(coverageDriver.numberOfBeneficiariesToProcess(any(Job.class), any(ContractDTO.class))).thenReturn(3);
List<FilterOutByDate.DateRange> dates = singletonList(TestUtil.getOpenRange());
List<CoverageSummary> summaries = List.of(new CoverageSummary(createIdentifierWithoutMbi(1L), null, dates), new CoverageSummary(createIdentifierWithoutMbi(2L), null, dates), new CoverageSummary(createIdentifierWithoutMbi(3L), null, dates));
when(coverageDriver.pageCoverage(any(CoveragePagingRequest.class))).thenReturn(new CoveragePagingResult(summaries, null));
List<JobOutput> outputs = cut.process(job);
assertNotNull(outputs);
assertEquals(1, outputs.size());
String fileName1 = contractId + "_0001.ndjson";
String output1 = outputs.get(0).getFilePath();
assertTrue(output1.equalsIgnoreCase(fileName1));
String actual1 = Files.readString(Path.of(tmpDirFolder.getAbsolutePath() + File.separator + job.getJobUuid() + "/" + output1));
assertTrue(actual1.contains("Patient/1") && actual1.contains("Patient/2"));
assertFalse(actual1.contains("Patient/3") || actual1.contains("Patient/4"));
}
use of gov.cms.ab2d.coverage.model.CoverageSummary in project ab2d by CMSgov.
the class FhirUtilsTest method testAddMbiIdToEobs.
@DisplayName("Add mbi to an eob works and adds in expected format")
@Test
void testAddMbiIdToEobs() {
Long beneId = 1234L;
String mbi = "4567";
org.hl7.fhir.dstu3.model.ExplanationOfBenefit b = new org.hl7.fhir.dstu3.model.ExplanationOfBenefit();
String patientId = "Patient/" + beneId;
org.hl7.fhir.dstu3.model.Reference ref = new org.hl7.fhir.dstu3.model.Reference();
ref.setReference(patientId);
b.setPatient(ref);
FilterOutByDate.DateRange dateRange = FilterOutByDate.getDateRange(1, 1900, 12, Calendar.getInstance().get(Calendar.YEAR));
CoverageSummary summary = new CoverageSummary(createIdentifier(beneId, mbi), null, List.of(dateRange));
FhirUtils.addMbiIdsToEobs(b, summary, STU3);
List<org.hl7.fhir.dstu3.model.Extension> extensions = b.getExtension();
assertNotNull(extensions);
assertEquals(1, extensions.size());
org.hl7.fhir.dstu3.model.Extension ext = extensions.get(0);
assertEquals(ID_EXT, ext.getUrl());
org.hl7.fhir.dstu3.model.Identifier id = (org.hl7.fhir.dstu3.model.Identifier) ext.getValue();
assertNotNull(id);
assertEquals(MBI_ID, id.getSystem());
assertEquals(mbi, id.getValue());
}
use of gov.cms.ab2d.coverage.model.CoverageSummary in project ab2d by CMSgov.
the class FhirUtilsTest method testAddMbiIdsToEobs.
@DisplayName("Add multiple mbis to an eob")
@Test
void testAddMbiIdsToEobs() {
Long beneId = 1234L;
String mbi1 = "456";
String mbi2 = "789";
org.hl7.fhir.dstu3.model.ExplanationOfBenefit b = new org.hl7.fhir.dstu3.model.ExplanationOfBenefit();
String patientId = "Patient/" + beneId;
org.hl7.fhir.dstu3.model.Reference ref = new org.hl7.fhir.dstu3.model.Reference();
ref.setReference(patientId);
b.setPatient(ref);
FilterOutByDate.DateRange dateRange = FilterOutByDate.getDateRange(1, 1900, 12, Calendar.getInstance().get(Calendar.YEAR));
CoverageSummary summary = new CoverageSummary(createIdentifier(beneId, mbi1, mbi2), null, List.of(dateRange));
FhirUtils.addMbiIdsToEobs(b, summary, STU3);
List<org.hl7.fhir.dstu3.model.Extension> extensions = b.getExtension();
assertNotNull(extensions);
assertEquals(2, extensions.size());
for (org.hl7.fhir.dstu3.model.Extension ext : extensions) {
assertEquals(ID_EXT, ext.getUrl());
org.hl7.fhir.dstu3.model.Identifier id = (org.hl7.fhir.dstu3.model.Identifier) ext.getValue();
assertNotNull(id);
assertFalse(id.isEmpty());
assertTrue(id.getValue().equals("456") || id.getValue().equals("789"));
}
}
use of gov.cms.ab2d.coverage.model.CoverageSummary 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.CoverageSummary in project ab2d by CMSgov.
the class CoverageServiceImplTest method selectCoverageOddMembership.
@DisplayName("Coverage summary for odd groupings of months")
@Test
void selectCoverageOddMembership() {
/*
* testing-1 is a member for three months (January, February, April)
* testing-2 is a member for three months (January, March, April)
* testing-3 is a member for two months (February, March)
*/
// 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);
Identifiers testing2 = createIdentifier(2L);
Identifiers testing3 = createIdentifier(3L);
coverageService.insertCoverage(inProgressJan.getId(), Set.of(testing1, testing2));
coverageService.insertCoverage(inProgressFeb.getId(), Set.of(testing1, testing3));
coverageService.insertCoverage(inProgressMarch.getId(), Set.of(testing2, testing3));
coverageService.insertCoverage(inProgressApril.getId(), Set.of(testing1, testing2));
CoveragePagingRequest pagingRequest = new CoveragePagingRequest(3, null, contract1, jobStartTime);
CoveragePagingResult pagingResult = coverageService.pageCoverage(pagingRequest);
List<CoverageSummary> coverageSummaries = pagingResult.getCoverageSummaries();
coverageSummaries.sort(Comparator.comparing(summary -> summary.getIdentifiers().getBeneficiaryId()));
assertEquals(3, coverageSummaries.size());
CoverageSummary summary1 = coverageSummaries.get(0);
assertEquals(1, summary1.getIdentifiers().getBeneficiaryId());
assertTrue(summary1.getDateRanges().stream().anyMatch(dr -> dr.inRange(START_JAN)));
assertTrue(summary1.getDateRanges().stream().anyMatch(dr -> dr.inRange(START_FEB)));
assertFalse(summary1.getDateRanges().stream().anyMatch(dr -> dr.inRange(START_MARCH)));
assertTrue(summary1.getDateRanges().stream().anyMatch(dr -> dr.inRange(START_APRIL)));
assertFalse(summary1.getDateRanges().stream().anyMatch(dr -> dr.inRange(START_MAY)));
CoverageSummary summary2 = coverageSummaries.get(1);
assertEquals(2, summary2.getIdentifiers().getBeneficiaryId());
assertTrue(summary2.getDateRanges().stream().anyMatch(dr -> dr.inRange(START_JAN)));
assertFalse(summary2.getDateRanges().stream().anyMatch(dr -> dr.inRange(START_FEB)));
assertTrue(summary2.getDateRanges().stream().anyMatch(dr -> dr.inRange(START_MARCH)));
assertTrue(summary2.getDateRanges().stream().anyMatch(dr -> dr.inRange(START_APRIL)));
assertFalse(summary2.getDateRanges().stream().anyMatch(dr -> dr.inRange(START_MAY)));
CoverageSummary summary3 = coverageSummaries.get(2);
assertEquals(3, summary3.getIdentifiers().getBeneficiaryId());
assertFalse(summary3.getDateRanges().stream().anyMatch(dr -> dr.inRange(START_JAN)));
assertTrue(summary3.getDateRanges().stream().anyMatch(dr -> dr.inRange(START_FEB)));
assertTrue(summary3.getDateRanges().stream().anyMatch(dr -> dr.inRange(START_MARCH)));
assertFalse(summary3.getDateRanges().stream().anyMatch(dr -> dr.inRange(START_APRIL)));
assertFalse(summary3.getDateRanges().stream().anyMatch(dr -> dr.inRange(START_MAY)));
}
Aggregations