Search in sources :

Example 1 with DeidentifyDatasetRequest

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

the class DatasetDeIdentify method datasetDeIdentify.

public static void datasetDeIdentify(String srcDatasetName, String destDatasetName) throws IOException {
    // String srcDatasetName =
    // String.format(DATASET_NAME, "your-project-id", "your-region-id", "your-src-dataset-id");
    // String destDatasetName =
    // String.format(DATASET_NAME, "your-project-id", "your-region-id", "your-dest-dataset-id");
    // Initialize the client, which will be used to interact with the service.
    CloudHealthcare client = createClient();
    // Configure what information needs to be De-Identified.
    // For more information on de-identifying using tags, please see the following:
    // https://cloud.google.com/healthcare/docs/how-tos/dicom-deidentify#de-identification_using_tags
    TagFilterList tags = new TagFilterList().setTags(Arrays.asList("PatientID"));
    DicomConfig dicomConfig = new DicomConfig().setKeepList(tags);
    DeidentifyConfig config = new DeidentifyConfig().setDicom(dicomConfig);
    // Create the de-identify request and configure any parameters.
    DeidentifyDatasetRequest deidentifyRequest = new DeidentifyDatasetRequest().setDestinationDataset(destDatasetName).setConfig(config);
    Datasets.Deidentify request = client.projects().locations().datasets().deidentify(srcDatasetName, deidentifyRequest);
    // 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("De-identified Dataset created. Response content: " + operation.getResponse());
    } catch (Exception ex) {
        System.out.printf("Error during request execution: %s", ex.toString());
        ex.printStackTrace(System.out);
    }
}
Also used : Datasets(com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets) DeidentifyDatasetRequest(com.google.api.services.healthcare.v1.model.DeidentifyDatasetRequest) DeidentifyConfig(com.google.api.services.healthcare.v1.model.DeidentifyConfig) CloudHealthcare(com.google.api.services.healthcare.v1.CloudHealthcare) Operation(com.google.api.services.healthcare.v1.model.Operation) DicomConfig(com.google.api.services.healthcare.v1.model.DicomConfig) TagFilterList(com.google.api.services.healthcare.v1.model.TagFilterList) IOException(java.io.IOException)

Aggregations

CloudHealthcare (com.google.api.services.healthcare.v1.CloudHealthcare)1 Datasets (com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets)1 DeidentifyConfig (com.google.api.services.healthcare.v1.model.DeidentifyConfig)1 DeidentifyDatasetRequest (com.google.api.services.healthcare.v1.model.DeidentifyDatasetRequest)1 DicomConfig (com.google.api.services.healthcare.v1.model.DicomConfig)1 Operation (com.google.api.services.healthcare.v1.model.Operation)1 TagFilterList (com.google.api.services.healthcare.v1.model.TagFilterList)1 IOException (java.io.IOException)1