use of gov.cms.ab2d.common.model.Contract in project ab2d by CMSgov.
the class BulkDataAccessAPIUnusualDataTests method testPatientExportWithNoAttestation.
@Test
void testPatientExportWithNoAttestation() throws Exception {
// Valid contract number for sponsor, but no attestation
String token = testUtil.setupContractWithNoAttestation(List.of(SPONSOR_ROLE));
Optional<Contract> contractOptional = contractRepository.findContractByContractNumber(VALID_CONTRACT_NUMBER);
Contract contract = contractOptional.get();
this.mockMvc.perform(get(API_PREFIX_V1 + FHIR_PREFIX + "/Group/" + contract.getContractNumber() + "/$export").contentType(MediaType.APPLICATION_JSON).header("Authorization", "Bearer " + token)).andExpect(status().is(403));
List<LoggableEvent> apiRequestEvents = loggerEventRepository.load(ApiRequestEvent.class);
ApiRequestEvent requestEvent = (ApiRequestEvent) apiRequestEvents.get(0);
List<LoggableEvent> apiResponseEvents = loggerEventRepository.load(ApiResponseEvent.class);
ApiResponseEvent responseEvent = (ApiResponseEvent) apiResponseEvents.get(0);
assertEquals(requestEvent.getRequestId(), responseEvent.getRequestId());
List<LoggableEvent> errorEvents = loggerEventRepository.load(ErrorEvent.class);
ErrorEvent errorEvent = (ErrorEvent) errorEvents.get(0);
assertEquals(ErrorEvent.ErrorType.UNAUTHORIZED_CONTRACT, errorEvent.getErrorType());
assertTrue(UtilMethods.allEmpty(loggerEventRepository.load(ReloadEvent.class), loggerEventRepository.load(ContractSearchEvent.class), loggerEventRepository.load(JobStatusChangeEvent.class), loggerEventRepository.load(FileEvent.class)));
}
use of gov.cms.ab2d.common.model.Contract in project ab2d by CMSgov.
the class CoverageDriverTest method discoverCoveragePeriodsIgnoresTestContracts.
@DisplayName("Ignore contracts marked test")
@Test
void discoverCoveragePeriodsIgnoresTestContracts() {
Contract testContract = dataSetup.setupContract("TST-AFTER-EPOCH", AB2D_EPOCH.toOffsetDateTime().plusMonths(3));
testContract.setUpdateMode(Contract.UpdateMode.NONE);
contractRepo.saveAndFlush(testContract);
try {
driver.discoverCoveragePeriods();
} catch (CoverageDriverException | InterruptedException exception) {
fail("could not queue periods due to driver exception", exception);
}
List<CoveragePeriod> periods = coveragePeriodRepo.findAllByContractNumber(testContract.getContractNumber());
assertTrue(periods.isEmpty());
}
use of gov.cms.ab2d.common.model.Contract in project ab2d by CMSgov.
the class CoverageDriverTest method availableCoverageWhenSinceContainsOnlySuccessful.
/**
* The since date is only relevant for claims data not enrollment data. So even though the since date
* is set the enrollment data must all be up to date before a job can start.
*/
@DisplayName("Do not start an eob job if periods before since are being worked on. Ignore since.")
@Test
void availableCoverageWhenSinceContainsOnlySuccessful() {
Job job = new Job();
job.setCreatedAt(OffsetDateTime.now());
Contract temp = contractRepo.findContractByContractNumber(contractForCoverageDTO.getContractNumber()).get();
job.setContractNumber(temp.getContractNumber());
OffsetDateTime since = OffsetDateTime.of(LocalDate.of(2020, 3, 1), LocalTime.of(0, 0, 0), AB2D_ZONE.getRules().getOffset(Instant.now()));
try {
changeStatus(contractForCoverageDTO, since, CoverageJobStatus.SUCCESSFUL);
LocalDate startMonth = LocalDate.of(2020, 3, 1);
LocalTime startDay = LocalTime.of(0, 0, 0);
job.setSince(OffsetDateTime.of(startMonth, startDay, AB2D_ZONE.getRules().getOffset(Instant.now())));
boolean inProgressBeginningMonth = driver.isCoverageAvailable(job, contract.toDTO());
assertFalse(inProgressBeginningMonth, "eob searches should run when only month after since is successful");
LocalDate endMonth = LocalDate.of(2020, 3, 31);
LocalTime endDay = LocalTime.of(23, 59, 59);
job.setSince(OffsetDateTime.of(endMonth, endDay, AB2D_ZONE.getRules().getOffset(Instant.now())));
boolean inProgressEndMonth = driver.isCoverageAvailable(job, contract.toDTO());
assertFalse(inProgressEndMonth, "eob searches should run when only month after since is successful");
} catch (InterruptedException | CoverageDriverException exception) {
fail("could not check for available coverage", exception);
}
}
use of gov.cms.ab2d.common.model.Contract in project ab2d by CMSgov.
the class ContractProcessorUnitTest method createContract.
private Contract createContract() {
Contract contract = new Contract();
contract.setContractName("CONTRACT_NM_00000");
contract.setContractNumber("CONTRACT_00000");
contract.setAttestedOn(OffsetDateTime.now().minusDays(10));
return contract;
}
use of gov.cms.ab2d.common.model.Contract in project ab2d by CMSgov.
the class JobPreProcessorIntegrationTest method setUp.
@BeforeEach
void setUp() {
MockitoAnnotations.openMocks(this);
LogManager manager = new LogManager(sqlEventLogger, kinesisEventLogger, slackLogger);
cut = new JobPreProcessorImpl(contractWorkerClient, jobRepository, manager, coverageDriver);
Contract tmpContract = new Contract();
tmpContract.setContractNumber(UUID.randomUUID().toString());
tmpContract.setContractName(UUID.randomUUID().toString());
contract = contractRepository.save(tmpContract);
pdpClient = createClient(tmpContract);
job = createJob(pdpClient, contract.getContractNumber());
}
Aggregations