us_core_test_kit 0.3.0 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/lib/us_core_test_kit/custom_groups/v4.0.0/device_udi_pi_test.rb +1 -1
  3. data/lib/us_core_test_kit/custom_groups/v4.0.0/document_reference_custodian_test.rb +1 -1
  4. data/lib/us_core_test_kit/date_search_validation.rb +14 -7
  5. data/lib/us_core_test_kit/generated/v4.0.0/metadata.yml +4 -315
  6. data/lib/us_core_test_kit/generated/v4.0.0/patient/metadata.yml +0 -8
  7. data/lib/us_core_test_kit/generated/v4.0.0/patient/patient_must_support_test.rb +1 -1
  8. data/lib/us_core_test_kit/generated/v4.0.0/smokingstatus/metadata.yml +4 -6
  9. data/lib/us_core_test_kit/generated/v4.0.0/smokingstatus/smokingstatus_patient_category_date_search_test.rb +0 -2
  10. data/lib/us_core_test_kit/generated/v5.0.1/metadata.yml +1922 -3532
  11. data/lib/us_core_test_kit/generated/v5.0.1/observation_sdoh_assessment/metadata.yml +0 -1
  12. data/lib/us_core_test_kit/generated/v5.0.1/patient/metadata.yml +2 -7
  13. data/lib/us_core_test_kit/generated/v5.0.1/patient/patient_must_support_test.rb +2 -1
  14. data/lib/us_core_test_kit/generated/v5.0.1/questionnaire_response/metadata.yml +288 -0
  15. data/lib/us_core_test_kit/generated/v5.0.1/questionnaire_response/questionnaire_response_id_search_test.rb +42 -0
  16. data/lib/us_core_test_kit/generated/v5.0.1/questionnaire_response/questionnaire_response_must_support_test.rb +56 -0
  17. data/lib/us_core_test_kit/generated/v5.0.1/questionnaire_response/questionnaire_response_patient_authored_search_test.rb +49 -0
  18. data/lib/us_core_test_kit/generated/v5.0.1/questionnaire_response/questionnaire_response_patient_questionnaire_search_test.rb +48 -0
  19. data/lib/us_core_test_kit/generated/v5.0.1/questionnaire_response/questionnaire_response_patient_search_test.rb +63 -0
  20. data/lib/us_core_test_kit/generated/v5.0.1/questionnaire_response/questionnaire_response_patient_status_search_test.rb +48 -0
  21. data/lib/us_core_test_kit/generated/v5.0.1/questionnaire_response/questionnaire_response_patient_tag_authored_search_test.rb +50 -0
  22. data/lib/us_core_test_kit/generated/v5.0.1/questionnaire_response/questionnaire_response_patient_tag_search_test.rb +49 -0
  23. data/lib/us_core_test_kit/generated/v5.0.1/questionnaire_response/questionnaire_response_provenance_revinclude_search_test.rb +52 -0
  24. data/lib/us_core_test_kit/generated/v5.0.1/questionnaire_response/questionnaire_response_read_test.rb +26 -0
  25. data/lib/us_core_test_kit/generated/v5.0.1/questionnaire_response/questionnaire_response_reference_resolution_test.rb +39 -0
  26. data/lib/us_core_test_kit/generated/v5.0.1/questionnaire_response/questionnaire_response_validation_test.rb +40 -0
  27. data/lib/us_core_test_kit/generated/v5.0.1/questionnaire_response_group.rb +101 -0
  28. data/lib/us_core_test_kit/generated/v5.0.1/smokingstatus/metadata.yml +4 -6
  29. data/lib/us_core_test_kit/generated/v5.0.1/smokingstatus/smokingstatus_patient_category_date_search_test.rb +0 -2
  30. data/lib/us_core_test_kit/generated/v5.0.1/us_core_test_suite.rb +2 -0
  31. data/lib/us_core_test_kit/generator/group_generator.rb +5 -0
  32. data/lib/us_core_test_kit/generator/group_metadata_extractor.rb +5 -1
  33. data/lib/us_core_test_kit/generator/ig_metadata_extractor.rb +9 -0
  34. data/lib/us_core_test_kit/generator/must_support_metadata_extractor.rb +17 -16
  35. data/lib/us_core_test_kit/generator/special_cases.rb +4 -10
  36. data/lib/us_core_test_kit/read_test.rb +1 -1
  37. data/lib/us_core_test_kit/reference_resolution_test.rb +16 -4
  38. data/lib/us_core_test_kit/search_test.rb +2 -3
  39. data/lib/us_core_test_kit/version.rb +1 -1
  40. metadata +16 -2
@@ -0,0 +1,49 @@
1
+ require_relative '../../../search_test'
2
+ require_relative '../../../generator/group_metadata'
3
+
4
+ module USCoreTestKit
5
+ module USCoreV501
6
+ class QuestionnaireResponsePatientTagSearchTest < Inferno::Test
7
+ include USCoreTestKit::SearchTest
8
+
9
+ title 'Server returns valid results for QuestionnaireResponse search by patient + _tag'
10
+ description %(
11
+ A server SHOULD support searching by
12
+ patient + _tag on the QuestionnaireResponse resource. This test
13
+ will pass if resources are returned and match the search criteria. If
14
+ none are returned, the test is skipped.
15
+
16
+ [US Core Server CapabilityStatement](http://hl7.org/fhir/us/core//CapabilityStatement-us-core-server.html)
17
+
18
+ )
19
+
20
+ id :us_core_v501_questionnaire_response_patient__tag_search_test
21
+ optional
22
+
23
+ input :patient_ids,
24
+ title: 'Patient IDs',
25
+ description: 'Comma separated list of patient IDs that in sum contain all MUST SUPPORT elements'
26
+
27
+ def self.properties
28
+ @properties ||= SearchTestProperties.new(
29
+ resource_type: 'QuestionnaireResponse',
30
+ search_param_names: ['patient', '_tag'],
31
+ possible_status_search: true,
32
+ token_search_params: ['_tag']
33
+ )
34
+ end
35
+
36
+ def self.metadata
37
+ @metadata ||= Generator::GroupMetadata.new(YAML.load_file(File.join(__dir__, 'metadata.yml')))
38
+ end
39
+
40
+ def scratch_resources
41
+ scratch[:questionnaire_response_resources] ||= {}
42
+ end
43
+
44
+ run do
45
+ run_search_test
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,52 @@
1
+ require_relative '../../../search_test'
2
+ require_relative '../../../generator/group_metadata'
3
+
4
+ module USCoreTestKit
5
+ module USCoreV501
6
+ class QuestionnaireResponseProvenanceRevincludeSearchTest < Inferno::Test
7
+ include USCoreTestKit::SearchTest
8
+
9
+ title 'Server returns Provenance resources from QuestionnaireResponse search by patient + revInclude:Provenance:target'
10
+ description %(
11
+ A server SHALL be capable of supporting _revIncludes:Provenance:target.
12
+
13
+ This test will perform a search by patient + revInclude:Provenance:target and
14
+ will pass if a Provenance resource is found in the response.
15
+ %)
16
+
17
+ id :us_core_v501_questionnaire_response_provenance_revinclude_search_test
18
+
19
+ input :patient_ids,
20
+ title: 'Patient IDs',
21
+ description: 'Comma separated list of patient IDs that in sum contain all MUST SUPPORT elements'
22
+
23
+ def properties
24
+ @properties ||= SearchTestProperties.new(
25
+ resource_type: 'QuestionnaireResponse',
26
+ search_param_names: ['patient'],
27
+ possible_status_search: true
28
+ )
29
+ end
30
+
31
+ def self.metadata
32
+ @metadata ||= Generator::GroupMetadata.new(YAML.load_file(File.join(__dir__, 'metadata.yml')))
33
+ end
34
+
35
+ def self.provenance_metadata
36
+ @provenance_metadata ||= Generator::GroupMetadata.new(YAML.load_file(File.join(__dir__, '..', 'provenance', 'metadata.yml')))
37
+ end
38
+
39
+ def scratch_resources
40
+ scratch[:questionnaire_response_resources] ||= {}
41
+ end
42
+
43
+ def scratch_provenance_resources
44
+ scratch[:provenance_resources] ||= {}
45
+ end
46
+
47
+ run do
48
+ run_provenance_revinclude_search_test
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,26 @@
1
+ require_relative '../../../read_test'
2
+
3
+ module USCoreTestKit
4
+ module USCoreV501
5
+ class QuestionnaireResponseReadTest < Inferno::Test
6
+ include USCoreTestKit::ReadTest
7
+
8
+ title 'Server returns correct QuestionnaireResponse resource from QuestionnaireResponse read interaction'
9
+ description 'A server SHALL support the QuestionnaireResponse read interaction.'
10
+
11
+ id :us_core_v501_questionnaire_response_read_test
12
+
13
+ def resource_type
14
+ 'QuestionnaireResponse'
15
+ end
16
+
17
+ def scratch_resources
18
+ scratch[:questionnaire_response_resources] ||= {}
19
+ end
20
+
21
+ run do
22
+ perform_read_test(all_scratch_resources)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,39 @@
1
+ require_relative '../../../reference_resolution_test'
2
+ require_relative '../resource_list'
3
+
4
+ module USCoreTestKit
5
+ module USCoreV501
6
+ class QuestionnaireResponseReferenceResolutionTest < Inferno::Test
7
+ include USCoreTestKit::ReferenceResolutionTest
8
+ include ResourceList
9
+
10
+ title 'MustSupport references within QuestionnaireResponse resources can be read'
11
+ description %(
12
+ This test will attempt to read external references provided within elements
13
+ marked as 'MustSupport', if any are available. Elements which may provide
14
+ external references include:
15
+
16
+ * QuestionnaireResponse.author
17
+ * QuestionnaireResponse.subject
18
+ )
19
+
20
+ id :us_core_v501_questionnaire_response_reference_resolution_test
21
+
22
+ def resource_type
23
+ 'QuestionnaireResponse'
24
+ end
25
+
26
+ def self.metadata
27
+ @metadata ||= Generator::GroupMetadata.new(YAML.load_file(File.join(__dir__, 'metadata.yml')))
28
+ end
29
+
30
+ def scratch_resources
31
+ scratch[:questionnaire_response_resources] ||= {}
32
+ end
33
+
34
+ run do
35
+ perform_reference_resolution_test(scratch_resources[:all])
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,40 @@
1
+ require_relative '../../../validation_test'
2
+
3
+ module USCoreTestKit
4
+ module USCoreV501
5
+ class QuestionnaireResponseValidationTest < Inferno::Test
6
+ include USCoreTestKit::ValidationTest
7
+
8
+ id :us_core_v501_questionnaire_response_validation_test
9
+ title 'QuestionnaireResponse resources returned during previous tests conform to the US Core QuestionnaireResponse Profile'
10
+ description %(
11
+ This test verifies resources returned from the first search conform to
12
+ the [US Core QuestionnaireResponse Profile](http://hl7.org/fhir/us/core/StructureDefinition/us-core-questionnaireresponse).
13
+ Systems must demonstrate at least one valid example in order to pass this test.
14
+
15
+ It verifies the presence of mandatory elements and that elements with
16
+ required bindings contain appropriate values. CodeableConcept element
17
+ bindings will fail if none of their codings have a code/system belonging
18
+ to the bound ValueSet. Quantity, Coding, and code element bindings will
19
+ fail if their code/system are not found in the valueset.
20
+
21
+ )
22
+ output :dar_code_found, :dar_extension_found
23
+
24
+ def resource_type
25
+ 'QuestionnaireResponse'
26
+ end
27
+
28
+ def scratch_resources
29
+ scratch[:questionnaire_response_resources] ||= {}
30
+ end
31
+
32
+ run do
33
+ perform_validation_test(scratch_resources[:all] || [],
34
+ 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-questionnaireresponse',
35
+ '5.0.1',
36
+ skip_if_empty: true)
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,101 @@
1
+ require_relative 'questionnaire_response/questionnaire_response_patient_search_test'
2
+ require_relative 'questionnaire_response/questionnaire_response_id_search_test'
3
+ require_relative 'questionnaire_response/questionnaire_response_patient_authored_search_test'
4
+ require_relative 'questionnaire_response/questionnaire_response_patient_tag_authored_search_test'
5
+ require_relative 'questionnaire_response/questionnaire_response_patient_status_search_test'
6
+ require_relative 'questionnaire_response/questionnaire_response_patient_tag_search_test'
7
+ require_relative 'questionnaire_response/questionnaire_response_patient_questionnaire_search_test'
8
+ require_relative 'questionnaire_response/questionnaire_response_read_test'
9
+ require_relative 'questionnaire_response/questionnaire_response_provenance_revinclude_search_test'
10
+ require_relative 'questionnaire_response/questionnaire_response_validation_test'
11
+ require_relative 'questionnaire_response/questionnaire_response_must_support_test'
12
+ require_relative 'questionnaire_response/questionnaire_response_reference_resolution_test'
13
+
14
+ module USCoreTestKit
15
+ module USCoreV501
16
+ class QuestionnaireResponseGroup < Inferno::TestGroup
17
+ title 'QuestionnaireResponse Tests'
18
+ short_description 'Verify support for the server capabilities required by the US Core QuestionnaireResponse Profile.'
19
+ description %(
20
+ # Background
21
+
22
+ The US Core QuestionnaireResponse sequence verifies that the system under test is
23
+ able to provide correct responses for QuestionnaireResponse queries. These queries
24
+ must contain resources conforming to the US Core QuestionnaireResponse Profile as
25
+ specified in the US Core v5.0.1 Implementation Guide.
26
+
27
+ # Testing Methodology
28
+ ## Searching
29
+ This test sequence will first perform each required search associated
30
+ with this resource. This sequence will perform searches with the
31
+ following parameters:
32
+
33
+ * patient
34
+ * _id
35
+
36
+ ### Search Parameters
37
+ The first search uses the selected patient(s) from the prior launch
38
+ sequence. Any subsequent searches will look for its parameter values
39
+ from the results of the first search. For example, the `identifier`
40
+ search in the patient sequence is performed by looking for an existing
41
+ `Patient.identifier` from any of the resources returned in the `_id`
42
+ search. If a value cannot be found this way, the search is skipped.
43
+
44
+ ### Search Validation
45
+ Inferno will retrieve up to the first 20 bundle pages of the reply for
46
+ QuestionnaireResponse resources and save them for subsequent tests. Each of
47
+ these resources is then checked to see if it matches the searched
48
+ parameters in accordance with [FHIR search
49
+ guidelines](https://www.hl7.org/fhir/search.html). The test will fail,
50
+ for example, if a Patient search for `gender=male` returns a `female`
51
+ patient.
52
+
53
+
54
+ ## Must Support
55
+ Each profile contains elements marked as "must support". This test
56
+ sequence expects to see each of these elements at least once. If at
57
+ least one cannot be found, the test will fail. The test will look
58
+ through the QuestionnaireResponse resources found in the first test for these
59
+ elements.
60
+
61
+ ## Profile Validation
62
+ Each resource returned from the first search is expected to conform to
63
+ the [US Core QuestionnaireResponse Profile](http://hl7.org/fhir/us/core/StructureDefinition/us-core-questionnaireresponse). Each element is checked against
64
+ teminology binding and cardinality requirements.
65
+
66
+ Elements with a required binding are validated against their bound
67
+ ValueSet. If the code/system in the element is not part of the ValueSet,
68
+ then the test will fail.
69
+
70
+ ## Reference Validation
71
+ At least one instance of each external reference in elements marked as
72
+ "must support" within the resources provided by the system must resolve.
73
+ The test will attempt to read each reference found and will fail if no
74
+ read succeeds.
75
+
76
+ )
77
+
78
+ id :us_core_v501_questionnaire_response
79
+ run_as_group
80
+ optional
81
+
82
+
83
+ def self.metadata
84
+ @metadata ||= Generator::GroupMetadata.new(YAML.load_file(File.join(__dir__, 'questionnaire_response', 'metadata.yml')))
85
+ end
86
+
87
+ test from: :us_core_v501_questionnaire_response_patient_search_test
88
+ test from: :us_core_v501_questionnaire_response__id_search_test
89
+ test from: :us_core_v501_questionnaire_response_patient_authored_search_test
90
+ test from: :us_core_v501_questionnaire_response_patient__tag_authored_search_test
91
+ test from: :us_core_v501_questionnaire_response_patient_status_search_test
92
+ test from: :us_core_v501_questionnaire_response_patient__tag_search_test
93
+ test from: :us_core_v501_questionnaire_response_patient_questionnaire_search_test
94
+ test from: :us_core_v501_questionnaire_response_read_test
95
+ test from: :us_core_v501_questionnaire_response_provenance_revinclude_search_test
96
+ test from: :us_core_v501_questionnaire_response_validation_test
97
+ test from: :us_core_v501_questionnaire_response_must_support_test
98
+ test from: :us_core_v501_questionnaire_response_reference_resolution_test
99
+ end
100
+ end
101
+ end
@@ -42,17 +42,15 @@
42
42
  - patient
43
43
  - category
44
44
  - date
45
- :names_not_must_support_or_mandatory:
46
- - date
47
- :must_support_or_mandatory: false
45
+ :names_not_must_support_or_mandatory: []
46
+ :must_support_or_mandatory: true
48
47
  - :expectation: SHOULD
49
48
  :names:
50
49
  - patient
51
50
  - code
52
51
  - date
53
- :names_not_must_support_or_mandatory:
54
- - date
55
- :must_support_or_mandatory: false
52
+ :names_not_must_support_or_mandatory: []
53
+ :must_support_or_mandatory: true
56
54
  - :expectation: SHALL
57
55
  :names:
58
56
  - patient
@@ -18,8 +18,6 @@ none are returned, the test is skipped.
18
18
  )
19
19
 
20
20
  id :us_core_v501_smokingstatus_patient_category_date_search_test
21
- optional
22
-
23
21
  input :patient_ids,
24
22
  title: 'Patient IDs',
25
23
  description: 'Comma separated list of patient IDs that in sum contain all MUST SUPPORT elements'
@@ -37,6 +37,7 @@ require_relative 'pediatric_bmi_for_age_group'
37
37
  require_relative 'head_circumference_percentile_group'
38
38
  require_relative 'body_weight_group'
39
39
  require_relative 'procedure_group'
40
+ require_relative 'questionnaire_response_group'
40
41
  require_relative 'service_request_group'
41
42
  require_relative 'organization_group'
42
43
  require_relative 'practitioner_group'
@@ -120,6 +121,7 @@ module USCoreTestKit
120
121
  group from: :us_core_v501_head_circumference_percentile
121
122
  group from: :us_core_v501_body_weight
122
123
  group from: :us_core_v501_procedure
124
+ group from: :us_core_v501_questionnaire_response
123
125
  group from: :us_core_v501_service_request
124
126
  group from: :us_core_v501_organization
125
127
  group from: :us_core_v501_practitioner
@@ -93,6 +93,11 @@ module USCoreTestKit
93
93
  group_metadata.profile_url
94
94
  end
95
95
 
96
+
97
+ def optional?
98
+ resource_type == 'QuestionnaireResponse'
99
+ end
100
+
96
101
  def generate
97
102
  add_special_tests
98
103
  File.open(output_file_name, 'w') { |f| f.write(output) }
@@ -70,9 +70,13 @@ module USCoreTestKit
70
70
 
71
71
  any_must_support_slices = must_supports[:slices].any? do |slice|
72
72
  # only handle type slices because that is all we need for now
73
+ # for a slice like Observation.effective[x]:effectiveDateTime, the search parameter's expression could be
74
+ # either Observation.effective or Observation.effectiveDateTime.
73
75
  if slice[:discriminator] && slice[:discriminator][:type] == 'type'
74
76
  full_must_support_path = "#{resource}.#{slice[:path].sub('[x]', slice[:discriminator][:code])}"
75
- full_paths.include?(full_must_support_path)
77
+ base_must_support_path = "#{resource}.#{slice[:path].sub('[x]', '')}"
78
+
79
+ full_paths.intersection([full_must_support_path,base_must_support_path]).present?
76
80
  else
77
81
  false
78
82
  end
@@ -9,6 +9,7 @@ module USCoreTestKit
9
9
  def initialize(ig_resources)
10
10
  self.ig_resources = ig_resources
11
11
  add_missing_supported_profiles
12
+ remove_extra_supported_profiles
12
13
  self.metadata = IGMetadata.new
13
14
  end
14
15
 
@@ -51,6 +52,14 @@ module USCoreTestKit
51
52
  end
52
53
  end
53
54
 
55
+ def remove_extra_supported_profiles
56
+ ig_resources.capability_statement.rest.first.resource
57
+ .find { |resource| resource.type == 'Observation' }
58
+ .supportedProfile.delete_if do |profile_url|
59
+ SpecialCases::PROFILES_TO_EXCLUDE.include?(profile_url)
60
+ end
61
+ end
62
+
54
63
  def add_metadata_from_resources
55
64
  metadata.groups =
56
65
  resources_in_capability_statement.flat_map do |resource|
@@ -296,6 +296,7 @@ module USCoreTestKit
296
296
  when '5.0.1'
297
297
  add_patient_uscdi_elements
298
298
  add_document_reference_category_values
299
+ remove_survey_questionnaire_response
299
300
  end
300
301
  end
301
302
 
@@ -374,11 +375,6 @@ module USCoreTestKit
374
375
  choices << { paths: ['location.location', 'serviceProvider'] }
375
376
  when 'MedicationRequest'
376
377
  choices << { paths: ['reportedBoolean', 'reportedReference'] }
377
- when 'Patient'
378
- choices << {
379
- paths: ['name.period.end', 'name.use'],
380
- uscdi_only: true
381
- }
382
378
  end
383
379
  when '5.0.1'
384
380
  case profile.type
@@ -399,13 +395,7 @@ module USCoreTestKit
399
395
  choices << { paths: ['location.location', 'serviceProvider'] }
400
396
  when 'MedicationRequest'
401
397
  choices << { paths: ['reportedBoolean', 'reportedReference'] }
402
- when 'Patient'
403
- choices << {
404
- paths: ['name.period.end', 'name.use'],
405
- uscdi_only: true
406
- }
407
398
  end
408
-
409
399
  end
410
400
 
411
401
  @must_supports[:choices] = choices if choices.present?
@@ -444,11 +434,6 @@ module USCoreTestKit
444
434
  path: 'name.suffix',
445
435
  uscdi_only: true
446
436
  }
447
- @must_supports[:elements] << {
448
- path: 'name.use',
449
- fixed_value: 'old',
450
- uscdi_only: true
451
- }
452
437
  @must_supports[:elements] << {
453
438
  path: 'name.period.end',
454
439
  uscdi_only: true
@@ -482,6 +467,11 @@ module USCoreTestKit
482
467
  fixed_value: 'old',
483
468
  uscdi_only: true
484
469
  }
470
+ @must_supports[:elements] << {
471
+ path: 'name.use',
472
+ fixed_value: 'old',
473
+ uscdi_only: true
474
+ }
485
475
  end
486
476
  end
487
477
 
@@ -492,6 +482,17 @@ module USCoreTestKit
492
482
 
493
483
  slice[:discriminator][:values] << 'clinical-note' if slice.present?
494
484
  end
485
+
486
+ # FHIR-37794 Server systems are not required to support US Core QuestionnaireResponse
487
+ def remove_survey_questionnaire_response
488
+ return unless profile.type == 'Observation' &&
489
+ ['us-core-observation-survey', 'us-core-observation-sdoh-assessment'].include?(profile.id)
490
+
491
+ element = @must_supports[:elements].find { |element| element[:path] == 'derivedFrom' }
492
+ element[:target_profiles].delete_if do |url|
493
+ url == 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-questionnaireresponse'
494
+ end
495
+ end
495
496
  end
496
497
  end
497
498
  end
@@ -4,23 +4,17 @@ module USCoreTestKit
4
4
  RESOURCES_TO_EXCLUDE = [
5
5
  'Location',
6
6
  'Medication',
7
- 'PractitionerRole',
8
- 'QuestionnaireResponse'
7
+ 'PractitionerRole'
9
8
  ].freeze
10
9
 
11
10
  PROFILES_TO_EXCLUDE = [
12
- 'us_core_observation_survey',
13
- 'us_core_vital_signs'
11
+ 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-observation-survey',
12
+ 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-vital-signs'
14
13
  ].freeze
15
14
 
16
15
  class << self
17
- def exclude_resource?(resource)
18
- RESOURCES_TO_EXCLUDE.include? resource
19
- end
20
-
21
16
  def exclude_group?(group)
22
- RESOURCES_TO_EXCLUDE.include?(group.resource) ||
23
- PROFILES_TO_EXCLUDE.include?(group.name)
17
+ RESOURCES_TO_EXCLUDE.include?(group.resource)
24
18
  end
25
19
  end
26
20
  end
@@ -47,7 +47,7 @@ module USCoreTestKit
47
47
  end
48
48
 
49
49
  def no_resources_skip_message
50
- "No #{resource_type} resources appeart to be available. " \
50
+ "No #{resource_type} resources appear to be available. " \
51
51
  'Please use patients with more information.'
52
52
  end
53
53
 
@@ -32,7 +32,7 @@ module USCoreTestKit
32
32
  end
33
33
 
34
34
  def no_resources_skip_message
35
- "No #{resource_type} resources appeart to be available. " \
35
+ "No #{resource_type} resources appear to be available. " \
36
36
  'Please use patients with more information.'
37
37
  end
38
38
 
@@ -76,10 +76,10 @@ module USCoreTestKit
76
76
 
77
77
  if metadata.must_supports[:choices].present?
78
78
  @unresolved_references.delete_if do |reference|
79
- choice_profiles = metadata.must_supports[:choices].find { |choice| choice[:target_profiles].include?(reference[:target_profile]) }
79
+ choice_profiles = metadata.must_supports[:choices].find { |choice| choice[:target_profiles]&.include?(reference[:target_profile]) }
80
80
 
81
81
  choice_profiles.present? &&
82
- choice_profiles[:target_profiles].any? { |profile| @unresolved_references.none? { |element| element[:target_profile] == profile } }
82
+ choice_profiles[:target_profiles]&.any? { |profile| @unresolved_references.none? { |element| element[:target_profile] == profile } }
83
83
  end
84
84
  end
85
85
 
@@ -136,7 +136,19 @@ module USCoreTestKit
136
136
  def resource_is_valid_with_target_profile?(resource, target_profile)
137
137
  return true if target_profile.blank?
138
138
 
139
- resource_is_valid?(resource: resource, profile_url: target_profile)
139
+ # Only need to know if the resource is valid.
140
+ # Calling resource_is_valid? causes validation errors to be logged.
141
+ validator = find_validator(:default)
142
+
143
+ outcome = FHIR::OperationOutcome.new(JSON.parse(validator.validate(resource, target_profile)))
144
+
145
+ message_hashes = outcome.issue&.map { |issue| validator.message_hash_from_issue(issue, resource) } || []
146
+
147
+ message_hashes.concat(validator.additional_validation_messages(resource, target_profile))
148
+
149
+ validator.filter_messages(message_hashes)
150
+
151
+ message_hashes.none? { |message_hash| message_hash[:type] == 'error' }
140
152
  end
141
153
  end
142
154
  end
@@ -609,9 +609,8 @@ module USCoreTestKit
609
609
  # Patient.birthDate does not mandate comparators so cannot be converted
610
610
  # Goal.target-date has day precision
611
611
  # All others have second + time offset precision
612
- if /^\d{4}$/.match?(element) || # YYYY
613
- /^\d{4}-\d{2}$/.match?(element) || # YYYY-MM
614
- (/^\d{4}-\d{2}-\d{2}$/.match?(element) && resource_type != "Goal") # YYYY-MM-DD AND Resource is NOT Goal
612
+ if /^\d{4}(-\d{2})?$/.match?(element) || # YYYY or YYYY-MM
613
+ (/^\d{4}-\d{2}-\d{2}$/.match?(element) && resource_type != "Goal") # YYY-MM-DD AND Resource is NOT Goal
615
614
  "gt#{(DateTime.xmlschema(element)-1).xmlschema}"
616
615
  else
617
616
  element
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module USCoreTestKit
4
- VERSION = '0.3.0'
4
+ VERSION = '0.3.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: us_core_test_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen MacVicar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-17 00:00:00.000000000 Z
11
+ date: 2022-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inferno_core
@@ -1207,6 +1207,20 @@ files:
1207
1207
  - lib/us_core_test_kit/generated/v5.0.1/pulse_oximetry/pulse_oximetry_reference_resolution_test.rb
1208
1208
  - lib/us_core_test_kit/generated/v5.0.1/pulse_oximetry/pulse_oximetry_validation_test.rb
1209
1209
  - lib/us_core_test_kit/generated/v5.0.1/pulse_oximetry_group.rb
1210
+ - lib/us_core_test_kit/generated/v5.0.1/questionnaire_response/metadata.yml
1211
+ - lib/us_core_test_kit/generated/v5.0.1/questionnaire_response/questionnaire_response_id_search_test.rb
1212
+ - lib/us_core_test_kit/generated/v5.0.1/questionnaire_response/questionnaire_response_must_support_test.rb
1213
+ - lib/us_core_test_kit/generated/v5.0.1/questionnaire_response/questionnaire_response_patient_authored_search_test.rb
1214
+ - lib/us_core_test_kit/generated/v5.0.1/questionnaire_response/questionnaire_response_patient_questionnaire_search_test.rb
1215
+ - lib/us_core_test_kit/generated/v5.0.1/questionnaire_response/questionnaire_response_patient_search_test.rb
1216
+ - lib/us_core_test_kit/generated/v5.0.1/questionnaire_response/questionnaire_response_patient_status_search_test.rb
1217
+ - lib/us_core_test_kit/generated/v5.0.1/questionnaire_response/questionnaire_response_patient_tag_authored_search_test.rb
1218
+ - lib/us_core_test_kit/generated/v5.0.1/questionnaire_response/questionnaire_response_patient_tag_search_test.rb
1219
+ - lib/us_core_test_kit/generated/v5.0.1/questionnaire_response/questionnaire_response_provenance_revinclude_search_test.rb
1220
+ - lib/us_core_test_kit/generated/v5.0.1/questionnaire_response/questionnaire_response_read_test.rb
1221
+ - lib/us_core_test_kit/generated/v5.0.1/questionnaire_response/questionnaire_response_reference_resolution_test.rb
1222
+ - lib/us_core_test_kit/generated/v5.0.1/questionnaire_response/questionnaire_response_validation_test.rb
1223
+ - lib/us_core_test_kit/generated/v5.0.1/questionnaire_response_group.rb
1210
1224
  - lib/us_core_test_kit/generated/v5.0.1/related_person/metadata.yml
1211
1225
  - lib/us_core_test_kit/generated/v5.0.1/related_person/related_person_id_search_test.rb
1212
1226
  - lib/us_core_test_kit/generated/v5.0.1/related_person/related_person_must_support_test.rb