Module: ADIWG::Mdcodes
- Defined in:
- lib/adiwg/mdcodes.rb,
lib/adiwg/mdcodes/version.rb
Constant Summary collapse
- VERSION =
"2.10.1"
Class Method Summary collapse
-
.getAllCodelistsDetail(format = 'hash', showDeprecated = false) ⇒ Object
return all codelists with all elements.
-
.getAllStaticCodelists(format = 'hash', showDeprecated = false) ⇒ Object
return all codelist with only the codeName.
-
.getCodelistDetail(codelist, format = 'hash', showDeprecated = false) ⇒ Object
return a single codelist with all elements.
-
.getStaticCodelist(codelist, format = 'hash', showDeprecated = false) ⇒ Object
return a single codelist with only the codeName.
-
.getYamlPath ⇒ Object
return the path to yaml files.
Class Method Details
.getAllCodelistsDetail(format = 'hash', showDeprecated = false) ⇒ Object
return all codelists with all elements
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# 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) ⇒ Object
return all codelist with only the codeName
78 79 80 81 82 83 84 85 86 87 88 89 90 |
# 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) ⇒ Object
return a single codelist with all elements
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# 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) ⇒ Object
return a single codelist with only the codeName
93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# 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 ⇒ Object
return the path to yaml files.
21 22 23 |
# File 'lib/adiwg/mdcodes.rb', line 21 def self.getYamlPath File.join(File.dirname(File.(__FILE__)), '..', '..', 'resources') end |