Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for enableHistoryModifications in FHIR Stores #6864

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
```
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