Class: Pueri::DoseCheck
- Inherits:
-
Object
- Object
- Pueri::DoseCheck
- Defined in:
- lib/pueri/dosecheck.rb
Overview
Checks the prescription of a given medication given the weight of the pacient, the dose-per-take, the concentration of the medication’s presentation and the periodicity of takes in hours.
Instance Attribute Summary collapse
-
#conc_unit ⇒ Object
Returns the value of attribute conc_unit.
-
#concentration ⇒ Object
readonly
Returns the value of attribute concentration.
-
#dose ⇒ Object
readonly
Returns the value of attribute dose.
-
#dose_unit ⇒ Object
Returns the value of attribute dose_unit.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#way ⇒ Object
Returns the value of attribute way.
-
#weight ⇒ Object
readonly
Returns the value of attribute weight.
Instance Method Summary collapse
-
#initialize(params) ⇒ DoseCheck
constructor
Calculate the dosage-per-weight-day for the prescribed medicine.
-
#to_f ⇒ Float
Outputs the calculated dosage-per-weight-day as a float.
-
#to_s(pretty = false) ⇒ String
Outputs the calculated dosage as a string.
Constructor Details
#initialize(params) ⇒ DoseCheck
Calculate the dosage-per-weight-day for the prescribed medicine.
23 24 25 26 |
# File 'lib/pueri/dosecheck.rb', line 23 def initialize(params) init_vars(params) @result = ((@dose * @concentration * 24.0) / (@time * @weight)).round(3) end |
Instance Attribute Details
#conc_unit ⇒ Object
Returns the value of attribute conc_unit.
9 10 11 |
# File 'lib/pueri/dosecheck.rb', line 9 def conc_unit @conc_unit end |
#concentration ⇒ Object (readonly)
Returns the value of attribute concentration.
8 9 10 |
# File 'lib/pueri/dosecheck.rb', line 8 def concentration @concentration end |
#dose ⇒ Object (readonly)
Returns the value of attribute dose.
8 9 10 |
# File 'lib/pueri/dosecheck.rb', line 8 def dose @dose end |
#dose_unit ⇒ Object
Returns the value of attribute dose_unit.
9 10 11 |
# File 'lib/pueri/dosecheck.rb', line 9 def dose_unit @dose_unit end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/pueri/dosecheck.rb', line 8 def name @name end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
8 9 10 |
# File 'lib/pueri/dosecheck.rb', line 8 def result @result end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
8 9 10 |
# File 'lib/pueri/dosecheck.rb', line 8 def time @time end |
#way ⇒ Object
Returns the value of attribute way.
9 10 11 |
# File 'lib/pueri/dosecheck.rb', line 9 def way @way end |
#weight ⇒ Object (readonly)
Returns the value of attribute weight.
8 9 10 |
# File 'lib/pueri/dosecheck.rb', line 8 def weight @weight end |
Instance Method Details
#to_f ⇒ Float
Outputs the calculated dosage-per-weight-day as a float.
47 48 49 |
# File 'lib/pueri/dosecheck.rb', line 47 def to_f @result end |
#to_s(pretty = false) ⇒ String
Outputs the calculated dosage as a string.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/pueri/dosecheck.rb', line 32 def to_s(pretty = false) if pretty pretty_to_s else [ '', "#{@name} #{@concentration.to_i}#{@conc_unit.join '/'} (#{usage})", " - Dose de #{@result}#{@conc_unit[0]}/kg/d." ].join "\n" end end |