Sha256: e7be3781268e33f917b02ce352acb252995d49dbe904740aa6e5716bd0fa60fa

Contents?: true

Size: 1.06 KB

Versions: 11

Compression:

Stored size: 1.06 KB

Contents

require 'rest_client'
require 'uri'
module HealthDataStandards
  module Util
		class VSApi			
			attr_accessor :api_url, :ticket_url,  :username, :password

			def initialize(ticket_url, api_url,username,password)
				@api_url = api_url
				@ticket_url = ticket_url
				@username = username
				@password = password
			end

			def get_valueset(oid,&block)
				vs = RestClient.get api_url, {:params=>{id: oid, ticket: get_ticket}}
				yield oid,vs if block_given?
				vs
			end

			def process_valuesets(oids, &block)
				oids.each do |oid|
		     		vs = get_valueset(oid)
		     		yield oid,vs
				end
			end

			def proxy_ticket
			 	@proxy_ticket ||= get_proxy_ticket
			end

			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
			
			def get_ticket
			  RestClient.post "#{ticket_url}/#{proxy_ticket}", {service: "http://umlsks.nlm.nih.gov"}
		  end
		end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
health-data-standards-3.0.6 lib/health-data-standards/util/vs_api.rb
health-data-standards-3.0.5 lib/health-data-standards/util/vs_api.rb
health-data-standards-3.0.4 lib/health-data-standards/util/vs_api.rb
health-data-standards-3.0.3 lib/health-data-standards/util/vs_api.rb
health-data-standards-2.2.1 lib/health-data-standards/util/vs_api.rb
health-data-standards-2.2.0 lib/health-data-standards/util/vs_api.rb
health-data-standards-2.1.4 lib/health-data-standards/util/vs_api.rb
health-data-standards-2.1.3 lib/health-data-standards/util/vs_api.rb
health-data-standards-2.1.2 lib/health-data-standards/util/vs_api.rb
health-data-standards-2.1.1 lib/health-data-standards/util/vs_api.rb
health-data-standards-2.1.0 lib/health-data-standards/util/vs_api.rb