Class: AUCoreTestKit::Generator::SpecialIdentifierSearchTestGenerator

Inherits:
SearchTestGenerator show all
Defined in:
lib/au_core_test_kit/generator/special_identifier_search_test_generator.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SearchTestGenerator

#array_of_strings, #base_output_file_name, #conformance_expectation, #first_search?, #first_search_description, #first_search_for_patient_by_patient_id, #fixed_value_search?, #fixed_value_search_param_name, #generate, #includes, #medication_inclusion_description, #module_name, #needs_patient_id?, #optional_multiple_and_search_params, #optional_multiple_and_search_params_string, #optional_multiple_or_search_params, #optional_multiple_or_search_params_string, #output, #output_file_directory, #output_file_name, #path_for_value, #possible_status_search?, #post_search_description, #profile_identifier, #reference_search_description, #required_comparators, #required_comparators_for_param, #required_comparators_string, #required_multiple_and_search_params, #required_multiple_and_search_params_string, #required_multiple_or_search_params, #required_multiple_or_search_params_string, #resource_type, #saves_delayed_references?, #search_definition, #search_identifier, #search_method, #search_param_name_string, #search_param_names, #search_param_names_array, #search_params, #search_test_properties_string, #search_title, #test_medication_inclusion?, #test_post_search?, #test_reference_variants?, #token_search_params, #token_search_params_string, #url_version

Constructor Details

#initialize(group_metadata, search_metadata, base_output_dir, special_identifier) ⇒ SpecialIdentifierSearchTestGenerator

Returns a new instance of SpecialIdentifierSearchTestGenerator.



39
40
41
42
# File 'lib/au_core_test_kit/generator/special_identifier_search_test_generator.rb', line 39

def initialize(, , base_output_dir, special_identifier)
  super(, , base_output_dir)
  self.special_identifier = special_identifier
end

Instance Attribute Details

#base_output_dirObject

Returns the value of attribute base_output_dir.



37
38
39
# File 'lib/au_core_test_kit/generator/special_identifier_search_test_generator.rb', line 37

def base_output_dir
  @base_output_dir
end

#group_metadataObject

Returns the value of attribute group_metadata.



37
38
39
# File 'lib/au_core_test_kit/generator/special_identifier_search_test_generator.rb', line 37

def 
  
end

#search_metadataObject

Returns the value of attribute search_metadata.



37
38
39
# File 'lib/au_core_test_kit/generator/special_identifier_search_test_generator.rb', line 37

def 
  
end

#special_identifierObject

Returns the value of attribute special_identifier.



37
38
39
# File 'lib/au_core_test_kit/generator/special_identifier_search_test_generator.rb', line 37

def special_identifier
  @special_identifier
end

Class Method Details

.generate(ig_metadata, base_output_dir) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/au_core_test_kit/generator/special_identifier_search_test_generator.rb', line 11

def generate(, base_output_dir)
  .groups.reject { |group| SpecialCases.exclude_group? group }
    .select { |group| ['au_core_patient', 'au_core_practitioner', 'au_core_organization', 'au_core_practitionerrole'].include? group.name }
    .select { |group| group.searches.present? }
    .each do |group|
      group.searches.each do |search|
        next unless search[:names].include? 'identifier'
        identifier_arr =
          case group.name
          when 'au_core_patient'
            SpecialCases.patient_au_identifiers
          when 'au_core_practitioner'
            SpecialCases.practitioner_au_identifiers
          when 'au_core_practitionerrole'
            SpecialCases.practitionerrole_au_identifiers
          when 'au_core_organization'
            SpecialCases.organization_au_identifiers
          end
        identifier_arr.each do |special_identifier|
          new(group, search, base_output_dir, special_identifier).generate
        end
      end
  end
end

Instance Method Details

#class_nameObject



52
53
54
# File 'lib/au_core_test_kit/generator/special_identifier_search_test_generator.rb', line 52

def class_name
  "#{Naming.upper_camel_case_for_profile(group_metadata)}#{search_title}#{special_identifier[:display].delete('-')}SearchTest"
end

#descriptionObject



73
74
75
76
77
78
79
80
81
82
# File 'lib/au_core_test_kit/generator/special_identifier_search_test_generator.rb', line 73

def description
  "    A server SHOULD support searching by\n    \#{search_param_name_string} (\#{special_identifier[:display]}) on the \#{resource_type} resource. This test\n    will pass if resources are returned and match the search criteria. If\n    none are returned, the test is skipped.\n\n    [AU Core Server CapabilityStatement](http://hl7.org.au/fhir/core/\#{url_version}/CapabilityStatement-au-core-server.html)\n  DESCRIPTION\nend\n".gsub(/\n{3,}/, "\n\n")

#optional?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/au_core_test_kit/generator/special_identifier_search_test_generator.rb', line 56

def optional?
  true
end

#search_propertiesObject



60
61
62
63
64
65
66
67
# File 'lib/au_core_test_kit/generator/special_identifier_search_test_generator.rb', line 60

def search_properties
  {}.tap do |properties|
    properties[:resource_type] = "'#{resource_type}'"
    properties[:search_param_names] = search_param_names_array
    properties[:token_search_params] = token_search_params_string if token_search_params.present?
    properties[:target_identifier] = special_identifier
  end
end

#templateObject



44
45
46
# File 'lib/au_core_test_kit/generator/special_identifier_search_test_generator.rb', line 44

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

#test_idObject



48
49
50
# File 'lib/au_core_test_kit/generator/special_identifier_search_test_generator.rb', line 48

def test_id
  "au_core_#{group_metadata.reformatted_version}_#{profile_identifier}_#{search_identifier}_#{special_identifier[:display].delete('-').downcase}_search_test"
end

#titleObject



69
70
71
# File 'lib/au_core_test_kit/generator/special_identifier_search_test_generator.rb', line 69

def title
  "Server returns valid results for #{resource_type} search by identifier (#{special_identifier[:display]})"
end