lifen_fhir 0.3.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c6e9cc27391f2a2ca45aa80e3c7577d345d5f265
4
- data.tar.gz: 7c6ed9d68019892246b3412125f874ade9ba23d4
3
+ metadata.gz: 1ff83240349a82a1baf58f72f9e8da8e88fd5578
4
+ data.tar.gz: d133e7733803dfb73aef7473840d093969e9d701
5
5
  SHA512:
6
- metadata.gz: 021a874fee8606735c51be90303a45ca69750c01b854b390fdc9780799cbd3e13ab889ccdf42adfbc28874210fc0fae82dec74971092b0f12dc2795b17f7b553
7
- data.tar.gz: afe404699c29e053bca25206788026902f609005d2575f85c83b74aa34ebdb809b13dde914ae03850d5ac598b588795db6a9be29eafe5b90757c7262de6ac0c4
6
+ metadata.gz: 31aa76ec4ebf4b495ffdec8569c53221c95b32fc961d1c6a09655369526aca76ae593af06b55cfff7d781c8c2508a5e7aaa1a7ebf7dddd14d50a633700d574fd
7
+ data.tar.gz: 73f4eaf5948b53a131fd0d470cc9e20a2065d549019897e9b9a6e8ce21ecbaf21ece57adb4ea34193c42e850b713fd22fd854ef26153cdaf95abb45c6d4f0285
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ 0.4.0
2
+ -----
3
+
4
+ - Added possibility to add a patient to a list of recipients in a CommunicationRequest
5
+ - Added Reference object to abstract all class reference relative to fhir
6
+
1
7
  0.3.0
2
8
  -----
3
9
 
data/README.md CHANGED
@@ -77,7 +77,7 @@ other_medium = LifenFhir::Medium(uuid: other_recipient.channels.first.uuid)
77
77
 
78
78
  binary = LifenFhir::Binary.new(uuid: "b7c7dae671b93e951ce6a4f530736276")
79
79
 
80
- communication_request_request = LifenFhir::CommunicationRequest.new(sender: sender, recipients: [recipient, other_recipient], medium: [medium, other_medium], binary: binary, patient: patient, category: category)
80
+ communication_request = LifenFhir::CommunicationRequest.new(sender: sender, recipients: [recipient, other_recipient], medium: [medium, other_medium], binary: binary, patient: patient, category: category)
81
81
 
82
82
  communication_request_request.send
83
83
 
@@ -104,6 +104,10 @@ patient = LifenFhir::Patient.create(first_name: ["Jean", "Charles"], last_name:
104
104
 
105
105
  # To find a patient by id
106
106
  patient = LifenFhir::Patient.find_by_uuid("c3f96278-3bfe-4933-96e7-171ebca7489f")
107
+
108
+ # To set the patient as a recipient in a CommunicationRequest
109
+ communication_request = LifenFhir::CommunicationRequest.new(sender: sender, recipients: [patient], binary: binary, category: category)
110
+
107
111
  ```
108
112
 
109
113
  ## Deploying to Rubygems
@@ -32,7 +32,7 @@ module LifenFhir
32
32
  end
33
33
 
34
34
  def reference
35
- "Binary/#{uuid}"
35
+ LifenFhir::Reference.new(self).to_s
36
36
  end
37
37
 
38
38
  end
@@ -4,8 +4,8 @@ module LifenFhir
4
4
  attribute :uuid, String
5
5
  attribute :number_communications, Integer
6
6
 
7
- attribute :sender, LifenFhir::Practitioner
8
- attribute :recipients, [LifenFhir::Practitioner]
7
+ attribute :sender, LifenFhir::Reference
8
+ attribute :recipients, [LifenFhir::Reference]
9
9
 
10
10
  attribute :category, LifenFhir::Category, default: LifenFhir::Category.new
11
11
  attribute :medium, [LifenFhir::Medium]
@@ -87,4 +87,4 @@ module LifenFhir
87
87
  end
88
88
 
89
89
  end
90
- end
90
+ end
@@ -22,7 +22,8 @@ module LifenFhir
22
22
  end
23
23
 
24
24
  def self.find_by_uuid(uuid)
25
- json = application_client.get("fhir/Patient/#{uuid}")
25
+ patient = new(uuid:uuid)
26
+ json = application_client.get("fhir/#{LifenFhir::Reference.new(patient)}")
26
27
 
27
28
  patient = new
28
29
  patient.attributes_from_json(json)
@@ -9,7 +9,7 @@ module LifenFhir
9
9
  attribute :rpps, String
10
10
 
11
11
  def fhir_payload
12
- { reference: "Practitioner/#{uuid}" }
12
+ { reference: reference }
13
13
  end
14
14
 
15
15
  def self.find_by_rpps(rpps)
@@ -46,7 +46,7 @@ module LifenFhir
46
46
 
47
47
  filtered_params[params[:type]] = address
48
48
 
49
- json = application_client.post("fhir/Practitioner/#{uuid}/$add-address", filtered_params)
49
+ json = application_client.post("fhir/#{reference}/$add-address", filtered_params)
50
50
 
51
51
  channel = Channel.new(uuid: json["issue"][0]["id"], type: params[:type], value: "#{Array(params[:lines]).join(", ")}, #{params[:postal_code]} #{params[:city]}")
52
52
 
@@ -73,7 +73,7 @@ module LifenFhir
73
73
 
74
74
  filtered_params[params[:type]] = telecom
75
75
 
76
- json = application_client.post("fhir/Practitioner/#{uuid}/$add-telecom", filtered_params)
76
+ json = application_client.post("fhir/#{reference}/$add-telecom", filtered_params)
77
77
 
78
78
  channel = Channel.new(uuid: json["issue"][0]["id"], type: params[:type], value: params[:value])
79
79
 
@@ -83,6 +83,10 @@ module LifenFhir
83
83
 
84
84
  end
85
85
 
86
+ def reference
87
+ LifenFhir::Reference.new(self).to_s
88
+ end
89
+
86
90
  private
87
91
 
88
92
  def application_client
@@ -0,0 +1,23 @@
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
@@ -1,3 +1,3 @@
1
1
  module LifenFhir
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/lifen_fhir.rb CHANGED
@@ -14,6 +14,7 @@ module LifenFhir
14
14
  require 'lifen_fhir/configuration'
15
15
  require 'lifen_fhir/base'
16
16
 
17
+ require 'lifen_fhir/reference'
17
18
  require 'lifen_fhir/address'
18
19
  require 'lifen_fhir/channel'
19
20
  require 'lifen_fhir/practitioner'
@@ -0,0 +1,61 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://develop.lifen.fr/fhir/CommunicationRequest
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"resourceType":"CommunicationRequest","sender":[{"reference":"Practitioner/valid-sender-uuid"}],"recipient":[{"reference":"Patient/invalid-patient-id"}],"contained":[],"medium":[],"category":[{"coding":[{"system":"http://honestica.com/fhir/communication/category","code":"MEDICAL_REPORT"}]}],"payload":[{"contentReference":{"reference":"Binary/valid-binary-uuid"}}]}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.12.1
12
+ Authorization:
13
+ - Bearer valid_application_access_token
14
+ Accept:
15
+ - application/json
16
+ Content-Type:
17
+ - application/json
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ response:
21
+ status:
22
+ code: 422
23
+ message: Unprocessable Entity
24
+ headers:
25
+ Server:
26
+ - Apache-Coyote/1.1
27
+ X-Content-Type-Options:
28
+ - nosniff
29
+ X-Xss-Protection:
30
+ - 1; mode=block
31
+ Cache-Control:
32
+ - no-cache, no-store, max-age=0, must-revalidate
33
+ Pragma:
34
+ - no-cache
35
+ Expires:
36
+ - '0'
37
+ X-Powered-By:
38
+ - HAPI FHIR 2.4 REST Server (FHIR Server; FHIR 3.0.1/DSTU3)
39
+ Content-Type:
40
+ - application/json+fhir;charset=UTF-8
41
+ Transfer-Encoding:
42
+ - chunked
43
+ Date:
44
+ - Wed, 31 May 2017 16:55:13 GMT
45
+ body:
46
+ encoding: UTF-8
47
+ string: |-
48
+ {
49
+ "resourceType": "OperationOutcome",
50
+ "id": "8ad3928e-ddcb-4e5e-9467-909f058ea3b0",
51
+ "issue": [
52
+ {
53
+ "severity": "fatal",
54
+ "code": "required",
55
+ "diagnostics": "No recipient provided."
56
+ }
57
+ ]
58
+ }
59
+ http_version:
60
+ recorded_at: Wed, 31 May 2017 16:54:51 GMT
61
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,62 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://develop.lifen.fr/fhir/CommunicationRequest
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"resourceType":"CommunicationRequest","sender":[{"reference":"Practitioner/valid-sender-uuid"}],"recipient":[{"reference":"Patient/valid-patient-id"}],"contained":[{"id":"patient","resourceType":"Patient","name":[{"family":["Dupond"],"given":[["Jean"]]}],"birthDate":"2000-01-01"}],"medium":[],"category":[{"coding":[{"system":"http://honestica.com/fhir/communication/category","code":"MEDICAL_REPORT"}]}],"payload":[{"contentReference":{"reference":"Binary/valid-binary-uuid"}}],"subject":[{"reference":"patient"}]}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.12.1
12
+ Authorization:
13
+ - Bearer valid_application_access_token
14
+ Accept:
15
+ - application/json
16
+ Content-Type:
17
+ - application/json
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ response:
21
+ status:
22
+ code: 201
23
+ message: Created
24
+ headers:
25
+ Server:
26
+ - Apache-Coyote/1.1
27
+ X-Content-Type-Options:
28
+ - nosniff
29
+ X-Xss-Protection:
30
+ - 1; mode=block
31
+ Cache-Control:
32
+ - no-cache, no-store, max-age=0, must-revalidate
33
+ Pragma:
34
+ - no-cache
35
+ Expires:
36
+ - '0'
37
+ X-Powered-By:
38
+ - HAPI FHIR 2.4 REST Server (FHIR Server; FHIR 3.0.1/DSTU3)
39
+ Location:
40
+ - http://rc.lifen.fr:10133/fhir/OperationOutcome/22d87145-79f3-4a06-9c4e-6dde586a865d
41
+ Content-Type:
42
+ - application/json+fhir;charset=UTF-8
43
+ Transfer-Encoding:
44
+ - chunked
45
+ Date:
46
+ - Tue, 30 May 2017 10:04:04 GMT
47
+ body:
48
+ encoding: UTF-8
49
+ string: |-
50
+ {
51
+ "resourceType": "OperationOutcome",
52
+ "id": "22d87145-79f3-4a06-9c4e-6dde586a865d",
53
+ "issue": [
54
+ {
55
+ "severity": "information",
56
+ "diagnostics": "CommunicationRequest accepted"
57
+ }
58
+ ]
59
+ }
60
+ http_version:
61
+ recorded_at: Tue, 30 May 2017 10:03:47 GMT
62
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,66 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://develop.lifen.fr/fhir/CommunicationRequest
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"resourceType":"CommunicationRequest","sender":[{"reference":"Practitioner/valid-sender-uuid"}],"recipient":[{"reference":"Practitioner/valid-recipient-uuid-1"},{"reference":"Patient/valid-patient-id"}],"contained":[],"medium":[{"coding":[{"id":"valid-medium-uuid-1"}]}],"category":[{"coding":[{"system":"http://honestica.com/fhir/communication/category","code":"MEDICAL_REPORT"}]}],"payload":[{"contentReference":{"reference":"Binary/valid-binary-uuid"}}]}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.12.1
12
+ Authorization:
13
+ - Bearer valid_application_access_token
14
+ Accept:
15
+ - application/json
16
+ Content-Type:
17
+ - application/json
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ response:
21
+ status:
22
+ code: 201
23
+ message: Created
24
+ headers:
25
+ Server:
26
+ - Apache-Coyote/1.1
27
+ X-Content-Type-Options:
28
+ - nosniff
29
+ X-Xss-Protection:
30
+ - 1; mode=block
31
+ Cache-Control:
32
+ - no-cache, no-store, max-age=0, must-revalidate
33
+ Pragma:
34
+ - no-cache
35
+ Expires:
36
+ - '0'
37
+ X-Powered-By:
38
+ - HAPI FHIR 2.4 REST Server (FHIR Server; FHIR 3.0.1/DSTU3)
39
+ Location:
40
+ - http://rc.lifen.fr:10129/fhir/OperationOutcome/e3c336cc-2cdf-4e8c-99da-417e15e3084b
41
+ Content-Type:
42
+ - application/json+fhir;charset=UTF-8
43
+ Transfer-Encoding:
44
+ - chunked
45
+ Date:
46
+ - Wed, 31 May 2017 16:32:34 GMT
47
+ body:
48
+ encoding: UTF-8
49
+ string: |-
50
+ {
51
+ "resourceType": "OperationOutcome",
52
+ "id": "e3c336cc-2cdf-4e8c-99da-417e15e3084b",
53
+ "issue": [
54
+ {
55
+ "severity": "information",
56
+ "diagnostics": "CommunicationRequest accepted"
57
+ },
58
+ {
59
+ "severity": "information",
60
+ "diagnostics": "CommunicationRequest accepted"
61
+ }
62
+ ]
63
+ }
64
+ http_version:
65
+ recorded_at: Wed, 31 May 2017 16:32:13 GMT
66
+ recorded_with: VCR 3.0.3
@@ -15,24 +15,64 @@ describe LifenFhir::CommunicationRequest do
15
15
 
16
16
  let(:attachment) { LifenFhir::Attachment.new(title: "Master Plan", path: File.dirname(__FILE__) + "/support/master_plan.pdf", content_type: "application/pdf") }
17
17
 
18
- let(:patient) { LifenFhir::Patient.new(first_name: "Jean", last_name: "Dupond", birth_date: Date.new(2000,1,1)) }
18
+ let(:patient) { LifenFhir::Patient.new(uuid: "valid-patient-id", first_name: "Jean", last_name: "Dupond", birth_date: Date.new(2000,1,1)) }
19
19
 
20
- describe ':send multi-recipients with a binary' do
20
+ let(:invalid_patient) { LifenFhir::Patient.new(uuid: "invalid-patient-id", first_name: "Jean", last_name: "Dupond", birth_date: Date.new(2000,1,1)) }
21
21
 
22
- let(:communication_request) { LifenFhir::CommunicationRequest.new(sender: sender, recipients: [recipient1, recipient2], medium: [medium1, medium2], binary: binary, patient: patient) }
22
+ describe ':send multi-recipients with a binary' do
23
23
 
24
- it 'works' do
25
- VCR.use_cassette "communication_request/send/valid_attributes_binary" do
26
- communication_request.send
27
- end
24
+ let(:communication_request) { LifenFhir::CommunicationRequest.new(sender: sender, recipients: [recipient1, recipient2], medium: [medium1, medium2], binary: binary, patient: patient) }
28
25
 
29
- expect(communication_request.uuid).to_not be_nil
30
- expect(communication_request.number_communications).to eq(2)
26
+
27
+ it 'works' do
28
+ VCR.use_cassette "communication_request/send/valid_attributes_binary" do
29
+ communication_request.send
30
+ end
31
+
32
+ expect(communication_request.uuid).to_not be_nil
33
+ expect(communication_request.number_communications).to eq(2)
34
+ end
35
+
36
+ end
37
+
38
+
39
+ describe ':send to patient with a binary' do
40
+ let(:communication_request) { LifenFhir::CommunicationRequest.new(sender: patient, recipients: [patient], binary: binary) }
41
+
42
+ let(:wrong_communication_request) { LifenFhir::CommunicationRequest.new(sender: sender, recipients: [invalid_patient], binary: binary) }
43
+
44
+ it 'works' do
45
+ VCR.use_cassette "communication_request/send/patient/valid_attributes_binary" do
46
+ communication_request.send
31
47
  end
32
48
 
49
+ expect(communication_request.uuid).to_not be_nil
50
+ expect(communication_request.number_communications).to eq(1)
51
+ end
52
+
53
+ it 'does not work' do
54
+ VCR.use_cassette "communication_request/send/patient/invalid_attributes_binary" do
55
+ expect{wrong_communication_request.send}.to raise_error LifenFhir::Error
56
+ end
33
57
  end
58
+ end
59
+
60
+ describe ':send to patient and practitioner with a binary' do
61
+
62
+ let(:communication_request) { LifenFhir::CommunicationRequest.new(sender: sender, recipients: [recipient1, patient], binary: binary, medium: [medium1]) }
63
+
64
+ it 'works' do
65
+ VCR.use_cassette("communication_request/send/to_patient_also", match_requests_on: [:method, :uri, :body]) do
66
+ communication_request.send
67
+ end
68
+
69
+ expect(communication_request.uuid).to_not be_nil
70
+ expect(communication_request.number_communications).to eq(2)
71
+ end
72
+ end
73
+
34
74
 
35
- describe ':send multi-recipients with an attachment' do
75
+ describe ':send multi-recipients with an attachment' do
36
76
 
37
77
  let(:communication_request) { LifenFhir::CommunicationRequest.new(sender: sender, recipients: [recipient1, recipient2], medium: [medium1, medium2], attachment: attachment, patient: patient) }
38
78
 
data/spec/patient_spec.rb CHANGED
@@ -19,7 +19,7 @@ describe LifenFhir::Patient do
19
19
  address: address
20
20
  )
21
21
 
22
- VCR.use_cassette "patient/create/with_all_information" do
22
+ VCR.use_cassette("patient/create/with_all_information", match_requests_on: [:method, :uri, :body]) do
23
23
  patient.save
24
24
  end
25
25
 
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe LifenFhir::Reference do
4
+
5
+ describe ':to_s' do
6
+
7
+ let(:patient) { LifenFhir::Patient.new(uuid: "valid_patient_uuid") }
8
+ let(:practitioner) { LifenFhir::Practitioner.new(uuid: "valid_practitioner_uuid") }
9
+ let(:binary) { LifenFhir::Binary.new(uuid: "valid_binary_uuid") }
10
+
11
+
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
+ end
17
+ end
18
+ end
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.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leonard Sellam
@@ -169,6 +169,7 @@ files:
169
169
  - lib/lifen_fhir/medium.rb
170
170
  - lib/lifen_fhir/patient.rb
171
171
  - lib/lifen_fhir/practitioner.rb
172
+ - lib/lifen_fhir/reference.rb
172
173
  - lib/lifen_fhir/user_authenticated_client.rb
173
174
  - lib/lifen_fhir/version.rb
174
175
  - lifen_fhir.gemspec
@@ -179,6 +180,9 @@ files:
179
180
  - spec/cassettes/communication_request/find_by_uuid/valid_uuid_with_a_status.yml
180
181
  - spec/cassettes/communication_request/find_by_uuid/valid_uuid_with_no_status.yml
181
182
  - spec/cassettes/communication_request/send/invalid_medium.yml
183
+ - spec/cassettes/communication_request/send/patient/invalid_attributes_binary.yml
184
+ - spec/cassettes/communication_request/send/patient/valid_attributes_binary.yml
185
+ - spec/cassettes/communication_request/send/to_patient_also.yml
182
186
  - spec/cassettes/communication_request/send/valid_attributes.yml
183
187
  - spec/cassettes/communication_request/send/valid_attributes_binary.yml
184
188
  - spec/cassettes/patient/create/with_all_information.yml
@@ -194,6 +198,7 @@ files:
194
198
  - spec/communication_request_spec.rb
195
199
  - spec/patient_spec.rb
196
200
  - spec/practitionner_spec.rb
201
+ - spec/reference_spec.rb
197
202
  - spec/spec_helper.rb
198
203
  - spec/support/master_plan.pdf
199
204
  homepage: https://github.com/honestica/lifen-fhir
@@ -228,6 +233,9 @@ test_files:
228
233
  - spec/cassettes/communication_request/find_by_uuid/valid_uuid_with_a_status.yml
229
234
  - spec/cassettes/communication_request/find_by_uuid/valid_uuid_with_no_status.yml
230
235
  - spec/cassettes/communication_request/send/invalid_medium.yml
236
+ - spec/cassettes/communication_request/send/patient/invalid_attributes_binary.yml
237
+ - spec/cassettes/communication_request/send/patient/valid_attributes_binary.yml
238
+ - spec/cassettes/communication_request/send/to_patient_also.yml
231
239
  - spec/cassettes/communication_request/send/valid_attributes.yml
232
240
  - spec/cassettes/communication_request/send/valid_attributes_binary.yml
233
241
  - spec/cassettes/patient/create/with_all_information.yml
@@ -243,5 +251,6 @@ test_files:
243
251
  - spec/communication_request_spec.rb
244
252
  - spec/patient_spec.rb
245
253
  - spec/practitionner_spec.rb
254
+ - spec/reference_spec.rb
246
255
  - spec/spec_helper.rb
247
256
  - spec/support/master_plan.pdf