Class: WellAttribute

Inherits:
ApplicationRecord show all
Includes:
AASM
Defined in:
app/models/well_attribute.rb

Overview

Note:

Try and use QcResult for any future readings, it will automatically update this table for you.

Contains qc information regarding a well, in addition to volume information to assist with Cherrypicking

Instance Method Summary collapse

Methods inherited from ApplicationRecord

alias_association, convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Squishify

extended

Instance Method Details

#broadcast_warehouse_messageObject



80
81
82
83
# File 'app/models/well_attribute.rb', line 80

def broadcast_warehouse_message
  message = Messenger.find_by(target_id: well_id)
  message.resend if message.present?
end

#current_volume=(current_volume) ⇒ Object



75
76
77
78
# File 'app/models/well_attribute.rb', line 75

def current_volume=(current_volume)
  current_volume = 0.0 if current_volume.to_f < 0
  super
end

#estimated_volumeObject



53
54
55
# File 'app/models/well_attribute.rb', line 53

def estimated_volume
  (current_volume || measured_volume).try(:to_f)
end

#gender_markers_stringObject



16
17
18
# File 'app/models/well_attribute.rb', line 16

def gender_markers_string
  gender_markers.try(:to_s)
end

#initial_volume=(volume) ⇒ Object



57
58
59
# File 'app/models/well_attribute.rb', line 57

def initial_volume=(volume)
  super if initial_volume.nil?
end

#measured_volume=(volume) ⇒ Object



47
48
49
50
51
# File 'app/models/well_attribute.rb', line 47

def measured_volume=(volume)
  self.initial_volume = volume
  self.current_volume = volume
  super
end

#pico_passObject

Since Pass and Fail are used as pico_state values we’re forced to use a different transition name.



36
37
38
39
40
41
42
43
44
45
# File 'app/models/well_attribute.rb', line 36

def pico_pass
  case self[:pico_pass]
  when 'Too Low To Normalise'
    'Fail'
  when nil, ''
    'ungraded'
  else
    self[:pico_pass]
  end
end

#quantity_in_micro_gramsObject



68
69
70
71
72
73
# File 'app/models/well_attribute.rb', line 68

def quantity_in_micro_grams
  return nil if estimated_volume.nil? || concentration.nil?
  return 0 if estimated_volume < 0 || concentration < 0

  (estimated_volume * concentration) / 1000
end

#quantity_in_nano_gramsObject



61
62
63
64
65
66
# File 'app/models/well_attribute.rb', line 61

def quantity_in_nano_grams
  return nil if estimated_volume.nil? || concentration.nil?
  return 0 if estimated_volume < 0 || concentration < 0

  (estimated_volume * concentration).to_i
end