Class: RxNav::NDFRT
- Inherits:
-
Object
- Object
- RxNav::NDFRT
- Defined in:
- lib/rx_nav/ndfrt.rb
Class Method Summary collapse
- .all_records_by_kind(kind) ⇒ Object
- .api_version ⇒ Object
- .find_by(hash) ⇒ Object
- .find_by_id(type, id) ⇒ Object
- .find_by_name(name, kind = nil) ⇒ Object
-
.get_info(nui, concept = nil) ⇒ Object
PLEASE NOTE: These methods were deprecated in the Sept 2014 release of ND-FRT.
- .possible_associations ⇒ Object
- .possible_kinds ⇒ Object
- .possible_options_for(type) ⇒ Object
- .possible_properties ⇒ Object
- .possible_roles ⇒ Object
- .possible_types ⇒ Object
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_version ⇒ Object
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_associations ⇒ Object
12 13 14 |
# File 'lib/rx_nav/ndfrt.rb', line 12 def possible_associations "association" end |
.possible_kinds ⇒ Object
20 21 22 |
# File 'lib/rx_nav/ndfrt.rb', line 20 def possible_kinds ("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 type type.to_s.downcase end |
.possible_properties ⇒ Object
24 25 26 |
# File 'lib/rx_nav/ndfrt.rb', line 24 def possible_properties "property" end |
.possible_roles ⇒ Object
28 29 30 |
# File 'lib/rx_nav/ndfrt.rb', line 28 def possible_roles "role" end |
.possible_types ⇒ Object
16 17 18 |
# File 'lib/rx_nav/ndfrt.rb', line 16 def possible_types "type" end |