davinci_us_drug_formulary_test_kit 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +201 -0
  3. data/lib/davinci_us_drug_formulary_test_kit/custom_groups/capability_statement/conformance_support_test.rb +41 -0
  4. data/lib/davinci_us_drug_formulary_test_kit/custom_groups/capability_statement/fhir_version_test.rb +15 -0
  5. data/lib/davinci_us_drug_formulary_test_kit/custom_groups/capability_statement/instantiate_test.rb +19 -0
  6. data/lib/davinci_us_drug_formulary_test_kit/custom_groups/capability_statement/json_support_test.rb +40 -0
  7. data/lib/davinci_us_drug_formulary_test_kit/custom_groups/capability_statement/profile_support_test.rb +39 -0
  8. data/lib/davinci_us_drug_formulary_test_kit/custom_groups/v2.0.1/capability_statement_group.rb +78 -0
  9. data/lib/davinci_us_drug_formulary_test_kit/date_search_validation.rb +121 -0
  10. data/lib/davinci_us_drug_formulary_test_kit/fhir_resource_navigation.rb +155 -0
  11. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/basic/basic_code_search_test.rb +54 -0
  12. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/basic/basic_drug_tier_search_test.rb +43 -0
  13. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/basic/basic_formulary_include_search_test.rb +40 -0
  14. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/basic/basic_formulary_search_test.rb +43 -0
  15. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/basic/basic_id_search_test.rb +42 -0
  16. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/basic/basic_lastupdated_search_test.rb +42 -0
  17. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/basic/basic_must_support_test.rb +46 -0
  18. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/basic/basic_period_search_test.rb +42 -0
  19. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/basic/basic_pharmacy_benefit_type_search_test.rb +43 -0
  20. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/basic/basic_read_test.rb +26 -0
  21. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/basic/basic_reference_resolution_test.rb +40 -0
  22. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/basic/basic_status_search_test.rb +42 -0
  23. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/basic/basic_subject_include_search_test.rb +40 -0
  24. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/basic/basic_subject_search_test.rb +43 -0
  25. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/basic/basic_validation_test.rb +39 -0
  26. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/basic/metadata.yml +292 -0
  27. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/basic_group.rb +107 -0
  28. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/formulary/formulary_coverage_area_search_test.rb +45 -0
  29. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/formulary/formulary_coverage_type_search_test.rb +45 -0
  30. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/formulary/formulary_formulary_coverage_search_test.rb +45 -0
  31. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/formulary/formulary_id_search_test.rb +42 -0
  32. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/formulary/formulary_identifier_search_test.rb +43 -0
  33. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/formulary/formulary_lastupdated_search_test.rb +42 -0
  34. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/formulary/formulary_must_support_test.rb +42 -0
  35. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/formulary/formulary_name_search_test.rb +42 -0
  36. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/formulary/formulary_period_search_test.rb +42 -0
  37. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/formulary/formulary_read_test.rb +26 -0
  38. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/formulary/formulary_status_search_test.rb +53 -0
  39. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/formulary/formulary_type_search_test.rb +43 -0
  40. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/formulary/formulary_validation_test.rb +39 -0
  41. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/formulary/metadata.yml +278 -0
  42. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/formulary_group.rb +104 -0
  43. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/location/location_address_city_search_test.rb +44 -0
  44. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/location/location_address_postalcode_search_test.rb +44 -0
  45. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/location/location_address_search_test.rb +42 -0
  46. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/location/location_address_state_search_test.rb +44 -0
  47. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/location/location_id_search_test.rb +56 -0
  48. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/location/location_lastupdated_search_test.rb +44 -0
  49. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/location/location_must_support_test.rb +37 -0
  50. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/location/location_read_test.rb +26 -0
  51. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/location/location_validation_test.rb +39 -0
  52. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/location/metadata.yml +177 -0
  53. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/location_group.rb +92 -0
  54. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/medication_knowledge/medication_knowledge_code_search_test.rb +43 -0
  55. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/medication_knowledge/medication_knowledge_doseform_search_test.rb +45 -0
  56. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/medication_knowledge/medication_knowledge_drug_name_search_test.rb +44 -0
  57. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/medication_knowledge/medication_knowledge_id_search_test.rb +42 -0
  58. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/medication_knowledge/medication_knowledge_lastupdated_search_test.rb +42 -0
  59. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/medication_knowledge/medication_knowledge_must_support_test.rb +47 -0
  60. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/medication_knowledge/medication_knowledge_read_test.rb +26 -0
  61. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/medication_knowledge/medication_knowledge_status_search_test.rb +53 -0
  62. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/medication_knowledge/medication_knowledge_validation_test.rb +39 -0
  63. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/medication_knowledge/metadata.yml +214 -0
  64. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/medication_knowledge_group.rb +91 -0
  65. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/metadata.yml +1192 -0
  66. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/payer_insurance_plan/metadata.yml +371 -0
  67. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/payer_insurance_plan/payer_insurance_plan_coverage_area_search_test.rb +43 -0
  68. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/payer_insurance_plan/payer_insurance_plan_coverage_type_search_test.rb +43 -0
  69. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/payer_insurance_plan/payer_insurance_plan_formulary_coverage_include_search_test.rb +40 -0
  70. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/payer_insurance_plan/payer_insurance_plan_formulary_coverage_search_test.rb +43 -0
  71. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/payer_insurance_plan/payer_insurance_plan_id_search_test.rb +42 -0
  72. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/payer_insurance_plan/payer_insurance_plan_identifier_search_test.rb +43 -0
  73. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/payer_insurance_plan/payer_insurance_plan_lastupdated_search_test.rb +42 -0
  74. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/payer_insurance_plan/payer_insurance_plan_must_support_test.rb +66 -0
  75. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/payer_insurance_plan/payer_insurance_plan_name_search_test.rb +42 -0
  76. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/payer_insurance_plan/payer_insurance_plan_period_search_test.rb +42 -0
  77. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/payer_insurance_plan/payer_insurance_plan_read_test.rb +26 -0
  78. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/payer_insurance_plan/payer_insurance_plan_reference_resolution_test.rb +40 -0
  79. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/payer_insurance_plan/payer_insurance_plan_status_search_test.rb +53 -0
  80. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/payer_insurance_plan/payer_insurance_plan_type_search_test.rb +43 -0
  81. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/payer_insurance_plan/payer_insurance_plan_validation_test.rb +39 -0
  82. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/payer_insurance_plan_group.rb +108 -0
  83. data/lib/davinci_us_drug_formulary_test_kit/generated/v2.0.1/usdf_test_suite.rb +114 -0
  84. data/lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb +181 -0
  85. data/lib/davinci_us_drug_formulary_test_kit/generator/group_metadata.rb +79 -0
  86. data/lib/davinci_us_drug_formulary_test_kit/generator/group_metadata_extractor.rb +329 -0
  87. data/lib/davinci_us_drug_formulary_test_kit/generator/ig_loader.rb +77 -0
  88. data/lib/davinci_us_drug_formulary_test_kit/generator/ig_metadata.rb +33 -0
  89. data/lib/davinci_us_drug_formulary_test_kit/generator/ig_metadata_extractor.rb +40 -0
  90. data/lib/davinci_us_drug_formulary_test_kit/generator/ig_resources.rb +60 -0
  91. data/lib/davinci_us_drug_formulary_test_kit/generator/include_search_test_generator.rb +68 -0
  92. data/lib/davinci_us_drug_formulary_test_kit/generator/must_support_metadata_extractor.rb +384 -0
  93. data/lib/davinci_us_drug_formulary_test_kit/generator/must_support_test_generator.rb +117 -0
  94. data/lib/davinci_us_drug_formulary_test_kit/generator/naming.rb +28 -0
  95. data/lib/davinci_us_drug_formulary_test_kit/generator/read_test_generator.rb +92 -0
  96. data/lib/davinci_us_drug_formulary_test_kit/generator/reference_resolution_test_generator.rb +91 -0
  97. data/lib/davinci_us_drug_formulary_test_kit/generator/search_definition_metadata_extractor.rb +187 -0
  98. data/lib/davinci_us_drug_formulary_test_kit/generator/search_metadata_extractor.rb +59 -0
  99. data/lib/davinci_us_drug_formulary_test_kit/generator/search_test_generator.rb +270 -0
  100. data/lib/davinci_us_drug_formulary_test_kit/generator/suite_generator.rb +94 -0
  101. data/lib/davinci_us_drug_formulary_test_kit/generator/terminology_binding_metadata_extractor.rb +116 -0
  102. data/lib/davinci_us_drug_formulary_test_kit/generator/validation_test_generator.rb +102 -0
  103. data/lib/davinci_us_drug_formulary_test_kit/generator/value_extractor.rb +113 -0
  104. data/lib/davinci_us_drug_formulary_test_kit/generator.rb +94 -0
  105. data/lib/davinci_us_drug_formulary_test_kit/igs/package/r4_search-parameters.json +65408 -0
  106. data/lib/davinci_us_drug_formulary_test_kit/igs/package.tgz +0 -0
  107. data/lib/davinci_us_drug_formulary_test_kit/must_support_test.rb +224 -0
  108. data/lib/davinci_us_drug_formulary_test_kit/read_test.rb +62 -0
  109. data/lib/davinci_us_drug_formulary_test_kit/reference_resolution_test.rb +174 -0
  110. data/lib/davinci_us_drug_formulary_test_kit/request_logger.rb +46 -0
  111. data/lib/davinci_us_drug_formulary_test_kit/search_test.rb +767 -0
  112. data/lib/davinci_us_drug_formulary_test_kit/search_test_properties.rb +58 -0
  113. data/lib/davinci_us_drug_formulary_test_kit/validation_test.rb +56 -0
  114. data/lib/davinci_us_drug_formulary_test_kit/version.rb +5 -0
  115. data/lib/davinci_us_drug_formulary_test_kit.rb +1 -0
  116. metadata +245 -0
@@ -0,0 +1,155 @@
1
+ module DaVinciUSDrugFormularyTestKit
2
+ module FHIRResourceNavigation
3
+ DAR_EXTENSION_URL = 'http://hl7.org/fhir/StructureDefinition/data-absent-reason'.freeze
4
+
5
+ def resolve_path(elements, path)
6
+ elements = Array.wrap(elements)
7
+ return elements if path.blank?
8
+
9
+ paths = path.split(/(?<!hl7)\./)
10
+ segment = paths.first
11
+ remaining_path = paths.drop(1).join('.')
12
+
13
+ elements.flat_map do |element|
14
+ child = get_next_value(element, segment)
15
+ resolve_path(child, remaining_path)
16
+ end.compact
17
+ end
18
+
19
+ def find_a_value_at(element, path, include_dar: false, &block)
20
+ return nil if element.nil?
21
+
22
+ elements = Array.wrap(element)
23
+
24
+ if path.empty?
25
+ unless include_dar
26
+ elements = elements.reject do |el|
27
+ el.respond_to?(:extension) && el.extension.any? { |ext| ext.url == DAR_EXTENSION_URL }
28
+ end
29
+ end
30
+
31
+ return elements.find(&block) if block_given?
32
+
33
+ return elements.first
34
+ end
35
+
36
+ path_segments = path.split(/(?<!hl7)\./)
37
+ segment = path_segments.shift.delete_suffix('[x]').gsub(/^class$/, 'local_class').gsub('[x]:', ':').to_sym
38
+
39
+ no_elements_present =
40
+ elements.none? do |element|
41
+ child = get_next_value(element, segment)
42
+
43
+ child.present? || child == false
44
+ end
45
+
46
+ return nil if no_elements_present
47
+
48
+ remaining_path = path_segments.join('.')
49
+
50
+ elements.each do |element|
51
+ child = get_next_value(element, segment)
52
+ element_found =
53
+ if block_given?
54
+ find_a_value_at(child, remaining_path, include_dar:, &block)
55
+ else
56
+ find_a_value_at(child, remaining_path, include_dar:)
57
+ end
58
+
59
+ return element_found if element_found.present? || element_found == false
60
+ end
61
+
62
+ nil
63
+ end
64
+
65
+ def get_next_value(element, property)
66
+ extension_url = property[/(?<=where\(url=').*(?='\))/]
67
+
68
+ if extension_url.present?
69
+ element.url == extension_url ? element : nil
70
+ elsif property.to_s.include?(':') && !property.to_s.include?('url')
71
+ find_slice_via_discriminator(element, property)
72
+
73
+ else
74
+ element.send(property)
75
+ end
76
+ rescue NoMethodError
77
+ nil
78
+ end
79
+
80
+ def find_slice_via_discriminator(element, property)
81
+ element_name = property.to_s.split(':')[0].gsub(/^class$/, 'local_class')
82
+ slice_name = property.to_s.split(':')[1].gsub(/^class$/, 'local_class')
83
+ if metadata.present?
84
+ slice_by_name = metadata.must_supports[:slices].find { |slice| slice[:slice_name] == slice_name }
85
+ discriminator = slice_by_name[:discriminator]
86
+ slices = Array.wrap(element.send(element_name))
87
+ slices.find do |slice|
88
+ case discriminator[:type]
89
+ when 'patternCodeableConcept'
90
+ slice_value = discriminator[:path].present? ? slice.send((discriminator[:path]).to_s).coding : slice.coding
91
+ slice_value.any? { |coding| coding.code == discriminator[:code] && coding.system == discriminator[:system] }
92
+ when 'patternCoding'
93
+ slice_value = discriminator[:path].present? ? slice.send(discriminator[:path]) : slice
94
+ slice_value.code == discriminator[:code] && slice_value.system == discriminator[:system]
95
+ when 'patternIdentifier'
96
+ slice.identifier.system == discriminator[:system]
97
+ when 'value'
98
+ values = discriminator[:values].map { |value| value.merge(path: value[:path].split('.')) }
99
+ verify_slice_by_values(slice, values)
100
+ when 'type'
101
+ case discriminator[:code]
102
+ when 'Date'
103
+ begin
104
+ Date.parse(slice)
105
+ rescue ArgumentError
106
+ false
107
+ end
108
+ when 'DateTime'
109
+ begin
110
+ DateTime.parse(slice)
111
+ rescue ArgumentError
112
+ false
113
+ end
114
+ when 'String'
115
+ slice.is_a? String
116
+ else
117
+ slice.is_a? FHIR.const_get(discriminator[:code])
118
+ end
119
+ when 'requiredBinding'
120
+ discriminator[:path].present? ? slice.send((discriminator[:path]).to_s).coding : slice.coding
121
+ slice_value { |coding| discriminator[:values].include?(coding.code) }
122
+ end
123
+ end
124
+ else
125
+ # TODO: Error handling for if this file doesn't have access to metadata for some reason (begin/rescue with StandardError?)
126
+ end
127
+ end
128
+
129
+ def verify_slice_by_values(element, value_definitions)
130
+ path_prefixes = value_definitions.map { |value_definition| value_definition[:path].first }.uniq
131
+ path_prefixes.all? do |path_prefix|
132
+ value_definitions_for_path =
133
+ value_definitions
134
+ .select { |value_definition| value_definition[:path].first == path_prefix }
135
+ .each { |value_definition| value_definition[:path].shift }
136
+ find_a_value_at(element, path_prefix) do |el_found|
137
+ child_element_value_definitions, current_element_value_definitions =
138
+ value_definitions_for_path.partition { |value_definition| value_definition[:path].present? }
139
+
140
+ current_element_values_match =
141
+ current_element_value_definitions
142
+ .all? { |value_definition| value_definition[:value] == el_found }
143
+
144
+ child_element_values_match =
145
+ if child_element_value_definitions.present?
146
+ verify_slice_by_values(el_found, child_element_value_definitions)
147
+ else
148
+ true
149
+ end
150
+ current_element_values_match && child_element_values_match
151
+ end
152
+ end
153
+ end
154
+ end
155
+ end
@@ -0,0 +1,54 @@
1
+ require_relative '../../../search_test'
2
+ require_relative '../../../generator/group_metadata'
3
+
4
+ module DaVinciUSDrugFormularyTestKit
5
+ module DaVinciUSDrugFormularyV201
6
+ class BasicCodeSearchTest < Inferno::Test
7
+ include DaVinciUSDrugFormularyTestKit::SearchTest
8
+
9
+ title 'Server returns valid results for Basic search by code'
10
+ description %(
11
+ A server SHALL support searching by
12
+ code on the Basic 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
+ Because this is the first search of the sequence, resources in the
17
+ response will be used for subsequent tests.
18
+
19
+ Additionally, this test will check that GET and POST search methods
20
+ return the same number of results. Search by POST is required by the
21
+ FHIR R4 specification, and these tests interpret search by GET as a
22
+ requirement of US Core v2.0.1.
23
+
24
+ [US Drug Formulary](http://hl7.org/fhir/us/davinci-drug-formulary/STU2/CapabilityStatement-usdf-server.html)
25
+
26
+ )
27
+
28
+ id :usdf_v201_basic_code_search_test
29
+
30
+ def self.properties
31
+ @properties ||= SearchTestProperties.new(
32
+ first_search: true,
33
+ fixed_value_search: true,
34
+ resource_type: 'Basic',
35
+ search_param_names: ['code'],
36
+ token_search_params: ['code'],
37
+ test_post_search: true
38
+ )
39
+ end
40
+
41
+ def self.metadata
42
+ @metadata ||= Generator::GroupMetadata.new(YAML.load_file(File.join(__dir__, 'metadata.yml'), aliases: true))
43
+ end
44
+
45
+ def scratch_resources
46
+ scratch[:basic_resources] ||= {}
47
+ end
48
+
49
+ run do
50
+ run_search_test
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,43 @@
1
+ require_relative '../../../search_test'
2
+ require_relative '../../../generator/group_metadata'
3
+
4
+ module DaVinciUSDrugFormularyTestKit
5
+ module DaVinciUSDrugFormularyV201
6
+ class BasicDrugTierSearchTest < Inferno::Test
7
+ include DaVinciUSDrugFormularyTestKit::SearchTest
8
+
9
+ title 'Server returns valid results for Basic search by drug-tier'
10
+ description %(
11
+ A server SHALL support searching by
12
+ drug-tier on the Basic 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 Drug Formulary](http://hl7.org/fhir/us/davinci-drug-formulary/STU2/CapabilityStatement-usdf-server.html)
17
+
18
+ )
19
+
20
+ id :usdf_v201_basic_drug_tier_search_test
21
+
22
+ def self.properties
23
+ @properties ||= SearchTestProperties.new(
24
+ resource_type: 'Basic',
25
+ search_param_names: ['drug-tier'],
26
+ token_search_params: ['drug-tier']
27
+ )
28
+ end
29
+
30
+ def self.metadata
31
+ @metadata ||= Generator::GroupMetadata.new(YAML.load_file(File.join(__dir__, 'metadata.yml'), aliases: true))
32
+ end
33
+
34
+ def scratch_resources
35
+ scratch[:basic_resources] ||= {}
36
+ end
37
+
38
+ run do
39
+ run_search_test
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,40 @@
1
+ require_relative '../../../search_test'
2
+ require_relative '../../../generator/group_metadata'
3
+
4
+ module DaVinciUSDrugFormularyTestKit
5
+ module DaVinciUSDrugFormularyV201
6
+ class BasicFormularyIncludeSearchTest < Inferno::Test
7
+ include DaVinciUSDrugFormularyTestKit::SearchTest
8
+
9
+ title 'Server returns InsurancePlan resources from Basic search by _include=formulary'
10
+ description %(
11
+ A server SHALL be capable of supporting _includes for formulary.
12
+
13
+ This test will perform a search using _include=formulary and
14
+ will pass if the referenced InsurancePlan is included in the response.
15
+ )
16
+
17
+ id :usdf_v201_basic_formulary_include_search_test
18
+
19
+ def self.properties
20
+ @properties ||= SearchTestProperties.new(
21
+ resource_type: 'Basic',
22
+ search_param_names: ["code"],
23
+ include_param: 'formulary'
24
+ )
25
+ end
26
+
27
+ def self.metadata
28
+ @metadata ||= Generator::GroupMetadata.new(YAML.load_file(File.join(__dir__, 'metadata.yml')))
29
+ end
30
+
31
+ def self.include_metadata
32
+ @include_metadata ||= Generator::GroupMetadata.new(YAML.load_file(File.join(__dir__, '..', 'InsurancePlan', 'metadata.yml'), aliases: true))
33
+ end
34
+
35
+ run do
36
+ run_include_search_test
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,43 @@
1
+ require_relative '../../../search_test'
2
+ require_relative '../../../generator/group_metadata'
3
+
4
+ module DaVinciUSDrugFormularyTestKit
5
+ module DaVinciUSDrugFormularyV201
6
+ class BasicFormularySearchTest < Inferno::Test
7
+ include DaVinciUSDrugFormularyTestKit::SearchTest
8
+
9
+ title 'Server returns valid results for Basic search by formulary'
10
+ description %(
11
+ A server SHALL support searching by
12
+ formulary on the Basic 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 Drug Formulary](http://hl7.org/fhir/us/davinci-drug-formulary/STU2/CapabilityStatement-usdf-server.html)
17
+
18
+ )
19
+
20
+ id :usdf_v201_basic_formulary_search_test
21
+
22
+ def self.properties
23
+ @properties ||= SearchTestProperties.new(
24
+ resource_type: 'Basic',
25
+ search_param_names: ['formulary'],
26
+ test_reference_variants: true
27
+ )
28
+ end
29
+
30
+ def self.metadata
31
+ @metadata ||= Generator::GroupMetadata.new(YAML.load_file(File.join(__dir__, 'metadata.yml'), aliases: true))
32
+ end
33
+
34
+ def scratch_resources
35
+ scratch[:basic_resources] ||= {}
36
+ end
37
+
38
+ run do
39
+ run_search_test
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,42 @@
1
+ require_relative '../../../search_test'
2
+ require_relative '../../../generator/group_metadata'
3
+
4
+ module DaVinciUSDrugFormularyTestKit
5
+ module DaVinciUSDrugFormularyV201
6
+ class BasicIdSearchTest < Inferno::Test
7
+ include DaVinciUSDrugFormularyTestKit::SearchTest
8
+
9
+ title 'Server returns valid results for Basic search by _id'
10
+ description %(
11
+ A server SHALL support searching by
12
+ _id on the Basic 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 Drug Formulary](http://hl7.org/fhir/us/davinci-drug-formulary/STU2/CapabilityStatement-usdf-server.html)
17
+
18
+ )
19
+
20
+ id :usdf_v201_basic__id_search_test
21
+
22
+ def self.properties
23
+ @properties ||= SearchTestProperties.new(
24
+ resource_type: 'Basic',
25
+ search_param_names: ['_id']
26
+ )
27
+ end
28
+
29
+ def self.metadata
30
+ @metadata ||= Generator::GroupMetadata.new(YAML.load_file(File.join(__dir__, 'metadata.yml'), aliases: true))
31
+ end
32
+
33
+ def scratch_resources
34
+ scratch[:basic_resources] ||= {}
35
+ end
36
+
37
+ run do
38
+ run_search_test
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,42 @@
1
+ require_relative '../../../search_test'
2
+ require_relative '../../../generator/group_metadata'
3
+
4
+ module DaVinciUSDrugFormularyTestKit
5
+ module DaVinciUSDrugFormularyV201
6
+ class BasicLastupdatedSearchTest < Inferno::Test
7
+ include DaVinciUSDrugFormularyTestKit::SearchTest
8
+
9
+ title 'Server returns valid results for Basic search by _lastUpdated'
10
+ description %(
11
+ A server SHALL support searching by
12
+ _lastUpdated on the Basic 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 Drug Formulary](http://hl7.org/fhir/us/davinci-drug-formulary/STU2/CapabilityStatement-usdf-server.html)
17
+
18
+ )
19
+
20
+ id :usdf_v201_basic__lastUpdated_search_test
21
+
22
+ def self.properties
23
+ @properties ||= SearchTestProperties.new(
24
+ resource_type: 'Basic',
25
+ search_param_names: ['_lastUpdated']
26
+ )
27
+ end
28
+
29
+ def self.metadata
30
+ @metadata ||= Generator::GroupMetadata.new(YAML.load_file(File.join(__dir__, 'metadata.yml'), aliases: true))
31
+ end
32
+
33
+ def scratch_resources
34
+ scratch[:basic_resources] ||= {}
35
+ end
36
+
37
+ run do
38
+ run_search_test
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,46 @@
1
+ require_relative '../../../must_support_test'
2
+
3
+ module DaVinciUSDrugFormularyTestKit
4
+ module DaVinciUSDrugFormularyV201
5
+ class BasicMustSupportTest < Inferno::Test
6
+ include DaVinciUSDrugFormularyTestKit::MustSupportTest
7
+
8
+ title 'All must support elements are provided in the Basic resources returned'
9
+ description %(
10
+ US Drug Formulary Responders SHALL be capable of populating all data elements as
11
+ part of the query results as specified by the US Drug Formulary Capability
12
+ Statement. This test will look through the Basic resources
13
+ found previously for the following must support elements:
14
+
15
+ * Basic.extension:usdf-AvailabilityPeriod-extension
16
+ * Basic.extension:usdf-AvailabilityStatus-extension
17
+ * Basic.extension:usdf-DrugTierID-extension
18
+ * Basic.extension:usdf-FormularyReference-extension
19
+ * Basic.extension:usdf-PharmacyBenefitType-extension
20
+ * Basic.extension:usdf-PriorAuthorization-extension
21
+ * Basic.extension:usdf-QuantityLimit-extension
22
+ * Basic.extension:usdf-StepTherapyLimit-extension
23
+ * Basic.meta.lastUpdated
24
+ * Basic.subject
25
+ )
26
+
27
+ id :usdf_v201_basic_must_support_test
28
+
29
+ def resource_type
30
+ 'Basic'
31
+ end
32
+
33
+ def self.metadata
34
+ @metadata ||= Generator::GroupMetadata.new(YAML.load_file(File.join(__dir__, 'metadata.yml'), aliases: true))
35
+ end
36
+
37
+ def scratch_resources
38
+ scratch[:basic_resources] ||= {}
39
+ end
40
+
41
+ run do
42
+ perform_must_support_test(all_scratch_resources)
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,42 @@
1
+ require_relative '../../../search_test'
2
+ require_relative '../../../generator/group_metadata'
3
+
4
+ module DaVinciUSDrugFormularyTestKit
5
+ module DaVinciUSDrugFormularyV201
6
+ class BasicPeriodSearchTest < Inferno::Test
7
+ include DaVinciUSDrugFormularyTestKit::SearchTest
8
+
9
+ title 'Server returns valid results for Basic search by period'
10
+ description %(
11
+ A server SHALL support searching by
12
+ period on the Basic 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 Drug Formulary](http://hl7.org/fhir/us/davinci-drug-formulary/STU2/CapabilityStatement-usdf-server.html)
17
+
18
+ )
19
+
20
+ id :usdf_v201_basic_period_search_test
21
+
22
+ def self.properties
23
+ @properties ||= SearchTestProperties.new(
24
+ resource_type: 'Basic',
25
+ search_param_names: ['period']
26
+ )
27
+ end
28
+
29
+ def self.metadata
30
+ @metadata ||= Generator::GroupMetadata.new(YAML.load_file(File.join(__dir__, 'metadata.yml'), aliases: true))
31
+ end
32
+
33
+ def scratch_resources
34
+ scratch[:basic_resources] ||= {}
35
+ end
36
+
37
+ run do
38
+ run_search_test
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,43 @@
1
+ require_relative '../../../search_test'
2
+ require_relative '../../../generator/group_metadata'
3
+
4
+ module DaVinciUSDrugFormularyTestKit
5
+ module DaVinciUSDrugFormularyV201
6
+ class BasicPharmacyBenefitTypeSearchTest < Inferno::Test
7
+ include DaVinciUSDrugFormularyTestKit::SearchTest
8
+
9
+ title 'Server returns valid results for Basic search by pharmacy-benefit-type'
10
+ description %(
11
+ A server SHALL support searching by
12
+ pharmacy-benefit-type on the Basic 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 Drug Formulary](http://hl7.org/fhir/us/davinci-drug-formulary/STU2/CapabilityStatement-usdf-server.html)
17
+
18
+ )
19
+
20
+ id :usdf_v201_basic_pharmacy_benefit_type_search_test
21
+
22
+ def self.properties
23
+ @properties ||= SearchTestProperties.new(
24
+ resource_type: 'Basic',
25
+ search_param_names: ['pharmacy-benefit-type'],
26
+ token_search_params: ['pharmacy-benefit-type']
27
+ )
28
+ end
29
+
30
+ def self.metadata
31
+ @metadata ||= Generator::GroupMetadata.new(YAML.load_file(File.join(__dir__, 'metadata.yml'), aliases: true))
32
+ end
33
+
34
+ def scratch_resources
35
+ scratch[:basic_resources] ||= {}
36
+ end
37
+
38
+ run do
39
+ run_search_test
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,26 @@
1
+ require_relative '../../../read_test'
2
+
3
+ module DaVinciUSDrugFormularyTestKit
4
+ module USDFV201
5
+ class BasicReadTest < Inferno::Test
6
+ include DaVinciUSDrugFormularyTestKit::ReadTest
7
+
8
+ title 'Server returns correct Basic resource from Basic read interaction'
9
+ description 'A server SHALL support the Basic read interaction.'
10
+
11
+ id :usdf_v201_basic_read_test
12
+
13
+ def resource_type
14
+ 'Basic'
15
+ end
16
+
17
+ def scratch_resources
18
+ scratch[:basic_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,40 @@
1
+ require_relative '../../../reference_resolution_test'
2
+
3
+ module DaVinciUSDrugFormularyTestKit
4
+ module DaVinciUSDrugFormularyV201
5
+ class BasicReferenceResolutionTest < Inferno::Test
6
+ include DaVinciUSDrugFormularyTestKit::ReferenceResolutionTest
7
+
8
+ title 'MustSupport references within Basic resources are valid'
9
+ description %(
10
+ This test will attempt to read external references provided within elements
11
+ marked as 'MustSupport', if any are available.
12
+
13
+ It verifies that at least one external reference for each MustSupport Reference element
14
+ can be accessed by the test client, and conforms to corresponding US Core profile.
15
+
16
+ Elements which may provide external references include:
17
+
18
+ * Basic.subject
19
+ )
20
+
21
+ id :usdf_v201_basic_reference_resolution_test
22
+
23
+ def resource_type
24
+ 'Basic'
25
+ end
26
+
27
+ def self.metadata
28
+ @metadata ||= Generator::GroupMetadata.new(YAML.load_file(File.join(__dir__, 'metadata.yml'), aliases: true))
29
+ end
30
+
31
+ def scratch_resources
32
+ scratch[:basic_resources] ||= {}
33
+ end
34
+
35
+ run do
36
+ perform_reference_resolution_test(scratch_resources[:all])
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,42 @@
1
+ require_relative '../../../search_test'
2
+ require_relative '../../../generator/group_metadata'
3
+
4
+ module DaVinciUSDrugFormularyTestKit
5
+ module DaVinciUSDrugFormularyV201
6
+ class BasicStatusSearchTest < Inferno::Test
7
+ include DaVinciUSDrugFormularyTestKit::SearchTest
8
+
9
+ title 'Server returns valid results for Basic search by status'
10
+ description %(
11
+ A server SHALL support searching by
12
+ status on the Basic 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 Drug Formulary](http://hl7.org/fhir/us/davinci-drug-formulary/STU2/CapabilityStatement-usdf-server.html)
17
+
18
+ )
19
+
20
+ id :usdf_v201_basic_status_search_test
21
+
22
+ def self.properties
23
+ @properties ||= SearchTestProperties.new(
24
+ resource_type: 'Basic',
25
+ search_param_names: ['status']
26
+ )
27
+ end
28
+
29
+ def self.metadata
30
+ @metadata ||= Generator::GroupMetadata.new(YAML.load_file(File.join(__dir__, 'metadata.yml'), aliases: true))
31
+ end
32
+
33
+ def scratch_resources
34
+ scratch[:basic_resources] ||= {}
35
+ end
36
+
37
+ run do
38
+ run_search_test
39
+ end
40
+ end
41
+ end
42
+ end