Class: RedoxEngine::Client
- Inherits:
-
Object
- Object
- RedoxEngine::Client
- Includes:
- RequestHelpers
- Defined in:
- lib/redox-engine/client.rb
Overview
RedoxEngine API client
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#destinations ⇒ Object
readonly
Returns the value of attribute destinations.
-
#refresh_token ⇒ Object
readonly
Returns the value of attribute refresh_token.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#test ⇒ Object
readonly
Returns the value of attribute test.
Instance Method Summary collapse
-
#add_appointment(visit:, patient:) ⇒ Hash
Send Scheduling#New message.
-
#add_patient(patient_params) ⇒ Hash
Send PatientAdmin#NewPatient message.
-
#get_available_slots(visit:, patient: nil, start_time: nil, end_time: nil) ⇒ Hash
Send Scheduling#AvailableSlots message.
-
#get_booked_slots(visit:, patient: nil, start_time: nil, end_time: nil) ⇒ Hash
Send Scheduling#BookedSlots message.
-
#get_summary_for_patient(patient_params) ⇒ Hash
Send ClinicalSummary#PatientQuery message.
-
#initialize(source:, destinations:, test_mode: true, token: nil, refresh_token: nil) ⇒ Client
constructor
Instantiates a new RedoxEngine Client object.
-
#search_patient(patient_params) ⇒ Hash
Send PatientSearch#Query message.
-
#update_patient(patient_params) ⇒ Hash
Send PatientAdmin#PatientUpdate message.
Constructor Details
#initialize(source:, destinations:, test_mode: true, token: nil, refresh_token: nil) ⇒ Client
Instantiates a new RedoxEngine Client object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/redox-engine/client.rb', line 28 def initialize( source:, destinations:, test_mode: true, token: nil, refresh_token: nil ) if [RedoxEngine.api_key, RedoxEngine.secret].any?(&:nil?) raise APIKeyError end @refresh_token = refresh_token @access_token = token || fetch_access_token @source = source @destinations = destinations @test = test_mode end |
Instance Attribute Details
#access_token ⇒ Object (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 |
#destinations ⇒ Object (readonly)
Returns the value of attribute destinations.
6 7 8 |
# File 'lib/redox-engine/client.rb', line 6 def destinations @destinations end |
#refresh_token ⇒ Object (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 |
#response ⇒ Object (readonly)
Returns the value of attribute response.
6 7 8 |
# File 'lib/redox-engine/client.rb', line 6 def response @response end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
6 7 8 |
# File 'lib/redox-engine/client.rb', line 6 def source @source end |
#test ⇒ Object (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_appointment(visit:, patient:) ⇒ Hash
Send Scheduling#New message
)
202 203 204 205 206 207 208 209 210 |
# File 'lib/redox-engine/client.rb', line 202 def add_appointment(visit:, patient:) request_body = scheduling_query( query_data: { visit: visit, patient: patient }, type: 'New' ) handle_request( request_body, 'Error posting New Appointment.' ) end |
#add_patient(patient_params) ⇒ Hash
Send PatientAdmin#NewPatient message
57 58 59 60 61 62 63 |
# File 'lib/redox-engine/client.rb', line 57 def add_patient(patient_params) request_body = ( data_model: 'PatientAdmin', event_type: 'NewPatient' ).merge(Patient: patient_params.redoxify_keys) handle_request(request_body, 'Error in Patient New.') end |
#get_available_slots(visit:, patient: nil, start_time: nil, end_time: nil) ⇒ Hash
Send Scheduling#AvailableSlots message
NOTE: Endpoint not supported by all Health Systems, talk to your redox rep for more information )
179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/redox-engine/client.rb', line 179 def get_available_slots( visit:, patient: nil, start_time: nil, end_time: nil ) visit[:reasons] = ['-1'] request_body = scheduling_query( query_data: { visit: visit, patient: patient }, start_time: start_time, end_time: end_time, type: 'AvailableSlots' ) handle_request(request_body, 'Error fetching Available Slots.') end |
#get_booked_slots(visit:, patient: nil, start_time: nil, end_time: nil) ⇒ Hash
Send Scheduling#BookedSlots message
NOTE: Endpoint not supported by all Health Systems, talk to your redox rep for more information )
149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/redox-engine/client.rb', line 149 def get_booked_slots(visit:, patient: nil, start_time: nil, end_time: nil) request_body = scheduling_query( query_data: { visit: visit, patient: patient }, start_time: start_time, end_time: end_time, type: 'Booked' ) handle_request( request_body, 'Error fetching Booked Slots.' ) end |
#get_summary_for_patient(patient_params) ⇒ Hash
Send ClinicalSummary#PatientQuery message
121 122 123 124 125 126 127 128 129 130 |
# File 'lib/redox-engine/client.rb', line 121 def get_summary_for_patient(patient_params) request_body = ( 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
100 101 102 103 104 105 106 |
# File 'lib/redox-engine/client.rb', line 100 def search_patient(patient_params) request_body = ( 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
81 82 83 84 85 86 87 |
# File 'lib/redox-engine/client.rb', line 81 def update_patient(patient_params) request_body = ( data_model: 'PatientAdmin', event_type: 'PatientUpdate' ).merge(Patient: patient_params.redoxify_keys) handle_request(request_body, 'Error updating Patient.') end |