Class: Redox::Redox

Inherits:
Object
  • Object
show all
Defined in:
lib/redox.rb

Overview

Redox API client

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, secret:, source:, destinations:, facility_code: nil, test: true) ⇒ Redox

Instantiates a new Redox connection object

Examples:

redox = Redox::Redox.new(
  api_key: ENV['REDOX_KEY'],
  secret: ENV['REDOX_SECRET'],
  source: source,
  destinations: destinations,
  test: true
)

Parameters:

  • api_key (String)

    API key for the connection

  • secret (String)

    API secret for the connection

  • source (Hash)

    source information

  • destinations (Array<Hash>)

    list of destinations

  • test (Boolean) (defaults to: true)

    whether to use test mode



24
25
26
27
28
29
30
31
# File 'lib/redox.rb', line 24

def initialize(api_key:, secret:, source:, destinations:, facility_code: nil, test: true)
  @api_key = api_key
  @secret = secret
  @source = source
  @destinations = destinations
  @facility_code = facility_code
  @test = test
end

Instance Method Details

#add_patient(patient_params) ⇒ Hash

Send NewPatient message

Examples:

Redox::Redox.new(*connection_params).add_patient(
  Identifiers: [],
  Demographics: {
    FirstName: 'Joe'
  }
)

Parameters:

  • patient_params (Hash)

    data to send in the Patient JSON object

Returns:

  • (Hash)

    parsed response object



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/redox.rb', line 44

def add_patient(patient_params)
  patient_request = Net::HTTP::Post.new('/endpoint', auth_header)
  request_body = request_meta(
    data_model: 'PatientAdmin', event_type: 'NewPatient'
  ).merge(Patient: patient_params)
  patient_request.body = request_body.to_json

  response = connection.request(patient_request)

  JSON.parse(response.body)
end

#update_patient(patient_params) ⇒ Hash

Send PatientUpdate message

Examples:

Redox::Redox.new(*connection_params).update_patient(
  Identifiers: [],
  Demographics: {
    FirstName: 'Joe'
  }
)

Parameters:

  • patient_params (Hash)

    data to send in the Patient JSON object

Returns:

  • (Hash)

    parsed response object



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/redox.rb', line 67

def update_patient(patient_params)
  patient_request = Net::HTTP::Post.new('/endpoint', auth_header)
  request_body = request_meta(
    data_model: 'PatientAdmin', event_type: 'PatientUpdate'
  ).merge(Patient: patient_params)
  patient_request.body = request_body.to_json

  response = connection.request(patient_request)

  JSON.parse(response.body)
end