lifen_fhir 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/Gemfile.lock +50 -1
- data/Guardfile +5 -0
- data/README.md +3 -1
- data/lib/lifen_fhir/address.rb +5 -5
- data/lib/lifen_fhir/base.rb +10 -0
- data/lib/lifen_fhir/binary.rb +2 -18
- data/lib/lifen_fhir/category.rb +6 -0
- data/lib/lifen_fhir/channel.rb +11 -3
- data/lib/lifen_fhir/communication_request.rb +14 -15
- data/lib/lifen_fhir/element.rb +37 -0
- data/lib/lifen_fhir/medium.rb +1 -3
- data/lib/lifen_fhir/patient.rb +11 -19
- data/lib/lifen_fhir/practitioner.rb +5 -36
- data/lib/lifen_fhir/telecom.rb +23 -0
- data/lib/lifen_fhir/version.rb +1 -1
- data/lib/lifen_fhir.rb +14 -1
- data/lifen_fhir.gemspec +4 -0
- data/spec/binary_spec.rb +7 -7
- data/spec/cassettes/communication_request/find_by_uuid/valid_uuid_with_no_status.yml +1 -1
- data/spec/cassettes/communication_request/send/unknown_binary.yml +62 -0
- data/spec/cassettes/communication_request/send/unknown_recipient.yml +63 -0
- data/spec/cassettes/patient/create/invalid_attributes.yml +63 -0
- data/spec/cassettes/patient/create/with_all_information.yml +1 -1
- data/spec/cassettes/patient/create/with_first_name_as_a_string.yml +65 -0
- data/spec/cassettes/practitioner/create_channel/address/invalid_attributes.yml +62 -0
- data/spec/cassettes/{practitionner → practitioner}/create_channel/address/old_valid_attributes.yml +0 -0
- data/spec/cassettes/{practitionner → practitioner}/create_channel/address/valid_attributes.yml +0 -0
- data/spec/cassettes/practitioner/create_channel/telecom/invalid_attributes.yml +62 -0
- data/spec/cassettes/{practitionner → practitioner}/create_channel/telecom/valid_attributes.yml +0 -0
- data/spec/cassettes/{practitionner → practitioner}/find_by_rpps/existing_rpps.yml +0 -0
- data/spec/cassettes/{practitionner → practitioner}/find_by_rpps/missing_line_attribute.yml +0 -0
- data/spec/cassettes/{practitionner → practitioner}/find_by_rpps/wrong_rpps.yml +0 -0
- data/spec/communication_request_spec.rb +105 -62
- data/spec/patient_spec.rb +53 -12
- data/spec/practitioner_spec.rb +105 -0
- data/spec/reference_spec.rb +29 -8
- data/spec/spec_helper.rb +10 -0
- metadata +73 -17
- data/lib/lifen_fhir/reference.rb +0 -23
- data/spec/practitionner_spec.rb +0 -76
data/spec/patient_spec.rb
CHANGED
@@ -4,28 +4,68 @@ describe LifenFhir::Patient do
|
|
4
4
|
|
5
5
|
describe ':create' do
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
address = LifenFhir::Address.new(
|
7
|
+
let(:address) {
|
8
|
+
LifenFhir::Address.new(
|
10
9
|
lines: ["M et Mme Potter", "39 rue d'Aboukir"],
|
11
|
-
city:"paris",
|
12
|
-
postal_code: "75002"
|
10
|
+
city: "paris",
|
11
|
+
postal_code: "75002",
|
12
|
+
country: "France"
|
13
13
|
)
|
14
|
+
}
|
14
15
|
|
16
|
+
let(:patient) {
|
15
17
|
patient = LifenFhir::Patient.new(
|
16
18
|
first_name: ["Pierre", "Henri"],
|
17
19
|
last_name: "Potter",
|
18
20
|
birth_date: Date.new(1974, 12, 25),
|
19
21
|
address: address
|
20
22
|
)
|
23
|
+
}
|
21
24
|
|
22
|
-
|
25
|
+
it 'works' do
|
26
|
+
VCR.use_cassette("patient/create/with_all_information") do
|
23
27
|
patient.save
|
24
28
|
end
|
25
29
|
|
26
30
|
expect(patient.uuid).to eq("ab7002e2-f017-48a5-ae09-1e232dc7c726")
|
27
31
|
end
|
28
32
|
|
33
|
+
context 'with first_name as a string' do
|
34
|
+
|
35
|
+
it 'works' do
|
36
|
+
patient.first_name = "Pierre"
|
37
|
+
|
38
|
+
VCR.use_cassette("patient/create/with_first_name_as_a_string") do
|
39
|
+
patient.save
|
40
|
+
end
|
41
|
+
|
42
|
+
expect(patient.uuid).to eq("f15cd0df-4edb-4b5b-9785-7390405af6cb")
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'with no birth_date' do
|
48
|
+
|
49
|
+
it 'has no birthDate in fhir_payload' do
|
50
|
+
patient.birth_date = nil
|
51
|
+
|
52
|
+
expect(patient.fhir_payload["birthDate"]).to be_nil
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'invalid attributes' do
|
58
|
+
it 'fails nicely' do
|
59
|
+
patient.last_name = nil
|
60
|
+
|
61
|
+
expect{
|
62
|
+
VCR.use_cassette("patient/create/invalid_attributes") do
|
63
|
+
patient.save
|
64
|
+
end
|
65
|
+
}.to raise_error LifenFhir::Error
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
29
69
|
end
|
30
70
|
|
31
71
|
describe ':find_by_uuid' do
|
@@ -46,12 +86,13 @@ describe LifenFhir::Patient do
|
|
46
86
|
expect(address.lines.size).to eq(2)
|
47
87
|
end
|
48
88
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
89
|
+
context 'invalid uuid' do
|
90
|
+
it 'fails nicely' do
|
91
|
+
VCR.use_cassette "patient/find/with_wrong_id" do
|
92
|
+
expect {
|
93
|
+
@patient = LifenFhir::Patient.find_by_uuid("wrong-uuid")
|
94
|
+
}.to raise_error LifenFhir::Error
|
95
|
+
end
|
55
96
|
end
|
56
97
|
end
|
57
98
|
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LifenFhir::Practitioner do
|
4
|
+
|
5
|
+
describe ':find_by_rpps' do
|
6
|
+
|
7
|
+
it 'works' do
|
8
|
+
VCR.use_cassette "practitioner/find_by_rpps/existing_rpps" do
|
9
|
+
@practitioner = LifenFhir::Practitioner.find_by_rpps("810004085790")
|
10
|
+
end
|
11
|
+
|
12
|
+
expect(@practitioner.channels.size).to eq(3)
|
13
|
+
|
14
|
+
address = @practitioner.channels.last
|
15
|
+
|
16
|
+
expect(address.value).to eq "11 RUE CHARLES TELLIER, 75016 Paris"
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'wrong rpps' do
|
20
|
+
it 'fails nicely' do
|
21
|
+
VCR.use_cassette "practitioner/find_by_rpps/wrong_rpps" do
|
22
|
+
expect { @practitioner = LifenFhir::Practitioner.find_by_rpps("8888888888") }.to raise_error LifenFhir::Error
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'missing lines attribute' do
|
28
|
+
|
29
|
+
it 'does not raise an issue' do
|
30
|
+
VCR.use_cassette "practitioner/find_by_rpps/missing_line_attribute" do
|
31
|
+
@practitioner = LifenFhir::Practitioner.find_by_rpps("810004085790")
|
32
|
+
end
|
33
|
+
|
34
|
+
address = @practitioner.channels.last
|
35
|
+
|
36
|
+
expect(address.value).to eq ", 75016 Paris"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
describe ':create_address' do
|
43
|
+
|
44
|
+
let(:practitioner) { LifenFhir::Practitioner.new(uuid: "11e5c85e-9bc0-4c6e-9b29-deb9993a92c0") }
|
45
|
+
|
46
|
+
it 'works' do
|
47
|
+
VCR.use_cassette "practitioner/create_channel/address/valid_attributes" do
|
48
|
+
@channel = practitioner.create_address(type: "address", lines: ["Honestica", "39 rue d'Aboukir"], city: "Paris", postal_code: "75002", country: "France")
|
49
|
+
end
|
50
|
+
|
51
|
+
expect(@channel.value).to eq "Honestica, 39 rue d'Aboukir, 75002 Paris"
|
52
|
+
expect(@channel.uuid).to eq "11e73ca3-c4b2-fe69-b5c5-0242ac110002"
|
53
|
+
expect(practitioner.channels.size).to eq 1
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'old version' do
|
57
|
+
it 'works' do
|
58
|
+
VCR.use_cassette "practitioner/create_channel/address/old_valid_attributes" do
|
59
|
+
@channel = practitioner.create_address(type: "address", lines: ["Honestica", "39 rue d'Aboukir"], city: "Paris", postal_code: "75002", country: "France")
|
60
|
+
end
|
61
|
+
|
62
|
+
expect(@channel.value).to eq "Honestica, 39 rue d'Aboukir, 75002 Paris"
|
63
|
+
expect(@channel.uuid).to eq "11e73ca4-e3d4-8c5f-b5c5-0242ac110002"
|
64
|
+
expect(practitioner.channels.size).to eq 1
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'invalid attributes' do
|
69
|
+
it 'fails nicely' do
|
70
|
+
expect{
|
71
|
+
VCR.use_cassette "practitioner/create_channel/address/invalid_attributes" do
|
72
|
+
practitioner.create_address(type: "address", lines: [], city: "Paris", postal_code: "75002", country: "France")
|
73
|
+
end
|
74
|
+
}.to raise_error LifenFhir::Error
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
describe ':create_telecom' do
|
81
|
+
|
82
|
+
let(:practitioner) { LifenFhir::Practitioner.new(uuid: "11e5c85e-9bc0-4c6e-9b29-deb9993a92c0") }
|
83
|
+
|
84
|
+
it 'works' do
|
85
|
+
VCR.use_cassette "practitioner/create_channel/telecom/valid_attributes" do
|
86
|
+
@channel = practitioner.create_telecom(type: "telecom", system: "fax", value: "+33102030405")
|
87
|
+
end
|
88
|
+
|
89
|
+
expect(@channel.uuid).to eq "11e73ca3-c56a-8e9b-b5c5-0242ac110002"
|
90
|
+
expect(practitioner.channels.size).to eq 1
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'invalid attributes' do
|
94
|
+
it 'fails nicely' do
|
95
|
+
expect{
|
96
|
+
VCR.use_cassette "practitioner/create_channel/telecom/invalid_attributes" do
|
97
|
+
practitioner.create_telecom(type: "telecom", system: "fax", value: "")
|
98
|
+
end
|
99
|
+
}.to raise_error LifenFhir::Error
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
data/spec/reference_spec.rb
CHANGED
@@ -1,18 +1,39 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe "references" do
|
4
4
|
|
5
5
|
describe ':to_s' do
|
6
6
|
|
7
|
-
|
8
|
-
let(:practitioner) { LifenFhir::Practitioner.new(uuid: "valid_practitioner_uuid") }
|
9
|
-
let(:binary) { LifenFhir::Binary.new(uuid: "valid_binary_uuid") }
|
7
|
+
context 'patient' do
|
10
8
|
|
9
|
+
let(:patient) { LifenFhir::Patient.new(uuid: "valid_patient_uuid") }
|
10
|
+
|
11
|
+
it 'works' do
|
12
|
+
expect(patient.reference).to eq("Patient/valid_patient_uuid")
|
13
|
+
end
|
11
14
|
|
12
|
-
it 'works' do
|
13
|
-
expect(LifenFhir::Reference.new(patient).to_s).to eq("Patient/valid_patient_uuid")
|
14
|
-
expect(LifenFhir::Reference.new(practitioner).to_s).to eq("Practitioner/valid_practitioner_uuid")
|
15
|
-
expect(LifenFhir::Reference.new(binary).to_s).to eq("Binary/valid_binary_uuid")
|
16
15
|
end
|
16
|
+
|
17
|
+
context 'practitioner' do
|
18
|
+
|
19
|
+
let(:practitioner) { LifenFhir::Practitioner.new(uuid: "valid_practitioner_uuid") }
|
20
|
+
|
21
|
+
it 'works' do
|
22
|
+
expect(practitioner.reference).to eq("Practitioner/valid_practitioner_uuid")
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'binary' do
|
28
|
+
|
29
|
+
let(:binary) { LifenFhir::Binary.new(uuid: "valid_binary_uuid") }
|
30
|
+
|
31
|
+
it 'works' do
|
32
|
+
expect(binary.reference).to eq("Binary/valid_binary_uuid")
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
17
37
|
end
|
38
|
+
|
18
39
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,6 +2,16 @@ require 'bundler/setup'
|
|
2
2
|
require 'webmock/rspec'
|
3
3
|
require 'vcr'
|
4
4
|
require 'awesome_print'
|
5
|
+
require 'simplecov'
|
6
|
+
|
7
|
+
if ENV['CIRCLE_ARTIFACTS']
|
8
|
+
dir = File.join(ENV['CIRCLE_ARTIFACTS'], "coverage")
|
9
|
+
SimpleCov.coverage_dir(dir)
|
10
|
+
end
|
11
|
+
|
12
|
+
SimpleCov.start do
|
13
|
+
add_filter '/spec/'
|
14
|
+
end
|
5
15
|
|
6
16
|
require_relative '../lib/lifen_fhir.rb'
|
7
17
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lifen_fhir
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leonard Sellam
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-06-
|
12
|
+
date: 2017-06-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -95,6 +95,48 @@ dependencies:
|
|
95
95
|
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: simplecov
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: guard-rspec
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: rb-readline
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
98
140
|
- !ruby/object:Gem::Dependency
|
99
141
|
name: virtus
|
100
142
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,6 +193,7 @@ files:
|
|
151
193
|
- CHANGELOG.md
|
152
194
|
- Gemfile
|
153
195
|
- Gemfile.lock
|
196
|
+
- Guardfile
|
154
197
|
- License.txt
|
155
198
|
- README.md
|
156
199
|
- lib/lifen_fhir.rb
|
@@ -165,11 +208,12 @@ files:
|
|
165
208
|
- lib/lifen_fhir/communication_request.rb
|
166
209
|
- lib/lifen_fhir/configuration.rb
|
167
210
|
- lib/lifen_fhir/content_string.rb
|
211
|
+
- lib/lifen_fhir/element.rb
|
168
212
|
- lib/lifen_fhir/error.rb
|
169
213
|
- lib/lifen_fhir/medium.rb
|
170
214
|
- lib/lifen_fhir/patient.rb
|
171
215
|
- lib/lifen_fhir/practitioner.rb
|
172
|
-
- lib/lifen_fhir/
|
216
|
+
- lib/lifen_fhir/telecom.rb
|
173
217
|
- lib/lifen_fhir/user_authenticated_client.rb
|
174
218
|
- lib/lifen_fhir/version.rb
|
175
219
|
- lifen_fhir.gemspec
|
@@ -183,21 +227,27 @@ files:
|
|
183
227
|
- spec/cassettes/communication_request/send/patient/invalid_attributes_binary.yml
|
184
228
|
- spec/cassettes/communication_request/send/patient/valid_attributes_binary.yml
|
185
229
|
- spec/cassettes/communication_request/send/to_patient_also.yml
|
230
|
+
- spec/cassettes/communication_request/send/unknown_binary.yml
|
231
|
+
- spec/cassettes/communication_request/send/unknown_recipient.yml
|
186
232
|
- spec/cassettes/communication_request/send/valid_attributes.yml
|
187
233
|
- spec/cassettes/communication_request/send/valid_attributes_binary.yml
|
234
|
+
- spec/cassettes/patient/create/invalid_attributes.yml
|
188
235
|
- spec/cassettes/patient/create/with_all_information.yml
|
236
|
+
- spec/cassettes/patient/create/with_first_name_as_a_string.yml
|
189
237
|
- spec/cassettes/patient/find/with_valid_id.yml
|
190
238
|
- spec/cassettes/patient/find/with_wrong_id.yml
|
191
|
-
- spec/cassettes/
|
192
|
-
- spec/cassettes/
|
193
|
-
- spec/cassettes/
|
194
|
-
- spec/cassettes/
|
195
|
-
- spec/cassettes/
|
196
|
-
- spec/cassettes/
|
239
|
+
- spec/cassettes/practitioner/create_channel/address/invalid_attributes.yml
|
240
|
+
- spec/cassettes/practitioner/create_channel/address/old_valid_attributes.yml
|
241
|
+
- spec/cassettes/practitioner/create_channel/address/valid_attributes.yml
|
242
|
+
- spec/cassettes/practitioner/create_channel/telecom/invalid_attributes.yml
|
243
|
+
- spec/cassettes/practitioner/create_channel/telecom/valid_attributes.yml
|
244
|
+
- spec/cassettes/practitioner/find_by_rpps/existing_rpps.yml
|
245
|
+
- spec/cassettes/practitioner/find_by_rpps/missing_line_attribute.yml
|
246
|
+
- spec/cassettes/practitioner/find_by_rpps/wrong_rpps.yml
|
197
247
|
- spec/category_spec.rb
|
198
248
|
- spec/communication_request_spec.rb
|
199
249
|
- spec/patient_spec.rb
|
200
|
-
- spec/
|
250
|
+
- spec/practitioner_spec.rb
|
201
251
|
- spec/reference_spec.rb
|
202
252
|
- spec/spec_helper.rb
|
203
253
|
- spec/support/master_plan.pdf
|
@@ -236,21 +286,27 @@ test_files:
|
|
236
286
|
- spec/cassettes/communication_request/send/patient/invalid_attributes_binary.yml
|
237
287
|
- spec/cassettes/communication_request/send/patient/valid_attributes_binary.yml
|
238
288
|
- spec/cassettes/communication_request/send/to_patient_also.yml
|
289
|
+
- spec/cassettes/communication_request/send/unknown_binary.yml
|
290
|
+
- spec/cassettes/communication_request/send/unknown_recipient.yml
|
239
291
|
- spec/cassettes/communication_request/send/valid_attributes.yml
|
240
292
|
- spec/cassettes/communication_request/send/valid_attributes_binary.yml
|
293
|
+
- spec/cassettes/patient/create/invalid_attributes.yml
|
241
294
|
- spec/cassettes/patient/create/with_all_information.yml
|
295
|
+
- spec/cassettes/patient/create/with_first_name_as_a_string.yml
|
242
296
|
- spec/cassettes/patient/find/with_valid_id.yml
|
243
297
|
- spec/cassettes/patient/find/with_wrong_id.yml
|
244
|
-
- spec/cassettes/
|
245
|
-
- spec/cassettes/
|
246
|
-
- spec/cassettes/
|
247
|
-
- spec/cassettes/
|
248
|
-
- spec/cassettes/
|
249
|
-
- spec/cassettes/
|
298
|
+
- spec/cassettes/practitioner/create_channel/address/invalid_attributes.yml
|
299
|
+
- spec/cassettes/practitioner/create_channel/address/old_valid_attributes.yml
|
300
|
+
- spec/cassettes/practitioner/create_channel/address/valid_attributes.yml
|
301
|
+
- spec/cassettes/practitioner/create_channel/telecom/invalid_attributes.yml
|
302
|
+
- spec/cassettes/practitioner/create_channel/telecom/valid_attributes.yml
|
303
|
+
- spec/cassettes/practitioner/find_by_rpps/existing_rpps.yml
|
304
|
+
- spec/cassettes/practitioner/find_by_rpps/missing_line_attribute.yml
|
305
|
+
- spec/cassettes/practitioner/find_by_rpps/wrong_rpps.yml
|
250
306
|
- spec/category_spec.rb
|
251
307
|
- spec/communication_request_spec.rb
|
252
308
|
- spec/patient_spec.rb
|
253
|
-
- spec/
|
309
|
+
- spec/practitioner_spec.rb
|
254
310
|
- spec/reference_spec.rb
|
255
311
|
- spec/spec_helper.rb
|
256
312
|
- spec/support/master_plan.pdf
|
data/lib/lifen_fhir/reference.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
module LifenFhir
|
2
|
-
class Reference < Base
|
3
|
-
|
4
|
-
def initialize(source)
|
5
|
-
@source = source
|
6
|
-
end
|
7
|
-
|
8
|
-
attr_reader :source
|
9
|
-
|
10
|
-
def to_s
|
11
|
-
"#{class_name}/#{source.uuid}"
|
12
|
-
end
|
13
|
-
|
14
|
-
def class_name
|
15
|
-
source.class.name.gsub!('LifenFhir::', '')
|
16
|
-
end
|
17
|
-
|
18
|
-
def fhir_payload
|
19
|
-
{ reference: self.to_s }
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
end
|
data/spec/practitionner_spec.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe LifenFhir::Practitioner do
|
4
|
-
|
5
|
-
describe ':find_by_rpps' do
|
6
|
-
|
7
|
-
|
8
|
-
it 'finds the practitionners' do
|
9
|
-
VCR.use_cassette "practitionner/find_by_rpps/existing_rpps" do
|
10
|
-
@practitionner = LifenFhir::Practitioner.find_by_rpps("810004085790")
|
11
|
-
end
|
12
|
-
|
13
|
-
expect(@practitionner.channels.size).to eq(3)
|
14
|
-
|
15
|
-
address = @practitionner.channels.last
|
16
|
-
|
17
|
-
expect(address.value).to eq "11 RUE CHARLES TELLIER, 75016 Paris"
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'cannot find rpps' do
|
21
|
-
VCR.use_cassette "practitionner/find_by_rpps/wrong_rpps" do
|
22
|
-
expect { @practitionner = LifenFhir::Practitioner.find_by_rpps("8888888888") }.to raise_error LifenFhir::Error
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
context 'missing lines attribute' do
|
29
|
-
|
30
|
-
it 'does not raise an issue' do
|
31
|
-
VCR.use_cassette "practitionner/find_by_rpps/missing_line_attribute" do
|
32
|
-
@practitionner = LifenFhir::Practitioner.find_by_rpps("810004085790")
|
33
|
-
end
|
34
|
-
|
35
|
-
address = @practitionner.channels.last
|
36
|
-
|
37
|
-
expect(address.value).to eq ", 75016 Paris"
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe ':create_address' do
|
42
|
-
|
43
|
-
let(:practitionner) { LifenFhir::Practitioner.new(uuid: "11e5c85e-9bc0-4c6e-9b29-deb9993a92c0") }
|
44
|
-
|
45
|
-
it 'creates the address' do
|
46
|
-
VCR.use_cassette "practitionner/create_channel/address/valid_attributes" do
|
47
|
-
@channel = practitionner.create_address(type: "address", lines: ["Honestica", "39 rue d'Aboukir"], city: "Paris", postal_code: "75002", country: "France")
|
48
|
-
end
|
49
|
-
|
50
|
-
expect(@channel.value).to eq "Honestica, 39 rue d'Aboukir, 75002 Paris"
|
51
|
-
expect(@channel.uuid).to eq "11e73ca3-c4b2-fe69-b5c5-0242ac110002"
|
52
|
-
expect(practitionner.channels.size).to eq 1
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'creates the channel - old version' do
|
56
|
-
VCR.use_cassette "practitionner/create_channel/address/old_valid_attributes" do
|
57
|
-
@channel = practitionner.create_address(type: "address", lines: ["Honestica", "39 rue d'Aboukir"], city: "Paris", postal_code: "75002", country: "France")
|
58
|
-
end
|
59
|
-
|
60
|
-
expect(@channel.value).to eq "Honestica, 39 rue d'Aboukir, 75002 Paris"
|
61
|
-
expect(@channel.uuid).to eq "11e73ca4-e3d4-8c5f-b5c5-0242ac110002"
|
62
|
-
expect(practitionner.channels.size).to eq 1
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'creates the telecom-fax channel' do
|
66
|
-
VCR.use_cassette "practitionner/create_channel/telecom/valid_attributes" do
|
67
|
-
@channel = practitionner.create_telecom(type: "telecom", system: "fax", value: "+33102030405")
|
68
|
-
end
|
69
|
-
|
70
|
-
expect(@channel.uuid).to eq "11e73ca3-c56a-8e9b-b5c5-0242ac110002"
|
71
|
-
expect(practitionner.channels.size).to eq 1
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
|
76
|
-
end
|