Class: Caren::Link

Inherits:
Base
  • Object
show all
Defined in:
lib/caren/link.rb

Instance Attribute Summary

Attributes inherited from Base

#attributes, #original_xml

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

from_xml, hash_from_image, init_dependent_objects, #initialize, #node_root, #resource_url, resource_url, search_url, #to_xml, to_xml

Constructor Details

This class inherits a constructor from Caren::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Caren::Base

Class Method Details

.all(session) ⇒ Object



33
34
35
# File 'lib/caren/link.rb', line 33

def self.all session
  from_xml session.get(self.resource_url)
end

.array_rootObject



49
50
51
# File 'lib/caren/link.rb', line 49

def self.array_root
  :links
end

.cancel_url(id = nil) ⇒ Object



61
62
63
# File 'lib/caren/link.rb', line 61

def self.cancel_url id=nil
  "#{resource_location}/#{id}/cancel"
end

.find(id, session) ⇒ Object



21
22
23
# File 'lib/caren/link.rb', line 21

def self.find id, session
  from_xml session.get(self.resource_url(id))
end

.keysObject



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/caren/link.rb', line 3

def self.keys
  [:id,               # Integer (Caren id)
   :person_name,      # String (Caren person name)
   :care_provider_id, # Integer
   :person_id,        # String (Caren person id)
   :person_photo,     # String (url of photo)
   :patient_number,   # String (12345)
   :external_id,      # String (Your person id)
   :status,           # String (pending,confirmed,cancelled)
   :skip_letter,      # Boolean
   :letter            # Base64 encoded pdf file
  ] + super
end

.node_rootObject



53
54
55
# File 'lib/caren/link.rb', line 53

def self.node_root
  :link
end

.pdf_url(id = nil) ⇒ Object



57
58
59
# File 'lib/caren/link.rb', line 57

def self.pdf_url id=nil
  "#{resource_location}/#{id}/pdf"
end

.resource_locationObject



65
66
67
# File 'lib/caren/link.rb', line 65

def self.resource_location
  "/api/pro/links"
end

.search(key, value, session) ⇒ Object



17
18
19
# File 'lib/caren/link.rb', line 17

def self.search key, value, session
  from_xml session.get( self.search_url(key,value) )
end

Instance Method Details

#as_xmlObject



43
44
45
46
47
# File 'lib/caren/link.rb', line 43

def as_xml
  { :patient_number => self.patient_number,
    :external_id => self.external_id,
    :skip_letter => self.skip_letter }
end

#cancel(session) ⇒ Object



25
26
27
# File 'lib/caren/link.rb', line 25

def cancel session
  self.class.from_xml session.put(self.class.cancel_url(self.id), "")
end

#create(session) ⇒ Object

Request to create a new link. Example: Caren::Link.new( :patient_number => 1234 ).create



39
40
41
# File 'lib/caren/link.rb', line 39

def create session
  self.class.from_xml session.post(self.resource_url, self.to_xml)
end

#pdf(session) ⇒ Object



29
30
31
# File 'lib/caren/link.rb', line 29

def pdf session
  self.class.from_xml session.get(self.class.pdf_url(self.id))
end