Class: USCoreTestKit::Generator::SuiteGenerator

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

Direct Known Subclasses

Client::Generator::SuiteGenerator

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_dir ⇒ Object

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_metadata ⇒ Object

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_name ⇒ Object



51
52
53
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 51

def base_output_file_name
  'us_core_test_suite.rb'
end

#capability_statement_file_name ⇒ Object



115
116
117
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 115

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

#capability_statement_group_id ⇒ Object



119
120
121
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 119

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

#class_name ⇒ Object



55
56
57
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 55

def class_name
  'USCoreTestSuite'
end

#clinical_notes_guidance_file_name ⇒ Object



123
124
125
126
127
128
129
130
131
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 123

def clinical_notes_guidance_file_name
  if .ig_version == 'v3.1.1'
    '../../custom_groups/v3.1.1/clinical_notes_guidance_group'
  elsif .ig_version[1].to_i < 8
    '../../custom_groups/v4.0.0/clinical_notes_guidance_group'
  else
    '../../custom_groups/v8.0.0/clinical_notes_guidance_group'
  end
end

#clinical_notes_guidance_group_id ⇒ Object



133
134
135
136
137
138
139
140
141
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 133

def clinical_notes_guidance_group_id
  if .reformatted_version == 'v311'
    'us_core_v311_clinical_notes_guidance'
  elsif .ig_version[1].to_i < 8
    'us_core_v400_clinical_notes_guidance'
  else
    'us_core_v800_clinical_notes_guidance'
  end
end

#fhir_api_group_id ⇒ Object



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

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

#generate ⇒ Object



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

def generate
  File.write(output_file_name, output)
end

#granular_scopes_file_name ⇒ Object



143
144
145
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 143

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

#granular_scopes_id ⇒ Object



147
148
149
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 147

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

#group_file_list ⇒ Object



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

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

#group_id_list ⇒ Object



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

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

#groups ⇒ Object



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

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

#ig_identifier ⇒ Object



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

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


84
85
86
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 84

def ig_link
  Naming.ig_link(.ig_version)
end

#module_name ⇒ Object



59
60
61
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 59

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

#output ⇒ Object



47
48
49
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 47

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

#output_file_name ⇒ Object



63
64
65
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 63

def output_file_name
  File.join(base_output_dir, base_output_file_name)
end

#screening_assessment_file_name ⇒ Object



151
152
153
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 151

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

#screening_assessment_id ⇒ Object



155
156
157
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 155

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

#smart_app_launch_file_name ⇒ Object



159
160
161
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 159

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

#smart_app_launch_id ⇒ Object



167
168
169
170
171
172
173
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 167

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_name ⇒ Object



163
164
165
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 163

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

#suite_id ⇒ Object



67
68
69
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 67

def suite_id
  "us_core_#{.reformatted_version}"
end

#template ⇒ Object



43
44
45
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 43

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

#title ⇒ Object



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

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

#us_core_6_and_above? ⇒ Boolean

Returns:

  • (Boolean)


88
89
90
# File 'lib/us_core_test_kit/generator/suite_generator.rb', line 88

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

#us_core_7_and_above? ⇒ Boolean

Returns:

  • (Boolean)


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

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

#version_specific_message_filters ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# 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}
    ]
  when 'v501'
    [
      %r{A definition for CodeSystem 'http://terminology\.hl7\.org/CodeSystem/v3-AdministrativeGender' version '2021-12-01' could not be found, so the code cannot be validated},
      %r{A definition for CodeSystem 'http://terminology\.hl7\.org/CodeSystem/v3-NullFlavor' version '2021-12-01' could not be found, so the code cannot be validated},
      %r{The value provided \('M'\) was not found in the value set 'Birth Sex' \(http://hl7\.org/fhir/us/core/ValueSet/birthsex\|5\.0\.1\)},
      %r{The value provided \('F'\) was not found in the value set 'Birth Sex' \(http://hl7\.org/fhir/us/core/ValueSet/birthsex\|5\.0\.1\)},
      %r{The value provided \('ASKU'\) was not found in the value set 'Birth Sex' \(http://hl7\.org/fhir/us/core/ValueSet/birthsex\|5\.0\.1\)},
      %r{The value provided \('OTH'\) was not found in the value set 'Birth Sex' \(http://hl7\.org/fhir/us/core/ValueSet/birthsex\|5\.0\.1\)},
      %r{The value provided \('UNK'\) was not found in the value set 'Birth Sex' \(http://hl7\.org/fhir/us/core/ValueSet/birthsex\|5\.0\.1\)}
    ]
  else
    []
  end
end