orthanc 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,146 +1,115 @@
1
1
  module Orthanc
2
- class Client
3
- # ------------- Studies -------------
4
- # GET /studies
5
- def all_studies
6
- handle_response(base_uri["studies"].get)
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 study(id)
11
- handle_response(base_uri["studies/#{id}"].get)
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 delete_study(id)
16
- handle_response(base_uri["studies/#{id}"].delete)
17
+ def delete
18
+ handle_response(base_uri.delete)
17
19
  end
18
20
 
19
21
  # POST /studies/{id}/anonymize
20
- def anonymize_study(id, payload = {}) # https://code.google.com/p/orthanc/wiki/Anonymization
21
- handle_response(base_uri["studies/#{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 /studies/{id}/archive
25
- def archive_study(id) # Create ZIP
26
- base_uri["studies/#{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 /studies/{id}/instances
30
- def study_instances(id) # Retrieve all the instances of this patient in a single REST call
31
- handle_response(base_uri["studies/#{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 /studies/{id}/media
35
- def study_media(id) # Create a ZIP archive for media storage with DICOMDIR
36
- base_uri["studies/#{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 /studies/{id}/modify
40
- def modify_study(id, payload = {}) # https://code.google.com/p/orthanc/wiki/Anonymization
41
- handle_response(base_uri["studies/#{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 /studies/{id}/module
45
- def study_module(id)
46
- handle_response(base_uri["studies/#{id}/module"].get)
47
+ def module
48
+ handle_response(base_uri["module"].get)
47
49
  end
48
50
 
49
51
  # GET /studies/{id}/module-patient
50
- def study_module_patient(id)
51
- handle_response(base_uri["studies/#{id}/module-patient"].get)
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 study_patient(id)
56
- handle_response(base_uri["studies/#{id}/patient"].get)
57
+ def patient
58
+ handle_response(base_uri["patient"].get)
57
59
  end
58
60
 
59
61
  # GET /studies/{id}/series
60
- def study_series(id) # Retrieve all the series of this patient in a single REST call
61
- handle_response(base_uri["studies/#{id}/series"].get)
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 study_shared_tags(id) # "?simplify" argument to simplify output
66
- handle_response(base_uri["studies/#{id}/shared-tags"].get)
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 study_statistics(id)
71
- handle_response(base_uri["studies/#{id}/statistics"].get)
72
+ def statistics
73
+ handle_response(base_uri["statistics"].get)
72
74
  end
73
75
 
74
- # TODO: Polymorphic resourceType resources. Repetitive. must refactor
76
+ # ---------- Polymorphic resources ----------
77
+ # Attachments
75
78
 
76
79
  # GET /{resourceType}/{id}/attachments
77
- def study_attachments(id)
78
- handle_response(base_uri["studies/#{id}/attachments"].get)
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
- # GET /{resourceType}/{id}/attachments/{name}/data
107
- def study_attachment_data(id, name)
108
- handle_response(base_uri["studies/#{id}/attachments/#{name}/data"].get)
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
- # GET /{resourceType}/{id}/attachments/{name}/md5
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 study_all_metadata(id)
128
- handle_response(base_uri["studies/#{id}/metadata"].get)
129
- end
130
-
131
- # GET /{resourceType}/{id}/metadata/{name}
132
- def study_metadata(id, name)
133
- handle_response(base_uri["studies/#{id}/metadata/#{name}"].get)
134
- end
135
-
136
- # DELETE /{resourceType}/{id}/metadata/{name}
137
- def study_delete_metadata(id, name)
138
- handle_response(base_uri["studies/#{id}/metadata/#{name}"].delete)
139
- end
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
@@ -1,40 +1,46 @@
1
1
  module Orthanc
2
- class Client
3
- # ------------- Tools -------------
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 tools_create_dicom(payload = {}) # Create and store a new DICOM instance (experimental)
7
- handle_response(base_uri["tools/create-dicom"].post(payload))
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 tools_dicom_conformance # DICOM conformance statement of this version of Orthanc
12
- base_uri["tools/dicom-conformance"].get
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 tools_execute_script(payload = {}) # Execute the Lua script in the POST body (experimental)
17
- handle_response(base_uri["tools/execute-script"].post(payload))
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 tools_generate_uid(level) # "level" argument among "patient", "study", "series" and "instance"
22
- handle_response(base_uri["tools/generate-uid"].get({params: {level: level}}))
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 tools_lookup(payload = {}) # Map DICOM UIDs to Orthanc identifiers
27
- handle_response(base_uri["tools/lookup"].post(payload))
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 tools_now # Returns the current datetime in the ISO 8601 format
32
- base_uri["tools/now"].get
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 tools_reset(payload = {}) # Hot restart of Orthanc, the configuration file will be read again
37
- handle_response(base_uri["tools/reset"].post(payload))
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
@@ -1,3 +1,4 @@
1
1
  module Orthanc
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
+ ORTHANC_API_VERSION = "0.8.6"
3
4
  end
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.1.1
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-17 00:00:00.000000000 Z
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