Class: CarinForBlueButtonTestKit::Generator::IncludeSearchTestGenerator
- Inherits:
-
Object
- Object
- CarinForBlueButtonTestKit::Generator::IncludeSearchTestGenerator
- Defined in:
- lib/carin_for_blue_button_test_kit/generator/include_search_test_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.
-
#search_param ⇒ Object
Returns the value of attribute search_param.
Instance Method Summary collapse
- #base_output_file_name ⇒ Object
- #class_name ⇒ Object
- #description ⇒ Object
- #generate ⇒ Object
- #include_parameters ⇒ Object
- #include_search_param ⇒ Object
- #include_search_type ⇒ Object
-
#initialize(group_metadata, search_param, base_output_dir) ⇒ IncludeSearchTestGenerator
constructor
A new instance of IncludeSearchTestGenerator.
- #input_description ⇒ Object
- #input_id ⇒ Object
- #input_title ⇒ Object
- #module_name ⇒ Object
- #output ⇒ Object
- #output_file_directory ⇒ Object
- #output_file_name ⇒ Object
- #profile_identifier ⇒ Object
- #remove_colon ⇒ Object
- #remove_star ⇒ Object
- #removed_hyphen ⇒ Object
- #resource_type ⇒ Object
- #template ⇒ Object
- #test_id ⇒ Object
Constructor Details
#initialize(group_metadata, search_param, base_output_dir) ⇒ IncludeSearchTestGenerator
Returns a new instance of IncludeSearchTestGenerator.
10 11 12 13 14 |
# File 'lib/carin_for_blue_button_test_kit/generator/include_search_test_generator.rb', line 10 def initialize(, search_param, base_output_dir) self. = self.search_param = search_param self.base_output_dir = base_output_dir end |
Instance Attribute Details
#base_output_dir ⇒ Object
Returns the value of attribute base_output_dir.
8 9 10 |
# File 'lib/carin_for_blue_button_test_kit/generator/include_search_test_generator.rb', line 8 def base_output_dir @base_output_dir end |
#group_metadata ⇒ Object
Returns the value of attribute group_metadata.
8 9 10 |
# File 'lib/carin_for_blue_button_test_kit/generator/include_search_test_generator.rb', line 8 def @group_metadata end |
#search_param ⇒ Object
Returns the value of attribute search_param.
8 9 10 |
# File 'lib/carin_for_blue_button_test_kit/generator/include_search_test_generator.rb', line 8 def search_param @search_param end |
Instance Method Details
#base_output_file_name ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/carin_for_blue_button_test_kit/generator/include_search_test_generator.rb', line 46 def base_output_file_name file_name = class_name file_name.sub!(resource_type, '') file_name = file_name.underscore file_name.sub!("#{profile_identifier}", 'incl') "#{file_name}.rb" end |
#class_name ⇒ Object
62 63 64 |
# File 'lib/carin_for_blue_button_test_kit/generator/include_search_test_generator.rb', line 62 def class_name "#{Naming.upper_camel_case_for_profile()}#{remove_star}SearchTest" end |
#description ⇒ Object
119 120 121 122 123 |
# File 'lib/carin_for_blue_button_test_kit/generator/include_search_test_generator.rb', line 119 def description <<~DESCRIPTION Tests that the server responds correctly when using _include="#{search_param}" as a search parameter DESCRIPTION end |
#generate ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/carin_for_blue_button_test_kit/generator/include_search_test_generator.rb', line 16 def generate FileUtils.mkdir_p(output_file_directory) File.open(output_file_name, 'w') { |f| f.write(output) } .add_test( id: test_id, file_name: base_output_file_name ) end |
#include_parameters ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/carin_for_blue_button_test_kit/generator/include_search_test_generator.rb', line 78 def include_parameters case search_param when 'ExplanationOfBenefit:payee' [{path: 'payee.party', target: 'Organization'}] when 'ExplanationOfBenefit:*' search_definitions = ['patient', 'provider', 'care-team', 'coverage', 'insurer'] include_params = [] search_definitions.each do |search_def| target_paths = .search_definitions[search_def.to_sym][:target_paths] include_params = include_params + target_paths end include_params else .search_definitions[include_search_type.to_sym][:target_paths] end end |
#include_search_param ⇒ Object
115 116 117 |
# File 'lib/carin_for_blue_button_test_kit/generator/include_search_test_generator.rb', line 115 def include_search_param search_param end |
#include_search_type ⇒ Object
95 96 97 |
# File 'lib/carin_for_blue_button_test_kit/generator/include_search_test_generator.rb', line 95 def include_search_type search_param.sub("#{resource_type}:", "") end |
#input_description ⇒ Object
74 75 76 |
# File 'lib/carin_for_blue_button_test_kit/generator/include_search_test_generator.rb', line 74 def input_description "#{resource_type} search parameter: _id" end |
#input_id ⇒ Object
66 67 68 |
# File 'lib/carin_for_blue_button_test_kit/generator/include_search_test_generator.rb', line 66 def input_id "c4bb_#{.reformatted_version}_#{profile_identifier}__id_search_test_param" end |
#input_title ⇒ Object
70 71 72 |
# File 'lib/carin_for_blue_button_test_kit/generator/include_search_test_generator.rb', line 70 def input_title "#{resource_type} search parameter for _id" end |
#module_name ⇒ Object
58 59 60 |
# File 'lib/carin_for_blue_button_test_kit/generator/include_search_test_generator.rb', line 58 def module_name "CARIN4BB#{.reformatted_version.upcase}" end |
#output ⇒ Object
30 31 32 |
# File 'lib/carin_for_blue_button_test_kit/generator/include_search_test_generator.rb', line 30 def output @output ||= ERB.new(template).result(binding) end |
#output_file_directory ⇒ Object
34 35 36 |
# File 'lib/carin_for_blue_button_test_kit/generator/include_search_test_generator.rb', line 34 def output_file_directory File.join(base_output_dir, profile_identifier) end |
#output_file_name ⇒ Object
38 39 40 |
# File 'lib/carin_for_blue_button_test_kit/generator/include_search_test_generator.rb', line 38 def output_file_name File.join(output_file_directory, base_output_file_name) end |
#profile_identifier ⇒ Object
42 43 44 |
# File 'lib/carin_for_blue_button_test_kit/generator/include_search_test_generator.rb', line 42 def profile_identifier Naming.snake_case_for_profile() end |
#remove_colon ⇒ Object
103 104 105 |
# File 'lib/carin_for_blue_button_test_kit/generator/include_search_test_generator.rb', line 103 def remove_colon removed_hyphen.gsub(':', '_') end |
#remove_star ⇒ Object
107 108 109 |
# File 'lib/carin_for_blue_button_test_kit/generator/include_search_test_generator.rb', line 107 def remove_star remove_colon.gsub('*', 'All') end |
#removed_hyphen ⇒ Object
99 100 101 |
# File 'lib/carin_for_blue_button_test_kit/generator/include_search_test_generator.rb', line 99 def removed_hyphen search_param.gsub('-', '') end |
#resource_type ⇒ Object
111 112 113 |
# File 'lib/carin_for_blue_button_test_kit/generator/include_search_test_generator.rb', line 111 def resource_type .resource end |
#template ⇒ Object
26 27 28 |
# File 'lib/carin_for_blue_button_test_kit/generator/include_search_test_generator.rb', line 26 def template @template ||= File.read(File.join(__dir__, 'templates', 'include_search.rb.erb')) end |
#test_id ⇒ Object
54 55 56 |
# File 'lib/carin_for_blue_button_test_kit/generator/include_search_test_generator.rb', line 54 def test_id "c4bb_#{.reformatted_version}_#{profile_identifier}_include_#{remove_star}_search_test" end |