rx_nav 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb4e475d76c23889b8562311f14a44dfbd8b2922
4
- data.tar.gz: e522d9a590ca890ca3b2f1aa0f89ad3eeba55e9f
3
+ metadata.gz: 28775ac88a7af9bdf70f04d10dd3d7f35848f2b7
4
+ data.tar.gz: 38f2c0a2c804905b4438cbcb160a5490ff70a969
5
5
  SHA512:
6
- metadata.gz: 796b5de96b725a354f1c2d8e223abb8f4095696908b15109fa08ae58da44da2a18e4ad365f752f0e6906b9400b88f0e88311dd790ac789bdd9fa7296bd4fc711
7
- data.tar.gz: 17db9257fa3aa69c526fdb923669c04b1b4b963081abe76d034e09124796dcfa96c02d6bb3ca95c84beaef915b09a4701fb308ddbd117582c665ef0d09737dcf
6
+ metadata.gz: d5273bc556ad65e44a1a406d992a17ad239e5ecd9a20e55a4f3ad24db9697cbf7fa00ec4f64d9bbecfad82123bf23b4449d041c66ff632d89ceeac9cf2c3bdc6
7
+ data.tar.gz: 9143f1a3ead0607d154cadde8bd71179c1955ad3fbaf6355e8338b6deaaad7b0266e88b83ee84e9ccce0e880f5a272dbb2c773d031ba9bcf8fbf0e1ecf8d5244
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # RxNav
2
2
 
3
- TODO: Write a gem description
3
+ [![Gem Version](https://badge.fury.io/rb/rx_nav.png)](http://badge.fury.io/rb/rx_nav) [![Code Climate](https://codeclimate.com/github/jbender/rx_nav_ruby.png)](https://codeclimate.com/github/jbender/rx_nav_ruby)
4
+
5
+ This gem makes it easier to work with the RxNav REST APIs, as enumerated on [this page](http://rxnav.nlm.nih.gov/APIsOverview.html).
6
+
7
+ Currently, there are wrappers for the [RxNorm](http://rxnav.nlm.nih.gov/RxNormAPIREST.html), [NDF-RT](http://rxnav.nlm.nih.gov/NdfrtAPIREST.html), and [RxTerms](http://rxnav.nlm.nih.gov/RxTermsAPIREST.html) APIs. Not all end points are covered, so be sure to check out the code to make sure the endpoint you're looking for is available in the wrapper. If it isn't, please feel free to fork, add it, and send a pull request.
4
8
 
5
9
  ## Installation
6
10
 
data/lib/rx_nav.rb CHANGED
@@ -4,13 +4,13 @@ require 'nokogiri'
4
4
  require 'ostruct'
5
5
 
6
6
  # Core of the API responses
7
- require 'rx_nav/concept'
8
- require 'rx_nav/interaction'
7
+ require_relative 'rx_nav/concept'
8
+ require_relative 'rx_nav/interaction'
9
9
 
10
10
  # Individual APIs
11
- require 'rx_nav/ndfrt'
12
- require 'rx_nav/rx_norm'
13
- require 'rx_nav/rx_terms'
11
+ require_relative 'rx_nav/ndfrt'
12
+ require_relative 'rx_nav/rx_norm'
13
+ require_relative 'rx_nav/rx_terms'
14
14
 
15
15
  module RxNav
16
16
 
@@ -4,7 +4,10 @@ module RxNav
4
4
  class Concept < OpenStruct
5
5
 
6
6
  def name
7
- name = self.concept_name
7
+ name = self.display_name ||
8
+ self.full_name ||
9
+ self.full_generic_name ||
10
+ self.concept_name
8
11
  name ? name.capitalize : nil
9
12
  end
10
13
 
@@ -14,7 +17,7 @@ module RxNav
14
17
  end
15
18
 
16
19
  def to_s
17
- display_name || full_name || full_generic_name || name
20
+ name
18
21
  end
19
22
 
20
23
  def get_terms_info
@@ -1,14 +1,20 @@
1
1
  module RxNav
2
2
  class RxNorm
3
3
  class << self
4
- def search_by_name name, max_results = 20, option = 0
5
- query = "/approximateTerm?term=#{name}&maxEntries=#{max_results}"
6
- # The API spec includes an option parameter, but doesn't specify options
7
- # other than the default
8
- # query += "&option=#{option}" if option
4
+
5
+ def search_by_name name, options = {}
6
+ options = {max_results: 20, options: 0}.merge(options)
7
+
8
+ query = %Q(/approximateTerm?term=#{name}&maxEntries=#{options[:max_results]}&options=#{options[:options]})
9
+
10
+ # Get the data we care about in the right form
9
11
  data = get_response_hash(query)[:approximate_group][:candidate]
10
12
  data = [data] if (data && !data.is_a?(Array))
11
- return data.nil? ? nil : data.map { |c| RxNav::Concept.new(c) }
13
+
14
+ # If we didn't get anything, say so
15
+ return nil if data.nil?
16
+
17
+ return data.map { |c| RxNav::Concept.new(c) }
12
18
  end
13
19
 
14
20
  def find_rxcui_by_id type, id
@@ -23,6 +29,18 @@ module RxNav
23
29
  return extract_rxcui query
24
30
  end
25
31
 
32
+ def spelling_suggestions name
33
+ query = "/spellingsuggestions?name=#{name}"
34
+ get_response_hash(query)[:suggestion_group][:suggestion_list][:suggestion]
35
+ end
36
+
37
+ def status id
38
+ query = "/rxcui/#{id}/status"
39
+ status = OpenStruct.new get_response_hash(query)[:rxcui_status]
40
+ status.send("active?=", status.status == 'Active')
41
+ return status
42
+ end
43
+
26
44
  def properties id
27
45
  query = "/rxcui/#{id}/properties"
28
46
  return OpenStruct.new get_response_hash(query)[:properties]
@@ -1,3 +1,3 @@
1
1
  module RxNav
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/rx_nav.gemspec CHANGED
@@ -18,7 +18,6 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency 'httparty'
22
21
  spec.add_dependency 'nori'
23
22
  spec.add_dependency 'nokogiri'
24
23
 
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rx_nav
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Bender
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-15 00:00:00.000000000 Z
11
+ date: 2013-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: httparty
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '>='
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '>='
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: nori
29
15
  requirement: !ruby/object:Gem::Requirement