fhir_client 4.0.4 → 4.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -2
- data/README.md +7 -2
- data/fhir_client.gemspec +3 -2
- data/lib/fhir_client.rb +5 -0
- data/lib/fhir_client/client.rb +5 -0
- data/lib/fhir_client/sections/search.rb +10 -22
- data/lib/fhir_client/version.rb +1 -1
- metadata +11 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7031a100f52d6a39207aeb7d33cd6f891ffd20f9fc920455bffcf7c18939a573
|
4
|
+
data.tar.gz: eea574c3405cf4796b81af0c828169e59e53371fa26862a35756fb5c430d2e91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b456acf0953615754397c38f1b5bd4c05d8150f41a73f9269dc005f4829c5001c2eae92d5f8e3600e56d9c330178d67231bca4ee6d39f7a235081fa7c655afa
|
7
|
+
data.tar.gz: 637593dc2f61702e28a2853b1cb073dc7af8ebe12bfca4f1f3b33fac88e0766370a0a1218106ac6ded1393398bd2ba7fedd2d05192a8c4dcd25e8e1e2830d07d
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -151,9 +151,14 @@ client.destroy(FHIR::Patient, patient_id)
|
|
151
151
|
|
152
152
|
### Searching
|
153
153
|
```ruby
|
154
|
+
# via GET
|
154
155
|
reply = client.search(FHIR::Patient, search: {parameters: {name: 'P'}})
|
156
|
+
|
157
|
+
# via POST
|
158
|
+
reply = client.search(FHIR::Patient, search: {body: {name: 'P'}})
|
159
|
+
|
155
160
|
bundle = reply.resource
|
156
|
-
patient = bundle
|
161
|
+
patient = bundle&.entry&.first&.resource
|
157
162
|
```
|
158
163
|
|
159
164
|
### Fetching a Bundle
|
@@ -215,7 +220,7 @@ end
|
|
215
220
|
|
216
221
|
# License
|
217
222
|
|
218
|
-
Copyright 2014-
|
223
|
+
Copyright 2014-2022 The MITRE Corporation
|
219
224
|
|
220
225
|
Licensed under the Apache License, Version 2.0 (the "License");
|
221
226
|
you may not use this file except in compliance with the License.
|
data/fhir_client.gemspec
CHANGED
@@ -6,8 +6,9 @@ require 'fhir_client/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'fhir_client'
|
8
8
|
spec.version = FHIR::Client::VERSION
|
9
|
-
spec.authors = ['Andre Quina', 'Jason Walonoski', '
|
9
|
+
spec.authors = ['Andre Quina', 'Jason Walonoski', 'Robert Scanlon', 'Reece Adamson']
|
10
10
|
spec.email = ['jwalonoski@mitre.org']
|
11
|
+
spec.licenses = ['Apache-2.0']
|
11
12
|
|
12
13
|
spec.summary = %q{A Gem for handling FHIR client requests in ruby}
|
13
14
|
spec.description = %q{A Gem for handling FHIR client requests in ruby}
|
@@ -32,7 +33,7 @@ Gem::Specification.new do |spec|
|
|
32
33
|
spec.add_dependency 'tilt', '>= 1.1'
|
33
34
|
|
34
35
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
35
|
-
spec.add_development_dependency 'rake', '
|
36
|
+
spec.add_development_dependency 'rake', '>= 12.3.3'
|
36
37
|
spec.add_development_dependency 'pry'
|
37
38
|
spec.add_development_dependency 'webmock'
|
38
39
|
spec.add_development_dependency 'test-unit'
|
data/lib/fhir_client.rb
CHANGED
@@ -3,6 +3,11 @@ require 'fhir_dstu2_models'
|
|
3
3
|
require 'fhir_stu3_models'
|
4
4
|
require 'active_support/all'
|
5
5
|
|
6
|
+
# Default to INFO level logging for all FHIR namespaced logging. Since there is
|
7
|
+
# no single gem that 'owns' the FHIR namespace, we use the client as the spot
|
8
|
+
# to set the default. Otherwise the default is set to DEBUG, which is too high.
|
9
|
+
FHIR.logger.level = Logger::INFO
|
10
|
+
|
6
11
|
root = File.expand_path '.', File.dirname(File.absolute_path(__FILE__))
|
7
12
|
Dir.glob(File.join(root, 'fhir_client', 'sections', '**', '*.rb')).each do |file|
|
8
13
|
require file
|
data/lib/fhir_client/client.rb
CHANGED
@@ -374,6 +374,7 @@ module FHIR
|
|
374
374
|
end
|
375
375
|
|
376
376
|
# Extract the request payload in the specified format, defaults to XML
|
377
|
+
# Note that the payload is usually a resource, but could be a form post for searches depending on content type
|
377
378
|
def request_payload(resource, headers)
|
378
379
|
if headers
|
379
380
|
format_specified = headers['Content-Type']
|
@@ -383,6 +384,10 @@ module FHIR
|
|
383
384
|
resource.to_xml
|
384
385
|
elsif format_specified.downcase.include?('json')
|
385
386
|
resource.to_json
|
387
|
+
elsif format_specified.downcase == 'application/x-www-form-urlencoded'
|
388
|
+
# Special case where this is a search body and not a resource.
|
389
|
+
# Leave as hash because underlying libraries automatically URL encode it.
|
390
|
+
resource
|
386
391
|
else
|
387
392
|
resource.to_xml
|
388
393
|
end
|
@@ -12,40 +12,28 @@ module FHIR
|
|
12
12
|
options[:resource] = klass
|
13
13
|
options[:format] = format
|
14
14
|
|
15
|
-
reply = if options
|
16
|
-
post resource_url(options), nil, fhir_headers({content_type: 'application/x-www-form-urlencoded'})
|
17
|
-
else
|
15
|
+
reply = if options.dig(:search, :flag).nil? && options.dig(:search, :body).nil?
|
18
16
|
get resource_url(options), fhir_headers
|
17
|
+
else
|
18
|
+
options[:search][:flag] = true
|
19
|
+
post resource_url(options), options.dig(:search, :body), fhir_headers({content_type: 'application/x-www-form-urlencoded'})
|
19
20
|
end
|
20
|
-
|
21
|
+
|
21
22
|
reply.resource = parse_reply(klass, format, reply)
|
22
23
|
reply.resource_class = klass
|
23
24
|
reply
|
24
25
|
end
|
25
26
|
|
27
|
+
# It does not appear that this is part of the specification (any more?)
|
28
|
+
# Investigate removing in next major version.
|
26
29
|
def search_existing(klass, id, options = {}, format = @default_format)
|
27
|
-
options
|
28
|
-
|
29
|
-
reply = if options[:search] && options[:search][:flag]
|
30
|
-
post resource_url(options), nil, fhir_headers({content_type: 'application/x-www-form-urlencoded'})
|
31
|
-
else
|
32
|
-
get resource_url(options), fhir_headers
|
33
|
-
end
|
34
|
-
reply.resource = parse_reply(klass, format, reply)
|
35
|
-
reply.resource_class = klass
|
36
|
-
reply
|
30
|
+
options[:id] = id
|
31
|
+
search(klass, options, format)
|
37
32
|
end
|
38
33
|
|
39
34
|
def search_all(options = {}, format = @default_format)
|
40
35
|
options[:format] = format
|
41
|
-
|
42
|
-
post resource_url(options), nil, fhir_headers({content_type: 'application/x-www-form-urlencoded'})
|
43
|
-
else
|
44
|
-
get resource_url(options), fhir_headers
|
45
|
-
end
|
46
|
-
reply.resource = parse_reply(nil, format, reply)
|
47
|
-
reply.resource_class = nil
|
48
|
-
reply
|
36
|
+
search(nil, options, format)
|
49
37
|
end
|
50
38
|
end
|
51
39
|
end
|
data/lib/fhir_client/version.rb
CHANGED
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fhir_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andre Quina
|
8
8
|
- Jason Walonoski
|
9
|
-
-
|
9
|
+
- Robert Scanlon
|
10
|
+
- Reece Adamson
|
10
11
|
autorequire:
|
11
12
|
bindir: exe
|
12
13
|
cert_chain: []
|
13
|
-
date:
|
14
|
+
date: 2021-03-31 00:00:00.000000000 Z
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
16
17
|
name: activesupport
|
@@ -170,16 +171,16 @@ dependencies:
|
|
170
171
|
name: rake
|
171
172
|
requirement: !ruby/object:Gem::Requirement
|
172
173
|
requirements:
|
173
|
-
- - "
|
174
|
+
- - ">="
|
174
175
|
- !ruby/object:Gem::Version
|
175
|
-
version:
|
176
|
+
version: 12.3.3
|
176
177
|
type: :development
|
177
178
|
prerelease: false
|
178
179
|
version_requirements: !ruby/object:Gem::Requirement
|
179
180
|
requirements:
|
180
|
-
- - "
|
181
|
+
- - ">="
|
181
182
|
- !ruby/object:Gem::Version
|
182
|
-
version:
|
183
|
+
version: 12.3.3
|
183
184
|
- !ruby/object:Gem::Dependency
|
184
185
|
name: pry
|
185
186
|
requirement: !ruby/object:Gem::Requirement
|
@@ -283,7 +284,8 @@ files:
|
|
283
284
|
- lib/fhir_client/version.rb
|
284
285
|
- lib/fhir_client/version_management.rb
|
285
286
|
homepage: https://github.com/fhir-crucible/fhir_client
|
286
|
-
licenses:
|
287
|
+
licenses:
|
288
|
+
- Apache-2.0
|
287
289
|
metadata: {}
|
288
290
|
post_install_message:
|
289
291
|
rdoc_options: []
|
@@ -300,8 +302,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
300
302
|
- !ruby/object:Gem::Version
|
301
303
|
version: '0'
|
302
304
|
requirements: []
|
303
|
-
|
304
|
-
rubygems_version: 2.7.6.2
|
305
|
+
rubygems_version: 3.1.4
|
305
306
|
signing_key:
|
306
307
|
specification_version: 4
|
307
308
|
summary: A Gem for handling FHIR client requests in ruby
|