Class: DaVinciUSDrugFormularyTestKit::Generator::ReferenceResolutionTestGenerator
- Inherits:
-
Object
- Object
- DaVinciUSDrugFormularyTestKit::Generator::ReferenceResolutionTestGenerator
- Defined in:
- lib/davinci_us_drug_formulary_test_kit/generator/reference_resolution_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
- #generate ⇒ Object
-
#initialize(group_metadata, base_output_dir) ⇒ ReferenceResolutionTestGenerator
constructor
A new instance of ReferenceResolutionTestGenerator.
- #module_name ⇒ Object
- #must_support_reference_list_string ⇒ Object
- #must_support_references ⇒ Object
- #output ⇒ Object
- #output_file_directory ⇒ Object
- #output_file_name ⇒ Object
- #profile_identifier ⇒ Object
- #resource_collection_string ⇒ Object
- #resource_type ⇒ Object
- #template ⇒ Object
- #test_id ⇒ Object
Constructor Details
#initialize(group_metadata, base_output_dir) ⇒ ReferenceResolutionTestGenerator
Returns a new instance of ReferenceResolutionTestGenerator.
15 16 17 18 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/reference_resolution_test_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/reference_resolution_test_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/reference_resolution_test_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/reference_resolution_test_generator.rb', line 7 def generate(, base_output_dir) .groups .each { |group| new(group, base_output_dir).generate } end |
Instance Method Details
#base_output_file_name ⇒ Object
28 29 30 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/reference_resolution_test_generator.rb', line 28 def base_output_file_name "#{class_name.underscore}.rb" end |
#class_name ⇒ Object
48 49 50 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/reference_resolution_test_generator.rb', line 48 def class_name "#{Naming.upper_camel_case_for_profile()}ReferenceResolutionTest" end |
#generate ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/reference_resolution_test_generator.rb', line 78 def generate return if must_support_references.empty? FileUtils.mkdir_p(output_file_directory) File.write(output_file_name, output) .add_test( id: test_id, file_name: base_output_file_name ) end |
#module_name ⇒ Object
52 53 54 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/reference_resolution_test_generator.rb', line 52 def module_name "DaVinciUSDrugFormulary#{.reformatted_version.upcase}" end |
#must_support_reference_list_string ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/reference_resolution_test_generator.rb', line 68 def must_support_reference_list_string must_support_references .map { |element| "#{' ' * 8}* #{resource_type}.#{element[:path]}" } .map do |string| string .gsub(".where(url='http://hl7.org/fhir/us/davinci-drug-formulary/StructureDefinition/", ':') .gsub("')", '') end.uniq.sort.join("\n") end |
#must_support_references ⇒ Object
64 65 66 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/reference_resolution_test_generator.rb', line 64 def must_support_references .must_supports[:references] end |
#output ⇒ Object
24 25 26 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/reference_resolution_test_generator.rb', line 24 def output @output ||= ERB.new(template).result(binding) end |
#output_file_directory ⇒ Object
32 33 34 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/reference_resolution_test_generator.rb', line 32 def output_file_directory File.join(base_output_dir, profile_identifier) end |
#output_file_name ⇒ Object
36 37 38 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/reference_resolution_test_generator.rb', line 36 def output_file_name File.join(output_file_directory, base_output_file_name) end |
#profile_identifier ⇒ Object
40 41 42 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/reference_resolution_test_generator.rb', line 40 def profile_identifier Naming.snake_case_for_profile() end |
#resource_collection_string ⇒ Object
60 61 62 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/reference_resolution_test_generator.rb', line 60 def resource_collection_string 'scratch_resources[:all]' end |
#resource_type ⇒ Object
56 57 58 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/reference_resolution_test_generator.rb', line 56 def resource_type .resource end |
#template ⇒ Object
20 21 22 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/reference_resolution_test_generator.rb', line 20 def template @template ||= File.read(File.join(__dir__, 'templates', 'reference_resolution.rb.erb')) end |
#test_id ⇒ Object
44 45 46 |
# File 'lib/davinci_us_drug_formulary_test_kit/generator/reference_resolution_test_generator.rb', line 44 def test_id "usdf_#{.reformatted_version}_#{profile_identifier}_reference_resolution_test" end |