Class: Unityapi::UnityClient

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, pass, app, path_to_wsdl, proxy = nil) ⇒ UnityClient

Returns a new instance of UnityClient.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/unityapi/unity_client.rb', line 5

def initialize(user, pass, app, path_to_wsdl, proxy = nil)
  @user = user
  @pass = pass
  @app = app
  Savon.configure do |config|
    config.env_namespace = :soap
    config.log = false
    config.pretty_print_xml = true
    HTTPI.log = false
  end
  @client = Savon.client do |wsdl, http|
    wsdl.document = path_to_wsdl
    if proxy
      http.proxy = proxy
    end
  end
  @security_token = get_security_token(user, pass)
end

Instance Attribute Details

#appObject

Returns the value of attribute app.



4
5
6
# File 'lib/unityapi/unity_client.rb', line 4

def app
  @app
end

#clientObject

Returns the value of attribute client.



4
5
6
# File 'lib/unityapi/unity_client.rb', line 4

def client
  @client
end

#passObject

Returns the value of attribute pass.



4
5
6
# File 'lib/unityapi/unity_client.rb', line 4

def pass
  @pass
end

#proxyObject

Returns the value of attribute proxy.



4
5
6
# File 'lib/unityapi/unity_client.rb', line 4

def proxy
  @proxy
end

#security_tokenObject

Returns the value of attribute security_token.



4
5
6
# File 'lib/unityapi/unity_client.rb', line 4

def security_token
  @security_token
end

#userObject

Returns the value of attribute user.



4
5
6
# File 'lib/unityapi/unity_client.rb', line 4

def user
  @user
end

Instance Method Details

#closeObject



24
25
26
27
28
29
# File 'lib/unityapi/unity_client.rb', line 24

def close
  response = self.client.request("RetireSecurityToken", xmlns: "http://www.allscripts.com/Unity") do
    http.headers = {"Accept-Encoding" => "gzip, deflate", "SOAPAction" => "http://www.allscripts.com/Unity/IUnityService/RetireSecurityToken", "Content-Type" =>  "text/xml; charset=UTF-8"}
    soap.body = {"Token" => self.security_token, "Appname" => self.app}
  end    
end

#commit_charges(user_id, encounter_id, side_de) ⇒ Object



72
73
74
75
# File 'lib/unityapi/unity_client.rb', line 72

def commit_charges(user_id, encounter_id, side_de)
  response = magic_action("CommitCharges", user_id, patient_id, encounter_id, site_de)
  return response.body[:magic_response][:magic_result][:diffgram][:commitchargesresponse][:commitchargesinfo]
end

#echo(user_id, patient_id = "", param_1 = nil, param_2 = nil, param_3 = nil, param_4 = nil, param_5 = nil, param_6 = nil) ⇒ Object



77
78
79
80
# File 'lib/unityapi/unity_client.rb', line 77

def echo(user_id, patient_id="", param_1=nil, param_2=nil, param_3=nil, param_4=nil, param_5=nil, param_6=nil)
  response = magic_action("Echo", user_id, patient_id, param_1, param_2, param_3, param_4, param_5, param_6)
  return response.body[:magic_response][:magic_result][:diffgram][:echoresponse][:echoinformation]
end

#get_accountObject



82
83
84
85
# File 'lib/unityapi/unity_client.rb', line 82

def 
  response = magic_action("GetAccount")
  return response.body[:magic_response][:magic_result][:diffgram][:getaccountresponse][:getaccountinfo]
end

#get_changed_patients(start_time = nil) ⇒ Object



87
88
89
90
# File 'lib/unityapi/unity_client.rb', line 87

def get_changed_patients(start_time=nil)
  response = magic_action("GetChangedPatients", nil, nil, start_time)
  return response.body[:magic_response][:magic_result][:diffgram][:getchangedpatientsresponse][:getchangedpatientsinfo].map(&:patientid)
end

#get_charge_info_by_username(user_id, username_filter = nil) ⇒ Object



92
93
94
95
# File 'lib/unityapi/unity_client.rb', line 92

def get_charge_info_by_username(user_id, username_filter=nil)
  response = magic_action("GetChargeInfoByUsername", user_id, nil, username_filter)
  return response.body[:magic_response][:magic_result][:diffgram][:getchargeinfobyusernameresponse][:getchargeinfobyusernameinfo]
end

#get_charges(user_id, encounter_id = nil) ⇒ Object



97
98
99
100
# File 'lib/unityapi/unity_client.rb', line 97

def get_charges(user_id, encounter_id=nil)
  response = magic_action("GetCharges", user_id, nil, encounter_id)
  return response.body[:magic_response][:magic_result][:diffgram][:getchargesresponse][:getchargesinfo]
end

#get_delegates(user_id) ⇒ Object



102
103
104
105
# File 'lib/unityapi/unity_client.rb', line 102

def get_delegates(user_id)
  response = magic_action("GetDelegates", user_id)
  return response.body[:magic_response][:magic_result][:diffgram][:getdelegatesresponse][:getdelegatesinfo]
end

#get_dictionary(user_id, dictionary_name, site = nil) ⇒ Object



107
108
109
110
# File 'lib/unityapi/unity_client.rb', line 107

def get_dictionary(user_id, dictionary_name, site=nil)
  response = magic_action("GetDictionary", user_id, nil, dictionary_name, site)
  return response.body[:magic_response][:magic_result][:diffgram][:getdictionaryresponse][:getdictionaryinfo]
end

#get_dictionary_sets(group_name, dictionary_set_name) ⇒ Object



112
113
114
115
# File 'lib/unityapi/unity_client.rb', line 112

def get_dictionary_sets(group_name, dictionary_set_name)
  response = magic_action("GetDictionarySets", nil, nil, group_name, dictionary_set_name)
  return response.body[:magic_response][:magic_result][:diffgram][:getdictionarysetsresponse][:getdictionarysetsinfo]
end

#get_doc_template(user_id, section, template) ⇒ Object



117
118
119
120
# File 'lib/unityapi/unity_client.rb', line 117

def get_doc_template(user_id, section, template)
  response = magic_action("GetDocTemplate", user_id, nil, section, template)
  return response.body[:magic_response][:magic_result][:diffgram][:getdoctemplateresponse][:getdoctemplateinfo]
end

#get_document_by_accession(patient_id = nil, accession_num) ⇒ Object



122
123
124
125
# File 'lib/unityapi/unity_client.rb', line 122

def get_document_by_accession(patient_id=nil, accession_num)
  response = magic_action("GetDocumentByAccession", nil, patient_id, accession_num)
  return response.body[:magic_response][:magic_result][:diffgram][:getdocumentbyaccensionresponse][:getdocumentbyaccensioninfo]
end

#get_document_image(user_id, patient_id = nil, document_id) ⇒ Object



127
128
129
130
# File 'lib/unityapi/unity_client.rb', line 127

def get_document_image(user_id, patient_id=nil, document_id)
  response = magic_action("GetDocumentImage", user_id, patient_id, document_id)
  return response.body[:magic_response][:magic_result][:diffgram][:getdocumentimageresponse][:getdocumentimageinfo]
end

#get_document_type(doc_type = nil) ⇒ Object

could be “Chart”, “Consult”, “SpecReport”, “ChartCopy” or nil



137
138
139
140
# File 'lib/unityapi/unity_client.rb', line 137

def get_document_type(doc_type=nil)#could be "Chart", "Consult", "SpecReport", "ChartCopy" or nil
  response = magic_action("GetDocumentType", nil, nil, doc_type)
  return response.body[:magic_response][:magic_result][:diffgram][:getdocumenttyperesponse][:getdocumenttypeinfo]
end

#get_documents(user_id, patient_id, document_id, document_type = nil, start_date = nil, end_date = nil) ⇒ Object



132
133
134
135
# File 'lib/unityapi/unity_client.rb', line 132

def get_documents(user_id, patient_id, document_id, document_type=nil, start_date=nil, end_date=nil)
  response = magic_action("GetDocuments", user_id, patient_id, start_date, end_date, document_id, document_type)
  return response.body[:magic_response][:magic_result][:diffgram][:getdocumentsresponse][:getdocumentsinfo]
end

#get_dur(user_id, patient_id, dur_type, client_id, rx_data) ⇒ Object



142
143
144
145
# File 'lib/unityapi/unity_client.rb', line 142

def get_dur(user_id, patient_id, dur_type, client_id, rx_data)
  response = magic_action("GetDUR", user_id, patient_id, dur_type, client_id, rx_data)
  return response.body[:magic_response][:magic_result][:diffgram][:getdurresponse][:getdurinfo]
end

#get_encounter(user_id, patient_id, encounter_type, encounter_time, force_new_encounter, match_provider_flag) ⇒ Object



147
148
149
150
# File 'lib/unityapi/unity_client.rb', line 147

def get_encounter(user_id, patient_id, encounter_type, encounter_time, force_new_encounter, match_provider_flag)
  response = magic_action("GetEncounter", user_id, patient_id, encounter_type, encounter_time, force_new_encounter, match_provider_flag)
  return response.body[:magic_response][:magic_result][:diffgram][:getencounterresponse][:getencounterinfo]
end

#get_encounter_date(patient_id, encounter_id) ⇒ Object



152
153
154
155
# File 'lib/unityapi/unity_client.rb', line 152

def get_encounter_date(patient_id, encounter_id)
  response = magic_action("GetEncounterDate", nil, patient_id, encounter_id)
  return response.body[:magic_response][:magic_result][:diffgram][:getencounterdateresponse][:getencounterdateinfo]
end

#get_encounter_list(user_id, patient_id, encounter_type, date, future_days, show_previous_encounters, billing_provider) ⇒ Object



157
158
159
160
# File 'lib/unityapi/unity_client.rb', line 157

def get_encounter_list(user_id, patient_id, encounter_type, date, future_days, show_previous_encounters, billing_provider)
  response = magic_action("GetEncounterList", user_id, patient_id, encounter_type, date, future_days, show_previous_encounters, billing_provider)
  return response.body[:magic_response][:magic_result][:diffgram][:getencounterlistresponse][:getencounterlistinfo]
end

#get_hie_document(patient_id) ⇒ Object



162
163
164
165
# File 'lib/unityapi/unity_client.rb', line 162

def get_hie_document(patient_id)
  response = magic_action("GetHIEDocument", nil, patient_id)
  return response.body[:magic_response][:magic_result][:diffgram][:gethiedocumentresponse][:gethiedocumentinfo]
end

#get_last_patientObject



167
168
169
170
# File 'lib/unityapi/unity_client.rb', line 167

def get_last_patient
  response = magic_action("GetLastPatient")
  return response.body[:magic_response][:magic_result][:diffgram][:getlastpatientresponse][:getlastpatientinfo]
end

#get_list_of_dictionariesObject



172
173
174
175
# File 'lib/unityapi/unity_client.rb', line 172

def get_list_of_dictionaries
  response = magic_action("GetListOfDictionaries")
  return response.body[:magic_response][:magic_result][:diffgram][:getlistofdictionariesresponse][:getlistofdictionariesinfo]
end

#get_medication_by_trans_id(user_id, patient_id, trans_id) ⇒ Object



177
178
179
180
# File 'lib/unityapi/unity_client.rb', line 177

def get_medication_by_trans_id(user_id, patient_id, trans_id)
  response = magic_action("GetMedicationByTransID", user_id, patient_id, trans_id)
  return response.body[:magic_response][:magic_result][:diffgram][:getmedicationbytransidresponse][:getmedicationbytransidinfo]      
end

#get_order_history(user_id, item_id) ⇒ Object



182
183
184
185
# File 'lib/unityapi/unity_client.rb', line 182

def get_order_history(user_id, item_id)
  response = magic_action("GetOrderHistory", user_id, nil, item_id)
  return response.body[:magic_response][:magic_result][:diffgram][:getorderhistoryresponse][:getorderhistoryinfo]
end

#get_organization_idObject



187
188
189
190
# File 'lib/unityapi/unity_client.rb', line 187

def get_organization_id
  response = magic_action("GetOrganizationID")
  return response.body[:magic_response][:magic_result][:diffgram][:getorganizationidresponse][:getorganizationidinfo]
end

#get_packages(user_id, org_name) ⇒ Object



192
193
194
195
# File 'lib/unityapi/unity_client.rb', line 192

def get_packages(user_id, org_name)
  response = magic_action("GetPackages", user_id, nil, org_name)
  return response.body[:magic_response][:magic_result][:diffgram][:getpackagesresponse][:getpackagesinfo]
end

#get_patient(user_id, patient_id, include_pic = nil) ⇒ Object



197
198
199
200
# File 'lib/unityapi/unity_client.rb', line 197

def get_patient(user_id, patient_id, include_pic=nil)
  response = magic_action("GetPatient", user_id, patient_id, include_pic)
  return response.body[:magic_response][:magic_result][:diffgram][:getpatientresponse][:getpatientinfo]
end

#get_patient_activity(user_id, patient_id) ⇒ Object



202
203
204
205
206
207
208
# File 'lib/unityapi/unity_client.rb', line 202

def get_patient_activity(user_id, patient_id)
   response = magic_action("GetPatientActivity", user_id, patient_id)
   rootobj = response.body[:magic_response][:magic_result][:diffgram][:getpatientactivityresponse]
   return {:encounters => rootobj[:getpatientactivityinfo], :problems => rootobj[:getpatientactivityinfo2], 
     :vitals => rootobj[:getpatientactivityinfo3], :results => rootobj[:getpatientactivityinfo4], 
     :orders =>  rootobj[:getpatientactivityinfo5], :procedures => rootobj[:getpatientactivityinfo6]}
end

#get_patient_by_mrn(user_id, mrn) ⇒ Object



210
211
212
213
# File 'lib/unityapi/unity_client.rb', line 210

def get_patient_by_mrn(user_id, mrn)
  response = magic_action("GetPatientByMRN", user_id, nil, mrn)
  return response.body[:magic_response][:magic_result][:diffgram][:getpatientbymrnresponse][:getpatientbymrninfo]
end

#get_patient_cda(patient_id, organization_id = nil, appgroup = nil) ⇒ Object



214
215
216
217
# File 'lib/unityapi/unity_client.rb', line 214

def get_patient_cda(patient_id, organization_id=nil, appgroup=nil)
  response = magic_action("GetPatientCDA", nil, patient_id, organization_id, appgroup)
  return response.body[:magic_response][:magic_result][:diffgram][:getpatientcdaresponse][:getpatientcdainfo]
end

#get_patient_diagnosis(user_id, patient_id, encounter_date, encounter_type_mnemonic, encounter_date_rage, encounter_id) ⇒ Object



219
220
221
222
# File 'lib/unityapi/unity_client.rb', line 219

def get_patient_diagnosis(user_id, patient_id, encounter_date, encounter_type_mnemonic, encounter_date_rage, encounter_id)
  response = magic_action("GetPatientDiagnosis", user_id, patient_id, encounter_date, encounter_type_mnemonic, encounter_date_rage, encounter_id)
  return response.body[:magic_response][:magic_result][:diffgram][:getpatientdiagnosisresponse][:getpatientdiagnosisinfo]
end

#get_patient_full(patient_id, mrn, org_id, order_id) ⇒ Object



224
225
226
227
# File 'lib/unityapi/unity_client.rb', line 224

def get_patient_full(patient_id, mrn, org_id, order_id)
  response = magic_action("GetPatientFull", nil, patient_id, mrn, org_id, order_id)
  return response.body[:magic_response][:magic_result][:diffgram][:getpatientfullresponse][:getpatientfullinfo]
end

#get_patient_ids(patient_id) ⇒ Object



229
230
231
232
# File 'lib/unityapi/unity_client.rb', line 229

def get_patient_ids(patient_id)
  response = magic_action("GetPatientIDs", nil, patient_id)
  return response.body[:magic_response][:magic_result][:diffgram][:getpatientidsresponse][:getpatientidsinfo]
end

#get_patient_list(location_code, appt_date) ⇒ Object



234
235
236
237
# File 'lib/unityapi/unity_client.rb', line 234

def get_patient_list(location_code, appt_date)
  response = magic_action("GetPatientList", nil, nil, location_code, appt_date)
  return response.body[:magic_response][:magic_result][:diffgram][:getpatientlistresponse][:getpatientlistinfo]
end

#get_patient_locations(user_id, user_xml = nil) ⇒ Object

user_xml needs to be better defined and broken down into true params



239
240
241
242
# File 'lib/unityapi/unity_client.rb', line 239

def get_patient_locations(user_id, user_xml=nil) #user_xml needs to be better defined and broken down into true params
  response = magic_action("GetPatientLocations", user_id, nil, user_xml)
  return response.body[:magic_response][:magic_result][:diffgram][:getpatientlocationsresponse][:getpatientlocationsinfo]
end

#get_patient_pharmacies(user_id, patient_id) ⇒ Object



243
244
245
246
# File 'lib/unityapi/unity_client.rb', line 243

def get_patient_pharmacies(user_id, patient_id)
  response = magic_action("GetPatientPharmacies", user_id, patient_id)
  return response.body[:magic_response][:magic_result][:diffgram][:getpatientpharmaciesresponse][:getpatientpharmaciesinfo]
end

#get_patient_problems(patient_id, show_by_encounter_flag = nil, assessed = nil, encounter_id = nil, medcin_id = nil) ⇒ Object



248
249
250
251
# File 'lib/unityapi/unity_client.rb', line 248

def get_patient_problems(patient_id, show_by_encounter_flag=nil, assessed=nil, encounter_id=nil, medcin_id=nil)
  response = magic_action("GetPatientProblems", nil, patient_id, show_by_encounter_flag, assessed, encounter_id, medcin_id)
  return response.body[:magic_response][:magic_result][:diffgram][:getpatientproblemsresponse][:getpatientproblemsinfo]
end

#get_patient_sections(user_id, patient_id, months) ⇒ Object



258
259
260
261
# File 'lib/unityapi/unity_client.rb', line 258

def get_patient_sections(user_id, patient_id, months)
  response = magic_action("GetPatientSections", user_id, patient_id, months)
  return response.body[:magic_response][:magic_result][:diffgram][:getpatientsectionsresponse][:getpatientsectionsinfo]
end

#get_patients_by_icd9(icd_9, start_date, end_date) ⇒ Object



253
254
255
256
# File 'lib/unityapi/unity_client.rb', line 253

def get_patients_by_icd9(icd_9, start_date, end_date)
  response = magic_action("GetPatientsByICD9", nil, nil, icd_9, start_date, end_date)
  return response.body[:magic_response][:magic_result][:diffgram][:getpatientsbyicd9response][:getpatientsbyicd9info]
end

#get_provider(provider_id, user_name) ⇒ Object



263
264
265
266
# File 'lib/unityapi/unity_client.rb', line 263

def get_provider(provider_id, user_name)
  response = magic_action("GetProvider", self.user, nil, provider_id, user_name)
  return response.body[:magic_response][:magic_result][:diffgram][:getproviderresponse][:getproviderinfo]
end

#get_providers(security_filter = nil, name_filter = nil) ⇒ Object



268
269
270
271
# File 'lib/unityapi/unity_client.rb', line 268

def get_providers(security_filter=nil, name_filter=nil)
  response = magic_action("GetProviders")
  return response.body[:magic_response][:magic_result][:diffgram][:getprovidersresponse][:getprovidersinfo]
end

#get_ref_providers_by_specialty(user_id, search) ⇒ Object



273
274
275
276
# File 'lib/unityapi/unity_client.rb', line 273

def get_ref_providers_by_specialty(user_id, search)
  response = magic_action("GetRefProvidersBySpecialty", user_id, nil, search)
  return response.body[:magic_response][:magic_result][:diffgram][:getrefprovidersbyspecialtyresponse][:getrefprovidersbyspecialtyinfo]
end

#get_rounding_list_entries(user_id, patient_list_id, sort_field, sort_order, org_id, timezone_offset) ⇒ Object



278
279
280
281
# File 'lib/unityapi/unity_client.rb', line 278

def get_rounding_list_entries(user_id, patient_list_id, sort_field, sort_order, org_id, timezone_offset)
  response = magic_action("GetRoundingListEntries", user_id, nil, patient_list_id, sort_field, sort_order, org_id, timezone_offset)
  return response.body[:magic_response][:magic_result][:diffgram][:getroundinglistentriesresponse][:getroundinglistentriesinfo]
end

#get_rounding_lists(user_id, org_id) ⇒ Object



283
284
285
286
# File 'lib/unityapi/unity_client.rb', line 283

def get_rounding_lists(user_id, org_id)
  response = magic_action("GetRoundingLists", user_id, nil, org_id)
  return response.body[:magic_response][:magic_result][:diffgram][:getroundinglistsresponse][:getroundinglistsinfo]
end

#get_rx_favs(user_id, patient_id) ⇒ Object



288
289
290
291
# File 'lib/unityapi/unity_client.rb', line 288

def get_rx_favs(user_id, patient_id)
  response = magic_action("GetRXFavs", user_id, patient_id)
  return response.body[:magic_response][:magic_result][:diffgram][:getrxfavsresponse][:getrxfavsinfo]
end

#get_schedule(date) ⇒ Object



293
294
295
296
# File 'lib/unityapi/unity_client.rb', line 293

def get_schedule(date)
  response = magic_action("GetSchedule", user_id, nil, date)
  return response.body[:magic_response][:magic_result][:diffgram][:scheduleresponse][:scheduleinfo]
end

#get_security_token(user, pass) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/unityapi/unity_client.rb', line 31

def get_security_token(user, pass)
  response = self.client.request("GetSecurityToken", xmlns: "http://www.allscripts.com/Unity") do
    http.headers = {"Accept-Encoding" => "gzip, deflate", "SOAPAction" => "http://www.allscripts.com/Unity/IUnityService/GetSecurityToken", "Content-Type" =>  "text/xml; charset=UTF-8"}
    soap.body = {"Username" => user, "Password" => pass}
  end
  return response.body[:get_security_token_response][:get_security_token_result]
end

#get_server_infoObject



298
299
300
301
# File 'lib/unityapi/unity_client.rb', line 298

def get_server_info
  response = magic_action("GetServerInfo")
  return response.body[:magic_response][:magic_result][:diffgram][:getserverinforesponse][:getserverinfoinfo]
end

#get_sigs(user_id, ddi, favs) ⇒ Object



303
304
305
306
# File 'lib/unityapi/unity_client.rb', line 303

def get_sigs(user_id, ddi, favs)
  response = magic_action("GetSigs", user_id, nil, ddi, favs)
  return response.body[:magic_response][:magic_result][:diffgram][:getsigsresponse][:getsigsinfo]
end

#get_site_config(site_id) ⇒ Object



308
309
310
311
# File 'lib/unityapi/unity_client.rb', line 308

def get_site_config(site_id)
  response = magic_action("GetSiteConfig", nil, nil, site_id)
  return response.body[:magic_response][:magic_result][:diffgram][:getsiteconfigresponse][:getsiteconfiginfo]
end

#get_task(user_id, trans_id) ⇒ Object



312
313
314
315
# File 'lib/unityapi/unity_client.rb', line 312

def get_task(user_id, trans_id)
  response = magic_action("GetTask", user_id, nil, trans_id)
  return response.body[:magic_response][:magic_result][:diffgram][:gettaskresponse][:gettaskinfo]
end

#get_task_list(user_id) ⇒ Object



316
317
318
319
# File 'lib/unityapi/unity_client.rb', line 316

def get_task_list(user_id)
  response = magic_action("GetTaskList", user_id)
  return response.body[:magic_response][:magic_result][:diffgram][:gettasklistresponse][:gettasklistinfo]
end

#get_token_validation(sso_token) ⇒ Object



320
321
322
323
# File 'lib/unityapi/unity_client.rb', line 320

def get_token_validation(sso_token)
  response = magic_action("GetTokenValidation", nil, nil, sso_token)
  return response.body[:magic_response][:magic_result][:diffgram][:gettokenvalidationresponse][:gettokenvalidationinfo]
end

#get_user_authentication(user_id, password, client_id, app_version) ⇒ Object



324
325
326
327
# File 'lib/unityapi/unity_client.rb', line 324

def get_user_authentication(user_id, password, client_id, app_version)
  response = magic_action("GetUserAuthentication", user_id, nil, password, client_id, app_version)
  return response.body[:magic_response][:magic_result][:diffgram][:getuserauthenticationresponse][:getuserauthenticationinfo]
end

#get_user_id(user_id) ⇒ Object



328
329
330
331
# File 'lib/unityapi/unity_client.rb', line 328

def get_user_id(user_id)
  response = magic_action("GetUserID", user_id)
  return response.body[:magic_response][:magic_result][:diffgram][:getuseridresponse][:getuseridinfo]
end

#get_user_security(user_id_num, org_id) ⇒ Object



332
333
334
335
# File 'lib/unityapi/unity_client.rb', line 332

def get_user_security(user_id_num, org_id)
  response = magic_action("GetUserSecurity", nil, nil, user_id_num, org_id)
  return response.body[:magic_response][:magic_result][:diffgram][:getusersecurityresponse][:getusersecurityinfo]
end

#get_vaccine_manufacturersObject



336
337
338
339
# File 'lib/unityapi/unity_client.rb', line 336

def get_vaccine_manufacturers
  response = magic_action("GetVaccineManufacturers")
  return response.body[:magic_response][:magic_result][:diffgram][:getvaccinemanufacturersresponse][:getvaccinemanufacturersinfo]
end

#get_vitalsObject

returns xml description of all vitals forms used in EHR



340
341
342
343
# File 'lib/unityapi/unity_client.rb', line 340

def get_vitals #returns xml description of all vitals forms used in EHR
  response = magic_action("GetVitals")
  return response.body[:magic_response][:magic_result][:diffgram][:getvitalsresponse][:getvitalsinfo]
end

#magic_action(action, user_id = self.user, patient_id = "", param_1 = nil, param_2 = nil, param_3 = nil, param_4 = nil, param_5 = nil, param_6 = nil, data = nil) ⇒ Object

basic magic action call for UnityAPI; all other actions use this call to execute the SOAP transaction



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/unityapi/unity_client.rb', line 40

def magic_action(action, user_id=self.user, patient_id = "", param_1=nil, param_2=nil, param_3=nil, param_4=nil, param_5=nil, param_6=nil, data=nil)
  begin
    response = self.client.request("Magic", xmlns: "http://www.allscripts.com/Unity") do
      http.headers = {"Accept-Encoding" => "gzip, deflate", "SOAPAction" => "http://www.allscripts.com/Unity/IUnityService/Magic", "Content-Type" =>  "text/xml; charset=UTF-8"}
      soap.body = {
        "Action" => action,
        "UserID" => user_id,
        "Appname" => self.app,
        "PatientID" => patient_id,
        "Token" => self.security_token,
        "Parameter1" => param_1,
        "Parameter2" => param_2,
        "Parameter3" => param_3,
        "Parameter4" => param_4,
        "Parameter5" => param_5,
        "Parameter6" => param_6,
        "data" => data,
        :attributes! => {"data" =>{"xsi:nil" => true}}
      }
    end
  rescue Timeout::Error
    puts "Timeout was rescued"
    30.times do |i|
      sleep 1
      puts "#{30 - i} seconds to next retry"
    end
    puts "retrying"
    retry
  end
  return response
end

#make_task(task_type, target_user, work_object_id) ⇒ Object



345
346
347
348
# File 'lib/unityapi/unity_client.rb', line 345

def make_task(task_type, target_user, work_object_id)
  response = magic_action("MakeTask", nil, nil, task_type, target_user, work_object_id)
  return response.body[:magic_response][:magic_result][:diffgram][:maketaskresponse][:maketaskinfo]
end

#save_admin_task(user_id, task_xml) ⇒ Object

better define task_xml



350
351
352
353
# File 'lib/unityapi/unity_client.rb', line 350

def save_admin_task(user_id, task_xml) #better define task_xml
  response = magic_action("SaveAdminTask", nil)
  return response.body[:magic_response][:magic_result][:diffgram][:saveadmintaskresponse][:saveadmintaskinfo]
end

#save_allergy(user_id, patient_id, allergy_xml) ⇒ Object



355
356
357
358
# File 'lib/unityapi/unity_client.rb', line 355

def save_allergy(user_id, patient_id, allergy_xml)
  response = magic_action("SaveAllergy", user_id, patient_id, allergy_xml)
  return response.body[:magic_response][:magic_result][:diffgram][:saveallergyresponse][:saveallergyinfo]
end

#save_ced(ced_params, ced_text) ⇒ Object



360
361
362
363
# File 'lib/unityapi/unity_client.rb', line 360

def save_ced(ced_params, ced_text)
  response = magic_action("SaveCED", nil, nil, ced_params, ced_text)
  return response.body[:magic_response][:magic_result][:diffgram][:savecedresponse][:savecedinfo]
end

#save_charge(user_id, charge_id, encounter_id, charge_code_de, payload_xml) ⇒ Object



365
366
367
368
# File 'lib/unityapi/unity_client.rb', line 365

def save_charge(user_id, charge_id, encounter_id, charge_code_de, payload_xml)
  response = magic_action("SaveCharge", user_id, nil, "", charge_id, encounter_id, charge_code_de, payload_xml)
  return response.body[:magic_response][:magic_result][:diffgram][:savechargeresponse][:savechargeinfo]
end

#save_chart_view_audit(user_id, xml_payload) ⇒ Object



370
371
372
373
# File 'lib/unityapi/unity_client.rb', line 370

def save_chart_view_audit(user_id, xml_payload)
  response = magic_action("SaveChartViewAudit", user_id, nil, xml_payload)
  return response.body[:magic_response][:magic_result][:diffgram][:savechartviewauditresponse][:savechartviewauditinfo]
end

#save_diagnosis(user_id, encounter_id, icd9, display_order, free_text) ⇒ Object



375
376
377
378
# File 'lib/unityapi/unity_client.rb', line 375

def save_diagnosis(user_id, encounter_id, icd9, display_order, free_text)
  response = magic_action("SaveDiagnosis", user_id, nil, encounter_id, icd9, display_order, free_text)
  return response.body[:magic_response][:magic_result][:diffgram][:savediagnosisresponse][:savediagnosisinfo]
end

#save_document_image(user_id, patient_id, document_param, data) ⇒ Object



380
381
382
383
# File 'lib/unityapi/unity_client.rb', line 380

def save_document_image(user_id, patient_id, document_param, data)
  response = magic_action("SaveDocumentImage", user_id, patient_id, document_param, nil, nil, nil , nil, nil, data)
  return response.body[:magic_response][:magic_result][:diffgram][:savedocumentimageresponse][:savedocumentimageinfo]
end

#save_er_note(user_id, patient_id, note, er_id) ⇒ Object



385
386
387
388
# File 'lib/unityapi/unity_client.rb', line 385

def save_er_note(user_id, patient_id, note, er_id)
  response = magic_action("SaveERNote", user_id, patient_id, note, er_id)
  return response.body[:magic_response][:magic_result][:diffgram][:saveernoteresponse][:saveernoteinfo]
end

#save_hie_document(user_id, patient_id, xml_params, ced_xml) ⇒ Object



390
391
392
393
# File 'lib/unityapi/unity_client.rb', line 390

def save_hie_document(user_id, patient_id, xml_params, ced_xml)
  response = magic_action("SaveHIEDocument", user_id, patient_id, xml_params, ced_xml)
  return response.body[:magic_response][:magic_result][:diffgram][:savehiedocumentresponse][:savehiedocumentinfo]
end

#save_history(user_id, patient_id, xml_params) ⇒ Object



395
396
397
398
# File 'lib/unityapi/unity_client.rb', line 395

def save_history(user_id, patient_id, xml_params)
  response = magic_action("SaveHistory", user_id, patient_id, xml_params)
  return response.body[:magic_response][:magic_result][:diffgram][:savehistoryresponse][:savehistoryinfo]
end

#save_immunization(user_id, patient_id, xml) ⇒ Object



400
401
402
403
# File 'lib/unityapi/unity_client.rb', line 400

def save_immunization(user_id, patient_id, xml)
  response = magic_action("SaveImmunization", user_id, patient_id, xml)
  return response.body[:magic_response][:magic_result][:diffgram][:saveimmunizationresponse][:saveimmunizationinfo]
end

#save_note(user_id, patient_id, note, doc_type, doc_status, rtf_ok) ⇒ Object



405
406
407
408
# File 'lib/unityapi/unity_client.rb', line 405

def save_note(user_id, patient_id, note, doc_type, doc_status, rtf_ok)
  response = magic_action("SaveNote", user_id, patient_id, note, doc_type, doc_status, rtf_ok)
  return response.body[:magic_response][:magic_result][:diffgram][:savenoteresponse][:savenoteinfo]
end

#save_patient(user_id, patient_id, xml) ⇒ Object



410
411
412
413
# File 'lib/unityapi/unity_client.rb', line 410

def save_patient(user_id, patient_id, xml)
  response = magic_action("SavePatient", user_id, patient_id, xml)
  return response.body[:magic_response][:magic_result][:diffgram][:savepatientresponse][:savepatientinfo]
end

#save_patient_location(user_id, patient_id, xml) ⇒ Object



415
416
417
418
# File 'lib/unityapi/unity_client.rb', line 415

def save_patient_location(user_id, patient_id, xml)
  response = magic_action("SavePatientLocation", user_id, patient_id, xml)
  return response.body[:magic_response][:magic_result][:diffgram][:savepatientlocationresponse][:savepatientlocationinfo]
end

#save_problem(patient_id, problem_type_id, problem_id, severity, type, xml_payload) ⇒ Object



420
421
422
423
# File 'lib/unityapi/unity_client.rb', line 420

def save_problem(patient_id, problem_type_id, problem_id, severity, type, xml_payload)
  response = magic_action("SaveProblem", nil, patient_id, problem_type_id, problem_id, severity, type, xml_payload)
  return response.body[:magic_response][:magic_result][:diffgram][:saveproblemresponse][:saveprobleminfo]
end

#save_problems_data(user_id, patient_id, xml_params) ⇒ Object



425
426
427
428
# File 'lib/unityapi/unity_client.rb', line 425

def save_problems_data(user_id, patient_id, xml_params)
  response = magic_action("SaveProblemsData", user_id, patient_id, xml_params)
  return response.body[:magic_response][:magic_result][:diffgram][:saveproblemsdataresponse][:saveproblemsdatainfo]
end

#save_ref_provider(xml) ⇒ Object



430
431
432
433
# File 'lib/unityapi/unity_client.rb', line 430

def save_ref_provider(xml)
  response = magic_action("SaveRefProvider", nil, nil, xml)
  return response.body[:magic_response][:magic_result][:diffgram][:saverefproviderresponse][:saverefproviderinfo]
end

#save_result(result_xml) ⇒ Object



435
436
437
438
# File 'lib/unityapi/unity_client.rb', line 435

def save_result(result_xml)
  response = magic_action("SaveResult", nil, nil, result_xml)
  return response.body[:magic_response][:magic_result][:diffgram][:saveresultresponse][:saveresultinfo]
end

#save_rx(user_id, patient_id, rxxml) ⇒ Object



440
441
442
443
# File 'lib/unityapi/unity_client.rb', line 440

def save_rx(user_id, patient_id, rxxml)
  response = magic_action("SaveRX", user_id, patient_id, rxxml)
  return response.body[:magic_response][:magic_result][:diffgram][:saverxresponse][:saverxinfo]
end

#save_simple_encounter(user_id, patient_id, encounter_type, datetime) ⇒ Object



445
446
447
448
# File 'lib/unityapi/unity_client.rb', line 445

def save_simple_encounter(user_id, patient_id, encounter_type, datetime)
  response = magic_action("SaveSimpleEncounter", user_id, patient_id, encounter_type, datetime)
  return response.body[:magic_response][:magic_result][:diffgram][:savesimpleencounterresponse][:savesimpleencounterinfo]
end

#save_simple_rx(user_id, patient_id, med_fav, pharm_id) ⇒ Object



450
451
452
453
# File 'lib/unityapi/unity_client.rb', line 450

def save_simple_rx(user_id, patient_id, med_fav, pharm_id)
  response = magic_action("SaveSimpleRX", user_id, patient_id, med_fav, pharm_id)
  return response.body[:magic_response][:magic_result][:diffgram][:savesimplerxresponse][:savesimplerxinfo]
end

#save_specialist(specialist_xml) ⇒ Object



455
456
457
458
# File 'lib/unityapi/unity_client.rb', line 455

def save_specialist(specialist_xml)
  response = magic_action("SaveSpecialist", nil, nil, specialist_xml)
  return response.body[:magic_response][:magic_result][:diffgram][:savespecialistresponse][:savespecialistinfo]
end

#save_task(patient_id, task_type, target_user, work_object_id, comments) ⇒ Object



460
461
462
463
# File 'lib/unityapi/unity_client.rb', line 460

def save_task(patient_id, task_type, target_user, work_object_id, comments)
  response = magic_action("SaveTask", nil, patient_id, task_type, target_user, work_object_id, comments)
  return response.body[:magic_response][:magic_result][:diffgram][:savetaskresponse][:savetaskinfo]
end

#save_task_status(user_id, trans_id, param, delegate_id, comment) ⇒ Object



465
466
467
468
# File 'lib/unityapi/unity_client.rb', line 465

def save_task_status(user_id, trans_id, param, delegate_id, comment)
  response = magic_action("SaveTaskStatus", user_id, nil, trans_id, param, delegate_id, comment)
  return response.body[:magic_response][:magic_result][:diffgram][:savetaskstatusresponse][:savetaskstatusinfo]
end

#save_unstructured_document(user_id, trans_id, param, delegate_id, comment) ⇒ Object



470
471
472
473
# File 'lib/unityapi/unity_client.rb', line 470

def save_unstructured_document(user_id, trans_id, param, delegate_id, comment)
  response = magic_action("SaveUnstructuredDocument", user_id, nil, trans_id, param, delegate_id, comment)
  return response.body[:magic_response][:magic_result][:diffgram][:saveunstructureddocumentresponse][:saveunstructureddocumentinfo]
end

#save_v10_doc_signature(user_id) ⇒ Object



475
476
477
478
# File 'lib/unityapi/unity_client.rb', line 475

def save_v10_doc_signature(user_id)
  response = magic_action("SaveV10DocSignature", user_id)
  return response.body[:magic_response][:magic_result][:diffgram][:savev10docsignatureresponse][:saveV10docsignatureinfo]
end

#save_v11_note(user_id, patient_id, input_template_id, xml_params, sign) ⇒ Object



480
481
482
483
# File 'lib/unityapi/unity_client.rb', line 480

def save_v11_note(user_id, patient_id, input_template_id, xml_params, sign)
  response = magic_action("SaveV11Note", user_id, patient_id, input_template_id, xml_params, sign)
  return response.body[:magic_response][:magic_result][:diffgram][:savev11noteresponse][:savev11noteinfo]
end

#save_vitals(user_id, patient_id, xml) ⇒ Object



485
486
487
488
# File 'lib/unityapi/unity_client.rb', line 485

def save_vitals(user_id, patient_id, xml)
  response = magic_action("SaveVitals", user_id, patient_id, xml)
  return response.body[:magic_response][:magic_result][:diffgram][:savevitalsresponse][:savevitalsinfo]
end

#search_charge_codes(user_id, patient_id, library, search_string, patient_recent_changes) ⇒ Object



490
491
492
493
# File 'lib/unityapi/unity_client.rb', line 490

def search_charge_codes(user_id, patient_id, library, search_string, patient_recent_changes)
  response = magic_action("SearchChargeCodes", user_id, patient_id, library, search_string, patient_recent_changes)
  return response.body[:magic_response][:magic_result][:diffgram][:searchchargecodesresponse][:searchchargecodesinfo]
end

#search_diagnosis_codes(user_id, patient_id, library, search_string, row_count, patient_diagnosis_count) ⇒ Object



495
496
497
498
# File 'lib/unityapi/unity_client.rb', line 495

def search_diagnosis_codes(user_id, patient_id, library, search_string, row_count, patient_diagnosis_count)
  response = magic_action("SearchDiagnosisCodes", user_id, patient_id, library, search_string, row_count, patient_diagnosis_count)
  return response.body[:magic_response][:magic_result][:diffgram][:searchdiagnosiscodesresponse][:searchdiagnosiscodesinfo]
end

#search_meds(user_id, patient_id, search) ⇒ Object



500
501
502
503
# File 'lib/unityapi/unity_client.rb', line 500

def search_meds(user_id, patient_id, search)
  response = magic_action("SearchMeds", user_id, patient_id, search)
  return response.body[:magic_response][:magic_result][:diffgram][:searchmedsresponse][:searchmedsinfo]
end

#search_patients(user_id, search) ⇒ Object



505
506
507
508
# File 'lib/unityapi/unity_client.rb', line 505

def search_patients(user_id, search)
  response = magic_action("SearchPatients", user_id, nil, search)
  return response.body[:magic_response][:magic_result][:diffgram][:searchpatientsresponse][:searchpatientsinfo]
end

#search_patients_rxhub5(first, last, zip, dob, gender) ⇒ Object



510
511
512
513
# File 'lib/unityapi/unity_client.rb', line 510

def search_patients_rxhub5(first, last, zip, dob, gender)
  response = magic_action("SearchPatientsRXHub5", nil, nil, first, last, zip, dob, gender)
  return response.body[:magic_response][:magic_result][:diffgram][:searchpatientsrxhub5response][:searchpatientsrxhub5info]
end

#search_pharmacies(user_id, search) ⇒ Object



515
516
517
518
# File 'lib/unityapi/unity_client.rb', line 515

def search_pharmacies(user_id, search)
  response = magic_action("SearchPharmacies", user_id, nil, search)
  return response.body[:magic_response][:magic_result][:diffgram][:searchpharmaciesresponse][:searchpharmaciesinfo]
end

#search_problem_codes(user_id, patient_id, library, search) ⇒ Object



520
521
522
523
# File 'lib/unityapi/unity_client.rb', line 520

def search_problem_codes(user_id, patient_id, library, search)
  response = magic_action("SearchProblemCodes", user_id, patient_id, library, search)
  return response.body[:magic_response][:magic_result][:diffgram][:searchproblemcodesresponse][:searchproblemcodesinfo]
end

#update_encounterObject



525
526
527
528
# File 'lib/unityapi/unity_client.rb', line 525

def update_encounter
  response = magic_action("UpdateEncounter")
  return response.body[:magic_response][:magic_result][:diffgram][:updateencounterresponse][:updateencounterinfo]
end

#update_referral_order_status(patient_id, trans_id, new_status) ⇒ Object



530
531
532
533
# File 'lib/unityapi/unity_client.rb', line 530

def update_referral_order_status(patient_id, trans_id, new_status)
  response = magic_action("UpdateReferralOrderStatus", nil, patient_id, trans_id, new_status)
  return response.body[:magic_response][:magic_result][:diffgram][:updatereferralorderstatusresponse][:updatereferralorderstatusinfo]
end