class RxNav::NDFRT

Public Class Methods

all_records_by_kind(kind) click to toggle source
# File lib/rx_nav/ndfrt.rb, line 79
def all_records_by_kind kind
  kind = kind.upcase + "_KIND"
  query = "/allconcepts?kind=#{kind}"
  data = get_response_hash(query)[:group_concepts][:concept]
  return data.map { |c| RxNav::Concept.new c }
end
api_version() click to toggle source
# File lib/rx_nav/ndfrt.rb, line 4
def api_version
  get_response_hash("/version")[:version][:version_name].to_s
end
find_by(hash) click to toggle source
# File lib/rx_nav/ndfrt.rb, line 32
def find_by hash
  return find_by_id(hash[:type], hash[:id]) if hash.has_key? :id
  return find_by_name(hash[:name], hash[:kind]) if hash.has_key? :name
end
find_by_id(type, id) click to toggle source
# File lib/rx_nav/ndfrt.rb, line 37
def find_by_id type, id
  type  = type.upcase
  id    = id.to_s
  query = "/idType=#{type}&idString=#{id}"
  get_concepts query
end
find_by_name(name, kind = nil) click to toggle source
# File lib/rx_nav/ndfrt.rb, line 44
def find_by_name name, kind = nil
  query = "/search?conceptName=#{name}"
  unless kind.nil?
    kind = kind.upcase + '_KIND'
    query += "&kindName=#{kind}"
  end
  get_concepts query
end
get_info(nui, concept = nil) click to toggle source

PLEASE NOTE: These methods were deprecated in the Sept 2014 release of ND-FRT

def find_interacting_drugs nui, scope = 3

query = "/interaction/nui=#{nui}&scope=#{scope}"
response = get_response_hash query
data = response[:group_interactions][:interactions][:group_interacting_drugs][:interacting_drug]
data = [data] unless data.is_a? Array
return data.map { |i| RxNav::Concept.new i[:concept] }

end

def find_interactions_between nuis, scope = 3

query = "/interaction?nuis=#{nuis.join('+')}&scope=#{scope}"
data = get_response_hash query
return data[:full_interaction_group][:full_interaction].map do |fi|
  RxNav::Interaction.new fi[:interaction_triple_group][:interaction_triple]
end

end

# File lib/rx_nav/ndfrt.rb, line 72
def get_info nui, concept = nil
  raise "Nui cannot be nil" if nui.nil?
  query = "/allInfo/#{nui}"
  data = get_response_hash(query)[:full_concept]
  return RxNav::Concept.new(data)
end
possible_associations() click to toggle source
# File lib/rx_nav/ndfrt.rb, line 12
def possible_associations
  get_options "association"
end
possible_kinds() click to toggle source
# File lib/rx_nav/ndfrt.rb, line 20
def possible_kinds
  get_options("kind").map { |k| k.split('_')[0...-1].join('_').downcase }
end
possible_options_for(type) click to toggle source
# File lib/rx_nav/ndfrt.rb, line 8
def possible_options_for type
  get_options type.to_s.downcase
end
possible_properties() click to toggle source
# File lib/rx_nav/ndfrt.rb, line 24
def possible_properties
  get_options "property"
end
possible_roles() click to toggle source
# File lib/rx_nav/ndfrt.rb, line 28
def possible_roles
  get_options "role"
end
possible_types() click to toggle source
# File lib/rx_nav/ndfrt.rb, line 16
def possible_types
  get_options "type"
end

Private Class Methods

get_concepts(query) click to toggle source
# File lib/rx_nav/ndfrt.rb, line 97
def get_concepts query
  data = get_response_hash(query)[:group_concepts]
  if data && data[:concept]
    concepts = RxNav.ensure_array data[:concept]
    return concepts.map { |c| RxNav::Concept.new(c) }
  else
    return nil
  end
end
get_options(type) click to toggle source
# File lib/rx_nav/ndfrt.rb, line 92
def get_options type
  data = get_response_hash "/#{type}List"
  return data["#{type}_list".to_sym]["#{type}_name".to_sym].map { |a| a.to_s }
end
get_response_hash(query) click to toggle source
# File lib/rx_nav/ndfrt.rb, line 88
def get_response_hash query
  RxNav.make_request('/Ndfrt' + query)[:ndfrtdata]
end