Class: RxNav::NDFRT

Inherits:
Object
  • Object
show all
Defined in:
lib/rx_nav/ndfrt.rb

Class Method Summary collapse

Class Method Details

.all_records_by_kind(kind) ⇒ Object



79
80
81
82
83
84
# 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_versionObject



4
5
6
# File 'lib/rx_nav/ndfrt.rb', line 4

def api_version
  get_response_hash("/version")[:version][:version_name].to_s
end

.find_by(hash) ⇒ Object



32
33
34
35
# 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) ⇒ Object



37
38
39
40
41
42
# 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) ⇒ Object



44
45
46
47
48
49
50
51
# 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) ⇒ Object

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



72
73
74
75
76
77
# 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_associationsObject



12
13
14
# File 'lib/rx_nav/ndfrt.rb', line 12

def possible_associations
  get_options "association"
end

.possible_kindsObject



20
21
22
# 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) ⇒ Object



8
9
10
# File 'lib/rx_nav/ndfrt.rb', line 8

def possible_options_for type
  get_options type.to_s.downcase
end

.possible_propertiesObject



24
25
26
# File 'lib/rx_nav/ndfrt.rb', line 24

def possible_properties
  get_options "property"
end

.possible_rolesObject



28
29
30
# File 'lib/rx_nav/ndfrt.rb', line 28

def possible_roles
  get_options "role"
end

.possible_typesObject



16
17
18
# File 'lib/rx_nav/ndfrt.rb', line 16

def possible_types
  get_options "type"
end