orthanc 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -5
- data/lib/orthanc/attachments.rb +57 -0
- data/lib/orthanc/client.rb +145 -20
- data/lib/orthanc/instances.rb +90 -127
- data/lib/orthanc/metadata.rb +26 -0
- data/lib/orthanc/modalities.rb +26 -24
- data/lib/orthanc/patients.rb +65 -96
- data/lib/orthanc/peers.rb +17 -15
- data/lib/orthanc/plugins.rb +11 -9
- data/lib/orthanc/response.rb +30 -0
- data/lib/orthanc/series.rb +61 -92
- data/lib/orthanc/studies.rb +63 -94
- data/lib/orthanc/tools.rb +22 -16
- data/lib/orthanc/version.rb +2 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 509d31ee74414e383409a5189892149d32457ce2
|
4
|
+
data.tar.gz: 9867650b3e71e828cc86ae3c1096b1220fb0d792
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fc432f1593ad9c8a64c8042de72fc93360b36873f909fee6841977bdb533cb65ecd4db6b375f37a782a4e4a7a9a6cf279d4d5422f3355c4124b93955d653e0f
|
7
|
+
data.tar.gz: eda048fbf6e437af42013473290af66fd1234efc4d1f344372ad83a460f1f3e15d7d08294135e8230de03d43214237e6a731d3577a1cd44cf6d93ea78daacc96
|
data/README.md
CHANGED
@@ -1,10 +1,17 @@
|
|
1
1
|
# Orthanc-ruby
|
2
2
|
|
3
|
-
|
3
|
+
#### A Ruby implementation of the [Orthanc](http://orthanc-server.com) DICOM server v0.8.6 REST API
|
4
4
|
|
5
|
-
|
5
|
+
---
|
6
|
+
|
7
|
+
**Alpha!! Not ready for production. Anything may change, including resource nesting and naming schemes.**
|
8
|
+
|
9
|
+
---
|
10
|
+
|
11
|
+
###Attention: The gem now implements the orthanc resources as multilevel methods, to make it more Ruby-like
|
12
|
+
|
13
|
+
_(This is my first API client gem, experienced help or advice would be most appreciated)_ :)
|
6
14
|
|
7
|
-
(This is my first API client gem, experienced help or advice would be most appreciated) :)
|
8
15
|
|
9
16
|
## Installation
|
10
17
|
|
@@ -28,8 +35,12 @@ Or install it yourself as:
|
|
28
35
|
The gem tries to follow the Orthanc API naming scheme as closely as possible, converting methods and response items to snake case to make the experience more ruby-like.
|
29
36
|
|
30
37
|
api=Orthanc::Client.new("localhost", "8042")
|
31
|
-
api.
|
32
|
-
api.
|
38
|
+
api.patients # All patients as instances for method chaining
|
39
|
+
api.patients_list # Patient array, from Orthanc response
|
40
|
+
pat = api.patients.first # First patient (instance)
|
41
|
+
|
42
|
+
pat.shared_tags(simplify:true) # Patient's shared tags (simplified)
|
43
|
+
|
33
44
|
api.system.database_version => 5
|
34
45
|
api.statistics.count_studies => 14
|
35
46
|
|
@@ -39,7 +50,13 @@ You can see what Orthanc API resources have been mapped in the gem, and their st
|
|
39
50
|
|
40
51
|
Basic documentation can be found in [here](http://www.rubydoc.info/github/simonmd/orthanc-ruby/master/Orthanc/Client)
|
41
52
|
|
53
|
+
## Backlog
|
42
54
|
|
55
|
+
- Methods that return a file should be handled by ruby
|
56
|
+
- Test attachments (not sure how they are implemented in Orthanc)
|
57
|
+
- Handle network errors, return false if 500 Server error? (eg. echo)
|
58
|
+
- Test peers
|
59
|
+
- Write automated tests
|
43
60
|
|
44
61
|
## Contributing
|
45
62
|
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Orthanc
|
2
|
+
class Attachment
|
3
|
+
include Response
|
4
|
+
attr_accessor :base_uri
|
5
|
+
|
6
|
+
def initialize(resource, id = nil)
|
7
|
+
self.base_uri = resource["/attachments/#{id}"]
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
# DELETE /{resourceType}/{id}/attachments/{name}
|
12
|
+
def delete_attachment
|
13
|
+
handle_response(base_uri["attachments/#{name}"].delete)
|
14
|
+
end
|
15
|
+
|
16
|
+
# PUT /{resourceType}/{id}/attachments/{name}
|
17
|
+
def modify(payload = {})
|
18
|
+
handle_response(base_uri["attachments/#{name}"].put(payload))
|
19
|
+
end
|
20
|
+
|
21
|
+
# GET /{resourceType}/{id}/attachments/{name}/compressed-data
|
22
|
+
def compressed_data
|
23
|
+
handle_response(base_uri["compressed-data"].get)
|
24
|
+
end
|
25
|
+
|
26
|
+
# GET /{resourceType}/{id}/attachments/{name}/compressed-md5
|
27
|
+
def compressed_md5
|
28
|
+
handle_response(base_uri["compressed-md5"].get)
|
29
|
+
end
|
30
|
+
|
31
|
+
# GET /{resourceType}/{id}/attachments/{name}/compressed-size
|
32
|
+
def compressed_size
|
33
|
+
handle_response(base_uri["compressed-size"].get)
|
34
|
+
end
|
35
|
+
|
36
|
+
# GET /{resourceType}/{id}/attachments/{name}/data
|
37
|
+
def data
|
38
|
+
handle_response(base_uri["data"].get)
|
39
|
+
end
|
40
|
+
|
41
|
+
# GET /{resourceType}/{id}/attachments/{name}/md5
|
42
|
+
def md5
|
43
|
+
handle_response(base_uri["md5"].get)
|
44
|
+
end
|
45
|
+
|
46
|
+
# GET /{resourceType}/{id}/attachments/{name}/size
|
47
|
+
def size
|
48
|
+
handle_response(base_uri["size"].get)
|
49
|
+
end
|
50
|
+
|
51
|
+
# POST /{resourceType}/{id}/attachments/{name}/verify-md5
|
52
|
+
def verify_md5
|
53
|
+
handle_response(base_uri["verify-md5"].get)
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
data/lib/orthanc/client.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'orthanc/response'
|
2
|
+
|
1
3
|
require 'orthanc/tools'
|
2
4
|
require 'orthanc/plugins'
|
3
5
|
require 'orthanc/modalities'
|
@@ -6,68 +8,191 @@ require 'orthanc/patients'
|
|
6
8
|
require 'orthanc/studies'
|
7
9
|
require 'orthanc/series'
|
8
10
|
require 'orthanc/instances'
|
11
|
+
require 'orthanc/attachments'
|
12
|
+
require 'orthanc/metadata'
|
9
13
|
|
10
14
|
module Orthanc
|
11
15
|
class Client
|
12
16
|
|
17
|
+
include Response
|
13
18
|
attr_accessor :base_uri
|
14
19
|
|
15
|
-
def initialize(host,port = 8042)
|
20
|
+
def initialize(host = "localhost", port = 8042)
|
16
21
|
self.base_uri = RestClient::Resource.new("http://#{host}:#{port}")
|
17
22
|
end
|
18
23
|
|
19
24
|
# ------------- General -------------
|
25
|
+
|
26
|
+
# GET /system
|
20
27
|
def system
|
21
28
|
handle_response(base_uri["system"].get)
|
22
29
|
end
|
23
30
|
|
31
|
+
# GET /statistics
|
24
32
|
def statistics
|
25
33
|
handle_response(base_uri["statistics"].get)
|
26
34
|
end
|
27
35
|
|
36
|
+
# GET /changes
|
28
37
|
def changes(params = {}) # "last", "limit" and "since" arguments
|
29
38
|
handle_response(base_uri["changes"].get({params: params}))
|
30
39
|
end
|
31
40
|
|
41
|
+
# DELETE /changes
|
32
42
|
def delete_changes(params = {}) # "last", "limit" and "since" arguments
|
33
43
|
handle_response(base_uri["changes"].delete({params: params}))
|
34
44
|
end
|
35
45
|
|
46
|
+
# GET /exports
|
36
47
|
def exports(params = {}) # "last", "limit" and "since" arguments
|
37
48
|
handle_response(base_uri["exports"].get({params: params}))
|
38
49
|
end
|
39
50
|
|
51
|
+
# DELETE /exports
|
40
52
|
def delete_exports(params = {}) # "last", "limit" and "since" arguments
|
41
53
|
handle_response(base_uri["exports"].delete({params: params}))
|
42
54
|
end
|
43
55
|
|
44
56
|
|
45
|
-
|
57
|
+
# ------------- Plugins -------------
|
58
|
+
|
59
|
+
# GET /plugins
|
60
|
+
def plugins_list # Orthanc endpoint response
|
61
|
+
handle_response(base_uri["plugins"].get)
|
62
|
+
end
|
63
|
+
|
64
|
+
# GET /plugins
|
65
|
+
def plugins(id = nil) # As class instances, for method chaining
|
66
|
+
if id
|
67
|
+
return Plugin.new(id)
|
68
|
+
else
|
69
|
+
a = []
|
70
|
+
handle_response(base_uri["plugins"].get).each do |id|
|
71
|
+
a << Plugin.new(id)
|
72
|
+
end
|
73
|
+
return a
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
# ------------- Tools -------------
|
79
|
+
|
80
|
+
# GET /tools
|
81
|
+
def tools
|
82
|
+
Tool.new
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
# ------------- Modalities -------------
|
46
87
|
|
47
|
-
def
|
48
|
-
|
49
|
-
return 1 if bool == true
|
88
|
+
def modalities_list # Orthanc endpoint response
|
89
|
+
handle_response(base_uri["modalities"].get)
|
50
90
|
end
|
51
91
|
|
52
|
-
def
|
53
|
-
|
54
|
-
|
92
|
+
def modalities(dicom = nil) # As class instances, for method chaining
|
93
|
+
if dicom
|
94
|
+
return Modality.new(dicom)
|
95
|
+
else
|
96
|
+
a = []
|
97
|
+
handle_response(base_uri["modalities"].get).each do |dicom|
|
98
|
+
a << Modality.new(dicom)
|
99
|
+
end
|
100
|
+
return a
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
# ------------- Modalities -------------
|
106
|
+
|
107
|
+
def peers_list # Orthanc endpoint response
|
108
|
+
handle_response(base_uri["peers"].get)
|
55
109
|
end
|
56
110
|
|
57
|
-
def
|
58
|
-
|
59
|
-
|
60
|
-
|
111
|
+
def peers(peer = nil) # As class instances, for method chaining
|
112
|
+
if peer
|
113
|
+
return Peer.new(peer)
|
114
|
+
else
|
115
|
+
a = []
|
116
|
+
handle_response(base_uri["peers"].get).each do |peer|
|
117
|
+
a << Peer.new(peer)
|
118
|
+
end
|
119
|
+
return a
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
# ------------- Patients -------------
|
125
|
+
|
126
|
+
def patients_list # Orthanc endpoint response
|
127
|
+
handle_response(base_uri["patients"].get)
|
128
|
+
end
|
129
|
+
|
130
|
+
def patients(id = nil) # As class instances, for method chaining
|
131
|
+
if id
|
132
|
+
return Patient.new(id)
|
133
|
+
else
|
134
|
+
a = []
|
135
|
+
handle_response(base_uri["patients"].get).each do |id|
|
136
|
+
a << Patient.new(id)
|
137
|
+
end
|
138
|
+
return a
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
|
143
|
+
# ------------- Studies -------------
|
144
|
+
|
145
|
+
def studies_list # Orthanc endpoint response
|
146
|
+
handle_response(base_uri["studies"].get)
|
147
|
+
end
|
148
|
+
|
149
|
+
def studies(id = nil) # As class instances, for method chaining
|
150
|
+
if id
|
151
|
+
return Study.new(id)
|
152
|
+
else
|
153
|
+
a = []
|
154
|
+
handle_response(base_uri["studies"].get).each do |id|
|
155
|
+
a << Study.new(id)
|
156
|
+
end
|
157
|
+
return a
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
|
162
|
+
# ------------- Series -------------
|
163
|
+
|
164
|
+
def series_list # Orthanc endpoint response
|
165
|
+
handle_response(base_uri["series"].get)
|
166
|
+
end
|
167
|
+
|
168
|
+
def series(id = nil) # As class instances, for method chaining
|
169
|
+
if id
|
170
|
+
return Series.new(id)
|
171
|
+
else
|
172
|
+
a = []
|
173
|
+
handle_response(base_uri["series"].get).each do |id|
|
174
|
+
a << Series.new(id)
|
175
|
+
end
|
176
|
+
return a
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
|
181
|
+
# ------------- Instances -------------
|
182
|
+
|
183
|
+
def instances_list # Orthanc endpoint response
|
184
|
+
handle_response(base_uri["instances"].get)
|
185
|
+
end
|
61
186
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
187
|
+
def instances(id = nil) # As class instances, for method chaining
|
188
|
+
if id
|
189
|
+
return Instance.new(id)
|
190
|
+
else
|
191
|
+
a = []
|
192
|
+
handle_response(base_uri["instances"].get).each do |id|
|
193
|
+
a << Instance.new(id)
|
68
194
|
end
|
69
|
-
|
70
|
-
return response
|
195
|
+
return a
|
71
196
|
end
|
72
197
|
end
|
73
198
|
|
data/lib/orthanc/instances.rb
CHANGED
@@ -1,222 +1,185 @@
|
|
1
1
|
module Orthanc
|
2
|
-
class
|
3
|
-
|
2
|
+
class Instance
|
3
|
+
include Response
|
4
|
+
attr_accessor :base_uri
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
def initialize(id = nil)
|
7
|
+
client = Client.new
|
8
|
+
self.base_uri = client.base_uri["/instances/#{id}"]
|
8
9
|
end
|
9
10
|
|
10
|
-
#
|
11
|
-
def
|
12
|
-
handle_response(base_uri
|
13
|
-
end
|
14
|
-
|
15
|
-
# GET /instances/{id}
|
16
|
-
def instance(id)
|
17
|
-
handle_response(base_uri["instances/#{id}"].get)
|
11
|
+
# GET /instances, # GET /instances/{id}
|
12
|
+
def fetch # Fetch API response
|
13
|
+
handle_response(base_uri.get)
|
18
14
|
end
|
19
15
|
|
20
16
|
# DELETE /instances/{id}
|
21
|
-
def
|
22
|
-
handle_response(base_uri
|
17
|
+
def delete
|
18
|
+
handle_response(base_uri.delete)
|
23
19
|
end
|
24
20
|
|
25
21
|
# POST /instances/{id}/anonymize
|
26
|
-
def
|
27
|
-
base_uri["
|
22
|
+
def anonymize(payload = {}) # https://code.google.com/p/orthanc/wiki/Anonymization
|
23
|
+
base_uri["anonymize"].post(payload.to_s)
|
28
24
|
end
|
29
25
|
|
30
26
|
# GET /instances/{id}/content/
|
31
|
-
def
|
32
|
-
handle_response(base_uri["
|
27
|
+
def content # List the first-level DICOM tags
|
28
|
+
handle_response(base_uri["frames"].get)
|
33
29
|
end
|
34
30
|
|
35
31
|
# GET /instances/{id}/content/{group}-{element}
|
36
|
-
def
|
37
|
-
handle_response(base_uri["
|
32
|
+
def content_tag(group, element) # Raw access to the value of DICOM tags (comprising the padding character)
|
33
|
+
handle_response(base_uri["content/#{group}-#{element}"].get)
|
38
34
|
end
|
39
35
|
|
40
36
|
# GET /instances/{id}/content/{group}-{element}/{index}/...
|
41
|
-
def
|
42
|
-
handle_response(base_uri["
|
37
|
+
def content_sequence(group, element, index) # Raw access to the content of DICOM sequences
|
38
|
+
handle_response(base_uri["content/#{group}-#{element}/#{index}"].get)
|
43
39
|
end
|
44
40
|
|
45
41
|
# POST /instances/{id}/export
|
46
|
-
def
|
47
|
-
base_uri["
|
42
|
+
def export(payload = {}) # Write the DICOM file in the filesystem where Orthanc is running
|
43
|
+
base_uri["export"].post(payload)
|
48
44
|
end
|
49
45
|
|
50
46
|
# GET /instances/{id}/file
|
51
|
-
def
|
52
|
-
base_uri["
|
47
|
+
def file
|
48
|
+
base_uri["file"].get
|
53
49
|
end
|
54
50
|
|
55
51
|
# GET /instances/{id}/frames
|
56
|
-
def
|
57
|
-
handle_response(base_uri["
|
52
|
+
def frames # Instance frames array
|
53
|
+
handle_response(base_uri["frames"].get)
|
58
54
|
end
|
59
55
|
|
60
56
|
# GET /instances/{id}/frames/{frameNumber}/image-int16
|
61
|
-
def
|
62
|
-
base_uri["
|
57
|
+
def frame_image_int16(frame_number) # Truncated image to the [-32768;32767] range
|
58
|
+
base_uri["frames/#{frame_number}/image-int16"].get
|
63
59
|
end
|
64
60
|
|
65
61
|
# GET /instances/{id}/frames/{frameNumber}/image-uint16
|
66
|
-
def
|
67
|
-
base_uri["
|
62
|
+
def frame_image_uint16(frame_number) # Truncated image to the [0;65535] range
|
63
|
+
base_uri["frames/#{frame_number}/image-uint16"].get
|
68
64
|
end
|
69
65
|
|
70
66
|
# GET /instances/{id}/frames/{frameNumber}/image-uint8
|
71
|
-
def
|
72
|
-
base_uri["
|
67
|
+
def frame_image_uint8(frame_number) # Truncated image to the [0;255] range
|
68
|
+
base_uri["frames/#{frame_number}/image-uint8"].get
|
73
69
|
end
|
74
70
|
|
75
71
|
# GET /instances/{id}/frames/{frameNumber}/matlab
|
76
|
-
def
|
77
|
-
base_uri["
|
72
|
+
def frame_matlab(frame_number) # a = eval(urlread('http://localhost:8042/instances/.../matlab'))
|
73
|
+
base_uri["frames/#{frame_number}/matlab"].get
|
78
74
|
end
|
79
75
|
|
80
76
|
# GET /instances/{id}/frames/{frameNumber}/preview
|
81
|
-
def
|
82
|
-
base_uri["
|
77
|
+
def preview(frame_number) # Rescaled image (so that all the range [0;255] is used)
|
78
|
+
base_uri["frames/#{frame_number}/preview"].get
|
83
79
|
end
|
84
80
|
|
85
81
|
# GET /instances/{id}/image-int16
|
86
|
-
def
|
87
|
-
base_uri["
|
82
|
+
def image_int16 # Truncated image to the [-32768;32767] range
|
83
|
+
base_uri["image-int16"].get
|
88
84
|
end
|
89
85
|
|
90
86
|
# GET /instances/{id}/image-uint16
|
91
|
-
def
|
92
|
-
base_uri["
|
87
|
+
def image_uint16 # Truncated image to the [0;65535] range
|
88
|
+
base_uri["image-uint16"].get
|
93
89
|
end
|
94
90
|
|
95
91
|
# GET /instances/{id}/image-uint8
|
96
|
-
def
|
97
|
-
base_uri["
|
92
|
+
def image_uint8 # Truncated image to the [0;255] range
|
93
|
+
base_uri["image-uint8"].get
|
98
94
|
end
|
99
95
|
|
100
96
|
# GET /instances/{id}/matlab
|
101
|
-
def
|
102
|
-
base_uri["
|
97
|
+
def matlab # a = eval(urlread('http://localhost:8042/instances/.../matlab'))
|
98
|
+
base_uri["matlab"].get
|
103
99
|
end
|
104
100
|
|
105
101
|
# POST /instances/{id}/modify
|
106
|
-
def
|
107
|
-
base_uri["
|
102
|
+
def modify(payload = {}) # https://code.google.com/p/orthanc/wiki/Anonymization
|
103
|
+
base_uri["modify"].post(payload.to_s)
|
108
104
|
end
|
109
105
|
|
110
106
|
# GET /instances/{id}/module
|
111
|
-
def
|
112
|
-
handle_response(base_uri["
|
107
|
+
def module
|
108
|
+
handle_response(base_uri["module"].get)
|
113
109
|
end
|
114
110
|
|
115
111
|
# GET /instances/{id}/patient
|
116
|
-
def
|
117
|
-
handle_response(base_uri["
|
112
|
+
def patient
|
113
|
+
handle_response(base_uri["patient"].get)
|
118
114
|
end
|
119
115
|
|
120
116
|
# GET /instances/{id}/preview
|
121
|
-
def
|
122
|
-
handle_response(base_uri["
|
117
|
+
def preview # Rescaled image (so that all the range [0;255] is used)
|
118
|
+
handle_response(base_uri["preview"].get)
|
123
119
|
end
|
124
120
|
|
125
121
|
# GET /instances/{id}/series
|
126
|
-
def
|
127
|
-
handle_response(base_uri["
|
122
|
+
def series
|
123
|
+
handle_response(base_uri["series"].get)
|
128
124
|
end
|
129
125
|
|
130
126
|
# GET /instances/{id}/simplified-tags
|
131
|
-
def
|
132
|
-
handle_response(base_uri["
|
127
|
+
def simplified_tags(params = {}) # "?simplify" argument to simplify output
|
128
|
+
handle_response(base_uri["simplified-tags"].get({params: params}))
|
133
129
|
end
|
134
130
|
|
135
131
|
# GET /instances/{id}/statistics
|
136
|
-
def
|
137
|
-
handle_response(base_uri["
|
132
|
+
def statistics
|
133
|
+
handle_response(base_uri["statistics"].get)
|
138
134
|
end
|
139
135
|
|
140
136
|
# GET /instances/{id}/study
|
141
|
-
def
|
142
|
-
handle_response(base_uri["
|
137
|
+
def study
|
138
|
+
handle_response(base_uri["study"].get)
|
143
139
|
end
|
144
140
|
|
145
141
|
# GET /instances/{id}/tags
|
146
|
-
def
|
147
|
-
handle_response(base_uri["
|
142
|
+
def tags(params = {}) # TODO: "?simplify" argument to simplify output (same as "simplified-tags")
|
143
|
+
handle_response(base_uri["tags"].get({params: params}))
|
148
144
|
end
|
149
145
|
|
150
|
-
#
|
146
|
+
# ---------- Polymorphic resources ----------
|
147
|
+
# Attachments
|
151
148
|
|
152
149
|
# GET /{resourceType}/{id}/attachments
|
153
|
-
def
|
154
|
-
handle_response(base_uri["
|
155
|
-
end
|
156
|
-
|
157
|
-
# DELETE /{resourceType}/{id}/attachments/{name}
|
158
|
-
def delete_instance_attachment(id, name)
|
159
|
-
handle_response(base_uri["instances/#{id}/attachments/#{name}"].delete)
|
160
|
-
end
|
161
|
-
|
162
|
-
# PUT /{resourceType}/{id}/attachments/{name}
|
163
|
-
def instance_attachment(id, name, payload = {})
|
164
|
-
handle_response(base_uri["instances/#{id}/attachments/#{name}"].put(payload))
|
150
|
+
def attachments_list # Orthanc endpoint response
|
151
|
+
handle_response(base_uri["attachments"].get)
|
165
152
|
end
|
166
153
|
|
167
|
-
|
168
|
-
|
169
|
-
|
154
|
+
def attachments(id = nil)
|
155
|
+
if id
|
156
|
+
return Attachment.new(base_uri, id)
|
157
|
+
else
|
158
|
+
a = []
|
159
|
+
handle_response(base_uri["attachments"].get).each do |id|
|
160
|
+
a << Attachment.new(base_uri, id)
|
161
|
+
end
|
162
|
+
return a
|
163
|
+
end
|
170
164
|
end
|
171
165
|
|
172
|
-
#
|
173
|
-
def instance_attachment_compressed_md5(id, name)
|
174
|
-
handle_response(base_uri["instances/#{id}/attachments/#{name}/compressed-md5"].get)
|
175
|
-
end
|
176
|
-
|
177
|
-
# GET /{resourceType}/{id}/attachments/{name}/compressed-size
|
178
|
-
def instance_attachment_compressed_size(id, name)
|
179
|
-
handle_response(base_uri["instances/#{id}/attachments/#{name}/compressed-size"].get)
|
180
|
-
end
|
181
|
-
|
182
|
-
# GET /{resourceType}/{id}/attachments/{name}/data
|
183
|
-
def instance_attachment_data(id, name)
|
184
|
-
handle_response(base_uri["instances/#{id}/attachments/#{name}/data"].get)
|
185
|
-
end
|
186
|
-
|
187
|
-
# GET /{resourceType}/{id}/attachments/{name}/md5
|
188
|
-
def instance_attachment_md5(id, name)
|
189
|
-
handle_response(base_uri["instances/#{id}/attachments/#{name}/md5"].get)
|
190
|
-
end
|
191
|
-
|
192
|
-
# GET /{resourceType}/{id}/attachments/{name}/size
|
193
|
-
def instance_attachment_size(id, name)
|
194
|
-
handle_response(base_uri["instances/#{id}/attachments/#{name}/size"].get)
|
195
|
-
end
|
196
|
-
|
197
|
-
# POST /{resourceType}/{id}/attachments/{name}/verify-md5
|
198
|
-
def instance_attachment_verify_md5(id, name)
|
199
|
-
handle_response(base_uri["instances/#{id}/attachments/#{name}/verify-md5"].get)
|
200
|
-
end
|
166
|
+
# Metadata
|
201
167
|
|
202
168
|
# GET /{resourceType}/{id}/metadata
|
203
|
-
def
|
204
|
-
handle_response(base_uri["
|
205
|
-
end
|
206
|
-
|
207
|
-
#
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
# PUT /{resourceType}/{id}/metadata/{name}
|
218
|
-
def instance_update_metadata(id, name, payload = {})
|
219
|
-
handle_response(base_uri["instances/#{id}/metadata/#{name}"].put(payload))
|
169
|
+
def metadata_list # Orthanc endpoint response
|
170
|
+
handle_response(base_uri["metadata"].get)
|
171
|
+
end
|
172
|
+
|
173
|
+
def metadata(name = nil) # As class instances, for method chaining
|
174
|
+
if name
|
175
|
+
return Metadata.new(base_uri, name)
|
176
|
+
else
|
177
|
+
a = []
|
178
|
+
handle_response(base_uri["metadata"].get).each do |name|
|
179
|
+
a << Metadata.new(base_uri, name)
|
180
|
+
end
|
181
|
+
return a
|
182
|
+
end
|
220
183
|
end
|
221
184
|
|
222
185
|
end
|