You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by GitBox <gi...@apache.org> on 2020/03/13 19:21:26 UTC

[GitHub] [beam] jaketf commented on a change in pull request #11107: [BEAM-9468] [WIP] add HL7v2IO and FhirIO

jaketf commented on a change in pull request #11107: [BEAM-9468] [WIP] add HL7v2IO and FhirIO
URL: https://github.com/apache/beam/pull/11107#discussion_r392424941
 
 

 ##########
 File path: sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/FetchHL7v2Message.java
 ##########
 @@ -0,0 +1,95 @@
+/*
+ * 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.api.services.healthcare.v1alpha2.model.Message;
+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.TupleTag;
+import org.apache.beam.sdk.values.TupleTagList;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * DoFn to fetch a message from an Google Cloud Healthcare HL7v2 store based on msgID
+ *
+ * <p>This DoFn consumes a {@link PCollection<String>} of notifications from the HL7v2 store, and
+ * fetches the actual {@link Message} object based on the id in the notification and will output a
+ * {@link PCollectionTuple} which contains the output and dead-letter {@link PCollection}.
+ *
+ * <p>The {@link PCollectionTuple} output will contain the following {@link PCollection}:
+ *
+ * <ul>
+ *   <li>{@link FetchHL7v2Message#OUT} - Contains all {@link FailsafeElement} records successfully
+ *       read from the HL7v2 store.
+ *   <li>{@link FetchHL7v2Message#DEAD_LETTER} - Contains all {@link FailsafeElement} records which
+ *       failed to be fetched from the HL7v2 store, with error message and stacktrace.
+ * </ul>
+ *
+ * <p>Example:
+ *
+ * <pre>{@code
+ * PipelineOptions options = ...;
+ * Pipeline pipeline = Pipeline.create(options)
+ *
+ * PCollection<String> msgIDs = pipeline.apply(
+ *    "ReadHL7v2Notifications",
+ *    PubsubIO.readStrings().fromSubscription(options.getInputSubscription()));
+ *
+ * PCollectionTuple fetchResults = msgIDs.apply(
+ *    "FetchHL7v2Messages",
+ *    new FetchHL7v2Message;
+ *
+ * // Write errors to your favorite dead letter  queue (e.g. Pub/Sub, GCS, BigQuery)
+ * fetchResults.get(PubsubNotificationToHL7v2Message.DEAD_LETTER)
+ *    .apply("WriteToDeadLetterQueue", ...);
+ *
+ * PCollection<Message> fetchedMessages = fetchResults.get(PubsubNotificationToHL7v2Message.OUT)
+ *    .apply("ExtractFetchedMessage",
+ *    MapElements
+ *        .into(TypeDescriptor.of(Message.class))
+ *        .via(FailsafeElement::getPayload));
+ *
+ * // Go about your happy path transformations.
+ * fetchedMessages.apply("ProcessFetchedMessages", ...)
+ *
+ * }***
+ * </pre>
+ */
+public class FetchHL7v2Message extends PTransform<PCollection<String>, PCollectionTuple> {
 
 Review comment:
   Totally Agreed. This is why I elected to use adaptive throttling in the HL7MessageGetFn.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services