Skip to content

Commit 19190d8

Browse files
authored
Added validationConfig to healthcare FHIR store. (#15057)
1 parent 64def5a commit 19190d8

File tree

3 files changed

+133
-0
lines changed

3 files changed

+133
-0
lines changed

mmv1/products/healthcare/FhirStore.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ examples:
7676
dataset_name: 'example-dataset'
7777
fhir_store_name: 'example-fhir-store'
7878
pubsub_topic: 'fhir-notifications'
79+
- name: 'healthcare_fhir_store_validation_config'
80+
primary_resource_id: 'default'
81+
vars:
82+
dataset_name: 'example-dataset'
83+
fhir_store_name: 'example-fhir-store'
84+
pubsub_topic: 'fhir-notifications'
7985
parameters:
8086
- name: 'dataset'
8187
type: ResourceRef
@@ -174,6 +180,47 @@ properties:
174180
output: true
175181
item_type:
176182
type: String
183+
- name: 'validationConfig'
184+
type: NestedObject
185+
description: |
186+
Configuration for how to validate incoming FHIR resources against configured profiles.
187+
properties:
188+
- name: 'disableProfileValidation'
189+
type: Boolean
190+
default_value: false
191+
description: |
192+
Whether to disable profile validation for this FHIR store. The default value is false. Set this to true to disable checking incoming resources for conformance against structure definitions in this FHIR store.
193+
- name: 'enabledImplementationGuides'
194+
type: Array
195+
description: |
196+
A list of implementation guide URLs in this FHIR store that are used to configure the profiles to use for validation.
197+
When a URL cannot be resolved (for example, in a type assertion), the server does not return an error.
198+
For example, to use the US Core profiles for validation, set enabledImplementationGuides to ["http://hl7.org/fhir/us/core/ImplementationGuide/ig"]. If enabledImplementationGuides is empty or omitted, then incoming resources are only required to conform to the base FHIR profiles. Otherwise, a resource must conform to at least one profile listed in the global property of one of the enabled ImplementationGuides.
199+
The Cloud Healthcare API does not currently enforce all of the rules in a StructureDefinition. The following rules are supported:
200+
- min/max
201+
- minValue/maxValue
202+
- maxLength
203+
- type
204+
- fixed[x]
205+
- pattern[x] on simple types
206+
- slicing, when using "value" as the discriminator type
207+
item_type:
208+
type: String
209+
- name: 'disableRequiredFieldValidation'
210+
type: Boolean
211+
default_value: false
212+
description: |
213+
Whether to disable required fields validation for incoming resources. The default value is false. Set this to true to disable checking incoming resources for conformance against required fields requirement defined in the FHIR specification. This property only affects resource types that do not have profiles configured for them, any rules in enabled implementation guides will still be enforced.
214+
- name: 'disableReferenceTypeValidation'
215+
type: Boolean
216+
default_value: false
217+
description: |
218+
Whether to disable reference type validation for incoming resources. The default value is false. Set this to true to disable checking incoming resources for conformance against reference type requirement defined in the FHIR specification. This property only affects resource types that do not have profiles configured for them, any rules in enabled implementation guides will still be enforced.
219+
- name: 'disableFhirpathValidation'
220+
type: Boolean
221+
default_value: false
222+
description: |
223+
Whether to disable FHIRPath validation for incoming resources. The default value is false. Set this to true to disable checking incoming resources for conformance against FHIRPath requirement defined in the FHIR specification. This property only affects resource types that do not have profiles configured for them, any rules in enabled implementation guides will still be enforced.
177224
- name: 'complexDataTypeReferenceParsing'
178225
type: Enum
179226
description: |
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
resource "google_healthcare_fhir_store" "default" {
2+
name = "{{index $.Vars "fhir_store_name"}}"
3+
dataset = google_healthcare_dataset.dataset.id
4+
version = "R4"
5+
complex_data_type_reference_parsing = "DISABLED"
6+
7+
enable_update_create = false
8+
disable_referential_integrity = false
9+
disable_resource_versioning = false
10+
enable_history_import = false
11+
default_search_handling_strict = false
12+
13+
notification_configs {
14+
pubsub_topic = google_pubsub_topic.topic.id
15+
}
16+
17+
labels = {
18+
label1 = "labelvalue1"
19+
}
20+
21+
validation_config {
22+
disable_profile_validation = true
23+
enabled_implementation_guides = []
24+
disable_required_field_validation = true
25+
disable_reference_type_validation = true
26+
disable_fhirpath_validation = true
27+
}
28+
}
29+
30+
resource "google_pubsub_topic" "topic" {
31+
name = "{{index $.Vars "pubsub_topic"}}"
32+
}
33+
34+
resource "google_healthcare_dataset" "dataset" {
35+
name = "{{index $.Vars "dataset_name"}}"
36+
location = "us-central1"
37+
}

mmv1/third_party/terraform/services/healthcare/resource_healthcare_fhir_store_test.go.tmpl

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,14 @@ resource "google_healthcare_fhir_store" "default" {
189189
}
190190
{{- end }}
191191

192+
validation_config {
193+
disable_profile_validation = true
194+
enabled_implementation_guides = ["http://hl7.org/fhir/us/core/ImplementationGuide/ig", "http://example.com/SomeCustomIG"]
195+
disable_required_field_validation = true
196+
disable_reference_type_validation = true
197+
disable_fhirpath_validation = true
198+
}
199+
192200
labels = {
193201
label1 = "labelvalue1"
194202
}
@@ -247,6 +255,29 @@ func testAccCheckGoogleHealthcareFhirStoreUpdate(t *testing.T, pubsubTopic strin
247255
}
248256
{{- end }}
249257

258+
if response.ValidationConfig == nil {
259+
return fmt.Errorf("fhirStore 'ValidationConfig' missing: %s", gcpResourceUri)
260+
}
261+
if !response.ValidationConfig.DisableProfileValidation {
262+
return fmt.Errorf("fhirStore 'ValidationConfig.DisableProfileValidation' not updated: %s", gcpResourceUri)
263+
}
264+
if response.ValidationConfig.EnabledImplementationGuides == nil {
265+
return fmt.Errorf("fhirStore 'ValidationConfig.EnabledImplementationGuides' missing: %s", gcpResourceUri)
266+
}
267+
expectedEnabledImplementationGuides := []string{"http://hl7.org/fhir/us/core/ImplementationGuide/ig", "http://example.com/SomeCustomIG"}
268+
if !checkEnabledImplementationGuidesArraysAreEqual(expectedEnabledImplementationGuides, response.ValidationConfig.EnabledImplementationGuides) {
269+
return fmt.Errorf("fhirStore 'ValidationConfig.EnabledImplementationGuides' not updated: %s", gcpResourceUri)
270+
}
271+
if !response.ValidationConfig.DisableRequiredFieldValidation {
272+
return fmt.Errorf("fhirStore 'ValidationConfig.DisableRequiredFieldValidation' not updated: %s", gcpResourceUri)
273+
}
274+
if !response.ValidationConfig.DisableReferenceTypeValidation {
275+
return fmt.Errorf("fhirStore 'ValidationConfig.DisableReferenceTypeValidation' not updated: %s", gcpResourceUri)
276+
}
277+
if !response.ValidationConfig.DisableFhirpathValidation {
278+
return fmt.Errorf("fhirStore 'ValidationConfig.DisableFhirpathValidation' not updated: %s", gcpResourceUri)
279+
}
280+
250281
if !response.EnableUpdateCreate {
251282
return fmt.Errorf("fhirStore 'EnableUpdateCreate' not updated: %s", gcpResourceUri)
252283
}
@@ -277,3 +308,21 @@ func testAccCheckGoogleHealthcareFhirStoreUpdate(t *testing.T, pubsubTopic strin
277308
return nil
278309
}
279310
}
311+
312+
// Returns true if the size and contents (order dependent) of enabledImplementationGuides1 and enabledImplementationGuides2 are identical,
313+
// else false.
314+
func checkEnabledImplementationGuidesArraysAreEqual(enabledImplementationGuides1 []string, enabledImplementationGuides2 []string) bool {
315+
// Same length?
316+
if len(enabledImplementationGuides1) != len(enabledImplementationGuides2) {
317+
return false
318+
}
319+
320+
// Same contents - do NOT sort to ensure order is identical and avoid permadiff risk
321+
for i1, v1 := range enabledImplementationGuides1 {
322+
if v1 != enabledImplementationGuides2[i1] {
323+
return false
324+
}
325+
}
326+
327+
return true
328+
}

0 commit comments

Comments
 (0)