class RTP::Prescription

The Prescription site class.

@note Relations:

* Parent: Plan
* Children: SiteSetup, SimulationField, Field

Attributes

course_id[R]
dose_spec[R]
dose_ttl[R]
dose_tx[R]
fields[R]

An array of Field records (if any) that belongs to this Prescription.

modality[R]
number_of_fields[R]
parent[RW]

The Record which this instance belongs to.

pattern[R]
rx_depth[R]
rx_note[R]
rx_site_name[R]
simulation_fields[R]

An array of SimulationField records (if any) that belongs to this Prescription.

site_setup[R]

The SiteSetup record (if any) that belongs to this Prescription.

technique[R]

Public Class Methods

load(string, parent) click to toggle source

Creates a new Prescription site by parsing a RTPConnect string line.

@param [#to_s] string the prescription site definition record string line @param [Record] parent a record which is used to determine the proper parent of this instance @return [Prescription] the created Precription instance @raise [ArgumentError] if given a string containing an invalid number of elements

# File lib/rtp-connect/prescription.rb, line 38
def self.load(string, parent)
  p = self.new(parent)
  p.load(string)
end
new(parent) click to toggle source

Creates a new Prescription site.

@param [Record] parent a record which is used to determine the proper parent of this instance

Calls superclass method
# File lib/rtp-connect/prescription.rb, line 47
def initialize(parent)
  super('RX_DEF', 4, 13)
  # Child objects:
  @site_setup = nil
  @fields = Array.new
  @simulation_fields = Array.new
  # Parent relation (may get more than one type of record here):
  @parent = get_parent(parent.to_record, Plan)
  @parent.add_prescription(self)
  @attributes = [
    # Required:
    :keyword,
    :course_id,
    :rx_site_name,
    # Optional:
    :technique,
    :modality,
    :dose_spec,
    :rx_depth,
    :dose_ttl,
    :dose_tx,
    :pattern,
    :rx_note,
    :number_of_fields
  ]
end

Public Instance Methods

==(other) click to toggle source

Checks for equality.

Other and self are considered equivalent if they are of compatible types and their attributes are equivalent.

@param other an object to be compared with self. @return [Boolean] true if self and other are considered equivalent

# File lib/rtp-connect/prescription.rb, line 82
def ==(other)
  if other.respond_to?(:to_prescription)
    other.send(:state) == state
  end
end
Also aliased as: eql?
add_field(child) click to toggle source

Adds a treatment field record to this instance.

@param [Field] child a Field instance which is to be associated with self

# File lib/rtp-connect/prescription.rb, line 94
def add_field(child)
  @fields << child.to_field
  child.parent = self
end
add_simulation_field(child) click to toggle source

Adds a simulation field record to this instance.

@param [Field] child a SimulationField instance which is to be associated with self

# File lib/rtp-connect/prescription.rb, line 103
def add_simulation_field(child)
  @simulation_fields << child.to_simulation_field
  child.parent = self
end
add_site_setup(child) click to toggle source

Adds a site setup record to this instance.

@param [SiteSetup] child a SiteSetup instance which is to be associated with self

# File lib/rtp-connect/prescription.rb, line 112
def add_site_setup(child)
  @site_setup = child.to_site_setup
  child.parent = self
end
children() click to toggle source

Collects the child records of this instance in a properly sorted array.

@return [Array<SiteSetup, SimulationField, Field>] a sorted array of self's child records

# File lib/rtp-connect/prescription.rb, line 121
def children
  return [@site_setup, @simulation_fields, @fields].flatten.compact
end
course_id=(value) click to toggle source

Sets the course_id attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/prescription.rb, line 182
def course_id=(value)
  @course_id = value && value.to_s
end
delete(record) click to toggle source

Removes the reference of the given instance from this instance.

@param [Field, SimulationField, SiteSetup] record a child record to be removed from this instance

# File lib/rtp-connect/prescription.rb, line 129
def delete(record)
  case record
  when Field
    delete_child(:fields, record)
  when SimulationField
    delete_child(:simulation_fields, record)
  when SiteSetup
    delete_site_setup
  else
    logger.warn("Unknown class (record) given to Prescription#delete: #{record.class}")
  end
end
delete_fields() click to toggle source

Removes all field references from this instance.

# File lib/rtp-connect/prescription.rb, line 144
def delete_fields
  delete_children(:fields)
end
delete_simulation_fields() click to toggle source

Removes all simulation_field references from this instance.

# File lib/rtp-connect/prescription.rb, line 150
def delete_simulation_fields
  delete_children(:simulation_fields)
end
delete_site_setup() click to toggle source

Removes the site setup reference from this instance.

# File lib/rtp-connect/prescription.rb, line 156
def delete_site_setup
  delete_child(:site_setup)
end
dose_spec=(value) click to toggle source

Sets the dose_spec attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/prescription.rb, line 214
def dose_spec=(value)
  @dose_spec = value && value.to_s
end
dose_ttl=(value) click to toggle source

Sets the dose_ttl attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/prescription.rb, line 230
def dose_ttl=(value)
  @dose_ttl = value && value.to_s.strip
end
dose_tx=(value) click to toggle source

Sets the dose_tx attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/prescription.rb, line 238
def dose_tx=(value)
  @dose_tx = value && value.to_s.strip
end
eql?(other)
Alias for: ==
hash() click to toggle source

Computes a hash code for this object.

@note Two objects with the same attributes will have the same hash code.

@return [Fixnum] the object's hash code

# File lib/rtp-connect/prescription.rb, line 166
def hash
  state.hash
end
modality=(value) click to toggle source

Sets the modality attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/prescription.rb, line 206
def modality=(value)
  @modality = value && value.to_s
end
number_of_fields=(value) click to toggle source

Sets the number_of_fields attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/prescription.rb, line 262
def number_of_fields=(value)
  @number_of_fields = value && value.to_s.strip
end
pattern=(value) click to toggle source

Sets the pattern attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/prescription.rb, line 246
def pattern=(value)
  @pattern = value && value.to_s
end
rx_depth=(value) click to toggle source

Sets the rx_depth attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/prescription.rb, line 222
def rx_depth=(value)
  @rx_depth = value && value.to_s
end
rx_note=(value) click to toggle source

Sets the rx_note attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/prescription.rb, line 254
def rx_note=(value)
  @rx_note = value && value.to_s
end
rx_site_name=(value) click to toggle source

Sets the rx_site_name attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/prescription.rb, line 190
def rx_site_name=(value)
  @rx_site_name = value && value.to_s
end
technique=(value) click to toggle source

Sets the technique attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/prescription.rb, line 198
def technique=(value)
  @technique = value && value.to_s
end
to_prescription() click to toggle source

Returns self.

@return [Prescription] self

# File lib/rtp-connect/prescription.rb, line 174
def to_prescription
  self
end