Search in sources :

Example 16 with StartJobDTO

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());
}
Also used : StartJobDTO(gov.cms.ab2d.common.dto.StartJobDTO) MvcResult(org.springframework.test.web.servlet.MvcResult) PdpClient(gov.cms.ab2d.common.model.PdpClient) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 17 with StartJobDTO

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);
}
Also used : StartJobDTO(gov.cms.ab2d.common.dto.StartJobDTO) Parameters(io.swagger.v3.oas.annotations.Parameters) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 18 with StartJobDTO

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);
}
Also used : StartJobDTO(gov.cms.ab2d.common.dto.StartJobDTO) Parameters(io.swagger.v3.oas.annotations.Parameters) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Aggregations

StartJobDTO (gov.cms.ab2d.common.dto.StartJobDTO)18 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)12 ResultActions (org.springframework.test.web.servlet.ResultActions)9 Operation (io.swagger.v3.oas.annotations.Operation)4 Parameters (io.swagger.v3.oas.annotations.Parameters)4 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)4 GetMapping (org.springframework.web.bind.annotation.GetMapping)4 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)4 Test (org.junit.jupiter.api.Test)3 MvcResult (org.springframework.test.web.servlet.MvcResult)3 Contract (gov.cms.ab2d.common.model.Contract)2 PdpClient (gov.cms.ab2d.common.model.PdpClient)2 LoggableEvent (gov.cms.ab2d.eventlogger.LoggableEvent)2 JobPollResult (gov.cms.ab2d.common.dto.JobPollResult)1 ResourceNotFoundException (gov.cms.ab2d.common.service.ResourceNotFoundException)1