class RxNav::Concept

Public Instance Methods

get_ndfrt_info() click to toggle source
# File lib/rx_nav/concept.rb, line 38
def get_ndfrt_info
  nui = get_nui
  info = RxNav::NDFRT.get_info(nui)
  merge_concept info
end
get_norm_info() click to toggle source
# File lib/rx_nav/concept.rb, line 44
def get_norm_info
  rxcui = get_rxcui
  info = RxNav::RxNorm.properties rxcui
  info.quantity = RxNav::RxNorm.quantity rxcui
  info.strength = RxNav::RxNorm.strength rxcui
  merge_concept info
end
get_terms_info() click to toggle source

Supplementary calls to fetch info from other DBs Note: these methods return false if no information was found

# File lib/rx_nav/concept.rb, line 32
def get_terms_info
  rxcui = get_rxcui
  info = RxNav::RxTerms.all_info(rxcui)
  merge_concept info
end
kind() click to toggle source
# File lib/rx_nav/concept.rb, line 16
def kind
  kind = self.concept_kind
  kind ? titleize_kind(self.concept_kind) : nil
end
name() click to toggle source
# File lib/rx_nav/concept.rb, line 6
def name
  name = self.display_name ||
         self.synonym ||
         self.full_name ||
         self.full_generic_name ||
         self.concept_name ||
         @table[:name]
  name ? titleize_str(name) : nil
end
nui() click to toggle source
# File lib/rx_nav/concept.rb, line 21
def nui
  self.concept_nui
end
to_s() click to toggle source
# File lib/rx_nav/concept.rb, line 25
def to_s
  name
end

Private Instance Methods

get_nui() click to toggle source
# File lib/rx_nav/concept.rb, line 69
def get_nui
  if self.nui.nil?
    if self.rxcui.nil?
      raise "This concept doesn't have a nui or rxcui"
    else
      record = RxNav::NDFRT.find_by_id('rxcui', self.rxcui).first
      self.concept_nui = record.nui
    end
  end
  return self.nui
end
get_rxcui() click to toggle source
# File lib/rx_nav/concept.rb, line 54
def get_rxcui
  # Terms use the rxcui for the lookup
  if self.rxcui.nil?
    # Fail if we have a concept without any IDs (that are written so far)
    if self.nui.nil?
      raise "This concept doesn't have a nui or rxcui"
    else
       rxcui = RxNav::RxNorm.find_rxcui_by_id('nui', self.nui)
       self.rxcui = rxcui.is_a?(Array) ? rxcui.first : rxcui
    end
  end
  # If we had to look it up, use that, otherwise use the model's
  return self.rxcui
end
merge_concept(concept_hash) click to toggle source
# File lib/rx_nav/concept.rb, line 89
def merge_concept concept_hash
  if concept_hash.nil? || concept_hash.empty?
    return false
  else
    concept_hash.each do |k,v|
      puts self.k
      self.k = v if self.k.nil?
      puts self.k
    end
  end
  return self
end
titleize_kind(str) click to toggle source
# File lib/rx_nav/concept.rb, line 81
def titleize_kind str
  str.split("_")[0...-1].map(&:capitalize).join(" ") if str.is_a? String
end
titleize_str(str) click to toggle source
# File lib/rx_nav/concept.rb, line 85
def titleize_str str
  str.gsub(/\w+/) { |w| w.capitalize } if str.is_a? String
end