[
https://issues.apache.org/jira/browse/BEAM-9990?focusedWorklogId=443992&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-443992
]
ASF GitHub Bot logged work on BEAM-9990:
----------------------------------------
Author: ASF GitHub Bot
Created on: 10/Jun/20 20:59
Start Date: 10/Jun/20 20:59
Worklog Time Spent: 10m
Work Description: 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:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 443992)
Time Spent: 1h 50m (was: 1h 40m)
> FhirIO should support conditional create / update methods
> ---------------------------------------------------------
>
> Key: BEAM-9990
> URL: https://issues.apache.org/jira/browse/BEAM-9990
> Project: Beam
> Issue Type: Improvement
> Components: io-java-gcp
> Reporter: Jacob Ferriero
> Assignee: Jacob Ferriero
> Priority: P2
> Time Spent: 1h 50m
> Remaining Estimate: 0h
>
> There are many use cases where it is expected that calling executeBundles in
> a distributed environment may fail (e.g. trying to create a resource that
> already exists).
> We should add classes to support the following methods as implementations of
> FhirIO.Write to provide more robust reconciliation strategies for Dead Letter
> Queues involving FhirIO.Write
> https://cloud.google.com/healthcare/docs/reference/rest/v1beta1/projects.locations.datasets.fhirStores.fhir/conditionalUpdate
> https://cloud.google.com/healthcare/docs/reference/rest/v1beta1/projects.locations.datasets.fhirStores.fhir/create
> https://cloud.google.com/healthcare/docs/reference/rest/v1beta1/projects.locations.datasets.fhirStores.fhir/update
--
This message was sent by Atlassian Jira
(v8.3.4#803005)