fbeevikm commented on code in PR #17741:
URL: https://github.com/apache/beam/pull/17741#discussion_r883245460


##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/FhirBundleWithMetadata.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * 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 com.google.auto.value.AutoValue;
+import java.util.Objects;
+import javax.annotation.Nullable;
+import org.apache.beam.sdk.coders.DefaultCoder;
+
+/**
+ * FhirBundleWithMetadata represents a FHIR bundle, with it's metadata (eg. 
source ID like HL7
+ * message path) in JSON format to be executed on any FHIR store. *
+ */
+@DefaultCoder(FhirBundleWithMetadataCoder.class)
+@AutoValue
+public abstract class FhirBundleWithMetadata {
+
+  static Builder builder() {
+    return new AutoValue_FhirBundleWithMetadata.Builder();
+  }
+
+  /**
+   * String representing the source of the Bundle to be written. Used to pass 
source data through
+   * the ExecuteBundles PTransform.
+   */
+  public abstract String getMetadata();
+
+  /** FHIR R4 bundle resource object as a string. */
+  public abstract String getBundle();
+
+  /** HTTP response from the FHIR store after attempting to write the Bundle 
method. */
+  public abstract String getResponse();

Review Comment:
   After discussing with the team, decided to go ahead with 
'FhirBundleResponse' class.



##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/FhirIO.java:
##########
@@ -1524,6 +1551,85 @@ private int parseBundleStatus(String status) {
     }
   }
 
+  /**
+   * ExecuteBundlesResult contains both successfully executed bundles and 
information help debugging
+   * failed executions (eg metadata & error msgs).
+   */
+  public static class ExecuteBundlesResult extends Write.AbstractResult {
+    private final Pipeline pipeline;
+    private final PCollection<FhirBundleWithMetadata> successfulBundles;
+    private final PCollection<HealthcareIOError<FhirBundleWithMetadata>> 
failedBundles;
+
+    private ExecuteBundlesResult(
+        Pipeline pipeline,
+        PCollection<FhirBundleWithMetadata> successfulBundles,
+        PCollection<HealthcareIOError<FhirBundleWithMetadata>> failedBundles) {
+      this.pipeline = pipeline;
+      this.successfulBundles = successfulBundles;
+      this.failedBundles = failedBundles;
+    }
+
+    /**
+     * Entry point for the ExecuteBundlesResult, storing the successful and 
failed bundles and their
+     * metadata.
+     */
+    public static ExecuteBundlesResult in(
+        Pipeline pipeline,
+        PCollection<FhirBundleWithMetadata> successfulBundles,
+        PCollection<HealthcareIOError<FhirBundleWithMetadata>> failedBundles) {
+      return new ExecuteBundlesResult(pipeline, successfulBundles, 
failedBundles);
+    }
+
+    /** Gets successful FhirBundleWithMetadata from execute bundles operation. 
*/
+    public PCollection<FhirBundleWithMetadata> 
getSuccessfulBundlesWithMetadata() {
+      return this.successfulBundles;
+    }
+
+    /**
+     * Gets failed FhirBundleWithMetadata with metadata wrapped inside 
HealthcareIOError. The bundle
+     * field could be null.
+     */
+    public PCollection<HealthcareIOError<FhirBundleWithMetadata>> 
getFailedBundles() {
+      return this.failedBundles;
+    }
+
+    @Override

Review Comment:
   done.



-- 
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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to