Aliraza-N commented on a change in pull request #13137:
URL: https://github.com/apache/beam/pull/13137#discussion_r512071470



##########
File path: 
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/DicomIO.java
##########
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.io.gcp.healthcare;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Map;
+import org.apache.beam.sdk.Pipeline;
+import org.apache.beam.sdk.io.gcp.pubsub.PubsubMessage;
+import org.apache.beam.sdk.transforms.DoFn;
+import org.apache.beam.sdk.transforms.PTransform;
+import org.apache.beam.sdk.transforms.ParDo;
+import org.apache.beam.sdk.values.PCollection;
+import org.apache.beam.sdk.values.PCollectionTuple;
+import org.apache.beam.sdk.values.PInput;
+import org.apache.beam.sdk.values.POutput;
+import org.apache.beam.sdk.values.PValue;
+import org.apache.beam.sdk.values.TupleTag;
+import org.apache.beam.sdk.values.TupleTagList;
+import 
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableMap;
+
+/**
+ * The DicomIO connectors allows Beam pipelines to make calls to the Dicom API 
from Google Cloud
+ * Healthcare. https://cloud.google.com/healthcare/docs/concepts/dicom
+ */
+public class DicomIO {
+
+  /** The type ReadDicomStudyMetadata. */
+  public static class ReadDicomStudyMetadata
+      extends PTransform<PCollection<PubsubMessage>, 
DicomIO.ReadDicomStudyMetadata.Result> {
+
+    /**
+     * This class makes a call to the retrieve metadata endpoint
+     * 
(https://cloud.google.com/healthcare/docs/how-tos/dicomweb#retrieving_metadata 
It is
+     * expecting a PubSub message as input, where the message's body will 
contain the path to the
+     * study. You can learn how to configure PubSub messages to be published 
when an instance is
+     * stored by following: 
https://cloud.google.com/healthcare/docs/how-tos/pubsub. The connector
+     * will output a {@link ReadDicomStudyMetadata.Result} which will contain 
metadata of the study
+     * encoded as a json array.
+     */
+    public ReadDicomStudyMetadata() {}
+
+    /** TupleTag for the main output. */
+    public static final TupleTag<String> METADATA = new TupleTag<String>() {};
+    /** TupleTag for any error response. */
+    public static final TupleTag<String> ERROR_MESSAGE = new 
TupleTag<String>() {};
+
+    public static class Result implements POutput, PInput {
+      private PCollection<String> readResponse;
+
+      private PCollection<String> failedReads;
+
+      /** Contains both the response and error outputs from the 
transformation. */
+      PCollectionTuple pct;
+
+      /**
+       * Create DicomIO.ReadDicomStudyMetadata.Result form PCollectionTuple 
with OUT and DEAD_LETTER
+       * tags.
+       *
+       * @param pct the pct
+       * @return the read result
+       * @throws IllegalArgumentException the illegal argument exception
+       */
+      static DicomIO.ReadDicomStudyMetadata.Result of(PCollectionTuple pct)
+          throws IllegalArgumentException {
+        if (pct.getAll()
+            .keySet()
+            .containsAll((Collection<?>) 
TupleTagList.of(METADATA).and(ERROR_MESSAGE))) {
+          return new DicomIO.ReadDicomStudyMetadata.Result(pct);
+        } else {
+          throw new IllegalArgumentException(
+              "The PCollection tuple must have the 
DicomIO.ReadDicomStudyMetadata.OUT "

Review comment:
       Need to update error message




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to