Class: HealthDataStandards::Util::VSApi
- Inherits:
-
Object
- Object
- HealthDataStandards::Util::VSApi
- Defined in:
- lib/health-data-standards/util/vs_api.rb
Instance Attribute Summary collapse
-
#api_url ⇒ Object
Returns the value of attribute api_url.
-
#password ⇒ Object
Returns the value of attribute password.
-
#ticket_url ⇒ Object
Returns the value of attribute ticket_url.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #get_proxy_ticket ⇒ Object
- #get_ticket ⇒ Object
- #get_valueset(oid) {|oid, vs| ... } ⇒ Object
-
#initialize(ticket_url, api_url, username, password) ⇒ VSApi
constructor
A new instance of VSApi.
- #process_valuesets(oids, &block) ⇒ Object
- #proxy_ticket ⇒ Object
Constructor Details
#initialize(ticket_url, api_url, username, password) ⇒ VSApi
Returns a new instance of VSApi.
8 9 10 11 12 13 |
# File 'lib/health-data-standards/util/vs_api.rb', line 8 def initialize(ticket_url, api_url,username,password) @api_url = api_url @ticket_url = ticket_url @username = username @password = password end |
Instance Attribute Details
#api_url ⇒ Object
Returns the value of attribute api_url.
6 7 8 |
# File 'lib/health-data-standards/util/vs_api.rb', line 6 def api_url @api_url end |
#password ⇒ Object
Returns the value of attribute password.
6 7 8 |
# File 'lib/health-data-standards/util/vs_api.rb', line 6 def password @password end |
#ticket_url ⇒ Object
Returns the value of attribute ticket_url.
6 7 8 |
# File 'lib/health-data-standards/util/vs_api.rb', line 6 def ticket_url @ticket_url end |
#username ⇒ Object
Returns the value of attribute username.
6 7 8 |
# File 'lib/health-data-standards/util/vs_api.rb', line 6 def username @username end |
Instance Method Details
#get_proxy_ticket ⇒ Object
32 33 34 35 36 |
# File 'lib/health-data-standards/util/vs_api.rb', line 32 def get_proxy_ticket # the content type is set and the body is a string becuase the NLM service does not support urlencoded content and # throws an error on that contnet type RestClient.post ticket_url, {username: username, password: password} end |
#get_ticket ⇒ Object
38 39 40 |
# File 'lib/health-data-standards/util/vs_api.rb', line 38 def get_ticket RestClient.post "#{ticket_url}/#{proxy_ticket}", {service: "http://umlsks.nlm.nih.gov"} end |
#get_valueset(oid) {|oid, vs| ... } ⇒ Object
15 16 17 18 19 |
# File 'lib/health-data-standards/util/vs_api.rb', line 15 def get_valueset(oid,&block) vs = RestClient.get api_url, {:params=>{id: oid, ticket: get_ticket}} yield oid,vs if block_given? vs end |
#process_valuesets(oids, &block) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/health-data-standards/util/vs_api.rb', line 21 def process_valuesets(oids, &block) oids.each do |oid| vs = get_valueset(oid) yield oid,vs end end |
#proxy_ticket ⇒ Object
28 29 30 |
# File 'lib/health-data-standards/util/vs_api.rb', line 28 def proxy_ticket @proxy_ticket ||= get_proxy_ticket end |