Class: DaVinciUSDrugFormularyTestKit::Generator::GroupGenerator
- Inherits:
-
Object
- Object
- DaVinciUSDrugFormularyTestKit::Generator::GroupGenerator
- Defined in:
- lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb
Instance Attribute Summary collapse
-
#base_output_dir ⇒ Object
Returns the value of attribute base_output_dir.
-
#group_metadata ⇒ Object
Returns the value of attribute group_metadata.
Class Method Summary collapse
Instance Method Summary collapse
- #base_metadata_file_name ⇒ Object
- #base_output_file_name ⇒ Object
- #class_name ⇒ Object
- #description ⇒ Object
- #generate ⇒ Object
- #group_id ⇒ Object
-
#initialize(group_metadata, base_output_dir) ⇒ GroupGenerator
constructor
A new instance of GroupGenerator.
- #metadata_file_name ⇒ Object
- #module_name ⇒ Object
- #optional? ⇒ Boolean
- #output ⇒ Object
- #output_file_name ⇒ Object
- #profile_identifier ⇒ Object
- #profile_name ⇒ Object
- #profile_url ⇒ Object
- #required_searches ⇒ Object
- #resource_type ⇒ Object
- #search_description ⇒ Object
- #search_param_name_string ⇒ Object
- #search_validation_resource_type ⇒ Object
- #short_description ⇒ Object
- #template ⇒ Object
- #test_file_list ⇒ Object
- #test_id_list ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(group_metadata, base_output_dir) ⇒ GroupGenerator
Returns a new instance of GroupGenerator.
15 16 17 18 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb', line 15 def initialize(, base_output_dir) self. = self.base_output_dir = base_output_dir end |
Instance Attribute Details
#base_output_dir ⇒ Object
Returns the value of attribute base_output_dir.
13 14 15 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb', line 13 def base_output_dir @base_output_dir end |
#group_metadata ⇒ Object
Returns the value of attribute group_metadata.
13 14 15 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb', line 13 def @group_metadata end |
Class Method Details
.generate(ig_metadata, base_output_dir) ⇒ Object
7 8 9 10 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb', line 7 def generate(, base_output_dir) .ordered_groups .each { |group| new(group, base_output_dir).generate } end |
Instance Method Details
#base_metadata_file_name ⇒ Object
32 33 34 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb', line 32 def 'metadata.yml' end |
#base_output_file_name ⇒ Object
28 29 30 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb', line 28 def base_output_file_name "#{class_name.underscore}.rb" end |
#class_name ⇒ Object
36 37 38 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb', line 36 def class_name "#{Naming.upper_camel_case_for_profile()}Group" end |
#description ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb', line 144 def description <<~DESCRIPTION # Background The USDF #{title} sequence verifies that the system under test is able to provide correct responses for #{resource_type} queries. These queries must contain resources conforming to the #{profile_name} as specified in the USDF #{.version} Implementation Guide. # Testing Methodology #{search_description} ## Must Support Each profile contains elements marked as "must support". This test sequence expects to see each of these elements at least once. If at least one cannot be found, the test will fail. The test will look through the #{resource_type} resources found in the first test for these elements. ## Profile Validation Each resource returned from the first search is expected to conform to the [#{profile_name}](#{profile_url}). Each element is checked against teminology binding and cardinality requirements. Elements with a required binding are validated against their bound ValueSet. If the code/system in the element is not part of the ValueSet, then the test will fail. ## Reference Validation At least one instance of each external reference in elements marked as "must support" within the resources provided by the system must resolve. The test will attempt to read each reference found and will fail if no read succeeds. DESCRIPTION end |
#generate ⇒ Object
88 89 90 91 92 93 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb', line 88 def generate File.write(output_file_name, output) .id = group_id .file_name = base_output_file_name File.write(, YAML.dump(.to_hash)) end |
#group_id ⇒ Object
64 65 66 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb', line 64 def group_id "usdf_#{.reformatted_version}_#{profile_identifier}" end |
#metadata_file_name ⇒ Object
56 57 58 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb', line 56 def File.join(base_output_dir, profile_identifier, ) end |
#module_name ⇒ Object
40 41 42 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb', line 40 def module_name "USDF#{.reformatted_version.upcase}" end |
#optional? ⇒ Boolean
84 85 86 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb', line 84 def optional? false end |
#output ⇒ Object
24 25 26 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb', line 24 def output @output ||= ERB.new(template).result(binding) end |
#output_file_name ⇒ Object
52 53 54 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb', line 52 def output_file_name File.join(base_output_dir, base_output_file_name) end |
#profile_identifier ⇒ Object
60 61 62 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb', line 60 def profile_identifier Naming.snake_case_for_profile() end |
#profile_name ⇒ Object
76 77 78 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb', line 76 def profile_name .profile_name end |
#profile_url ⇒ Object
80 81 82 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb', line 80 def profile_url .profile_url end |
#required_searches ⇒ Object
108 109 110 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb', line 108 def required_searches .searches.select { |search| search[:expectation] == 'SHALL' } end |
#resource_type ⇒ Object
68 69 70 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb', line 68 def resource_type .resource end |
#search_description ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb', line 119 def search_description return '' if required_searches.blank? <<~SEARCH_DESCRIPTION ## Searching This test sequence will first perform each required search associated with this resource. This sequence will perform searches with the following parameters: #{search_param_name_string} ### Search Parameters The first search uses the selected resources from the prior launch sequence. Any subsequent searches will look for its parameter values from the results of the first search. If a value cannot be found this way, the search is skipped. ### Search Validation Inferno will retrieve up to the first 20 bundle pages of the reply for #{search_validation_resource_type} and save them for subsequent tests. Each of these resources is then checked to see if it matches the searched parameters in accordance with [FHIR search guidelines](https://www.hl7.org/fhir/search.html). SEARCH_DESCRIPTION end |
#search_param_name_string ⇒ Object
112 113 114 115 116 117 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb', line 112 def search_param_name_string required_searches .map { |search| search[:names].join(' + ') } .map { |names| "* #{names}" } .join("\n") end |
#search_validation_resource_type ⇒ Object
72 73 74 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb', line 72 def search_validation_resource_type "#{resource_type} resources" end |
#short_description ⇒ Object
48 49 50 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb', line 48 def short_description .short_description end |
#template ⇒ Object
20 21 22 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb', line 20 def template @template ||= File.read(File.join(__dir__, 'templates', 'group.rb.erb')) end |
#test_file_list ⇒ Object
100 101 102 103 104 105 106 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb', line 100 def test_file_list @test_file_list ||= .tests.map do |test| name_without_suffix = test[:file_name].delete_suffix('.rb') name_without_suffix.start_with?('..') ? name_without_suffix : "#{profile_identifier}/#{name_without_suffix}" end end |
#test_id_list ⇒ Object
95 96 97 98 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb', line 95 def test_id_list @test_id_list ||= .tests.map { |test| test[:id] } end |
#title ⇒ Object
44 45 46 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/group_generator.rb', line 44 def title .title end |