Search in sources :

Example 1 with ImportResourcesRequest

use of com.google.api.services.healthcare.v1.model.ImportResourcesRequest in project beam by apache.

the class HttpHealthcareApiClient method importFhirResource.

@Override
public Operation importFhirResource(String fhirStore, String gcsSourcePath, @Nullable String contentStructure) throws IOException {
    GoogleCloudHealthcareV1FhirGcsSource gcsSrc = new GoogleCloudHealthcareV1FhirGcsSource();
    gcsSrc.setUri(gcsSourcePath);
    ImportResourcesRequest importRequest = new ImportResourcesRequest();
    importRequest.setGcsSource(gcsSrc).setContentStructure(contentStructure);
    return client.projects().locations().datasets().fhirStores().healthcareImport(fhirStore, importRequest).execute();
}
Also used : ImportResourcesRequest(com.google.api.services.healthcare.v1.model.ImportResourcesRequest) GoogleCloudHealthcareV1FhirGcsSource(com.google.api.services.healthcare.v1.model.GoogleCloudHealthcareV1FhirGcsSource)

Example 2 with ImportResourcesRequest

use of com.google.api.services.healthcare.v1.model.ImportResourcesRequest in project java-docs-samples by GoogleCloudPlatform.

the class FhirStoreImport method fhirStoreImport.

public static void fhirStoreImport(String fhirStoreName, String gcsUri) throws IOException {
    // String fhirStoreName =
    // String.format(
    // FHIR_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-fhir-id");
    // String gcsUri = "gs://your-bucket-id/path/to/destination/dir"
    // Initialize the client, which will be used to interact with the service.
    CloudHealthcare client = createClient();
    // Configure where the store should be imported from.
    GoogleCloudHealthcareV1FhirGcsSource gcsSource = new GoogleCloudHealthcareV1FhirGcsSource().setUri(gcsUri);
    ImportResourcesRequest importRequest = new ImportResourcesRequest().setGcsSource(gcsSource);
    // Create request and configure any parameters.
    FhirStores.CloudHealthcareImport request = client.projects().locations().datasets().fhirStores().healthcareImport(fhirStoreName, importRequest);
    // Execute the request, wait for the operation to complete, and process the results.
    try {
        Operation operation = request.execute();
        while (operation.getDone() == null || !operation.getDone()) {
            // Update the status of the operation with another request.
            // Pause for 500ms between requests.
            Thread.sleep(500);
            operation = client.projects().locations().datasets().operations().get(operation.getName()).execute();
        }
        System.out.println("FHIR store import complete: " + operation.getResponse());
    } catch (Exception ex) {
        System.out.printf("Error during request execution: %s", ex.toString());
        ex.printStackTrace(System.out);
    }
}
Also used : FhirStores(com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.FhirStores) ImportResourcesRequest(com.google.api.services.healthcare.v1.model.ImportResourcesRequest) CloudHealthcare(com.google.api.services.healthcare.v1.CloudHealthcare) Operation(com.google.api.services.healthcare.v1.model.Operation) GoogleCloudHealthcareV1FhirGcsSource(com.google.api.services.healthcare.v1.model.GoogleCloudHealthcareV1FhirGcsSource) IOException(java.io.IOException)

Aggregations

GoogleCloudHealthcareV1FhirGcsSource (com.google.api.services.healthcare.v1.model.GoogleCloudHealthcareV1FhirGcsSource)2 ImportResourcesRequest (com.google.api.services.healthcare.v1.model.ImportResourcesRequest)2 CloudHealthcare (com.google.api.services.healthcare.v1.CloudHealthcare)1 FhirStores (com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.FhirStores)1 Operation (com.google.api.services.healthcare.v1.model.Operation)1 IOException (java.io.IOException)1