lnogueir commented on code in PR #22152:
URL: https://github.com/apache/beam/pull/22152#discussion_r919248827
##########
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:
Yes. When the healthcare client executes `Deidentify`, it returns a
`healthcare.Operation` which represents a long-running operation that is the
result of a network API call. While the operation's `Done` member variable is
not set to true, it means the operation is still in progress and we need to
poll until it is complete.
--
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]