Search in sources :

Example 6 with StartJobDTO

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());
}
Also used : StartJobDTO(gov.cms.ab2d.common.dto.StartJobDTO) ResultActions(org.springframework.test.web.servlet.ResultActions) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 7 with StartJobDTO

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());
}
Also used : StartJobDTO(gov.cms.ab2d.common.dto.StartJobDTO) ResultActions(org.springframework.test.web.servlet.ResultActions) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 8 with StartJobDTO

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

Example 9 with StartJobDTO

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);
}
Also used : StartJobDTO(gov.cms.ab2d.common.dto.StartJobDTO) ResourceNotFoundException(gov.cms.ab2d.common.service.ResourceNotFoundException) JobPollResult(gov.cms.ab2d.common.dto.JobPollResult)

Example 10 with StartJobDTO

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);
}
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