super_ehr 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/super_ehr.rb +89 -81
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 09cbd1262f2e3563f2343d3e5f08fd2a5c38c7ff
|
|
4
|
+
data.tar.gz: 130a27d74cb74971dd33b0d8ea36116bc894f843
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a025572ec3658d09641518d61422475d5d6bb87baaefa2d5920827ce72b4f4f13df0d0b1769b707a5a8c261b7b2e832c9983a3b9a9de035376fcfc1434e234e8
|
|
7
|
+
data.tar.gz: 6927eae6a99973faf579a0b4c54aea7b6ec99849be7985fc2eec04491b54b6beee602ba0d17c2679011a895b20e34880015970fbee453e60f26a4cdfca7ddcee
|
data/lib/super_ehr.rb
CHANGED
|
@@ -25,7 +25,7 @@ module SuperEHR
|
|
|
25
25
|
return {}
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
def get_request_headers
|
|
28
|
+
def get_request_headers
|
|
29
29
|
return {}
|
|
30
30
|
end
|
|
31
31
|
|
|
@@ -42,11 +42,9 @@ module SuperEHR
|
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
# make a HTTP request
|
|
45
|
-
def make_request(request_type, endpoint, request_params={}, use_default_params=true,
|
|
46
|
-
to_json=true)
|
|
47
|
-
|
|
45
|
+
def make_request(request_type, endpoint, request_params={}, use_default_params=true, to_json=true)
|
|
48
46
|
if use_default_params
|
|
49
|
-
params = get_default_params
|
|
47
|
+
params = get_default_params
|
|
50
48
|
params = params.merge(request_params)
|
|
51
49
|
else
|
|
52
50
|
params = request_params
|
|
@@ -112,9 +110,7 @@ module SuperEHR
|
|
|
112
110
|
|
|
113
111
|
### API SPECIFIC HOUSEKEEPING ###
|
|
114
112
|
|
|
115
|
-
def initialize(ehr_username, ehr_password='',
|
|
116
|
-
app_username, app_password, app_name,
|
|
117
|
-
using_touchworks)
|
|
113
|
+
def initialize(ehr_username, ehr_password='', app_username, app_password, app_name, using_touchworks)
|
|
118
114
|
|
|
119
115
|
# convert these to environment variables
|
|
120
116
|
@app_username = app_username
|
|
@@ -136,8 +132,8 @@ module SuperEHR
|
|
|
136
132
|
|
|
137
133
|
def get_default_params
|
|
138
134
|
return {:Action => '', :AppUserID => @ehr_username, :Appname => @app_name,
|
|
139
|
-
:PatientID => '', :Token => refresh_token,
|
|
140
|
-
:Parameter1 => '', :Parameter2 => '', :Parameter3 => '',
|
|
135
|
+
:PatientID => '', :Token => refresh_token,
|
|
136
|
+
:Parameter1 => '', :Parameter2 => '', :Parameter3 => '',
|
|
141
137
|
:Parameter4 => '', :Parameter5 => '', :Parameter6 => '', :Data => ''}
|
|
142
138
|
end
|
|
143
139
|
|
|
@@ -199,7 +195,7 @@ module SuperEHR
|
|
|
199
195
|
end
|
|
200
196
|
end
|
|
201
197
|
end
|
|
202
|
-
return patients
|
|
198
|
+
return patients
|
|
203
199
|
end
|
|
204
200
|
|
|
205
201
|
## UPLOAD PDF IMPLEMENTATION ##
|
|
@@ -217,14 +213,14 @@ module SuperEHR
|
|
|
217
213
|
# first call to push the contents
|
|
218
214
|
save_pdf_xml = create_pdf_xml_params(first_name, last_name,
|
|
219
215
|
filepath, file.size, 0, "false", "", "0")
|
|
220
|
-
params = {:Action => 'SaveDocumentImage', :PatientID => patient_id,
|
|
216
|
+
params = {:Action => 'SaveDocumentImage', :PatientID => patient_id,
|
|
221
217
|
:Parameter1 => save_pdf_xml, :Parameter6 => buffer}
|
|
222
218
|
out = make_request("POST", "json/MagicJson", params)
|
|
223
219
|
# second call to push file information and wrap up upload
|
|
224
220
|
doc_guid = out[0]["savedocumentimageinfo"][0]["documentVar"].to_s
|
|
225
221
|
save_pdf_xml = create_pdf_xml_params(first_name, last_name,
|
|
226
222
|
filepath, file.size, 0, "true", doc_guid, "0")
|
|
227
|
-
params = {:Action => 'SaveDocumentImage', :PatientID => patient_id,
|
|
223
|
+
params = {:Action => 'SaveDocumentImage', :PatientID => patient_id,
|
|
228
224
|
:Parameter1 => save_pdf_xml, :Parameter6 => nil}
|
|
229
225
|
out = make_request("POST", "json/MagicJson", params)
|
|
230
226
|
return out
|
|
@@ -245,14 +241,14 @@ module SuperEHR
|
|
|
245
241
|
b.item :name => "vendorFileName", :value => file_name
|
|
246
242
|
b.item :name => "ahsEncounterID", :value => 0
|
|
247
243
|
b.item :name => "ownerCode", :value => get_provider_entry_code.strip
|
|
248
|
-
b.item :name => "organizationName", :value => organization_name
|
|
244
|
+
b.item :name => "organizationName", :value => organization_name
|
|
249
245
|
b.item :name => "patientFirstName", :value => first_name
|
|
250
246
|
b.item :name => "patientLastName", :value => last_name
|
|
251
247
|
end
|
|
252
248
|
return xml.target!
|
|
253
249
|
end
|
|
254
250
|
|
|
255
|
-
private
|
|
251
|
+
private
|
|
256
252
|
|
|
257
253
|
# necessary to create the xml params for upload_document
|
|
258
254
|
def get_provider_entry_code()
|
|
@@ -276,10 +272,10 @@ module SuperEHR
|
|
|
276
272
|
|
|
277
273
|
def initialize(version, key, secret, practice_id)
|
|
278
274
|
@uri = URI.parse('https://api.athenahealth.com/')
|
|
279
|
-
@version = version
|
|
280
|
-
@key = key
|
|
281
|
-
@secret = secret
|
|
282
|
-
@practiceid = practice_id
|
|
275
|
+
@version = version
|
|
276
|
+
@key = key
|
|
277
|
+
@secret = secret
|
|
278
|
+
@practiceid = practice_id
|
|
283
279
|
end
|
|
284
280
|
|
|
285
281
|
def get_request_headers
|
|
@@ -290,7 +286,7 @@ module SuperEHR
|
|
|
290
286
|
return "#{@uri}/#{@version}/#{@practiceid}/#{endpoint}"
|
|
291
287
|
end
|
|
292
288
|
|
|
293
|
-
def refresh_token
|
|
289
|
+
def refresh_token
|
|
294
290
|
auth_paths = {
|
|
295
291
|
'vi' => 'oauth',
|
|
296
292
|
'preview1' => 'oauthpreview',
|
|
@@ -303,7 +299,7 @@ module SuperEHR
|
|
|
303
299
|
params = {:grant_type => "client_credentials"}
|
|
304
300
|
response = HTTParty.post(url, :body => params, :basic_auth => auth)
|
|
305
301
|
|
|
306
|
-
return response["access_token"]
|
|
302
|
+
return response["access_token"]
|
|
307
303
|
end
|
|
308
304
|
|
|
309
305
|
|
|
@@ -328,9 +324,8 @@ module SuperEHR
|
|
|
328
324
|
end
|
|
329
325
|
|
|
330
326
|
# start_date needs to be in mm/dd/yyyy
|
|
331
|
-
# returns a list of patient ids that have been changed since start_date
|
|
332
|
-
def get_changed_patients_ids(start_date,
|
|
333
|
-
end_date=Time.new.strftime("%m/%d/%Y %H:%M:%S"))
|
|
327
|
+
# returns a list of patient ids that have been changed since start_date
|
|
328
|
+
def get_changed_patients_ids(start_date, end_date=Time.new.strftime("%m/%d/%Y %H:%M:%S"))
|
|
334
329
|
subscribe = make_request("GET", "patients/changed/subscription", {})
|
|
335
330
|
if subscribe.has_key?("status") and subscribe["status"] == "ACTIVE"
|
|
336
331
|
response = make_request("GET", "patients/changed",
|
|
@@ -349,7 +344,7 @@ module SuperEHR
|
|
|
349
344
|
end
|
|
350
345
|
|
|
351
346
|
def get_scheduled_patients(date, department_id=1)
|
|
352
|
-
response = make_request("GET", "appointments/booked",
|
|
347
|
+
response = make_request("GET", "appointments/booked",
|
|
353
348
|
{:departmentid => department_id, :startdate => date, :enddate => date})
|
|
354
349
|
patients = []
|
|
355
350
|
if not response["appointments"].empty?
|
|
@@ -357,7 +352,7 @@ module SuperEHR
|
|
|
357
352
|
patients << scheduled_patient
|
|
358
353
|
end
|
|
359
354
|
end
|
|
360
|
-
return patients
|
|
355
|
+
return patients
|
|
361
356
|
end
|
|
362
357
|
|
|
363
358
|
# might have issues if patient is in multiple departments
|
|
@@ -365,7 +360,7 @@ module SuperEHR
|
|
|
365
360
|
endpoint = "patients/#{patient_id}/documents"
|
|
366
361
|
headers = { 'Authorization' => "Bearer #{refresh_token}" }
|
|
367
362
|
url = "#{@uri}/#{@version}/#{@practiceid}/#{endpoint}"
|
|
368
|
-
params = {
|
|
363
|
+
params = {
|
|
369
364
|
:departmentid => department_id != -1 ? department_id : get_patient(patient_id)["departmentid"],
|
|
370
365
|
:attachmentcontents => File.new(filepath),
|
|
371
366
|
:documentsubclass => "CLINICALDOCUMENT",
|
|
@@ -380,28 +375,34 @@ module SuperEHR
|
|
|
380
375
|
end
|
|
381
376
|
|
|
382
377
|
class DrChronoAPI < BaseEHR
|
|
378
|
+
attr_reader :access_token, :refresh_token
|
|
383
379
|
|
|
384
380
|
### API SPECIFIC HOUSEKEEPING ###
|
|
385
381
|
|
|
386
382
|
def initialize(args={})
|
|
387
|
-
params = {:access_code => '',
|
|
388
|
-
|
|
383
|
+
params = {:access_code => '',
|
|
384
|
+
:access_token => '',
|
|
385
|
+
:refresh_token => '',
|
|
386
|
+
:client_id => '',
|
|
387
|
+
:client_secret => '',
|
|
388
|
+
:redirect_uri => ''
|
|
389
|
+
}
|
|
389
390
|
params = params.merge(args)
|
|
390
391
|
if (params[:access_code] == '' && (params[:access_token] == '' || params[:refresh_token] == ''))
|
|
391
|
-
raise ArgumentError, "
|
|
392
|
+
raise ArgumentError, "Access Code='#{params[:access_code]}' is blank or one or more of Access Token='#{params[:access_token]}', Refresh Token='#{params[:refresh_token]}' is blank"
|
|
392
393
|
end
|
|
393
394
|
@access_code = params[:access_code]
|
|
394
395
|
@client_id = params[:client_id]
|
|
395
396
|
@client_secret = params[:client_secret]
|
|
396
|
-
@redirect_uri = params[:redirect_uri]
|
|
397
|
-
@access_token = params[:access_token]
|
|
398
|
-
@refresh_token = params[:refresh_token]
|
|
397
|
+
@redirect_uri = params[:redirect_uri]
|
|
398
|
+
@access_token = params[:access_token]
|
|
399
|
+
@refresh_token = params[:refresh_token]
|
|
399
400
|
@uri = URI.parse("https://drchrono.com")
|
|
400
|
-
|
|
401
|
+
exchange_token
|
|
401
402
|
end
|
|
402
403
|
|
|
403
404
|
def get_request_headers
|
|
404
|
-
return { 'Authorization' => "Bearer #{
|
|
405
|
+
return { 'Authorization' => "Bearer #{@access_token}"}
|
|
405
406
|
end
|
|
406
407
|
|
|
407
408
|
def get_request_url(endpoint)
|
|
@@ -416,44 +417,6 @@ module SuperEHR
|
|
|
416
417
|
return @refresh_token
|
|
417
418
|
end
|
|
418
419
|
|
|
419
|
-
def refresh_token
|
|
420
|
-
if @refresh_token == ''
|
|
421
|
-
post_args = {:code => @access_code,
|
|
422
|
-
:grant_type => "authorization_code",
|
|
423
|
-
:redirect_uri => @redirect_uri,
|
|
424
|
-
:client_id => @client_id,
|
|
425
|
-
:client_secret => @client_secret}
|
|
426
|
-
response = HTTParty.post(get_request_url("o/token/"),
|
|
427
|
-
:body => post_args)
|
|
428
|
-
@refresh_token = response["refresh_token"]
|
|
429
|
-
@access_token = response["access_token"]
|
|
430
|
-
return response["access_token"]
|
|
431
|
-
else
|
|
432
|
-
post_args = {:refresh_token => @refresh_token,
|
|
433
|
-
:grant_type => "refresh_token",
|
|
434
|
-
:redirect_uri => @redirect_uri,
|
|
435
|
-
:client_id => @client_id,
|
|
436
|
-
:client_secret => @client_secret}
|
|
437
|
-
response = HTTParty.post(get_request_url("o/token/"),
|
|
438
|
-
:body => post_args)
|
|
439
|
-
@refresh_token = response["refresh_token"]
|
|
440
|
-
@access_token = response["access_token"]
|
|
441
|
-
return response["access_token"]
|
|
442
|
-
end
|
|
443
|
-
|
|
444
|
-
end
|
|
445
|
-
|
|
446
|
-
def chrono_request(endpoint, params={})
|
|
447
|
-
result = []
|
|
448
|
-
while endpoint
|
|
449
|
-
data = make_request("GET", endpoint, params)
|
|
450
|
-
if data["results"]
|
|
451
|
-
result = result | data["results"]
|
|
452
|
-
end
|
|
453
|
-
endpoint = data["next"]
|
|
454
|
-
end
|
|
455
|
-
return result
|
|
456
|
-
end
|
|
457
420
|
|
|
458
421
|
### API CALLS ###
|
|
459
422
|
|
|
@@ -471,13 +434,15 @@ module SuperEHR
|
|
|
471
434
|
|
|
472
435
|
def get_patients(params={})
|
|
473
436
|
patient_url = 'api/patients'
|
|
474
|
-
return chrono_request(patient_url, params)
|
|
437
|
+
return chrono_request(patient_url, params)
|
|
475
438
|
end
|
|
476
439
|
|
|
477
|
-
def get_changed_patients(
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
440
|
+
def get_changed_patients(date)
|
|
441
|
+
if self.class != SuperEHR::DrChronoAPI
|
|
442
|
+
date = date.gsub(/\//, '-')
|
|
443
|
+
date = Date.strptime(date, '%m-%d-%Y').ios8601
|
|
444
|
+
end
|
|
445
|
+
return get_patients({:since => date})
|
|
481
446
|
end
|
|
482
447
|
|
|
483
448
|
def get_changed_patients_ids(ts)
|
|
@@ -504,16 +469,59 @@ module SuperEHR
|
|
|
504
469
|
:date => Time.now.strftime("%Y-%m-%d") << " 00:00:00",
|
|
505
470
|
:document => File.new(filepath)
|
|
506
471
|
}
|
|
507
|
-
response = HTTMultiParty.post(url, :body => params, :headers => headers)
|
|
472
|
+
response = HTTMultiParty.post(url, :body => params, :headers => headers)
|
|
508
473
|
return response
|
|
509
474
|
end
|
|
510
475
|
|
|
476
|
+
private
|
|
477
|
+
|
|
478
|
+
def chrono_request(endpoint, params={})
|
|
479
|
+
result = []
|
|
480
|
+
while endpoint
|
|
481
|
+
data = make_request("GET", endpoint, params)
|
|
482
|
+
if data["results"]
|
|
483
|
+
result = result | data["results"]
|
|
484
|
+
end
|
|
485
|
+
endpoint = data["next"]
|
|
486
|
+
end
|
|
487
|
+
return result
|
|
488
|
+
end
|
|
489
|
+
|
|
490
|
+
def exchange_token
|
|
491
|
+
if @refresh_token == '' || @refresh_token == nil
|
|
492
|
+
post_args = {
|
|
493
|
+
"code" => @access_code,
|
|
494
|
+
"grant_type" => "authorization_code",
|
|
495
|
+
"redirect_uri" => @redirect_uri,
|
|
496
|
+
"client_id" => @client_id,
|
|
497
|
+
"client_secret" => @client_secret
|
|
498
|
+
}
|
|
499
|
+
response = HTTParty.post(get_request_url("o/token/"),
|
|
500
|
+
:body => post_args)
|
|
501
|
+
@refresh_token = response["refresh_token"]
|
|
502
|
+
@access_token = response["access_token"]
|
|
503
|
+
return response["access_token"]
|
|
504
|
+
else
|
|
505
|
+
post_args = {
|
|
506
|
+
"refresh_token" => @refresh_token,
|
|
507
|
+
"grant_type" => "refresh_token",
|
|
508
|
+
"redirect_uri" => @redirect_uri,
|
|
509
|
+
"client_id" => @client_id,
|
|
510
|
+
"client_secret" => @client_secret
|
|
511
|
+
}
|
|
512
|
+
response = HTTParty.post(get_request_url("o/token/"),
|
|
513
|
+
:body => post_args)
|
|
514
|
+
@refresh_token = response["refresh_token"]
|
|
515
|
+
@access_token = response["access_token"]
|
|
516
|
+
return response["access_token"]
|
|
517
|
+
end
|
|
518
|
+
end
|
|
511
519
|
end
|
|
512
520
|
|
|
513
|
-
def self.allscripts(ehr_username, ehr_password,
|
|
521
|
+
def self.allscripts(ehr_username, ehr_password,
|
|
514
522
|
app_username, app_password, app_name,
|
|
515
523
|
using_touchworks)
|
|
516
|
-
return AllScriptsAPI.new(ehr_username, ehr_password,
|
|
524
|
+
return AllScriptsAPI.new(ehr_username, ehr_password,
|
|
517
525
|
app_username, app_password, app_name,
|
|
518
526
|
using_touchworks)
|
|
519
527
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: super_ehr
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brian Su
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-05-
|
|
11
|
+
date: 2015-05-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: This project generalizes EHR integrations with various EHR vendors. Currently
|
|
14
14
|
supports Allscripts, Athena, and DrChrono.
|