Class: DaVinciPASTestKit::Generator::MustSupportTestGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/davinci_pas_test_kit/generator/must_support_test_generator.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ig_metadata, profile_metadata, base_output_dir, type, operation, system = 'server') ⇒ MustSupportTestGenerator

Returns a new instance of MustSupportTestGenerator.



58
59
60
61
62
63
64
65
# File 'lib/davinci_pas_test_kit/generator/must_support_test_generator.rb', line 58

def initialize(, , base_output_dir, type, operation, system = 'server')
  self. = 
  self. = 
  self.base_output_dir = base_output_dir
  self.type = type
  self.operation = operation
  self.system = system
end

Instance Attribute Details

#base_output_dirObject

Returns the value of attribute base_output_dir.



56
57
58
# File 'lib/davinci_pas_test_kit/generator/must_support_test_generator.rb', line 56

def base_output_dir
  @base_output_dir
end

#ig_metadataObject

Returns the value of attribute ig_metadata.



56
57
58
# File 'lib/davinci_pas_test_kit/generator/must_support_test_generator.rb', line 56

def 
  @ig_metadata
end

#operationObject

Returns the value of attribute operation.



56
57
58
# File 'lib/davinci_pas_test_kit/generator/must_support_test_generator.rb', line 56

def operation
  @operation
end

#profile_metadataObject

Returns the value of attribute profile_metadata.



56
57
58
# File 'lib/davinci_pas_test_kit/generator/must_support_test_generator.rb', line 56

def 
  @profile_metadata
end

#systemObject

Returns the value of attribute system.



56
57
58
# File 'lib/davinci_pas_test_kit/generator/must_support_test_generator.rb', line 56

def system
  @system
end

#typeObject

Returns the value of attribute type.



56
57
58
# File 'lib/davinci_pas_test_kit/generator/must_support_test_generator.rb', line 56

def type
  @type
end

Class Method Details

.generate(ig_metadata, base_server_output_dir, base_client_output_dir) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/davinci_pas_test_kit/generator/must_support_test_generator.rb', line 7

def generate(, base_server_output_dir, base_client_output_dir)
  submit_request_profiles =
    .profiles.select { |profile| MustSupportTargetProfiles.submit_request_profile?(profile) }
      .reject { |profile| MustSupportTargetProfiles.request_profile?(profile) }
  submit_response_profiles = .profiles.select do |profile|
    MustSupportTargetProfiles.submit_response_profile?(profile)
  end
  inquiry_request_profiles = .profiles.select do |profile|
    MustSupportTargetProfiles.inquire_request_profile?(profile)
  end
  inquiry_response_profiles = .profiles.select do |profile|
    MustSupportTargetProfiles.inquire_response_profile?(profile)
  end

  submit_request_profiles.each do |profile|
    new(, profile, base_server_output_dir, 'request', 'submit').generate
    if generate_client_request_test?(, profile)
      new(, profile, base_client_output_dir, 'request', 'submit', 'client').generate
    end
  end
  submit_response_profiles.each do |profile|
    new(, profile, base_server_output_dir, 'response', 'submit').generate
    new(, profile, base_client_output_dir, 'response', 'submit', 'client').generate
  end

  inquiry_request_profiles.each do |profile|
    new(, profile, base_server_output_dir, 'request', 'inquire').generate
    if generate_client_request_test?(, profile)
      new(, profile, base_client_output_dir, 'request', 'inquire', 'client').generate
    end
  end
  inquiry_response_profiles.each do |profile|
    new(, profile, base_server_output_dir, 'response', 'inquire').generate
    new(, profile, base_client_output_dir, 'response', 'inquire', 'client').generate
  end
end

.generate_client_request_test?(ig_metadata, profile) ⇒ Boolean

For v2.2.1 the client request must support tests are collapsed into the attestation tests (see ClientMustSupportGroupGenerator), so only the mandatory Claim profile keeps a standalone per-profile client request test. Other profiles are covered by the attestation tests and their per-profile client request tests are not generated. Server tests and earlier IG versions are unaffected.

Returns:

  • (Boolean)


49
50
51
52
53
# File 'lib/davinci_pas_test_kit/generator/must_support_test_generator.rb', line 49

def generate_client_request_test?(, profile)
  return true unless .ig_version == 'v2.2.1'

  profile.resource == 'Claim'
end

Instance Method Details

#base_output_file_nameObject



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

def base_output_file_name
  "#{class_name.underscore}.rb"
end

#class_nameObject



103
104
105
106
# File 'lib/davinci_pas_test_kit/generator/must_support_test_generator.rb', line 103

def class_name
  "#{system.capitalize}#{request_type.camelize}MustSupport" \
    "#{.upper_camel_case_for_profile()}Test"
end

#generateObject



133
134
135
136
137
138
139
140
141
# File 'lib/davinci_pas_test_kit/generator/must_support_test_generator.rb', line 133

def generate
  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_nameObject



108
109
110
# File 'lib/davinci_pas_test_kit/generator/must_support_test_generator.rb', line 108

def module_name
  "DaVinciPAS#{.reformatted_version.upcase}"
end

#must_support_list_stringObject



120
121
122
# File 'lib/davinci_pas_test_kit/generator/must_support_test_generator.rb', line 120

def must_support_list_string
  .must_support_list_string(indent: 8)
end

#outputObject



71
72
73
# File 'lib/davinci_pas_test_kit/generator/must_support_test_generator.rb', line 71

def output
  @output ||= ERB.new(template, trim_mode: '-').result(binding)
end

#output_file_directoryObject



79
80
81
# File 'lib/davinci_pas_test_kit/generator/must_support_test_generator.rb', line 79

def output_file_directory
  File.join(base_output_dir, profile_identifier)
end

#output_file_nameObject



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

def output_file_name
  File.join(output_file_directory, base_output_file_name)
end

#profile_identifierObject



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

def profile_identifier
  .snake_case_for_profile()
end

#profile_nameObject



116
117
118
# File 'lib/davinci_pas_test_kit/generator/must_support_test_generator.rb', line 116

def profile_name
  .profile_name
end

#read_interactionObject



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

def read_interaction
  self.class.read_interaction()
end

#request_typeObject



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

def request_type
  "#{operation}_#{type}"
end

#resource_typeObject



112
113
114
# File 'lib/davinci_pas_test_kit/generator/must_support_test_generator.rb', line 112

def resource_type
  .resource
end

#templateObject



67
68
69
# File 'lib/davinci_pas_test_kit/generator/must_support_test_generator.rb', line 67

def template
  @template ||= File.read(File.join(__dir__, 'templates', 'must_support.rb.erb'))
end

#test_idObject



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

def test_id
  "pas_#{system}_#{.reformatted_version}_#{request_type}_must_support_#{profile_identifier}"
end

#verifies_requirementsObject



124
125
126
127
128
129
130
131
# File 'lib/davinci_pas_test_kit/generator/must_support_test_generator.rb', line 124

def verifies_requirements
  case "#{system}_#{operation}_#{type}_#{.ig_version}"
  when 'server_submit_response_v2.0.1'
    ['hl7.fhir.us.davinci-pas_2.0.1@37', 'hl7.fhir.us.davinci-pas_2.0.1@110']
  when 'server_inquire_response_v2.0.1'
    ['hl7.fhir.us.davinci-pas_2.0.1@38']
  end
end