Class: Orthanc::Client

Inherits:
Object
  • Object
show all
Includes:
Response
Defined in:
lib/orthanc/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Response

#bool_to_num, #handle_response, #num_to_bool

Constructor Details

#initialize(host = "localhost", port = 8042) ⇒ Client

Returns a new instance of Client.



20
21
22
# File 'lib/orthanc/client.rb', line 20

def initialize(host = "localhost", port = 8042)
  self.base_uri = RestClient::Resource.new("http://#{host}:#{port}")
end

Instance Attribute Details

#base_uriObject

Returns the value of attribute base_uri.



18
19
20
# File 'lib/orthanc/client.rb', line 18

def base_uri
  @base_uri
end

Instance Method Details

#changes(params = {}) ⇒ Object

GET /changes



37
38
39
# File 'lib/orthanc/client.rb', line 37

def changes(params = {}) # "last", "limit" and "since" arguments
  handle_response(base_uri["changes"].get({params: params}))
end

#delete_changes(params = {}) ⇒ Object

DELETE /changes



42
43
44
# File 'lib/orthanc/client.rb', line 42

def delete_changes(params = {}) # "last", "limit" and "since" arguments
  handle_response(base_uri["changes"].delete({params: params}))
end

#delete_exports(params = {}) ⇒ Object

DELETE /exports



52
53
54
# File 'lib/orthanc/client.rb', line 52

def delete_exports(params = {}) # "last", "limit" and "since" arguments
  handle_response(base_uri["exports"].delete({params: params}))
end

#exports(params = {}) ⇒ Object

GET /exports



47
48
49
# File 'lib/orthanc/client.rb', line 47

def exports(params = {}) # "last", "limit" and "since" arguments
  handle_response(base_uri["exports"].get({params: params}))
end

#instances(id = nil) ⇒ Object

As class instances, for method chaining



187
188
189
190
191
192
193
194
195
196
197
# File 'lib/orthanc/client.rb', line 187

def instances(id = nil) # As class instances, for method chaining
  if id
    return Instance.new(id)
  else
    a = []
    handle_response(base_uri["instances"].get).each do |id|
      a << Instance.new(id)
    end
    return a
  end
end

#instances_listObject

————- Instances ————-



183
184
185
# File 'lib/orthanc/client.rb', line 183

def instances_list # Orthanc endpoint response
  handle_response(base_uri["instances"].get)
end

#modalities(dicom = nil) ⇒ Object

As class instances, for method chaining



92
93
94
95
96
97
98
99
100
101
102
# File 'lib/orthanc/client.rb', line 92

def modalities(dicom = nil) # As class instances, for method chaining
  if dicom
    return Modality.new(dicom)
  else
    a = []
    handle_response(base_uri["modalities"].get).each do |dicom|
      a << Modality.new(dicom)
    end
    return a
  end
end

#modalities_listObject

————- Modalities ————-



88
89
90
# File 'lib/orthanc/client.rb', line 88

def modalities_list # Orthanc endpoint response
  handle_response(base_uri["modalities"].get)
end

#patients(id = nil) ⇒ Object

As class instances, for method chaining



130
131
132
133
134
135
136
137
138
139
140
# File 'lib/orthanc/client.rb', line 130

def patients(id = nil) # As class instances, for method chaining
  if id
    return Patient.new(id)
  else
    a = []
    handle_response(base_uri["patients"].get).each do |id|
      a << Patient.new(id)
    end
    return a
  end
end

#patients_listObject

————- Patients ————-



126
127
128
# File 'lib/orthanc/client.rb', line 126

def patients_list # Orthanc endpoint response
  handle_response(base_uri["patients"].get)
end

#peers(peer = nil) ⇒ Object

As class instances, for method chaining



111
112
113
114
115
116
117
118
119
120
121
# File 'lib/orthanc/client.rb', line 111

def peers(peer = nil) # As class instances, for method chaining
  if peer
    return Peer.new(peer)
  else
    a = []
    handle_response(base_uri["peers"].get).each do |peer|
      a << Peer.new(peer)
    end
    return a
  end
end

#peers_listObject

————- Modalities ————-



107
108
109
# File 'lib/orthanc/client.rb', line 107

def peers_list # Orthanc endpoint response
  handle_response(base_uri["peers"].get)
end

#plugins(id = nil) ⇒ Object

GET /plugins



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/orthanc/client.rb', line 65

def plugins(id = nil) # As class instances, for method chaining
  if id
    return Plugin.new(id)
  else
    a = []
    handle_response(base_uri["plugins"].get).each do |id|
      a << Plugin.new(id)
    end
    return a
  end
end

#plugins_listObject

GET /plugins



60
61
62
# File 'lib/orthanc/client.rb', line 60

def plugins_list # Orthanc endpoint response
  handle_response(base_uri["plugins"].get)
end

#series(id = nil) ⇒ Object

As class instances, for method chaining



168
169
170
171
172
173
174
175
176
177
178
# File 'lib/orthanc/client.rb', line 168

def series(id = nil) # As class instances, for method chaining
  if id
    return Series.new(id)
  else
    a = []
    handle_response(base_uri["series"].get).each do |id|
      a << Series.new(id)
    end
    return a
  end
end

#series_listObject

————- Series ————-



164
165
166
# File 'lib/orthanc/client.rb', line 164

def series_list # Orthanc endpoint response
  handle_response(base_uri["series"].get)
end

#statisticsObject

GET /statistics



32
33
34
# File 'lib/orthanc/client.rb', line 32

def statistics
  handle_response(base_uri["statistics"].get)
end

#studies(id = nil) ⇒ Object

As class instances, for method chaining



149
150
151
152
153
154
155
156
157
158
159
# File 'lib/orthanc/client.rb', line 149

def studies(id = nil) # As class instances, for method chaining
  if id
    return Study.new(id)
  else
    a = []
    handle_response(base_uri["studies"].get).each do |id|
      a << Study.new(id)
    end
    return a
  end
end

#studies_listObject

————- Studies ————-



145
146
147
# File 'lib/orthanc/client.rb', line 145

def studies_list # Orthanc endpoint response
  handle_response(base_uri["studies"].get)
end

#systemObject

GET /system



27
28
29
# File 'lib/orthanc/client.rb', line 27

def system
  handle_response(base_uri["system"].get)
end

#toolsObject

GET /tools



81
82
83
# File 'lib/orthanc/client.rb', line 81

def tools
  Tool.new
end