Class: PacioInfernoCore::Generator::GroupGenerator
- Inherits:
-
Object
- Object
- PacioInfernoCore::Generator::GroupGenerator
- Defined in:
- lib/pacio_inferno_core/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
- #add_special_tests ⇒ Object
- #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_with_version ⇒ Object
- #naming ⇒ 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.
17 18 19 20 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 17 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.
15 16 17 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 15 def base_output_dir @base_output_dir end |
#group_metadata ⇒ Object
Returns the value of attribute group_metadata.
15 16 17 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 15 def @group_metadata end |
Class Method Details
.generate(ig_metadata, base_output_dir) ⇒ Object
8 9 10 11 12 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 8 def generate(, base_output_dir) .ordered_groups .reject { |group| SpecialCases.exclude_group? group } .each { |group| new(group, base_output_dir).generate } end |
Instance Method Details
#add_special_tests ⇒ Object
102 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 102 def add_special_tests; end |
#base_metadata_file_name ⇒ Object
38 39 40 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 38 def 'metadata.yml' end |
#base_output_file_name ⇒ Object
34 35 36 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 34 def base_output_file_name "#{class_name.underscore}.rb" end |
#class_name ⇒ Object
42 43 44 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 42 def class_name "#{naming.upper_camel_case_for_profile()}Group" end |
#description ⇒ Object
158 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 158 def description; end |
#generate ⇒ Object
94 95 96 97 98 99 100 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 94 def generate add_special_tests 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
70 71 72 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 70 def group_id "#{naming.prefix}_#{.reformatted_version}_#{profile_identifier}" end |
#metadata_file_name ⇒ Object
62 63 64 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 62 def File.join(base_output_dir, profile_identifier, ) end |
#module_name_with_version ⇒ Object
46 47 48 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 46 def module_name_with_version "#{naming.module_name}#{.reformatted_version.upcase}" end |
#naming ⇒ Object
30 31 32 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 30 def naming self.class.module_parent::Naming end |
#optional? ⇒ Boolean
90 91 92 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 90 def optional? SpecialCases::OPTIONAL_RESOURCES.include?(resource_type) || .optional_profile? end |
#output ⇒ Object
26 27 28 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 26 def output @output ||= ERB.new(template, trim_mode: '-').result(binding) end |
#output_file_name ⇒ Object
58 59 60 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 58 def output_file_name File.join(base_output_dir, base_output_file_name) end |
#profile_identifier ⇒ Object
66 67 68 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 66 def profile_identifier naming.snake_case_for_profile() end |
#profile_name ⇒ Object
82 83 84 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 82 def profile_name .profile_name end |
#profile_url ⇒ Object
86 87 88 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 86 def profile_url .profile_url end |
#required_searches ⇒ Object
117 118 119 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 117 def required_searches .searches.select { |search| search[:expectation] == 'SHALL' } end |
#resource_type ⇒ Object
74 75 76 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 74 def resource_type .resource end |
#search_description ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 128 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 patient(s) from the prior launch sequence. Any subsequent searches will look for its parameter values from the results of the first search. For example, the `identifier` search in the patient sequence is performed by looking for an existing `Patient.identifier` from any of the resources returned in the `_id` 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). The test will fail, for example, if a Patient search for `gender=male` returns a `female` patient. SEARCH_DESCRIPTION end |
#search_param_name_string ⇒ Object
121 122 123 124 125 126 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 121 def search_param_name_string required_searches .map { |search| search[:names].join(' + ') } .map { |names| "* #{names}" } .join("\n") end |
#search_validation_resource_type ⇒ Object
78 79 80 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 78 def search_validation_resource_type "#{resource_type} resources" end |
#short_description ⇒ Object
54 55 56 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 54 def short_description .short_description end |
#template ⇒ Object
22 23 24 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 22 def template @template ||= File.read(File.join(__dir__, 'templates', 'group.rb.erb')) end |
#test_file_list ⇒ Object
109 110 111 112 113 114 115 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 109 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
104 105 106 107 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 104 def test_id_list @test_id_list ||= .tests.map { |test| test[:id] } end |
#title ⇒ Object
50 51 52 |
# File 'lib/pacio_inferno_core/generator/group_generator.rb', line 50 def title .title end |