Skip to content

Commit

Permalink
Add support for enableHistoryModifications in FHIR Stores (#9823) (#6864
Browse files Browse the repository at this point in the history
)

* 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]>
  • Loading branch information
modular-magician authored Jan 17, 2024
1 parent 5676a4d commit e11d829
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/9823.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
healthcare: added `enable_history_modifications` field to `google_healthcare_fhir_store` resource (beta)
```
33 changes: 33 additions & 0 deletions google-beta/services/healthcare/resource_healthcare_fhir_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ will fail with an error.
** Changing this property may recreate the FHIR store (removing all data) **
** This property can be changed manually in the Google Cloud Healthcare admin console without recreating the FHIR store **`,
},
"enable_history_modifications": {
Type: schema.TypeBool,
Optional: true,
Description: `Whether to allow the ExecuteBundle API to accept history bundles, and directly insert and overwrite historical
resource versions into the FHIR store. If set to false, using history bundles fails with an error.`,
},
"enable_update_create": {
Type: schema.TypeBool,
Expand Down Expand Up @@ -383,6 +389,12 @@ func resourceHealthcareFhirStoreCreate(d *schema.ResourceData, meta interface{})
} else if v, ok := d.GetOkExists("enable_history_import"); !tpgresource.IsEmptyValue(reflect.ValueOf(enableHistoryImportProp)) && (ok || !reflect.DeepEqual(v, enableHistoryImportProp)) {
obj["enableHistoryImport"] = enableHistoryImportProp
}
enableHistoryModificationsProp, err := expandHealthcareFhirStoreEnableHistoryModifications(d.Get("enable_history_modifications"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("enable_history_modifications"); !tpgresource.IsEmptyValue(reflect.ValueOf(enableHistoryModificationsProp)) && (ok || !reflect.DeepEqual(v, enableHistoryModificationsProp)) {
obj["enableHistoryModifications"] = enableHistoryModificationsProp
}
notificationConfigProp, err := expandHealthcareFhirStoreNotificationConfig(d.Get("notification_config"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -515,6 +527,9 @@ func resourceHealthcareFhirStoreRead(d *schema.ResourceData, meta interface{}) e
if err := d.Set("enable_history_import", flattenHealthcareFhirStoreEnableHistoryImport(res["enableHistoryImport"], d, config)); err != nil {
return fmt.Errorf("Error reading FhirStore: %s", err)
}
if err := d.Set("enable_history_modifications", flattenHealthcareFhirStoreEnableHistoryModifications(res["enableHistoryModifications"], d, config)); err != nil {
return fmt.Errorf("Error reading FhirStore: %s", err)
}
if err := d.Set("labels", flattenHealthcareFhirStoreLabels(res["labels"], d, config)); err != nil {
return fmt.Errorf("Error reading FhirStore: %s", err)
}
Expand Down Expand Up @@ -562,6 +577,12 @@ func resourceHealthcareFhirStoreUpdate(d *schema.ResourceData, meta interface{})
} else if v, ok := d.GetOkExists("enable_update_create"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, enableUpdateCreateProp)) {
obj["enableUpdateCreate"] = enableUpdateCreateProp
}
enableHistoryModificationsProp, err := expandHealthcareFhirStoreEnableHistoryModifications(d.Get("enable_history_modifications"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("enable_history_modifications"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, enableHistoryModificationsProp)) {
obj["enableHistoryModifications"] = enableHistoryModificationsProp
}
notificationConfigProp, err := expandHealthcareFhirStoreNotificationConfig(d.Get("notification_config"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -609,6 +630,10 @@ func resourceHealthcareFhirStoreUpdate(d *schema.ResourceData, meta interface{})
updateMask = append(updateMask, "enableUpdateCreate")
}

if d.HasChange("enable_history_modifications") {
updateMask = append(updateMask, "enableHistoryModifications")
}

if d.HasChange("notification_config") {
updateMask = append(updateMask, "notificationConfig")
}
Expand Down Expand Up @@ -749,6 +774,10 @@ func flattenHealthcareFhirStoreEnableHistoryImport(v interface{}, d *schema.Reso
return v
}

func flattenHealthcareFhirStoreEnableHistoryModifications(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}

func flattenHealthcareFhirStoreLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
if v == nil {
return v
Expand Down Expand Up @@ -967,6 +996,10 @@ func expandHealthcareFhirStoreEnableHistoryImport(v interface{}, d tpgresource.T
return v, nil
}

func expandHealthcareFhirStoreEnableHistoryModifications(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func expandHealthcareFhirStoreNotificationConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 || l[0] == nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ resource "google_healthcare_fhir_store" "default" {
disable_referential_integrity = false
disable_resource_versioning = false
enable_history_import = false
enable_history_modifications = false
labels = {
label1 = "labelvalue1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ resource "google_healthcare_fhir_store" "default" {
disable_resource_versioning = false
enable_history_import = false
version = "R4"
enable_history_modifications = false
}
resource "google_healthcare_dataset" "dataset" {
Expand Down Expand Up @@ -163,6 +165,7 @@ resource "google_healthcare_fhir_store" "default" {
send_previous_resource_on_delete = true
}
enable_history_modifications = true
labels = {
label1 = "labelvalue1"
}
Expand Down
6 changes: 6 additions & 0 deletions website/docs/r/healthcare_fhir_store.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ resource "google_healthcare_fhir_store" "default" {
disable_referential_integrity = false
disable_resource_versioning = false
enable_history_import = false
enable_history_modifications = false
labels = {
label1 = "labelvalue1"
Expand Down Expand Up @@ -269,6 +270,11 @@ The following arguments are supported:
** Changing this property may recreate the FHIR store (removing all data) **
** This property can be changed manually in the Google Cloud Healthcare admin console without recreating the FHIR store **

* `enable_history_modifications` -
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
Whether to allow the ExecuteBundle API to accept history bundles, and directly insert and overwrite historical
resource versions into the FHIR store. If set to false, using history bundles fails with an error.

* `labels` -
(Optional)
User-supplied key-value pairs used to organize FHIR stores.
Expand Down

0 comments on commit e11d829

Please sign in to comment.