us_core_test_kit 0.4.5 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/us_core_test_kit/fhir_resource_navigation.rb +9 -3
- data/lib/us_core_test_kit/generated/v3.1.1/metadata.yml +9 -1
- data/lib/us_core_test_kit/generated/v3.1.1/patient/metadata.yml +9 -1
- data/lib/us_core_test_kit/generated/v3.1.1/patient/patient_must_support_test.rb +5 -1
- 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 +10 -4
- data/lib/us_core_test_kit/generated/v4.0.0/patient/metadata.yml +9 -3
- data/lib/us_core_test_kit/generated/v4.0.0/patient/patient_must_support_test.rb +2 -2
- data/lib/us_core_test_kit/generated/v5.0.1/condition_encounter_diagnosis/metadata.yml +4 -4
- data/lib/us_core_test_kit/generated/v5.0.1/condition_problems_health_concerns/metadata.yml +4 -4
- 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 +23 -12
- data/lib/us_core_test_kit/generated/v5.0.1/patient/metadata.yml +9 -3
- data/lib/us_core_test_kit/generated/v5.0.1/patient/patient_must_support_test.rb +2 -4
- data/lib/us_core_test_kit/generated/v5.0.1/service_request/metadata.yml +5 -0
- 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 +62 -0
- data/lib/us_core_test_kit/generator/must_support_metadata_extractor_us_core_4.rb +110 -0
- data/lib/us_core_test_kit/generator/must_support_metadata_extractor_us_core_5.rb +113 -0
- data/lib/us_core_test_kit/generator/search_definition_metadata_extractor.rb +52 -4
- data/lib/us_core_test_kit/generator.rb +1 -1
- data/lib/us_core_test_kit/igs/us_core_501/StructureDefinition-condition-assertedDate.json +280 -0
- data/lib/us_core_test_kit/search_test.rb +1 -1
- data/lib/us_core_test_kit/version.rb +1 -1
- data/lib/us_core_test_kit.rb +0 -1
- metadata +6 -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
@@ -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,62 @@
|
|
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_patient_address_period
|
14
|
+
remove_document_reference_custodian
|
15
|
+
end
|
16
|
+
|
17
|
+
def add_must_support_choices
|
18
|
+
choices = []
|
19
|
+
|
20
|
+
case profile.type
|
21
|
+
when 'Device'
|
22
|
+
choices << { paths: ['udiCarrier.carrierAIDC', 'udiCarrier.carrierHRF'] }
|
23
|
+
when 'DocumentReference'
|
24
|
+
choices << { paths: ['content.attachment.data', 'content.attachment.url'] }
|
25
|
+
when 'Patient'
|
26
|
+
# FHIR-40299 adds USCDI MustSupport choices for:
|
27
|
+
# * address.period.end and address.use,
|
28
|
+
# * name.period.end and name.use
|
29
|
+
choices << {
|
30
|
+
paths: ['address.period.end', 'address.use'],
|
31
|
+
uscdi_only: true
|
32
|
+
}
|
33
|
+
|
34
|
+
choices << {
|
35
|
+
paths: ['name.period.end', 'name.use'],
|
36
|
+
uscdi_only: true
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
must_supports[:choices] = choices if choices.present?
|
41
|
+
end
|
42
|
+
|
43
|
+
# FHIR-40299 removes Patient.address.period from MustSupport,
|
44
|
+
def remove_patient_address_period
|
45
|
+
return unless profile.type == 'Patient'
|
46
|
+
|
47
|
+
must_supports[:elements].delete_if do |element|
|
48
|
+
element[:path] == 'address.period'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# US Core clarified that server implmentation is not required to support DocumentReference.custodian (FHIR-28393)
|
53
|
+
def remove_document_reference_custodian
|
54
|
+
return unless profile.type == 'DocumentReference'
|
55
|
+
|
56
|
+
must_supports[:elements].delete_if do |element|
|
57
|
+
element[:path] == 'custodian'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require_relative 'must_support_metadata_extractor_us_core_3'
|
2
|
+
|
3
|
+
module USCoreTestKit
|
4
|
+
class Generator
|
5
|
+
class MustSupportMetadataExtractorUsCore4
|
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
|
+
def us_core_3_extractor
|
14
|
+
@us_core_3_extractor ||= MustSupportMetadataExtractorUsCore3.new(profile, must_supports)
|
15
|
+
end
|
16
|
+
|
17
|
+
def handle_special_cases
|
18
|
+
add_must_support_choices
|
19
|
+
remove_patient_address_period
|
20
|
+
add_device_distinct_identifier
|
21
|
+
add_patient_uscdi_elements
|
22
|
+
end
|
23
|
+
|
24
|
+
def add_must_support_choices
|
25
|
+
choices = []
|
26
|
+
|
27
|
+
case profile.type
|
28
|
+
when 'DocumentReference'
|
29
|
+
choices << { paths: ['content.attachment.data', 'content.attachment.url'] }
|
30
|
+
when 'Encounter'
|
31
|
+
choices << { paths: ['reasonCode', 'reasonReference'] }
|
32
|
+
choices << { paths: ['location.location', 'serviceProvider'] }
|
33
|
+
when 'MedicationRequest'
|
34
|
+
choices << { paths: ['reportedBoolean', 'reportedReference'] }
|
35
|
+
when 'Patient'
|
36
|
+
# FHIR-40299 adds USCDI MustSupport choices for:
|
37
|
+
# * address.period.end and address.use,
|
38
|
+
# * name.period.end and name.use
|
39
|
+
choices << {
|
40
|
+
paths: ['address.period.end', 'address.use'],
|
41
|
+
uscdi_only: true
|
42
|
+
}
|
43
|
+
|
44
|
+
choices << {
|
45
|
+
paths: ['name.period.end', 'name.use'],
|
46
|
+
uscdi_only: true
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
must_supports[:choices] = choices if choices.present?
|
51
|
+
end
|
52
|
+
|
53
|
+
def remove_patient_address_period
|
54
|
+
us_core_3_extractor.remove_patient_address_period
|
55
|
+
end
|
56
|
+
|
57
|
+
def add_device_distinct_identifier
|
58
|
+
if profile.type == 'Device'
|
59
|
+
# FHIR-36303 US Core 4.0.0 mistakenly removed MS from Device.distinctIdentifier
|
60
|
+
# This will be fixed in US Core 5.0.0
|
61
|
+
must_supports[:elements] << {
|
62
|
+
path: 'distinctIdentifier'
|
63
|
+
}
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def add_patient_uscdi_elements
|
68
|
+
return unless profile.type == 'Patient'
|
69
|
+
|
70
|
+
#US Core 4.0.0 Section 10.112.1.1 Additional USCDI v1 Requirement:
|
71
|
+
must_supports[:extensions] << {
|
72
|
+
id: 'Patient.extension:race',
|
73
|
+
url: 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-race',
|
74
|
+
uscdi_only: true
|
75
|
+
}
|
76
|
+
must_supports[:extensions] << {
|
77
|
+
id: 'Patient.extension:ethnicity',
|
78
|
+
url: 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity',
|
79
|
+
uscdi_only: true
|
80
|
+
}
|
81
|
+
must_supports[:extensions] << {
|
82
|
+
id: 'Patient.extension:birthsex',
|
83
|
+
url: 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex',
|
84
|
+
uscdi_only: true
|
85
|
+
}
|
86
|
+
must_supports[:elements] << {
|
87
|
+
path: 'name.suffix',
|
88
|
+
uscdi_only: true
|
89
|
+
}
|
90
|
+
must_supports[:elements] << {
|
91
|
+
path: 'telecom',
|
92
|
+
uscdi_only: true
|
93
|
+
}
|
94
|
+
must_supports[:elements] << {
|
95
|
+
path: 'communication',
|
96
|
+
uscdi_only: true
|
97
|
+
}
|
98
|
+
# Though telecom.system, telecom.value, telecom.use, and communication.language are marked as MustSupport since US Core v4.0.0,
|
99
|
+
# their parent elements telecom, and communication are not MustSupport but listed under "Additional USCDI requirements"
|
100
|
+
# According to the updated FHIR spec that "When a child element is defined as Must Support and the parent element isn't,
|
101
|
+
# a system must support the child if it support the parent, but there's no expectation that the system must support the parent.",
|
102
|
+
# We add uscdi_only tag to these elements
|
103
|
+
must_supports[:elements].each do |element|
|
104
|
+
path = element[:path]
|
105
|
+
element[:uscdi_only] = true if path.include?('telecom.') || path.include?('communication.')
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,113 @@
|
|
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
|
+
remove_patient_address_period
|
21
|
+
add_patient_uscdi_elements
|
22
|
+
add_value_set_expansion
|
23
|
+
remove_survey_questionnaire_response
|
24
|
+
end
|
25
|
+
|
26
|
+
def add_must_support_choices
|
27
|
+
us_core_4_extractor.add_must_support_choices
|
28
|
+
|
29
|
+
more_choices = []
|
30
|
+
|
31
|
+
case profile.type
|
32
|
+
when 'CareTeam'
|
33
|
+
more_choices << {
|
34
|
+
target_profiles: [
|
35
|
+
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitioner',
|
36
|
+
'http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitionerrole'
|
37
|
+
]
|
38
|
+
}
|
39
|
+
when 'Condition'
|
40
|
+
more_choices << {
|
41
|
+
paths: ['onsetDateTime'],
|
42
|
+
extension_ids: ['Condition.extension:assertedDate']
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
if more_choices.present?
|
47
|
+
must_supports[:choices] ||= []
|
48
|
+
must_supports[:choices].concat(more_choices)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def remove_patient_address_period
|
53
|
+
us_core_4_extractor.remove_patient_address_period
|
54
|
+
end
|
55
|
+
|
56
|
+
def add_patient_uscdi_elements
|
57
|
+
return unless profile.type == 'Patient'
|
58
|
+
|
59
|
+
us_core_4_extractor.add_patient_uscdi_elements
|
60
|
+
|
61
|
+
must_supports[:extensions] << {
|
62
|
+
id: 'Patient.extension:genderIdentity',
|
63
|
+
url: 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-genderIdentity',
|
64
|
+
uscdi_only: true
|
65
|
+
}
|
66
|
+
must_supports[:elements] << {
|
67
|
+
path: 'address.use',
|
68
|
+
fixed_value: 'old',
|
69
|
+
uscdi_only: true
|
70
|
+
}
|
71
|
+
must_supports[:elements] << {
|
72
|
+
path: 'name.use',
|
73
|
+
fixed_value: 'old',
|
74
|
+
uscdi_only: true
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
def add_value_set_expansion
|
79
|
+
add_document_reference_category_values
|
80
|
+
add_service_request_category_values
|
81
|
+
end
|
82
|
+
|
83
|
+
def add_document_reference_category_values
|
84
|
+
return unless profile.type == 'DocumentReference'
|
85
|
+
|
86
|
+
slice = must_supports[:slices].find{|slice| slice[:path] == 'category'}
|
87
|
+
|
88
|
+
slice[:discriminator][:values] = ['clinical-note'] if slice.present?
|
89
|
+
end
|
90
|
+
|
91
|
+
def add_service_request_category_values
|
92
|
+
return unless profile.type == 'ServiceRequest'
|
93
|
+
|
94
|
+
slice = must_supports[:slices].find{|slice| slice[:path] == 'category'}
|
95
|
+
|
96
|
+
if slice.present?
|
97
|
+
slice[:discriminator][:values].concat(['108252007', '363679005', '409063005', '409073007', '387713003'])
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# FHIR-37794 Server systems are not required to support US Core QuestionnaireResponse
|
102
|
+
def remove_survey_questionnaire_response
|
103
|
+
return unless profile.type == 'Observation' &&
|
104
|
+
['us-core-observation-survey', 'us-core-observation-sdoh-assessment'].include?(profile.id)
|
105
|
+
|
106
|
+
element = must_supports[:elements].find { |element| element[:path] == 'derivedFrom' }
|
107
|
+
element[:target_profiles].delete_if do |url|
|
108
|
+
url == 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-questionnaireresponse'
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -37,22 +37,58 @@ module USCoreTestKit
|
|
37
37
|
def full_paths
|
38
38
|
@full_paths ||=
|
39
39
|
begin
|
40
|
-
path = param.expression.gsub(/.where\((.*)/, '')
|
40
|
+
path = param.expression.gsub(/.where\(resolve\((.*)/, '').gsub(/url = '/, 'url=\'')
|
41
41
|
path = path[1..-2] if path.start_with?('(') && path.end_with?(')')
|
42
42
|
path.scan(/[. ]as[( ]([^)]*)[)]?/).flatten.map do |as_type|
|
43
43
|
path.gsub!(/[. ]as[( ](#{as_type}[^)]*)[)]?/, as_type.upcase_first) if as_type.present?
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
|
+
full_paths = path.split('|')
|
47
|
+
|
48
|
+
# There is a bug in US Core 5 asserted-date search parameter. See FHIR-40573
|
49
|
+
if param.respond_to?(:version) && param.version == '5.0.1' && name == 'asserted-date'
|
50
|
+
remove_additional_extension_from_asserted_date(full_paths)
|
51
|
+
end
|
52
|
+
|
53
|
+
full_paths
|
46
54
|
end
|
47
55
|
end
|
48
56
|
|
57
|
+
def remove_additional_extension_from_asserted_date(full_paths)
|
58
|
+
full_paths.each do |full_path|
|
59
|
+
next unless full_path.include?('http://hl7.org/fhir/StructureDefinition/condition-assertedDate')
|
60
|
+
full_path.gsub!(/\).extension./, ').')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
49
64
|
def paths
|
50
65
|
@paths ||= full_paths.map { |a_path| a_path.gsub("#{resource}.", '') }
|
51
66
|
end
|
52
67
|
|
68
|
+
def extensions
|
69
|
+
@extensions ||= full_paths.select { |a_path| a_path.include?('extension.where') }
|
70
|
+
.map { |a_path| { url: a_path[/(?<=extension.where\(url=').*(?='\))/] }}
|
71
|
+
.presence
|
72
|
+
end
|
73
|
+
|
53
74
|
def profile_element
|
54
75
|
@profile_element ||=
|
55
|
-
|
76
|
+
(
|
77
|
+
profile_elements.find { |element| full_paths.include?(element.id) } ||
|
78
|
+
extension_definition&.differential&.element&.find { |element| element.id == 'Extension.value[x]'}
|
79
|
+
)
|
80
|
+
end
|
81
|
+
|
82
|
+
def extension_definition
|
83
|
+
@extension_definition ||=
|
84
|
+
begin
|
85
|
+
ext_definition = nil
|
86
|
+
extensions&.each do |ext_metadata|
|
87
|
+
ext_definition = ig_resources.profile_by_url(ext_metadata[:url])
|
88
|
+
break if ext_definition.present?
|
89
|
+
end
|
90
|
+
ext_definition
|
91
|
+
end
|
56
92
|
end
|
57
93
|
|
58
94
|
def comparator_expectation_extensions
|
@@ -90,7 +126,19 @@ module USCoreTestKit
|
|
90
126
|
end
|
91
127
|
|
92
128
|
def contains_multiple?
|
93
|
-
profile_element
|
129
|
+
if profile_element.present?
|
130
|
+
if profile_element.id.start_with?('Extension') && extension_definition.present?
|
131
|
+
# Find the extension instance in a US Core profile
|
132
|
+
target_element = profile_elements.find do |element|
|
133
|
+
element.type.any? { |type| type.code == "Extension" && type.profile.include?(extension_definition.url) }
|
134
|
+
end
|
135
|
+
target_element&.max == '*'
|
136
|
+
else
|
137
|
+
profile_element.max == '*'
|
138
|
+
end
|
139
|
+
else
|
140
|
+
false
|
141
|
+
end
|
94
142
|
end
|
95
143
|
|
96
144
|
def chain_extensions
|