Class: Orthanc::Patient

Inherits:
Object
  • Object
show all
Includes:
Response
Defined in:
lib/orthanc/patients.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Response

#bool_to_num, #handle_response, #num_to_bool

Constructor Details

#initialize(id = nil) ⇒ Patient

Returns a new instance of Patient.



6
7
8
9
# File 'lib/orthanc/patients.rb', line 6

def initialize(id = nil)
  client = Client.new
  self.base_uri = client.base_uri["/patients/#{id}"]
end

Instance Attribute Details

#base_uriObject

Returns the value of attribute base_uri.



4
5
6
# File 'lib/orthanc/patients.rb', line 4

def base_uri
  @base_uri
end

Instance Method Details

#anonymize(payload = {}) ⇒ Object

POST /patients/id/anonymize



22
23
24
# File 'lib/orthanc/patients.rb', line 22

def anonymize(payload = {}) # https://code.google.com/p/orthanc/wiki/Anonymization
  handle_response(base_uri["anonymize"].post(payload.to_s))
end

#archiveObject

GET /patients/id/archive



27
28
29
# File 'lib/orthanc/patients.rb', line 27

def archive # Create ZIP
  base_uri["archive"].get # CAREFUL! Returns the whole zipfile
end

#attachments(id = nil) ⇒ Object



91
92
93
94
95
96
97
98
99
100
101
# File 'lib/orthanc/patients.rb', line 91

def attachments(id = nil)
  if id
    return Attachment.new(base_uri, id)
  else
    a = []
    handle_response(base_uri["attachments"].get).each do |id|
      a << Attachment.new(base_uri, id)
    end
    return a
  end
end

#attachments_listObject

GET /resourceType/id/attachments



87
88
89
# File 'lib/orthanc/patients.rb', line 87

def attachments_list # Orthanc endpoint response
  handle_response(base_uri["attachments"].get)
end

#deleteObject

DELETE /patients/id



17
18
19
# File 'lib/orthanc/patients.rb', line 17

def delete
  handle_response(base_uri.delete)
end

#fetchObject

GET /patients, # GET /patients/id



12
13
14
# File 'lib/orthanc/patients.rb', line 12

def fetch # Fetch API response
  handle_response(base_uri.get)
end

#instancesObject

GET /patients/id/instances



32
33
34
# File 'lib/orthanc/patients.rb', line 32

def instances # Retrieve all the instances of this patient in a single REST call
  handle_response(base_uri["instances"].get)
end

#mediaObject

GET /patients/id/media



37
38
39
# File 'lib/orthanc/patients.rb', line 37

def media # Create a ZIP archive for media storage with DICOMDIR
  base_uri["media"].get # CAREFUL! Returns the whole zipfile
end

#metadata(name = nil) ⇒ Object

As class instances, for method chaining



110
111
112
113
114
115
116
117
118
119
120
# File 'lib/orthanc/patients.rb', line 110

def (name = nil) # As class instances, for method chaining
  if name
    return .new(base_uri, name)
  else
    a = []
    handle_response(base_uri["metadata"].get).each do |name|
      a << .new(base_uri, name)
    end
    return a
  end
end

#metadata_listObject

GET /resourceType/id/metadata



106
107
108
# File 'lib/orthanc/patients.rb', line 106

def  # Orthanc endpoint response
  handle_response(base_uri["metadata"].get)
end

#modify(payload = {}) ⇒ Object

POST /patients/id/modify



42
43
44
# File 'lib/orthanc/patients.rb', line 42

def modify(payload = {}) # https://code.google.com/p/orthanc/wiki/Anonymization
  handle_response(base_uri["modify"].post(payload.to_s))
end

#moduleObject

GET /patients/id/module



47
48
49
# File 'lib/orthanc/patients.rb', line 47

def module
  handle_response(base_uri["module"].get)
end

#protected(boolstatus = true) ⇒ Object

PUT /patients/id/protected



57
58
59
60
61
# File 'lib/orthanc/patients.rb', line 57

def protected(boolstatus = true) # Protection against recycling: "0" means unprotected, "1" protected
  status = bool_to_num(boolstatus)
  base_uri["protected"].put("#{status}")
  return nil # API returns ""
end

#protected?Boolean

GET /patients/id/protected

Returns:

  • (Boolean)


52
53
54
# File 'lib/orthanc/patients.rb', line 52

def protected? # Protection against recycling: "0" means unprotected, "1" protected
  num_to_bool(base_uri["protected"].get)
end

#seriesObject

GET /patients/id/series



64
65
66
# File 'lib/orthanc/patients.rb', line 64

def series # Retrieve all the series of this patient in a single REST call
  handle_response(base_uri["series"].get)
end

#shared_tags(params = {}) ⇒ Object

GET /patients/id/shared-tags



69
70
71
# File 'lib/orthanc/patients.rb', line 69

def shared_tags(params = {}) # "?simplify" argument to simplify output
  handle_response(base_uri["shared-tags"].get({params: params}))
end

#statisticsObject

GET /patients/id/statistics



74
75
76
# File 'lib/orthanc/patients.rb', line 74

def statistics
  handle_response(base_uri["statistics"].get)
end

#studiesObject

GET /patients/id/studies



79
80
81
# File 'lib/orthanc/patients.rb', line 79

def studies # Retrieve all the studies of this patient in a single REST call
  handle_response(base_uri["studies"].get)
end