Class: DaVinciPlanNetTestKit::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/davinci_plan_net_test_kit/generator.rb,
lib/davinci_plan_net_test_kit/generator/naming.rb,
lib/davinci_plan_net_test_kit/generator/ig_loader.rb,
lib/davinci_plan_net_test_kit/generator/ig_metadata.rb,
lib/davinci_plan_net_test_kit/generator/ig_resources.rb,
lib/davinci_plan_net_test_kit/generator/special_cases.rb,
lib/davinci_plan_net_test_kit/generator/group_metadata.rb,
lib/davinci_plan_net_test_kit/generator/group_generator.rb,
lib/davinci_plan_net_test_kit/generator/suite_generator.rb,
lib/davinci_plan_net_test_kit/generator/value_extractor.rb,
lib/davinci_plan_net_test_kit/generator/read_test_generator.rb,
lib/davinci_plan_net_test_kit/generator/ig_metadata_extractor.rb,
lib/davinci_plan_net_test_kit/generator/search_test_generator.rb,
lib/davinci_plan_net_test_kit/generator/resource_list_generator.rb,
lib/davinci_plan_net_test_kit/generator/group_metadata_extractor.rb,
lib/davinci_plan_net_test_kit/generator/search_metadata_extractor.rb,
lib/davinci_plan_net_test_kit/generator/validation_test_generator.rb,
lib/davinci_plan_net_test_kit/generator/must_support_test_generator.rb,
lib/davinci_plan_net_test_kit/generator/forward_chain_test_generator.rb,
lib/davinci_plan_net_test_kit/generator/include_search_test_generator.rb,
lib/davinci_plan_net_test_kit/generator/must_support_metadata_extractor.rb,
lib/davinci_plan_net_test_kit/generator/search_no_params_test_generator.rb,
lib/davinci_plan_net_test_kit/generator/revinclude_search_test_generator.rb,
lib/davinci_plan_net_test_kit/generator/combination_search_test_generator.rb,
lib/davinci_plan_net_test_kit/generator/reference_resolution_test_generator.rb,
lib/davinci_plan_net_test_kit/generator/reverse_chain_search_test_generator.rb,
lib/davinci_plan_net_test_kit/generator/search_definition_metadata_extractor.rb,
lib/davinci_plan_net_test_kit/generator/terminology_binding_metadata_extractor.rb,
lib/davinci_plan_net_test_kit/generator/must_support_metadata_extractor_us_core_3.rb

Defined Under Namespace

Modules: Naming, SpecialCases Classes: CombinationSearchTestGenerator, ForwardChainSearchTestGenerator, GroupGenerator, GroupMetadata, GroupMetadataExtractor, IGLoader, IGMetadata, IGMetadataExtractor, IGResources, IncludeSearchTestGenerator, MustSupportMetadataExtractor, MustSupportMetadataExtractorUsCore3, MustSupportTestGenerator, ReadTestGenerator, ReferenceResolutionTestGenerator, ResourceListGenerator, ReverseChainSearchTestGenerator, RevincludeSearchTestGenerator, SearchDefinitionMetadataExtractor, SearchMetadataExtractor, SearchNoParamsTestGenerator, SearchTestGenerator, SuiteGenerator, TerminologyBindingMetadataExtractor, ValidationTestGenerator, ValueExactor

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ig_file_name) ⇒ Generator

Returns a new instance of Generator.



34
35
36
# File 'lib/davinci_plan_net_test_kit/generator.rb', line 34

def initialize(ig_file_name)
  self.ig_file_name = ig_file_name
end

Instance Attribute Details

#ig_file_nameObject

Returns the value of attribute ig_file_name.



32
33
34
# File 'lib/davinci_plan_net_test_kit/generator.rb', line 32

def ig_file_name
  @ig_file_name
end

#ig_metadataObject

Returns the value of attribute ig_metadata.



32
33
34
# File 'lib/davinci_plan_net_test_kit/generator.rb', line 32

def 
  @ig_metadata
end

#ig_resourcesObject

Returns the value of attribute ig_resources.



32
33
34
# File 'lib/davinci_plan_net_test_kit/generator.rb', line 32

def ig_resources
  @ig_resources
end

Class Method Details

.generateObject



24
25
26
27
28
29
30
# File 'lib/davinci_plan_net_test_kit/generator.rb', line 24

def self.generate
  ig_packages = Dir.glob(File.join(Dir.pwd, 'lib', 'davinci_plan_net_test_kit', 'igs', '*.tgz'))

  ig_packages.each do |ig_package|
    new(ig_package).generate
  end
end

Instance Method Details

#base_output_dirObject



74
75
76
# File 'lib/davinci_plan_net_test_kit/generator.rb', line 74

def base_output_dir
  File.join(__dir__, 'generated', .ig_version)
end

#extract_metadataObject



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/davinci_plan_net_test_kit/generator.rb', line 62

def 
  self. = IGMetadataExtractor.new(ig_resources).extract
  
  # Specific corrections 
  SpecialCases.run_special_cases()

  FileUtils.mkdir_p(base_output_dir)
  File.open(File.join(base_output_dir, 'metadata.yml'), 'w') do |file|
    file.write(YAML.dump(.to_hash))
  end
end

#generateObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/davinci_plan_net_test_kit/generator.rb', line 38

def generate
  puts "Generating tests for IG #{File.basename(ig_file_name)}"
  load_ig_package
  
  generate_resource_list
  generate_search_no_params_tests
  generate_read_tests
  generate_search_tests
  # TODO: generate_vread_tests
  # TODO: generate_history_tests
  generate_include_search_tests
  generate_revinclude_search_tests
  generate_forward_chain_search_tests
  generate_reverse_chain_search_tests
  generate_combination_chain_search_tests
  generate_validation_tests
  generate_must_support_tests
  generate_reference_resolution_tests

  generate_groups

  generate_suites
end

#generate_combination_chain_search_testsObject



129
130
131
132
133
# File 'lib/davinci_plan_net_test_kit/generator.rb', line 129

def generate_combination_chain_search_tests
  examples = File.read('lib/davinci_plan_net_test_kit/custom_groups/combination_searches/examples.json')
  examples_hash = JSON.parse(examples)
  CombinationSearchTestGenerator.generate(, examples_hash, base_output_dir)
end

#generate_forward_chain_search_testsObject



125
126
127
# File 'lib/davinci_plan_net_test_kit/generator.rb', line 125

def generate_forward_chain_search_tests
  ForwardChainSearchTestGenerator.generate(, base_output_dir)
end

#generate_groupsObject



135
136
137
# File 'lib/davinci_plan_net_test_kit/generator.rb', line 135

def generate_groups
  GroupGenerator.generate(, base_output_dir)
end

#generate_include_search_testsObject



111
112
113
# File 'lib/davinci_plan_net_test_kit/generator.rb', line 111

def generate_include_search_tests
  IncludeSearchTestGenerator.generate(, base_output_dir)
end

#generate_must_support_testsObject



91
92
93
# File 'lib/davinci_plan_net_test_kit/generator.rb', line 91

def generate_must_support_tests
  MustSupportTestGenerator.generate(, base_output_dir)
end

#generate_read_testsObject



99
100
101
# File 'lib/davinci_plan_net_test_kit/generator.rb', line 99

def generate_read_tests
  ReadTestGenerator.generate(, base_output_dir)
end

#generate_reference_resolution_testsObject



87
88
89
# File 'lib/davinci_plan_net_test_kit/generator.rb', line 87

def generate_reference_resolution_tests
  ReferenceResolutionTestGenerator.generate(, base_output_dir)
end

#generate_resource_listObject



83
84
85
# File 'lib/davinci_plan_net_test_kit/generator.rb', line 83

def generate_resource_list
  ResourceListGenerator.generate(, base_output_dir)
end

#generate_reverse_chain_search_testsObject



119
120
121
122
123
# File 'lib/davinci_plan_net_test_kit/generator.rb', line 119

def generate_reverse_chain_search_tests
  examples = File.read('lib/davinci_plan_net_test_kit/custom_groups/reverse_chain_tests/examples.json')
  examples_hash = JSON.parse(examples)
  ReverseChainSearchTestGenerator.generate(, examples_hash, base_output_dir)
end

#generate_revinclude_search_testsObject



115
116
117
# File 'lib/davinci_plan_net_test_kit/generator.rb', line 115

def generate_revinclude_search_tests
  RevincludeSearchTestGenerator.generate(, base_output_dir)
end

#generate_search_no_params_testsObject



107
108
109
# File 'lib/davinci_plan_net_test_kit/generator.rb', line 107

def generate_search_no_params_tests
  SearchNoParamsTestGenerator.generate(, base_output_dir)
end

#generate_search_testsObject



103
104
105
# File 'lib/davinci_plan_net_test_kit/generator.rb', line 103

def generate_search_tests
  SearchTestGenerator.generate(, base_output_dir)
end

#generate_suitesObject



139
140
141
# File 'lib/davinci_plan_net_test_kit/generator.rb', line 139

def generate_suites
  SuiteGenerator.generate(, base_output_dir)
end

#generate_validation_testsObject



95
96
97
# File 'lib/davinci_plan_net_test_kit/generator.rb', line 95

def generate_validation_tests
  ValidationTestGenerator.generate(, base_output_dir)
end

#load_ig_packageObject



78
79
80
81
# File 'lib/davinci_plan_net_test_kit/generator.rb', line 78

def load_ig_package
  FHIR.logger = Logger.new('/dev/null')
  self.ig_resources = IGLoader.new(ig_file_name).load
end