Class: HealthDataStandards::Util::VSApiV2

Inherits:
VSApi
  • Object
show all
Defined in:
lib/health-data-standards/util/vs_api.rb

Constant Summary collapse

DEFAULT_PROFILE =

This default profile is used when the include_draft option is true without a profile specified. The VSAC V2 API needs a profile to be specified when using includeDraft. Future work on this class could include a function to fetch the list of profiles from the vsac.nlm.nih.gov/vsac/profiles call.

"Most Recent CS Versions"

Instance Attribute Summary

Attributes inherited from VSApi

#api_url, #password, #ticket_url, #username

Instance Method Summary collapse

Methods inherited from VSApi

#get_proxy_ticket, get_tgt_using_credentials, #get_ticket, #proxy_ticket

Constructor Details

#initialize(ticket_url, api_url, username, password, ticket_granting_ticket = nil) ⇒ VSApiV2

Returns a new instance of VSApiV2.



62
63
64
# File 'lib/health-data-standards/util/vs_api.rb', line 62

def initialize(ticket_url, api_url, username, password, ticket_granting_ticket = nil)
  super(ticket_url, api_url, username, password, ticket_granting_ticket)
end

Instance Method Details

#get_valueset(oid, options = {}) {|oid, vs| ... } ⇒ Object

Yields:

  • (oid, vs)


66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/health-data-standards/util/vs_api.rb', line 66

def get_valueset(oid, options = {}, &block)
  version = options.fetch(:version, nil)
  include_draft = options.fetch(:include_draft, false)
  profile = options.fetch(:profile, nil)
  effective_date = options.fetch(:effective_date, nil)
  program_name = options.fetch(:program, nil)
  params = { id: oid, ticket: get_ticket }
  params[:version] = version if version
  params[:includeDraft] = 'yes' if profile && include_draft
  params[:profile] = profile if profile
  params[:effectiveDate] = effective_date if effective_date
  params[:programType] = program_name if program_name
  begin
    vs = RestClient.get(api_url, :params=>params)
  rescue RestClient::ResourceNotFound
    raise VSNotFoundError, "No ValueSet found for oid '#{oid}'"
  end
  yield oid, vs if block_given?
  vs
end

#process_valuesets(oids, options = {}, &block) ⇒ Object



87
88
89
90
91
92
93
94
# File 'lib/health-data-standards/util/vs_api.rb', line 87

def process_valuesets(oids, options = {}, &block)
  version = options.fetch(:version, nil)
  include_draft = options.fetch(:include_draft, false)
  oids.each do |oid|
    vs = get_valueset(oid, version: version, include_draft: include_draft)
    yield oid, vs
  end
end