unityapi 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,26 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .idea/.name
19
+ .idea/.rakeTasks
20
+ .idea/encodings.xml
21
+ .idea/misc.xml
22
+ .idea/modules.xml
23
+ .idea/scopes/scope_settings.xml
24
+ .idea/unityapi.iml
25
+ .idea/vcs.xml
26
+ .idea/workspace.xml
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in unityapi.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Ash Gupta
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # Unityapi
2
+
3
+ The Unityapi Gem is a ruby wrapper for the Allscripts Unity API. See http://asdn.unitysandbox.com/UnitySDK/SDK/ for more information regarding the Allscripts API
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'unityapi'
10
+
11
+ And then execute:
12
+
13
+ $ bundle install
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install unityapi
18
+
19
+ ## Usage
20
+
21
+ 1.) Initialize the Unity Client
22
+
23
+ client = Unityapi::UnityClient.new(unity_username, unity_password, appname, unity_server_url)
24
+
25
+ 2.) Make calls with the client
26
+
27
+ unity_response = client.magic_action(action_name, provider_username, patient_id, param_1, param_2, param_3, param_4, param_5, param_6)
28
+ patient_data = client.get_patient("jmedici", 77) #shortcut for the GetPatient Unity Call - gets patient 77 for provider with username "jmedici"
29
+
30
+ 3.) Close the connection
31
+
32
+ client.close
33
+
34
+ The UnityApi Gem uses Savon as the SOAP client to broker the connection, and does all the setup work for managing the security token for you as you use Unity Calls.
35
+
36
+ For a full list of supported calls please browse the source found in lib/unityapi/unity_client.rb or use the client.magic_action
37
+
38
+ ## To Dos
39
+
40
+ 1. Add tests
41
+ 2. Add documentation
42
+ 3. Clean up Unity calls for a target born-on date
43
+
44
+ ## Contributing
45
+
46
+ 1. Fork it
47
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
48
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
49
+ 4. Push to the branch (`git push origin my-new-feature`)
50
+ 5. Create new Pull Request
51
+ =======
52
+ unityapi
53
+ ========
54
+
55
+ Ruby wrapper for Allscripts Unity API
56
+
57
+ Maintainer
58
+
59
+ Ash Gupta (https://github.com/incomethax)
60
+
61
+ License
62
+
63
+ MIT License. Copyright 2012 healthfinch, Inc. http://www.healthfinch.com
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,555 @@
1
+ module Unityapi
2
+ class UnityClient
3
+ require 'savon'
4
+ attr_accessor :client, :security_token, :user, :pass, :app
5
+ def initialize(user, pass, app, path_to_wsdl)
6
+ @user = user
7
+ @pass = pass
8
+ @app = app
9
+ Savon.configure do |config|
10
+ config.env_namespace = :soap
11
+ config.log = false
12
+ config.pretty_print_xml = true
13
+ HTTPI.log = false
14
+ end
15
+ @client = Savon.client(path_to_wsdl)
16
+ @security_token = get_security_token(user, pass)
17
+ end
18
+
19
+ def close
20
+ response = self.client.request("RetireSecurityToken", xmlns: "http://www.allscripts.com/Unity") do
21
+ http.headers = {"Accept-Encoding" => "gzip, deflate", "SOAPAction" => "http://www.allscripts.com/Unity/IUnityService/RetireSecurityToken", "Content-Type" => "text/xml; charset=UTF-8"}
22
+ soap.body = {"Token" => self.security_token, "Appname" => self.app}
23
+ end
24
+ end
25
+
26
+ def get_security_token(user, pass)
27
+ response = self.client.request("GetSecurityToken", xmlns: "http://www.allscripts.com/Unity") do
28
+ http.headers = {"Accept-Encoding" => "gzip, deflate", "SOAPAction" => "http://www.allscripts.com/Unity/IUnityService/GetSecurityToken", "Content-Type" => "text/xml; charset=UTF-8"}
29
+ soap.body = {"Username" => user, "Password" => pass}
30
+ end
31
+ return response.body[:get_security_token_response][:get_security_token_result]
32
+ end
33
+
34
+ #basic magic action call for UnityAPI; all other actions use this call to execute the SOAP transaction
35
+ 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)
36
+ begin
37
+ response = self.client.request("Magic", xmlns: "http://www.allscripts.com/Unity") do
38
+ http.headers = {"Accept-Encoding" => "gzip, deflate", "SOAPAction" => "http://www.allscripts.com/Unity/IUnityService/Magic", "Content-Type" => "text/xml; charset=UTF-8"}
39
+ soap.body = {
40
+ "Action" => action,
41
+ "UserID" => user_id,
42
+ "Appname" => self.app,
43
+ "PatientID" => patient_id,
44
+ "Token" => self.security_token,
45
+ "Parameter1" => param_1,
46
+ "Parameter2" => param_2,
47
+ "Parameter3" => param_3,
48
+ "Parameter4" => param_4,
49
+ "Parameter5" => param_5,
50
+ "Parameter6" => param_6,
51
+ "data" => data,
52
+ :attributes! => {"data" =>{"xsi:nil" => true}}
53
+ }
54
+ end
55
+ rescue Timeout::Error
56
+ puts "Timeout was rescued"
57
+ 30.times do |i|
58
+ sleep 1
59
+ puts "#{30 - i} seconds to next retry"
60
+ end
61
+ puts "retrying"
62
+ retry
63
+ end
64
+ return response
65
+ end
66
+
67
+ def commit_charges(user_id, encounter_id, side_de)
68
+ response = magic_action("CommitCharges", user_id, patient_id, encounter_id, site_de)
69
+ return response.body[:magic_response][:magic_result][:diffgram][:commitchargesresponse][:commitchargesinfo]
70
+ end
71
+
72
+ def echo(user_id, patient_id="", param_1=nil, param_2=nil, param_3=nil, param_4=nil, param_5=nil, param_6=nil)
73
+ response = magic_action("Echo", user_id, patient_id, param_1, param_2, param_3, param_4, param_5, param_6)
74
+ return response.body[:magic_response][:magic_result][:diffgram][:echoresponse][:echoinformation]
75
+ end
76
+
77
+ def get_account
78
+ response = magic_action("GetAccount")
79
+ return response.body[:magic_response][:magic_result][:diffgram][:getaccountresponse][:getaccountinfo]
80
+ end
81
+
82
+ def get_changed_patients(start_time=nil)
83
+ response = magic_action("GetChangedPatients", nil, nil, start_time)
84
+ return response.body[:magic_response][:magic_result][:diffgram][:getchangedpatientsresponse][:getchangedpatientsinfo].map(&:patientid)
85
+ end
86
+
87
+ def get_charge_info_by_username(user_id, username_filter=nil)
88
+ response = magic_action("GetChargeInfoByUsername", user_id, nil, username_filter)
89
+ return response.body[:magic_response][:magic_result][:diffgram][:getchargeinfobyusernameresponse][:getchargeinfobyusernameinfo]
90
+ end
91
+
92
+ def get_charges(user_id, encounter_id=nil)
93
+ response = magic_action("GetCharges", user_id, nil, encounter_id)
94
+ return response.body[:magic_response][:magic_result][:diffgram][:getchargesresponse][:getchargesinfo]
95
+ end
96
+
97
+ def get_delegates(user_id)
98
+ response = magic_action("GetDelegates", user_id)
99
+ return response.body[:magic_response][:magic_result][:diffgram][:getdelegatesresponse][:getdelegatesinfo]
100
+ end
101
+
102
+ def get_dictionary(user_id, dictionary_name, site=nil)
103
+ response = magic_action("GetDictionary", user_id, nil, dictionary_name, site)
104
+ return response.body[:magic_response][:magic_result][:diffgram][:getdictionaryresponse][:getdictionaryinfo]
105
+ end
106
+
107
+ def get_dictionary_sets(group_name, dictionary_set_name)
108
+ response = magic_action("GetDictionarySets", nil, nil, group_name, dictionary_set_name)
109
+ return response.body[:magic_response][:magic_result][:diffgram][:getdictionarysetsresponse][:getdictionarysetsinfo]
110
+ end
111
+
112
+ def get_doc_template(user_id, section, template)
113
+ response = magic_action("GetDocTemplate", user_id, nil, section, template)
114
+ return response.body[:magic_response][:magic_result][:diffgram][:getdoctemplateresponse][:getdoctemplateinfo]
115
+ end
116
+
117
+ def get_document_by_accession(patient_id=nil, accession_num)
118
+ response = magic_action("GetDocumentByAccession", nil, patient_id, accession_num)
119
+ return response.body[:magic_response][:magic_result][:diffgram][:getdocumentbyaccensionresponse][:getdocumentbyaccensioninfo]
120
+ end
121
+
122
+ def get_document_image(user_id, patient_id=nil, document_id)
123
+ response = magic_action("GetDocumentImage", user_id, patient_id, document_id)
124
+ return response.body[:magic_response][:magic_result][:diffgram][:getdocumentimageresponse][:getdocumentimageinfo]
125
+ end
126
+
127
+ def get_documents(user_id, patient_id, document_id, document_type=nil, start_date=nil, end_date=nil)
128
+ response = magic_action("GetDocuments", user_id, patient_id, start_date, end_date, document_id, document_type)
129
+ return response.body[:magic_response][:magic_result][:diffgram][:getdocumentsresponse][:getdocumentsinfo]
130
+ end
131
+
132
+ def get_document_type(doc_type=nil)#could be "Chart", "Consult", "SpecReport", "ChartCopy" or nil
133
+ response = magic_action("GetDocumentType", nil, nil, doc_type)
134
+ return response.body[:magic_response][:magic_result][:diffgram][:getdocumenttyperesponse][:getdocumenttypeinfo]
135
+ end
136
+
137
+ def get_dur(user_id, patient_id, dur_type, client_id, rx_data)
138
+ response = magic_action("GetDUR", user_id, patient_id, dur_type, client_id, rx_data)
139
+ return response.body[:magic_response][:magic_result][:diffgram][:getdurresponse][:getdurinfo]
140
+ end
141
+
142
+ def get_encounter(user_id, patient_id, encounter_type, encounter_time, force_new_encounter, match_provider_flag)
143
+ response = magic_action("GetEncounter", user_id, patient_id, encounter_type, encounter_time, force_new_encounter, match_provider_flag)
144
+ return response.body[:magic_response][:magic_result][:diffgram][:getencounterresponse][:getencounterinfo]
145
+ end
146
+
147
+ def get_encounter_date(patient_id, encounter_id)
148
+ response = magic_action("GetEncounterDate", nil, patient_id, encounter_id)
149
+ return response.body[:magic_response][:magic_result][:diffgram][:getencounterdateresponse][:getencounterdateinfo]
150
+ end
151
+
152
+ def get_encounter_list(user_id, patient_id, encounter_type, date, future_days, show_previous_encounters, billing_provider)
153
+ response = magic_action("GetEncounterList", user_id, patient_id, encounter_type, date, future_days, show_previous_encounters, billing_provider)
154
+ return response.body[:magic_response][:magic_result][:diffgram][:getencounterlistresponse][:getencounterlistinfo]
155
+ end
156
+
157
+ def get_hie_document(patient_id)
158
+ response = magic_action("GetHIEDocument", nil, patient_id)
159
+ return response.body[:magic_response][:magic_result][:diffgram][:gethiedocumentresponse][:gethiedocumentinfo]
160
+ end
161
+
162
+ def get_last_patient
163
+ response = magic_action("GetLastPatient")
164
+ return response.body[:magic_response][:magic_result][:diffgram][:getlastpatientresponse][:getlastpatientinfo]
165
+ end
166
+
167
+ def get_list_of_dictionaries
168
+ response = magic_action("GetListOfDictionaries")
169
+ return response.body[:magic_response][:magic_result][:diffgram][:getlistofdictionariesresponse][:getlistofdictionariesinfo]
170
+ end
171
+
172
+ def get_medication_by_trans_id(user_id, patient_id, trans_id)
173
+ response = magic_action("GetMedicationByTransID", user_id, patient_id, trans_id)
174
+ return response.body[:magic_response][:magic_result][:diffgram][:getmedicationbytransidresponse][:getmedicationbytransidinfo]
175
+ end
176
+
177
+ def get_order_history(user_id, item_id)
178
+ response = magic_action("GetOrderHistory", user_id, nil, item_id)
179
+ return response.body[:magic_response][:magic_result][:diffgram][:getorderhistoryresponse][:getorderhistoryinfo]
180
+ end
181
+
182
+ def get_organization_id
183
+ response = magic_action("GetOrganizationID")
184
+ return response.body[:magic_response][:magic_result][:diffgram][:getorganizationidresponse][:getorganizationidinfo]
185
+ end
186
+
187
+ def get_packages(user_id, org_name)
188
+ response = magic_action("GetPackages", user_id, nil, org_name)
189
+ return response.body[:magic_response][:magic_result][:diffgram][:getpackagesresponse][:getpackagesinfo]
190
+ end
191
+
192
+ def get_patient(user_id, patient_id, include_pic=nil)
193
+ response = magic_action("GetPatient", user_id, patient_id, include_pic)
194
+ return response.body[:magic_response][:magic_result][:diffgram][:getpatientresponse][:getpatientinfo]
195
+ end
196
+
197
+ def get_patient_activity(user_id, patient_id)
198
+ response = magic_action("GetPatientActivity", user_id, patient_id)
199
+ rootobj = response.body[:magic_response][:magic_result][:diffgram][:getpatientactivityresponse]
200
+ return {:encounters => rootobj[:getpatientactivityinfo], :problems => rootobj[:getpatientactivityinfo2], :vitals => rootobj[:getpatientactivityinfo3], :results => rootobj[:getpatientactivityinfo4],:orders => rootobj[:getpatientactivityinfo5],:procedures => rootobj[:getpatientactivityinfo6], :item_7 => rootobj[:getpatientactivityinfo7], :item_8 => rootobj[:getpatientactivityinfo8]}
201
+ end
202
+
203
+ def get_patient_by_mrn(user_id, mrn)
204
+ response = magic_action("GetPatientByMRN", user_id, nil, mrn)
205
+ return response.body[:magic_response][:magic_result][:diffgram][:getpatientbymrnresponse][:getpatientbymrninfo]
206
+ end
207
+ def get_patient_cda(patient_id, organization_id=nil, appgroup=nil)
208
+ response = magic_action("GetPatientCDA", nil, patient_id, organization_id, appgroup)
209
+ return response.body[:magic_response][:magic_result][:diffgram][:getpatientcdaresponse][:getpatientcdainfo]
210
+ end
211
+
212
+ def get_patient_diagnosis(user_id, patient_id, encounter_date, encounter_type_mnemonic, encounter_date_rage, encounter_id)
213
+ response = magic_action("GetPatientDiagnosis", user_id, patient_id, encounter_date, encounter_type_mnemonic, encounter_date_rage, encounter_id)
214
+ return response.body[:magic_response][:magic_result][:diffgram][:getpatientdiagnosisresponse][:getpatientdiagnosisinfo]
215
+ end
216
+
217
+ def get_patient_full(patient_id, mrn, org_id, order_id)
218
+ response = magic_action("GetPatientFull", nil, patient_id, mrn, org_id, order_id)
219
+ return response.body[:magic_response][:magic_result][:diffgram][:getpatientfullresponse][:getpatientfullinfo]
220
+ end
221
+
222
+ def get_patient_ids(patient_id)
223
+ response = magic_action("GetPatientIDs", nil, patient_id)
224
+ return response.body[:magic_response][:magic_result][:diffgram][:getpatientidsresponse][:getpatientidsinfo]
225
+ end
226
+
227
+ def get_patient_list(location_code, appt_date)
228
+ response = magic_action("GetPatientList", nil, nil, location_code, appt_date)
229
+ return response.body[:magic_response][:magic_result][:diffgram][:getpatientlistresponse][:getpatientlistinfo]
230
+ end
231
+
232
+ def get_patient_locations(user_id, user_xml=nil) #user_xml needs to be better defined and broken down into true params
233
+ response = magic_action("GetPatientLocations", user_id, nil, user_xml)
234
+ return response.body[:magic_response][:magic_result][:diffgram][:getpatientlocationsresponse][:getpatientlocationsinfo]
235
+ end
236
+ def get_patient_pharmacies(user_id, patient_id)
237
+ response = magic_action("GetPatientPharmacies", user_id, patient_id)
238
+ return response.body[:magic_response][:magic_result][:diffgram][:getpatientpharmaciesresponse][:getpatientpharmaciesinfo]
239
+ end
240
+
241
+ def get_patient_problems(patient_id, show_by_encounter_flag=nil, assessed=nil, encounter_id=nil, medcin_id=nil)
242
+ response = magic_action("GetPatientProblems", nil, patient_id, show_by_encounter_flag, assessed, encounter_id, medcin_id)
243
+ return response.body[:magic_response][:magic_result][:diffgram][:getpatientproblemsresponse][:getpatientproblemsinfo]
244
+ end
245
+
246
+ def get_patients_by_icd9(icd_9, start_date, end_date)
247
+ response = magic_action("GetPatientsByICD9", nil, nil, icd_9, start_date, end_date)
248
+ return response.body[:magic_response][:magic_result][:diffgram][:getpatientsbyicd9response][:getpatientsbyicd9info]
249
+ end
250
+
251
+ def get_patient_sections(user_id, patient_id, months)
252
+ response = magic_action("GetPatientSections", user_id, patient_id, months)
253
+ return response.body[:magic_response][:magic_result][:diffgram][:getpatientsectionsresponse][:getpatientsectionsinfo]
254
+ end
255
+
256
+ def get_provider(provider_id, user_name)
257
+ response = magic_action("GetProvider")
258
+ return response.body[:magic_response][:magic_result][:diffgram][:getproviderresponse][:getproviderinfo]
259
+ end
260
+
261
+ def get_providers(security_filter=nil, name_filter=nil)
262
+ response = magic_action("GetProviders")
263
+ return response.body[:magic_response][:magic_result][:diffgram][:getprovidersresponse][:getprovidersinfo]
264
+ end
265
+
266
+ def get_ref_providers_by_specialty(user_id, search)
267
+ response = magic_action("GetRefProvidersBySpecialty", user_id, nil, search)
268
+ return response.body[:magic_response][:magic_result][:diffgram][:getrefprovidersbyspecialtyresponse][:getrefprovidersbyspecialtyinfo]
269
+ end
270
+
271
+ def get_rounding_list_entries(user_id, patient_list_id, sort_field, sort_order, org_id, timezone_offset)
272
+ response = magic_action("GetRoundingListEntries", user_id, nil, patient_list_id, sort_field, sort_order, org_id, timezone_offset)
273
+ return response.body[:magic_response][:magic_result][:diffgram][:getroundinglistentriesresponse][:getroundinglistentriesinfo]
274
+ end
275
+
276
+ def get_rounding_lists(user_id, org_id)
277
+ response = magic_action("GetRoundingLists", user_id, nil, org_id)
278
+ return response.body[:magic_response][:magic_result][:diffgram][:getroundinglistsresponse][:getroundinglistsinfo]
279
+ end
280
+
281
+ def get_rx_favs(user_id, patient_id)
282
+ response = magic_action("GetRXFavs", user_id, patient_id)
283
+ return response.body[:magic_response][:magic_result][:diffgram][:getrxfavsresponse][:getrxfavsinfo]
284
+ end
285
+
286
+ def get_schedule(date)
287
+ response = magic_action("GetSchedule", user_id, nil, date)
288
+ return response.body[:magic_response][:magic_result][:diffgram][:scheduleresponse][:scheduleinfo]
289
+ end
290
+
291
+ def get_server_info
292
+ response = magic_action("GetServerInfo")
293
+ return response.body[:magic_response][:magic_result][:diffgram][:getserverinforesponse][:getserverinfoinfo]
294
+ end
295
+
296
+ def get_sigs(user_id, ddi, favs)
297
+ response = magic_action("GetSigs", user_id, nil, ddi, favs)
298
+ return response.body[:magic_response][:magic_result][:diffgram][:getsigsresponse][:getsigsinfo]
299
+ end
300
+
301
+ def get_site_config(site_id)
302
+ response = magic_action("GetSiteConfig", nil, nil, site_id)
303
+ return response.body[:magic_response][:magic_result][:diffgram][:getsiteconfigresponse][:getsiteconfiginfo]
304
+ end
305
+ def get_task(user_id, trans_id)
306
+ response = magic_action("GetTask", user_id, nil, trans_id)
307
+ return response.body[:magic_response][:magic_result][:diffgram][:gettaskresponse][:gettaskinfo]
308
+ end
309
+ def get_task_list(user_id)
310
+ response = magic_action("GetTaskList", user_id)
311
+ return response.body[:magic_response][:magic_result][:diffgram][:gettasklistresponse][:gettasklistinfo]
312
+ end
313
+ def get_token_validation(sso_token)
314
+ response = magic_action("GetTokenValidation", nil, nil, sso_token)
315
+ return response.body[:magic_response][:magic_result][:diffgram][:gettokenvalidationresponse][:gettokenvalidationinfo]
316
+ end
317
+ def get_user_authentication(user_id, password, client_id, app_version)
318
+ response = magic_action("GetUserAuthentication", user_id, nil, password, client_id, app_version)
319
+ return response.body[:magic_response][:magic_result][:diffgram][:getuserauthenticationresponse][:getuserauthenticationinfo]
320
+ end
321
+ def get_user_id(user_id)
322
+ response = magic_action("GetUserID", user_id)
323
+ return response.body[:magic_response][:magic_result][:diffgram][:getuseridresponse][:getuseridinfo]
324
+ end
325
+ def get_user_security(user_id_num, org_id)
326
+ response = magic_action("GetUserSecurity", nil, nil, user_id_num, org_id)
327
+ return response.body[:magic_response][:magic_result][:diffgram][:getusersecurityresponse][:getusersecurityinfo]
328
+ end
329
+ def get_vaccine_manufacturers
330
+ response = magic_action("GetVaccineManufacturers")
331
+ return response.body[:magic_response][:magic_result][:diffgram][:getvaccinemanufacturersresponse][:getvaccinemanufacturersinfo]
332
+ end
333
+ def get_vitals #returns xml description of all vitals forms used in EHR
334
+ response = magic_action("GetVitals")
335
+ return response.body[:magic_response][:magic_result][:diffgram][:getvitalsresponse][:getvitalsinfo]
336
+ end
337
+
338
+ def make_task(task_type, target_user, work_object_id)
339
+ response = magic_action("MakeTask", nil, nil, task_type, target_user, work_object_id)
340
+ return response.body[:magic_response][:magic_result][:diffgram][:maketaskresponse][:maketaskinfo]
341
+ end
342
+
343
+ def save_admin_task(user_id, task_xml) #better define task_xml
344
+ response = magic_action("SaveAdminTask", nil)
345
+ return response.body[:magic_response][:magic_result][:diffgram][:saveadmintaskresponse][:saveadmintaskinfo]
346
+ end
347
+
348
+ def save_allergy(user_id, patient_id, allergy_xml)
349
+ response = magic_action("SaveAllergy", user_id, patient_id, allergy_xml)
350
+ return response.body[:magic_response][:magic_result][:diffgram][:saveallergyresponse][:saveallergyinfo]
351
+ end
352
+
353
+ def save_ced(ced_params, ced_text)
354
+ response = magic_action("SaveCED", nil, nil, ced_params, ced_text)
355
+ return response.body[:magic_response][:magic_result][:diffgram][:savecedresponse][:savecedinfo]
356
+ end
357
+
358
+ def save_charge(user_id, charge_id, encounter_id, charge_code_de, payload_xml)
359
+ response = magic_action("SaveCharge", user_id, nil, "", charge_id, encounter_id, charge_code_de, payload_xml)
360
+ return response.body[:magic_response][:magic_result][:diffgram][:savechargeresponse][:savechargeinfo]
361
+ end
362
+
363
+ def save_chart_view_audit(user_id, xml_payload)
364
+ response = magic_action("SaveChartViewAudit", user_id, nil, xml_payload)
365
+ return response.body[:magic_response][:magic_result][:diffgram][:savechartviewauditresponse][:savechartviewauditinfo]
366
+ end
367
+
368
+ def save_diagnosis(user_id, encounter_id, icd9, display_order, free_text)
369
+ response = magic_action("SaveDiagnosis", user_id, nil, encounter_id, icd9, display_order, free_text)
370
+ return response.body[:magic_response][:magic_result][:diffgram][:savediagnosisresponse][:savediagnosisinfo]
371
+ end
372
+
373
+ def save_document_image(user_id, patient_id, document_param, data)
374
+ response = magic_action("SaveDocumentImage", user_id, patient_id, document_param, nil, nil, nil , nil, nil, data)
375
+ return response.body[:magic_response][:magic_result][:diffgram][:savedocumentimageresponse][:savedocumentimageinfo]
376
+ end
377
+
378
+ def save_er_note(user_id, patient_id, note, er_id)
379
+ response = magic_action("SaveERNote", user_id, patient_id, note, er_id)
380
+ return response.body[:magic_response][:magic_result][:diffgram][:saveernoteresponse][:saveernoteinfo]
381
+ end
382
+
383
+ def save_hie_document(user_id, patient_id, xml_params, ced_xml)
384
+ response = magic_action("SaveHIEDocument", user_id, patient_id, xml_params, ced_xml)
385
+ return response.body[:magic_response][:magic_result][:diffgram][:savehiedocumentresponse][:savehiedocumentinfo]
386
+ end
387
+
388
+ def save_history(user_id, patient_id, xml_params)
389
+ response = magic_action("SaveHistory", user_id, patient_id, xml_params)
390
+ return response.body[:magic_response][:magic_result][:diffgram][:savehistoryresponse][:savehistoryinfo]
391
+ end
392
+
393
+ def save_immunization(user_id, patient_id, xml)
394
+ response = magic_action("SaveImmunization", user_id, patient_id, xml)
395
+ return response.body[:magic_response][:magic_result][:diffgram][:saveimmunizationresponse][:saveimmunizationinfo]
396
+ end
397
+
398
+ def save_note(user_id, patient_id, note, doc_type, doc_status, rtf_ok)
399
+ response = magic_action("SaveNote", user_id, patient_id, note, doc_type, doc_status, rtf_ok)
400
+ return response.body[:magic_response][:magic_result][:diffgram][:savenoteresponse][:savenoteinfo]
401
+ end
402
+
403
+ def save_patient(user_id, patient_id, xml)
404
+ response = magic_action("SavePatient", user_id, patient_id, xml)
405
+ return response.body[:magic_response][:magic_result][:diffgram][:savepatientresponse][:savepatientinfo]
406
+ end
407
+
408
+ def save_patient_location(user_id, patient_id, xml)
409
+ response = magic_action("SavePatientLocation", user_id, patient_id, xml)
410
+ return response.body[:magic_response][:magic_result][:diffgram][:savepatientlocationresponse][:savepatientlocationinfo]
411
+ end
412
+
413
+ def save_problem(patient_id, problem_type_id, problem_id, severity, type, xml_payload)
414
+ response = magic_action("SaveProblem", nil, patient_id, problem_type_id, problem_id, severity, type, xml_payload)
415
+ return response.body[:magic_response][:magic_result][:diffgram][:saveproblemresponse][:saveprobleminfo]
416
+ end
417
+
418
+ def save_problems_data(user_id, patient_id, xml_params)
419
+ response = magic_action("SaveProblemsData", user_id, patient_id, xml_params)
420
+ return response.body[:magic_response][:magic_result][:diffgram][:saveproblemsdataresponse][:saveproblemsdatainfo]
421
+ end
422
+
423
+ def save_ref_provider(xml)
424
+ response = magic_action("SaveRefProvider", nil, nil, xml)
425
+ return response.body[:magic_response][:magic_result][:diffgram][:saverefproviderresponse][:saverefproviderinfo]
426
+ end
427
+
428
+ def save_result(result_xml)
429
+ response = magic_action("SaveResult", nil, nil, result_xml)
430
+ return response.body[:magic_response][:magic_result][:diffgram][:saveresultresponse][:saveresultinfo]
431
+ end
432
+
433
+ def save_rx(user_id, patient_id, rxxml)
434
+ response = magic_action("SaveRX", user_id, patient_id, rxxml)
435
+ return response.body[:magic_response][:magic_result][:diffgram][:saverxresponse][:saverxinfo]
436
+ end
437
+
438
+ def save_simple_encounter(user_id, patient_id, encounter_type, datetime)
439
+ response = magic_action("SaveSimpleEncounter", user_id, patient_id, encounter_type, datetime)
440
+ return response.body[:magic_response][:magic_result][:diffgram][:savesimpleencounterresponse][:savesimpleencounterinfo]
441
+ end
442
+
443
+ def save_simple_rx(user_id, patient_id, med_fav, pharm_id)
444
+ response = magic_action("SaveSimpleRX", user_id, patient_id, med_fav, pharm_id)
445
+ return response.body[:magic_response][:magic_result][:diffgram][:savesimplerxresponse][:savesimplerxinfo]
446
+ end
447
+
448
+ def save_specialist(specialist_xml)
449
+ response = magic_action("SaveSpecialist", nil, nil, specialist_xml)
450
+ return response.body[:magic_response][:magic_result][:diffgram][:savespecialistresponse][:savespecialistinfo]
451
+ end
452
+
453
+ def save_task(patient_id, task_type, target_user, work_object_id, comments)
454
+ response = magic_action("SaveTask", nil, patient_id, task_type, target_user, work_object_id, comments)
455
+ return response.body[:magic_response][:magic_result][:diffgram][:savetaskresponse][:savetaskinfo]
456
+ end
457
+
458
+ def save_task_status(user_id, trans_id, param, delegate_id, comment)
459
+ response = magic_action("SaveTaskStatus", user_id, nil, trans_id, param, delegate_id, comment)
460
+ return response.body[:magic_response][:magic_result][:diffgram][:savetaskstatusresponse][:savetaskstatusinfo]
461
+ end
462
+
463
+ def save_unstructured_document(user_id, trans_id, param, delegate_id, comment)
464
+ response = magic_action("SaveUnstructuredDocument", user_id, nil, trans_id, param, delegate_id, comment)
465
+ return response.body[:magic_response][:magic_result][:diffgram][:saveunstructureddocumentresponse][:saveunstructureddocumentinfo]
466
+ end
467
+
468
+ def save_v10_doc_signature(user_id)
469
+ response = magic_action("SaveV10DocSignature", user_id)
470
+ return response.body[:magic_response][:magic_result][:diffgram][:savev10docsignatureresponse][:saveV10docsignatureinfo]
471
+ end
472
+
473
+ def save_v11_note(user_id, patient_id, input_template_id, xml_params, sign)
474
+ response = magic_action("SaveV11Note", user_id, patient_id, input_template_id, xml_params, sign)
475
+ return response.body[:magic_response][:magic_result][:diffgram][:savev11noteresponse][:savev11noteinfo]
476
+ end
477
+
478
+ def save_vitals(user_id, patient_id, xml)
479
+ response = magic_action("SaveVitals", user_id, patient_id, xml)
480
+ return response.body[:magic_response][:magic_result][:diffgram][:savevitalsresponse][:savevitalsinfo]
481
+ end
482
+
483
+ def search_charge_codes(user_id, patient_id, library, search_string, patient_recent_changes)
484
+ response = magic_action("SearchChargeCodes", user_id, patient_id, library, search_string, patient_recent_changes)
485
+ return response.body[:magic_response][:magic_result][:diffgram][:searchchargecodesresponse][:searchchargecodesinfo]
486
+ end
487
+
488
+ def search_diagnosis_codes(user_id, patient_id, library, search_string, row_count, patient_diagnosis_count)
489
+ response = magic_action("SearchDiagnosisCodes", user_id, patient_id, library, search_string, row_count, patient_diagnosis_count)
490
+ return response.body[:magic_response][:magic_result][:diffgram][:searchdiagnosiscodesresponse][:searchdiagnosiscodesinfo]
491
+ end
492
+
493
+ def search_meds(user_id, patient_id, search)
494
+ response = magic_action("SearchMeds", user_id, patient_id, search)
495
+ return response.body[:magic_response][:magic_result][:diffgram][:searchmedsresponse][:searchmedsinfo]
496
+ end
497
+
498
+ def search_patients(user_id, search)
499
+ response = magic_action("SearchPatients", user_id, nil, search)
500
+ return response.body[:magic_response][:magic_result][:diffgram][:searchpatientsresponse][:searchpatientsinfo]
501
+ end
502
+
503
+ def search_patients_rxhub5(first, last, zip, dob, gender)
504
+ response = magic_action("SearchPatientsRXHub5", nil, nil, first, last, zip, dob, gender)
505
+ return response.body[:magic_response][:magic_result][:diffgram][:searchpatientsrxhub5response][:searchpatientsrxhub5info]
506
+ end
507
+
508
+ def search_pharmacies(user_id, search)
509
+ response = magic_action("SearchPharmacies", user_id, nil, search)
510
+ return response.body[:magic_response][:magic_result][:diffgram][:searchpharmaciesresponse][:searchpharmaciesinfo]
511
+ end
512
+
513
+ def search_problem_codes(user_id, patient_id, library, search)
514
+ response = magic_action("SearchProblemCodes", user_id, patient_id, library, search)
515
+ return response.body[:magic_response][:magic_result][:diffgram][:searchproblemcodesresponse][:searchproblemcodesinfo]
516
+ end
517
+
518
+ def update_encounter
519
+ response = magic_action("UpdateEncounter")
520
+ return response.body[:magic_response][:magic_result][:diffgram][:updateencounterresponse][:updateencounterinfo]
521
+ end
522
+
523
+ def update_referral_order_status(patient_id, trans_id, new_status)
524
+ response = magic_action("UpdateReferralOrderStatus", nil, patient_id, trans_id, new_status)
525
+ return response.body[:magic_response][:magic_result][:diffgram][:updatereferralorderstatusresponse][:updatereferralorderstatusinfo]
526
+ end
527
+
528
+ # def method_missing(name, *args, &block)
529
+ # if name.to_s =~ /^get_(.+)$/
530
+ # run_get_methods($1, *args, &block)
531
+ # else
532
+ # super
533
+ # end
534
+ # end
535
+ #
536
+ # def respond_to?(meth)
537
+ # if meth.to_s =~ /^get_(.+)$/
538
+ # true
539
+ # else
540
+ # super
541
+ # end
542
+ # end
543
+ #
544
+ # # def run_get_methods(attrs, *args, &block)
545
+ # # cameled = attrs.to_s.sub(/^[a-z\d]*/) { inflections.acronyms[$&] || $&.capitalize }
546
+ # # cameled.gsub(/(?:_|(\/))([a-z\d]*)/i) { "#{$1}#{inflections.acronyms[$2] || $2.capitalize}" }.gsub('/', '::')
547
+ # #
548
+ # # symname = attrs.clone.delete("_")
549
+ # # puts "running method missing for Get#{attrs.camelize} with symname #{symname}"
550
+ # # response = magic_action("Get#{attrs.camelize}", nil, *args)
551
+ # # return response.body[:magic_response][:magic_result][:diffgram]["#{symname}response".to_sym]["#{symname}info".to_sym]
552
+ # # end
553
+
554
+ end
555
+ end
@@ -0,0 +1,3 @@
1
+ module Unityapi
2
+ VERSION = "0.0.8"
3
+ end
data/lib/unityapi.rb ADDED
@@ -0,0 +1,4 @@
1
+ module Unityapi
2
+ require 'unityapi/unity_client'
3
+ end
4
+
data/unityapi.gemspec ADDED
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/unityapi/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = "unityapi"
6
+ gem.version = Unityapi::VERSION
7
+ gem.authors = ["Ash Gupta"]
8
+ gem.email = ["ash.gupta@healthfinch.com"]
9
+ gem.description = %q{Unity Enterprise API wrapper}
10
+ gem.summary = %q{This is a ruby wrapper for the Allscripts Unity Enterprise API}
11
+ gem.homepage = ""
12
+ gem.files = `git ls-files`.split($\)
13
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
14
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
+ gem.add_runtime_dependency 'savon', '>= 1.0.0'
16
+ gem.require_paths = ["lib"]
17
+
18
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: unityapi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.8
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ash Gupta
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-27 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: savon
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.0.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.0.0
30
+ description: Unity Enterprise API wrapper
31
+ email:
32
+ - ash.gupta@healthfinch.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - Gemfile
39
+ - LICENSE
40
+ - README.md
41
+ - Rakefile
42
+ - lib/unityapi.rb
43
+ - lib/unityapi/unity_client.rb
44
+ - lib/unityapi/version.rb
45
+ - unityapi.gemspec
46
+ homepage: ''
47
+ licenses: []
48
+ post_install_message:
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubyforge_project:
66
+ rubygems_version: 1.8.24
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: This is a ruby wrapper for the Allscripts Unity Enterprise API
70
+ test_files: []