class HealthDataStandards::Util::VSApi

Attributes

api_url[RW]
password[RW]
ticket_url[RW]
username[RW]

Public Class Methods

get_tgt_using_credentials(username, password, ticket_url) click to toggle source
# File lib/health-data-standards/util/vs_api.rb, line 49
def self.get_tgt_using_credentials(username, password, ticket_url)
  RestClient.post(ticket_url, username: username, password: password)
end
new(ticket_url, api_url, username, password, ticket_granting_ticket = nil) click to toggle source
# File lib/health-data-standards/util/vs_api.rb, line 11
def initialize(ticket_url, api_url, username, password, ticket_granting_ticket = nil)
  @api_url = api_url
  @ticket_url = ticket_url
  @username = username
  @password = password
  @proxy_ticket = ticket_granting_ticket
end

Public Instance Methods

get_proxy_ticket() click to toggle source
# File lib/health-data-standards/util/vs_api.rb, line 39
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() click to toggle source
# File lib/health-data-standards/util/vs_api.rb, line 45
def get_ticket
  RestClient.post("#{ticket_url}/#{proxy_ticket}", service: "http://umlsks.nlm.nih.gov")
end
get_valueset(oid, effective_date = nil, include_draft = false) { |oid, vs| ... } click to toggle source
# File lib/health-data-standards/util/vs_api.rb, line 19
def get_valueset(oid, effective_date = nil, include_draft = false, &block)
  params = { id: oid, ticket: get_ticket }
  params[:effectiveDate] = effective_date if effective_date
  params[:includeDraft] = 'yes' if include_draft
  vs = RestClient.get(api_url, params: params)
  yield oid, vs if block_given?
  vs
end
process_valuesets(oids, effective_date = nil) { |oid,vs| ... } click to toggle source
# File lib/health-data-standards/util/vs_api.rb, line 28
def process_valuesets(oids, effective_date = nil, &block)
  oids.each do |oid|
    vs = get_valueset(oid,effective_date)
    yield oid,vs
  end
end
proxy_ticket() click to toggle source
# File lib/health-data-standards/util/vs_api.rb, line 35
def proxy_ticket
  @proxy_ticket ||= get_proxy_ticket
end