use of gov.cms.ab2d.common.dto.StartJobDTO in project ab2d by CMSgov.
the class BulkDataAccessAPIIntegrationTests method testBasicPatientExportWithHttps.
@Test
void testBasicPatientExportWithHttps() throws Exception {
ResultActions resultActions = this.mockMvc.perform(get(API_PREFIX_V1 + FHIR_PREFIX + PATIENT_EXPORT_PATH).contentType(MediaType.APPLICATION_JSON).header("Authorization", "Bearer " + token).header("X-Forwarded-Proto", "https"));
String jobUuid = jobClientMock.pickAJob();
StartJobDTO startJobDTO = jobClientMock.lookupJob(jobUuid);
String statusUrl = "https://localhost" + API_PREFIX_V1 + FHIR_PREFIX + "/Job/" + jobUuid + "/$status";
resultActions.andExpect(status().isAccepted()).andExpect(header().string(CONTENT_LOCATION, statusUrl));
assertEquals("https://localhost" + API_PREFIX_V1 + FHIR_PREFIX + PATIENT_EXPORT_PATH, startJobDTO.getUrl());
assertEquals(EOB, startJobDTO.getResourceTypes());
assertEquals(pdpClientRepository.findByClientId(TEST_PDP_CLIENT).getOrganization(), startJobDTO.getOrganization());
}
use of gov.cms.ab2d.common.dto.StartJobDTO in project ab2d by CMSgov.
the class BulkDataAccessAPIIntegrationTests method testBasicPatientExportWithContract.
@Test
void testBasicPatientExportWithContract() throws Exception {
Optional<Contract> contractOptional = contractRepository.findContractByContractNumber(VALID_CONTRACT_NUMBER);
Contract contract = contractOptional.get();
ResultActions resultActions = this.mockMvc.perform(get(API_PREFIX_V1 + FHIR_PREFIX + "/Group/" + contract.getContractNumber() + "/$export").contentType(MediaType.APPLICATION_JSON).header("Authorization", "Bearer " + token));
String jobUuid = jobClientMock.pickAJob();
StartJobDTO startJobDTO = jobClientMock.lookupJob(jobUuid);
String statusUrl = "http://localhost" + API_PREFIX_V1 + FHIR_PREFIX + "/Job/" + jobUuid + "/$status";
resultActions.andExpect(status().isAccepted()).andExpect(header().string(CONTENT_LOCATION, statusUrl));
assertEquals("http://localhost" + API_PREFIX_V1 + FHIR_PREFIX + "/Group/" + contract.getContractNumber() + "/$export", startJobDTO.getUrl());
assertNull(startJobDTO.getResourceTypes());
assertEquals(pdpClientRepository.findByClientId(TEST_PDP_CLIENT).getOrganization(), startJobDTO.getOrganization());
}
use of gov.cms.ab2d.common.dto.StartJobDTO in project ab2d by CMSgov.
the class BulkDataAccessAPIV2IntegrationTests method testBasicPatientExportWithHttps.
@Test
void testBasicPatientExportWithHttps() throws Exception {
ResultActions resultActions = this.mockMvc.perform(get(API_PREFIX_V2 + FHIR_PREFIX + PATIENT_EXPORT_PATH).contentType(MediaType.APPLICATION_JSON).header("Authorization", "Bearer " + token).header("X-Forwarded-Proto", "https"));
String jobUuid = jobClientMock.pickAJob();
StartJobDTO startJobDTO = jobClientMock.lookupJob(jobUuid);
String statusUrl = "https://localhost" + API_PREFIX_V2 + FHIR_PREFIX + "/Job/" + jobUuid + "/$status";
resultActions.andExpect(status().isAccepted()).andExpect(header().string(CONTENT_LOCATION, statusUrl));
assertEquals("https://localhost" + API_PREFIX_V2 + FHIR_PREFIX + PATIENT_EXPORT_PATH, startJobDTO.getUrl());
assertEquals(EOB, startJobDTO.getResourceTypes());
assertEquals(pdpClientRepository.findByClientId(TEST_PDP_CLIENT).getOrganization(), startJobDTO.getOrganization());
}
use of gov.cms.ab2d.common.dto.StartJobDTO in project ab2d by CMSgov.
the class JobClientMock method poll.
public JobPollResult poll(boolean admin, String jobUuid, String organization, int delaySeconds) {
if (jobUuid.isBlank()) {
throw new ResourceNotFoundException("No job with jobUuid " + jobUuid + " was found");
}
pollAndUpdateTime(jobUuid, delaySeconds);
StartJobDTO startJobDTO = createdJobs.get(jobUuid);
if (startJobDTO == null) {
throw new ResourceNotFoundException("No job with jobUuid " + jobUuid + " was found");
}
String transactionTime = new org.hl7.fhir.dstu3.model.DateTimeType(OffsetDateTime.now().toString()).toHumanDisplay();
return new JobPollResult(startJobDTO.getUrl(), expectedStatus, progress, transactionTime, expiresAt, jobOutputList);
}
use of gov.cms.ab2d.common.dto.StartJobDTO in project ab2d by CMSgov.
the class BulkDataAccessAPIV1 method exportPatientsWithContract.
@Deprecated
@Operation(summary = BULK_CONTRACT_EXPORT)
@Parameters(value = { @Parameter(name = PREFER, required = true, in = ParameterIn.HEADER, description = BULK_PREFER, schema = @Schema(type = "string", allowableValues = ASYNC, defaultValue = ASYNC)), @Parameter(name = "contractNumber", required = true, in = ParameterIn.PATH, description = CONTRACT_NO, example = "Z0000"), @Parameter(name = TYPE_PARAM, description = BULK_EXPORT_TYPE, in = ParameterIn.QUERY, schema = @Schema(allowableValues = EOB, defaultValue = EOB)), @Parameter(name = OUT_FORMAT, description = BULK_OUTPUT_FORMAT, in = ParameterIn.QUERY, schema = @Schema(allowableValues = { "application/fhir+ndjson", "application/ndjson", "ndjson", "application/zip" }, defaultValue = NDJSON_FIRE_CONTENT_TYPE)), @Parameter(name = SINCE, description = BULK_SINCE, example = SINCE_EARLIEST_DATE, schema = @Schema(type = "date-time")) })
@ApiResponses(value = { @ApiResponse(responseCode = "202", description = EXPORT_STARTED, headers = @Header(name = CONTENT_LOCATION, description = BULK_RESPONSE, schema = @Schema(type = "string"))), @ApiResponse(responseCode = "429", description = MAX_JOBS, headers = @Header(name = CONTENT_LOCATION, description = RUNNING_JOBIDS, schema = @Schema(type = "string")), content = @Content(schema = @Schema(ref = "#/components/schemas/OperationOutcome"))) })
// todo: This endpoint no longer makes sense in the new model where one Okta credential maps to one Contract
@ResponseStatus(value = HttpStatus.ACCEPTED)
@GetMapping("/Group/{contractNumber}/$export")
public ResponseEntity<Void> exportPatientsWithContract(HttpServletRequest request, @PathVariable @NotBlank String contractNumber, @RequestParam(required = false, name = TYPE_PARAM) String resourceTypes, @RequestParam(required = false, name = OUT_FORMAT) String outputFormat, @RequestParam(required = false, name = SINCE) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) OffsetDateTime since) {
MDC.put(CONTRACT_LOG, contractNumber);
log.info("Received request to export by contractNumber");
StartJobDTO startJobDTO = apiCommon.checkValidCreateJob(request, contractNumber, since, resourceTypes, outputFormat, STU3);
String jobGuid = jobClient.createJob(startJobDTO);
apiCommon.logSuccessfulJobCreation(jobGuid);
return apiCommon.returnStatusForJobCreation(jobGuid, API_PREFIX_V1, (String) request.getAttribute(REQUEST_ID), request);
}
Aggregations