lifen_fhir 0.4.1 → 0.4.2

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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -1
  3. data/Gemfile.lock +50 -1
  4. data/Guardfile +5 -0
  5. data/README.md +3 -1
  6. data/lib/lifen_fhir/address.rb +5 -5
  7. data/lib/lifen_fhir/base.rb +10 -0
  8. data/lib/lifen_fhir/binary.rb +2 -18
  9. data/lib/lifen_fhir/category.rb +6 -0
  10. data/lib/lifen_fhir/channel.rb +11 -3
  11. data/lib/lifen_fhir/communication_request.rb +14 -15
  12. data/lib/lifen_fhir/element.rb +37 -0
  13. data/lib/lifen_fhir/medium.rb +1 -3
  14. data/lib/lifen_fhir/patient.rb +11 -19
  15. data/lib/lifen_fhir/practitioner.rb +5 -36
  16. data/lib/lifen_fhir/telecom.rb +23 -0
  17. data/lib/lifen_fhir/version.rb +1 -1
  18. data/lib/lifen_fhir.rb +14 -1
  19. data/lifen_fhir.gemspec +4 -0
  20. data/spec/binary_spec.rb +7 -7
  21. data/spec/cassettes/communication_request/find_by_uuid/valid_uuid_with_no_status.yml +1 -1
  22. data/spec/cassettes/communication_request/send/unknown_binary.yml +62 -0
  23. data/spec/cassettes/communication_request/send/unknown_recipient.yml +63 -0
  24. data/spec/cassettes/patient/create/invalid_attributes.yml +63 -0
  25. data/spec/cassettes/patient/create/with_all_information.yml +1 -1
  26. data/spec/cassettes/patient/create/with_first_name_as_a_string.yml +65 -0
  27. data/spec/cassettes/practitioner/create_channel/address/invalid_attributes.yml +62 -0
  28. data/spec/cassettes/{practitionner → practitioner}/create_channel/address/old_valid_attributes.yml +0 -0
  29. data/spec/cassettes/{practitionner → practitioner}/create_channel/address/valid_attributes.yml +0 -0
  30. data/spec/cassettes/practitioner/create_channel/telecom/invalid_attributes.yml +62 -0
  31. data/spec/cassettes/{practitionner → practitioner}/create_channel/telecom/valid_attributes.yml +0 -0
  32. data/spec/cassettes/{practitionner → practitioner}/find_by_rpps/existing_rpps.yml +0 -0
  33. data/spec/cassettes/{practitionner → practitioner}/find_by_rpps/missing_line_attribute.yml +0 -0
  34. data/spec/cassettes/{practitionner → practitioner}/find_by_rpps/wrong_rpps.yml +0 -0
  35. data/spec/communication_request_spec.rb +105 -62
  36. data/spec/patient_spec.rb +53 -12
  37. data/spec/practitioner_spec.rb +105 -0
  38. data/spec/reference_spec.rb +29 -8
  39. data/spec/spec_helper.rb +10 -0
  40. metadata +73 -17
  41. data/lib/lifen_fhir/reference.rb +0 -23
  42. data/spec/practitionner_spec.rb +0 -76
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4a0ed993d46baf68edddbda17ef20c4140ddf0d
4
- data.tar.gz: 7b45c21f3d3a4b98518b36a2550d99ecd538c196
3
+ metadata.gz: 444903207c6344dafb7a9fc38f6bec501fa136c4
4
+ data.tar.gz: 823d8c0d7bd31e27c15f6d39cc31ebdf8d2ecd35
5
5
  SHA512:
6
- metadata.gz: 785f0ce96c4bd01f49958de43f553162619f41ec6fba062fbad1426e8737d743eba9c6b7bff2d07cd684dab13591fd8693d63f49700e5a58260b32c0a1ab705d
7
- data.tar.gz: 1949b2369f4c939fb7979d55635ed4142a4c45bac6bd26e96988ffb95e2dee573c17ca49b0dca96b8d0b913a0f3e99de77a2b54331caa1179d85b2a7e7ef231b
6
+ metadata.gz: 4bc7ee300eb9427f5100c08e996e406d2d14a4235b8e4340543c065c727a656dae4c610e731e174f532fe8bbbd67a9eb4f8605598ec2b3a14b4a81952f929001
7
+ data.tar.gz: c6a2b3e3baf246bc3494e1e7feff523b14563f31a325bfe8a743e6d391ea5912626c0a2a85bfcad28a90301c89efc7b844d53dfbaaaf900e65ed5636e68fa5bb
data/CHANGELOG.md CHANGED
@@ -1,8 +1,13 @@
1
- 0.4.1
1
+ 0.4.2
2
2
  -----
3
3
 
4
4
  - Fixed incorrect FHIR payload for Patient
5
5
 
6
+ 0.4.1
7
+ -----
8
+
9
+ - Fixed empty birthDate issue with FHIR payload for Patient
10
+
6
11
  0.4.0
7
12
  -----
8
13
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lifen_fhir (0.4.1)
4
+ lifen_fhir (0.4.2)
5
5
  faraday (>= 0.9)
6
6
  inflecto
7
7
  virtus (>= 1.0)
@@ -16,6 +16,7 @@ GEM
16
16
  descendants_tracker (~> 0.0.4)
17
17
  ice_nine (~> 0.11.0)
18
18
  thread_safe (~> 0.3, >= 0.3.1)
19
+ coderay (1.1.1)
19
20
  coercible (1.0.0)
20
21
  descendants_tracker (~> 0.0.1)
21
22
  crack (0.4.3)
@@ -23,15 +24,51 @@ GEM
23
24
  descendants_tracker (0.0.4)
24
25
  thread_safe (~> 0.3, >= 0.3.1)
25
26
  diff-lcs (1.3)
27
+ docile (1.1.5)
26
28
  equalizer (0.0.11)
27
29
  faraday (0.12.1)
28
30
  multipart-post (>= 1.2, < 3)
31
+ ffi (1.9.18)
32
+ formatador (0.2.5)
33
+ guard (2.14.1)
34
+ formatador (>= 0.2.4)
35
+ listen (>= 2.7, < 4.0)
36
+ lumberjack (~> 1.0)
37
+ nenv (~> 0.1)
38
+ notiffany (~> 0.0)
39
+ pry (>= 0.9.12)
40
+ shellany (~> 0.0)
41
+ thor (>= 0.18.1)
42
+ guard-compat (1.2.1)
43
+ guard-rspec (4.7.3)
44
+ guard (~> 2.1)
45
+ guard-compat (~> 1.1)
46
+ rspec (>= 2.99.0, < 4.0)
29
47
  hashdiff (0.3.4)
30
48
  ice_nine (0.11.2)
31
49
  inflecto (0.0.2)
50
+ json (2.0.3)
51
+ listen (3.1.5)
52
+ rb-fsevent (~> 0.9, >= 0.9.4)
53
+ rb-inotify (~> 0.9, >= 0.9.7)
54
+ ruby_dep (~> 1.2)
55
+ lumberjack (1.0.11)
56
+ method_source (0.8.2)
32
57
  multipart-post (2.0.0)
58
+ nenv (0.3.0)
59
+ notiffany (0.1.1)
60
+ nenv (~> 0.1)
61
+ shellany (~> 0.0)
62
+ pry (0.10.4)
63
+ coderay (~> 1.1.0)
64
+ method_source (~> 0.8.1)
65
+ slop (~> 3.4)
33
66
  public_suffix (2.0.5)
34
67
  rake (10.5.0)
68
+ rb-fsevent (0.9.8)
69
+ rb-inotify (0.9.8)
70
+ ffi (>= 0.5.0)
71
+ rb-readline (0.5.4)
35
72
  rspec (3.6.0)
36
73
  rspec-core (~> 3.6.0)
37
74
  rspec-expectations (~> 3.6.0)
@@ -45,7 +82,16 @@ GEM
45
82
  diff-lcs (>= 1.2.0, < 2.0)
46
83
  rspec-support (~> 3.6.0)
47
84
  rspec-support (3.6.0)
85
+ ruby_dep (1.5.0)
48
86
  safe_yaml (1.0.4)
87
+ shellany (0.0.1)
88
+ simplecov (0.14.1)
89
+ docile (~> 1.1.0)
90
+ json (>= 1.8, < 3)
91
+ simplecov-html (~> 0.10.0)
92
+ simplecov-html (0.10.0)
93
+ slop (3.6.0)
94
+ thor (0.19.4)
49
95
  thread_safe (0.3.6)
50
96
  vcr (3.0.3)
51
97
  virtus (1.0.5)
@@ -64,9 +110,12 @@ PLATFORMS
64
110
  DEPENDENCIES
65
111
  awesome_print
66
112
  bundler (~> 1.12)
113
+ guard-rspec
67
114
  lifen_fhir!
68
115
  rake (~> 10.5)
116
+ rb-readline
69
117
  rspec (~> 3.5)
118
+ simplecov
70
119
  vcr (~> 3.0)
71
120
  webmock (~> 1.24)
72
121
 
data/Guardfile ADDED
@@ -0,0 +1,5 @@
1
+ guard :rspec, cmd: 'rspec' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/lifen_fhir/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
data/README.md CHANGED
@@ -100,9 +100,11 @@ channel = recipient.create_telecom(type: "telecom", system: "fax", value: "+3310
100
100
  ```ruby
101
101
  # To create a new patient
102
102
  address = LifenFhir::Address.new(lines: ["39 rue d'Aboukir"], city: "Paris", postal_code: "75002")
103
+
103
104
  patient = LifenFhir::Patient.create(first_name: ["Jean", "Charles"], last_name: "Dupond", birth_date: Date.new(1974, 12, 25), address: address)
105
+ patient = LifenFhir::Patient.create(first_name: "Jean", last_name: "Dupond", birth_date: Date.new(1974, 12, 25), address: address)
104
106
 
105
- # To find a patient by id
107
+ # To find a patient
106
108
  patient = LifenFhir::Patient.find_by_uuid("c3f96278-3bfe-4933-96e7-171ebca7489f")
107
109
 
108
110
  # To set the patient as a recipient in a CommunicationRequest
@@ -1,11 +1,10 @@
1
1
  module LifenFhir
2
- class Address < Base
3
-
4
- attribute :uuid, String
2
+ class Address < Element
5
3
 
6
4
  attribute :lines, [String]
7
5
  attribute :postal_code, String
8
6
  attribute :city, String
7
+ attribute :country, String
9
8
 
10
9
  def attributes_from_json(json)
11
10
  self.lines = Array(json.fetch("line"))
@@ -17,11 +16,12 @@ module LifenFhir
17
16
  self
18
17
  end
19
18
 
20
- def create_payload
19
+ def fhir_payload
21
20
  {
22
21
  "line": lines,
23
22
  "city": city,
24
- "postalCode": postal_code
23
+ "postalCode": postal_code,
24
+ "country": country
25
25
  }
26
26
  end
27
27
 
@@ -3,5 +3,15 @@ module LifenFhir
3
3
 
4
4
  include Virtus.model
5
5
 
6
+ private
7
+
8
+ def application_client
9
+ @application_client ||= AppAuthenticatedClient.new
10
+ end
11
+
12
+ def self.application_client
13
+ @application_client ||= AppAuthenticatedClient.new
14
+ end
15
+
6
16
  end
7
17
  end
@@ -1,7 +1,5 @@
1
1
  module LifenFhir
2
- class Binary < Base
3
-
4
- attribute :uuid, String
2
+ class Binary < Element
5
3
 
6
4
  def fhir_payload
7
5
  {
@@ -16,24 +14,10 @@ module LifenFhir
16
14
  end
17
15
 
18
16
  def attributes_from_json(json)
19
- first_binary = Array(json).first
20
-
21
- reference = first_binary["contentReference"]["reference"]
22
-
23
- self.uuid = reference.gsub('Binary/', '')
24
-
25
- self
17
+ super(json["contentReference"])
26
18
  end
27
19
 
28
20
  private
29
21
 
30
- def application_client
31
- @application_client ||= AppAuthenticatedClient.new
32
- end
33
-
34
- def reference
35
- LifenFhir::Reference.new(self).to_s
36
- end
37
-
38
22
  end
39
23
  end
@@ -18,6 +18,12 @@ module LifenFhir
18
18
  }
19
19
  end
20
20
 
21
+ def attributes_from_json(json)
22
+ self.code = Array(json["coding"]).first.fetch "code"
23
+
24
+ self
25
+ end
26
+
21
27
  def valid?
22
28
  CODES.include? code
23
29
  end
@@ -1,10 +1,11 @@
1
1
  module LifenFhir
2
- class Channel < Base
2
+ class Channel < Element
3
3
 
4
- attribute :uuid, String
5
4
  attribute :type, String
6
5
  attribute :value, String
7
6
 
7
+ attribute :telecom, LifenFhir::Telecom
8
+
8
9
  def fhir_payload(user)
9
10
  raise LifenFhir::Error, "Invalid channel: an UUID is required" if !valid?
10
11
 
@@ -24,7 +25,14 @@ module LifenFhir
24
25
  end
25
26
 
26
27
  def self.from_json(json, type = nil)
27
- new(uuid: json["id"], type: type, value: json["value"] || "#{Array(json["line"]).join(", ")}, #{json["postalCode"]} #{json["city"]}")
28
+ if type == "telecom"
29
+ telecom = Telecom.new.attributes_from_json(json)
30
+
31
+ new(uuid: telecom.uuid, type: type, value: telecom.value)
32
+ else
33
+
34
+ new(uuid: json["id"], type: type, value: "#{Array(json["line"]).join(", ")}, #{json["postalCode"]} #{json["city"]}")
35
+ end
28
36
  end
29
37
 
30
38
  end
@@ -1,11 +1,10 @@
1
1
  module LifenFhir
2
- class CommunicationRequest < Base
2
+ class CommunicationRequest < Element
3
3
 
4
- attribute :uuid, String
5
4
  attribute :number_communications, Integer
6
5
 
7
- attribute :sender, LifenFhir::Reference
8
- attribute :recipients, [LifenFhir::Reference]
6
+ attribute :sender, LifenFhir::Sender
7
+ attribute :recipients, [LifenFhir::Recipient]
9
8
 
10
9
  attribute :category, LifenFhir::Category, default: LifenFhir::Category.new
11
10
  attribute :medium, [LifenFhir::Medium]
@@ -39,7 +38,15 @@ module LifenFhir
39
38
 
40
39
  self.status = json.fetch("status") { "unknown" }
41
40
 
42
- self.binary = Binary.new.attributes_from_json(json["payload"])
41
+ self.binary = Binary.new.attributes_from_json(Array(json["payload"]).first)
42
+
43
+ self.category = Category.new.attributes_from_json(Array(json["category"]).first)
44
+
45
+ self.sender = Practitioner.new.attributes_from_json(json["sender"])
46
+
47
+ self.recipients = Array(json["recipient"]).map do |recipient_json|
48
+ Practitioner.new.attributes_from_json(recipient_json)
49
+ end
43
50
  end
44
51
 
45
52
  private
@@ -48,8 +55,8 @@ module LifenFhir
48
55
 
49
56
  payload = {
50
57
  resourceType: "CommunicationRequest",
51
- sender: [ sender.fhir_payload ],
52
- recipient: recipients.map(&:fhir_payload),
58
+ sender: [ sender.fhir_payload_as_reference ],
59
+ recipient: recipients.map(&:fhir_payload_as_reference),
53
60
  contained: [],
54
61
  medium: medium.map(&:fhir_payload) ,
55
62
  category: [ category.fhir_payload],
@@ -78,13 +85,5 @@ module LifenFhir
78
85
  end
79
86
  end
80
87
 
81
- def application_client
82
- @application_client ||= AppAuthenticatedClient.new
83
- end
84
-
85
- def self.application_client
86
- @application_client ||= AppAuthenticatedClient.new
87
- end
88
-
89
88
  end
90
89
  end
@@ -0,0 +1,37 @@
1
+ module LifenFhir
2
+ class Element < Base
3
+
4
+ attribute :uuid, String
5
+
6
+ def reference
7
+ "#{resource_type}/#{uuid}"
8
+ end
9
+
10
+ def attributes_from_json(json)
11
+ self.uuid = extract_uuid(json["reference"])
12
+
13
+ self
14
+ end
15
+
16
+ def fhir_payload_as_reference
17
+ { reference: reference }
18
+ end
19
+
20
+ private
21
+
22
+ def extract_uuid(uuid_or_reference)
23
+ if m = uuid_or_reference.match(/^#(.*)/) # "#1234-abcd-5678'
24
+ return m[1]
25
+ elsif m = uuid_or_reference.match(/(.*)\/(.*)/) # "Binary/1234-abcd-5678'
26
+ return m[2]
27
+ else
28
+ return uuid_or_reference
29
+ end
30
+ end
31
+
32
+ def resource_type
33
+ self.class.name.gsub!('LifenFhir::', '')
34
+ end
35
+
36
+ end
37
+ end
@@ -1,7 +1,5 @@
1
1
  module LifenFhir
2
- class Medium < Base
3
-
4
- attribute :uuid, String
2
+ class Medium < Element
5
3
 
6
4
  def fhir_payload
7
5
  {
@@ -1,7 +1,5 @@
1
1
  module LifenFhir
2
- class Patient < Base
3
-
4
- attribute :uuid, String
2
+ class Patient < Element
5
3
 
6
4
  attribute :first_name, [String]
7
5
  attribute :last_name, String
@@ -23,16 +21,16 @@ module LifenFhir
23
21
 
24
22
  def self.find_by_uuid(uuid)
25
23
  patient = new(uuid:uuid)
26
- json = application_client.get("fhir/#{LifenFhir::Reference.new(patient)}")
27
24
 
28
- patient = new
25
+ json = application_client.get("fhir/#{patient.reference}")
26
+
29
27
  patient.attributes_from_json(json)
30
28
 
31
29
  patient
32
30
  end
33
31
 
34
32
  def fhir_payload
35
- {
33
+ fhir_payload = {
36
34
  id: "patient",
37
35
  resourceType: "Patient",
38
36
  name: [
@@ -40,9 +38,10 @@ module LifenFhir
40
38
  family: last_name,
41
39
  given: first_name
42
40
  }
43
- ],
44
- birthDate: birth_date.to_s
41
+ ]
45
42
  }
43
+ fhir_payload[:birthDate] = birth_date.to_s if birth_date
44
+ fhir_payload
46
45
  end
47
46
 
48
47
  def attributes_from_json(json)
@@ -72,23 +71,16 @@ module LifenFhir
72
71
 
73
72
  if address
74
73
  filtered_params["address"] = [
75
- address.create_payload
74
+ address.fhir_payload
76
75
  ]
77
76
  end
78
77
 
79
- filtered_params["birthDate"] = birth_date.to_s
78
+ if birth_date
79
+ filtered_params["birthDate"] = birth_date.to_s
80
+ end
80
81
 
81
82
  filtered_params
82
83
  end
83
84
 
84
- def application_client
85
- @application_client ||= AppAuthenticatedClient.new
86
- end
87
-
88
-
89
- def self.application_client
90
- @application_client ||= AppAuthenticatedClient.new
91
- end
92
-
93
85
  end
94
86
  end
@@ -1,9 +1,8 @@
1
1
  module LifenFhir
2
- class Practitioner < Base
2
+ class Practitioner < Element
3
3
 
4
4
  attribute :channels, [LifenFhir::Channel]
5
5
 
6
- attribute :uuid, String
7
6
  attribute :last_name, String
8
7
  attribute :first_name, String
9
8
  attribute :rpps, String
@@ -37,14 +36,8 @@ module LifenFhir
37
36
  def create_address(params)
38
37
  filtered_params = {"resourceType" => "Practitioner"}
39
38
 
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
39
+ address = Address.new(params)
40
+ filtered_params[params[:type]] = address.fhir_payload
48
41
 
49
42
  json = application_client.post("fhir/#{reference}/$add-address", filtered_params)
50
43
 
@@ -55,23 +48,11 @@ module LifenFhir
55
48
  channel
56
49
  end
57
50
 
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
51
  def create_telecom(params)
67
52
  filtered_params = {"resourceType" => "Practitioner"}
68
53
 
69
- telecom = {
70
- "system": params[:system],
71
- "value": params[:value]
72
- }
73
-
74
- filtered_params[params[:type]] = telecom
54
+ telecom = Telecom.new(params)
55
+ filtered_params[params[:type]] = telecom.fhir_payload
75
56
 
76
57
  json = application_client.post("fhir/#{reference}/$add-telecom", filtered_params)
77
58
 
@@ -83,19 +64,7 @@ module LifenFhir
83
64
 
84
65
  end
85
66
 
86
- def reference
87
- LifenFhir::Reference.new(self).to_s
88
- end
89
-
90
67
  private
91
68
 
92
- def application_client
93
- @application_client ||= AppAuthenticatedClient.new
94
- end
95
-
96
- def self.application_client
97
- @application_client ||= AppAuthenticatedClient.new
98
- end
99
-
100
69
  end
101
70
  end
@@ -0,0 +1,23 @@
1
+ module LifenFhir
2
+ class Telecom < Element
3
+
4
+ attribute :system, String
5
+ attribute :value, String
6
+
7
+ def attributes_from_json(json)
8
+ self.uuid = json.fetch("id")
9
+ self.system = json.fetch("system")
10
+ self.value = json.fetch("value")
11
+
12
+ self
13
+ end
14
+
15
+ def fhir_payload
16
+ {
17
+ "system": system,
18
+ "value": value
19
+ }
20
+ end
21
+
22
+ end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module LifenFhir
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
data/lib/lifen_fhir.rb CHANGED
@@ -5,6 +5,18 @@ module LifenFhir
5
5
  require 'inflecto'
6
6
  require 'base64'
7
7
 
8
+ class Recipient < Virtus::Attribute
9
+ def coerce(value)
10
+ (value.is_a?(Practitioner) or value.is_a?(Patient) or value.nil?) ? value : raise(Error)
11
+ end
12
+ end
13
+
14
+ class Sender < Virtus::Attribute
15
+ def coerce(value)
16
+ (value.is_a?(Practitioner) or value.nil?) ? value : raise(Error)
17
+ end
18
+ end
19
+
8
20
  require "lifen_fhir/version"
9
21
 
10
22
  require 'lifen_fhir/error'
@@ -13,9 +25,10 @@ module LifenFhir
13
25
  require 'lifen_fhir/app_authenticated_client'
14
26
  require 'lifen_fhir/configuration'
15
27
  require 'lifen_fhir/base'
28
+ require 'lifen_fhir/element'
16
29
 
17
- require 'lifen_fhir/reference'
18
30
  require 'lifen_fhir/address'
31
+ require 'lifen_fhir/telecom'
19
32
  require 'lifen_fhir/channel'
20
33
  require 'lifen_fhir/practitioner'
21
34
  require 'lifen_fhir/category'
data/lifen_fhir.gemspec CHANGED
@@ -23,6 +23,10 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "vcr", '~> 3.0'
24
24
  spec.add_development_dependency "webmock", '~> 1.24'
25
25
  spec.add_development_dependency "awesome_print"
26
+ spec.add_development_dependency "simplecov"
27
+ spec.add_development_dependency "guard-rspec"
28
+ spec.add_development_dependency "rb-readline"
29
+
26
30
 
27
31
  spec.add_runtime_dependency "virtus", '>= 1.0'
28
32
  spec.add_runtime_dependency "inflecto"
data/spec/binary_spec.rb CHANGED
@@ -2,28 +2,28 @@ require 'spec_helper'
2
2
 
3
3
  describe LifenFhir::Binary do
4
4
 
5
- describe ':download with right uuid' do
5
+ describe ':download' do
6
6
 
7
7
  let(:binary) { LifenFhir::Binary.new(uuid: "valid_binary_id") }
8
8
 
9
9
  it 'works' do
10
-
11
10
  VCR.use_cassette "binary/download/valid" do
12
11
  expect(Digest::MD5.hexdigest(binary.download)).to eq("2285abb032c5e9054a518690b4701ab6")
13
12
  end
14
13
  end
15
- end
16
-
17
- describe ':download with right uuid' do
18
14
 
19
- let(:binary) { LifenFhir::Binary.new(uuid: "wrong-binary-uuid") }
15
+ context 'with invalid uuid' do
20
16
 
21
- it 'fails with wrong uuid' do
17
+ let(:binary) { LifenFhir::Binary.new(uuid: "wrong-binary-uuid") }
22
18
 
19
+ it 'fails nicely' do
23
20
  VCR.use_cassette "binary/download/invalid" do
24
21
  expect{ binary.download }.to raise_error LifenFhir::Error
25
22
  end
26
23
  end
27
24
 
28
25
  end
26
+
29
27
  end
28
+
29
+ end
@@ -66,7 +66,7 @@ http_interactions:
66
66
  "coding": [
67
67
  {
68
68
  "system": "http://honestica.com/fhir/communication/category",
69
- "code": "MEDICAL_REPORT"
69
+ "code": "MEDICATION_ORDER"
70
70
  }
71
71
  ]
72
72
  }