use of com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores.Studies in project beam by apache.
the class HttpHealthcareApiClient method uploadToDicomStore.
@Override
public Empty uploadToDicomStore(String webPath, String filePath) throws IOException, URISyntaxException {
byte[] dcmFile = Files.readAllBytes(Paths.get(filePath));
ByteArrayEntity requestEntity = new ByteArrayEntity(dcmFile);
String uri = String.format("%sv1/%s/dicomWeb/studies", client.getRootUrl(), webPath);
URIBuilder uriBuilder = new URIBuilder(uri).setParameter("access_token", credentials.getAccessToken().getTokenValue());
HttpUriRequest request = RequestBuilder.post(uriBuilder.build()).setEntity(requestEntity).addHeader("Content-Type", "application/dicom").build();
httpClient.execute(request);
return new Empty();
}
use of com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores.Studies in project java-docs-samples by GoogleCloudPlatform.
the class DicomWebRetrieveInstance method dicomWebRetrieveInstance.
public static void dicomWebRetrieveInstance(String dicomStoreName, String dicomWebPath) throws IOException {
// String dicomStoreName =
// String.format(
// DICOM_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-dicom-id");
// String dicomWebPath = String.format(DICOMWEB_PATH, "your-study-id", "your-series-id",
// "your-instance-id");
// Initialize the client, which will be used to interact with the service.
CloudHealthcare client = createClient();
// Create request and configure any parameters.
Instances.RetrieveInstance request = client.projects().locations().datasets().dicomStores().studies().series().instances().retrieveInstance(dicomStoreName, dicomWebPath);
// Execute the request and process the results.
HttpResponse response = request.executeUnparsed();
String outputPath = "instance.dcm";
OutputStream outputStream = new FileOutputStream(new File(outputPath));
try {
response.download(outputStream);
System.out.println("DICOM instance written to file " + outputPath);
} finally {
outputStream.close();
}
if (!response.isSuccessStatusCode()) {
System.err.print(String.format("Exception retrieving DICOM instance: %s\n", response.getStatusMessage()));
throw new RuntimeException();
}
}
use of com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores.Studies in project java-docs-samples by GoogleCloudPlatform.
the class DicomWebSearchStudies method dicomWebSearchStudies.
public static void dicomWebSearchStudies(String dicomStoreName) throws IOException {
// String dicomStoreName =
// String.format(
// DICOM_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-dicom-id");
// Initialize the client, which will be used to interact with the service.
CloudHealthcare client = createClient();
DicomStores.SearchForStudies request = client.projects().locations().datasets().dicomStores().searchForStudies(dicomStoreName, "studies").set("PatientName", "Sally Zhang");
// Execute the request and process the results.
HttpResponse response = request.executeUnparsed();
System.out.println("Studies found: \n" + response.toString());
}
use of com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores.Studies in project java-docs-samples by GoogleCloudPlatform.
the class DicomWebDeleteStudy method dicomWebDeleteStudy.
public static void dicomWebDeleteStudy(String dicomStoreName, String studyId) throws IOException {
// String dicomStoreName =
// String.format(
// DICOM_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-dicom-id");
// String studyId = "your-study-id";
// Initialize the client, which will be used to interact with the service.
CloudHealthcare client = createClient();
// Create request and configure any parameters.
Studies.Delete request = client.projects().locations().datasets().dicomStores().studies().delete(dicomStoreName, "studies/" + studyId);
// Execute the request and process the results.
request.execute();
System.out.println("DICOM study deleted.");
}
use of com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores.Studies in project java-docs-samples by GoogleCloudPlatform.
the class DicomWebRetrieveRendered method dicomWebRetrieveRendered.
public static void dicomWebRetrieveRendered(String dicomStoreName, String dicomWebPath) throws IOException {
// String dicomStoreName =
// String.format(
// DICOM_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-dicom-id");
// String dicomWebPath = String.format(DICOMWEB_PATH, "your-study-id", "your-series-id",
// "your-instance-id");
// Initialize the client, which will be used to interact with the service.
CloudHealthcare client = createClient();
// Create request and configure any parameters.
Instances.RetrieveRendered request = client.projects().locations().datasets().dicomStores().studies().series().instances().retrieveRendered(dicomStoreName, dicomWebPath);
// Execute the request and process the results.
HttpResponse response = request.executeUnparsed();
String outputPath = "image.png";
OutputStream outputStream = new FileOutputStream(new File(outputPath));
try {
response.download(outputStream);
System.out.println("DICOM rendered PNG image written to file " + outputPath);
} finally {
outputStream.close();
}
if (!response.isSuccessStatusCode()) {
System.err.print(String.format("Exception retrieving DICOM rendered image: %s\n", response.getStatusMessage()));
throw new RuntimeException();
}
}
Aggregations