Class: FichaValoracionNutricional

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/gematdd/valoracion/ficha_valoracion.rb

Overview

Clase que asocia un Individuo y unos Datos Antropométricos con un historial regististrado por la Clínica

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fecha, n_historia, individuo, datos_antropometricos) ⇒ FichaValoracionNutricional

Returns a new instance of FichaValoracionNutricional



11
12
13
14
15
16
# File 'lib/gematdd/valoracion/ficha_valoracion.rb', line 11

def initialize(fecha, n_historia, individuo, datos_antropometricos)
  @fecha = fecha
  @n_historia = n_historia
  @individuo = individuo
  @datos = datos_antropometricos
end

Instance Attribute Details

#datosObject

Returns the value of attribute datos



9
10
11
# File 'lib/gematdd/valoracion/ficha_valoracion.rb', line 9

def datos
  @datos
end

#fechaObject

Returns the value of attribute fecha



9
10
11
# File 'lib/gematdd/valoracion/ficha_valoracion.rb', line 9

def fecha
  @fecha
end

#individuoObject

Returns the value of attribute individuo



9
10
11
# File 'lib/gematdd/valoracion/ficha_valoracion.rb', line 9

def individuo
  @individuo
end

#n_historiaObject

Returns the value of attribute n_historia



9
10
11
# File 'lib/gematdd/valoracion/ficha_valoracion.rb', line 9

def n_historia
  @n_historia
end

Instance Method Details

#<=>(other) ⇒ Object



60
61
62
63
# File 'lib/gematdd/valoracion/ficha_valoracion.rb', line 60

def <=>(other)
  [n_historia, fecha, individuo, datos] <=>
    [other.n_historia, other.fecha, other.individuo, other.datos]
end

#significado_imcObject

Devuelve (de manera legible) el resultado del IMC



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/gematdd/valoracion/ficha_valoracion.rb', line 19

def significado_imc
  imc = @datos.imc.round(1)
  if imc < 18.5
    "Clasificación OMS: Bajo peso\t\t Descripción popular: Delgado"
  elsif imc.between?(18.5, 24.9)
    "Clasificación OMS: Adecuado\t\t Descripción popular: Aceptable"
  elsif imc.between?(25.0, 29.9)
    "Clasificación OMS: Sobrepeso\t\t Descripción popular: Sobrepeso"
  elsif imc.between?(30.0, 34.9)
    "Clasificación OMS: Obesdad grado 1\t\t Descripción popular: Obesidad"
  elsif imc.between?(35.0, 39.9)
    "Clasificación OMS: Obesidad grado 2\t\t Descripción popular: Obesidad"
  else
    "Clasificación OMS: Obesisdad grado 2\t\t Descripción popular: Obesidad"
  end
end

#significado_rccObject

Devuelve (de manera legible) el resultado del RCC



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/gematdd/valoracion/ficha_valoracion.rb', line 37

def significado_rcc
  rcc = @datos.rcc.round(2)
  if @individuo.sexo == 1
    if rcc.between?(0.83, 0.88)
      'Riesgo: Bajo'
    elsif rcc.between?(0.88, 0.95)
      'Riesgo: Moderado'
    elsif rcc.between?(0.95, 1.01)
      'Riesgo: Alto'
    elsif rcc > 1.01
      'Riesgo: Muy Alto'
    end
  else
    if rcc.between?(0.72, 0.75)
      'Riesgo: Bajo'
    elsif rcc.between?(0.78, 0.82)
      'Riesgo: Moderado'
    elsif rcc > 0.82
      'Riesgo: Alto'
    end
  end
end

#to_sObject



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/gematdd/valoracion/ficha_valoracion.rb', line 65

def to_s
  puts "--- Ficha de Valoración Nutricional ---\n"
  puts " Fecha #{@fecha}"
  puts " Nº Historia #{@n_historia}"
  puts " Nombre: #{@individuo.nombre}\n Apellidos: #{@individuo.apellidos}"
  puts " Edad: #{@individuo.edad} años\t\tGénero: #{@individuo.genero} \t\tFecha de nacimiento: #{@individuo.fecha_nac}"
  puts " Ocupación: #{@individuo.ocupacion}"

  puts "\n-- Datos antropométricos --"
  puts " Peso: #{@datos.peso} kg\tTalla(cm): #{@datos.talla * 100}"
  puts " IMC(kg/m^2): #{@datos.imc.round(2)}"
  puts " #{significado_imc}"
  puts " Porcentaje de grasa: #{@datos.porcentaje_grasa(@individuo.edad, @individuo.sexo).round(2)}"

  puts "\n- Circunferencias (cm)"
  puts " Hora a la que se han tomado las medidas: #{@datos.hora.strftime('%H:%M')}"
  puts " Cintura: #{@datos.ccintura} cm\t\tCadera: #{@datos.ccadera} cm"
  puts " Relacion cintura/cadera: #{@datos.rcc.round(2)}"
  puts " #{significado_rcc}"
end