24
24
import com .google .api .services .healthcare .v1 .CloudHealthcare ;
25
25
import com .google .api .services .healthcare .v1 .CloudHealthcare .Projects .Locations .Datasets .FhirStores ;
26
26
import com .google .api .services .healthcare .v1 .CloudHealthcareScopes ;
27
+ import com .google .api .services .healthcare .v1 .model .FhirNotificationConfig ;
27
28
import com .google .api .services .healthcare .v1 .model .FhirStore ;
28
- import com .google .api .services .healthcare .v1 .model .NotificationConfig ;
29
29
import com .google .auth .http .HttpCredentialsAdapter ;
30
30
import com .google .auth .oauth2 .GoogleCredentials ;
31
31
import java .io .IOException ;
@@ -38,51 +38,58 @@ public class FhirStorePatch {
38
38
39
39
public static void fhirStorePatch (String fhirStoreName , String pubsubTopic ) throws IOException {
40
40
// String fhirStoreName =
41
- // String.format(
42
- // FHIR_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-fhir-id");
41
+ // String.format(
42
+ // FHIR_NAME, "your-project-id", "your-region-id", "your-dataset-id",
43
+ // "your-fhir-id");
43
44
// String pubsubTopic = "projects/your-project-id/topics/your-pubsub-topic";
44
45
45
46
// Initialize the client, which will be used to interact with the service.
46
47
CloudHealthcare client = createClient ();
47
48
48
49
// Fetch the initial state of the FHIR store.
49
- FhirStores .Get getRequest =
50
- client .projects ().locations ().datasets ().fhirStores ().get (fhirStoreName );
50
+ FhirStores .Get getRequest = client
51
+ .projects ()
52
+ .locations ()
53
+ .datasets ()
54
+ .fhirStores ()
55
+ .get (fhirStoreName );
51
56
FhirStore store = getRequest .execute ();
52
57
53
- // Update the FhirStore fields as needed as needed. For a full list of FhirStore fields, see:
58
+ // Update the FhirStore fields as needed as needed. For a full list of FhirStore
59
+ // fields, see:
54
60
// https://cloud.google.com/healthcare/docs/reference/rest/v1/projects.locations.datasets.fhirStores#FhirStore
55
- store .setNotificationConfig (new NotificationConfig ().setPubsubTopic (pubsubTopic ));
61
+ FhirNotificationConfig notificationConfig = new FhirNotificationConfig ()
62
+ .setPubsubTopic (pubsubTopic );
63
+ store .setNotificationConfigs (Collections .singletonList (notificationConfig ));
56
64
57
65
// Create request and configure any parameters.
58
- FhirStores .Patch request =
59
- client
60
- .projects ()
61
- .locations ()
62
- .datasets ()
63
- .fhirStores ()
64
- .patch (fhirStoreName , store )
65
- .setUpdateMask ("notificationConfig" );
66
+ FhirStores .Patch request = client
67
+ .projects ()
68
+ .locations ()
69
+ .datasets ()
70
+ .fhirStores ()
71
+ .patch (fhirStoreName , store )
72
+ .setUpdateMask ("notificationConfigs" );
66
73
67
74
// Execute the request and process the results.
68
75
store = request .execute ();
69
- System .out .println ("Fhir store patched: \n " + store .toPrettyString ());
76
+ System .out .println ("FHIR store patched: \n " + store .toPrettyString ());
70
77
}
71
78
72
79
private static CloudHealthcare createClient () throws IOException {
73
80
// Use Application Default Credentials (ADC) to authenticate the requests
74
- // For more information see https://cloud.google.com/docs/authentication/production
75
- GoogleCredentials credential =
76
- GoogleCredentials .getApplicationDefault ()
77
- .createScoped (Collections .singleton (CloudHealthcareScopes .CLOUD_PLATFORM ));
81
+ // For more information see
82
+ // https://cloud.google.com/docs/authentication/production
83
+ GoogleCredentials credential = GoogleCredentials .getApplicationDefault ()
84
+ .createScoped (Collections .singleton (CloudHealthcareScopes .CLOUD_PLATFORM ));
78
85
79
- // Create a HttpRequestInitializer, which will provide a baseline configuration to all requests.
80
- HttpRequestInitializer requestInitializer =
81
- request -> {
82
- new HttpCredentialsAdapter (credential ).initialize (request );
83
- request .setConnectTimeout (60000 ); // 1 minute connect timeout
84
- request .setReadTimeout (60000 ); // 1 minute read timeout
85
- };
86
+ // Create a HttpRequestInitializer, which will provide a baseline configuration
87
+ // to all requests.
88
+ HttpRequestInitializer requestInitializer = request -> {
89
+ new HttpCredentialsAdapter (credential ).initialize (request );
90
+ request .setConnectTimeout (60000 ); // 1 minute connect timeout
91
+ request .setReadTimeout (60000 ); // 1 minute read timeout
92
+ };
86
93
87
94
// Build the client for interacting with the service.
88
95
return new CloudHealthcare .Builder (HTTP_TRANSPORT , JSON_FACTORY , requestInitializer )
0 commit comments