onc_certification_g10_test_kit 3.0.1 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/lib/inferno/terminology/expected_manifest.yml +36 -693
  3. data/lib/inferno/terminology/fhir_package_manager.rb +16 -14
  4. data/lib/inferno/terminology/loader.rb +24 -2
  5. data/lib/inferno/terminology/tasks/download_umls.rb +2 -1
  6. data/lib/inferno/terminology/tasks/expand_value_set_to_file.rb +1 -1
  7. data/lib/inferno/terminology/tasks/run_umls_jar.rb +2 -1
  8. data/lib/inferno/terminology/value_set.rb +58 -56
  9. data/lib/onc_certification_g10_test_kit/base_token_refresh_group.rb +2 -0
  10. data/lib/onc_certification_g10_test_kit/bulk_data_group_export_stu1.rb +2 -0
  11. data/lib/onc_certification_g10_test_kit/bulk_data_group_export_stu2.rb +1 -1
  12. data/lib/onc_certification_g10_test_kit/bulk_data_group_export_validation.rb +7 -4
  13. data/lib/onc_certification_g10_test_kit/bulk_export_validation_tester.rb +2 -11
  14. data/lib/onc_certification_g10_test_kit/configuration_checker.rb +22 -0
  15. data/lib/onc_certification_g10_test_kit/export_kick_off_performer.rb +3 -2
  16. data/lib/onc_certification_g10_test_kit/g10_options.rb +46 -0
  17. data/lib/onc_certification_g10_test_kit/incorrectly_permitted_tls_versions_messages_setup_test.rb +34 -0
  18. data/lib/onc_certification_g10_test_kit/limited_scope_grant_test.rb +3 -1
  19. data/lib/onc_certification_g10_test_kit/multi_patient_api_stu1.rb +11 -0
  20. data/lib/onc_certification_g10_test_kit/multi_patient_api_stu2.rb +10 -0
  21. data/lib/onc_certification_g10_test_kit/onc_program_procedure.yml +1502 -658
  22. data/lib/onc_certification_g10_test_kit/profile_selector.rb +34 -24
  23. data/lib/onc_certification_g10_test_kit/resource_access_test.rb +1 -2
  24. data/lib/onc_certification_g10_test_kit/restricted_resource_type_access_group.rb +2 -2
  25. data/lib/onc_certification_g10_test_kit/short_id_manager.rb +46 -0
  26. data/lib/onc_certification_g10_test_kit/short_id_map.yml +1536 -0
  27. data/lib/onc_certification_g10_test_kit/single_patient_api_group.rb +7 -0
  28. data/lib/onc_certification_g10_test_kit/single_patient_us_core_4_api_group.rb +7 -0
  29. data/lib/onc_certification_g10_test_kit/single_patient_us_core_5_api_group.rb +9 -2
  30. data/lib/onc_certification_g10_test_kit/smart_app_launch_invalid_aud_group.rb +2 -2
  31. data/lib/onc_certification_g10_test_kit/smart_ehr_practitioner_app_group.rb +61 -6
  32. data/lib/onc_certification_g10_test_kit/smart_invalid_token_refresh_test.rb +37 -0
  33. data/lib/onc_certification_g10_test_kit/smart_limited_app_group.rb +3 -2
  34. data/lib/onc_certification_g10_test_kit/smart_scopes_test.rb +4 -2
  35. data/lib/onc_certification_g10_test_kit/smart_standalone_patient_app_group.rb +60 -4
  36. data/lib/onc_certification_g10_test_kit/unrestricted_resource_type_access_group.rb +7 -4
  37. data/lib/onc_certification_g10_test_kit/version.rb +1 -1
  38. data/lib/onc_certification_g10_test_kit/visual_inspection_and_attestations_group.rb +88 -2
  39. data/lib/onc_certification_g10_test_kit/well_known_capabilities_test.rb +4 -2
  40. data/lib/onc_certification_g10_test_kit.rb +25 -20
  41. metadata +15 -10
@@ -1,5 +1,9 @@
1
+ require_relative 'g10_options'
2
+
1
3
  module ONCCertificationG10TestKit
2
4
  module ProfileSelector
5
+ include G10Options
6
+
3
7
  def extract_profile(profile)
4
8
  case profile
5
9
  when 'Medication'
@@ -28,8 +32,8 @@ module ONCCertificationG10TestKit
28
32
  def select_profile(resource) # rubocop:disable Metrics/CyclomaticComplexity
29
33
  case resource.resourceType
30
34
  when 'Condition'
31
- case suite_options[:us_core_version]
32
- when 'us_core_5'
35
+ case us_core_version
36
+ when US_CORE_5
33
37
  if resource_contains_category(resource, 'encounter-diagnosis', 'http://terminology.hl7.org/CodeSystem/condition-category')
34
38
  extract_profile('ConditionEncounterDiagnosis')
35
39
  elsif resource_contains_category(resource, 'problem-list-item',
@@ -56,28 +60,28 @@ module ONCCertificationG10TestKit
56
60
  return extract_profile('PulseOximetry') if observation_contains_code(resource, '59408-5')
57
61
 
58
62
  if observation_contains_code(resource, '8289-1')
59
- case suite_options[:us_core_version]
60
- when 'us_core_3'
63
+ case us_core_version
64
+ when US_CORE_3
61
65
  return extract_profile('HeadCircumference')
62
66
  else
63
67
  return extract_profile('HeadCircumferencePercentile')
64
68
  end
65
69
  end
66
70
 
67
- return extract_profile('HeadCircumference') if observation_contains_code(resource, '9843-4')
71
+ if observation_contains_code(resource, '9843-4') && !using_us_core_3?
72
+ return extract_profile('HeadCircumference')
73
+ end
68
74
 
69
75
  # FHIR Vital Signs profiles: https://www.hl7.org/fhir/observation-vitalsigns.html
70
76
  # Vital Signs Panel, Oxygen Saturation are not required by USCDI
71
77
  # Body Mass Index is replaced by :pediatric_bmi_age Profile
72
78
  # Systolic Blood Pressure, Diastolic Blood Pressure are covered by :blood_pressure Profile
73
79
  # Head Circumference is replaced by US Core Head Occipital-frontal Circumference Percentile Profile
74
- if observation_contains_code(resource, '39156-5') && suite_options[:us_core_version] != 'us_core_3'
75
- return extract_profile('Bmi')
76
- end
80
+ return extract_profile('Bmi') if observation_contains_code(resource, '39156-5') && !using_us_core_3?
77
81
 
78
82
  if observation_contains_code(resource, '85354-9')
79
- case suite_options[:us_core_version]
80
- when 'us_core_3'
83
+ case us_core_version
84
+ when US_CORE_3
81
85
  return extract_profile('Bp')
82
86
  else
83
87
  return extract_profile('BloodPressure')
@@ -85,8 +89,8 @@ module ONCCertificationG10TestKit
85
89
  end
86
90
 
87
91
  if observation_contains_code(resource, '8302-2')
88
- case suite_options[:us_core_version]
89
- when 'us_core_3'
92
+ case us_core_version
93
+ when US_CORE_3
90
94
  return extract_profile('Bodyheight')
91
95
  else
92
96
  return extract_profile('BodyHeight')
@@ -94,8 +98,8 @@ module ONCCertificationG10TestKit
94
98
  end
95
99
 
96
100
  if observation_contains_code(resource, '8310-5')
97
- case suite_options[:us_core_version]
98
- when 'us_core_3'
101
+ case us_core_version
102
+ when US_CORE_3
99
103
  return extract_profile('Bodytemp')
100
104
  else
101
105
  return extract_profile('BodyTemperature')
@@ -103,8 +107,8 @@ module ONCCertificationG10TestKit
103
107
  end
104
108
 
105
109
  if observation_contains_code(resource, '29463-7')
106
- case suite_options[:us_core_version]
107
- when 'us_core_3'
110
+ case us_core_version
111
+ when US_CORE_3
108
112
  return extract_profile('Bodyweight')
109
113
  else
110
114
  return extract_profile('BodyWeight')
@@ -112,8 +116,8 @@ module ONCCertificationG10TestKit
112
116
  end
113
117
 
114
118
  if observation_contains_code(resource, '8867-4')
115
- case suite_options[:us_core_version]
116
- when 'us_core_3'
119
+ case us_core_version
120
+ when US_CORE_3
117
121
  return extract_profile('Heartrate')
118
122
  else
119
123
  return extract_profile('HeartRate')
@@ -121,31 +125,37 @@ module ONCCertificationG10TestKit
121
125
  end
122
126
 
123
127
  if observation_contains_code(resource, '9279-1')
124
- case suite_options[:us_core_version]
125
- when 'us_core_3'
128
+ case us_core_version
129
+ when US_CORE_3
126
130
  return extract_profile('Resprate')
127
131
  else
128
132
  return extract_profile('RespiratoryRate')
129
133
  end
130
134
  end
131
135
 
132
- if suite_options[:us_core_version] == 'us_core_5' &&
136
+ if using_us_core_5? &&
133
137
  resource_contains_category(
134
138
  resource, 'clinical-test', 'http://terminology.hl7.org/CodeSystem/observation-category'
135
139
  )
136
140
  return extract_profile('ObservationClinicalTest')
137
141
  end
138
142
 
139
- if suite_options[:us_core_version] == 'us_core_5' && observation_contains_code(resource, '76690-7')
143
+ if using_us_core_5? && observation_contains_code(resource, '76690-7')
140
144
  return extract_profile('ObservationSexualOrientation')
141
145
  end
142
146
 
143
- if suite_options[:us_core_version] == 'us_core_5' &&
147
+ if using_us_core_5? &&
144
148
  resource_contains_category(resource, 'social-history',
145
149
  'http://terminology.hl7.org/CodeSystem/observation-category')
146
150
  return extract_profile('ObservationSocialHistory')
147
151
  end
148
152
 
153
+ if using_us_core_5? &&
154
+ resource_contains_category(resource, 'imaging',
155
+ 'http://terminology.hl7.org/CodeSystem/observation-category')
156
+ return extract_profile('ObservationImaging')
157
+ end
158
+
149
159
  # We will simply match all Observations of category "survey" to SDOH,
150
160
  # and do not look at the category "sdoh". US Core spec team says that
151
161
  # support for the "sdoh" category is limited, and the validation rules
@@ -157,7 +167,7 @@ module ONCCertificationG10TestKit
157
167
  # `resource_contains_category(resource, 'sdoh',
158
168
  # 'http://terminology.hl7.org/CodeSystem/observation-category') &&`
159
169
  # along with a specific extract_profile('ObservationSurvey') to catch non-sdoh.
160
- if suite_options[:us_core_version] == 'us_core_5' &&
170
+ if using_us_core_5? &&
161
171
  resource_contains_category(resource, 'survey',
162
172
  'http://terminology.hl7.org/CodeSystem/observation-category')
163
173
 
@@ -74,10 +74,9 @@ module ONCCertificationG10TestKit
74
74
  body of the response.
75
75
  )
76
76
  begin
77
+ assert_valid_json(response[:body])
77
78
  parsed_body = JSON.parse(response[:body])
78
79
  assert parsed_body['resourceType'] == 'OperationOutcome', error_message
79
- rescue JSON::ParserError
80
- assert false, error_message
81
80
  end
82
81
  fhir_search(
83
82
  resource_type,
@@ -323,7 +323,7 @@ module ONCCertificationG10TestKit
323
323
  )
324
324
  id :g10_encounter_restricted_access
325
325
 
326
- required_suite_options us_core_version: 'us_core_5'
326
+ required_suite_options G10Options::US_CORE_5_REQUIREMENT
327
327
 
328
328
  def resource_group
329
329
  USCoreTestKit::USCoreV501::EncounterGroup
@@ -343,7 +343,7 @@ module ONCCertificationG10TestKit
343
343
  )
344
344
  id :g10_service_request_restricted_access
345
345
 
346
- required_suite_options us_core_version: 'us_core_5'
346
+ required_suite_options G10Options::US_CORE_5_REQUIREMENT
347
347
 
348
348
  def resource_group
349
349
  USCoreTestKit::USCoreV501::ServiceRequestGroup
@@ -0,0 +1,46 @@
1
+ module ONCCertificationG10TestKit
2
+ # @private
3
+ # This module ensures that short test ids don't change
4
+ module ShortIDManager
5
+ class << self
6
+ def all_children(runnable)
7
+ runnable
8
+ .children
9
+ .flat_map { |child| [child] + all_children(child) }
10
+ end
11
+
12
+ def short_id_file_path
13
+ File.join(__dir__, 'short_id_map.yml')
14
+ end
15
+
16
+ def short_id_map
17
+ @short_id_map ||= YAML.load_file(short_id_file_path)
18
+ end
19
+
20
+ def assign_short_ids
21
+ all_children(G10CertificationSuite).each do |runnable|
22
+ short_id = short_id_map.fetch(runnable.id)
23
+ runnable.define_singleton_method(:short_id) do
24
+ short_id
25
+ end
26
+ rescue KeyError
27
+ Inferno::Application['logger'].warn("No short id defined for #{runnable.id}")
28
+ end
29
+ end
30
+
31
+ ### The methods below are only for creating an initial list of short ids
32
+
33
+ # Run this in an inferno console to save the current short ids
34
+ def save_current_short_id_map
35
+ File.write(short_id_file_path, current_short_id_map.to_yaml)
36
+ end
37
+
38
+ def current_short_id_map
39
+ @current_short_id_map ||=
40
+ all_children(G10CertificationSuite).each_with_object({}) do |runnable, mapping|
41
+ mapping[runnable.id] = runnable.short_id
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end