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
data/lib/orthanc/studies.rb
CHANGED
@@ -1,146 +1,115 @@
|
|
1
1
|
module Orthanc
|
2
|
-
class
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
class Study
|
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["/studies/#{id}"]
|
7
9
|
end
|
8
10
|
|
9
|
-
# GET /studies/{id}
|
10
|
-
def
|
11
|
-
handle_response(base_uri
|
11
|
+
# GET /studies, # GET /studies/{id}
|
12
|
+
def fetch # Fetch API response
|
13
|
+
handle_response(base_uri.get)
|
12
14
|
end
|
13
15
|
|
14
16
|
# DELETE /studies/{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 /studies/{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 /studies/{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 /studies/{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 /studies/{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 /studies/{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 /studies/{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 /studies/{id}/module-patient
|
50
|
-
def
|
51
|
-
handle_response(base_uri["
|
52
|
+
def module_patient
|
53
|
+
handle_response(base_uri["module-patient"].get)
|
52
54
|
end
|
53
55
|
|
54
56
|
# GET /studies/{id}/patient
|
55
|
-
def
|
56
|
-
handle_response(base_uri["
|
57
|
+
def patient
|
58
|
+
handle_response(base_uri["patient"].get)
|
57
59
|
end
|
58
60
|
|
59
61
|
# GET /studies/{id}/series
|
60
|
-
def
|
61
|
-
handle_response(base_uri["
|
62
|
+
def series # Retrieve all the series of this patient in a single REST call
|
63
|
+
handle_response(base_uri["series"].get)
|
62
64
|
end
|
63
65
|
|
64
66
|
# GET /studies/{id}/shared-tags
|
65
|
-
def
|
66
|
-
handle_response(base_uri["
|
67
|
+
def shared_tags(params = {}) # "?simplify" argument to simplify output
|
68
|
+
handle_response(base_uri["shared-tags"].get({params: params}))
|
67
69
|
end
|
68
70
|
|
69
71
|
# GET /studies/{id}/statistics
|
70
|
-
def
|
71
|
-
handle_response(base_uri["
|
72
|
+
def statistics
|
73
|
+
handle_response(base_uri["statistics"].get)
|
72
74
|
end
|
73
75
|
|
74
|
-
#
|
76
|
+
# ---------- Polymorphic resources ----------
|
77
|
+
# Attachments
|
75
78
|
|
76
79
|
# GET /{resourceType}/{id}/attachments
|
77
|
-
def
|
78
|
-
handle_response(base_uri["
|
79
|
-
end
|
80
|
-
|
81
|
-
# DELETE /{resourceType}/{id}/attachments/{name}
|
82
|
-
def delete_study_attachment(id, name)
|
83
|
-
handle_response(base_uri["studies/#{id}/attachments/#{name}"].delete)
|
84
|
-
end
|
85
|
-
|
86
|
-
# PUT /{resourceType}/{id}/attachments/{name}
|
87
|
-
def study_attachment(id, name, payload = {})
|
88
|
-
handle_response(base_uri["studies/#{id}/attachments/#{name}"].put(payload))
|
89
|
-
end
|
90
|
-
|
91
|
-
# GET /{resourceType}/{id}/attachments/{name}/compressed-data
|
92
|
-
def study_attachment_compressed_data(id, name)
|
93
|
-
handle_response(base_uri["studies/#{id}/attachments/#{name}/compressed-data"].get)
|
94
|
-
end
|
95
|
-
|
96
|
-
# GET /{resourceType}/{id}/attachments/{name}/compressed-md5
|
97
|
-
def study_attachment_compressed_md5(id, name)
|
98
|
-
handle_response(base_uri["studies/#{id}/attachments/#{name}/compressed-md5"].get)
|
99
|
-
end
|
100
|
-
|
101
|
-
# GET /{resourceType}/{id}/attachments/{name}/compressed-size
|
102
|
-
def study_attachment_compressed_size(id, name)
|
103
|
-
handle_response(base_uri["studies/#{id}/attachments/#{name}/compressed-size"].get)
|
80
|
+
def attachments_list # Orthanc endpoint response
|
81
|
+
handle_response(base_uri["attachments"].get)
|
104
82
|
end
|
105
83
|
|
106
|
-
|
107
|
-
|
108
|
-
|
84
|
+
def attachments(id = nil)
|
85
|
+
if id
|
86
|
+
return Attachment.new(base_uri, id)
|
87
|
+
else
|
88
|
+
a = []
|
89
|
+
handle_response(base_uri["attachments"].get).each do |id|
|
90
|
+
a << Attachment.new(base_uri, id)
|
91
|
+
end
|
92
|
+
return a
|
93
|
+
end
|
109
94
|
end
|
110
95
|
|
111
|
-
#
|
112
|
-
def study_attachment_md5(id, name)
|
113
|
-
handle_response(base_uri["studies/#{id}/attachments/#{name}/md5"].get)
|
114
|
-
end
|
115
|
-
|
116
|
-
# GET /{resourceType}/{id}/attachments/{name}/size
|
117
|
-
def study_attachment_size(id, name)
|
118
|
-
handle_response(base_uri["studies/#{id}/attachments/#{name}/size"].get)
|
119
|
-
end
|
120
|
-
|
121
|
-
# POST /{resourceType}/{id}/attachments/{name}/verify-md5
|
122
|
-
def study_attachment_verify_md5(id, name)
|
123
|
-
handle_response(base_uri["studies/#{id}/attachments/#{name}/verify-md5"].get)
|
124
|
-
end
|
96
|
+
# Metadata
|
125
97
|
|
126
98
|
# GET /{resourceType}/{id}/metadata
|
127
|
-
def
|
128
|
-
handle_response(base_uri["
|
129
|
-
end
|
130
|
-
|
131
|
-
#
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
# PUT /{resourceType}/{id}/metadata/{name}
|
142
|
-
def study_update_metadata(id, name, payload = {})
|
143
|
-
handle_response(base_uri["studies/#{id}/metadata/#{name}"].put(payload))
|
99
|
+
def metadata_list # Orthanc endpoint response
|
100
|
+
handle_response(base_uri["metadata"].get)
|
101
|
+
end
|
102
|
+
|
103
|
+
def metadata(name = nil) # As class instances, for method chaining
|
104
|
+
if name
|
105
|
+
return Metadata.new(base_uri, name)
|
106
|
+
else
|
107
|
+
a = []
|
108
|
+
handle_response(base_uri["metadata"].get).each do |name|
|
109
|
+
a << Metadata.new(base_uri, name)
|
110
|
+
end
|
111
|
+
return a
|
112
|
+
end
|
144
113
|
end
|
145
114
|
|
146
115
|
end
|
data/lib/orthanc/tools.rb
CHANGED
@@ -1,40 +1,46 @@
|
|
1
1
|
module Orthanc
|
2
|
-
class
|
3
|
-
|
2
|
+
class Tool
|
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["tools"]
|
9
|
+
end
|
4
10
|
|
5
11
|
# POST /tools/create-dicom
|
6
|
-
def
|
7
|
-
handle_response(base_uri["
|
12
|
+
def create_dicom(payload = {}) # Create and store a new DICOM instance (experimental)
|
13
|
+
handle_response(base_uri["create-dicom"].post(payload))
|
8
14
|
end
|
9
15
|
|
10
16
|
# GET /tools/dicom-conformance
|
11
|
-
def
|
12
|
-
base_uri["
|
17
|
+
def dicom_conformance # DICOM conformance statement of this version of Orthanc
|
18
|
+
base_uri["dicom-conformance"].get
|
13
19
|
end
|
14
20
|
|
15
21
|
# POST /tools/execute-script
|
16
|
-
def
|
17
|
-
handle_response(base_uri["
|
22
|
+
def execute_script(payload = {}) # Execute the Lua script in the POST body (experimental)
|
23
|
+
handle_response(base_uri["execute-script"].post(payload))
|
18
24
|
end
|
19
25
|
|
20
26
|
# GET /tools/generate-uid
|
21
|
-
def
|
22
|
-
handle_response(base_uri["
|
27
|
+
def generate_uid(level) # "level" argument among "patient", "study", "series" and "instance"
|
28
|
+
handle_response(base_uri["generate-uid"].get({params: {level: level}}))
|
23
29
|
end
|
24
30
|
|
25
31
|
# POST /tools/lookup
|
26
|
-
def
|
27
|
-
handle_response(base_uri["
|
32
|
+
def lookup(payload = {}) # Map DICOM UIDs to Orthanc identifiers
|
33
|
+
handle_response(base_uri["lookup"].post(payload))
|
28
34
|
end
|
29
35
|
|
30
36
|
# GET /tools/now
|
31
|
-
def
|
32
|
-
base_uri["
|
37
|
+
def now # Returns the current datetime in the ISO 8601 format
|
38
|
+
base_uri["now"].get
|
33
39
|
end
|
34
40
|
|
35
41
|
# POST /tools/reset
|
36
|
-
def
|
37
|
-
handle_response(base_uri["
|
42
|
+
def reset(payload = {}) # Hot restart of Orthanc, the configuration file will be read again
|
43
|
+
handle_response(base_uri["reset"].post(payload))
|
38
44
|
end
|
39
45
|
|
40
46
|
end
|
data/lib/orthanc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: orthanc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Rascovsky
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -95,12 +95,15 @@ files:
|
|
95
95
|
- bin/console
|
96
96
|
- bin/setup
|
97
97
|
- lib/orthanc.rb
|
98
|
+
- lib/orthanc/attachments.rb
|
98
99
|
- lib/orthanc/client.rb
|
99
100
|
- lib/orthanc/instances.rb
|
101
|
+
- lib/orthanc/metadata.rb
|
100
102
|
- lib/orthanc/modalities.rb
|
101
103
|
- lib/orthanc/patients.rb
|
102
104
|
- lib/orthanc/peers.rb
|
103
105
|
- lib/orthanc/plugins.rb
|
106
|
+
- lib/orthanc/response.rb
|
104
107
|
- lib/orthanc/series.rb
|
105
108
|
- lib/orthanc/studies.rb
|
106
109
|
- lib/orthanc/tools.rb
|