Class: ChangeHealth::Request::TradingPartner

Inherits:
Hashie::Trash
  • Object
show all
Defined in:
lib/change_health/request/trading_partner.rb

Constant Summary collapse

ENDPOINT =
'/medicalnetwork/payerfinder/v1/payers'.freeze

Class Method Summary collapse

Class Method Details

.query(term, service_name: 'Eligibility', clearing_house: 'npd') ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/change_health/request/trading_partner.rb', line 6

def self.query(term, service_name: 'Eligibility', clearing_house: 'npd')
  params = {
    businessName: term,
    serviceName: service_name,
    clearingHouse: clearing_house
  }

  response = ChangeHealth::Connection.new.request(endpoint: ENDPOINT, verb: :get, query: params)
  trading_partners_data = ChangeHealth::Response::TradingPartnersData.new(response['payers'])
  trading_partners_data.map { |partner| ChangeHealth::Models::TradingPartner.new(name: partner.name, alias: partner.alias, line_of_business: partner.line_of_business, plan_type: partner.plan_type, service_id: partner.service_id )}
end