Class: DaVinciPASTestKit::Generator::OperationTestGenerator

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(group_metadata, medication_request_metadata = nil, base_output_dir:) ⇒ OperationTestGenerator

Returns a new instance of OperationTestGenerator.



19
20
21
22
23
# File 'lib/davinci_pas_test_kit/generator/operation_test_generator.rb', line 19

def initialize(,  = nil, base_output_dir:)
  self. = 
  self. = 
  self.base_output_dir = base_output_dir
end

Instance Attribute Details

#base_output_dirObject

Returns the value of attribute base_output_dir.



17
18
19
# File 'lib/davinci_pas_test_kit/generator/operation_test_generator.rb', line 17

def base_output_dir
  @base_output_dir
end

#group_metadataObject

Returns the value of attribute group_metadata.



17
18
19
# File 'lib/davinci_pas_test_kit/generator/operation_test_generator.rb', line 17

def 
  @group_metadata
end

#medication_request_metadataObject

Returns the value of attribute medication_request_metadata.



17
18
19
# File 'lib/davinci_pas_test_kit/generator/operation_test_generator.rb', line 17

def 
  @medication_request_metadata
end

Class Method Details

.generate(ig_metadata, base_output_dir) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/davinci_pas_test_kit/generator/operation_test_generator.rb', line 8

def generate(, base_output_dir)
  .claim_groups
    .reject { |group| group.name.include?('update') }
    .each do |group|
      new(group, base_output_dir:).generate
    end
end

Instance Method Details

#base_output_file_nameObject



33
34
35
# File 'lib/davinci_pas_test_kit/generator/operation_test_generator.rb', line 33

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

#class_nameObject



69
70
71
# File 'lib/davinci_pas_test_kit/generator/operation_test_generator.rb', line 69

def class_name
  "#{Naming.upper_camel_case_for_profile()}OperationTest"
end

#conformance_expectationObject



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

def conformance_expectation
  read_interaction[:expectation]
end

#descriptionObject



139
140
141
142
143
144
145
146
# File 'lib/davinci_pas_test_kit/generator/operation_test_generator.rb', line 139

def description
  <<~DESCRIPTION
    Server SHALL support PAS #{operation_name} requests: a POST interaction to
    the /Claim/$#{operation} endpoint.
    This test submits a Prior Authorization #{operation_name} request to the server and verifies that a
    response is returned with HTTP status 2XX.#{operation == 'submit' ? "\nThe server SHOULD respond within 15 seconds." : ''}
  DESCRIPTION
end

#directory_nameObject



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

def directory_name
  Naming.snake_case_for_profile( || )
end

#generateObject



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

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

   = {
    id: test_id,
    file_name: base_output_file_name
  }
  .add_test(**)
end

#module_nameObject



73
74
75
# File 'lib/davinci_pas_test_kit/generator/operation_test_generator.rb', line 73

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

#operationObject



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

def operation
  operations = .operations.map { |op| op[:code] }
  operations.find { |op| request_type.include?(op.delete_prefix('$')) }
    .to_s.delete_prefix('$')
end

#operation_nameObject



101
102
103
104
105
106
107
108
# File 'lib/davinci_pas_test_kit/generator/operation_test_generator.rb', line 101

def operation_name
  case operation
  when 'inquire'
    'Inquiry'
  when 'submit'
    'Submit'
  end
end

#outputObject



29
30
31
# File 'lib/davinci_pas_test_kit/generator/operation_test_generator.rb', line 29

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

#output_file_directoryObject



37
38
39
# File 'lib/davinci_pas_test_kit/generator/operation_test_generator.rb', line 37

def output_file_directory
  File.join(base_output_dir, directory_name)
end

#output_file_nameObject



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

def output_file_name
  File.join(output_file_directory, base_output_file_name)
end

#profile_identifierObject



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

def profile_identifier
  Naming.snake_case_for_profile()
end

#profile_nameObject



57
58
59
# File 'lib/davinci_pas_test_kit/generator/operation_test_generator.rb', line 57

def profile_name
  .profile_name
end

#profile_urlObject



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

def profile_url
  .profile_url
end

#profile_versionObject



61
62
63
# File 'lib/davinci_pas_test_kit/generator/operation_test_generator.rb', line 61

def profile_version
  .profile_version
end

#request_typeObject



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

def request_type
  Naming.request_type_for_bundle_or_claim[profile_name]
end

#resource_typeObject



77
78
79
# File 'lib/davinci_pas_test_kit/generator/operation_test_generator.rb', line 77

def resource_type
  .resource
end

#skip_if_emptyObject



85
86
87
88
89
# File 'lib/davinci_pas_test_kit/generator/operation_test_generator.rb', line 85

def skip_if_empty
  # Return true if a system must demonstrate at least one example of the resource type.
  # This drives omit vs. skip result statuses in this test.
  resource_type != 'Medication'
end

#templateObject



25
26
27
# File 'lib/davinci_pas_test_kit/generator/operation_test_generator.rb', line 25

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

#test_idObject



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

def test_id
  "pas_#{.reformatted_version}_#{profile_identifier}_operation_test"
end

#titleObject



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

def title
  "Submission of a claim to the $#{operation} operation succeeds"
end

#verifies_requirementsObject



110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/davinci_pas_test_kit/generator/operation_test_generator.rb', line 110

def verifies_requirements
  case test_id
  when 'pas_v201_claim_inquiry_operation_test'
    ['hl7.fhir.us.davinci-pas_2.0.1@5', 'hl7.fhir.us.davinci-pas_2.0.1@111',
     'hl7.fhir.us.davinci-pas_2.0.1@208']
  when 'pas_v201_claim_operation_test'
    ['hl7.fhir.us.davinci-pas_2.0.1@5', 'hl7.fhir.us.davinci-pas_2.0.1@66',
     'hl7.fhir.us.davinci-pas_2.0.1@111', 'hl7.fhir.us.davinci-pas_2.0.1@136',
     'hl7.fhir.us.davinci-pas_2.0.1@207']
  else
    "\n"
  end
end