us_core_test_kit 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab7582755a94412bbb3ec0b8a270897af3f388565d958d81142d6bb8bda8807b
4
- data.tar.gz: fa11f769e3df77aeded50dd43a1131980818cda097185630105f07b45233f73c
3
+ metadata.gz: e2165ec13e4df3f34f052db84ac66517f2c05287f7337a262419c67c35e8b166
4
+ data.tar.gz: f05531ac89796f43c6199889370741b1f2f78e187169f7c5153df2264fa87dbc
5
5
  SHA512:
6
- metadata.gz: 5f8b612193ffc30eea51d859618fb82a452ae7b1d967e8c460a43f3f1dedf3afdfc93b5395274be42312e42550816b327f70c0cb377b7010cb2718ee68513389
7
- data.tar.gz: eae33ba2a29f0242203eea93ca967e00b93ec767f218ea83c80e28eb1144b45d36563416149435a5d0c224a6d26dcb26de826e94f2745c8e52fc41915c34f7cf
6
+ metadata.gz: 81d0e3b1eb27d76f15855b378fe50596f9c75dc639f3a824ed4871e7b7a102ebc4a500a56773d818ac1ec19bb148d0c9fc9ddc4a8270e38c6827b31f2e5454de
7
+ data.tar.gz: 2960026760e8b35b815016a76388125d5730b2074d4b10155b5eeb654f3b40028df7311ac241b3706c58541f8140cac59ed23d6f9a9bb2a346696c40ef37a72b
@@ -22,7 +22,6 @@ module USCoreTestKit
22
22
  * DocumentReference.context
23
23
  * DocumentReference.context.encounter
24
24
  * DocumentReference.context.period
25
- * DocumentReference.custodian
26
25
  * DocumentReference.date
27
26
  * DocumentReference.identifier
28
27
  * DocumentReference.status
@@ -15,7 +15,6 @@ module USCoreTestKit
15
15
 
16
16
  * DocumentReference.author
17
17
  * DocumentReference.context.encounter
18
- * DocumentReference.custodian
19
18
  * DocumentReference.subject
20
19
  )
21
20
 
@@ -233,9 +233,6 @@
233
233
  - :path: author
234
234
  :types:
235
235
  - Reference
236
- - :path: custodian
237
- :types:
238
- - Reference
239
236
  - :path: content
240
237
  - :path: content.attachment
241
238
  - :path: content.attachment.contentType
@@ -155,7 +155,7 @@
155
155
  :path: target.measure
156
156
  - :type: Quantity
157
157
  :strength: example
158
- :system:
158
+ :system:
159
159
  :path: target.detail
160
160
  - :type: CodeableConcept
161
161
  :strength: example
@@ -4645,9 +4645,6 @@
4645
4645
  - :path: author
4646
4646
  :types:
4647
4647
  - Reference
4648
- - :path: custodian
4649
- :types:
4650
- - Reference
4651
4648
  - :path: content
4652
4649
  - :path: content.attachment
4653
4650
  - :path: content.attachment.contentType
@@ -5279,7 +5276,7 @@
5279
5276
  :path: target.measure
5280
5277
  - :type: Quantity
5281
5278
  :strength: example
5282
- :system:
5279
+ :system:
5283
5280
  :path: target.detail
5284
5281
  - :type: CodeableConcept
5285
5282
  :strength: example
@@ -152,7 +152,7 @@
152
152
  :path: target.measure
153
153
  - :type: Quantity
154
154
  :strength: example
155
- :system:
155
+ :system:
156
156
  :path: target.detail
157
157
  - :type: CodeableConcept
158
158
  :strength: example
@@ -5317,7 +5317,7 @@
5317
5317
  :path: target.measure
5318
5318
  - :type: Quantity
5319
5319
  :strength: example
5320
- :system:
5320
+ :system:
5321
5321
  :path: target.detail
5322
5322
  - :type: CodeableConcept
5323
5323
  :strength: example
@@ -1168,7 +1168,7 @@
1168
1168
  :path: target.measure
1169
1169
  - :type: Quantity
1170
1170
  :strength: example
1171
- :system:
1171
+ :system:
1172
1172
  :path: target.detail
1173
1173
  - :type: CodeableConcept
1174
1174
  :strength: example
@@ -148,7 +148,11 @@
148
148
  :discriminator:
149
149
  :type: requiredBinding
150
150
  :path: ''
151
- :values: []
151
+ :values:
152
+ - inpatient
153
+ - outpatient
154
+ - community
155
+ - discharge
152
156
  :elements:
153
157
  - :path: status
154
158
  - :path: intent
@@ -6904,7 +6904,7 @@
6904
6904
  :path: target.measure
6905
6905
  - :type: Quantity
6906
6906
  :strength: example
6907
- :system:
6907
+ :system:
6908
6908
  :path: target.detail
6909
6909
  - :type: CodeableConcept
6910
6910
  :strength: example
@@ -7534,7 +7534,11 @@
7534
7534
  :discriminator:
7535
7535
  :type: requiredBinding
7536
7536
  :path: ''
7537
- :values: []
7537
+ :values:
7538
+ - inpatient
7539
+ - outpatient
7540
+ - community
7541
+ - discharge
7538
7542
  :elements:
7539
7543
  - :path: status
7540
7544
  - :path: intent
@@ -1,3 +1,5 @@
1
+ require_relative 'value_extractor'
2
+
1
3
  module USCoreTestKit
2
4
  class Generator
3
5
  class MustSupportMetadataExtractor
@@ -97,13 +99,10 @@ module USCoreTestKit
97
99
  elsif pattern_element.binding&.strength == 'required' &&
98
100
  pattern_element.binding&.valueSet.present?
99
101
 
100
- value_set = ig_resources.value_set_by_url(pattern_element.binding.valueSet)
101
- bound_systems = value_set&.compose&.include&.reject { |code| code.concept.blank? }
102
- values = []
102
+ value_extractor = ValueExactor.new(ig_resources, resource)
103
103
 
104
- if bound_systems.present?
105
- values = bound_systems&.flat_map { |system| system.concept.map { |code| code.code } }.uniq
106
- end
104
+ values = value_extractor.values_from_value_set_binding(pattern_element).presence ||
105
+ value_extractor.values_from_resource_metadata([metadata[:path]]).presence || []
107
106
 
108
107
  {
109
108
  type: 'requiredBinding',
@@ -292,6 +291,8 @@ module USCoreTestKit
292
291
  add_must_support_choices
293
292
 
294
293
  case profile.version
294
+ when '3.1.1'
295
+ remove_document_reference_custodian
295
296
  when '4.0.0'
296
297
  add_device_distinct_identifier
297
298
  add_patient_uscdi_elements
@@ -354,6 +355,15 @@ module USCoreTestKit
354
355
  end
355
356
  end
356
357
 
358
+ # US Core clarified that server implmentation is not required to support DocumentReference.custodian (FHIR-28393)
359
+ def remove_document_reference_custodian
360
+ if profile.type == 'DocumentReference'
361
+ @must_supports[:elements].delete_if do |element|
362
+ element[:path] == 'custodian'
363
+ end
364
+ end
365
+ end
366
+
357
367
  def remove_document_reference_attachment_data_url
358
368
  if profile.type == 'DocumentReference'
359
369
  @must_supports[:elements].delete_if do |element|
@@ -482,7 +492,7 @@ module USCoreTestKit
482
492
 
483
493
  slice = @must_supports[:slices].find{|slice| slice[:path] == 'category'}
484
494
 
485
- slice[:discriminator][:values] << 'clinical-note' if slice.present?
495
+ slice[:discriminator][:values] = ['clinical-note'] if slice.present?
486
496
  end
487
497
 
488
498
  # FHIR-37794 Server systems are not required to support US Core QuestionnaireResponse
@@ -1,3 +1,5 @@
1
+ require_relative 'value_extractor'
2
+
1
3
  module USCoreTestKit
2
4
  class Generator
3
5
  class SearchDefinitionMetadataExtractor
@@ -113,14 +115,15 @@ module USCoreTestKit
113
115
 
114
116
  def values
115
117
  values = (
116
- (
117
118
  values_from_pattern_codeable_concept_slices +
118
119
  values_from_required_binding_slices +
119
120
  values_from_fixed_codes +
120
121
  values_from_pattern_coding +
121
122
  values_from_pattern_codeable_concept
122
- ).uniq.presence || values_from_value_set_binding(profile_element)
123
- ).presence || values_from_resource_metadata
123
+ ).uniq.presence ||
124
+ value_extractor.values_from_value_set_binding(profile_element).presence ||
125
+ value_extractor.values_from_resource_metadata(paths).presence || []
126
+
124
127
  values
125
128
  end
126
129
 
@@ -146,7 +149,7 @@ module USCoreTestKit
146
149
  def values_from_required_binding_slices
147
150
  slices.map do |slice|
148
151
  if slice.binding.present? && slice.binding.strength == 'required'
149
- values_from_value_set_binding(slice)
152
+ value_extractor.values_from_value_set_binding(slice)
150
153
  end
151
154
  end.flatten.compact
152
155
  end
@@ -173,42 +176,8 @@ module USCoreTestKit
173
176
  [profile_element.patternCodeableConcept.coding.first.code]
174
177
  end
175
178
 
176
- def value_set_binding(the_element)
177
- the_element&.binding
178
- end
179
-
180
- def value_set(the_element)
181
- ig_resources.value_set_by_url(value_set_binding(the_element)&.valueSet)
182
- end
183
-
184
- def bound_systems(the_element)
185
- value_set(the_element)&.compose&.include&.reject { |code| code.concept.nil? }
186
- end
187
-
188
- def values_from_value_set_binding(the_element)
189
- bound_systems = bound_systems(the_element)
190
-
191
- return [] if bound_systems.blank?
192
-
193
- bound_systems.flat_map { |system| system.concept.map { |code| code.code } }.uniq
194
- end
195
-
196
- def fhir_metadata(current_path)
197
- FHIR.const_get(resource)::METADATA[current_path]
198
- end
199
-
200
- def values_from_resource_metadata
201
- values = []
202
-
203
- paths.each do |current_path|
204
- current_metadata = fhir_metadata(current_path)
205
-
206
- if current_metadata&.dig('valid_codes').present?
207
- values = values + current_metadata['valid_codes'].values.flatten
208
- end
209
- end
210
-
211
- values
179
+ def value_extractor
180
+ @value_extractor ||= ValueExactor.new(ig_resources, resource)
212
181
  end
213
182
  end
214
183
  end
@@ -0,0 +1,50 @@
1
+ module USCoreTestKit
2
+ class Generator
3
+ class ValueExactor
4
+ attr_accessor :ig_resources, :resource
5
+
6
+ def initialize(ig_resources, resource)
7
+ self.ig_resources = ig_resources
8
+ self.resource = resource
9
+ end
10
+
11
+ def value_set_binding(the_element)
12
+ the_element&.binding
13
+ end
14
+
15
+ def value_set(the_element)
16
+ ig_resources.value_set_by_url(value_set_binding(the_element)&.valueSet)
17
+ end
18
+
19
+ def bound_systems(the_element)
20
+ value_set(the_element)&.compose&.include&.reject { |code| code.concept.nil? }
21
+ end
22
+
23
+ def values_from_value_set_binding(the_element)
24
+ bound_systems = bound_systems(the_element)
25
+
26
+ return [] if bound_systems.blank?
27
+
28
+ bound_systems.flat_map { |system| system.concept.map { |code| code.code } }.uniq
29
+ end
30
+
31
+ def fhir_metadata(current_path)
32
+ FHIR.const_get(resource)::METADATA[current_path]
33
+ end
34
+
35
+ def values_from_resource_metadata(paths)
36
+ values = []
37
+
38
+ paths.each do |current_path|
39
+ current_metadata = fhir_metadata(current_path)
40
+
41
+ if current_metadata&.dig('valid_codes').present?
42
+ values = values + current_metadata['valid_codes'].values.flatten
43
+ end
44
+ end
45
+
46
+ values
47
+ end
48
+ end
49
+ end
50
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module USCoreTestKit
4
- VERSION = '0.4.0'
4
+ VERSION = '0.4.1'
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.4.0
4
+ version: 0.4.1
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-10-31 00:00:00.000000000 Z
11
+ date: 2022-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inferno_core
@@ -1292,6 +1292,7 @@ files:
1292
1292
  - lib/us_core_test_kit/generator/suite_generator.rb
1293
1293
  - lib/us_core_test_kit/generator/terminology_binding_metadata_extractor.rb
1294
1294
  - lib/us_core_test_kit/generator/validation_test_generator.rb
1295
+ - lib/us_core_test_kit/generator/value_extractor.rb
1295
1296
  - lib/us_core_test_kit/igs/us_core_311.tgz
1296
1297
  - lib/us_core_test_kit/igs/us_core_311/StructureDefinition-bodyheight.json
1297
1298
  - lib/us_core_test_kit/igs/us_core_311/StructureDefinition-bodytemp.json