orthanc 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -1,54 +1,56 @@
1
1
  module Orthanc
2
- class Client
3
- # ------------- Modalities -------------
4
- # GET /modalities
5
- def modalities
6
- handle_response(base_uri["modalities"].get)
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/{dicom}
10
- def modality(dicom)
11
- handle_response(base_uri["modalities/#{dicom}"].get)
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/{dicom}
15
- def delete_modality(dicom)
16
- handle_response(base_uri["modalities/#{dicom}"].delete)
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 modify_modality(dicom, payload = {})
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 modality_echo(dicom, payload = {}) # C-Echo SCU
26
- handle_response(base_uri["modalities/#{dicom}/echo"].post(payload))
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 modality_find(dicom, payload = {})
31
- handle_response(base_uri["modalities/#{dicom}/find"].post(payload))
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 modality_find_patient(dicom, payload = {})
36
- handle_response(base_uri["modalities/#{dicom}/find-patient"].post(payload))
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 modality_find_series(dicom, payload = {})
41
- handle_response(base_uri["modalities/#{dicom}/find-series"].post(payload))
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 modality_find_study(dicom, payload = {})
46
- handle_response(base_uri["modalities/#{dicom}/find-study"].post(payload))
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 modality_store(dicom, payload = {}) # POST body = UUID series, UUID instance, or raw DICOM file
51
- handle_response(base_uri["modalities/#{dicom}/store"].post(payload))
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
@@ -1,153 +1,122 @@
1
1
  module Orthanc
2
- class Client
3
- # ------------- Patients -------------
4
- # GET /patients
5
- def all_patients
6
- handle_response(base_uri["patients"].get)
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 patient(id)
11
- handle_response(base_uri["patients/#{id}"].get)
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 delete_patient(id)
16
- handle_response(base_uri["patients/#{id}"].delete)
17
+ def delete
18
+ handle_response(base_uri.delete)
17
19
  end
18
20
 
19
21
  # POST /patients/{id}/anonymize
20
- def anonymize_patient(id, payload = {}) # https://code.google.com/p/orthanc/wiki/Anonymization
21
- handle_response(base_uri["patients/#{id}/anonymize"].post(payload.to_s))
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 archive_patient(id) # Create ZIP
26
- base_uri["patients/#{id}/archive"].get # CAREFUL! Returns the whole zipfile
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 patient_instances(id) # Retrieve all the instances of this patient in a single REST call
31
- handle_response(base_uri["patients/#{id}/instances"].get)
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 patient_media(id) # Create a ZIP archive for media storage with DICOMDIR
36
- base_uri["patients/#{id}/media"].get # CAREFUL! Returns the whole zipfile
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 modify_patient(id, payload = {}) # https://code.google.com/p/orthanc/wiki/Anonymization
41
- handle_response(base_uri["patients/#{id}/modify"].post(payload.to_s))
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 patient_module(id)
46
- handle_response(base_uri["patients/#{id}/module"].get)
47
+ def module
48
+ handle_response(base_uri["module"].get)
47
49
  end
48
50
 
49
51
  # GET /patients/{id}/protected
50
- def is_patient_protected?(id) # Protection against recycling: "0" means unprotected, "1" protected
51
- num_to_bool(base_uri["patients/#{id}/protected"].get)
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 set_patient_protected(id, boolstatus = true) # Protection against recycling: "0" means unprotected, "1" protected
57
+ def protected(boolstatus = true) # Protection against recycling: "0" means unprotected, "1" protected
56
58
  status = bool_to_num(boolstatus)
57
- base_uri["patients/#{id}/protected"].put("#{status}")
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 patient_series(id) # Retrieve all the series of this patient in a single REST call
63
- handle_response(base_uri["patients/#{id}/series"].get)
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 patient_shared_tags(id) # "?simplify" argument to simplify output
68
- handle_response(base_uri["patients/#{id}/shared-tags"].get)
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 patient_statistics(id)
73
- handle_response(base_uri["patients/#{id}/statistics"].get)
74
+ def statistics
75
+ handle_response(base_uri["statistics"].get)
74
76
  end
75
77
 
76
78
  # GET /patients/{id}/studies
77
- def patient_studies(id) # Retrieve all the studies of this patient in a single REST call
78
- handle_response(base_uri["patients/#{id}/studies"].get)
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
- # TODO: Polymorphic resourceType resources. Repetitive. must refactor
83
+ # ---------- Polymorphic resources ----------
84
+ # Attachments
82
85
 
83
86
  # GET /{resourceType}/{id}/attachments
84
- def patient_attachments(id)
85
- handle_response(base_uri["patients/#{id}/attachments"].get)
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
- # GET /{resourceType}/{id}/attachments/{name}/data
114
- def patient_attachment_data(id, name)
115
- handle_response(base_uri["patients/#{id}/attachments/#{name}/data"].get)
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
- # GET /{resourceType}/{id}/attachments/{name}/md5
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 patient_all_metadata(id)
135
- handle_response(base_uri["patients/#{id}/metadata"].get)
136
- end
137
-
138
- # GET /{resourceType}/{id}/metadata/{name}
139
- def patient_metadata(id, name)
140
- handle_response(base_uri["patients/#{id}/metadata/#{name}"].get)
141
- end
142
-
143
- # DELETE /{resourceType}/{id}/metadata/{name}
144
- def patient_delete_metadata(id, name)
145
- handle_response(base_uri["patients/#{id}/metadata/#{name}"].delete)
146
- end
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
@@ -1,29 +1,31 @@
1
1
  module Orthanc
2
- class Client
3
- # ------------- Peers -------------
4
- # GET /peers
5
- def peers # Get the list of all the registered plugins
6
- handle_response(base_uri["peers"].get)
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/{peer}
10
- def peer(peer)
11
- handle_response(base_uri["peers/#{peer}"].get)
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/{peer}
15
- def delete_peer(peer)
16
- handle_response(base_uri["peers/#{peer}"].delete)
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 modify_peer(peer, payload = {})
21
- handle_response(base_uri["peers/#{peer}"].put(payload))
22
+ def modify(payload = {})
23
+ handle_response(base_uri.put(payload))
22
24
  end
23
25
 
24
26
  # GET /peers/{peer}/store
25
- def peer_store(peer, payload = {}) # POST body = UUID series, UUID instance, or raw DICOM file
26
- handle_response(base_uri["peers/#{peer}/store"].post(payload))
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
@@ -1,19 +1,21 @@
1
1
  module Orthanc
2
- class Client
3
- # ------------- Plugins -------------
4
- # GET /plugins
5
- def plugins # Get the list of all the registered plugins
6
- handle_response(base_uri["plugins"].get)
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 plugins_explorerjs # Get the JavaScript code that is injected by plugins into Orthanc Explorer
11
- handle_response(base_uri["plugins/explorer.js"].get)
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 plugin(id) # Get information about some plugin
16
- handle_response(base_uri["plugins/#{id}"].get)
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
@@ -1,141 +1,110 @@
1
1
  module Orthanc
2
- class Client
3
- # ------------- Series -------------
4
- # GET /series
5
- def all_series # Darn DICOM, why did you have to call them something that's spelled the same singular and plural?
6
- handle_response(base_uri["series"].get)
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 series(id)
11
- handle_response(base_uri["series/#{id}"].get)
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 delete_series(id)
16
- handle_response(base_uri["series/#{id}"].delete)
17
+ def delete
18
+ handle_response(base_uri.delete)
17
19
  end
18
20
 
19
21
  # POST /series/{id}/anonymize
20
- def anonymize_series(id, payload = {}) # https://code.google.com/p/orthanc/wiki/Anonymization
21
- handle_response(base_uri["series/#{id}/anonymize"].post(payload.to_s))
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 archive_series(id) # Create ZIP
26
- base_uri["series/#{id}/archive"].get # CAREFUL! Returns the whole zipfile
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 series_instances(id) # Retrieve all the instances of this patient in a single REST call
31
- handle_response(base_uri["series/#{id}/instances"].get)
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 series_media(id) # Create a ZIP archive for media storage with DICOMDIR
36
- base_uri["series/#{id}/media"].get # CAREFUL! Returns the whole zipfile
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 modify_series(id, payload = {}) # https://code.google.com/p/orthanc/wiki/Anonymization
41
- handle_response(base_uri["series/#{id}/modify"].post(payload.to_s))
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 series_module(id)
46
- handle_response(base_uri["series/#{id}/module"].get)
47
+ def module
48
+ handle_response(base_uri["module"].get)
47
49
  end
48
50
 
49
51
  # GET /series/{id}/patient
50
- def series_patient(id)
51
- handle_response(base_uri["series/#{id}/patient"].get)
52
+ def patient
53
+ handle_response(base_uri["patient"].get)
52
54
  end
53
55
 
54
56
  # GET /series/{id}/shared-tags
55
- def series_shared_tags(id) # "?simplify" argument to simplify output
56
- handle_response(base_uri["series/#{id}/shared-tags"].get)
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 series_statistics(id)
61
- handle_response(base_uri["series/#{id}/statistics"].get)
62
+ def statistics
63
+ handle_response(base_uri["statistics"].get)
62
64
  end
63
65
 
64
66
  # GET /series/{id}/study
65
- def series_study(id)
66
- handle_response(base_uri["series/#{id}/study"].get)
67
+ def study
68
+ handle_response(base_uri["study"].get)
67
69
  end
68
70
 
69
- # TODO: Polymorphic resourceType resources. Repetitive. must refactor
71
+ # ---------- Polymorphic resources ----------
72
+ # Attachments
70
73
 
71
74
  # GET /{resourceType}/{id}/attachments
72
- def series_attachments(id)
73
- handle_response(base_uri["series/#{id}/attachments"].get)
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
- # GET /{resourceType}/{id}/attachments/{name}/data
102
- def series_attachment_data(id, name)
103
- handle_response(base_uri["series/#{id}/attachments/#{name}/data"].get)
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
- # GET /{resourceType}/{id}/attachments/{name}/md5
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 series_all_metadata(id)
123
- handle_response(base_uri["series/#{id}/metadata"].get)
124
- end
125
-
126
- # GET /{resourceType}/{id}/metadata/{name}
127
- def series_metadata(id, name)
128
- handle_response(base_uri["series/#{id}/metadata/#{name}"].get)
129
- end
130
-
131
- # DELETE /{resourceType}/{id}/metadata/{name}
132
- def series_delete_metadata(id, name)
133
- handle_response(base_uri["series/#{id}/metadata/#{name}"].delete)
134
- end
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