us_core_test_kit 0.4.4 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/us_core_test_kit/custom_groups/capability_statement/profile_support_test.rb +14 -17
- data/lib/us_core_test_kit/custom_groups/v3.1.1/capability_statement_group.rb +1 -1
- data/lib/us_core_test_kit/custom_groups/v4.0.0/capability_statement_group.rb +1 -1
- data/lib/us_core_test_kit/custom_groups/v5.0.1/capability_statement_group.rb +1 -1
- data/lib/us_core_test_kit/generated/v3.1.1/us_core_test_suite.rb +2 -2
- data/lib/us_core_test_kit/generated/v4.0.0/device/metadata.yml +0 -2
- data/lib/us_core_test_kit/generated/v4.0.0/device_group.rb +0 -2
- data/lib/us_core_test_kit/generated/v4.0.0/medication_request/medication_request_reference_resolution_test.rb +1 -0
- data/lib/us_core_test_kit/generated/v4.0.0/medication_request/metadata.yml +1 -1
- data/lib/us_core_test_kit/generated/v4.0.0/metadata.yml +1 -1
- data/lib/us_core_test_kit/generated/v4.0.0/us_core_test_suite.rb +2 -2
- data/lib/us_core_test_kit/generated/v5.0.1/device/metadata.yml +0 -2
- data/lib/us_core_test_kit/generated/v5.0.1/device_group.rb +0 -2
- data/lib/us_core_test_kit/generated/v5.0.1/medication_request/medication_request_reference_resolution_test.rb +1 -0
- data/lib/us_core_test_kit/generated/v5.0.1/medication_request/metadata.yml +1 -1
- data/lib/us_core_test_kit/generated/v5.0.1/metadata.yml +6 -1
- data/lib/us_core_test_kit/generated/v5.0.1/service_request/metadata.yml +5 -0
- data/lib/us_core_test_kit/generated/v5.0.1/us_core_test_suite.rb +2 -2
- data/lib/us_core_test_kit/generator/group_generator.rb +0 -5
- data/lib/us_core_test_kit/generator/must_support_metadata_extractor.rb +7 -167
- data/lib/us_core_test_kit/generator/must_support_metadata_extractor_us_core_3.rb +39 -0
- data/lib/us_core_test_kit/generator/must_support_metadata_extractor_us_core_4.rb +90 -0
- data/lib/us_core_test_kit/generator/must_support_metadata_extractor_us_core_5.rb +108 -0
- data/lib/us_core_test_kit/generator.rb +1 -1
- data/lib/us_core_test_kit/version.rb +1 -1
- data/lib/us_core_test_kit.rb +0 -1
- metadata +5 -4
- data/lib/us_core_test_kit/custom_groups/v4.0.0/device_udi_pi_test.rb +0 -40
- data/lib/us_core_test_kit/ext/fhir_models.rb +0 -59
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 827607a65eeb7956db852bbf500ad1d9d55f03403e6eb9075d2adb6186e69b2f
|
4
|
+
data.tar.gz: efabaf62e09af2fed1de8a5e15e5bcc104ff744dbcfe4976577774a92700a700
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07a7bffbc53564983eb5c28944f98983108abf34be06f96eafff061edfc6bc4f800db1634b7e2414d452c063e926a97d834429c762825c0d72dd83eae58eb3be
|
7
|
+
data.tar.gz: 4dcfe3c97fb35c3319f466936a3c09ea84d9c887b02d487ce1b0a14de2e999c0097b9d6d55e9e319f10f102693b0e58d8ccdcdb26861e35b51c39cdb35a3c931
|
@@ -9,7 +9,9 @@ module USCoreTestKit
|
|
9
9
|
The US Core Server SHALL:
|
10
10
|
1. Support the US Core Patient resource profile.
|
11
11
|
2. Support at least one additional resource profile from the list of US
|
12
|
-
|
12
|
+
Core Profiles.
|
13
|
+
|
14
|
+
In order to support USCDI, servers must support all USCDI resources.
|
13
15
|
```
|
14
16
|
)
|
15
17
|
uses_request :capability_statement
|
@@ -23,30 +25,25 @@ module USCoreTestKit
|
|
23
25
|
&.each_with_object([]) do |rest, resources|
|
24
26
|
rest.resource.each { |resource| resources << resource.type }
|
25
27
|
end.uniq
|
26
|
-
supported_profiles =
|
27
|
-
capability_statement.rest
|
28
|
-
&.flat_map(&:resource)
|
29
|
-
&.flat_map { |resource| resource.supportedProfile + [resource.profile] }
|
30
|
-
&.compact || []
|
31
|
-
supported_profiles.map! { |profile_url| profile_url.split('|').first }
|
32
28
|
|
33
29
|
assert supported_resources.include?('Patient'), 'US Core Patient profile not supported'
|
34
30
|
|
35
|
-
|
31
|
+
us_core_resources = config.options[:us_core_resources]
|
36
32
|
|
37
|
-
other_resources =
|
33
|
+
other_resources = us_core_resources.reject { |resource_type| resource_type == 'Patient' }
|
38
34
|
other_resources_supported = other_resources.any? { |resource| supported_resources.include? resource }
|
39
35
|
assert other_resources_supported, 'No US Core resources other than Patient are supported'
|
40
36
|
|
41
|
-
|
42
|
-
|
37
|
+
if config.options[:required_resources].present?
|
38
|
+
missing_resources = config.options[:required_resources] - supported_resources
|
39
|
+
|
40
|
+
missing_resource_list =
|
41
|
+
missing_resources
|
42
|
+
.map { |resource| "`#{resource}`" }
|
43
|
+
.join(', ')
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
assert supported_profiles&.include?(profile),
|
47
|
-
"CapabilityStatement does not claim support for US Core #{resource_type} profile: #{profile}"
|
48
|
-
end
|
49
|
-
end
|
45
|
+
assert missing_resources.empty?,
|
46
|
+
"The CapabilityStatement did not list support for the following resources: #{missing_resource_list}"
|
50
47
|
end
|
51
48
|
end
|
52
49
|
end
|
@@ -54,8 +54,8 @@ module USCoreTestKit
|
|
54
54
|
version VERSION
|
55
55
|
|
56
56
|
VALIDATION_MESSAGE_FILTERS = [
|
57
|
-
%r{Sub-extension url 'introspect' is not defined by the Extension http://fhir-registry\.smarthealthit\.org/StructureDefinition/oauth-uris
|
58
|
-
%r{Sub-extension url 'revoke' is not defined by the Extension http://fhir-registry\.smarthealthit\.org/StructureDefinition/oauth-uris
|
57
|
+
%r{Sub-extension url 'introspect' is not defined by the Extension http://fhir-registry\.smarthealthit\.org/StructureDefinition/oauth-uris},
|
58
|
+
%r{Sub-extension url 'revoke' is not defined by the Extension http://fhir-registry\.smarthealthit\.org/StructureDefinition/oauth-uris},
|
59
59
|
/Observation\.effective\.ofType\(Period\): .*vs-1:/, # Invalid invariant in FHIR v4.0.1
|
60
60
|
/Observation\.effective\.ofType\(Period\): .*us-core-1:/, # Invalid invariant in US Core v3.1.1
|
61
61
|
/Provenance.agent\[\d*\]: Rule provenance-1/ #Invalid invariant in US Core v5.0.1
|
@@ -136,8 +136,6 @@
|
|
136
136
|
:file_name: device_must_support_test.rb
|
137
137
|
- :id: us_core_v400_device_reference_resolution_test
|
138
138
|
:file_name: device_reference_resolution_test.rb
|
139
|
-
- :id: us_core_v400_device_udi_pi_test
|
140
|
-
:file_name: "../../custom_groups/v4.0.0/device_udi_pi_test.rb"
|
141
139
|
:id: us_core_v400_device
|
142
140
|
:file_name: device_group.rb
|
143
141
|
:delayed_references: []
|
@@ -5,7 +5,6 @@ require_relative 'device/device_provenance_revinclude_search_test'
|
|
5
5
|
require_relative 'device/device_validation_test'
|
6
6
|
require_relative 'device/device_must_support_test'
|
7
7
|
require_relative 'device/device_reference_resolution_test'
|
8
|
-
require_relative '../../custom_groups/v4.0.0/device_udi_pi_test'
|
9
8
|
|
10
9
|
module USCoreTestKit
|
11
10
|
module USCoreV400
|
@@ -84,7 +83,6 @@ read succeeds.
|
|
84
83
|
test from: :us_core_v400_device_validation_test
|
85
84
|
test from: :us_core_v400_device_must_support_test
|
86
85
|
test from: :us_core_v400_device_reference_resolution_test
|
87
|
-
test from: :us_core_v400_device_udi_pi_test
|
88
86
|
end
|
89
87
|
end
|
90
88
|
end
|
@@ -56,8 +56,8 @@ module USCoreTestKit
|
|
56
56
|
version VERSION
|
57
57
|
|
58
58
|
VALIDATION_MESSAGE_FILTERS = [
|
59
|
-
%r{Sub-extension url 'introspect' is not defined by the Extension http://fhir-registry\.smarthealthit\.org/StructureDefinition/oauth-uris
|
60
|
-
%r{Sub-extension url 'revoke' is not defined by the Extension http://fhir-registry\.smarthealthit\.org/StructureDefinition/oauth-uris
|
59
|
+
%r{Sub-extension url 'introspect' is not defined by the Extension http://fhir-registry\.smarthealthit\.org/StructureDefinition/oauth-uris},
|
60
|
+
%r{Sub-extension url 'revoke' is not defined by the Extension http://fhir-registry\.smarthealthit\.org/StructureDefinition/oauth-uris},
|
61
61
|
/Observation\.effective\.ofType\(Period\): .*vs-1:/, # Invalid invariant in FHIR v4.0.1
|
62
62
|
/Observation\.effective\.ofType\(Period\): .*us-core-1:/, # Invalid invariant in US Core v3.1.1
|
63
63
|
/Provenance.agent\[\d*\]: Rule provenance-1/ #Invalid invariant in US Core v5.0.1
|
@@ -136,8 +136,6 @@
|
|
136
136
|
:file_name: device_must_support_test.rb
|
137
137
|
- :id: us_core_v501_device_reference_resolution_test
|
138
138
|
:file_name: device_reference_resolution_test.rb
|
139
|
-
- :id: us_core_v400_device_udi_pi_test
|
140
|
-
:file_name: "../../custom_groups/v4.0.0/device_udi_pi_test.rb"
|
141
139
|
:id: us_core_v501_device
|
142
140
|
:file_name: device_group.rb
|
143
141
|
:delayed_references: []
|
@@ -5,7 +5,6 @@ require_relative 'device/device_provenance_revinclude_search_test'
|
|
5
5
|
require_relative 'device/device_validation_test'
|
6
6
|
require_relative 'device/device_must_support_test'
|
7
7
|
require_relative 'device/device_reference_resolution_test'
|
8
|
-
require_relative '../../custom_groups/v4.0.0/device_udi_pi_test'
|
9
8
|
|
10
9
|
module USCoreTestKit
|
11
10
|
module USCoreV501
|
@@ -84,7 +83,6 @@ read succeeds.
|
|
84
83
|
test from: :us_core_v501_device_validation_test
|
85
84
|
test from: :us_core_v501_device_must_support_test
|
86
85
|
test from: :us_core_v501_device_reference_resolution_test
|
87
|
-
test from: :us_core_v400_device_udi_pi_test
|
88
86
|
end
|
89
87
|
end
|
90
88
|
end
|
@@ -3079,7 +3079,7 @@
|
|
3079
3079
|
:original_path: reported[x]
|
3080
3080
|
- :path: reportedReference
|
3081
3081
|
:original_path: reported[x]
|
3082
|
-
:
|
3082
|
+
:types:
|
3083
3083
|
- Reference
|
3084
3084
|
:target_profiles:
|
3085
3085
|
- http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitioner
|
@@ -10047,6 +10047,11 @@
|
|
10047
10047
|
- sdoh
|
10048
10048
|
- '386053000'
|
10049
10049
|
- '410606002'
|
10050
|
+
- '108252007'
|
10051
|
+
- '363679005'
|
10052
|
+
- '409063005'
|
10053
|
+
- '409073007'
|
10054
|
+
- '387713003'
|
10050
10055
|
:elements:
|
10051
10056
|
- :path: status
|
10052
10057
|
- :path: intent
|
@@ -65,8 +65,8 @@ module USCoreTestKit
|
|
65
65
|
version VERSION
|
66
66
|
|
67
67
|
VALIDATION_MESSAGE_FILTERS = [
|
68
|
-
%r{Sub-extension url 'introspect' is not defined by the Extension http://fhir-registry\.smarthealthit\.org/StructureDefinition/oauth-uris
|
69
|
-
%r{Sub-extension url 'revoke' is not defined by the Extension http://fhir-registry\.smarthealthit\.org/StructureDefinition/oauth-uris
|
68
|
+
%r{Sub-extension url 'introspect' is not defined by the Extension http://fhir-registry\.smarthealthit\.org/StructureDefinition/oauth-uris},
|
69
|
+
%r{Sub-extension url 'revoke' is not defined by the Extension http://fhir-registry\.smarthealthit\.org/StructureDefinition/oauth-uris},
|
70
70
|
/Observation\.effective\.ofType\(Period\): .*vs-1:/, # Invalid invariant in FHIR v4.0.1
|
71
71
|
/Observation\.effective\.ofType\(Period\): .*us-core-1:/, # Invalid invariant in US Core v3.1.1
|
72
72
|
/Provenance.agent\[\d*\]: Rule provenance-1/ #Invalid invariant in US Core v5.0.1
|
@@ -110,11 +110,6 @@ module USCoreTestKit
|
|
110
110
|
return if group_metadata.reformatted_version == 'v311'
|
111
111
|
|
112
112
|
case group_metadata.resource
|
113
|
-
when 'Device'
|
114
|
-
group_metadata.add_test(
|
115
|
-
id: 'us_core_v400_device_udi_pi_test',
|
116
|
-
file_name: '../../custom_groups/v4.0.0/device_udi_pi_test.rb'
|
117
|
-
)
|
118
113
|
when 'DocumentReference'
|
119
114
|
group_metadata.add_test(
|
120
115
|
id: 'us_core_v400_document_reference_custodian_test',
|
@@ -1,4 +1,7 @@
|
|
1
1
|
require_relative 'value_extractor'
|
2
|
+
require_relative 'must_support_metadata_extractor_us_core_3'
|
3
|
+
require_relative 'must_support_metadata_extractor_us_core_4'
|
4
|
+
require_relative 'must_support_metadata_extractor_us_core_5'
|
2
5
|
|
3
6
|
module USCoreTestKit
|
4
7
|
class Generator
|
@@ -218,7 +221,7 @@ module USCoreTestKit
|
|
218
221
|
path: "#{current_metadata[:path].delete_suffix('[x]')}#{type.code.upcase_first}",
|
219
222
|
original_path: current_metadata[:path]
|
220
223
|
}
|
221
|
-
metadata[:
|
224
|
+
metadata[:types] = [type.code] if save_type_code?(type)
|
222
225
|
handle_type_must_support_target_profiles(type, metadata) if type.code == 'Reference'
|
223
226
|
|
224
227
|
metadata
|
@@ -288,18 +291,14 @@ module USCoreTestKit
|
|
288
291
|
remove_vital_sign_component
|
289
292
|
remove_blood_pressure_value
|
290
293
|
remove_observation_data_absent_reason
|
291
|
-
add_must_support_choices
|
292
294
|
|
293
295
|
case profile.version
|
294
296
|
when '3.1.1'
|
295
|
-
|
297
|
+
MustSupportMetadataExtractorUsCore3.new(profile, @must_supports).handle_special_cases
|
296
298
|
when '4.0.0'
|
297
|
-
|
298
|
-
add_patient_uscdi_elements
|
299
|
+
MustSupportMetadataExtractorUsCore4.new(profile, @must_supports).handle_special_cases
|
299
300
|
when '5.0.1'
|
300
|
-
|
301
|
-
add_document_reference_category_values
|
302
|
-
remove_survey_questionnaire_response
|
301
|
+
MustSupportMetadataExtractorUsCore5.new(profile, @must_supports).handle_special_cases
|
303
302
|
end
|
304
303
|
end
|
305
304
|
|
@@ -346,165 +345,6 @@ module USCoreTestKit
|
|
346
345
|
end
|
347
346
|
end
|
348
347
|
end
|
349
|
-
|
350
|
-
def remove_device_carrier
|
351
|
-
if profile.type == 'Device'
|
352
|
-
@must_supports[:elements].delete_if do |element|
|
353
|
-
['udiCarrier.carrierAIDC', 'udiCarrier.carrierHRF'].include?(element[:path])
|
354
|
-
end
|
355
|
-
end
|
356
|
-
end
|
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
|
-
|
367
|
-
def remove_document_reference_attachment_data_url
|
368
|
-
if profile.type == 'DocumentReference'
|
369
|
-
@must_supports[:elements].delete_if do |element|
|
370
|
-
['content.attachment.data', 'content.attachment.url'].include?(element[:path])
|
371
|
-
end
|
372
|
-
end
|
373
|
-
end
|
374
|
-
|
375
|
-
def add_must_support_choices
|
376
|
-
choices = []
|
377
|
-
|
378
|
-
choices << { paths: ['content.attachment.data', 'content.attachment.url'] } if profile.type == 'DocumentReference'
|
379
|
-
|
380
|
-
case profile.version
|
381
|
-
when '3.1.1'
|
382
|
-
choices << { paths: ['udiCarrier.carrierAIDC', 'udiCarrier.carrierHRF'] } if profile.type == 'Device'
|
383
|
-
when '4.0.0'
|
384
|
-
case profile.type
|
385
|
-
when 'Encounter'
|
386
|
-
choices << { paths: ['reasonCode', 'reasonReference'] }
|
387
|
-
choices << { paths: ['location.location', 'serviceProvider'] }
|
388
|
-
when 'MedicationRequest'
|
389
|
-
choices << { paths: ['reportedBoolean', 'reportedReference'] }
|
390
|
-
end
|
391
|
-
when '5.0.1'
|
392
|
-
case profile.type
|
393
|
-
when 'CareTeam'
|
394
|
-
choices << {
|
395
|
-
target_profiles: [
|
396
|
-
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitioner',
|
397
|
-
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitionerrole'
|
398
|
-
]
|
399
|
-
}
|
400
|
-
when 'Condition'
|
401
|
-
choices << {
|
402
|
-
paths: ['onsetDateTime'],
|
403
|
-
extension_ids: ['Condition.extension:assertedDate']
|
404
|
-
}
|
405
|
-
when 'Encounter'
|
406
|
-
choices << { paths: ['reasonCode', 'reasonReference'] }
|
407
|
-
choices << { paths: ['location.location', 'serviceProvider'] }
|
408
|
-
when 'MedicationRequest'
|
409
|
-
choices << { paths: ['reportedBoolean', 'reportedReference'] }
|
410
|
-
end
|
411
|
-
end
|
412
|
-
|
413
|
-
@must_supports[:choices] = choices if choices.present?
|
414
|
-
end
|
415
|
-
|
416
|
-
def add_device_distinct_identifier
|
417
|
-
if profile.type == 'Device'
|
418
|
-
# FHIR-36303 US Core 4.0.0 mistakenly removed MS from Device.distinctIdentifier
|
419
|
-
# This will be fixed in US Core 5.0.0
|
420
|
-
@must_supports[:elements] << {
|
421
|
-
path: 'distinctIdentifier'
|
422
|
-
}
|
423
|
-
end
|
424
|
-
end
|
425
|
-
|
426
|
-
def add_patient_uscdi_elements
|
427
|
-
return unless profile.type == 'Patient'
|
428
|
-
|
429
|
-
#US Core 4.0.0 Section 10.112.1.1 Additional USCDI v1 Requirement:
|
430
|
-
@must_supports[:extensions] << {
|
431
|
-
id: 'Patient.extension:race',
|
432
|
-
url: 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-race',
|
433
|
-
uscdi_only: true
|
434
|
-
}
|
435
|
-
@must_supports[:extensions] << {
|
436
|
-
id: 'Patient.extension:ethnicity',
|
437
|
-
url: 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity',
|
438
|
-
uscdi_only: true
|
439
|
-
}
|
440
|
-
@must_supports[:extensions] << {
|
441
|
-
id: 'Patient.extension:birthsex',
|
442
|
-
url: 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex',
|
443
|
-
uscdi_only: true
|
444
|
-
}
|
445
|
-
@must_supports[:elements] << {
|
446
|
-
path: 'name.suffix',
|
447
|
-
uscdi_only: true
|
448
|
-
}
|
449
|
-
@must_supports[:elements] << {
|
450
|
-
path: 'name.period.end',
|
451
|
-
uscdi_only: true
|
452
|
-
}
|
453
|
-
@must_supports[:elements] << {
|
454
|
-
path: 'telecom',
|
455
|
-
uscdi_only: true
|
456
|
-
}
|
457
|
-
@must_supports[:elements] << {
|
458
|
-
path: 'communication',
|
459
|
-
uscdi_only: true
|
460
|
-
}
|
461
|
-
# Though telecom.system, telecom.value, telecom.use, and communication.language are marked as MustSupport since US Core v4.0.0,
|
462
|
-
# their parent elements telecom, and communication are not MustSupport but listed under "Additional USCDI requirements"
|
463
|
-
# According to the updated FHIR spec that "When a child element is defined as Must Support and the parent element isn't,
|
464
|
-
# a system must support the child if it support the parent, but there's no expectation that the system must support the parent.",
|
465
|
-
# We add uscdi_only tag to these elements
|
466
|
-
@must_supports[:elements].each do |element|
|
467
|
-
path = element[:path]
|
468
|
-
element[:uscdi_only] = true if path.include?('telecom.') || path.include?('communication.')
|
469
|
-
end
|
470
|
-
|
471
|
-
if profile.version == '5.0.1'
|
472
|
-
@must_supports[:extensions] << {
|
473
|
-
id: 'Patient.extension:genderIdentity',
|
474
|
-
url: 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-genderIdentity',
|
475
|
-
uscdi_only: true
|
476
|
-
}
|
477
|
-
@must_supports[:elements] << {
|
478
|
-
path: 'address.use',
|
479
|
-
fixed_value: 'old',
|
480
|
-
uscdi_only: true
|
481
|
-
}
|
482
|
-
@must_supports[:elements] << {
|
483
|
-
path: 'name.use',
|
484
|
-
fixed_value: 'old',
|
485
|
-
uscdi_only: true
|
486
|
-
}
|
487
|
-
end
|
488
|
-
end
|
489
|
-
|
490
|
-
def add_document_reference_category_values
|
491
|
-
return unless profile.type == 'DocumentReference'
|
492
|
-
|
493
|
-
slice = @must_supports[:slices].find{|slice| slice[:path] == 'category'}
|
494
|
-
|
495
|
-
slice[:discriminator][:values] = ['clinical-note'] if slice.present?
|
496
|
-
end
|
497
|
-
|
498
|
-
# FHIR-37794 Server systems are not required to support US Core QuestionnaireResponse
|
499
|
-
def remove_survey_questionnaire_response
|
500
|
-
return unless profile.type == 'Observation' &&
|
501
|
-
['us-core-observation-survey', 'us-core-observation-sdoh-assessment'].include?(profile.id)
|
502
|
-
|
503
|
-
element = @must_supports[:elements].find { |element| element[:path] == 'derivedFrom' }
|
504
|
-
element[:target_profiles].delete_if do |url|
|
505
|
-
url == 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-questionnaireresponse'
|
506
|
-
end
|
507
|
-
end
|
508
348
|
end
|
509
349
|
end
|
510
350
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module USCoreTestKit
|
2
|
+
class Generator
|
3
|
+
class MustSupportMetadataExtractorUsCore3
|
4
|
+
attr_accessor :profile, :must_supports
|
5
|
+
|
6
|
+
def initialize(profile, must_supports)
|
7
|
+
self.profile = profile
|
8
|
+
self.must_supports = must_supports
|
9
|
+
end
|
10
|
+
|
11
|
+
def handle_special_cases
|
12
|
+
add_must_support_choices
|
13
|
+
remove_document_reference_custodian
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_must_support_choices
|
17
|
+
choices = []
|
18
|
+
|
19
|
+
case profile.type
|
20
|
+
when 'Device'
|
21
|
+
choices << { paths: ['udiCarrier.carrierAIDC', 'udiCarrier.carrierHRF'] }
|
22
|
+
when 'DocumentReference'
|
23
|
+
choices << { paths: ['content.attachment.data', 'content.attachment.url'] }
|
24
|
+
end
|
25
|
+
|
26
|
+
must_supports[:choices] = choices if choices.present?
|
27
|
+
end
|
28
|
+
|
29
|
+
# US Core clarified that server implmentation is not required to support DocumentReference.custodian (FHIR-28393)
|
30
|
+
def remove_document_reference_custodian
|
31
|
+
return unless profile.type == 'DocumentReference'
|
32
|
+
|
33
|
+
must_supports[:elements].delete_if do |element|
|
34
|
+
element[:path] == 'custodian'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module USCoreTestKit
|
2
|
+
class Generator
|
3
|
+
class MustSupportMetadataExtractorUsCore4
|
4
|
+
attr_accessor :profile, :must_supports
|
5
|
+
|
6
|
+
def initialize(profile, must_supports)
|
7
|
+
self.profile = profile
|
8
|
+
self.must_supports = must_supports
|
9
|
+
end
|
10
|
+
|
11
|
+
def handle_special_cases
|
12
|
+
add_must_support_choices
|
13
|
+
add_device_distinct_identifier
|
14
|
+
add_patient_uscdi_elements
|
15
|
+
end
|
16
|
+
|
17
|
+
def add_must_support_choices
|
18
|
+
choices = []
|
19
|
+
|
20
|
+
case profile.type
|
21
|
+
when 'DocumentReference'
|
22
|
+
choices << { paths: ['content.attachment.data', 'content.attachment.url'] }
|
23
|
+
when 'Encounter'
|
24
|
+
choices << { paths: ['reasonCode', 'reasonReference'] }
|
25
|
+
choices << { paths: ['location.location', 'serviceProvider'] }
|
26
|
+
when 'MedicationRequest'
|
27
|
+
choices << { paths: ['reportedBoolean', 'reportedReference'] }
|
28
|
+
end
|
29
|
+
|
30
|
+
must_supports[:choices] = choices if choices.present?
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_device_distinct_identifier
|
34
|
+
if profile.type == 'Device'
|
35
|
+
# FHIR-36303 US Core 4.0.0 mistakenly removed MS from Device.distinctIdentifier
|
36
|
+
# This will be fixed in US Core 5.0.0
|
37
|
+
must_supports[:elements] << {
|
38
|
+
path: 'distinctIdentifier'
|
39
|
+
}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def add_patient_uscdi_elements
|
44
|
+
return unless profile.type == 'Patient'
|
45
|
+
|
46
|
+
#US Core 4.0.0 Section 10.112.1.1 Additional USCDI v1 Requirement:
|
47
|
+
must_supports[:extensions] << {
|
48
|
+
id: 'Patient.extension:race',
|
49
|
+
url: 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-race',
|
50
|
+
uscdi_only: true
|
51
|
+
}
|
52
|
+
must_supports[:extensions] << {
|
53
|
+
id: 'Patient.extension:ethnicity',
|
54
|
+
url: 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity',
|
55
|
+
uscdi_only: true
|
56
|
+
}
|
57
|
+
must_supports[:extensions] << {
|
58
|
+
id: 'Patient.extension:birthsex',
|
59
|
+
url: 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex',
|
60
|
+
uscdi_only: true
|
61
|
+
}
|
62
|
+
must_supports[:elements] << {
|
63
|
+
path: 'name.suffix',
|
64
|
+
uscdi_only: true
|
65
|
+
}
|
66
|
+
must_supports[:elements] << {
|
67
|
+
path: 'name.period.end',
|
68
|
+
uscdi_only: true
|
69
|
+
}
|
70
|
+
must_supports[:elements] << {
|
71
|
+
path: 'telecom',
|
72
|
+
uscdi_only: true
|
73
|
+
}
|
74
|
+
must_supports[:elements] << {
|
75
|
+
path: 'communication',
|
76
|
+
uscdi_only: true
|
77
|
+
}
|
78
|
+
# Though telecom.system, telecom.value, telecom.use, and communication.language are marked as MustSupport since US Core v4.0.0,
|
79
|
+
# their parent elements telecom, and communication are not MustSupport but listed under "Additional USCDI requirements"
|
80
|
+
# According to the updated FHIR spec that "When a child element is defined as Must Support and the parent element isn't,
|
81
|
+
# a system must support the child if it support the parent, but there's no expectation that the system must support the parent.",
|
82
|
+
# We add uscdi_only tag to these elements
|
83
|
+
must_supports[:elements].each do |element|
|
84
|
+
path = element[:path]
|
85
|
+
element[:uscdi_only] = true if path.include?('telecom.') || path.include?('communication.')
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require_relative 'must_support_metadata_extractor_us_core_4'
|
2
|
+
|
3
|
+
module USCoreTestKit
|
4
|
+
class Generator
|
5
|
+
class MustSupportMetadataExtractorUsCore5
|
6
|
+
attr_accessor :profile, :must_supports
|
7
|
+
|
8
|
+
def initialize(profile, must_supports)
|
9
|
+
self.profile = profile
|
10
|
+
self.must_supports = must_supports
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
def us_core_4_extractor
|
15
|
+
@us_core_4_extractor ||= MustSupportMetadataExtractorUsCore4.new(profile, must_supports)
|
16
|
+
end
|
17
|
+
|
18
|
+
def handle_special_cases
|
19
|
+
add_must_support_choices
|
20
|
+
add_patient_uscdi_elements
|
21
|
+
add_value_set_expansion
|
22
|
+
remove_survey_questionnaire_response
|
23
|
+
end
|
24
|
+
|
25
|
+
def add_must_support_choices
|
26
|
+
us_core_4_extractor.add_must_support_choices
|
27
|
+
|
28
|
+
more_choices = []
|
29
|
+
|
30
|
+
case profile.type
|
31
|
+
when 'CareTeam'
|
32
|
+
more_choices << {
|
33
|
+
target_profiles: [
|
34
|
+
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitioner',
|
35
|
+
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitionerrole'
|
36
|
+
]
|
37
|
+
}
|
38
|
+
when 'Condition'
|
39
|
+
more_choices << {
|
40
|
+
paths: ['onsetDateTime'],
|
41
|
+
extension_ids: ['Condition.extension:assertedDate']
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
if more_choices.present?
|
46
|
+
must_supports[:choices] ||= []
|
47
|
+
must_supports[:choices].concat(more_choices)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def add_patient_uscdi_elements
|
52
|
+
return unless profile.type == 'Patient'
|
53
|
+
|
54
|
+
us_core_4_extractor.add_patient_uscdi_elements
|
55
|
+
|
56
|
+
must_supports[:extensions] << {
|
57
|
+
id: 'Patient.extension:genderIdentity',
|
58
|
+
url: 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-genderIdentity',
|
59
|
+
uscdi_only: true
|
60
|
+
}
|
61
|
+
must_supports[:elements] << {
|
62
|
+
path: 'address.use',
|
63
|
+
fixed_value: 'old',
|
64
|
+
uscdi_only: true
|
65
|
+
}
|
66
|
+
must_supports[:elements] << {
|
67
|
+
path: 'name.use',
|
68
|
+
fixed_value: 'old',
|
69
|
+
uscdi_only: true
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
def add_value_set_expansion
|
74
|
+
add_document_reference_category_values
|
75
|
+
add_service_request_category_values
|
76
|
+
end
|
77
|
+
|
78
|
+
def add_document_reference_category_values
|
79
|
+
return unless profile.type == 'DocumentReference'
|
80
|
+
|
81
|
+
slice = must_supports[:slices].find{|slice| slice[:path] == 'category'}
|
82
|
+
|
83
|
+
slice[:discriminator][:values] = ['clinical-note'] if slice.present?
|
84
|
+
end
|
85
|
+
|
86
|
+
def add_service_request_category_values
|
87
|
+
return unless profile.type == 'ServiceRequest'
|
88
|
+
|
89
|
+
slice = must_supports[:slices].find{|slice| slice[:path] == 'category'}
|
90
|
+
|
91
|
+
if slice.present?
|
92
|
+
slice[:discriminator][:values].concat(['108252007', '363679005', '409063005', '409073007', '387713003'])
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
# FHIR-37794 Server systems are not required to support US Core QuestionnaireResponse
|
97
|
+
def remove_survey_questionnaire_response
|
98
|
+
return unless profile.type == 'Observation' &&
|
99
|
+
['us-core-observation-survey', 'us-core-observation-sdoh-assessment'].include?(profile.id)
|
100
|
+
|
101
|
+
element = must_supports[:elements].find { |element| element[:path] == 'derivedFrom' }
|
102
|
+
element[:target_profiles].delete_if do |url|
|
103
|
+
url == 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-questionnaireresponse'
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
data/lib/us_core_test_kit.rb
CHANGED
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.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen MacVicar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inferno_core
|
@@ -115,11 +115,9 @@ files:
|
|
115
115
|
- lib/us_core_test_kit/custom_groups/v3.1.1/clinical_notes_guidance_group.rb
|
116
116
|
- lib/us_core_test_kit/custom_groups/v4.0.0/capability_statement_group.rb
|
117
117
|
- lib/us_core_test_kit/custom_groups/v4.0.0/clinical_notes_guidance_group.rb
|
118
|
-
- lib/us_core_test_kit/custom_groups/v4.0.0/device_udi_pi_test.rb
|
119
118
|
- lib/us_core_test_kit/custom_groups/v4.0.0/document_reference_custodian_test.rb
|
120
119
|
- lib/us_core_test_kit/custom_groups/v5.0.1/capability_statement_group.rb
|
121
120
|
- lib/us_core_test_kit/date_search_validation.rb
|
122
|
-
- lib/us_core_test_kit/ext/fhir_models.rb
|
123
121
|
- lib/us_core_test_kit/fhir_resource_navigation.rb
|
124
122
|
- lib/us_core_test_kit/generated/v3.1.1/allergy_intolerance/allergy_intolerance_must_support_test.rb
|
125
123
|
- lib/us_core_test_kit/generated/v3.1.1/allergy_intolerance/allergy_intolerance_patient_clinical_status_search_test.rb
|
@@ -1279,6 +1277,9 @@ files:
|
|
1279
1277
|
- lib/us_core_test_kit/generator/ig_metadata_extractor.rb
|
1280
1278
|
- lib/us_core_test_kit/generator/ig_resources.rb
|
1281
1279
|
- lib/us_core_test_kit/generator/must_support_metadata_extractor.rb
|
1280
|
+
- lib/us_core_test_kit/generator/must_support_metadata_extractor_us_core_3.rb
|
1281
|
+
- lib/us_core_test_kit/generator/must_support_metadata_extractor_us_core_4.rb
|
1282
|
+
- lib/us_core_test_kit/generator/must_support_metadata_extractor_us_core_5.rb
|
1282
1283
|
- lib/us_core_test_kit/generator/must_support_test_generator.rb
|
1283
1284
|
- lib/us_core_test_kit/generator/naming.rb
|
1284
1285
|
- lib/us_core_test_kit/generator/provenance_revinclude_search_test_generator.rb
|
@@ -1,40 +0,0 @@
|
|
1
|
-
module USCoreTestKit
|
2
|
-
module USCoreV400
|
3
|
-
class DeviceUdiPiTest < Inferno::Test
|
4
|
-
id :us_core_v400_device_udi_pi_test
|
5
|
-
title 'Device resources returned during previous tests have UDI-PI elements'
|
6
|
-
description %(
|
7
|
-
This test verifies implantable medical devices that have UDI information represent all of the UDI-PI elements that are present in the UDI code
|
8
|
-
in the corresponding US Core Implantable Device Profile element.
|
9
|
-
)
|
10
|
-
|
11
|
-
def scratch_resources
|
12
|
-
scratch[:device_resources] ||= {}
|
13
|
-
end
|
14
|
-
|
15
|
-
run do
|
16
|
-
resources = scratch_resources[:all] || []
|
17
|
-
|
18
|
-
skip_if resources.blank?,
|
19
|
-
'No Devices resources appear to be available. ' \
|
20
|
-
'Please use patients with more information.'
|
21
|
-
|
22
|
-
resources.each do |device|
|
23
|
-
if device.udiCarrier&.first&.carrierHRF.present? &&
|
24
|
-
!(
|
25
|
-
device.manufactureDate.present? ||
|
26
|
-
device.expirationDate.present? ||
|
27
|
-
device.lotNumber.present? ||
|
28
|
-
device.serialNumber.present? ||
|
29
|
-
device.distinctIdentifier.present?
|
30
|
-
)
|
31
|
-
add_message('error',
|
32
|
-
"Device/#{device.id} has UDI information but does not have any UDI-PI elements presented")
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
assert messages.blank?, "Resource has UDI information but does not have any UDI-PI elements presented"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
|
3
|
-
# Extension to FHIR::Model. Prepending this into FHIR::Model (done below)
|
4
|
-
# allows us to call super() on initialize when we overriding it,
|
5
|
-
# while also defining new methods and attributes
|
6
|
-
module InfernoFHIRModelExtensions
|
7
|
-
attr_accessor :source_hash, :source_text
|
8
|
-
|
9
|
-
def initialize(hash = {})
|
10
|
-
super(hash)
|
11
|
-
@source_hash = hash
|
12
|
-
end
|
13
|
-
|
14
|
-
def source_contents
|
15
|
-
@source_text || JSON.generate(@source_hash)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
module FHIR
|
20
|
-
class Model
|
21
|
-
prepend ::InfernoFHIRModelExtensions
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
# Extension to FHIR::Json. Prepending this into FHIR::Json (done below)
|
26
|
-
# allows us to call super() on from_json
|
27
|
-
module InfernoJson
|
28
|
-
def from_json(json)
|
29
|
-
resource = super(json)
|
30
|
-
resource.source_text = json
|
31
|
-
resource
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
# Extension to FHIR::Xml. Prepending this into FHIR::Xml (done below)
|
36
|
-
# allows us to call super() on from_xml
|
37
|
-
module InfernoXml
|
38
|
-
def from_xml(xml)
|
39
|
-
resource = super(xml)
|
40
|
-
resource.source_text = xml
|
41
|
-
resource
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
module FHIR
|
46
|
-
module Json
|
47
|
-
class << self
|
48
|
-
prepend InfernoJson
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
module FHIR
|
54
|
-
module Xml
|
55
|
-
class << self
|
56
|
-
prepend InfernoXml
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|