Class: DaVinciPASTestKit::Generator::ClientMustSupportGroupGenerator

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ig_metadata, operation, profiles, base_output_dir, type = 'request') ⇒ ClientMustSupportGroupGenerator

Returns a new instance of ClientMustSupportGroupGenerator.



33
34
35
36
37
38
39
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 33

def initialize(, operation, profiles, base_output_dir, type = 'request')
  self. = 
  self.operation = operation
  self.profiles = profiles
  self.base_output_dir = base_output_dir
  self.type = type
end

Instance Attribute Details

#base_output_dirObject

Returns the value of attribute base_output_dir.



31
32
33
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 31

def base_output_dir
  @base_output_dir
end

#ig_metadataObject

Returns the value of attribute ig_metadata.



31
32
33
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 31

def 
  @ig_metadata
end

#operationObject

Returns the value of attribute operation.



31
32
33
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 31

def operation
  @operation
end

#profilesObject

Returns the value of attribute profiles.



31
32
33
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 31

def profiles
  @profiles
end

#typeObject

Returns the value of attribute type.



31
32
33
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 31

def type
  @type
end

Class Method Details

.generate(ig_metadata, base_client_output_dir) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 8

def generate(, base_client_output_dir)
  submit_request_profiles = .profiles.select do |profile|
    MustSupportTargetProfiles.submit_request_profile?(profile)
  end
  new(, 'submit', submit_request_profiles, base_client_output_dir).generate

  submit_response_profiles = .profiles.select do |profile|
    MustSupportTargetProfiles.submit_response_profile?(profile)
  end
  new(, 'submit', submit_response_profiles, base_client_output_dir, 'response').generate

  inquire_request_profiles = .profiles.select do |profile|
    MustSupportTargetProfiles.inquire_request_profile?(profile)
  end
  new(, 'inquire', inquire_request_profiles, base_client_output_dir).generate

  inquire_response_profiles = .profiles.select do |profile|
    MustSupportTargetProfiles.inquire_response_profile?(profile)
  end
  new(, 'inquire', inquire_response_profiles, base_client_output_dir, 'response').generate
end

Instance Method Details

#attestation_profiles_block(profile_metadatas) ⇒ Object

Formats a profiles list for an attestation test's config, one hash literal per line.



181
182
183
184
185
186
187
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 181

def attestation_profiles_block(profile_metadatas)
  profile_metadatas.map do ||
    "              { resource_type: '#{.resource}', " \
      "profile_key: '#{profile_identifier()}', " \
      "title: '#{.profile_name}' }"
  end.join(",\n")
end

#base_output_file_nameObject



53
54
55
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 53

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

#claim_profilesObject

Collapsed request groups: the mandatory Claim profile(s) kept as standalone tests.



166
167
168
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 166

def claim_profiles
  required_profiles.select { || .resource == 'Claim' }
end

#class_nameObject



57
58
59
60
61
62
63
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 57

def class_name
  if type == 'response'
    "PASClient#{operation.camelize}ResponseMustSupportGroup"
  else
    "PASClient#{operation.camelize}MustSupportGroup"
  end
end

#descriptionObject



204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 204

def description
  if type == 'response'
    <<~DESCRIPTION
      Check that `$#{operation}` responses provided to the client contain
      all PAS-defined profiles and their must support elements.

      **USER INPUT VALIDATION**: These tests validate responses provided by the tester,
      not the system under test. Errors will be treated as skips instead of failures.

      For `$#{operation}` responses, this includes the following profiles:

      #{Descriptions.profile_links_list(profiles, ig_version)}
    DESCRIPTION
  else
    <<~DESCRIPTION
      Check that the client can demonstrate `$#{operation}` requests that contain
      all PAS-defined profiles and their must support elements.

      For `$#{operation}` requests, this includes the following profiles:

      #{Descriptions.profile_links_list(required_profiles, ig_version, request_profiles: operation == 'submit' ? request_profiles : nil)}
    DESCRIPTION
  end
end

#generateObject



109
110
111
112
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 109

def generate
  FileUtils.mkdir_p(base_output_dir)
  File.write(output_file_name, output)
end

#group_idObject



93
94
95
96
97
98
99
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 93

def group_id
  if type == 'response'
    "pas_client_#{ig_version_for_id}_#{operation}_response_must_support"
  else
    "pas_client_#{ig_version_for_id}_#{operation}_must_support"
  end
end

#ig_versionObject



101
102
103
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 101

def ig_version
  .ig_version
end

#ig_version_for_idObject



105
106
107
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 105

def ig_version_for_id
  .reformatted_version
end

#mandatory_profile?(profile_metadata) ⇒ Boolean

The Claim (request) / ClaimResponse (response) profiles remain mandatory standalone tests.

Returns:

  • (Boolean)


151
152
153
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 151

def mandatory_profile?()
  %w[Claim ClaimResponse].include?(.resource)
end

#module_nameObject



65
66
67
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 65

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

#optional_must_support_enabled?Boolean

The collapsed attestation structure / optional response tests are only applied to v2.2.1.

Returns:

  • (Boolean)


146
147
148
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 146

def optional_must_support_enabled?
  ig_version == 'v2.2.1'
end

#other_profilesObject

Collapsed request groups: every other supporting profile, assessed by the attestation test.



171
172
173
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 171

def other_profiles
  required_profiles.reject { || .resource == 'Claim' }
end

#other_profiles_titleObject



175
176
177
178
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 175

def other_profiles_title
  'All must support elements for other profiles referenced by Claim ' \
    "#{operation == 'submit' ? 'submissions' : 'inquiries'} are observed on $#{operation} requests"
end

#outputObject



49
50
51
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 49

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

#output_file_nameObject



85
86
87
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 85

def output_file_name
  File.join(base_output_dir, base_output_file_name)
end

#profile_identifier(profile_metadata) ⇒ Object



89
90
91
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 89

def profile_identifier()
  .snake_case_for_profile()
end

#profile_identifier_for_profile(profile_metadata) ⇒ Object



136
137
138
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 136

def profile_identifier_for_profile()
  .snake_case_for_profile()
end

#profile_test_filesObject



189
190
191
192
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 189

def profile_test_files
  target_profiles = type == 'response' ? profiles : required_profiles
  target_profiles.map { || test_file_for_profile() }
end

#profile_test_idsObject



140
141
142
143
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 140

def profile_test_ids
  target_profiles = type == 'response' ? profiles : required_profiles
  target_profiles.map { || test_id_for_profile() }
end

#profile_testsObject

Response groups: pairs each per-profile test id with whether it should be marked optional.



156
157
158
159
160
161
162
163
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 156

def profile_tests
  profiles.map do ||
    {
      id: test_id_for_profile(),
      optional: optional_must_support_enabled? && !mandatory_profile?()
    }
  end
end

#request_profilesObject



120
121
122
123
124
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 120

def request_profiles
  @request_profiles = profiles.select do ||
    MustSupportTargetProfiles.request_profile?()
  end
end

#request_typeObject



81
82
83
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 81

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

#required_profilesObject



114
115
116
117
118
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 114

def required_profiles
  @required_profiles = profiles.reject do ||
    MustSupportTargetProfiles.request_profile?()
  end
end

#templateObject



41
42
43
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 41

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

#template_file_nameObject



45
46
47
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 45

def template_file_name
  type == 'response' ? 'client_must_support_response_group.rb.erb' : 'client_must_support_group.rb.erb'
end

#test_file_for_profile(profile_metadata) ⇒ Object



131
132
133
134
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 131

def test_file_for_profile()
  profile_id = profile_identifier_for_profile()
  File.join(profile_id, "client_#{request_type}_must_support_#{profile_id}_test")
end

#test_id_for_profile(profile_metadata) ⇒ Object



126
127
128
129
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 126

def test_id_for_profile()
  "pas_client_#{.reformatted_version}_#{request_type}_" \
    "must_support_#{profile_identifier_for_profile()}"
end

#titleObject



69
70
71
72
73
74
75
76
77
78
79
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 69

def title
  if type == 'response'
    return '$submit Response Must Support Coverage' if operation == 'submit'

    '$inquire Response Must Support Coverage'
  else
    return '$submit Request Must Support Coverage' if operation == 'submit'

    '$inquire Request Must Support Coverage'
  end
end

#verifies_requirementsObject



194
195
196
197
198
199
200
201
202
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 194

def verifies_requirements
  case "#{operation}_#{ig_version}"
  when 'submit_v2.0.1'
    return nil if type == 'response'

    ['hl7.fhir.us.davinci-pas_2.0.1@58', 'hl7.fhir.us.davinci-pas_2.0.1@62',
     'hl7.fhir.us.davinci-pas_2.0.1@70', 'hl7.fhir.us.davinci-pas_2.0.1@202']
  end
end