fhir_client 1.6.0 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{test/simplecov.rb → .simplecov} +0 -0
- data/Gemfile.lock +9 -8
- data/fhir_client.gemspec +3 -2
- data/lib/client_interface.rb +26 -26
- data/lib/fhir_client.rb +0 -4
- data/test/test_helper.rb +1 -1
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f523acfa3330a69197b1ca3a12bf1eda98ee484
|
4
|
+
data.tar.gz: 0ae134593aed324e36d059d47562f7d20123edf3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 780f5ebb17b33e0446aad7e9d8a522697a7329274074eb58fa5efcbb5f7818ae5b8175b64187df75a922a6030ae91e682d5422de016163c13c643dd0e4bde5db
|
7
|
+
data.tar.gz: d06d7f38225109b2b153536e8ae005cfc736b0b5e760944f4bad1c1ec3fc11cb2a0b032da78f086e5407687cb5c061d7b78767d937178a63c26740d80cede051
|
File without changes
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fhir_client (1.6.
|
4
|
+
fhir_client (1.6.1)
|
5
5
|
activesupport (>= 3)
|
6
6
|
addressable (>= 2.3)
|
7
|
-
fhir_models (>= 1.6.
|
7
|
+
fhir_models (>= 1.6.1)
|
8
8
|
oauth2 (~> 1.1)
|
9
|
+
rack (~> 1.6)
|
9
10
|
rest-client (~> 1.8)
|
10
11
|
tilt (>= 1.1)
|
11
12
|
|
@@ -30,7 +31,7 @@ GEM
|
|
30
31
|
unf (>= 0.0.5, < 1.0.0)
|
31
32
|
faraday (0.9.2)
|
32
33
|
multipart-post (>= 1.2, < 3)
|
33
|
-
fhir_models (1.6.
|
34
|
+
fhir_models (1.6.1)
|
34
35
|
bcp47 (>= 0.3)
|
35
36
|
date_time_precision (>= 0.8)
|
36
37
|
mime-types (>= 1.16, < 3)
|
@@ -39,7 +40,7 @@ GEM
|
|
39
40
|
http-cookie (1.0.2)
|
40
41
|
domain_name (~> 0.5)
|
41
42
|
i18n (0.7.0)
|
42
|
-
json (
|
43
|
+
json (2.0.2)
|
43
44
|
jwt (1.5.4)
|
44
45
|
method_source (0.8.2)
|
45
46
|
mime-types (2.99.2)
|
@@ -69,9 +70,9 @@ GEM
|
|
69
70
|
http-cookie (>= 1.0.2, < 2.0)
|
70
71
|
mime-types (>= 1.16, < 3.0)
|
71
72
|
netrc (~> 0.7)
|
72
|
-
simplecov (0.
|
73
|
+
simplecov (0.12.0)
|
73
74
|
docile (~> 1.1.0)
|
74
|
-
json (
|
75
|
+
json (>= 1.8, < 3)
|
75
76
|
simplecov-html (~> 0.10.0)
|
76
77
|
simplecov-html (0.10.0)
|
77
78
|
slop (3.6.0)
|
@@ -80,7 +81,7 @@ GEM
|
|
80
81
|
turn (0.9.7)
|
81
82
|
ansi
|
82
83
|
minitest (~> 4)
|
83
|
-
tzinfo (0.3.
|
84
|
+
tzinfo (0.3.51)
|
84
85
|
unf (0.1.4)
|
85
86
|
unf_ext
|
86
87
|
unf_ext (0.0.7.2)
|
@@ -97,4 +98,4 @@ DEPENDENCIES
|
|
97
98
|
turn
|
98
99
|
|
99
100
|
BUNDLED WITH
|
100
|
-
1.
|
101
|
+
1.12.5
|
data/fhir_client.gemspec
CHANGED
@@ -7,16 +7,17 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.email = "aquina@mitre.org"
|
8
8
|
s.homepage = "https://github.com/hl7-fhir/fhir-svn"
|
9
9
|
s.authors = ["Andre Quina", "Jason Walonoski", "Janoo Fernandes"]
|
10
|
-
s.version = '1.6.
|
10
|
+
s.version = '1.6.1'
|
11
11
|
|
12
12
|
s.files = s.files = `git ls-files`.split("\n")
|
13
13
|
|
14
|
-
s.add_dependency 'fhir_models', '>= 1.6.
|
14
|
+
s.add_dependency 'fhir_models', '>= 1.6.1'
|
15
15
|
s.add_dependency 'tilt', '>= 1.1'
|
16
16
|
s.add_dependency 'rest-client', '~> 1.8'
|
17
17
|
s.add_dependency 'oauth2', '~> 1.1'
|
18
18
|
s.add_dependency 'activesupport', '>= 3'
|
19
19
|
s.add_dependency 'addressable', '>= 2.3'
|
20
|
+
s.add_dependency 'rack', '~> 1.6'
|
20
21
|
s.add_development_dependency 'pry'
|
21
22
|
end
|
22
23
|
|
data/lib/client_interface.rb
CHANGED
@@ -30,7 +30,7 @@ module FHIR
|
|
30
30
|
# @return
|
31
31
|
#
|
32
32
|
def initialize(baseServiceUrl)
|
33
|
-
|
33
|
+
FHIR.logger.info "Initializing client with #{@baseServiceUrl}"
|
34
34
|
@baseServiceUrl = baseServiceUrl
|
35
35
|
@use_format_param = false
|
36
36
|
@default_format = FHIR::Formats::ResourceFormat::RESOURCE_XML
|
@@ -40,7 +40,7 @@ module FHIR
|
|
40
40
|
|
41
41
|
# Set the client to use no authentication mechanisms
|
42
42
|
def set_no_auth
|
43
|
-
|
43
|
+
FHIR.logger.info "Configuring the client to use no authentication."
|
44
44
|
@use_oauth2_auth = false
|
45
45
|
@use_basic_auth = false
|
46
46
|
@security_headers = {}
|
@@ -49,7 +49,7 @@ module FHIR
|
|
49
49
|
|
50
50
|
# Set the client to use HTTP Basic Authentication
|
51
51
|
def set_basic_auth(client,secret)
|
52
|
-
|
52
|
+
FHIR.logger.info "Configuring the client to use HTTP Basic authentication."
|
53
53
|
token = Base64.encode64("#{client}:#{secret}")
|
54
54
|
value = "Basic #{token}"
|
55
55
|
@security_headers = { 'Authorization' => value }
|
@@ -60,7 +60,7 @@ module FHIR
|
|
60
60
|
|
61
61
|
# Set the client to use Bearer Token Authentication
|
62
62
|
def set_bearer_token(token)
|
63
|
-
|
63
|
+
FHIR.logger.info "Configuring the client to use Bearer Token authentication."
|
64
64
|
value = "Bearer #{token}"
|
65
65
|
@security_headers = { 'Authorization' => value }
|
66
66
|
@use_oauth2_auth = false
|
@@ -74,7 +74,7 @@ module FHIR
|
|
74
74
|
# authorizePath -- absolute path of authorization endpoint
|
75
75
|
# tokenPath -- absolute path of token endpoint
|
76
76
|
def set_oauth2_auth(client,secret,authorizePath,tokenPath)
|
77
|
-
|
77
|
+
FHIR.logger.info "Configuring the client to use OpenID Connect OAuth2 authentication."
|
78
78
|
@use_oauth2_auth = true
|
79
79
|
@use_basic_auth = false
|
80
80
|
@security_headers = {}
|
@@ -146,7 +146,7 @@ module FHIR
|
|
146
146
|
end
|
147
147
|
end
|
148
148
|
rescue Exception => e
|
149
|
-
|
149
|
+
FHIR.logger.error 'Failed to locate SMART-on-FHIR OAuth2 Security Extensions.'
|
150
150
|
end
|
151
151
|
options.delete_if{|k,v|v.nil?}
|
152
152
|
options.clear if options.keys.size!=2
|
@@ -199,15 +199,15 @@ module FHIR
|
|
199
199
|
end
|
200
200
|
|
201
201
|
def parse_reply(klass, format, response)
|
202
|
-
|
202
|
+
FHIR.logger.info "Parsing response with {klass: #{klass}, format: #{format}, code: #{response.code}}."
|
203
203
|
return nil if ![200,201].include? response.code
|
204
204
|
res = nil
|
205
205
|
begin
|
206
206
|
res = FHIR.from_contents(response.body)
|
207
207
|
res.client = self if !res.nil?
|
208
|
-
|
208
|
+
FHIR.logger.warn "Expected #{klass} but got #{res.class}" if res.class!=klass
|
209
209
|
rescue Exception => e
|
210
|
-
|
210
|
+
FHIR.logger.error "Failed to parse #{format} as resource #{klass}: #{e.message} %n #{e.backtrace.join("\n")} #{response}"
|
211
211
|
nil
|
212
212
|
end
|
213
213
|
res
|
@@ -290,7 +290,7 @@ module FHIR
|
|
290
290
|
|
291
291
|
def get(path, headers)
|
292
292
|
url = URI(build_url(path)).to_s
|
293
|
-
|
293
|
+
FHIR.logger.info "GETTING: #{url}"
|
294
294
|
headers = clean_headers(headers)
|
295
295
|
if @use_oauth2_auth
|
296
296
|
# @client.refresh!
|
@@ -311,7 +311,7 @@ module FHIR
|
|
311
311
|
:headers => response.headers,
|
312
312
|
:body => response.body
|
313
313
|
}
|
314
|
-
|
314
|
+
FHIR.logger.info "GET - Request: #{req.to_s}, Response: #{response.body.force_encoding("UTF-8")}"
|
315
315
|
@reply = FHIR::ClientReply.new(req, res)
|
316
316
|
else
|
317
317
|
headers.merge!(@security_headers) if @use_basic_auth
|
@@ -321,7 +321,7 @@ module FHIR
|
|
321
321
|
response = e.response if e.response
|
322
322
|
end
|
323
323
|
|
324
|
-
|
324
|
+
FHIR.logger.info "GET - Request: #{response.request.to_json}, Response: #{response.body.force_encoding("UTF-8")}"
|
325
325
|
response.request.args[:path] = response.request.args[:url].gsub(@baseServiceUrl,'')
|
326
326
|
headers = response.headers.inject({}){ |h,(k,v)| h[k.to_s.gsub('_','-')] = v.to_s; h}
|
327
327
|
res = {
|
@@ -336,7 +336,7 @@ module FHIR
|
|
336
336
|
|
337
337
|
def post(path, resource, headers)
|
338
338
|
url = URI(build_url(path)).to_s
|
339
|
-
|
339
|
+
FHIR.logger.info "POSTING: #{url}"
|
340
340
|
headers = clean_headers(headers)
|
341
341
|
payload = request_payload(resource, headers) if resource
|
342
342
|
if @use_oauth2_auth
|
@@ -358,12 +358,12 @@ module FHIR
|
|
358
358
|
:headers => response.headers,
|
359
359
|
:body => response.body
|
360
360
|
}
|
361
|
-
|
361
|
+
FHIR.logger.info "POST - Request: #{req.to_s}, Response: #{response.body.force_encoding("UTF-8")}"
|
362
362
|
@reply = FHIR::ClientReply.new(req, res)
|
363
363
|
else
|
364
364
|
headers.merge!(@security_headers) if @use_basic_auth
|
365
365
|
@client.post(url, payload, headers){ |response, request, result|
|
366
|
-
|
366
|
+
FHIR.logger.info "POST - Request: #{request.to_json}, Response: #{response.force_encoding("UTF-8")}"
|
367
367
|
request.args[:path] = url.gsub(@baseServiceUrl,'')
|
368
368
|
res = {
|
369
369
|
:code => result.code,
|
@@ -377,7 +377,7 @@ module FHIR
|
|
377
377
|
|
378
378
|
def put(path, resource, headers)
|
379
379
|
url = URI(build_url(path)).to_s
|
380
|
-
|
380
|
+
FHIR.logger.info "PUTTING: #{url}"
|
381
381
|
headers = clean_headers(headers)
|
382
382
|
payload = request_payload(resource, headers) if resource
|
383
383
|
if @use_oauth2_auth
|
@@ -399,12 +399,12 @@ module FHIR
|
|
399
399
|
:headers => response.headers,
|
400
400
|
:body => response.body
|
401
401
|
}
|
402
|
-
|
402
|
+
FHIR.logger.info "PUT - Request: #{req.to_s}, Response: #{response.body.force_encoding("UTF-8")}"
|
403
403
|
@reply = FHIR::ClientReply.new(req, res)
|
404
404
|
else
|
405
405
|
headers.merge!(@security_headers) if @use_basic_auth
|
406
406
|
@client.put(url, payload, headers){ |response, request, result|
|
407
|
-
|
407
|
+
FHIR.logger.info "PUT - Request: #{request.to_json}, Response: #{response.force_encoding("UTF-8")}"
|
408
408
|
request.args[:path] = url.gsub(@baseServiceUrl,'')
|
409
409
|
res = {
|
410
410
|
:code => result.code,
|
@@ -418,7 +418,7 @@ module FHIR
|
|
418
418
|
|
419
419
|
def patch(path, patchset, headers)
|
420
420
|
url = URI(build_url(path)).to_s
|
421
|
-
|
421
|
+
FHIR.logger.info "PATCHING: #{url}"
|
422
422
|
headers = clean_headers(headers)
|
423
423
|
payload = request_patch_payload(patchset, headers['format'])
|
424
424
|
if @use_oauth2_auth
|
@@ -440,13 +440,13 @@ module FHIR
|
|
440
440
|
:headers => response.headers,
|
441
441
|
:body => response.body
|
442
442
|
}
|
443
|
-
|
443
|
+
FHIR.logger.info "PATCH - Request: #{req.to_s}, Response: #{response.body.force_encoding("UTF-8")}"
|
444
444
|
@reply = FHIR::ClientReply.new(req, res)
|
445
445
|
else
|
446
446
|
headers.merge!(@security_headers) if @use_basic_auth
|
447
447
|
# url = 'http://requestb.in/o8juy3o8'
|
448
448
|
@client.patch(url, payload, headers){ |response, request, result|
|
449
|
-
|
449
|
+
FHIR.logger.info "PATCH - Request: #{request.to_json}, Response: #{response.force_encoding("UTF-8")}"
|
450
450
|
request.args[:path] = url.gsub(@baseServiceUrl,'')
|
451
451
|
res = {
|
452
452
|
:code => result.code,
|
@@ -460,7 +460,7 @@ module FHIR
|
|
460
460
|
|
461
461
|
def delete(path, headers)
|
462
462
|
url = URI(build_url(path)).to_s
|
463
|
-
|
463
|
+
FHIR.logger.info "DELETING: #{url}"
|
464
464
|
headers = clean_headers(headers)
|
465
465
|
if @use_oauth2_auth
|
466
466
|
# @client.refresh!
|
@@ -481,12 +481,12 @@ module FHIR
|
|
481
481
|
:headers => response.headers,
|
482
482
|
:body => response.body
|
483
483
|
}
|
484
|
-
|
484
|
+
FHIR.logger.info "DELETE - Request: #{req.to_s}, Response: #{response.body.force_encoding("UTF-8")}"
|
485
485
|
@reply = FHIR::ClientReply.new(req, res)
|
486
486
|
else
|
487
487
|
headers.merge!(@security_headers) if @use_basic_auth
|
488
488
|
@client.delete(url, headers){ |response, request, result|
|
489
|
-
|
489
|
+
FHIR.logger.info "DELETE - Request: #{request.to_json}, Response: #{response.force_encoding("UTF-8")}"
|
490
490
|
request.args[:path] = url.gsub(@baseServiceUrl,'')
|
491
491
|
res = {
|
492
492
|
:code => result.code,
|
@@ -501,9 +501,9 @@ module FHIR
|
|
501
501
|
def head(path, headers)
|
502
502
|
headers.merge!(@security_headers) unless @security_headers.blank?
|
503
503
|
url = URI(build_url(path)).to_s
|
504
|
-
|
504
|
+
FHIR.logger.info "HEADING: #{url}"
|
505
505
|
RestClient.head(url, headers){ |response, request, result|
|
506
|
-
|
506
|
+
FHIR.logger.info "HEAD - Request: #{request.to_json}, Response: #{response.force_encoding("UTF-8")}"
|
507
507
|
request.args[:path] = url.gsub(@baseServiceUrl,'')
|
508
508
|
res = {
|
509
509
|
:code => result.code,
|
data/lib/fhir_client.rb
CHANGED
@@ -9,10 +9,6 @@ require 'addressable/uri'
|
|
9
9
|
require 'oauth2'
|
10
10
|
require 'active_support/core_ext'
|
11
11
|
|
12
|
-
# Simple and verbose loggers
|
13
|
-
RestClient.log = Logger.new("fhir_client.log", 10, 1024000)
|
14
|
-
$LOG = Logger.new("fhir_client_verbose.log", 10, 1024000)
|
15
|
-
|
16
12
|
root = File.expand_path '..', File.dirname(File.absolute_path(__FILE__))
|
17
13
|
Dir.glob(File.join(root, 'lib','sections','**','*.rb')).each do |file|
|
18
14
|
require file
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fhir_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andre Quina
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-08-
|
13
|
+
date: 2016-08-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: fhir_models
|
@@ -18,14 +18,14 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.6.
|
21
|
+
version: 1.6.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - '>='
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: 1.6.
|
28
|
+
version: 1.6.1
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: tilt
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -96,6 +96,20 @@ dependencies:
|
|
96
96
|
- - '>='
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
version: '2.3'
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
name: rack
|
101
|
+
requirement: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ~>
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '1.6'
|
106
|
+
type: :runtime
|
107
|
+
prerelease: false
|
108
|
+
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ~>
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '1.6'
|
99
113
|
- !ruby/object:Gem::Dependency
|
100
114
|
name: pry
|
101
115
|
requirement: !ruby/object:Gem::Requirement
|
@@ -117,6 +131,7 @@ extensions: []
|
|
117
131
|
extra_rdoc_files: []
|
118
132
|
files:
|
119
133
|
- .gitignore
|
134
|
+
- .simplecov
|
120
135
|
- .travis.yml
|
121
136
|
- Gemfile
|
122
137
|
- Gemfile.lock
|
@@ -149,7 +164,6 @@ files:
|
|
149
164
|
- test/fixtures/bundle-example.xml
|
150
165
|
- test/fixtures/parameters-example.json
|
151
166
|
- test/fixtures/parameters-example.xml
|
152
|
-
- test/simplecov.rb
|
153
167
|
- test/test_helper.rb
|
154
168
|
- test/unit/basic_test.rb
|
155
169
|
- test/unit/bundle_test.rb
|