Class: USCoreTestKit::Generator::SuiteGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/us_core_test_kit/generator/suite_generator.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ig_metadata, base_output_dir) ⇒ SuiteGenerator

Returns a new instance of SuiteGenerator.



15
16
17
18
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 15

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

Instance Attribute Details

#base_output_dirObject

Returns the value of attribute base_output_dir.



13
14
15
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 13

def base_output_dir
  @base_output_dir
end

#ig_metadataObject

Returns the value of attribute ig_metadata.



13
14
15
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 13

def 
  @ig_metadata
end

Class Method Details

.generate(ig_metadata, base_output_dir) ⇒ Object



8
9
10
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 8

def generate(, base_output_dir)
  new(, base_output_dir).generate
end

Instance Method Details

#base_output_file_nameObject



41
42
43
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 41

def base_output_file_name
  'us_core_test_suite.rb'
end

#capability_statement_file_nameObject



105
106
107
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 105

def capability_statement_file_name
  "../../custom_groups/#{.ig_version}/capability_statement_group"
end

#capability_statement_group_idObject



109
110
111
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 109

def capability_statement_group_id
  "us_core_#{.reformatted_version}_capability_statement"
end

#class_nameObject



45
46
47
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 45

def class_name
  'USCoreTestSuite'
end

#clinical_notes_guidance_file_nameObject



113
114
115
116
117
118
119
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 113

def clinical_notes_guidance_file_name
  if .ig_version == 'v3.1.1'
    "../../custom_groups/#{.ig_version}/clinical_notes_guidance_group"
  else
    '../../custom_groups/v4.0.0/clinical_notes_guidance_group'
  end
end

#clinical_notes_guidance_group_idObject



121
122
123
124
125
126
127
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 121

def clinical_notes_guidance_group_id
  if .reformatted_version == 'v311'
    "us_core_#{.reformatted_version}_clinical_notes_guidance"
  else
    'us_core_v400_clinical_notes_guidance'
  end
end

#fhir_api_group_idObject



61
62
63
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 61

def fhir_api_group_id
  "us_core_#{.reformatted_version}_fhir_api"
end

#generateObject



86
87
88
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 86

def generate
  File.write(output_file_name, output)
end

#granular_scopes_file_nameObject



129
130
131
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 129

def granular_scopes_file_name
  "../../custom_groups/#{.ig_version}/smart_granular_scopes_group"
end

#granular_scopes_idObject



133
134
135
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 133

def granular_scopes_id
  "us_core_#{.reformatted_version}_smart_granular_scopes"
end

#group_file_listObject



100
101
102
103
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 100

def group_file_list
  @group_file_list ||=
    groups.map { |group| group.file_name.delete_suffix('.rb') }
end

#group_id_listObject



95
96
97
98
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 95

def group_id_list
  @group_id_list ||=
    groups.map(&:id)
end

#groupsObject



90
91
92
93
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 90

def groups
  .ordered_groups
    .reject { |group| SpecialCases.exclude_group? group }
end

#ig_identifierObject



69
70
71
72
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 69

def ig_identifier
  version = .ig_version[1..] # Remove leading 'v'
  "hl7.fhir.us.core##{version}"
end


74
75
76
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 74

def ig_link
  Naming.ig_link(.ig_version)
end

#module_nameObject



49
50
51
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 49

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

#outputObject



37
38
39
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 37

def output
  @output ||= ERB.new(template).result(binding)
end

#output_file_nameObject



53
54
55
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 53

def output_file_name
  File.join(base_output_dir, base_output_file_name)
end

#screening_assessment_file_nameObject



137
138
139
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 137

def screening_assessment_file_name
  "../../custom_groups/#{.ig_version}/screening_assessment_group"
end

#screening_assessment_idObject



141
142
143
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 141

def screening_assessment_id
  "us_core_#{.reformatted_version}_screening_assessment"
end

#smart_app_launch_file_nameObject



145
146
147
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 145

def smart_app_launch_file_name
  "../../custom_groups/#{.ig_version}/smart_app_launch_group"
end

#smart_app_launch_idObject



153
154
155
156
157
158
159
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 153

def smart_app_launch_id
  if us_core_7_and_above?
    "us_core_#{.reformatted_version}_smart_app_launch"
  else
    'us_core_smart_app_launch'
  end
end

#stu2_2_smart_app_launch_file_nameObject



149
150
151
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 149

def stu2_2_smart_app_launch_file_name
  "../../custom_groups/#{.ig_version}/smart_app_launch_stu2_2_group"
end

#suite_idObject



57
58
59
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 57

def suite_id
  "us_core_#{.reformatted_version}"
end

#templateObject



33
34
35
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 33

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

#titleObject



65
66
67
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 65

def title
  "US Core #{.ig_version}"
end

#us_core_6_and_above?Boolean

Returns:

  • (Boolean)


78
79
80
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 78

def us_core_6_and_above?
  .ig_version[1].to_i > 5
end

#us_core_7_and_above?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 82

def us_core_7_and_above?
  .ig_version[1].to_i > 6
end

#version_specific_message_filtersObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 20

def version_specific_message_filters
  case .reformatted_version
  when 'v610'
    [
      %r{Observation\.effective\.ofType\(Period\):.*http://hl7.org/fhir/us/core/StructureDefinition/us-core-smokingstatus|6.1.0},
      %r{Observation: Slice 'Observation\.effective\[x\]:effectiveDateTime':.*http://hl7.org/fhir/us/core/StructureDefinition/us-core-smokingstatus|6.1.0},
      %r{Observation\.effective\.ofType\(Period\)\.(start|end): This element is not allowed by the profile http://hl7.org/fhir/StructureDefinition/dateTime}
    ]
  else
    []
  end
end