Class: RedoxEngine::Client

Inherits:
Object
  • Object
show all
Includes:
RequestHelpers
Defined in:
lib/redox-engine/client.rb

Overview

RedoxEngine API client

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source:, destinations:, test_mode: true, token: nil, refresh_token: nil) ⇒ Client

Instantiates a new RedoxEngine Client object

Examples:

redox = RedoxEngine::Client.new(
  source: source,
  destinations: destinations,
  test_mode: true,
  OPTIONAL: (If tokens/refresh_tokens are being persisted elsewhere)
  token: (existing access token),
  refresh_token: (existing refresh token)
)

Parameters:

  • source (Hash)

    source information

  • destinations (Array<Hash>)

    list of destinations

  • test_mode (Boolean) (defaults to: true)

    whether to use test mode

  • access_token (String)

    Optional param to provide an existing Access Token

  • refresh_token (String) (defaults to: nil)

    Optional param to provide an existing Refresh Token

Raises:



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/redox-engine/client.rb', line 28

def initialize(
  source:, destinations:, test_mode: true, token: nil, refresh_token: nil
)
  raise APIKeyError if [RedoxEngine.api_key, RedoxEngine.secret].any?(&:nil?)
  @refresh_token = refresh_token
  @access_token = token || fetch_access_token

  @source = source
  @destinations = destinations
  @test = test_mode
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



6
7
8
# File 'lib/redox-engine/client.rb', line 6

def access_token
  @access_token
end

#destinationsObject (readonly)

Returns the value of attribute destinations.



6
7
8
# File 'lib/redox-engine/client.rb', line 6

def destinations
  @destinations
end

#refresh_tokenObject (readonly)

Returns the value of attribute refresh_token.



6
7
8
# File 'lib/redox-engine/client.rb', line 6

def refresh_token
  @refresh_token
end

#responseObject (readonly)

Returns the value of attribute response.



6
7
8
# File 'lib/redox-engine/client.rb', line 6

def response
  @response
end

#sourceObject (readonly)

Returns the value of attribute source.



6
7
8
# File 'lib/redox-engine/client.rb', line 6

def source
  @source
end

#testObject (readonly)

Returns the value of attribute test.



6
7
8
# File 'lib/redox-engine/client.rb', line 6

def test
  @test
end

Instance Method Details

#add_patient(patient_params) ⇒ Hash

Send PatientAdmin#NewPatient message

Examples:

RedoxEngine::Client.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



51
52
53
54
55
56
57
# File 'lib/redox-engine/client.rb', line 51

def add_patient(patient_params)
  request_body = request_meta(
    data_model: 'PatientAdmin',
    event_type: 'NewPatient'
  ).merge(Patient: patient_params.redoxify_keys)
  handle_request(request_body, 'Error in Patient New.')
end

#get_booked_slots(visit:, start_time: nil, end_time: nil) ⇒ Hash

Send Scheduling#BookedSlots message

)

Examples:

RedoxEngine::Client.new(*connection_params).get_booked_slots(
  visit: {
    reason?: string
    attending_providers: Provider[]
    location: {
      type: string
      facility: string
      department: string | number
      room: string | number
    }
  }
 start_time?: Time | String (ISO-8601 Time String)
 end_time?: Time | String (ISO-8601 Time String)

Parameters:

  • visit (Hash)

    data to send in the Visit JSON object

  • start_time (String|Time) (defaults to: nil)

    datetime to search from

Returns:

  • (Hash)

    parsed response object



142
143
144
145
146
147
148
149
150
151
152
# File 'lib/redox-engine/client.rb', line 142

def get_booked_slots(visit:, start_time: nil, end_time: nil)
  request_body = scheduling_query(
    visit: visit,
    start_time: start_time,
    end_time: end_time
  )
  handle_request(
    request_body,
    'Error fetching Booked Slots'
  )
end

#get_summary_for_patient(patient_params) ⇒ Hash

Send ClinicalSummary#PatientQuery message

Examples:

RedoxEngine::Client.new(*connection_params).search_patient(
  identifiers: [
    {
      id: '4681'
      id_type: 'AthenaNet Enterprise ID'
    }
  ]
)

Parameters:

  • patient_params (Hash)

    data to send in the Patient JSON object

Returns:

  • (Hash)

    parsed response object



110
111
112
113
114
115
116
117
118
119
# File 'lib/redox-engine/client.rb', line 110

def get_summary_for_patient(patient_params)
  request_body = request_meta(
    data_model: 'Clinical Summary',
    event_type: 'PatientQuery'
  ).merge(Patient: patient_params.redoxify_keys)
  handle_request(
    request_body,
    'Error fetching Patient Clinical Summary'
  )
end

#search_patient(patient_params) ⇒ Hash

Send PatientSearch#Query message

Examples:

RedoxEngine::Client.new(*connection_params).search_patient(
  demographics: {
    FirstName: 'Joe'
    ...
  }
)

Parameters:

  • patient_params (Hash)

    data to send in the Patient JSON object

Returns:

  • (Hash)

    parsed response object



89
90
91
92
93
94
95
# File 'lib/redox-engine/client.rb', line 89

def search_patient(patient_params)
  request_body = request_meta(
    data_model: 'PatientSearch',
    event_type: 'Query'
  ).merge(Patient: patient_params.redoxify_keys)
  handle_request(request_body, 'Error in Patient Search.')
end

#update_patient(patient_params) ⇒ Hash

Send PatientAdmin#PatientUpdate message

Examples:

RedoxEngine::Client.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



70
71
72
73
74
75
76
# File 'lib/redox-engine/client.rb', line 70

def update_patient(patient_params)
  request_body = request_meta(
    data_model: 'PatientAdmin',
    event_type: 'PatientUpdate'
  ).merge(Patient: patient_params.redoxify_keys)
  handle_request(request_body, 'Error updating Patient.')
end