use of gov.cms.ab2d.coverage.model.CoverageSearchEvent in project ab2d by CMSgov.
the class CoverageDriverTest method createEvent.
private CoverageSearchEvent createEvent(CoveragePeriod period, CoverageJobStatus status, OffsetDateTime created) {
CoverageSearchEvent event = new CoverageSearchEvent();
event.setCoveragePeriod(period);
event.setNewStatus(status);
event.setCreated(created);
event.setDescription("testing");
event = coverageSearchEventRepo.saveAndFlush(event);
event.setCreated(created);
coverageSearchEventRepo.saveAndFlush(event);
return event;
}
use of gov.cms.ab2d.coverage.model.CoverageSearchEvent in project ab2d by CMSgov.
the class CoverageMappingCallableTest method filterYear.
@DisplayName("Filter out years that do not match the provided year")
@Test
void filterYear() {
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());
int pastYear = (int) ReflectionTestUtils.getField(coverageCallable, "pastReferenceYear");
assertEquals(10, pastYear);
} catch (Exception exception) {
fail("could not execute basic job with mock client", exception);
}
}
use of gov.cms.ab2d.coverage.model.CoverageSearchEvent 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.CoverageSearchEvent 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.CoverageSearchEvent in project ab2d by CMSgov.
the class CoverageUpdateAndProcessorTest method createEvent.
private CoverageSearchEvent createEvent(CoveragePeriod period, CoverageJobStatus status, OffsetDateTime created) {
CoverageSearchEvent event = new CoverageSearchEvent();
event.setCoveragePeriod(period);
event.setNewStatus(status);
event.setCreated(created);
event.setDescription("testing");
event = coverageSearchEventRepo.saveAndFlush(event);
event.setCreated(created);
coverageSearchEventRepo.saveAndFlush(event);
return event;
}
Aggregations