use of gov.cms.ab2d.coverage.model.CoverageMapping in project ab2d by CMSgov.
the class CoverageMappingCallableTest method trackYears.
@DisplayName("Track distribution of reference years returned to callable")
@Test
void trackYears() {
org.hl7.fhir.dstu3.model.Bundle bundle1 = buildBundle(0, 10, 2020);
bundle1.setLink(singletonList(new org.hl7.fhir.dstu3.model.Bundle.BundleLinkComponent().setRelation(org.hl7.fhir.dstu3.model.Bundle.LINK_NEXT)));
org.hl7.fhir.dstu3.model.Bundle bundle2 = buildBundle(10, 20, 2019);
when(bfdClient.requestPartDEnrolleesFromServer(eq(STU3), anyString(), anyInt(), anyInt())).thenReturn(bundle1);
when(bfdClient.requestNextBundleFromServer(eq(STU3), any(org.hl7.fhir.dstu3.model.Bundle.class))).thenReturn(bundle2);
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 coverageCallable = new CoverageMappingCallable(STU3, mapping, bfdClient, mapping.getPeriod().getYear());
try {
mapping = coverageCallable.call();
assertEquals(10, mapping.getBeneficiaryIds().size());
Map<Integer, Integer> referenceYears = (Map<Integer, Integer>) ReflectionTestUtils.getField(coverageCallable, "referenceYears");
assertTrue(referenceYears.containsKey(2019));
assertTrue(referenceYears.containsKey(2020));
referenceYears.forEach((referenceYear, occurrences) -> {
assertEquals(10, occurrences);
});
} catch (Exception exception) {
fail("could not execute basic job with mock client", exception);
}
}
use of gov.cms.ab2d.coverage.model.CoverageMapping in project ab2d by CMSgov.
the class CoverageMappingCallableTest method callableFunctions.
@DisplayName("Successfully completing marks as done and transfers results")
@Test
void callableFunctions() {
org.hl7.fhir.dstu3.model.Bundle bundle1 = buildBundle(0, 10, 2020);
bundle1.setLink(singletonList(new org.hl7.fhir.dstu3.model.Bundle.BundleLinkComponent().setRelation(org.hl7.fhir.dstu3.model.Bundle.LINK_NEXT)));
org.hl7.fhir.dstu3.model.Bundle bundle2 = buildBundle(10, 20, 2020);
when(bfdClient.requestPartDEnrolleesFromServer(eq(STU3), anyString(), anyInt(), anyInt())).thenReturn(bundle1);
when(bfdClient.requestNextBundleFromServer(eq(STU3), any(org.hl7.fhir.dstu3.model.Bundle.class))).thenReturn(bundle2);
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);
ContractToContractCoverageMapping contractToContractCoverageMapping = new ContractToContractCoverageMapping();
CoverageMapping mapping = new CoverageMapping(cse, search);
CoverageMappingCallable callable = new CoverageMappingCallable(STU3, mapping, bfdClient, mapping.getPeriod().getYear());
assertFalse(callable.isCompleted());
CoverageMapping results = callable.call();
assertEquals(mapping, results);
assertTrue(callable.isCompleted());
assertTrue(mapping.isSuccessful());
assertEquals(20, results.getBeneficiaryIds().size());
}
use of gov.cms.ab2d.coverage.model.CoverageMapping in project ab2d by CMSgov.
the class CoverageMappingCallableTest method multipleMbis.
@DisplayName("Multiple mbis captured")
@Test
void multipleMbis() {
org.hl7.fhir.dstu3.model.Bundle bundle1 = buildBundle(0, 10, 3, 2020);
bundle1.setLink(singletonList(new org.hl7.fhir.dstu3.model.Bundle.BundleLinkComponent().setRelation(org.hl7.fhir.dstu3.model.Bundle.LINK_NEXT)));
org.hl7.fhir.dstu3.model.Bundle bundle2 = buildBundle(10, 20, 3, 2020);
when(bfdClient.requestPartDEnrolleesFromServer(eq(STU3), anyString(), anyInt(), anyInt())).thenReturn(bundle1);
when(bfdClient.requestNextBundleFromServer(eq(STU3), any(org.hl7.fhir.dstu3.model.Bundle.class))).thenReturn(bundle2);
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());
try {
callable.call();
for (Identifiers patient : mapping.getBeneficiaryIds()) {
assertNotNull(patient.getBeneficiaryId());
assertNotNull(patient.getCurrentMbi());
assertEquals(2, patient.getHistoricMbis().size());
}
assertEquals(20, mapping.getBeneficiaryIds().size());
} catch (Exception exception) {
fail("could not execute basic job with mock client", exception);
}
}
use of gov.cms.ab2d.coverage.model.CoverageMapping in project ab2d by CMSgov.
the class CoverageMappingCallableTest method filterMissingIdentifier.
@DisplayName("Filter out patients without identifiers")
@Test
void filterMissingIdentifier() {
org.hl7.fhir.dstu3.model.Bundle bundle1 = buildBundle(0, 10, 2020);
bundle1.setLink(singletonList(new org.hl7.fhir.dstu3.model.Bundle.BundleLinkComponent().setRelation(org.hl7.fhir.dstu3.model.Bundle.LINK_NEXT)));
org.hl7.fhir.dstu3.model.Bundle bundle2 = buildBundle(10, 20, 2020);
bundle2.getEntry().forEach(ec -> {
org.hl7.fhir.dstu3.model.Patient patient = (org.hl7.fhir.dstu3.model.Patient) ec.getResource();
patient.setIdentifier(emptyList());
});
when(bfdClient.requestPartDEnrolleesFromServer(eq(STU3), anyString(), anyInt(), anyInt())).thenReturn(bundle1);
when(bfdClient.requestNextBundleFromServer(eq(STU3), any(org.hl7.fhir.dstu3.model.Bundle.class))).thenReturn(bundle2);
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 coverageCallable = new CoverageMappingCallable(STU3, mapping, bfdClient, mapping.getPeriod().getYear());
try {
mapping = coverageCallable.call();
assertEquals(10, mapping.getBeneficiaryIds().size());
int missingIdentifier = (int) ReflectionTestUtils.getField(coverageCallable, "missingBeneId");
assertEquals(10, missingIdentifier);
} catch (Exception exception) {
fail("could not execute basic job with mock client", exception);
}
}
use of gov.cms.ab2d.coverage.model.CoverageMapping in project ab2d by CMSgov.
the class CoverageMappingCallableTest method exceptionCaught.
@DisplayName("Exceptional behavior leads to failure")
@Test
void exceptionCaught() {
when(bfdClient.requestPartDEnrolleesFromServer(eq(STU3), anyString(), anyInt())).thenThrow(new RuntimeException("exception"));
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());
try {
callable.call();
} catch (Exception exception) {
// ignore exception for sake of test
}
assertFalse(mapping.isSuccessful());
assertTrue(callable.isCompleted());
}
Aggregations