fhir_client 5.0.3 → 6.1.0
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/.github/workflows/ruby.yml +1 -1
- data/.rubocop.yml +1 -7
- data/.rubocop_todo.yml +1 -13
- data/Gemfile +1 -1
- data/README.md +7 -3
- data/fhir_client.gemspec +3 -2
- data/lib/fhir_client/client.rb +58 -15
- data/lib/fhir_client/ext/bundle.rb +16 -0
- data/lib/fhir_client/ext/model.rb +16 -0
- data/lib/fhir_client/ext/reference.rb +28 -4
- data/lib/fhir_client/fhir_api_validation.json +1 -1
- data/lib/fhir_client/version.rb +1 -1
- data/lib/fhir_client/version_management.rb +4 -0
- data/lib/fhir_client.rb +2 -0
- metadata +8 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cbe2b0477f5b2802f5b80e989c206b5cc00b5a6c28c1388a2c76fa0e5241b228
|
|
4
|
+
data.tar.gz: 1534d137bb8c1f15cf7ba84daed51b676ae92d93ee9f898798f681443fbc4059
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 674637e8bc356bf26565b500468482496cc261e8ad4a609ba7bca66f216856ee4bf2a249aa20804c6c6e8867b6f5cbd9bbf7a6e17e2d86242e1f410e032b7a5f
|
|
7
|
+
data.tar.gz: 6ccd4138d23100ca210ffd0a6f1c241023a642146b7a5048d7916fa1e1ae5e52deff07c67c7480c4373f85cd476979349b86c75344933b274034108567d59cb6
|
data/.github/workflows/ruby.yml
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
inherit_from: .rubocop_todo.yml
|
|
2
2
|
|
|
3
3
|
AllCops:
|
|
4
|
-
TargetRubyVersion:
|
|
4
|
+
TargetRubyVersion: 3.0
|
|
5
5
|
Exclude:
|
|
6
6
|
- '*.gemspec'
|
|
7
7
|
- 'Gemfile*'
|
|
@@ -10,9 +10,6 @@ AllCops:
|
|
|
10
10
|
- 'lib/tasks/*'
|
|
11
11
|
- 'vendor/**/*'
|
|
12
12
|
|
|
13
|
-
Documentation:
|
|
14
|
-
Enabled: false
|
|
15
|
-
|
|
16
13
|
Metrics:
|
|
17
14
|
Enabled: false
|
|
18
15
|
|
|
@@ -22,8 +19,5 @@ Style:
|
|
|
22
19
|
Layout:
|
|
23
20
|
Enabled: false
|
|
24
21
|
|
|
25
|
-
Performance/Casecmp:
|
|
26
|
-
Enabled: false
|
|
27
|
-
|
|
28
22
|
Naming:
|
|
29
23
|
Enabled: false
|
data/.rubocop_todo.yml
CHANGED
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on
|
|
3
|
+
# on 2024-10-14 14:56:48 UTC using RuboCop version 1.23.0.
|
|
4
4
|
# The point is for the user to remove these configuration records
|
|
5
5
|
# one by one as the offenses are removed from the code base.
|
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
|
8
|
-
|
|
9
|
-
# Offense count: 4
|
|
10
|
-
# Cop supports --auto-correct.
|
|
11
|
-
Performance/RegexpMatch:
|
|
12
|
-
Exclude:
|
|
13
|
-
- 'lib/fhir_client/model/client_reply.rb'
|
|
14
|
-
|
|
15
|
-
# Offense count: 197
|
|
16
|
-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
|
17
|
-
# URISchemes: http, https
|
|
18
|
-
Metrics/LineLength:
|
|
19
|
-
Max: 210
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Ruby FHIR client.
|
|
4
4
|
|
|
5
5
|
Supports:
|
|
6
|
-
* FHIR R4, STU3 and DSTU2
|
|
6
|
+
* FHIR R5, R4B, R4, STU3 and DSTU2
|
|
7
7
|
* JSON and XML
|
|
8
8
|
* All CRUD, including version read and history
|
|
9
9
|
* Transactions and Batches
|
|
@@ -59,7 +59,7 @@ patient.destroy
|
|
|
59
59
|
## Advanced Usage
|
|
60
60
|
|
|
61
61
|
### Changing FHIR Versions
|
|
62
|
-
The client defaults to `R4` but can be switched to
|
|
62
|
+
The client defaults to `R4` but can be switched to other versions. It can also attempt to autodetect the FHIR version based on the `metadata` endpoint.
|
|
63
63
|
|
|
64
64
|
```ruby
|
|
65
65
|
# autodetect the FHIR version
|
|
@@ -71,6 +71,10 @@ elsif version == :dstu2
|
|
|
71
71
|
puts 'FHIR Client using DSTU2'
|
|
72
72
|
elsif version == :r4
|
|
73
73
|
puts 'FHIR Client using R4'
|
|
74
|
+
elsif version == :r4b
|
|
75
|
+
puts 'FHIR Client using R4B'
|
|
76
|
+
elsif
|
|
77
|
+
puts 'FHIR Client using R5'
|
|
74
78
|
end
|
|
75
79
|
|
|
76
80
|
# tell the client to use R4
|
|
@@ -79,7 +83,7 @@ client.use_r4
|
|
|
79
83
|
patient = FHIR::Patient.read('example')
|
|
80
84
|
patient = client.read(FHIR::Patient, 'example').resource
|
|
81
85
|
|
|
82
|
-
# tell the client to use STU3
|
|
86
|
+
# tell the client to use STU3
|
|
83
87
|
client.use_stu3
|
|
84
88
|
# now use the client normally
|
|
85
89
|
patient = FHIR::STU3::Patient.read('example')
|
data/fhir_client.gemspec
CHANGED
|
@@ -21,13 +21,14 @@ Gem::Specification.new do |spec|
|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
22
22
|
spec.require_paths = ['lib']
|
|
23
23
|
|
|
24
|
+
spec.required_ruby_version = '>= 3.0.0'
|
|
24
25
|
spec.add_dependency 'activesupport', '>= 3'
|
|
25
26
|
spec.add_dependency 'addressable', '>= 2.3'
|
|
26
|
-
spec.add_dependency 'fhir_models', '>=
|
|
27
|
+
spec.add_dependency 'fhir_models', '>= 5.0.0'
|
|
27
28
|
spec.add_dependency 'fhir_stu3_models', '>= 3.1.1'
|
|
28
29
|
spec.add_dependency 'fhir_dstu2_models', '>= 1.1.1'
|
|
29
30
|
spec.add_dependency 'nokogiri', '>= 1.10.4'
|
|
30
|
-
spec.add_dependency 'oauth2', '~>
|
|
31
|
+
spec.add_dependency 'oauth2', '~> 2.0'
|
|
31
32
|
spec.add_dependency 'rack', '>= 1.5'
|
|
32
33
|
spec.add_dependency 'rest-client', '~> 2.0'
|
|
33
34
|
spec.add_dependency 'tilt', '>= 1.1'
|
data/lib/fhir_client/client.rb
CHANGED
|
@@ -77,6 +77,16 @@ module FHIR
|
|
|
77
77
|
@default_format = versioned_format_class
|
|
78
78
|
end
|
|
79
79
|
|
|
80
|
+
def use_r4b
|
|
81
|
+
@fhir_version = :r4b
|
|
82
|
+
@default_format = versioned_format_class
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def use_r5
|
|
86
|
+
@fhir_version = :r5
|
|
87
|
+
@default_format = versioned_format_class
|
|
88
|
+
end
|
|
89
|
+
|
|
80
90
|
#
|
|
81
91
|
# Instructs the client to specify the minimal Prefer Header where applicable
|
|
82
92
|
def use_minimal_preference
|
|
@@ -95,6 +105,10 @@ module FHIR
|
|
|
95
105
|
cap = capability_statement
|
|
96
106
|
if cap.is_a?(FHIR::CapabilityStatement)
|
|
97
107
|
use_r4
|
|
108
|
+
elsif cap.is_a?(FHIR::R4B::CapabilityStatement)
|
|
109
|
+
use_r4b
|
|
110
|
+
elsif cap.is_a?(FHIR::R5::CapabilityStatement)
|
|
111
|
+
use_r5
|
|
98
112
|
elsif cap.is_a?(FHIR::STU3::CapabilityStatement)
|
|
99
113
|
use_stu3
|
|
100
114
|
elsif cap.is_a?(FHIR::DSTU2::Conformance)
|
|
@@ -158,10 +172,11 @@ module FHIR
|
|
|
158
172
|
site: site || @base_service_url,
|
|
159
173
|
authorize_url: authorize_path,
|
|
160
174
|
token_url: token_path,
|
|
161
|
-
raise_errors: true
|
|
175
|
+
raise_errors: true,
|
|
176
|
+
auth_scheme: :request_body
|
|
162
177
|
}
|
|
178
|
+
options[:connection_opts] = { proxy: proxy } unless proxy.nil?
|
|
163
179
|
client = OAuth2::Client.new(client, secret, options)
|
|
164
|
-
client.connection.proxy(proxy) unless proxy.nil?
|
|
165
180
|
@client = client.client_credentials.get_token
|
|
166
181
|
end
|
|
167
182
|
|
|
@@ -275,20 +290,36 @@ module FHIR
|
|
|
275
290
|
rescue
|
|
276
291
|
@cached_capability_statement = nil
|
|
277
292
|
end
|
|
278
|
-
if @cached_capability_statement.nil? || !@cached_capability_statement.fhirVersion.starts_with?('4')
|
|
279
|
-
|
|
293
|
+
if @cached_capability_statement.nil? || !@cached_capability_statement.fhirVersion.starts_with?('4.0')
|
|
294
|
+
use_r4b
|
|
280
295
|
begin
|
|
281
|
-
@cached_capability_statement = parse_reply(FHIR::
|
|
296
|
+
@cached_capability_statement = parse_reply(FHIR::R4B::CapabilityStatement, frmt, reply)
|
|
282
297
|
rescue
|
|
283
298
|
@cached_capability_statement = nil
|
|
284
299
|
end
|
|
285
|
-
|
|
286
|
-
|
|
300
|
+
if @cached_capability_statement.nil? || !@cached_capability_statement.fhirVersion.starts_with?('4')
|
|
301
|
+
use_r5
|
|
287
302
|
begin
|
|
288
|
-
@cached_capability_statement = parse_reply(FHIR::
|
|
303
|
+
@cached_capability_statement = parse_reply(FHIR::R5::CapabilityStatement, frmt, reply)
|
|
289
304
|
rescue
|
|
290
305
|
@cached_capability_statement = nil
|
|
291
306
|
end
|
|
307
|
+
if @cached_capability_statement.nil? || !@cached_capability_statement.fhirVersion.starts_with?('5')
|
|
308
|
+
use_stu3
|
|
309
|
+
begin
|
|
310
|
+
@cached_capability_statement = parse_reply(FHIR::STU3::CapabilityStatement, frmt, reply)
|
|
311
|
+
rescue
|
|
312
|
+
@cached_capability_statement = nil
|
|
313
|
+
end
|
|
314
|
+
unless @cached_capability_statement
|
|
315
|
+
use_dstu2
|
|
316
|
+
begin
|
|
317
|
+
@cached_capability_statement = parse_reply(FHIR::DSTU2::Conformance, frmt, reply)
|
|
318
|
+
rescue
|
|
319
|
+
@cached_capability_statement = nil
|
|
320
|
+
end
|
|
321
|
+
end
|
|
322
|
+
end
|
|
292
323
|
end
|
|
293
324
|
end
|
|
294
325
|
if @cached_capability_statement
|
|
@@ -317,23 +348,35 @@ module FHIR
|
|
|
317
348
|
return nil unless [200, 201].include? response.code
|
|
318
349
|
res =
|
|
319
350
|
begin
|
|
320
|
-
if(@fhir_version == :dstu2 || klass
|
|
351
|
+
if(@fhir_version == :dstu2 || klass < FHIR::DSTU2::Model)
|
|
321
352
|
if(format.include?('xml'))
|
|
322
353
|
FHIR::DSTU2::Xml.from_xml(response.body)
|
|
323
354
|
else
|
|
324
355
|
FHIR::DSTU2::Json.from_json(response.body)
|
|
325
356
|
end
|
|
326
|
-
elsif(@fhir_version == :
|
|
357
|
+
elsif(@fhir_version == :stu3 || klass < FHIR::STU3::Model)
|
|
327
358
|
if(format.include?('xml'))
|
|
328
|
-
FHIR::Xml.from_xml(response.body)
|
|
359
|
+
FHIR::STU3::Xml.from_xml(response.body)
|
|
329
360
|
else
|
|
330
|
-
FHIR::Json.from_json(response.body)
|
|
361
|
+
FHIR::STU3::Json.from_json(response.body)
|
|
362
|
+
end
|
|
363
|
+
elsif(@fhir_version == :r4b || klass < FHIR::R4B::Model)
|
|
364
|
+
if(format.include?('xml'))
|
|
365
|
+
FHIR::R4B::Xml.from_xml(response.body)
|
|
366
|
+
else
|
|
367
|
+
FHIR::R4B::Json.from_json(response.body)
|
|
368
|
+
end
|
|
369
|
+
elsif(@fhir_version == :r5 || klass < FHIR::R5::Model)
|
|
370
|
+
if(format.include?('xml'))
|
|
371
|
+
FHIR::R5::Xml.from_xml(response.body)
|
|
372
|
+
else
|
|
373
|
+
FHIR::R5::Json.from_json(response.body)
|
|
331
374
|
end
|
|
332
375
|
else
|
|
333
376
|
if(format.include?('xml'))
|
|
334
|
-
FHIR::
|
|
377
|
+
FHIR::Xml.from_xml(response.body)
|
|
335
378
|
else
|
|
336
|
-
FHIR::
|
|
379
|
+
FHIR::Json.from_json(response.body)
|
|
337
380
|
end
|
|
338
381
|
end
|
|
339
382
|
rescue => e
|
|
@@ -349,7 +392,7 @@ module FHIR
|
|
|
349
392
|
|
|
350
393
|
resource.client = self
|
|
351
394
|
resource.each_element do |element, _, _|
|
|
352
|
-
if element.is_a?(Reference) || element.is_a?(STU3::Reference) || element.is_a?(DSTU2::Reference) || element.respond_to?(:resourceType)
|
|
395
|
+
if element.is_a?(Reference) || element.is_a?(FHIR::R4B::Reference) || element.is_a?(FHIR::R5::Reference) || element.is_a?(STU3::Reference) || element.is_a?(DSTU2::Reference) || element.respond_to?(:resourceType)
|
|
353
396
|
element.client = self
|
|
354
397
|
end
|
|
355
398
|
end
|
|
@@ -67,4 +67,20 @@ module FHIR
|
|
|
67
67
|
include FHIR::BundleExtras
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
module FHIR
|
|
73
|
+
module R4B
|
|
74
|
+
class Bundle < FHIR::R4B::Model
|
|
75
|
+
include FHIR::BundleExtras
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
module FHIR
|
|
81
|
+
module R5
|
|
82
|
+
class Bundle < FHIR::R5::Model
|
|
83
|
+
include FHIR::BundleExtras
|
|
84
|
+
end
|
|
85
|
+
end
|
|
70
86
|
end
|
|
@@ -144,3 +144,19 @@ module FHIR
|
|
|
144
144
|
end
|
|
145
145
|
end
|
|
146
146
|
end
|
|
147
|
+
|
|
148
|
+
module FHIR
|
|
149
|
+
module R4B
|
|
150
|
+
class Model < FHIR::Model
|
|
151
|
+
include FHIR::ModelExtras
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
module FHIR
|
|
157
|
+
module R5
|
|
158
|
+
class Model < FHIR::Model
|
|
159
|
+
include FHIR::ModelExtras
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
end
|
|
@@ -82,7 +82,7 @@ module FHIR
|
|
|
82
82
|
include FHIR::ReferenceExtras
|
|
83
83
|
|
|
84
84
|
def resource_class
|
|
85
|
-
|
|
85
|
+
FHIR.const_get(resource_type) unless contained?
|
|
86
86
|
end
|
|
87
87
|
end
|
|
88
88
|
end
|
|
@@ -93,7 +93,7 @@ module FHIR
|
|
|
93
93
|
include FHIR::ReferenceExtras
|
|
94
94
|
|
|
95
95
|
def resource_class
|
|
96
|
-
|
|
96
|
+
FHIR::DSTU2.const_get(resource_type) unless contained?
|
|
97
97
|
end
|
|
98
98
|
end
|
|
99
99
|
end
|
|
@@ -101,12 +101,36 @@ end
|
|
|
101
101
|
|
|
102
102
|
module FHIR
|
|
103
103
|
module STU3
|
|
104
|
-
class Reference
|
|
104
|
+
class Reference
|
|
105
|
+
include FHIR::ReferenceExtras
|
|
106
|
+
|
|
107
|
+
def resource_class
|
|
108
|
+
FHIR::STU3.const_get(resource_type) unless contained?
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
module FHIR
|
|
115
|
+
module R4B
|
|
116
|
+
class Reference < FHIR::R4B::Model
|
|
105
117
|
include FHIR::ReferenceExtras
|
|
106
118
|
|
|
107
119
|
def resource_class
|
|
108
|
-
|
|
120
|
+
FHIR::R4B.const_get(resource_type) unless contained?
|
|
109
121
|
end
|
|
110
122
|
end
|
|
111
123
|
end
|
|
112
124
|
end
|
|
125
|
+
|
|
126
|
+
module FHIR
|
|
127
|
+
module R5
|
|
128
|
+
class Reference < FHIR::R5::Model
|
|
129
|
+
include FHIR::ReferenceExtras
|
|
130
|
+
|
|
131
|
+
def resource_class
|
|
132
|
+
FHIR::R5.const_get(resource_type) unless contained?
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|
|
@@ -344,7 +344,7 @@
|
|
|
344
344
|
"Accept": "optional",
|
|
345
345
|
"Prefer": false
|
|
346
346
|
},
|
|
347
|
-
"body": { "regex": "([
|
|
347
|
+
"body": { "regex": "([\\w\\-]+(=[\\w\\-.:\\/\\|]*)?(&[\\w\\-]+(=[\\w\\-.:\\/\\|]*)?)*)?" }
|
|
348
348
|
},
|
|
349
349
|
"response": {
|
|
350
350
|
"status": [200],
|
data/lib/fhir_client/version.rb
CHANGED
data/lib/fhir_client.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:
|
|
4
|
+
version: 6.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andre Quina
|
|
@@ -11,7 +11,7 @@ authors:
|
|
|
11
11
|
autorequire:
|
|
12
12
|
bindir: exe
|
|
13
13
|
cert_chain: []
|
|
14
|
-
date:
|
|
14
|
+
date: 2026-03-13 00:00:00.000000000 Z
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
17
17
|
name: activesupport
|
|
@@ -47,14 +47,14 @@ dependencies:
|
|
|
47
47
|
requirements:
|
|
48
48
|
- - ">="
|
|
49
49
|
- !ruby/object:Gem::Version
|
|
50
|
-
version:
|
|
50
|
+
version: 5.0.0
|
|
51
51
|
type: :runtime
|
|
52
52
|
prerelease: false
|
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
|
54
54
|
requirements:
|
|
55
55
|
- - ">="
|
|
56
56
|
- !ruby/object:Gem::Version
|
|
57
|
-
version:
|
|
57
|
+
version: 5.0.0
|
|
58
58
|
- !ruby/object:Gem::Dependency
|
|
59
59
|
name: fhir_stu3_models
|
|
60
60
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -103,14 +103,14 @@ dependencies:
|
|
|
103
103
|
requirements:
|
|
104
104
|
- - "~>"
|
|
105
105
|
- !ruby/object:Gem::Version
|
|
106
|
-
version: '
|
|
106
|
+
version: '2.0'
|
|
107
107
|
type: :runtime
|
|
108
108
|
prerelease: false
|
|
109
109
|
version_requirements: !ruby/object:Gem::Requirement
|
|
110
110
|
requirements:
|
|
111
111
|
- - "~>"
|
|
112
112
|
- !ruby/object:Gem::Version
|
|
113
|
-
version: '
|
|
113
|
+
version: '2.0'
|
|
114
114
|
- !ruby/object:Gem::Dependency
|
|
115
115
|
name: rack
|
|
116
116
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -295,15 +295,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
295
295
|
requirements:
|
|
296
296
|
- - ">="
|
|
297
297
|
- !ruby/object:Gem::Version
|
|
298
|
-
version:
|
|
298
|
+
version: 3.0.0
|
|
299
299
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
300
300
|
requirements:
|
|
301
301
|
- - ">="
|
|
302
302
|
- !ruby/object:Gem::Version
|
|
303
303
|
version: '0'
|
|
304
304
|
requirements: []
|
|
305
|
-
|
|
306
|
-
rubygems_version: 2.7.6.2
|
|
305
|
+
rubygems_version: 3.5.22
|
|
307
306
|
signing_key:
|
|
308
307
|
specification_version: 4
|
|
309
308
|
summary: A Gem for handling FHIR client requests in ruby
|