Skip to content

Commit 0301ce0

Browse files
authored
Merge pull request #56 from fhir-crucible/update_1_8
Update client to FHIR v1.8
2 parents 03003d1 + ec888f7 commit 0301ce0

File tree

6 files changed

+16
-219
lines changed

6 files changed

+16
-219
lines changed

fhir_client.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
2222

2323
spec.add_dependency 'activesupport', '>= 3'
2424
spec.add_dependency 'addressable', '>= 2.3'
25-
spec.add_dependency 'fhir_models', '>= 1.6.8'
25+
spec.add_dependency 'fhir_models', '>= 1.8.0'
2626
spec.add_dependency 'nokogiri'
2727
spec.add_dependency 'oauth2', '~> 1.1'
2828
spec.add_dependency 'rack', '>= 1.5'

lib/fhir_client/client.rb

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Client
2323

2424
attr_accessor :default_format
2525

26-
attr_accessor :cached_conformance
26+
attr_accessor :cached_capability_statement
2727

2828
# Call method to initialize FHIR client. This method must be invoked
2929
# with a valid base server URL prior to using the client.
@@ -98,9 +98,9 @@ def set_oauth2_auth(client, secret, authorize_path, token_path)
9898
@client = client.client_credentials.get_token
9999
end
100100

101-
# Get the OAuth2 server and endpoints from the conformance statement
101+
# Get the OAuth2 server and endpoints from the capability statement
102102
# (the server should not require OAuth2 or other special security to access
103-
# the conformance statement).
103+
# the capability statement).
104104
# <rest>
105105
# <mode value="server"/>
106106
# <documentation value="All the functionality defined in FHIR"/>
@@ -134,8 +134,7 @@ def get_oauth2_metadata_from_conformance
134134
authorize_extension = 'authorize'
135135
token_extension = 'token'
136136
begin
137-
conformance = conformance_statement
138-
conformance.rest.each do |rest|
137+
capability_statement.rest.each do |rest|
139138
rest.security.service.each do |service|
140139
service.coding.each do |coding|
141140
next unless coding.code == 'SMART-on-FHIR'
@@ -170,10 +169,10 @@ def capability_statement(format = @default_format)
170169
# Method returns a conformance statement for the system queried.
171170
# @return
172171
def conformance_statement(format = @default_format)
173-
if @cached_conformance.nil? || format != @default_format
172+
if @cached_capability_statement.nil? || format != @default_format
174173
try_conformance_formats(format)
175174
end
176-
@cached_conformance
175+
@cached_capability_statement
177176
end
178177

179178
def try_conformance_formats(default_format)
@@ -185,13 +184,13 @@ def try_conformance_formats(default_format)
185184
'application/json']
186185
formats.insert(0, default_format)
187186

188-
@cached_conformance = nil
187+
@cached_capability_statement = nil
189188
@default_format = nil
190189

191190
formats.each do |frmt|
192191
reply = get 'metadata', fhir_headers(format: frmt)
193192
next unless reply.code == 200
194-
@cached_conformance = parse_reply(FHIR::Conformance, frmt, reply)
193+
@cached_capability_statement = parse_reply(FHIR::CapabilityStatement, frmt, reply)
195194
@default_format = frmt
196195
break
197196
end

lib/fhir_client/fhir_api_validation.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
"body": false
128128
},
129129
"response": {
130-
"status": [200,403],
130+
"status": [200,401],
131131
"headers": {
132132
"Content-Type": true,
133133
"Location": false,
@@ -149,7 +149,7 @@
149149
"body": "form data"
150150
},
151151
"response": {
152-
"status": [200,403],
152+
"status": [200,401],
153153
"headers": {
154154
"Content-Type": true,
155155
"Location": false,
@@ -160,7 +160,7 @@
160160
}
161161
},{
162162
"interaction": "search-all",
163-
"path": ["/_search?"],
163+
"path": ["?"],
164164
"verb": "GET",
165165
"request": {
166166
"headers": {
@@ -171,7 +171,7 @@
171171
"body": false
172172
},
173173
"response": {
174-
"status": [200,403],
174+
"status": [200,401],
175175
"headers": {
176176
"Content-Type": true,
177177
"Location": false,
@@ -181,7 +181,7 @@
181181
"body": { "types": ["Bundle"] }
182182
}
183183
},{
184-
"interaction": "conformance",
184+
"interaction": "capabilities",
185185
"path": ["/","/metadata"],
186186
"verb": ["GET","OPTIONS"],
187187
"request": {
@@ -200,7 +200,7 @@
200200
"ETag": false,
201201
"Last-Modified": false
202202
},
203-
"body": { "types": ["Conformance"] }
203+
"body": { "types": ["CapabilityStatement"] }
204204
}
205205
},{
206206
"interaction": "transaction",

lib/fhir_client/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module FHIR
22
class Client
3-
VERSION = '1.6.10'
3+
VERSION = '1.8.0'
44
end
55
end

test/fixtures/conformance-example.json

Lines changed: 0 additions & 191 deletions
This file was deleted.

test/unit/capability_statement_test.rb

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,6 @@ def client
55
@client ||= FHIR::Client.new('capability-test')
66
end
77

8-
def test_metadata_returns_conformance
9-
root = File.expand_path '..', File.dirname(File.absolute_path(__FILE__))
10-
conformance = File.read(File.join(root, 'fixtures', 'conformance-example.json'))
11-
stub_request(:get, /capability-test/).to_return(body: conformance)
12-
statement = client.conformance_statement
13-
assert statement.is_a?(FHIR::Conformance)
14-
statement = client.capability_statement
15-
assert statement.is_a?(FHIR::Conformance)
16-
end
17-
18-
198
def test_metadata_returns_capability_statement
209
root = File.expand_path '..', File.dirname(File.absolute_path(__FILE__))
2110
capabilitystatement = File.read(File.join(root, 'fixtures', 'capabilitystatement-example.json'))

0 commit comments

Comments
 (0)