Class: PhqAssessment
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- PhqAssessment
- Defined in:
- app/models/phq_assessment.rb
Overview
Collected responses from one Participant PHQ-9 assessment session.
Constant Summary collapse
- MIN_QUESTION_SCORE =
0
- MAX_QUESTION_SCORE =
3
- QUESTION_ATTRIBUTES =
rubocop:disable Style/MutableConstant
:q1, :q2, :q3, :q4, :q5, :q6, :q7, :q8, :q9
- SUICIDAL_SCORE =
rubocop:enable Style/MutableConstant
3
Class Method Summary collapse
Instance Method Summary collapse
- #answered_questions ⇒ Object
- #completed? ⇒ Boolean
- #number_answered ⇒ Object
- #score ⇒ Object
- #suicidal? ⇒ Boolean
Class Method Details
.most_recent ⇒ Object
19 20 21 |
# File 'app/models/phq_assessment.rb', line 19 def self.most_recent recenty_released.first end |
Instance Method Details
#answered_questions ⇒ Object
23 24 25 |
# File 'app/models/phq_assessment.rb', line 23 def answered_questions @answered_questions ||= remove_nils end |
#completed? ⇒ Boolean
27 28 29 |
# File 'app/models/phq_assessment.rb', line 27 def completed? number_answered == QUESTION_ATTRIBUTES.count end |
#number_answered ⇒ Object
31 32 33 |
# File 'app/models/phq_assessment.rb', line 31 def number_answered answered_questions.count end |
#score ⇒ Object
35 36 37 |
# File 'app/models/phq_assessment.rb', line 35 def score answered_questions.inject(:+) end |
#suicidal? ⇒ Boolean
39 40 41 |
# File 'app/models/phq_assessment.rb', line 39 def suicidal? q9 == SUICIDAL_SCORE end |