use of gov.cms.ab2d.common.dto.StartJobDTO in project ab2d by CMSgov.
the class AdminAPIPdpClientTests method testCreateClientsJobByContractOnAdminBehalf.
@Test
public void testCreateClientsJobByContractOnAdminBehalf() throws Exception {
setupClient("regularClient", true);
MvcResult mvcResult = this.mockMvc.perform(post(API_PREFIX_V1 + ADMIN_PREFIX + "/job/Z0000").contentType(MediaType.APPLICATION_JSON).header("Authorization", "Bearer " + token)).andReturn();
assertEquals(202, mvcResult.getResponse().getStatus());
String header = mvcResult.getResponse().getHeader(CONTENT_LOCATION);
String jobId = header.substring(header.indexOf("/Job/") + 5, header.indexOf("/$status"));
StartJobDTO startJobDTO = jobClientMock.lookupJob(jobId);
PdpClient jobPdpClient = pdpClientRepository.findAll().stream().filter(pdp -> startJobDTO.getOrganization().equals(pdp.getOrganization())).findFirst().get();
jobClientMock.cleanup(jobId);
dataSetup.queueForCleanup(jobPdpClient);
assertEquals("regularClient", jobPdpClient.getClientId());
}
use of gov.cms.ab2d.common.dto.StartJobDTO in project ab2d by CMSgov.
the class BulkDataAccessAPIV1 method exportAllPatients.
@ResponseStatus(value = HttpStatus.ACCEPTED)
@Parameters(value = { @Parameter(name = PREFER, required = true, in = ParameterIn.HEADER, description = BULK_PREFER, schema = @Schema(type = "string", allowableValues = ASYNC, defaultValue = ASYNC)), @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, schema = @Schema(type = "date-time", description = SINCE_EARLIEST_DATE)) })
@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"))) })
@Operation(summary = BULK_EXPORT)
@GetMapping("/Patient/$export")
public ResponseEntity<Void> exportAllPatients(HttpServletRequest request, @RequestParam(name = TYPE_PARAM, required = false, defaultValue = EOB) String resourceTypes, @RequestParam(name = OUT_FORMAT, required = false, defaultValue = NDJSON_FIRE_CONTENT_TYPE) String outputFormat, @RequestParam(required = false, name = SINCE) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) OffsetDateTime since) {
log.info("Received request to export");
StartJobDTO startJobDTO = apiCommon.checkValidCreateJob(request, null, 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);
}
use of gov.cms.ab2d.common.dto.StartJobDTO in project ab2d by CMSgov.
the class BulkDataAccessAPIV2 method exportAllPatients.
@Operation(summary = BULK_EXPORT)
@Parameters(value = { @Parameter(name = PREFER, required = true, in = ParameterIn.HEADER, description = BULK_PREFER, schema = @Schema(type = "string", allowableValues = ASYNC, defaultValue = ASYNC)), @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_DEFAULT, schema = @Schema(type = "date-time", description = SINCE_EARLIEST_DATE)) })
@ApiResponses(value = { @ApiResponse(responseCode = "202", description = EXPORT_STARTED, headers = @Header(name = CONTENT_LOCATION, description = BULK_RESPONSE, schema = @Schema(type = "string")), content = @Content(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"))) })
@ResponseStatus(value = HttpStatus.ACCEPTED)
@GetMapping("/Patient/$export")
public ResponseEntity<Void> exportAllPatients(HttpServletRequest request, @RequestParam(name = TYPE_PARAM, required = false, defaultValue = EOB) String resourceTypes, @RequestParam(name = OUT_FORMAT, required = false, defaultValue = NDJSON_FIRE_CONTENT_TYPE) String outputFormat, @RequestParam(required = false, name = SINCE) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) OffsetDateTime since) {
log.info("Received request to export");
StartJobDTO startJobDTO = apiCommon.checkValidCreateJob(request, null, since, resourceTypes, outputFormat, R4);
String jobGuid = jobClient.createJob(startJobDTO);
apiCommon.logSuccessfulJobCreation(jobGuid);
return apiCommon.returnStatusForJobCreation(jobGuid, API_PREFIX_V2, (String) request.getAttribute(REQUEST_ID), request);
}
Aggregations