pabloem commented on a change in pull request #11702:
URL: https://github.com/apache/beam/pull/11702#discussion_r438404800



##########
File path: 
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/FhirIO.java
##########
@@ -1173,4 +1276,339 @@ public void executeBundles(ProcessContext context) {
       }
     }
   }
+
+  /**
+   * Create resources fhir io . create resources.
+   *
+   * @param <T> the type parameter
+   * @param fhirStore the fhir store
+   * @return the fhir io . create resources
+   */
+  public static <T> FhirIO.CreateResources<T> 
createResources(ValueProvider<String> fhirStore) {
+    return new CreateResources(fhirStore);
+  }
+
+  /**
+   * Create resources fhir io . create resources.
+   *
+   * @param <T> the type parameter
+   * @param fhirStore the fhir store
+   * @return the fhir io . create resources
+   */
+  public static <T> FhirIO.CreateResources<T> createResources(String 
fhirStore) {
+    return new CreateResources(fhirStore);
+  }
+  /**
+   * {@link PTransform} for Creating FHIR resources.
+   *
+   * 
<p>https://cloud.google.com/healthcare/docs/reference/rest/v1beta1/projects.locations.datasets.fhirStores.fhir/create
+   */
+  public static class CreateResources<T> extends PTransform<PCollection<T>, 
Write.Result> {
+    private final String fhirStore;
+    private SerializableFunction<T, String> ifNoneExistFunction;
+    private SerializableFunction<T, String> formatBodyFunction;
+    private SerializableFunction<T, String> typeFunction;
+    private static final Logger LOG = 
LoggerFactory.getLogger(CreateResources.class);
+
+    /**
+     * Instantiates a new Create resources transform.
+     *
+     * @param fhirStore the fhir store
+     */
+    CreateResources(ValueProvider<String> fhirStore) {
+      this.fhirStore = fhirStore.get();
+    }
+
+    /**
+     * Instantiates a new Create resources.
+     *
+     * @param fhirStore the fhir store
+     */
+    CreateResources(String fhirStore) {
+      this.fhirStore = fhirStore;
+    }
+
+    /**
+     * This adds a {@link SerializableFunction} that reads an resource string 
and extracts an
+     * If-None-Exists query for conditional create. Typically this will just 
be extracting an ID to
+     * look for.
+     *
+     * 
<p>https://cloud.google.com/healthcare/docs/reference/rest/v1beta1/projects.locations.datasets.fhirStores.fhir/create
+     *
+     * @param ifNoneExistFunction the if none exist function
+     * @return the create resources
+     */
+    public CreateResources withIfNotExistFunction(
+        SerializableFunction<T, String> ifNoneExistFunction) {
+      this.ifNoneExistFunction = ifNoneExistFunction;
+      return this;
+    }
+
+    /**
+     * This adds a {@link SerializableFunction} that reads an resource string 
and extracts an
+     * resource type.
+     *
+     * 
<p>https://cloud.google.com/healthcare/docs/reference/rest/v1beta1/projects.locations.datasets.fhirStores.fhir/create
+     *
+     * @param typeFunction for extracting type from a resource.
+     * @return the create resources
+     */
+    public CreateResources withTypeFunction(SerializableFunction<T, String> 
typeFunction) {
+      this.typeFunction = typeFunction;
+      return this;
+    }
+    /**
+     * With format body function create resources.
+     *
+     * @param formatBodyFunction the format body function
+     * @return the create resources
+     */
+    public CreateResources withFormatBodyFunction(

Review comment:
       Hm - I am not sure. I feel that `Resource` may be better? Since we take 
in any type, and format a resource that gets inserted? But I trust your 
judgement here.




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


Reply via email to