lnogueir commented on code in PR #22152:
URL: https://github.com/apache/beam/pull/22152#discussion_r920785272


##########
sdks/go/pkg/beam/io/fhirio/common.go:
##########
@@ -91,18 +108,53 @@ func (c *fhirStoreClientImpl) search(storePath, 
resourceType string, queries map
        }
 
        searchRequest := &healthcare.SearchResourcesRequest{}
+       fhirService := 
c.healthcareService.Projects.Locations.Datasets.FhirStores.Fhir
+
        if resourceType == "" {
-               return c.fhirService.Search(storePath, 
searchRequest).Do(queryParams...)
+               return fhirService.Search(storePath, 
searchRequest).Do(queryParams...)
        }
-       return c.fhirService.SearchType(storePath, resourceType, 
searchRequest).Do(queryParams...)
+       return fhirService.SearchType(storePath, resourceType, 
searchRequest).Do(queryParams...)
 }
 
-func newFhirStoreClient() *fhirStoreClientImpl {
-       healthcareService, err := healthcare.NewService(context.Background(), 
option.WithUserAgent(UserAgent))
+func (c *fhirStoreClientImpl) deidentify(srcStorePath, dstStorePath string, 
deidConfig *healthcare.DeidentifyConfig) (operationResults, error) {
+       deidRequest := &healthcare.DeidentifyFhirStoreRequest{
+               Config:           deidConfig,
+               DestinationStore: dstStorePath,
+       }
+       operation, err := 
c.healthcareService.Projects.Locations.Datasets.FhirStores.Deidentify(srcStorePath,
 deidRequest).Do()
        if err != nil {
-               panic("Failed to initialize Google Cloud Healthcare Service. 
Reason: " + err.Error())
+               return operationResults{}, err
+       }
+       return c.pollTilCompleteAndCollectResults(operation)
+}
+
+func (c *fhirStoreClientImpl) pollTilCompleteAndCollectResults(operation 
*healthcare.Operation) (operationResults, error) {
+       var err error
+       for !operation.Done {
+               time.Sleep(15 * time.Second)
+               operation, err = 
c.healthcareService.Projects.Locations.Datasets.Operations.Get(operation.Name).Do()

Review Comment:
   Yea, after inspecting the source code of the Deidentify client function, it 
seems like it could be Done immediately. Updated to poll once before the loop.



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