Class: FHIR::Terminology
- Inherits:
-
Object
- Object
- FHIR::Terminology
- Defined in:
- lib/terminology.rb
Constant Summary collapse
- CODE_SYSTEMS =
{ 'http://snomed.info/sct'=>'SNOMED', 'http://loinc.org'=>'LOINC', 'http://www.nlm.nih.gov/research/umls/rxnorm'=>'RXNORM', 'http://hl7.org/fhir/sid/icd-10'=>'ICD10', 'http://hl7.org/fhir/sid/icd-10-de'=>'ICD10', 'http://hl7.org/fhir/sid/icd-10-nl'=>'ICD10', 'http://hl7.org/fhir/sid/icd-10-us'=>'ICD10', 'http://www.icd10data.com/icd10pcs'=>'ICD10', 'http://hl7.org/fhir/sid/icd-9-cm'=>'ICD9', 'http://hl7.org/fhir/sid/icd-9-cm/diagnosis'=>'ICD9', 'http://hl7.org/fhir/sid/icd-9-cm/procedure'=>'ICD9', 'http://hl7.org/fhir/sid/cvx'=>'CVX' }
- @@term_root =
File. '../terminology',File.dirname(File.absolute_path(__FILE__))
- @@loaded =
false- @@top_lab_code_units =
{}
- @@top_lab_code_descriptions =
{}
- @@known_codes =
{}
- @@core_snomed =
{}
- @@common_ucum =
[]
Class Method Summary collapse
- .get_description(system, code) ⇒ Object
- .is_core_snomed?(code) ⇒ Boolean
- .is_known_ucum?(units) ⇒ Boolean
- .is_top_lab_code?(code) ⇒ Boolean
- .lab_description(code) ⇒ Object
- .lab_units(code) ⇒ Object
- .load_terminology ⇒ Object
- .set_terminology_root(root) ⇒ Object
Class Method Details
.get_description(system, code) ⇒ Object
101 102 103 104 105 106 107 108 |
# File 'lib/terminology.rb', line 101 def self.get_description(system,code) load_terminology if @@known_codes[system] @@known_codes[system][code] else nil end end |
.is_core_snomed?(code) ⇒ Boolean
110 111 112 113 |
# File 'lib/terminology.rb', line 110 def self.is_core_snomed?(code) load_terminology !@@core_snomed[code].nil? end |
.is_known_ucum?(units) ⇒ Boolean
125 126 127 128 |
# File 'lib/terminology.rb', line 125 def self.is_known_ucum?(units) load_terminology @@top_lab_code_units.values.include?(units) || @@common_ucum.include?(units) end |
.is_top_lab_code?(code) ⇒ Boolean
115 116 117 118 |
# File 'lib/terminology.rb', line 115 def self.is_top_lab_code?(code) load_terminology !@@top_lab_code_units[code].nil? end |
.lab_description(code) ⇒ Object
130 131 132 133 |
# File 'lib/terminology.rb', line 130 def self.lab_description(code) load_terminology @@top_lab_code_descriptions[code] end |
.lab_units(code) ⇒ Object
120 121 122 123 |
# File 'lib/terminology.rb', line 120 def self.lab_units(code) load_terminology @@top_lab_code_units[code] end |
.load_terminology ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/terminology.rb', line 32 def self.load_terminology if !@@loaded begin # load the top lab codes filename = File.join(@@term_root,'scorecard_loinc_2000.txt') raw = File.open(filename,'r:UTF-8',&:read) raw.split("\n").each do |line| row = line.split('|') @@top_lab_code_descriptions[row[0]] = row[1] if !row[1].nil? @@top_lab_code_units[row[0]] = row[2] if !row[2].nil? end rescue Exception => error FHIR.logger.error error end begin # load the known codes filename = File.join(@@term_root,'scorecard_umls.txt') raw = File.open(filename,'r:UTF-8',&:read) raw.split("\n").each do |line| row = line.split('|') codeSystem = row[0] code = row[1] description = row[2] if @@known_codes[codeSystem] codeSystemHash = @@known_codes[codeSystem] else codeSystemHash = {} @@known_codes[codeSystem] = codeSystemHash end codeSystemHash[code] = description end rescue Exception => error FHIR.logger.error error end begin # load the core snomed codes @@known_codes['SNOMED'] = {} if @@known_codes['SNOMED'].nil? codeSystemHash = @@known_codes['SNOMED'] filename = File.join(@@term_root,'scorecard_snomed_core.txt') raw = File.open(filename,'r:UTF-8',&:read) raw.split("\n").each do |line| row = line.split('|') code = row[0] description = row[1] codeSystemHash[code] = description if codeSystemHash[code].nil? @@core_snomed[code] = description end rescue Exception => error FHIR.logger.error error end begin # load common UCUM codes filename = File.join(@@term_root,'scorecard_ucum.txt') raw = File.open(filename,'r:UTF-8',&:read) raw.split("\n").each do |code| @@common_ucum << code end @@common_ucum.uniq! rescue Exception => error FHIR.logger.error error end @@loaded = true end end |