Class: DaVinciPASTestKit::Generator::OperationTestGenerator
- Inherits:
-
Object
- Object
- DaVinciPASTestKit::Generator::OperationTestGenerator
- Defined in:
- lib/davinci_pas_test_kit/generator/operation_test_generator.rb
Instance Attribute Summary collapse
-
#base_output_dir ⇒ Object
Returns the value of attribute base_output_dir.
-
#group_metadata ⇒ Object
Returns the value of attribute group_metadata.
-
#medication_request_metadata ⇒ Object
Returns the value of attribute medication_request_metadata.
Class Method Summary collapse
Instance Method Summary collapse
- #base_output_file_name ⇒ Object
- #class_name ⇒ Object
- #conformance_expectation ⇒ Object
- #description ⇒ Object
- #directory_name ⇒ Object
- #generate ⇒ Object
-
#initialize(group_metadata, medication_request_metadata = nil, base_output_dir:) ⇒ OperationTestGenerator
constructor
A new instance of OperationTestGenerator.
- #module_name ⇒ Object
- #operation ⇒ Object
- #operation_name ⇒ Object
- #output ⇒ Object
- #output_file_directory ⇒ Object
- #output_file_name ⇒ Object
- #profile_identifier ⇒ Object
- #profile_name ⇒ Object
- #profile_url ⇒ Object
- #profile_version ⇒ Object
- #request_type ⇒ Object
- #resource_type ⇒ Object
- #skip_if_empty ⇒ Object
- #template ⇒ Object
- #test_id ⇒ Object
- #title ⇒ Object
- #verifies_requirements ⇒ Object
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_dir ⇒ Object
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_metadata ⇒ Object
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_metadata ⇒ Object
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_name ⇒ Object
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_name ⇒ Object
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_expectation ⇒ Object
81 82 83 |
# File 'lib/davinci_pas_test_kit/generator/operation_test_generator.rb', line 81 def conformance_expectation read_interaction[:expectation] end |
#description ⇒ Object
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_name ⇒ Object
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 |
#generate ⇒ Object
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_name ⇒ Object
73 74 75 |
# File 'lib/davinci_pas_test_kit/generator/operation_test_generator.rb', line 73 def module_name "DaVinciPAS#{.reformatted_version.upcase}" end |
#operation ⇒ Object
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_name ⇒ Object
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 |
#output ⇒ Object
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_directory ⇒ Object
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_name ⇒ Object
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_identifier ⇒ Object
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_name ⇒ Object
57 58 59 |
# File 'lib/davinci_pas_test_kit/generator/operation_test_generator.rb', line 57 def profile_name .profile_name end |
#profile_url ⇒ Object
53 54 55 |
# File 'lib/davinci_pas_test_kit/generator/operation_test_generator.rb', line 53 def profile_url .profile_url end |
#profile_version ⇒ Object
61 62 63 |
# File 'lib/davinci_pas_test_kit/generator/operation_test_generator.rb', line 61 def profile_version .profile_version end |
#request_type ⇒ Object
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_type ⇒ Object
77 78 79 |
# File 'lib/davinci_pas_test_kit/generator/operation_test_generator.rb', line 77 def resource_type .resource end |
#skip_if_empty ⇒ Object
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 |
#template ⇒ Object
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_id ⇒ Object
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 |
#title ⇒ Object
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_requirements ⇒ Object
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 |