Class: CarinForBlueButtonTestKit::Generator::ValidationTestGenerator
- Inherits:
-
Object
- Object
- CarinForBlueButtonTestKit::Generator::ValidationTestGenerator
- Defined in:
- lib/carin_for_blue_button_test_kit/generator/validation_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
- #description_intro ⇒ Object
- #directory_name ⇒ Object
- #generate ⇒ Object
-
#initialize(group_metadata, medication_request_metadata = nil, base_output_dir:) ⇒ ValidationTestGenerator
constructor
A new instance of ValidationTestGenerator.
- #module_name ⇒ Object
- #output ⇒ Object
- #output_file_directory ⇒ Object
- #output_file_name ⇒ Object
- #profile_identifier ⇒ Object
- #profile_name ⇒ Object
- #profile_url ⇒ Object
- #profile_version ⇒ Object
- #resource_type ⇒ Object
- #skip_if_empty ⇒ Object
- #specific_resource_type ⇒ Object
- #template ⇒ Object
- #test_id ⇒ Object
Constructor Details
#initialize(group_metadata, medication_request_metadata = nil, base_output_dir:) ⇒ ValidationTestGenerator
Returns a new instance of ValidationTestGenerator.
17 18 19 20 21 |
# File 'lib/carin_for_blue_button_test_kit/generator/validation_test_generator.rb', line 17 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.
15 16 17 |
# File 'lib/carin_for_blue_button_test_kit/generator/validation_test_generator.rb', line 15 def base_output_dir @base_output_dir end |
#group_metadata ⇒ Object
Returns the value of attribute group_metadata.
15 16 17 |
# File 'lib/carin_for_blue_button_test_kit/generator/validation_test_generator.rb', line 15 def @group_metadata end |
#medication_request_metadata ⇒ Object
Returns the value of attribute medication_request_metadata.
15 16 17 |
# File 'lib/carin_for_blue_button_test_kit/generator/validation_test_generator.rb', line 15 def @medication_request_metadata end |
Class Method Details
.generate(ig_metadata, base_output_dir) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/carin_for_blue_button_test_kit/generator/validation_test_generator.rb', line 7 def generate(, base_output_dir) .groups .each do |group| new(group, base_output_dir: base_output_dir).generate end end |
Instance Method Details
#base_output_file_name ⇒ Object
31 32 33 34 35 |
# File 'lib/carin_for_blue_button_test_kit/generator/validation_test_generator.rb', line 31 def base_output_file_name file_name = class_name.underscore file_name.sub!("#{profile_identifier}_", '') "#{file_name}.rb" end |
#class_name ⇒ Object
69 70 71 |
# File 'lib/carin_for_blue_button_test_kit/generator/validation_test_generator.rb', line 69 def class_name "#{Naming.upper_camel_case_for_profile()}ValidationTest" end |
#conformance_expectation ⇒ Object
81 82 83 |
# File 'lib/carin_for_blue_button_test_kit/generator/validation_test_generator.rb', line 81 def conformance_expectation read_interaction[:expectation] end |
#description ⇒ Object
119 120 121 122 123 124 125 126 127 128 |
# File 'lib/carin_for_blue_button_test_kit/generator/validation_test_generator.rb', line 119 def description <<~DESCRIPTION #{description_intro} It verifies the presence of mandatory elements and that elements with required bindings contain appropriate values. CodeableConcept element bindings will fail if none of their codings have a code/system belonging to the bound ValueSet. Quantity, Coding, and code element bindings will fail if their code/system are not found in the valueset. DESCRIPTION end |
#description_intro ⇒ Object
130 131 132 133 134 135 136 |
# File 'lib/carin_for_blue_button_test_kit/generator/validation_test_generator.rb', line 130 def description_intro <<~GENERIC_INTRO This test verifies resources returned from the first search conform to the [#{profile_name}](#{profile_url}). Systems must demonstrate at least one valid example in order to pass this test. GENERIC_INTRO end |
#directory_name ⇒ Object
45 46 47 |
# File 'lib/carin_for_blue_button_test_kit/generator/validation_test_generator.rb', line 45 def directory_name Naming.snake_case_for_profile( || ) end |
#generate ⇒ Object
108 109 110 111 112 113 114 115 116 117 |
# File 'lib/carin_for_blue_button_test_kit/generator/validation_test_generator.rb', line 108 def generate FileUtils.mkdir_p(output_file_directory) File.open(output_file_name, 'w') { |f| f.write(output) } = { id: test_id, file_name: base_output_file_name } .add_test(**) end |
#module_name ⇒ Object
73 74 75 |
# File 'lib/carin_for_blue_button_test_kit/generator/validation_test_generator.rb', line 73 def module_name "CARIN4BB#{.reformatted_version.upcase}" end |
#output ⇒ Object
27 28 29 |
# File 'lib/carin_for_blue_button_test_kit/generator/validation_test_generator.rb', line 27 def output @output ||= ERB.new(template).result(binding) end |
#output_file_directory ⇒ Object
37 38 39 |
# File 'lib/carin_for_blue_button_test_kit/generator/validation_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/carin_for_blue_button_test_kit/generator/validation_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/carin_for_blue_button_test_kit/generator/validation_test_generator.rb', line 49 def profile_identifier Naming.snake_case_for_profile() end |
#profile_name ⇒ Object
57 58 59 |
# File 'lib/carin_for_blue_button_test_kit/generator/validation_test_generator.rb', line 57 def profile_name .profile_name end |
#profile_url ⇒ Object
53 54 55 |
# File 'lib/carin_for_blue_button_test_kit/generator/validation_test_generator.rb', line 53 def profile_url .profile_url end |
#profile_version ⇒ Object
61 62 63 |
# File 'lib/carin_for_blue_button_test_kit/generator/validation_test_generator.rb', line 61 def profile_version .profile_version end |
#resource_type ⇒ Object
77 78 79 |
# File 'lib/carin_for_blue_button_test_kit/generator/validation_test_generator.rb', line 77 def resource_type .resource end |
#skip_if_empty ⇒ Object
102 103 104 105 106 |
# File 'lib/carin_for_blue_button_test_kit/generator/validation_test_generator.rb', line 102 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 |
#specific_resource_type ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/carin_for_blue_button_test_kit/generator/validation_test_generator.rb', line 85 def specific_resource_type case profile_identifier when 'eob_inpatient_institutional' return "ExplanationOfBenefitInpatientInstitutional" when 'eob_oral' return "ExplanationOfBenefitOral" when 'eob_outpatient_institutional' return "ExplanationOfBenefitOutpatientInstitutional" when 'eob_pharmacy' return "ExplanationOfBenefitPharmacy" when 'eob_professional_non_clinician' return "ExplanationOfBenefitProfessionalNonClinician" else return self.resource_type end end |
#template ⇒ Object
23 24 25 |
# File 'lib/carin_for_blue_button_test_kit/generator/validation_test_generator.rb', line 23 def template @template ||= File.read(File.join(__dir__, 'templates', 'validation.rb.erb')) end |
#test_id ⇒ Object
65 66 67 |
# File 'lib/carin_for_blue_button_test_kit/generator/validation_test_generator.rb', line 65 def test_id "c4bb_#{.reformatted_version}_#{profile_identifier}_validation_test" end |