Class: Inferno::Terminology::Tasks::ExpandValueSetToFile
- Inherits:
-
Object
- Object
- Inferno::Terminology::Tasks::ExpandValueSetToFile
- Defined in:
- lib/inferno/terminology/tasks/expand_value_set_to_file.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value_set_url ⇒ Object
readonly
Returns the value of attribute value_set_url.
Instance Method Summary collapse
-
#initialize(vs:, filename:, type:) ⇒ ExpandValueSetToFile
constructor
rubocop:disable Naming/MethodParameterName.
- #run ⇒ Object
Constructor Details
#initialize(vs:, filename:, type:) ⇒ ExpandValueSetToFile
rubocop:disable Naming/MethodParameterName
7 8 9 10 11 |
# File 'lib/inferno/terminology/tasks/expand_value_set_to_file.rb', line 7 def initialize(vs:, filename:, type:) # rubocop:disable Naming/MethodParameterName @value_set_url = vs @filename = filename @type = type end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
5 6 7 |
# File 'lib/inferno/terminology/tasks/expand_value_set_to_file.rb', line 5 def filename @filename end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/inferno/terminology/tasks/expand_value_set_to_file.rb', line 5 def type @type end |
#value_set_url ⇒ Object (readonly)
Returns the value of attribute value_set_url.
5 6 7 |
# File 'lib/inferno/terminology/tasks/expand_value_set_to_file.rb', line 5 def value_set_url @value_set_url end |
Instance Method Details
#run ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/inferno/terminology/tasks/expand_value_set_to_file.rb', line 13 def run # JSON is a special case, because we need to add codes from valuesets from several versions # We accomplish this by collecting and merging codes from each version # Before writing the JSON to a file at the end end_vs = nil if type == 'json' %w[2024].each do |version| Loader.register_umls_db File.join(TEMP_DIR, version, 'umls.db') Loader.load_value_sets_from_directory(PACKAGE_DIR, true) vs = Repositories::ValueSets.new.find(value_set_url) if type == 'json' end_vs ||= vs end_vs.value_set.merge vs.value_set else Loader.save_to_file(vs.valueset, filename, type.to_sym) end end File.open("#{filename}.json", 'wb') { |f| f << end_vs.expansion_as_fhir_valueset.to_json } if type == 'json' end |