Class: RTP::Field

Inherits:
Record show all
Defined in:
lib/rtp-connect/field.rb

Overview

Note:

Relations:

  • Parent: Prescription

  • Children: ExtendedField, ControlPoint

The treatment Field class.

Constant Summary

Constants inherited from Record

Record::NR_SURPLUS_ATTRIBUTES

Instance Attribute Summary collapse

Attributes inherited from Record

#attributes, #crc, #keyword

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Record

#encode, #get_parent, #load, #to_record, #to_s, #values

Constructor Details

#initialize(parent) ⇒ Field

Creates a new (treatment) Field.

Parameters:

  • parent (Record)

    a record which is used to determine the proper parent of this instance



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/rtp-connect/field.rb', line 81

def initialize(parent)
  super('FIELD_DEF', 27, 49)
  # Child records:

  @control_points = Array.new
  @extended_field = nil
  # Parent relation (may get more than one type of record here):

  @parent = get_parent(parent.to_record, Prescription)
  @parent.add_field(self)
  @attributes = [
    # Required:

    :keyword,
    :rx_site_name,
    :field_name,
    :field_id,
    :field_note,
    :field_dose,
    :field_monitor_units,
    :wedge_monitor_units,
    :treatment_machine,
    :treatment_type,
    :modality,
    :energy,
    :time,
    :doserate,
    :sad,
    :ssd,
    :gantry_angle,
    :collimator_angle,
    :field_x_mode,
    :field_x,
    :collimator_x1,
    :collimator_x2,
    :field_y_mode,
    :field_y,
    :collimator_y1,
    :collimator_y2,
    # Optional:

    :couch_vertical,
    :couch_lateral,
    :couch_longitudinal,
    :couch_angle,
    :couch_pedestal,
    :tolerance_table,
    :arc_direction,
    :arc_start_angle,
    :arc_stop_angle,
    :arc_mu_degree,
    :wedge,
    :dynamic_wedge,
    :block,
    :compensator,
    :e_applicator,
    :e_field_def_aperture,
    :bolus,
    :portfilm_mu_open,
    :portfilm_coeff_open,
    :portfilm_delta_open,
    :portfilm_mu_treat,
    :portfilm_coeff_treat
  ]
end

Instance Attribute Details

#arc_directionObject

Returns the value of attribute arc_direction.



48
49
50
# File 'lib/rtp-connect/field.rb', line 48

def arc_direction
  @arc_direction
end

#arc_mu_degreeObject

Returns the value of attribute arc_mu_degree.



51
52
53
# File 'lib/rtp-connect/field.rb', line 51

def arc_mu_degree
  @arc_mu_degree
end

#arc_start_angleObject

Returns the value of attribute arc_start_angle.



49
50
51
# File 'lib/rtp-connect/field.rb', line 49

def arc_start_angle
  @arc_start_angle
end

#arc_stop_angleObject

Returns the value of attribute arc_stop_angle.



50
51
52
# File 'lib/rtp-connect/field.rb', line 50

def arc_stop_angle
  @arc_stop_angle
end

#blockObject

Returns the value of attribute block.



54
55
56
# File 'lib/rtp-connect/field.rb', line 54

def block
  @block
end

#bolusObject

Returns the value of attribute bolus.



58
59
60
# File 'lib/rtp-connect/field.rb', line 58

def bolus
  @bolus
end

#collimator_angleObject

Returns the value of attribute collimator_angle.



33
34
35
# File 'lib/rtp-connect/field.rb', line 33

def collimator_angle
  @collimator_angle
end

#collimator_x1Object

Returns the value of attribute collimator_x1.



36
37
38
# File 'lib/rtp-connect/field.rb', line 36

def collimator_x1
  @collimator_x1
end

#collimator_x2Object

Returns the value of attribute collimator_x2.



37
38
39
# File 'lib/rtp-connect/field.rb', line 37

def collimator_x2
  @collimator_x2
end

#collimator_y1Object

Returns the value of attribute collimator_y1.



40
41
42
# File 'lib/rtp-connect/field.rb', line 40

def collimator_y1
  @collimator_y1
end

#collimator_y2Object

Returns the value of attribute collimator_y2.



41
42
43
# File 'lib/rtp-connect/field.rb', line 41

def collimator_y2
  @collimator_y2
end

#compensatorObject

Returns the value of attribute compensator.



55
56
57
# File 'lib/rtp-connect/field.rb', line 55

def compensator
  @compensator
end

#control_pointsObject (readonly)

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



16
17
18
# File 'lib/rtp-connect/field.rb', line 16

def control_points
  @control_points
end

#couch_angleObject

Returns the value of attribute couch_angle.



45
46
47
# File 'lib/rtp-connect/field.rb', line 45

def couch_angle
  @couch_angle
end

#couch_lateralObject

Returns the value of attribute couch_lateral.



43
44
45
# File 'lib/rtp-connect/field.rb', line 43

def couch_lateral
  @couch_lateral
end

#couch_longitudinalObject

Returns the value of attribute couch_longitudinal.



44
45
46
# File 'lib/rtp-connect/field.rb', line 44

def couch_longitudinal
  @couch_longitudinal
end

#couch_pedestalObject

Returns the value of attribute couch_pedestal.



46
47
48
# File 'lib/rtp-connect/field.rb', line 46

def couch_pedestal
  @couch_pedestal
end

#couch_verticalObject

Returns the value of attribute couch_vertical.



42
43
44
# File 'lib/rtp-connect/field.rb', line 42

def couch_vertical
  @couch_vertical
end

#doserateObject

Returns the value of attribute doserate.



29
30
31
# File 'lib/rtp-connect/field.rb', line 29

def doserate
  @doserate
end

#dynamic_wedgeObject

Returns the value of attribute dynamic_wedge.



53
54
55
# File 'lib/rtp-connect/field.rb', line 53

def dynamic_wedge
  @dynamic_wedge
end

#e_applicatorObject

Returns the value of attribute e_applicator.



56
57
58
# File 'lib/rtp-connect/field.rb', line 56

def e_applicator
  @e_applicator
end

#e_field_def_apertureObject

Returns the value of attribute e_field_def_aperture.



57
58
59
# File 'lib/rtp-connect/field.rb', line 57

def e_field_def_aperture
  @e_field_def_aperture
end

#energyObject

Returns the value of attribute energy.



27
28
29
# File 'lib/rtp-connect/field.rb', line 27

def energy
  @energy
end

#extended_fieldObject (readonly)

The ExtendedField record (if any) that belongs to this Field.



14
15
16
# File 'lib/rtp-connect/field.rb', line 14

def extended_field
  @extended_field
end

#field_doseObject

Returns the value of attribute field_dose.



21
22
23
# File 'lib/rtp-connect/field.rb', line 21

def field_dose
  @field_dose
end

#field_idObject

Returns the value of attribute field_id.



19
20
21
# File 'lib/rtp-connect/field.rb', line 19

def field_id
  @field_id
end

#field_monitor_unitsObject

Returns the value of attribute field_monitor_units.



22
23
24
# File 'lib/rtp-connect/field.rb', line 22

def field_monitor_units
  @field_monitor_units
end

#field_nameObject

Returns the value of attribute field_name.



18
19
20
# File 'lib/rtp-connect/field.rb', line 18

def field_name
  @field_name
end

#field_noteObject

Returns the value of attribute field_note.



20
21
22
# File 'lib/rtp-connect/field.rb', line 20

def field_note
  @field_note
end

#field_xObject

Returns the value of attribute field_x.



35
36
37
# File 'lib/rtp-connect/field.rb', line 35

def field_x
  @field_x
end

#field_x_modeObject

Returns the value of attribute field_x_mode.



34
35
36
# File 'lib/rtp-connect/field.rb', line 34

def field_x_mode
  @field_x_mode
end

#field_yObject

Returns the value of attribute field_y.



39
40
41
# File 'lib/rtp-connect/field.rb', line 39

def field_y
  @field_y
end

#field_y_modeObject

Returns the value of attribute field_y_mode.



38
39
40
# File 'lib/rtp-connect/field.rb', line 38

def field_y_mode
  @field_y_mode
end

#gantry_angleObject

Returns the value of attribute gantry_angle.



32
33
34
# File 'lib/rtp-connect/field.rb', line 32

def gantry_angle
  @gantry_angle
end

#modalityObject

Returns the value of attribute modality.



26
27
28
# File 'lib/rtp-connect/field.rb', line 26

def modality
  @modality
end

#parentObject

The Record which this instance belongs to.



12
13
14
# File 'lib/rtp-connect/field.rb', line 12

def parent
  @parent
end

#portfilm_coeff_openObject

Returns the value of attribute portfilm_coeff_open.



60
61
62
# File 'lib/rtp-connect/field.rb', line 60

def portfilm_coeff_open
  @portfilm_coeff_open
end

#portfilm_coeff_treatObject

Returns the value of attribute portfilm_coeff_treat.



63
64
65
# File 'lib/rtp-connect/field.rb', line 63

def portfilm_coeff_treat
  @portfilm_coeff_treat
end

#portfilm_delta_openObject

Returns the value of attribute portfilm_delta_open.



61
62
63
# File 'lib/rtp-connect/field.rb', line 61

def portfilm_delta_open
  @portfilm_delta_open
end

#portfilm_mu_openObject

Returns the value of attribute portfilm_mu_open.



59
60
61
# File 'lib/rtp-connect/field.rb', line 59

def portfilm_mu_open
  @portfilm_mu_open
end

#portfilm_mu_treatObject

Returns the value of attribute portfilm_mu_treat.



62
63
64
# File 'lib/rtp-connect/field.rb', line 62

def portfilm_mu_treat
  @portfilm_mu_treat
end

#rx_site_nameObject

Returns the value of attribute rx_site_name.



17
18
19
# File 'lib/rtp-connect/field.rb', line 17

def rx_site_name
  @rx_site_name
end

#sadObject

Returns the value of attribute sad.



30
31
32
# File 'lib/rtp-connect/field.rb', line 30

def sad
  @sad
end

#ssdObject

Returns the value of attribute ssd.



31
32
33
# File 'lib/rtp-connect/field.rb', line 31

def ssd
  @ssd
end

#timeObject

Returns the value of attribute time.



28
29
30
# File 'lib/rtp-connect/field.rb', line 28

def time
  @time
end

#tolerance_tableObject

Returns the value of attribute tolerance_table.



47
48
49
# File 'lib/rtp-connect/field.rb', line 47

def tolerance_table
  @tolerance_table
end

#treatment_machineObject

Returns the value of attribute treatment_machine.



24
25
26
# File 'lib/rtp-connect/field.rb', line 24

def treatment_machine
  @treatment_machine
end

#treatment_typeObject

Returns the value of attribute treatment_type.



25
26
27
# File 'lib/rtp-connect/field.rb', line 25

def treatment_type
  @treatment_type
end

#wedgeObject

Returns the value of attribute wedge.



52
53
54
# File 'lib/rtp-connect/field.rb', line 52

def wedge
  @wedge
end

#wedge_monitor_unitsObject

Returns the value of attribute wedge_monitor_units.



23
24
25
# File 'lib/rtp-connect/field.rb', line 23

def wedge_monitor_units
  @wedge_monitor_units
end

Class Method Details

.load(string, parent) ⇒ Field

Creates a new (treatment) Field by parsing a RTPConnect string line.

Parameters:

  • string (#to_s)

    the treatment field definition record string line

  • parent (Record)

    a record which is used to determine the proper parent of this instance

Returns:

  • (Field)

    the created Field instance

Raises:

  • (ArgumentError)

    if given a string containing an invalid number of elements



72
73
74
75
# File 'lib/rtp-connect/field.rb', line 72

def self.load(string, parent)
  f = self.new(parent)
  f.load(string)
end

Instance Method Details

#==(other) ⇒ Boolean Also known as: eql?

Checks for equality.

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

Parameters:

  • other

    an object to be compared with self.

Returns:

  • (Boolean)

    true if self and other are considered equivalent



151
152
153
154
155
# File 'lib/rtp-connect/field.rb', line 151

def ==(other)
  if other.respond_to?(:to_field)
    other.send(:state) == state
  end
end

#add_control_point(child) ⇒ Object

Adds a control point record to this instance.

Parameters:

  • child (ControlPoint)

    a ControlPoint instance which is to be associated with self



163
164
165
166
# File 'lib/rtp-connect/field.rb', line 163

def add_control_point(child)
  @control_points << child.to_control_point
  child.parent = self
end

#add_extended_field(child) ⇒ Object

Adds an extended treatment field record to this instance.

Parameters:

  • child (ExtendedField)

    an ExtendedField instance which is to be associated with self



172
173
174
175
# File 'lib/rtp-connect/field.rb', line 172

def add_extended_field(child)
  @extended_field = child.to_extended_field
  child.parent = self
end

#childrenArray<ExtendedField, ControlPoint>

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

Returns:



181
182
183
# File 'lib/rtp-connect/field.rb', line 181

def children
  return [@extended_field, @control_points].flatten.compact
end

#dcm_collimator_x1Float

Converts the collimator_x1 attribute to proper DICOM format.

Returns:

  • (Float)

    the DICOM-formatted collimator_x1 attribute



189
190
191
# File 'lib/rtp-connect/field.rb', line 189

def dcm_collimator_x1
  dcm_collimator1(:x)
end

#dcm_collimator_x2Float

Converts the collimator_x2 attribute to proper DICOM format.

Returns:

  • (Float)

    the DICOM-formatted collimator_x2 attribute



197
198
199
# File 'lib/rtp-connect/field.rb', line 197

def dcm_collimator_x2
  value = @collimator_x2.to_f * 10
end

#dcm_collimator_y1Float

Converts the collimator_y1 attribute to proper DICOM format.

Returns:

  • (Float)

    the DICOM-formatted collimator_y1 attribute



205
206
207
# File 'lib/rtp-connect/field.rb', line 205

def dcm_collimator_y1
  dcm_collimator1(:y)
end

#dcm_collimator_y2Float

Converts the collimator_y2 attribute to proper DICOM format.

Returns:

  • (Float)

    the DICOM-formatted collimator_y2 attribute



213
214
215
# File 'lib/rtp-connect/field.rb', line 213

def dcm_collimator_y2
  value = @collimator_y2.to_f * 10
end

#delete(record) ⇒ Object

Removes the reference of the given instance from this instance.

Parameters:



221
222
223
224
225
226
227
228
229
230
# File 'lib/rtp-connect/field.rb', line 221

def delete(record)
  case record
  when ControlPoint
    delete_child(:control_points, record)
  when ExtendedField
    delete_extended_field
  else
    logger.warn("Unknown class (record) given to Field#delete: #{record.class}")
  end
end

#delete_control_pointsObject

Removes all control point references from this instance.



234
235
236
# File 'lib/rtp-connect/field.rb', line 234

def delete_control_points
  delete_children(:control_points)
end

#delete_extended_fieldObject

Removes the extended field reference from this instance.



240
241
242
# File 'lib/rtp-connect/field.rb', line 240

def delete_extended_field
  delete_child(:extended_field)
end

#hashFixnum

Note:

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

Computes a hash code for this object.

Returns:

  • (Fixnum)

    the object’s hash code



250
251
252
# File 'lib/rtp-connect/field.rb', line 250

def hash
  state.hash
end

#to_fieldField

Returns self.

Returns:



258
259
260
# File 'lib/rtp-connect/field.rb', line 258

def to_field
  self
end