Class: QcMetric

Inherits:
ApplicationRecord show all
Extended by:
QcState
Defined in:
app/models/qc_metric.rb

Defined Under Namespace

Modules: QcState

Constant Summary collapse

InvalidValue =
Class.new(StandardError)
QC_DECISION_TRANSITIONS =
{
  'passed' => 'manually_passed',
  'manually_passed' => 'manually_passed',
  'failed' => 'manually_failed',
  'manually_failed' => 'manually_failed'
}
PROCEED_TRANSLATION =
{
  true => 'Y',
  false => 'N'
}

Instance Method Summary collapse

Methods included from QcState

new_state, qc_state_object_called, valid_states

Methods inherited from ApplicationRecord

convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Warren::BroadcastMessages

#broadcast, included, #queue_associated_for_broadcast, #queue_for_broadcast, #warren

Instance Method Details

#human_proceedObject


62
63
64
# File 'app/models/qc_metric.rb', line 62

def human_proceed
  PROCEED_TRANSLATION[proceed]
end

#human_proceed=(h_proceed) ⇒ Object


66
67
68
69
70
# File 'app/models/qc_metric.rb', line 66

def human_proceed=(h_proceed)
  return self.proceed = nil if h_proceed.blank?

  self.proceed = proceedable? && human_to_bool(PROCEED_TRANSLATION, h_proceed.upcase)
end

#manual_qc_decision=(decision) ⇒ Object

Update the new state as appropriate:

  • Don't change the state if we already match

  • If we have an automatic state, update to a manual state

  • If we already have a manual state, perform some magic to ensure eg. pass -> manual_fail -> pass BUT unprocessable -> manual_fail -> manual_pass


54
55
56
57
58
59
60
# File 'app/models/qc_metric.rb', line 54

def manual_qc_decision=(decision)
  return if qc_decision == decision
  return self.qc_decision = decision_to_manual_state(decision) if qc_automatic?
  return self.qc_decision = decision if original_qc_decision == decision

  self.qc_decision = decision_to_manual_state(decision)
end

#original_qc_decisionObject


94
95
96
# File 'app/models/qc_metric.rb', line 94

def original_qc_decision
  qc_report.original_qc_decision(metrics)
end

#poor_quality_proceedObject

The metric indicates that the sample has been progressed despite poor quality || false ensures nil gets converted to a boolean


74
75
76
# File 'app/models/qc_metric.rb', line 74

def poor_quality_proceed
  (qc_failed? && proceed) || false
end

#proceedable?Boolean

Returns:

  • (Boolean)

86
87
88
# File 'app/models/qc_metric.rb', line 86

def proceedable?
  qc_state_object.proceedable
end

#qc_automatic?Boolean

Returns:

  • (Boolean)

90
91
92
# File 'app/models/qc_metric.rb', line 90

def qc_automatic?
  qc_state_object.automatic
end

#qc_failed?Boolean

Returns:

  • (Boolean)

82
83
84
# File 'app/models/qc_metric.rb', line 82

def qc_failed?
  !qc_passed?
end

#qc_passed?Boolean

Returns:

  • (Boolean)

78
79
80
# File 'app/models/qc_metric.rb', line 78

def qc_passed?
  qc_state_object.passed
end