module ADIWG::Mdcodes
Constants
- VERSION
Public Class Methods
getAllCodelistsDetail(format='hash', showDeprecated=false)
click to toggle source
return all codelists with all elements
# File lib/adiwg/mdcodes.rb, line 26 def self.getAllCodelistsDetail(format='hash', showDeprecated=false) path = getYamlPath + '/*.yml' hCodelists = {} Dir.glob(path) do |item| hCodelist = YAML.load_file(item) hCodelists[hCodelist['codelistName']] = hCodelist end unless showDeprecated hCodelists.each do |key, value| aKeepItems = [] value['codelist'].each do |item| if item.has_key?('deprecated') unless item['deprecated'] aKeepItems << item end else aKeepItems << item end value['codelist'] = aKeepItems end end end return hCodelists.to_json if format == 'json' return hCodelists end
getAllStaticCodelists(format='hash', showDeprecated=false)
click to toggle source
return all codelist with only the codeName
# File lib/adiwg/mdcodes.rb, line 78 def self.getAllStaticCodelists(format='hash', showDeprecated=false) hCodelists = {} codelists = getAllCodelistsDetail('hash', showDeprecated) codelists.each do |key, value| aList = [] value['codelist'].each do |item| aList << item['codeName'] end hCodelists[key] = aList end return hCodelists.to_json if format == 'json' return hCodelists end
getCodelistDetail(codelist, format='hash', showDeprecated=false)
click to toggle source
return a single codelist with all elements
# File lib/adiwg/mdcodes.rb, line 53 def self.getCodelistDetail(codelist, format='hash', showDeprecated=false) file = File.join(getYamlPath, codelist + '.yml') if File.exist?(file) hCodelist = YAML.load_file(file) unless showDeprecated aKeepItems = [] hCodelist['codelist'].each do |item| if item.has_key?('deprecated') unless item['deprecated'] aKeepItems << item end else aKeepItems << item end hCodelist['codelist'] = aKeepItems end end else return nil end return hCodelist.to_json if format == 'json' return hCodelist end
getStaticCodelist(codelist, format='hash', showDeprecated=false)
click to toggle source
return a single codelist with only the codeName
# File lib/adiwg/mdcodes.rb, line 93 def self.getStaticCodelist(codelist, format='hash', showDeprecated=false) hCodelist = getCodelistDetail(codelist, 'hash', showDeprecated) unless hCodelist.nil? hCodeNames = {} aList = [] hCodelist['codelist'].each do |item| aList << item['codeName'] end hCodeNames[hCodelist['codelistName']] = aList return hCodeNames.to_json if format == 'json' return hCodeNames end return nil end
getYamlPath()
click to toggle source
return the path to yaml files.
# File lib/adiwg/mdcodes.rb, line 21 def self.getYamlPath File.join(File.dirname(File.expand_path(__FILE__)), '..', '..', 'resources') end