Class: FHIR::Model

Inherits:
Object
  • Object
show all
Defined in:
lib/fhir_client/ext/model.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.all(client = @@client) ⇒ Object



64
65
66
# File 'lib/fhir_client/ext/model.rb', line 64

def self.all(client = @@client)
  handle_response client.read_feed(self)
end

.conditional_create(model, params, client = @@client) ⇒ Object



59
60
61
62
# File 'lib/fhir_client/ext/model.rb', line 59

def self.conditional_create(model, params, client = @@client)
  model = new(model) unless model.is_a?(self)
  handle_response client.conditional_create(model, params)
end

.create(model, client = @@client) ⇒ Object



54
55
56
57
# File 'lib/fhir_client/ext/model.rb', line 54

def self.create(model, client = @@client)
  model = new(model) unless model.is_a?(self)
  handle_response client.create(model)
end

.read(id, client = @@client) ⇒ Object



22
23
24
# File 'lib/fhir_client/ext/model.rb', line 22

def self.read(id, client = @@client)
  handle_response client.read(self, id)
end

.read_with_summary(id, summary, client = @@client) ⇒ Object



26
27
28
# File 'lib/fhir_client/ext/model.rb', line 26

def self.read_with_summary(id, summary, client = @@client)
  handle_response client.read(self, id, client.default_format, summary)
end

.resource_history(client = @@client) ⇒ Object



34
35
36
# File 'lib/fhir_client/ext/model.rb', line 34

def self.resource_history(client = @@client)
  handle_response client.resource_history(self)
end

.resource_history_as_of(last_update, client = @@client) ⇒ Object



38
39
40
# File 'lib/fhir_client/ext/model.rb', line 38

def self.resource_history_as_of(last_update, client = @@client)
  handle_response client.resource_history_as_of(self, last_update)
end

.resource_instance_history(id, client = @@client) ⇒ Object



42
43
44
# File 'lib/fhir_client/ext/model.rb', line 42

def self.resource_instance_history(id, client = @@client)
  handle_response client.resource_instance_history(self, id)
end

.resource_instance_history_as_of(id, last_update, client = @@client) ⇒ Object



46
47
48
# File 'lib/fhir_client/ext/model.rb', line 46

def self.resource_instance_history_as_of(id, last_update, client = @@client)
  handle_response client.resource_instance_history_as_of(self, id, last_update)
end

.search(params = {}, client = @@client) ⇒ Object



50
51
52
# File 'lib/fhir_client/ext/model.rb', line 50

def self.search(params = {}, client = @@client)
  handle_response client.search(self, search: { parameters: params })
end

.vread(id, version_id, client = @@client) ⇒ Object



30
31
32
# File 'lib/fhir_client/ext/model.rb', line 30

def self.vread(id, version_id, client = @@client)
  handle_response client.vread(self, id, version_id)
end

Instance Method Details

#clientObject



5
6
7
# File 'lib/fhir_client/ext/model.rb', line 5

def client
  @@client
end

#client=(client) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fhir_client/ext/model.rb', line 9

def client=(client)
  @@client = client

  # Ensure the client-setting cascades to all child models
  instance_values.each do |_key, values|
    Array.wrap(values).each do |value|
      next unless value.is_a?(FHIR::Model)
      next if value.client == client
      value.client = client
    end
  end
end

#conditional_create(params) ⇒ Object



76
77
78
# File 'lib/fhir_client/ext/model.rb', line 76

def conditional_create(params)
  handle_response client.conditional_create(self, params)
end

#conditional_update(params) ⇒ Object



84
85
86
# File 'lib/fhir_client/ext/model.rb', line 84

def conditional_update(params)
  handle_response client.conditional_update(self, id, params)
end

#createObject



72
73
74
# File 'lib/fhir_client/ext/model.rb', line 72

def create
  handle_response client.create(self)
end

#destroyObject



88
89
90
91
# File 'lib/fhir_client/ext/model.rb', line 88

def destroy
  handle_response client.destroy(self.class, id) unless id.nil?
  nil
end

#resolve(reference) ⇒ Object



93
94
95
96
97
98
99
# File 'lib/fhir_client/ext/model.rb', line 93

def resolve(reference)
  if reference.contained?
    contained.detect { |c| c.id == reference.id }
  else
    reference.read
  end
end

#updateObject



80
81
82
# File 'lib/fhir_client/ext/model.rb', line 80

def update
  handle_response client.update(self, id)
end

#vread(version_id) ⇒ Object



68
69
70
# File 'lib/fhir_client/ext/model.rb', line 68

def vread(version_id)
  self.class.vread(id, version_id, client)
end