Class: USCoreTestKit::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/us_core_test_kit/generator.rb,
lib/us_core_test_kit/generator/naming.rb,
lib/us_core_test_kit/generator/ig_loader.rb,
lib/us_core_test_kit/generator/ig_metadata.rb,
lib/us_core_test_kit/generator/ig_resources.rb,
lib/us_core_test_kit/generator/special_cases.rb,
lib/us_core_test_kit/generator/group_metadata.rb,
lib/us_core_test_kit/generator/group_generator.rb,
lib/us_core_test_kit/generator/suite_generator.rb,
lib/us_core_test_kit/generator/value_extractor.rb,
lib/us_core_test_kit/generator/read_test_generator.rb,
lib/us_core_test_kit/generator/ig_metadata_extractor.rb,
lib/us_core_test_kit/generator/search_test_generator.rb,
lib/us_core_test_kit/generator/group_metadata_extractor.rb,
lib/us_core_test_kit/generator/search_metadata_extractor.rb,
lib/us_core_test_kit/generator/validation_test_generator.rb,
lib/us_core_test_kit/generator/must_support_test_generator.rb,
lib/us_core_test_kit/generator/granular_scope_test_generator.rb,
lib/us_core_test_kit/generator/granular_scope_group_generator.rb,
lib/us_core_test_kit/generator/must_support_metadata_extractor.rb,
lib/us_core_test_kit/generator/granular_scope_read_test_generator.rb,
lib/us_core_test_kit/generator/practitioner_address_test_generator.rb,
lib/us_core_test_kit/generator/reference_resolution_test_generator.rb,
lib/us_core_test_kit/generator/search_definition_metadata_extractor.rb,
lib/us_core_test_kit/generator/terminology_binding_metadata_extractor.rb,
lib/us_core_test_kit/generator/must_support_metadata_extractor_us_core_3.rb,
lib/us_core_test_kit/generator/must_support_metadata_extractor_us_core_4.rb,
lib/us_core_test_kit/generator/must_support_metadata_extractor_us_core_5.rb,
lib/us_core_test_kit/generator/must_support_metadata_extractor_us_core_6.rb,
lib/us_core_test_kit/generator/must_support_metadata_extractor_us_core_7.rb,
lib/us_core_test_kit/generator/provenance_revinclude_search_test_generator.rb,
lib/us_core_test_kit/generator/granular_scope_resource_type_group_generator.rb

Defined Under Namespace

Modules: Naming, SpecialCases Classes: GranularScopeGroupGenerator, GranularScopeReadTestGenerator, GranularScopeResourceTypeGroupGenerator, GranularScopeTestGenerator, GroupGenerator, GroupMetadata, GroupMetadataExtractor, IGLoader, IGMetadata, IGMetadataExtractor, IGResources, MustSupportMetadataExtractor, MustSupportMetadataExtractorUsCore3, MustSupportMetadataExtractorUsCore4, MustSupportMetadataExtractorUsCore5, MustSupportMetadataExtractorUsCore6, MustSupportMetadataExtractorUsCore7, MustSupportTestGenerator, PractitionerAddressTestGenerator, ProvenanceRevincludeSearchTestGenerator, ReadTestGenerator, ReferenceResolutionTestGenerator, SearchDefinitionMetadataExtractor, SearchMetadataExtractor, 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.



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

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.



30
31
32
# File 'lib/us_core_test_kit/generator.rb', line 30

def ig_file_name
  @ig_file_name
end

#ig_metadataObject

Returns the value of attribute ig_metadata.



30
31
32
# File 'lib/us_core_test_kit/generator.rb', line 30

def 
  @ig_metadata
end

#ig_resourcesObject

Returns the value of attribute ig_resources.



30
31
32
# File 'lib/us_core_test_kit/generator.rb', line 30

def ig_resources
  @ig_resources
end

Class Method Details

.generateObject



22
23
24
25
26
27
28
# File 'lib/us_core_test_kit/generator.rb', line 22

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

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

Instance Method Details

#base_output_dirObject



75
76
77
# File 'lib/us_core_test_kit/generator.rb', line 75

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

#extract_metadataObject



63
64
65
66
67
# File 'lib/us_core_test_kit/generator.rb', line 63

def 
  self. = IGMetadataExtractor.new(ig_resources).extract

  FileUtils.mkdir_p(base_output_dir)
end

#generateObject



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

def generate
  puts "Generating tests for IG #{File.basename(ig_file_name)}"
  load_ig_package
  
  generate_search_tests
  generate_read_tests
  # TODO: generate_vread_tests
  # TODO: generate_history_tests
  generate_provenance_revinclude_search_tests
  generate_validation_tests
  generate_must_support_tests
  generate_reference_resolution_tests
  generate_practitioner_address_tests

  generate_granular_scope_tests

  generate_groups

  generate_granular_scope_resource_type_groups

  generate_granular_scope_groups

  generate_suites

  
end

#generate_granular_scope_groupsObject



121
122
123
# File 'lib/us_core_test_kit/generator.rb', line 121

def generate_granular_scope_groups
  GranularScopeGroupGenerator.generate(, base_output_dir)
end

#generate_granular_scope_resource_type_groupsObject



117
118
119
# File 'lib/us_core_test_kit/generator.rb', line 117

def generate_granular_scope_resource_type_groups
  GranularScopeResourceTypeGroupGenerator.generate(, base_output_dir)
end

#generate_granular_scope_testsObject



108
109
110
111
# File 'lib/us_core_test_kit/generator.rb', line 108

def generate_granular_scope_tests
  GranularScopeTestGenerator.generate(, base_output_dir)
  GranularScopeReadTestGenerator.generate(, base_output_dir)
end

#generate_groupsObject



113
114
115
# File 'lib/us_core_test_kit/generator.rb', line 113

def generate_groups
  GroupGenerator.generate(, base_output_dir)
end

#generate_must_support_testsObject



88
89
90
# File 'lib/us_core_test_kit/generator.rb', line 88

def generate_must_support_tests
  MustSupportTestGenerator.generate(, base_output_dir)
end

#generate_practitioner_address_testsObject



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

def generate_practitioner_address_tests
  PractitionerAddressTestGenerator.generate(, base_output_dir)
end

#generate_provenance_revinclude_search_testsObject



104
105
106
# File 'lib/us_core_test_kit/generator.rb', line 104

def generate_provenance_revinclude_search_tests
  ProvenanceRevincludeSearchTestGenerator.generate(, base_output_dir)
end

#generate_read_testsObject



96
97
98
# File 'lib/us_core_test_kit/generator.rb', line 96

def generate_read_tests
  ReadTestGenerator.generate(, base_output_dir)
end

#generate_reference_resolution_testsObject



84
85
86
# File 'lib/us_core_test_kit/generator.rb', line 84

def generate_reference_resolution_tests
  ReferenceResolutionTestGenerator.generate(, base_output_dir)
end

#generate_search_testsObject



100
101
102
# File 'lib/us_core_test_kit/generator.rb', line 100

def generate_search_tests
  SearchTestGenerator.generate(, base_output_dir)
end

#generate_suitesObject



129
130
131
# File 'lib/us_core_test_kit/generator.rb', line 129

def generate_suites
  SuiteGenerator.generate(, base_output_dir)
end

#generate_validation_testsObject



92
93
94
# File 'lib/us_core_test_kit/generator.rb', line 92

def generate_validation_tests
  ValidationTestGenerator.generate(, base_output_dir)
end

#load_ig_packageObject



79
80
81
82
# File 'lib/us_core_test_kit/generator.rb', line 79

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

#write_metadataObject



69
70
71
72
73
# File 'lib/us_core_test_kit/generator.rb', line 69

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