lifen 2.4.0 → 3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e808f690c7594a8a9fbb168e6b83d5fc8ebfe1ae
4
- data.tar.gz: ed7525498a82f199e230817c42c143ebfe41097b
3
+ metadata.gz: 79deed444977cb5560f104a1507ad85d3f7066fa
4
+ data.tar.gz: ca4895e8cf1356a51d01661e18acfd3d4e52e8a6
5
5
  SHA512:
6
- metadata.gz: bdcccaff11cb9d9ef89037084d93bcedae393769be52e2a72ed68238a21aaf317e061e4fc0c85514fa10a3167a8a82eee64a4b7815a355a3937156b348399b18
7
- data.tar.gz: 48e9ab0eb11eb976d7addf3d25ad3f6f1e093d16004591c96a2bca3bfefca521d0a59f02e5eeabf798b4518313d9a1793bdb53a2a54f02639ec7aafd3fa6263c
6
+ metadata.gz: f9a0a0d34c22b03898a17af6b078693e31d5d512073c1d7c35874d931d0c64e94743d3a8d584d8e388b8f597c03b9abfc333d3e2e5e82d831a2a33f17997b7f6
7
+ data.tar.gz: 813dc3995c10b1d70f4bf9fccb3190cd7dc2b0757ca1d401bc312552c835ff929160af47467dd2eee0b55be2079eea33ae1180f56df3706c08066c0ad9b2e62c
@@ -1,3 +1,11 @@
1
+ 3.0.0
2
+ -----
3
+
4
+ - Major refactoring to separate the private and public use of the gem
5
+ - Added `Practitioner`
6
+ - Extracts some business and methods from `User` to `Practitioner`
7
+ - Deleted `Communication`. Use `CommunicationRequest` from now on
8
+
1
9
  2.4.0
2
10
  -----
3
11
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lifen (2.4.0)
4
+ lifen (3.0.0)
5
5
  faraday (>= 0.9)
6
6
  inflecto
7
7
  virtus (>= 1.0)
data/README.md CHANGED
@@ -140,9 +140,9 @@ binary.download
140
140
  #### Communications with an Attachment
141
141
 
142
142
  ```ruby
143
- sender = Lifen::User.find_by_rpps("899900018483")
143
+ sender = Lifen::Practitioner.find_by_rpps("899900018483")
144
144
 
145
- recipient = Lifen::User.find_by_rpps("899900018484")
145
+ recipient = Lifen::Practitioner.find_by_rpps("899900018484")
146
146
  channel = recipient.channels.first
147
147
 
148
148
  category = Lifen::Category.new(code: "MEDICAL_REPORT") # default case, optionnal element
@@ -151,52 +151,52 @@ attachment = Lifen::Attachment.new(title: "Test document", path: "path/to/file")
151
151
 
152
152
  patient = Lifen::Patient.new(first_name: "Jean", last_name: "Dupond", birthdate: Date.new(2000,1,1))
153
153
 
154
- communication = Lifen::Communication.new(sender: sender, recipient: recipient, channel: channel, attachment: attachment, patient: patient, category: category)
155
- communication.send
154
+ communication_request = Lifen::CommunicationRequest.new(sender: sender, recipient: recipient, channel: channel, attachment: attachment, patient: patient, category: category)
155
+ communication_request.send
156
156
 
157
- communication = Lifen::Communication.find("valid-communication-uuid")
158
- communication.status
157
+ communication_request = Lifen::CommunicationRequest.find("valid-communication_request-uuid")
158
+ communication_request.status
159
159
  ```
160
160
 
161
161
  ### Communications with a Binary
162
162
 
163
163
  ```ruby
164
- sender = Lifen::User.find_by_rpps("899900018483")
164
+ sender = Lifen::Practitioner.find_by_rpps("899900018483")
165
165
 
166
- recipient = Lifen::User.find_by_rpps("899900018484")
166
+ recipient = Lifen::Practitioner.find_by_rpps("899900018484")
167
167
  channel = recipient.channels.first
168
168
 
169
169
  binary = Lifen::Binary.new(uuid: "b7c7dae671b93e951ce6a4f530736276")
170
170
 
171
- communication = Lifen::Communication.new(sender: sender, recipient: recipient, channel: channel, binary: binary, patient: patient, category: category)
171
+ communication_request = Lifen::CommunicationRequest.new(sender: sender, recipient: recipient, channel: channel, binary: binary, patient: patient, category: category)
172
172
 
173
- communication.send
173
+ communication_request.send
174
174
 
175
175
  ```
176
176
 
177
177
  #### Communication requets with multiple recipients
178
178
 
179
179
  ```ruby
180
- sender = Lifen::User.find_by_rpps("899900018483")
180
+ sender = Lifen::Practitioner.find_by_rpps("899900018483")
181
181
 
182
- recipient = Lifen::User.find_by_rpps("899900018484")
182
+ recipient = Lifen::Practitioner.find_by_rpps("899900018484")
183
183
  medium = Lifen::Medium(uuid: recipient.channels.first.uuid)
184
184
 
185
- other_recipient = Lifen::User.find_by_rpps("899900018484")
185
+ other_recipient = Lifen::Practitioner.find_by_rpps("899900018484")
186
186
  other_medium = Lifen::Medium(uuid: other_recipient.channels.first.uuid)
187
187
 
188
188
  binary = Lifen::Binary.new(uuid: "b7c7dae671b93e951ce6a4f530736276")
189
189
 
190
- communication_request = Lifen::CommunicationRequest.new(sender: sender, recipients: [recipient, other_recipient], medium: [medium, other_medium], binary: binary, patient: patient, category: category)
190
+ communication_request_request = Lifen::CommunicationRequest.new(sender: sender, recipients: [recipient, other_recipient], medium: [medium, other_medium], binary: binary, patient: patient, category: category)
191
191
 
192
- communication_request.send
192
+ communication_request_request.send
193
193
 
194
194
  ```
195
195
 
196
196
  #### Custom Channels management
197
197
 
198
198
  ```ruby
199
- recipient = Lifen::User.new(uuid: "valid-user-uuid")
199
+ recipient = Lifen::Practitioner.new(uuid: "valid-user-uuid")
200
200
 
201
201
  # To create a new mailing address channel
202
202
  channel = recipient.create_address(type: "address", lines: ["39 rue Aboukir"], city: "Paris", postal_code: "75002", country: "France")
@@ -22,14 +22,14 @@ module Lifen
22
22
  require 'lifen/flows'
23
23
  require 'lifen/message'
24
24
 
25
+ require 'lifen/channel'
26
+ require 'lifen/practitioner'
25
27
  require 'lifen/category'
26
28
  require 'lifen/medium'
27
29
  require 'lifen/attachment'
28
30
  require 'lifen/binary'
29
- require 'lifen/channel'
30
31
  require 'lifen/patient'
31
32
  require 'lifen/content_string'
32
- require 'lifen/communication'
33
33
  require 'lifen/communication_request'
34
34
 
35
35
  Virtus.finalize
@@ -4,8 +4,8 @@ module Lifen
4
4
  attribute :uuid, String
5
5
  attribute :number_communications, Integer
6
6
 
7
- attribute :sender, Lifen::User
8
- attribute :recipients, [Lifen::User]
7
+ attribute :sender, Lifen::Practitioner
8
+ attribute :recipients, [Lifen::Practitioner]
9
9
 
10
10
  attribute :category, Lifen::Category, default: Lifen::Category.new
11
11
  attribute :medium, [Lifen::Medium]
@@ -0,0 +1,97 @@
1
+ module Lifen
2
+ class Practitioner < Base
3
+
4
+ attribute :channels, [Lifen::Channel]
5
+
6
+ attribute :uuid, String
7
+ attribute :last_name, String
8
+ attribute :first_name, String
9
+ attribute :rpps, String
10
+
11
+ def fhir_payload
12
+ { reference: "Practitioner/#{uuid}" }
13
+ end
14
+
15
+ def self.find_by_rpps(rpps)
16
+ json = application_client.get("fhir/Practitioner/?identifier=#{rpps}")
17
+
18
+ raise "Practitioner not found" if Array(json["entry"]).size != 1
19
+
20
+ user_json = Array(json["entry"]).first.fetch("resource") { {} }
21
+
22
+ user_json[:uuid] = user_json["id"]
23
+
24
+ user = new(user_json)
25
+
26
+ Array(user_json["telecom"]).each do |telecom_json|
27
+ user.channels << Lifen::Channel.from_json(telecom_json, "telecom")
28
+ end
29
+
30
+ Array(user_json["address"]).each do |address_json|
31
+ user.channels << Lifen::Channel.from_json(address_json, "address")
32
+ end
33
+
34
+ user
35
+ end
36
+
37
+ def create_address(params)
38
+ filtered_params = {"resourceType" => "Practitioner"}
39
+
40
+ address = {
41
+ "line": Array(params[:lines]),
42
+ "city": params[:city],
43
+ "postalCode": params[:postal_code],
44
+ "country": params[:country]
45
+ }
46
+
47
+ filtered_params[params[:type]] = address
48
+
49
+ json = application_client.post("fhir/Practitioner/#{uuid}/$add-address", filtered_params)
50
+
51
+ channel = Channel.new(uuid: json["issue"][0]["id"], type: params[:type], value: "#{Array(params[:lines]).join(", ")}, #{params[:postal_code]} #{params[:city]}")
52
+
53
+ self.channels << channel
54
+
55
+ channel
56
+ end
57
+
58
+ def self.from_json(json)
59
+ reference = json["reference"]
60
+
61
+ uuid = reference.gsub("Practitioner/", "")
62
+
63
+ new(uuid: uuid)
64
+ end
65
+
66
+ def create_telecom(params)
67
+ filtered_params = {"resourceType" => "Practitioner"}
68
+
69
+ telecom = {
70
+ "system": params[:system],
71
+ "value": params[:value]
72
+ }
73
+
74
+ filtered_params[params[:type]] = telecom
75
+
76
+ json = application_client.post("fhir/Practitioner/#{uuid}/$add-telecom", filtered_params)
77
+
78
+ channel = Channel.new(uuid: json["issue"][0]["id"], type: params[:type], value: params[:value])
79
+
80
+ self.channels << channel
81
+
82
+ channel
83
+
84
+ end
85
+
86
+ private
87
+
88
+ def application_client
89
+ @application_client ||= AppAuthenticatedClient.new
90
+ end
91
+
92
+ def self.application_client
93
+ @application_client ||= AppAuthenticatedClient.new
94
+ end
95
+
96
+ end
97
+ end
@@ -101,10 +101,6 @@ module Lifen
101
101
  UserAuthenticatedClient.new(token)
102
102
  end
103
103
 
104
- def fhir_payload
105
- { reference: "Practitioner/#{uuid}" }
106
- end
107
-
108
104
  # def self.where(params)
109
105
  # json = application_client.get("fhir/Practitioner/", params)
110
106
 
@@ -115,80 +111,6 @@ module Lifen
115
111
  # users
116
112
  # end
117
113
 
118
- def self.find_by_rpps(rpps)
119
- json = application_client.get("fhir/Practitioner/?identifier=#{rpps}")
120
-
121
-
122
-
123
- raise "User not found" if Array(json["entry"]).size != 1
124
-
125
- user_json = Array(json["entry"]).first.fetch("resource") { {} }
126
-
127
- user_json[:uuid] = user_json["id"]
128
-
129
- user = new(user_json)
130
-
131
- Array(user_json["telecom"]).each do |telecom_json|
132
- user.channels << Lifen::Channel.from_json(telecom_json, "telecom")
133
- end
134
-
135
- Array(user_json["address"]).each do |address_json|
136
- user.channels << Lifen::Channel.from_json(address_json, "address")
137
- end
138
-
139
- user
140
- end
141
-
142
- def create_address(params)
143
- filtered_params = {"resourceType" => "Practitioner"}
144
-
145
- address = {
146
- "line": Array(params[:lines]),
147
- "city": params[:city],
148
- "postalCode": params[:postal_code],
149
- "country": params[:country]
150
- }
151
-
152
- filtered_params[params[:type]] = address
153
-
154
- json = application_client.post("fhir/Practitioner/#{uuid}/$add-address", filtered_params)
155
-
156
- channel = Channel.new(uuid: json["issue"][0]["id"], type: params[:type], value: "#{Array(params[:lines]).join(", ")}, #{params[:postal_code]} #{params[:city]}")
157
-
158
- self.channels << channel
159
-
160
- channel
161
- end
162
-
163
- alias_method :create_channel, :create_address
164
-
165
- def self.from_json(json)
166
- reference = json["reference"]
167
-
168
- uuid = reference.gsub("Practitioner/", "")
169
-
170
- new(uuid: uuid)
171
- end
172
-
173
- def create_telecom(params)
174
- filtered_params = {"resourceType" => "Practitioner"}
175
-
176
- telecom = {
177
- "system": params[:system],
178
- "value": params[:value]
179
- }
180
-
181
- filtered_params[params[:type]] = telecom
182
-
183
- json = application_client.post("fhir/Practitioner/#{uuid}/$add-telecom", filtered_params)
184
-
185
- channel = Channel.new(uuid: json["issue"][0]["id"], type: params[:type], value: params[:value])
186
-
187
- self.channels << channel
188
-
189
- channel
190
-
191
- end
192
114
 
193
115
  private
194
116
 
@@ -1,3 +1,3 @@
1
1
  module Lifen
2
- VERSION = "2.4.0"
2
+ VERSION = "3.0.0"
3
3
  end
@@ -0,0 +1,71 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://develop.lifen.fr/fhir/Practitioner/11e5c85e-9bc0-4c6e-9b29-deb9993a92c0/$add-address
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"resourceType":"Practitioner","address":{"line":["Honestica","39 rue
9
+ d''Aboukir"],"city":"Paris","postalCode":"75002","country":"France"}}'
10
+ headers:
11
+ User-Agent:
12
+ - Faraday v0.11.0
13
+ Authorization:
14
+ - Bearer valid_application_access_token
15
+ Accept:
16
+ - application/json
17
+ Content-Type:
18
+ - application/json
19
+ Accept-Encoding:
20
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
21
+ response:
22
+ status:
23
+ code: 200
24
+ message: OK
25
+ headers:
26
+ Server:
27
+ - Apache-Coyote/1.1
28
+ X-B3-Sampled:
29
+ - '1'
30
+ X-B3-Spanid:
31
+ - 1471c2eb1e86756b
32
+ X-B3-Traceid:
33
+ - 1471c2eb1e86756b
34
+ X-Content-Type-Options:
35
+ - nosniff
36
+ X-Xss-Protection:
37
+ - 1; mode=block
38
+ Cache-Control:
39
+ - no-cache, no-store, max-age=0, must-revalidate
40
+ Pragma:
41
+ - no-cache
42
+ Expires:
43
+ - '0'
44
+ X-Powered-By:
45
+ - HAPI FHIR 2.4 REST Server (FHIR Server; FHIR 3.0.1/DSTU3)
46
+ Content-Type:
47
+ - application/json+fhir;charset=UTF-8
48
+ Transfer-Encoding:
49
+ - chunked
50
+ Date:
51
+ - Fri, 19 May 2017 15:07:35 GMT
52
+ Connection:
53
+ - close
54
+ Access-Control-Allow-Credentials:
55
+ - 'true'
56
+ body:
57
+ encoding: UTF-8
58
+ string: |-
59
+ {
60
+ "resourceType": "OperationOutcome",
61
+ "issue": [
62
+ {
63
+ "id": "11e73ca4-e3d4-8c5f-b5c5-0242ac110002",
64
+ "severity": "information",
65
+ "diagnostics": "Address created."
66
+ }
67
+ ]
68
+ }
69
+ http_version:
70
+ recorded_at: Fri, 19 May 2017 15:07:06 GMT
71
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,71 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://develop.lifen.fr/fhir/Practitioner/11e5c85e-9bc0-4c6e-9b29-deb9993a92c0/$add-address
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"resourceType":"Practitioner","address":{"line":["Honestica","39 rue
9
+ d''Aboukir"],"city":"Paris","postalCode":"75002","country":"France"}}'
10
+ headers:
11
+ User-Agent:
12
+ - Faraday v0.11.0
13
+ Authorization:
14
+ - Bearer valid_application_access_token
15
+ Accept:
16
+ - application/json
17
+ Content-Type:
18
+ - application/json
19
+ Accept-Encoding:
20
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
21
+ response:
22
+ status:
23
+ code: 200
24
+ message: OK
25
+ headers:
26
+ Server:
27
+ - Apache-Coyote/1.1
28
+ X-B3-Sampled:
29
+ - '1'
30
+ X-B3-Spanid:
31
+ - 6bdba43c90ff2827
32
+ X-B3-Traceid:
33
+ - 6bdba43c90ff2827
34
+ X-Content-Type-Options:
35
+ - nosniff
36
+ X-Xss-Protection:
37
+ - 1; mode=block
38
+ Cache-Control:
39
+ - no-cache, no-store, max-age=0, must-revalidate
40
+ Pragma:
41
+ - no-cache
42
+ Expires:
43
+ - '0'
44
+ X-Powered-By:
45
+ - HAPI FHIR 2.4 REST Server (FHIR Server; FHIR 3.0.1/DSTU3)
46
+ Content-Type:
47
+ - application/json+fhir;charset=UTF-8
48
+ Transfer-Encoding:
49
+ - chunked
50
+ Date:
51
+ - Fri, 19 May 2017 14:59:33 GMT
52
+ Connection:
53
+ - close
54
+ Access-Control-Allow-Credentials:
55
+ - 'true'
56
+ body:
57
+ encoding: UTF-8
58
+ string: |-
59
+ {
60
+ "resourceType": "OperationOutcome",
61
+ "issue": [
62
+ {
63
+ "id": "11e73ca3-c4b2-fe69-b5c5-0242ac110002",
64
+ "severity": "information",
65
+ "diagnostics": "Address created."
66
+ }
67
+ ]
68
+ }
69
+ http_version:
70
+ recorded_at: Fri, 19 May 2017 14:59:03 GMT
71
+ recorded_with: VCR 3.0.3