Class: RxNav::RxNorm
- Inherits:
-
Object
- Object
- RxNav::RxNorm
- Defined in:
- lib/rx_nav/rx_norm.rb
Class Method Summary collapse
- .complete_info(id) ⇒ Object
- .find_rxcui_by_id(type, id) ⇒ Object
- .find_rxcui_by_name(name) ⇒ Object
- .properties(id) ⇒ Object
- .quantity(id) ⇒ Object
- .search_by_name(name, options = {}) ⇒ Object
- .spelling_suggestions(name) ⇒ Object
- .status(id) ⇒ Object
- .strength(id) ⇒ Object
Class Method Details
.complete_info(id) ⇒ Object
59 60 61 62 63 64 |
# File 'lib/rx_nav/rx_norm.rb', line 59 def complete_info id result = self.properties(id) result.strength = self.strength(id).strength result.quantity = self.quantity(id).quantity return result end |
.find_rxcui_by_id(type, id) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/rx_nav/rx_norm.rb', line 20 def find_rxcui_by_id type, id type = type.upcase id = id.to_s query = "/rxcui?idtype=#{type}&id=#{id}" return extract_rxcui query end |
.find_rxcui_by_name(name) ⇒ Object
27 28 29 30 |
# File 'lib/rx_nav/rx_norm.rb', line 27 def find_rxcui_by_name name query = "/rxcui?name=#{name}" return extract_rxcui query end |
.properties(id) ⇒ Object
44 45 46 47 |
# File 'lib/rx_nav/rx_norm.rb', line 44 def properties id query = "/rxcui/#{id}/properties" return OpenStruct.new get_response_hash(query)[:properties] end |
.quantity(id) ⇒ Object
49 50 51 52 |
# File 'lib/rx_nav/rx_norm.rb', line 49 def quantity id query = "/rxcui/#{id}/quantity" return OpenStruct.new get_response_hash(query)[:quantity_group] end |
.search_by_name(name, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/rx_nav/rx_norm.rb', line 5 def search_by_name name, = {} = {max_results: 20, options: 0}.merge() query = %Q(/approximateTerm?term=#{name}&maxEntries=#{options[:max_results]}&options=#{options[:options]}) # Get the data we care about in the right form data = get_response_hash(query)[:approximate_group][:candidate] data = [data] if (data && !data.is_a?(Array)) # If we didn't get anything, say so return nil if data.nil? return data.map { |c| RxNav::Concept.new(c) } end |
.spelling_suggestions(name) ⇒ Object
32 33 34 35 |
# File 'lib/rx_nav/rx_norm.rb', line 32 def spelling_suggestions name query = "/spellingsuggestions?name=#{name}" get_response_hash(query)[:suggestion_group][:suggestion_list][:suggestion] end |
.status(id) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/rx_nav/rx_norm.rb', line 37 def status id query = "/rxcui/#{id}/status" status = OpenStruct.new get_response_hash(query)[:rxcui_status] status.send("active?=", status.status == 'Active') return status end |
.strength(id) ⇒ Object
54 55 56 57 |
# File 'lib/rx_nav/rx_norm.rb', line 54 def strength id query = "/rxcui/#{id}/strength" return OpenStruct.new get_response_hash(query)[:strength_group] end |