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
@@ -0,0 +1,26 @@
|
|
1
|
+
module Orthanc
|
2
|
+
class Metadata
|
3
|
+
include Response
|
4
|
+
attr_accessor :base_uri
|
5
|
+
|
6
|
+
def initialize(resource, id = nil)
|
7
|
+
self.base_uri = resource["/metadata/#{id}"]
|
8
|
+
end
|
9
|
+
|
10
|
+
# GET /{resourceType}/{id}/metadata/{name}
|
11
|
+
def fetch # Fetch API response
|
12
|
+
handle_response(base_uri.get)
|
13
|
+
end
|
14
|
+
|
15
|
+
# DELETE /{resourceType}/{id}/metadata/{name}
|
16
|
+
def delete
|
17
|
+
handle_response(base_uri.delete)
|
18
|
+
end
|
19
|
+
|
20
|
+
# PUT /{resourceType}/{id}/metadata/{name}
|
21
|
+
def modify(payload = {})
|
22
|
+
handle_response(base_uri.put(payload))
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
data/lib/orthanc/modalities.rb
CHANGED
@@ -1,54 +1,56 @@
|
|
1
1
|
module Orthanc
|
2
|
-
class
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
class Modality
|
3
|
+
include Response
|
4
|
+
attr_accessor :base_uri
|
5
|
+
|
6
|
+
def initialize(id = nil)
|
7
|
+
client = Client.new
|
8
|
+
self.base_uri = client.base_uri["/modalities/#{id}"]
|
7
9
|
end
|
8
10
|
|
9
|
-
# GET /modalities/{
|
10
|
-
def
|
11
|
-
handle_response(base_uri
|
11
|
+
# GET /modalities, # GET /modalities/{id}
|
12
|
+
def fetch # Fetch API response
|
13
|
+
handle_response(base_uri.get)
|
12
14
|
end
|
13
15
|
|
14
|
-
# DELETE /modalities/{
|
15
|
-
def
|
16
|
-
handle_response(base_uri
|
16
|
+
# DELETE /modalities/{id}
|
17
|
+
def delete
|
18
|
+
handle_response(base_uri.delete)
|
17
19
|
end
|
18
20
|
|
19
21
|
# PUT /modalities/{dicom}
|
20
|
-
def
|
22
|
+
def modify(payload = {})
|
21
23
|
handle_response(base_uri["modalities/#{dicom}"].put(payload))
|
22
24
|
end
|
23
25
|
|
24
26
|
# POST /modalities/{dicom}/echo
|
25
|
-
def
|
26
|
-
handle_response(base_uri["
|
27
|
+
def echo(payload = {}) # C-Echo SCU
|
28
|
+
handle_response(base_uri["echo"].post(payload))
|
27
29
|
end
|
28
30
|
|
29
31
|
# POST /modalities/{dicom}/find
|
30
|
-
def
|
31
|
-
handle_response(base_uri["
|
32
|
+
def find(payload = {})
|
33
|
+
handle_response(base_uri["find"].post(payload))
|
32
34
|
end
|
33
35
|
|
34
36
|
# POST /modalities/{dicom}/find-patient
|
35
|
-
def
|
36
|
-
handle_response(base_uri["
|
37
|
+
def find_patient(payload = {})
|
38
|
+
handle_response(base_uri["find-patient"].post(payload))
|
37
39
|
end
|
38
40
|
|
39
41
|
# POST /modalities/{dicom}/find-series
|
40
|
-
def
|
41
|
-
handle_response(base_uri["
|
42
|
+
def find_series(payload = {})
|
43
|
+
handle_response(base_uri["find-series"].post(payload))
|
42
44
|
end
|
43
45
|
|
44
46
|
# POST /modalities/{dicom}/find-study
|
45
|
-
def
|
46
|
-
handle_response(base_uri["
|
47
|
+
def find_study(payload = {})
|
48
|
+
handle_response(base_uri["find-study"].post(payload))
|
47
49
|
end
|
48
50
|
|
49
51
|
# POST /modalities/{dicom}/store
|
50
|
-
def
|
51
|
-
handle_response(base_uri["
|
52
|
+
def store(payload = {}) # POST body = UUID series, UUID instance, or raw DICOM file
|
53
|
+
handle_response(base_uri["store"].post(payload))
|
52
54
|
end
|
53
55
|
|
54
56
|
end
|
data/lib/orthanc/patients.rb
CHANGED
@@ -1,153 +1,122 @@
|
|
1
1
|
module Orthanc
|
2
|
-
class
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
class Patient
|
3
|
+
include Response
|
4
|
+
attr_accessor :base_uri
|
5
|
+
|
6
|
+
def initialize(id = nil)
|
7
|
+
client = Client.new
|
8
|
+
self.base_uri = client.base_uri["/patients/#{id}"]
|
7
9
|
end
|
8
10
|
|
9
|
-
# GET /patients/{id}
|
10
|
-
def
|
11
|
-
handle_response(base_uri
|
11
|
+
# GET /patients, # GET /patients/{id}
|
12
|
+
def fetch # Fetch API response
|
13
|
+
handle_response(base_uri.get)
|
12
14
|
end
|
13
15
|
|
14
16
|
# DELETE /patients/{id}
|
15
|
-
def
|
16
|
-
handle_response(base_uri
|
17
|
+
def delete
|
18
|
+
handle_response(base_uri.delete)
|
17
19
|
end
|
18
20
|
|
19
21
|
# POST /patients/{id}/anonymize
|
20
|
-
def
|
21
|
-
handle_response(base_uri["
|
22
|
+
def anonymize(payload = {}) # https://code.google.com/p/orthanc/wiki/Anonymization
|
23
|
+
handle_response(base_uri["anonymize"].post(payload.to_s))
|
22
24
|
end
|
23
25
|
|
24
26
|
# GET /patients/{id}/archive
|
25
|
-
def
|
26
|
-
base_uri["
|
27
|
+
def archive # Create ZIP
|
28
|
+
base_uri["archive"].get # CAREFUL! Returns the whole zipfile
|
27
29
|
end
|
28
30
|
|
29
31
|
# GET /patients/{id}/instances
|
30
|
-
def
|
31
|
-
handle_response(base_uri["
|
32
|
+
def instances # Retrieve all the instances of this patient in a single REST call
|
33
|
+
handle_response(base_uri["instances"].get)
|
32
34
|
end
|
33
35
|
|
34
36
|
# GET /patients/{id}/media
|
35
|
-
def
|
36
|
-
base_uri["
|
37
|
+
def media # Create a ZIP archive for media storage with DICOMDIR
|
38
|
+
base_uri["media"].get # CAREFUL! Returns the whole zipfile
|
37
39
|
end
|
38
40
|
|
39
41
|
# POST /patients/{id}/modify
|
40
|
-
def
|
41
|
-
handle_response(base_uri["
|
42
|
+
def modify(payload = {}) # https://code.google.com/p/orthanc/wiki/Anonymization
|
43
|
+
handle_response(base_uri["modify"].post(payload.to_s))
|
42
44
|
end
|
43
45
|
|
44
46
|
# GET /patients/{id}/module
|
45
|
-
def
|
46
|
-
handle_response(base_uri["
|
47
|
+
def module
|
48
|
+
handle_response(base_uri["module"].get)
|
47
49
|
end
|
48
50
|
|
49
51
|
# GET /patients/{id}/protected
|
50
|
-
def
|
51
|
-
num_to_bool(base_uri["
|
52
|
+
def protected? # Protection against recycling: "0" means unprotected, "1" protected
|
53
|
+
num_to_bool(base_uri["protected"].get)
|
52
54
|
end
|
53
55
|
|
54
56
|
# PUT /patients/{id}/protected
|
55
|
-
def
|
57
|
+
def protected(boolstatus = true) # Protection against recycling: "0" means unprotected, "1" protected
|
56
58
|
status = bool_to_num(boolstatus)
|
57
|
-
base_uri["
|
59
|
+
base_uri["protected"].put("#{status}")
|
58
60
|
return nil # API returns ""
|
59
61
|
end
|
60
62
|
|
61
63
|
# GET /patients/{id}/series
|
62
|
-
def
|
63
|
-
handle_response(base_uri["
|
64
|
+
def series # Retrieve all the series of this patient in a single REST call
|
65
|
+
handle_response(base_uri["series"].get)
|
64
66
|
end
|
65
67
|
|
66
68
|
# GET /patients/{id}/shared-tags
|
67
|
-
def
|
68
|
-
handle_response(base_uri["
|
69
|
+
def shared_tags(params = {}) # "?simplify" argument to simplify output
|
70
|
+
handle_response(base_uri["shared-tags"].get({params: params}))
|
69
71
|
end
|
70
72
|
|
71
73
|
# GET /patients/{id}/statistics
|
72
|
-
def
|
73
|
-
handle_response(base_uri["
|
74
|
+
def statistics
|
75
|
+
handle_response(base_uri["statistics"].get)
|
74
76
|
end
|
75
77
|
|
76
78
|
# GET /patients/{id}/studies
|
77
|
-
def
|
78
|
-
handle_response(base_uri["
|
79
|
+
def studies # Retrieve all the studies of this patient in a single REST call
|
80
|
+
handle_response(base_uri["studies"].get)
|
79
81
|
end
|
80
82
|
|
81
|
-
#
|
83
|
+
# ---------- Polymorphic resources ----------
|
84
|
+
# Attachments
|
82
85
|
|
83
86
|
# GET /{resourceType}/{id}/attachments
|
84
|
-
def
|
85
|
-
handle_response(base_uri["
|
86
|
-
end
|
87
|
-
|
88
|
-
# DELETE /{resourceType}/{id}/attachments/{name}
|
89
|
-
def delete_patient_attachment(id, name)
|
90
|
-
handle_response(base_uri["patients/#{id}/attachments/#{name}"].delete)
|
91
|
-
end
|
92
|
-
|
93
|
-
# PUT /{resourceType}/{id}/attachments/{name}
|
94
|
-
def patient_attachment(id, name, payload = {})
|
95
|
-
handle_response(base_uri["patients/#{id}/attachments/#{name}"].put(payload))
|
96
|
-
end
|
97
|
-
|
98
|
-
# GET /{resourceType}/{id}/attachments/{name}/compressed-data
|
99
|
-
def patient_attachment_compressed_data(id, name)
|
100
|
-
handle_response(base_uri["patients/#{id}/attachments/#{name}/compressed-data"].get)
|
101
|
-
end
|
102
|
-
|
103
|
-
# GET /{resourceType}/{id}/attachments/{name}/compressed-md5
|
104
|
-
def patient_attachment_compressed_md5(id, name)
|
105
|
-
handle_response(base_uri["patients/#{id}/attachments/#{name}/compressed-md5"].get)
|
106
|
-
end
|
107
|
-
|
108
|
-
# GET /{resourceType}/{id}/attachments/{name}/compressed-size
|
109
|
-
def patient_attachment_compressed_size(id, name)
|
110
|
-
handle_response(base_uri["patients/#{id}/attachments/#{name}/compressed-size"].get)
|
87
|
+
def attachments_list # Orthanc endpoint response
|
88
|
+
handle_response(base_uri["attachments"].get)
|
111
89
|
end
|
112
90
|
|
113
|
-
|
114
|
-
|
115
|
-
|
91
|
+
def attachments(id = nil)
|
92
|
+
if id
|
93
|
+
return Attachment.new(base_uri, id)
|
94
|
+
else
|
95
|
+
a = []
|
96
|
+
handle_response(base_uri["attachments"].get).each do |id|
|
97
|
+
a << Attachment.new(base_uri, id)
|
98
|
+
end
|
99
|
+
return a
|
100
|
+
end
|
116
101
|
end
|
117
102
|
|
118
|
-
#
|
119
|
-
def patient_attachment_md5(id, name)
|
120
|
-
handle_response(base_uri["patients/#{id}/attachments/#{name}/md5"].get)
|
121
|
-
end
|
122
|
-
|
123
|
-
# GET /{resourceType}/{id}/attachments/{name}/size
|
124
|
-
def patient_attachment_size(id, name)
|
125
|
-
handle_response(base_uri["patients/#{id}/attachments/#{name}/size"].get)
|
126
|
-
end
|
127
|
-
|
128
|
-
# POST /{resourceType}/{id}/attachments/{name}/verify-md5
|
129
|
-
def patient_attachment_verify_md5(id, name)
|
130
|
-
handle_response(base_uri["patients/#{id}/attachments/#{name}/verify-md5"].get)
|
131
|
-
end
|
103
|
+
# Metadata
|
132
104
|
|
133
105
|
# GET /{resourceType}/{id}/metadata
|
134
|
-
def
|
135
|
-
handle_response(base_uri["
|
136
|
-
end
|
137
|
-
|
138
|
-
#
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
# PUT /{resourceType}/{id}/metadata/{name}
|
149
|
-
def patient_update_metadata(id, name, payload = {})
|
150
|
-
handle_response(base_uri["patients/#{id}/metadata/#{name}"].put(payload))
|
106
|
+
def metadata_list # Orthanc endpoint response
|
107
|
+
handle_response(base_uri["metadata"].get)
|
108
|
+
end
|
109
|
+
|
110
|
+
def metadata(name = nil) # As class instances, for method chaining
|
111
|
+
if name
|
112
|
+
return Metadata.new(base_uri, name)
|
113
|
+
else
|
114
|
+
a = []
|
115
|
+
handle_response(base_uri["metadata"].get).each do |name|
|
116
|
+
a << Metadata.new(base_uri, name)
|
117
|
+
end
|
118
|
+
return a
|
119
|
+
end
|
151
120
|
end
|
152
121
|
|
153
122
|
end
|
data/lib/orthanc/peers.rb
CHANGED
@@ -1,29 +1,31 @@
|
|
1
1
|
module Orthanc
|
2
|
-
class
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
class Peer
|
3
|
+
include Response
|
4
|
+
attr_accessor :base_uri
|
5
|
+
|
6
|
+
def initialize(id = nil)
|
7
|
+
client = Client.new
|
8
|
+
self.base_uri = client.base_uri["/peers/#{id}"]
|
7
9
|
end
|
8
10
|
|
9
|
-
# GET /peers/{
|
10
|
-
def
|
11
|
-
handle_response(base_uri
|
11
|
+
# GET /peers, # GET /peers/{id}
|
12
|
+
def fetch # Fetch API response
|
13
|
+
handle_response(base_uri.get)
|
12
14
|
end
|
13
15
|
|
14
|
-
# DELETE /peers/{
|
15
|
-
def
|
16
|
-
handle_response(base_uri
|
16
|
+
# DELETE /peers/{id}
|
17
|
+
def delete
|
18
|
+
handle_response(base_uri.delete)
|
17
19
|
end
|
18
20
|
|
19
21
|
# PUT /peers/{peer}
|
20
|
-
def
|
21
|
-
handle_response(base_uri
|
22
|
+
def modify(payload = {})
|
23
|
+
handle_response(base_uri.put(payload))
|
22
24
|
end
|
23
25
|
|
24
26
|
# GET /peers/{peer}/store
|
25
|
-
def
|
26
|
-
handle_response(base_uri["
|
27
|
+
def store(payload = {}) # POST body = UUID series, UUID instance, or raw DICOM file
|
28
|
+
handle_response(base_uri["store"].post(payload))
|
27
29
|
end
|
28
30
|
|
29
31
|
end
|
data/lib/orthanc/plugins.rb
CHANGED
@@ -1,19 +1,21 @@
|
|
1
1
|
module Orthanc
|
2
|
-
class
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
class Plugin
|
3
|
+
include Response
|
4
|
+
attr_accessor :base_uri
|
5
|
+
|
6
|
+
def initialize(id = nil)
|
7
|
+
client = Client.new
|
8
|
+
self.base_uri = client.base_uri["/plugins/#{id}"]
|
7
9
|
end
|
8
10
|
|
9
11
|
# GET /plugins/explorer.js
|
10
|
-
def
|
11
|
-
handle_response(base_uri["
|
12
|
+
def explorerjs # Get the JavaScript code that is injected by plugins into Orthanc Explorer
|
13
|
+
handle_response(base_uri["explorer.js"].get)
|
12
14
|
end
|
13
15
|
|
14
16
|
# GET /plugins/{id}
|
15
|
-
def
|
16
|
-
handle_response(base_uri
|
17
|
+
def fetch # Fetch API response
|
18
|
+
handle_response(base_uri.get)
|
17
19
|
end
|
18
20
|
|
19
21
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Response
|
2
|
+
|
3
|
+
def bool_to_num(bool)
|
4
|
+
return 0 if bool == false
|
5
|
+
return 1 if bool == true
|
6
|
+
end
|
7
|
+
|
8
|
+
def num_to_bool(num)
|
9
|
+
return false if num == "0"
|
10
|
+
return true if num == "1"
|
11
|
+
end
|
12
|
+
|
13
|
+
def handle_response(response)
|
14
|
+
begin
|
15
|
+
# Try to parse response
|
16
|
+
parsed_response = JSON.parse(response)
|
17
|
+
|
18
|
+
if parsed_response.class == Array
|
19
|
+
return parsed_response
|
20
|
+
elsif parsed_response.class == Hash
|
21
|
+
return RecursiveOpenStruct.new(parsed_response.to_snake_keys, recurse_over_arrays: true )
|
22
|
+
else
|
23
|
+
return response
|
24
|
+
end
|
25
|
+
rescue JSON::ParserError => e # If JSON parse fails, return original response
|
26
|
+
return response
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
data/lib/orthanc/series.rb
CHANGED
@@ -1,141 +1,110 @@
|
|
1
1
|
module Orthanc
|
2
|
-
class
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
class Series
|
3
|
+
include Response
|
4
|
+
attr_accessor :base_uri
|
5
|
+
|
6
|
+
def initialize(id = nil)
|
7
|
+
client = Client.new
|
8
|
+
self.base_uri = client.base_uri["/series/#{id}"]
|
7
9
|
end
|
8
10
|
|
9
|
-
# GET /series/{id}
|
10
|
-
def
|
11
|
-
handle_response(base_uri
|
11
|
+
# GET /series, # GET /series/{id}
|
12
|
+
def fetch # Fetch API response
|
13
|
+
handle_response(base_uri.get)
|
12
14
|
end
|
13
15
|
|
14
16
|
# DELETE /series/{id}
|
15
|
-
def
|
16
|
-
handle_response(base_uri
|
17
|
+
def delete
|
18
|
+
handle_response(base_uri.delete)
|
17
19
|
end
|
18
20
|
|
19
21
|
# POST /series/{id}/anonymize
|
20
|
-
def
|
21
|
-
handle_response(base_uri["
|
22
|
+
def anonymize(payload = {}) # https://code.google.com/p/orthanc/wiki/Anonymization
|
23
|
+
handle_response(base_uri["anonymize"].post(payload.to_s))
|
22
24
|
end
|
23
25
|
|
24
26
|
# GET /series/{id}/archive
|
25
|
-
def
|
26
|
-
base_uri["
|
27
|
+
def archive # Create ZIP
|
28
|
+
base_uri["archive"].get # CAREFUL! Returns the whole zipfile
|
27
29
|
end
|
28
30
|
|
29
31
|
# GET /series/{id}/instances
|
30
|
-
def
|
31
|
-
handle_response(base_uri["
|
32
|
+
def instances # Retrieve all the instances of this patient in a single REST call
|
33
|
+
handle_response(base_uri["instances"].get)
|
32
34
|
end
|
33
35
|
|
34
36
|
# GET /series/{id}/media
|
35
|
-
def
|
36
|
-
base_uri["
|
37
|
+
def media # Create a ZIP archive for media storage with DICOMDIR
|
38
|
+
base_uri["media"].get # CAREFUL! Returns the whole zipfile
|
37
39
|
end
|
38
40
|
|
39
41
|
# POST /series/{id}/modify
|
40
|
-
def
|
41
|
-
handle_response(base_uri["
|
42
|
+
def modify(payload = {}) # https://code.google.com/p/orthanc/wiki/Anonymization
|
43
|
+
handle_response(base_uri["modify"].post(payload.to_s))
|
42
44
|
end
|
43
45
|
|
44
46
|
# GET /series/{id}/module
|
45
|
-
def
|
46
|
-
handle_response(base_uri["
|
47
|
+
def module
|
48
|
+
handle_response(base_uri["module"].get)
|
47
49
|
end
|
48
50
|
|
49
51
|
# GET /series/{id}/patient
|
50
|
-
def
|
51
|
-
handle_response(base_uri["
|
52
|
+
def patient
|
53
|
+
handle_response(base_uri["patient"].get)
|
52
54
|
end
|
53
55
|
|
54
56
|
# GET /series/{id}/shared-tags
|
55
|
-
def
|
56
|
-
handle_response(base_uri["
|
57
|
+
def shared_tags(params = {}) # "?simplify" argument to simplify output
|
58
|
+
handle_response(base_uri["shared-tags"].get({params: params}))
|
57
59
|
end
|
58
60
|
|
59
61
|
# GET /series/{id}/statistics
|
60
|
-
def
|
61
|
-
handle_response(base_uri["
|
62
|
+
def statistics
|
63
|
+
handle_response(base_uri["statistics"].get)
|
62
64
|
end
|
63
65
|
|
64
66
|
# GET /series/{id}/study
|
65
|
-
def
|
66
|
-
handle_response(base_uri["
|
67
|
+
def study
|
68
|
+
handle_response(base_uri["study"].get)
|
67
69
|
end
|
68
70
|
|
69
|
-
#
|
71
|
+
# ---------- Polymorphic resources ----------
|
72
|
+
# Attachments
|
70
73
|
|
71
74
|
# GET /{resourceType}/{id}/attachments
|
72
|
-
def
|
73
|
-
handle_response(base_uri["
|
74
|
-
end
|
75
|
-
|
76
|
-
# DELETE /{resourceType}/{id}/attachments/{name}
|
77
|
-
def delete_series_attachment(id, name)
|
78
|
-
handle_response(base_uri["series/#{id}/attachments/#{name}"].delete)
|
79
|
-
end
|
80
|
-
|
81
|
-
# PUT /{resourceType}/{id}/attachments/{name}
|
82
|
-
def series_attachment(id, name, payload = {})
|
83
|
-
handle_response(base_uri["series/#{id}/attachments/#{name}"].put(payload))
|
84
|
-
end
|
85
|
-
|
86
|
-
# GET /{resourceType}/{id}/attachments/{name}/compressed-data
|
87
|
-
def series_attachment_compressed_data(id, name)
|
88
|
-
handle_response(base_uri["series/#{id}/attachments/#{name}/compressed-data"].get)
|
89
|
-
end
|
90
|
-
|
91
|
-
# GET /{resourceType}/{id}/attachments/{name}/compressed-md5
|
92
|
-
def series_attachment_compressed_md5(id, name)
|
93
|
-
handle_response(base_uri["series/#{id}/attachments/#{name}/compressed-md5"].get)
|
94
|
-
end
|
95
|
-
|
96
|
-
# GET /{resourceType}/{id}/attachments/{name}/compressed-size
|
97
|
-
def series_attachment_compressed_size(id, name)
|
98
|
-
handle_response(base_uri["series/#{id}/attachments/#{name}/compressed-size"].get)
|
75
|
+
def attachments_list # Orthanc endpoint response
|
76
|
+
handle_response(base_uri["attachments"].get)
|
99
77
|
end
|
100
78
|
|
101
|
-
|
102
|
-
|
103
|
-
|
79
|
+
def attachments(id = nil)
|
80
|
+
if id
|
81
|
+
return Attachment.new(base_uri, id)
|
82
|
+
else
|
83
|
+
a = []
|
84
|
+
handle_response(base_uri["attachments"].get).each do |id|
|
85
|
+
a << Attachment.new(base_uri, id)
|
86
|
+
end
|
87
|
+
return a
|
88
|
+
end
|
104
89
|
end
|
105
90
|
|
106
|
-
#
|
107
|
-
def series_attachment_md5(id, name)
|
108
|
-
handle_response(base_uri["series/#{id}/attachments/#{name}/md5"].get)
|
109
|
-
end
|
110
|
-
|
111
|
-
# GET /{resourceType}/{id}/attachments/{name}/size
|
112
|
-
def series_attachment_size(id, name)
|
113
|
-
handle_response(base_uri["series/#{id}/attachments/#{name}/size"].get)
|
114
|
-
end
|
115
|
-
|
116
|
-
# POST /{resourceType}/{id}/attachments/{name}/verify-md5
|
117
|
-
def series_attachment_verify_md5(id, name)
|
118
|
-
handle_response(base_uri["series/#{id}/attachments/#{name}/verify-md5"].get)
|
119
|
-
end
|
91
|
+
# Metadata
|
120
92
|
|
121
93
|
# GET /{resourceType}/{id}/metadata
|
122
|
-
def
|
123
|
-
handle_response(base_uri["
|
124
|
-
end
|
125
|
-
|
126
|
-
#
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
# GET /{resourceType}/{id}/metadata/{name}
|
137
|
-
def series_update_metadata(id, name, payload = {})
|
138
|
-
handle_response(base_uri["series/#{id}/metadata/#{name}"].put(payload))
|
94
|
+
def metadata_list # Orthanc endpoint response
|
95
|
+
handle_response(base_uri["metadata"].get)
|
96
|
+
end
|
97
|
+
|
98
|
+
def metadata(name = nil) # As class instances, for method chaining
|
99
|
+
if name
|
100
|
+
return Metadata.new(base_uri, name)
|
101
|
+
else
|
102
|
+
a = []
|
103
|
+
handle_response(base_uri["metadata"].get).each do |name|
|
104
|
+
a << Metadata.new(base_uri, name)
|
105
|
+
end
|
106
|
+
return a
|
107
|
+
end
|
139
108
|
end
|
140
109
|
|
141
110
|
end
|