fhir_client 5.0.3 → 6.0.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 +2 -1
- data/lib/fhir_client/client.rb +55 -13
- 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/version.rb +1 -1
- data/lib/fhir_client/version_management.rb +4 -0
- data/lib/fhir_client.rb +2 -0
- metadata +9 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1ebef998f125ad3c3281c75602cee395f436da883458842f1dfb2fd4b9cbe30
|
4
|
+
data.tar.gz: 2e0ca22b44c4bce9ca869053e75f4899d6cef341861b0bba56a5301c159c3197
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b86936cd0a2d4e8d9a47c762b1e1488297b54d452792ef29d34eb2b8134dbd14c4ba396b373fc7ec8079aee234c80bab5996ae5698237fee39b92fc370fcbc98
|
7
|
+
data.tar.gz: 963ed414219b1ac4a89c3b9b6ef679dbc1704bfe9e9e2d20ffb9d4531507b0511e300a68fc0521c6eeffc34fed1580537266af49ffc51db25daa9c0d8b370f0d
|
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,9 +21,10 @@ 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'
|
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)
|
@@ -275,20 +289,36 @@ module FHIR
|
|
275
289
|
rescue
|
276
290
|
@cached_capability_statement = nil
|
277
291
|
end
|
278
|
-
if @cached_capability_statement.nil? || !@cached_capability_statement.fhirVersion.starts_with?('4')
|
279
|
-
|
292
|
+
if @cached_capability_statement.nil? || !@cached_capability_statement.fhirVersion.starts_with?('4.0')
|
293
|
+
use_r4b
|
280
294
|
begin
|
281
|
-
@cached_capability_statement = parse_reply(FHIR::
|
295
|
+
@cached_capability_statement = parse_reply(FHIR::R4B::CapabilityStatement, frmt, reply)
|
282
296
|
rescue
|
283
297
|
@cached_capability_statement = nil
|
284
298
|
end
|
285
|
-
|
286
|
-
|
299
|
+
if @cached_capability_statement.nil? || !@cached_capability_statement.fhirVersion.starts_with?('4')
|
300
|
+
use_r5
|
287
301
|
begin
|
288
|
-
@cached_capability_statement = parse_reply(FHIR::
|
302
|
+
@cached_capability_statement = parse_reply(FHIR::R5::CapabilityStatement, frmt, reply)
|
289
303
|
rescue
|
290
304
|
@cached_capability_statement = nil
|
291
305
|
end
|
306
|
+
if @cached_capability_statement.nil? || !@cached_capability_statement.fhirVersion.starts_with?('5')
|
307
|
+
use_stu3
|
308
|
+
begin
|
309
|
+
@cached_capability_statement = parse_reply(FHIR::STU3::CapabilityStatement, frmt, reply)
|
310
|
+
rescue
|
311
|
+
@cached_capability_statement = nil
|
312
|
+
end
|
313
|
+
unless @cached_capability_statement
|
314
|
+
use_dstu2
|
315
|
+
begin
|
316
|
+
@cached_capability_statement = parse_reply(FHIR::DSTU2::Conformance, frmt, reply)
|
317
|
+
rescue
|
318
|
+
@cached_capability_statement = nil
|
319
|
+
end
|
320
|
+
end
|
321
|
+
end
|
292
322
|
end
|
293
323
|
end
|
294
324
|
if @cached_capability_statement
|
@@ -317,23 +347,35 @@ module FHIR
|
|
317
347
|
return nil unless [200, 201].include? response.code
|
318
348
|
res =
|
319
349
|
begin
|
320
|
-
if(@fhir_version == :dstu2 || klass
|
350
|
+
if(@fhir_version == :dstu2 || klass < FHIR::DSTU2::Model)
|
321
351
|
if(format.include?('xml'))
|
322
352
|
FHIR::DSTU2::Xml.from_xml(response.body)
|
323
353
|
else
|
324
354
|
FHIR::DSTU2::Json.from_json(response.body)
|
325
355
|
end
|
326
|
-
elsif(@fhir_version == :
|
356
|
+
elsif(@fhir_version == :stu3 || klass < FHIR::STU3::Model)
|
327
357
|
if(format.include?('xml'))
|
328
|
-
FHIR::Xml.from_xml(response.body)
|
358
|
+
FHIR::STU3::Xml.from_xml(response.body)
|
329
359
|
else
|
330
|
-
FHIR::Json.from_json(response.body)
|
360
|
+
FHIR::STU3::Json.from_json(response.body)
|
361
|
+
end
|
362
|
+
elsif(@fhir_version == :r4b || klass < FHIR::R4B::Model)
|
363
|
+
if(format.include?('xml'))
|
364
|
+
FHIR::R4B::Xml.from_xml(response.body)
|
365
|
+
else
|
366
|
+
FHIR::R4B::Json.from_json(response.body)
|
367
|
+
end
|
368
|
+
elsif(@fhir_version == :r5 || klass < FHIR::R5::Model)
|
369
|
+
if(format.include?('xml'))
|
370
|
+
FHIR::R5::Xml.from_xml(response.body)
|
371
|
+
else
|
372
|
+
FHIR::R5::Json.from_json(response.body)
|
331
373
|
end
|
332
374
|
else
|
333
375
|
if(format.include?('xml'))
|
334
|
-
FHIR::
|
376
|
+
FHIR::Xml.from_xml(response.body)
|
335
377
|
else
|
336
|
-
FHIR::
|
378
|
+
FHIR::Json.from_json(response.body)
|
337
379
|
end
|
338
380
|
end
|
339
381
|
rescue => e
|
@@ -349,7 +391,7 @@ module FHIR
|
|
349
391
|
|
350
392
|
resource.client = self
|
351
393
|
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)
|
394
|
+
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
395
|
element.client = self
|
354
396
|
end
|
355
397
|
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
|
data/lib/fhir_client/version.rb
CHANGED
data/lib/fhir_client.rb
CHANGED
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fhir_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andre Quina
|
8
8
|
- Jason Walonoski
|
9
9
|
- Robert Scanlon
|
10
10
|
- Reece Adamson
|
11
|
-
autorequire:
|
11
|
+
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2024-10-18 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
|
@@ -287,7 +287,7 @@ homepage: https://github.com/fhir-crucible/fhir_client
|
|
287
287
|
licenses:
|
288
288
|
- Apache-2.0
|
289
289
|
metadata: {}
|
290
|
-
post_install_message:
|
290
|
+
post_install_message:
|
291
291
|
rdoc_options: []
|
292
292
|
require_paths:
|
293
293
|
- lib
|
@@ -295,16 +295,15 @@ 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
|
-
|
307
|
-
signing_key:
|
305
|
+
rubygems_version: 3.3.7
|
306
|
+
signing_key:
|
308
307
|
specification_version: 4
|
309
308
|
summary: A Gem for handling FHIR client requests in ruby
|
310
309
|
test_files: []
|