caren-api 0.11.1 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.11.1
1
+ 0.12.0
data/caren-api.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "caren-api"
8
- s.version = "0.11.1"
8
+ s.version = "0.12.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Andre Foeken"]
12
- s.date = "2013-04-12"
12
+ s.date = "2013-06-13"
13
13
  s.description = "You can use this gem as inspiration of the base of your connections with Caren."
14
14
  s.email = "andre.foeken@nedap.com"
15
15
  s.extra_rdoc_files = [
@@ -36,6 +36,7 @@ Gem::Specification.new do |s|
36
36
  "lib/caren/chat_session.rb",
37
37
  "lib/caren/chat_session_message.rb",
38
38
  "lib/caren/client.rb",
39
+ "lib/caren/dossier/dossier_entry.rb",
39
40
  "lib/caren/employee.rb",
40
41
  "lib/caren/error.rb",
41
42
  "lib/caren/event.rb",
@@ -43,6 +44,7 @@ Gem::Specification.new do |s|
43
44
  "lib/caren/event_slot_container.rb",
44
45
  "lib/caren/external_message.rb",
45
46
  "lib/caren/link.rb",
47
+ "lib/caren/person.rb",
46
48
  "lib/caren/store/account.rb",
47
49
  "lib/caren/store/account_entry.rb",
48
50
  "lib/caren/store/address.rb",
@@ -58,6 +60,7 @@ Gem::Specification.new do |s|
58
60
  "spec/chat_session_message_spec.rb",
59
61
  "spec/chat_session_spec.rb",
60
62
  "spec/client_spec.rb",
63
+ "spec/dossier/dossier_entry_spec.rb",
61
64
  "spec/employee_spec.rb",
62
65
  "spec/event_slot_container_spec.rb",
63
66
  "spec/event_slot_spec.rb",
@@ -83,6 +86,8 @@ Gem::Specification.new do |s|
83
86
  "spec/fixtures/caren_chat_session_message.xml",
84
87
  "spec/fixtures/caren_chat_session_messages.xml",
85
88
  "spec/fixtures/caren_chat_sessions.xml",
89
+ "spec/fixtures/caren_dossier_entries.xml",
90
+ "spec/fixtures/caren_dossier_entry.xml",
86
91
  "spec/fixtures/caren_event.xml",
87
92
  "spec/fixtures/caren_events.xml",
88
93
  "spec/fixtures/caren_external_message.xml",
data/lib/caren/caren.rb CHANGED
@@ -123,6 +123,7 @@ module Caren
123
123
  :chat_sessions => Caren::ChatSession,
124
124
  :chat_session_messages => Caren::ChatSessionMessage,
125
125
  :care_providers => Caren::CareProvider,
126
+ :dossier_entries => Caren::Dossier::DossierEntry,
126
127
  :billable_categories => Caren::Store::BillableCategory,
127
128
  :billables => Caren::Store::Billable,
128
129
  :invoices => Caren::Store::Invoice,
@@ -0,0 +1,76 @@
1
+ module Caren::Dossier ; end
2
+ class Caren::Dossier::DossierEntry < Caren::Base
3
+
4
+ def self.keys
5
+ [ :id, # Integer (Caren dossier entry id)
6
+ :type, # String
7
+ :value, # Float
8
+ :reporting_time, # DateTime
9
+ :person_name, # String (CP person name)
10
+ :external_id, # String (Your dossier entry id)
11
+ :external_person_id, # String (Your person id)
12
+ :care_provider_id, # Integer (Caren CP id)
13
+ :comment, # Text
14
+ :subject_id, # Integer (Caren person id)
15
+ :systolic_pressure, # Integer
16
+ :diastolic_pressure, # Integer
17
+ :heart_rate, # Integer
18
+ :bmi, # Float
19
+ :weight, # Float
20
+ :length # Integer
21
+ ] + super
22
+ end
23
+
24
+ def self.all subject_id, session
25
+ from_xml session.get(self.resource_url(subject_id))
26
+ end
27
+
28
+ def self.find subject_id, id, session
29
+ from_xml session.get(self.resource_url(subject_id,id))
30
+ end
31
+
32
+ def create session
33
+ self.class.from_xml session.post self.class.resource_url(self.subject_id), self.to_xml
34
+ end
35
+
36
+
37
+ def self.array_root
38
+ :dossier_entries
39
+ end
40
+
41
+ def self.node_root
42
+ :dossier_entry
43
+ end
44
+
45
+ def as_xml
46
+ { :type => self.type,
47
+ :external_id => self.external_id,
48
+ :external_person_id => self.external_person_id,
49
+ :subject_id => self.subject_id,
50
+ :person_name => self.person_name,
51
+ :comment => self.comment,
52
+ :value => self.value,
53
+ :reporting_time => self.reporting_time,
54
+ :systolic_pressure => self.systolic_pressure,
55
+ :diastolic_pressure => self.diastolic_pressure,
56
+ :heart_rate => self.heart_rate,
57
+ :bmi => self.bmi,
58
+ :weight => self.weight,
59
+ :length => self.length }
60
+ end
61
+
62
+ def self.resource_location
63
+ "/api/pro/people/%i/dossier_entries"
64
+ end
65
+
66
+ private
67
+
68
+ def resource_url subject_id, id=nil
69
+ self.class.resource_url(subject_id,id)
70
+ end
71
+
72
+ def self.resource_url subject_id, id=nil
73
+ "#{self.resource_location % subject_id}#{id}"
74
+ end
75
+
76
+ end
@@ -0,0 +1,40 @@
1
+ class Caren::Person < Caren::Base
2
+
3
+ def self.keys
4
+ [:id, # Integer (Caren id)
5
+ :first_name, # String
6
+ :last_name, # String
7
+ :male, # Boolean
8
+ :email, # String
9
+ :photo, # String
10
+ :link_id, # Integer
11
+ :external_id, # String
12
+ :citizen_service_number # String
13
+ ] + super
14
+ end
15
+
16
+ def self.search key, value, session
17
+ from_xml session.get( self.search_url(key,value) )
18
+ end
19
+
20
+ def self.find id, session
21
+ from_xml session.get(self.resource_url(id))
22
+ end
23
+
24
+ def self.all session
25
+ from_xml session.get(self.resource_url)
26
+ end
27
+
28
+ def self.array_root
29
+ :people
30
+ end
31
+
32
+ def self.node_root
33
+ :person
34
+ end
35
+
36
+ def self.resource_location
37
+ "/api/pro/people"
38
+ end
39
+
40
+ end
data/lib/caren-api.rb CHANGED
@@ -19,6 +19,7 @@ require "caren/external_message"
19
19
  require "caren/chat_session"
20
20
  require "caren/chat_session_message"
21
21
  require "caren/link"
22
+ require "caren/dossier/dossier_entry"
22
23
  require "caren/store/store"
23
24
  require "caren/store/billable"
24
25
  require "caren/store/billable_category"
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+
3
+ describe "DossierEntry", "converting to xml" do
4
+
5
+ before do
6
+ @dossier_entry_a = Caren::Dossier::DossierEntry.new :type => 'Dossier::TemperatureDossierEntry',
7
+ :external_person_id => 1,
8
+ :external_id => 1,
9
+ :person_name => 'Andre Foeken',
10
+ :comment => 'Burning up',
11
+ :value => 38.1
12
+
13
+ @dossier_entry_b = Caren::Dossier::DossierEntry.new :type => 'Dossier::BMIDossierEntry',
14
+ :external_person_id => 2,
15
+ :external_id => 2,
16
+ :person_name => 'Jan Willem Mooij',
17
+ :comment => 'Heavy weight',
18
+ :value => 38.1
19
+ end
20
+
21
+ it "should be able to convert a dossier entry to valid xml" do
22
+ @dossier_entry_a.should convert_to_valid_caren_xml
23
+ end
24
+
25
+ it "should be able to convert an array of dossier entries to valid xml" do
26
+ [@dossier_entry_a,@dossier_entry_b].should convert_to_valid_caren_array_xml
27
+ end
28
+
29
+ end
30
+
31
+ describe "DossierEntry", "REST methods" do
32
+
33
+ before do
34
+ message = File.read("spec/fixtures/caren_dossier_entry.xml")
35
+ messages = File.read("spec/fixtures/caren_dossier_entries.xml")
36
+
37
+ entries_url = Caren::Api.session.url_for( Caren::Dossier::DossierEntry.resource_url(1) )
38
+ entry_url = Caren::Api.session.url_for( Caren::Dossier::DossierEntry.resource_url(1,1) )
39
+ timestamp = DateTime.now.to_i
40
+
41
+ FakeWeb.register_uri(:get, entries_url, :body => messages, :signature => Caren::Api.session.sign(timestamp,nil,messages), :timestamp => timestamp )
42
+ FakeWeb.register_uri(:get, entry_url, :body => message, :signature => Caren::Api.session.sign(timestamp,nil,message), :timestamp => timestamp )
43
+ FakeWeb.register_uri(:post, entries_url, :status => 201, :signature => Caren::Api.session.sign(timestamp), :timestamp => timestamp )
44
+ FakeWeb.register_uri(:delete, entry_url, :signature => Caren::Api.session.sign(timestamp), :timestamp => timestamp )
45
+ end
46
+
47
+ it "should be able to find all dossier entries" do
48
+ messages = Caren::Dossier::DossierEntry.all 1, Caren::Api.session
49
+ messages.should have(2).things
50
+ messages.first.comment.should == "Test"
51
+ end
52
+
53
+ it "should be able to find one dossier entry" do
54
+ message = Caren::Dossier::DossierEntry.find 1, 1, Caren::Api.session
55
+ message.comment.should == "Test"
56
+ end
57
+
58
+ it "should be able to create a dossier entry" do
59
+ lambda{ Caren::Dossier::DossierEntry.new :type => 'Dossier::ReportDossierEntry',
60
+ :external_person_id => 1,
61
+ :external_id => 1,
62
+ :person_name => 'Andre Foeken',
63
+ :comment => 'This guy is a dude' }.should_not raise_error
64
+ end
65
+
66
+ end
@@ -0,0 +1,41 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <dossier-entries type="array">
3
+ <dossier-entry>
4
+ <bmi type="float" nil="true"/>
5
+ <care-provider-id type="integer">4098</care-provider-id>
6
+ <care-provider-name>Zuwe</care-provider-name>
7
+ <comment>Test</comment>
8
+ <diastolic-pressure type="integer" nil="true"/>
9
+ <external-id>1</external-id>
10
+ <external-person-id nil="true"/>
11
+ <heart-rate type="integer" nil="true"/>
12
+ <id type="integer">2065</id>
13
+ <length type="integer" nil="true"/>
14
+ <person-name>Ruben</person-name>
15
+ <reporting-time type="datetime">2013-04-19T14:17:44+02:00</reporting-time>
16
+ <subject-id type="integer">1</subject-id>
17
+ <systolic-pressure type="integer" nil="true"/>
18
+ <type>Dossier::ReportDossierEntry</type>
19
+ <value type="float" nil="true"/>
20
+ <weight type="float" nil="true"/>
21
+ </dossier-entry>
22
+ <dossier-entry>
23
+ <bmi type="float" nil="true"/>
24
+ <care-provider-id type="integer">4098</care-provider-id>
25
+ <care-provider-name>Zuwe</care-provider-name>
26
+ <comment>Something important concerning this dossier-entry</comment>
27
+ <diastolic-pressure type="integer" nil="true"/>
28
+ <external-id>1</external-id>
29
+ <external-person-id nil="true"/>
30
+ <heart-rate type="integer" nil="true"/>
31
+ <id type="integer">2066</id>
32
+ <length type="integer" nil="true"/>
33
+ <person-name>Ruben</person-name>
34
+ <reporting-time type="datetime">2013-04-19T14:17:44+02:00</reporting-time>
35
+ <subject-id type="integer">1</subject-id>
36
+ <systolic-pressure type="integer" nil="true"/>
37
+ <type>Dossier::BulletinBoardDossierEntry</type>
38
+ <value type="float" nil="true"/>
39
+ <weight type="float" nil="true"/>
40
+ </dossier-entry>
41
+ </dossier-entries>
@@ -0,0 +1,20 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <dossier-entry>
3
+ <bmi type="float" nil="true"/>
4
+ <care-provider-id type="integer">4100</care-provider-id>
5
+ <care-provider-name>Zuwe</care-provider-name>
6
+ <comment>Test</comment>
7
+ <diastolic-pressure type="integer" nil="true"/>
8
+ <external-id>1</external-id>
9
+ <external-person-id nil="true"/>
10
+ <heart-rate type="integer" nil="true"/>
11
+ <id type="integer">2072</id>
12
+ <length type="integer" nil="true"/>
13
+ <person-name>Ruben</person-name>
14
+ <reporting-time type="datetime">2013-04-19T14:22:14+02:00</reporting-time>
15
+ <subject-id type="integer">1</subject-id>
16
+ <systolic-pressure type="integer" nil="true"/>
17
+ <type>Dossier::ReportDossierEntry</type>
18
+ <value type="float" nil="true"/>
19
+ <weight type="float" nil="true"/>
20
+ </dossier-entry>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caren-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
4
+ version: 0.12.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-12 00:00:00.000000000 Z
12
+ date: 2013-06-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: i18n
@@ -183,6 +183,7 @@ files:
183
183
  - lib/caren/chat_session.rb
184
184
  - lib/caren/chat_session_message.rb
185
185
  - lib/caren/client.rb
186
+ - lib/caren/dossier/dossier_entry.rb
186
187
  - lib/caren/employee.rb
187
188
  - lib/caren/error.rb
188
189
  - lib/caren/event.rb
@@ -190,6 +191,7 @@ files:
190
191
  - lib/caren/event_slot_container.rb
191
192
  - lib/caren/external_message.rb
192
193
  - lib/caren/link.rb
194
+ - lib/caren/person.rb
193
195
  - lib/caren/store/account.rb
194
196
  - lib/caren/store/account_entry.rb
195
197
  - lib/caren/store/address.rb
@@ -205,6 +207,7 @@ files:
205
207
  - spec/chat_session_message_spec.rb
206
208
  - spec/chat_session_spec.rb
207
209
  - spec/client_spec.rb
210
+ - spec/dossier/dossier_entry_spec.rb
208
211
  - spec/employee_spec.rb
209
212
  - spec/event_slot_container_spec.rb
210
213
  - spec/event_slot_spec.rb
@@ -230,6 +233,8 @@ files:
230
233
  - spec/fixtures/caren_chat_session_message.xml
231
234
  - spec/fixtures/caren_chat_session_messages.xml
232
235
  - spec/fixtures/caren_chat_sessions.xml
236
+ - spec/fixtures/caren_dossier_entries.xml
237
+ - spec/fixtures/caren_dossier_entry.xml
233
238
  - spec/fixtures/caren_event.xml
234
239
  - spec/fixtures/caren_events.xml
235
240
  - spec/fixtures/caren_external_message.xml
@@ -271,7 +276,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
271
276
  version: '0'
272
277
  segments:
273
278
  - 0
274
- hash: 3998427801995676370
279
+ hash: 4515662501562381571
275
280
  required_rubygems_version: !ruby/object:Gem::Requirement
276
281
  none: false
277
282
  requirements: