Class: Quby::Answers::Entities::Patient
- Inherits:
-
Object
- Object
- Quby::Answers::Entities::Patient
- Defined in:
- lib/quby/answers/entities/patient.rb
Instance Attribute Summary collapse
-
#birthyear ⇒ Object
Returns the value of attribute birthyear.
-
#gender ⇒ Object
Returns the value of attribute gender.
Instance Method Summary collapse
-
#age_at(timestamp) ⇒ Object
returns the age at the given timestamp, as an integer NB: if you make this a float, this breaks various questionnaire score calculations that do the following: ‘if (8..12).cover?(age) …
-
#initialize(attributes = {}) ⇒ Patient
constructor
A new instance of Patient.
Constructor Details
#initialize(attributes = {}) ⇒ Patient
Returns a new instance of Patient.
11 12 13 14 15 |
# File 'lib/quby/answers/entities/patient.rb', line 11 def initialize(attributes = {}) attributes = attributes.with_indifferent_access @gender = attributes[:gender] || :unknown @birthyear = attributes[:birthyear] end |
Instance Attribute Details
#birthyear ⇒ Object
Returns the value of attribute birthyear.
9 10 11 |
# File 'lib/quby/answers/entities/patient.rb', line 9 def birthyear @birthyear end |
#gender ⇒ Object
Returns the value of attribute gender.
9 10 11 |
# File 'lib/quby/answers/entities/patient.rb', line 9 def gender @gender end |
Instance Method Details
#age_at(timestamp) ⇒ Object
returns the age at the given timestamp, as an integer NB: if you make this a float, this breaks various questionnaire score calculations that do the following: ‘if (8..12).cover?(age) … elsif (13..15).cover?(age)` etc.
20 21 22 23 |
# File 'lib/quby/answers/entities/patient.rb', line 20 def age_at() return nil unless @birthyear and (( - Time.gm(@birthyear, 1, 1)) / 1.year).floor end |