Class: DaVinciUSDrugFormularyTestKit::Generator::ValidationTestGenerator
- Inherits:
-
Object
- Object
- DaVinciUSDrugFormularyTestKit::Generator::ValidationTestGenerator
- Defined in:
- lib/davinci_us_drug_formulary_test_kit/generator/validation_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.
Class Method Summary collapse
Instance Method Summary collapse
- #base_output_file_name ⇒ Object
- #class_name ⇒ Object
- #description ⇒ Object
- #directory_name ⇒ Object
- #generate ⇒ Object
-
#initialize(group_metadata, base_output_dir:) ⇒ ValidationTestGenerator
constructor
A new instance of ValidationTestGenerator.
- #module_name ⇒ Object
- #output ⇒ Object
- #output_file_directory ⇒ Object
- #output_file_name ⇒ Object
- #profile_identifier ⇒ Object
- #profile_name ⇒ Object
- #profile_url ⇒ Object
- #profile_version ⇒ Object
- #resource_type ⇒ Object
- #template ⇒ Object
- #test_id ⇒ Object
Constructor Details
#initialize(group_metadata, base_output_dir:) ⇒ ValidationTestGenerator
Returns a new instance of ValidationTestGenerator.
14 15 16 17 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/validation_test_generator.rb', line 14 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.
12 13 14 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/validation_test_generator.rb', line 12 def base_output_dir @base_output_dir end |
#group_metadata ⇒ Object
Returns the value of attribute group_metadata.
12 13 14 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/validation_test_generator.rb', line 12 def @group_metadata end |
Class Method Details
.generate(ig_metadata, base_output_dir) ⇒ Object
6 7 8 9 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/validation_test_generator.rb', line 6 def generate(, base_output_dir) .groups .each { |group| new(group, base_output_dir:).generate } end |
Instance Method Details
#base_output_file_name ⇒ Object
27 28 29 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/validation_test_generator.rb', line 27 def base_output_file_name "#{class_name.underscore}.rb" end |
#class_name ⇒ Object
63 64 65 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/validation_test_generator.rb', line 63 def class_name "#{Naming.upper_camel_case_for_profile()}ValidationTest" end |
#description ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/validation_test_generator.rb', line 75 def description <<~DESCRIPTION This test verifies resources returned from the first search conform to the [#{profile_name} profile](#{profile_url}). Systems must demonstrate at least one valid example in order to pass this test. It verifies the presence of mandatory elements and that elements with required bindings contain appropriate values. CodeableConcept element bindings will fail if none of their codings have a code/system belonging to the bound ValueSet. Quantity, Coding, and code element bindings will fail if their code/system are not found in the valueset. DESCRIPTION end |
#directory_name ⇒ Object
39 40 41 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/validation_test_generator.rb', line 39 def directory_name Naming.snake_case_for_profile() end |
#generate ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/validation_test_generator.rb', line 89 def generate FileUtils.mkdir_p(output_file_directory) File.write(output_file_name, output) = { id: test_id, file_name: base_output_file_name } .add_test(**) end |
#module_name ⇒ Object
67 68 69 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/validation_test_generator.rb', line 67 def module_name "DaVinciUSDrugFormulary#{.reformatted_version.upcase}" end |
#output ⇒ Object
23 24 25 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/validation_test_generator.rb', line 23 def output @output ||= ERB.new(template).result(binding) end |
#output_file_directory ⇒ Object
31 32 33 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/validation_test_generator.rb', line 31 def output_file_directory File.join(base_output_dir, directory_name) end |
#output_file_name ⇒ Object
35 36 37 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/validation_test_generator.rb', line 35 def output_file_name File.join(output_file_directory, base_output_file_name) end |
#profile_identifier ⇒ Object
43 44 45 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/validation_test_generator.rb', line 43 def profile_identifier Naming.snake_case_for_profile() end |
#profile_name ⇒ Object
51 52 53 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/validation_test_generator.rb', line 51 def profile_name .profile_name end |
#profile_url ⇒ Object
47 48 49 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/validation_test_generator.rb', line 47 def profile_url .profile_url end |
#profile_version ⇒ Object
55 56 57 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/validation_test_generator.rb', line 55 def profile_version .profile_version end |
#resource_type ⇒ Object
71 72 73 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/validation_test_generator.rb', line 71 def resource_type .resource end |
#template ⇒ Object
19 20 21 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/validation_test_generator.rb', line 19 def template @template ||= File.read(File.join(__dir__, 'templates', 'validation.rb.erb')) end |
#test_id ⇒ Object
59 60 61 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/validation_test_generator.rb', line 59 def test_id "usdf_#{.reformatted_version}_#{profile_identifier}_validation_test" end |