Skip to content

Commit e11d829

Browse files
Add support for enableHistoryModifications in FHIR Stores (#9823) (#6864)
* initial commit * clean unused code * add test. * Update resource_healthcare_fhir_store_test.go.erb * Update resource_healthcare_fhir_store_test.go.erb * Move to beta example * Update resource_healthcare_fhir_store_test.go.erb * Add version guard * Update resource_healthcare_fhir_store_test.go.erb * Update resource_healthcare_fhir_store_test.go.erb [upstream:5d303ae685495eaa845bc50696ccd6617fd1e3d4] Signed-off-by: Modular Magician <[email protected]>
1 parent 5676a4d commit e11d829

File tree

5 files changed

+46
-0
lines changed

5 files changed

+46
-0
lines changed

.changelog/9823.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
healthcare: added `enable_history_modifications` field to `google_healthcare_fhir_store` resource (beta)
3+
```

google-beta/services/healthcare/resource_healthcare_fhir_store.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ will fail with an error.
120120
** Changing this property may recreate the FHIR store (removing all data) **
121121
122122
** This property can be changed manually in the Google Cloud Healthcare admin console without recreating the FHIR store **`,
123+
},
124+
"enable_history_modifications": {
125+
Type: schema.TypeBool,
126+
Optional: true,
127+
Description: `Whether to allow the ExecuteBundle API to accept history bundles, and directly insert and overwrite historical
128+
resource versions into the FHIR store. If set to false, using history bundles fails with an error.`,
123129
},
124130
"enable_update_create": {
125131
Type: schema.TypeBool,
@@ -383,6 +389,12 @@ func resourceHealthcareFhirStoreCreate(d *schema.ResourceData, meta interface{})
383389
} else if v, ok := d.GetOkExists("enable_history_import"); !tpgresource.IsEmptyValue(reflect.ValueOf(enableHistoryImportProp)) && (ok || !reflect.DeepEqual(v, enableHistoryImportProp)) {
384390
obj["enableHistoryImport"] = enableHistoryImportProp
385391
}
392+
enableHistoryModificationsProp, err := expandHealthcareFhirStoreEnableHistoryModifications(d.Get("enable_history_modifications"), d, config)
393+
if err != nil {
394+
return err
395+
} else if v, ok := d.GetOkExists("enable_history_modifications"); !tpgresource.IsEmptyValue(reflect.ValueOf(enableHistoryModificationsProp)) && (ok || !reflect.DeepEqual(v, enableHistoryModificationsProp)) {
396+
obj["enableHistoryModifications"] = enableHistoryModificationsProp
397+
}
386398
notificationConfigProp, err := expandHealthcareFhirStoreNotificationConfig(d.Get("notification_config"), d, config)
387399
if err != nil {
388400
return err
@@ -515,6 +527,9 @@ func resourceHealthcareFhirStoreRead(d *schema.ResourceData, meta interface{}) e
515527
if err := d.Set("enable_history_import", flattenHealthcareFhirStoreEnableHistoryImport(res["enableHistoryImport"], d, config)); err != nil {
516528
return fmt.Errorf("Error reading FhirStore: %s", err)
517529
}
530+
if err := d.Set("enable_history_modifications", flattenHealthcareFhirStoreEnableHistoryModifications(res["enableHistoryModifications"], d, config)); err != nil {
531+
return fmt.Errorf("Error reading FhirStore: %s", err)
532+
}
518533
if err := d.Set("labels", flattenHealthcareFhirStoreLabels(res["labels"], d, config)); err != nil {
519534
return fmt.Errorf("Error reading FhirStore: %s", err)
520535
}
@@ -562,6 +577,12 @@ func resourceHealthcareFhirStoreUpdate(d *schema.ResourceData, meta interface{})
562577
} else if v, ok := d.GetOkExists("enable_update_create"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, enableUpdateCreateProp)) {
563578
obj["enableUpdateCreate"] = enableUpdateCreateProp
564579
}
580+
enableHistoryModificationsProp, err := expandHealthcareFhirStoreEnableHistoryModifications(d.Get("enable_history_modifications"), d, config)
581+
if err != nil {
582+
return err
583+
} else if v, ok := d.GetOkExists("enable_history_modifications"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, enableHistoryModificationsProp)) {
584+
obj["enableHistoryModifications"] = enableHistoryModificationsProp
585+
}
565586
notificationConfigProp, err := expandHealthcareFhirStoreNotificationConfig(d.Get("notification_config"), d, config)
566587
if err != nil {
567588
return err
@@ -609,6 +630,10 @@ func resourceHealthcareFhirStoreUpdate(d *schema.ResourceData, meta interface{})
609630
updateMask = append(updateMask, "enableUpdateCreate")
610631
}
611632

633+
if d.HasChange("enable_history_modifications") {
634+
updateMask = append(updateMask, "enableHistoryModifications")
635+
}
636+
612637
if d.HasChange("notification_config") {
613638
updateMask = append(updateMask, "notificationConfig")
614639
}
@@ -749,6 +774,10 @@ func flattenHealthcareFhirStoreEnableHistoryImport(v interface{}, d *schema.Reso
749774
return v
750775
}
751776

777+
func flattenHealthcareFhirStoreEnableHistoryModifications(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
778+
return v
779+
}
780+
752781
func flattenHealthcareFhirStoreLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
753782
if v == nil {
754783
return v
@@ -967,6 +996,10 @@ func expandHealthcareFhirStoreEnableHistoryImport(v interface{}, d tpgresource.T
967996
return v, nil
968997
}
969998

999+
func expandHealthcareFhirStoreEnableHistoryModifications(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1000+
return v, nil
1001+
}
1002+
9701003
func expandHealthcareFhirStoreNotificationConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
9711004
l := v.([]interface{})
9721005
if len(l) == 0 || l[0] == nil {

google-beta/services/healthcare/resource_healthcare_fhir_store_generated_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ resource "google_healthcare_fhir_store" "default" {
259259
disable_referential_integrity = false
260260
disable_resource_versioning = false
261261
enable_history_import = false
262+
enable_history_modifications = false
262263
263264
labels = {
264265
label1 = "labelvalue1"

google-beta/services/healthcare/resource_healthcare_fhir_store_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ resource "google_healthcare_fhir_store" "default" {
134134
disable_resource_versioning = false
135135
enable_history_import = false
136136
version = "R4"
137+
138+
enable_history_modifications = false
137139
}
138140
139141
resource "google_healthcare_dataset" "dataset" {
@@ -163,6 +165,7 @@ resource "google_healthcare_fhir_store" "default" {
163165
send_previous_resource_on_delete = true
164166
}
165167
168+
enable_history_modifications = true
166169
labels = {
167170
label1 = "labelvalue1"
168171
}

website/docs/r/healthcare_fhir_store.html.markdown

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ resource "google_healthcare_fhir_store" "default" {
179179
disable_referential_integrity = false
180180
disable_resource_versioning = false
181181
enable_history_import = false
182+
enable_history_modifications = false
182183
183184
labels = {
184185
label1 = "labelvalue1"
@@ -269,6 +270,11 @@ The following arguments are supported:
269270
** Changing this property may recreate the FHIR store (removing all data) **
270271
** This property can be changed manually in the Google Cloud Healthcare admin console without recreating the FHIR store **
271272

273+
* `enable_history_modifications` -
274+
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
275+
Whether to allow the ExecuteBundle API to accept history bundles, and directly insert and overwrite historical
276+
resource versions into the FHIR store. If set to false, using history bundles fails with an error.
277+
272278
* `labels` -
273279
(Optional)
274280
User-supplied key-value pairs used to organize FHIR stores.

0 commit comments

Comments
 (0)