lastomato commented on a change in pull request #13395:
URL: https://github.com/apache/beam/pull/13395#discussion_r527961426



##########
File path: 
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/FhirIO.java
##########
@@ -215,6 +215,16 @@ public static Read readResources() {
     return new Read();
   }
 
+  /**
+   * Search resources from a PCollection
+   *
+   * @return the search
+   * @see Search
+   */
+  public static Search searchResources(String fhirStore) {

Review comment:
       I just realized that your case is totally different from what I thought, 
I expect a single query is used to generate the input to the pipeline, while it 
looks like we are doing something in reverse here, the search parameters are 
from the input. Can you confirm this is indeed the use case you have in mind? 
Please feel free to reach out to me offline.

##########
File path: 
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/HttpHealthcareApiClient.java
##########
@@ -545,6 +529,26 @@ public HttpBody readFhirResource(String resourceId) throws 
IOException {
     return 
client.projects().locations().datasets().fhirStores().fhir().read(resourceId).execute();
   }
 
+  @Override
+  public HttpBody searchFhirResource(
+          String fhirStore,
+          String resourceType,
+          @Nullable Map<String, Object> parameters)
+          throws IOException {
+    SearchResourcesRequest request = new 
SearchResourcesRequest().setResourceType(resourceType);
+    Search search = client
+            .projects()
+            .locations()
+            .datasets()
+            .fhirStores()
+            .fhir()
+            .search(fhirStore, request);

Review comment:
       You will need to handle pagination here, see how this is handled for 
ListMessages: 
https://github.com/apache/beam/blob/master/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/HttpHealthcareApiClient.java#L682.

##########
File path: 
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/FhirIO.java
##########
@@ -215,6 +215,16 @@ public static Read readResources() {
     return new Read();
   }
 
+  /**
+   * Search resources from a PCollection
+   *
+   * @return the search
+   * @see Search
+   */
+  public static Search searchResources(String fhirStore) {

Review comment:
       Should we pass the queries in as well, or is it part of `fhirStore`?

##########
File path: 
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/FhirIO.java
##########
@@ -1388,4 +1398,206 @@ public void deidentify(ProcessContext context)
       }
     }
   }
+
+  /** The type Search. */
+  public static class Search extends PTransform<PCollection<KV<String, 
Map<String, Object>>>, FhirIO.Search.Result> {
+    private static final Logger LOG = LoggerFactory.getLogger(Search.class);
+
+    private final ValueProvider<String> fhirStore;
+
+    /**
+     * Instantiates a new Search.
+     *
+     * @param fhirStore the fhir store
+     */
+    Search(ValueProvider<String> fhirStore) {
+      this.fhirStore = fhirStore;
+    }
+
+    /**
+     * Instantiates a new Search.
+     *
+     * @param fhirStore the fhir store
+     */
+    Search(String fhirStore) {
+      this.fhirStore = StaticValueProvider.of(fhirStore);
+    }
+
+    /** The type Result. */
+    public static class Result implements POutput, PInput {
+      private PCollection<String> resources;
+
+      private PCollection<HealthcareIOError<String>> failedSearches;
+      /** The Pct. */

Review comment:
       nit: maybe remove this comment? Doesn't seem to be very informative.




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