gematdd-dibad 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +14 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +115 -0
- data/Guardfile +82 -0
- data/README.md +41 -0
- data/Rakefile +11 -0
- data/bin/bundle +105 -0
- data/bin/console +14 -0
- data/bin/htmldiff +29 -0
- data/bin/ldiff +29 -0
- data/bin/rspec +29 -0
- data/bin/setup +8 -0
- data/doc/DatosAntropometricos.html +782 -0
- data/doc/Etiqueta.html +1339 -0
- data/doc/Factor.html +262 -0
- data/doc/FactorActFisica.html +136 -0
- data/doc/FichaValoracionNutricional.html +857 -0
- data/doc/Gematdd.html +133 -0
- data/doc/Gematdd/Error.html +124 -0
- data/doc/Grasas.html +578 -0
- data/doc/Hidratos.html +576 -0
- data/doc/Individuo.html +845 -0
- data/doc/Lista.html +1281 -0
- data/doc/Node.html +409 -0
- data/doc/Paciente.html +379 -0
- data/doc/PacienteConDatos.html +988 -0
- data/doc/PacienteConObesidad.html +342 -0
- data/doc/PacienteSinObesidad.html +342 -0
- data/doc/_index.html +251 -0
- data/doc/class_list.html +51 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +58 -0
- data/doc/css/style.css +496 -0
- data/doc/file.README.html +118 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +17 -0
- data/doc/index.html +118 -0
- data/doc/js/app.js +292 -0
- data/doc/js/full_list.js +216 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +787 -0
- data/doc/top-level-namespace.html +112 -0
- data/examples/ejemplo.rb +32 -0
- data/gematdd.gemspec +35 -0
- data/lib/gematdd.rb +6 -0
- data/lib/gematdd/etiqueta/etiqueta.rb +100 -0
- data/lib/gematdd/etiqueta/factor.rb +32 -0
- data/lib/gematdd/etiqueta/grasas.rb +24 -0
- data/lib/gematdd/etiqueta/hidratos.rb +23 -0
- data/lib/gematdd/lista/lista.rb +170 -0
- data/lib/gematdd/menu/menu.rb +89 -0
- data/lib/gematdd/menu/menu.rb~ +95 -0
- data/lib/gematdd/paciente/individuo.rb +37 -0
- data/lib/gematdd/paciente/paciente.rb +16 -0
- data/lib/gematdd/paciente/paciente_con_obesidad.rb +21 -0
- data/lib/gematdd/paciente/paciente_datos.rb +69 -0
- data/lib/gematdd/paciente/paciente_sin_obesidad.rb +22 -0
- data/lib/gematdd/valoracion/datos_antropometricos.rb +37 -0
- data/lib/gematdd/valoracion/ficha_valoracion.rb +70 -0
- data/lib/gematdd/version.rb +3 -0
- metadata +235 -0
| @@ -0,0 +1,89 @@ | |
| 1 | 
            +
            require 'etiqueta/etiqueta'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class Menu
         | 
| 4 | 
            +
              attr_accessor :dia, :titl, :ingesta_min, :ingesta_max, :al_desayuno, :al_almuerzo, :al_cena
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              def initialize(dia, &block)
         | 
| 7 | 
            +
                @dia = dia
         | 
| 8 | 
            +
                @titl = ''
         | 
| 9 | 
            +
                @ingesta_min = 0
         | 
| 10 | 
            +
                @ingesta_max = 0
         | 
| 11 | 
            +
                @al_desayuno = []
         | 
| 12 | 
            +
                @al_almuerzo = []
         | 
| 13 | 
            +
                @al_cena = []
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                if block_given?
         | 
| 16 | 
            +
                  if block.arity == 1
         | 
| 17 | 
            +
                    yield self
         | 
| 18 | 
            +
                  else
         | 
| 19 | 
            +
                    instance_eval(&block)
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              def to_s
         | 
| 25 | 
            +
                output = @dia
         | 
| 26 | 
            +
                output << "\t\tTitulo: #{@titl}\n"
         | 
| 27 | 
            +
                output << "Ingesta min: #{@ingesta_min} - Ingesta max: #{@ingesta_max}\n"
         | 
| 28 | 
            +
                output << "==================================================================\n"
         | 
| 29 | 
            +
                output << "".ljust(25) << "grasas".ljust(15) << "carbohid.".ljust(15) <<
         | 
| 30 | 
            +
                "proteínas".ljust(15) << "fibra".ljust(15) << "sal".ljust(15) << "valor energético\n"
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                { 'Desayuno' => @al_desayuno,
         | 
| 33 | 
            +
                  'Almuerzo' => @al_almuerzo,
         | 
| 34 | 
            +
                  'Cena' => @al_cena }.each do |nombre, comida|
         | 
| 35 | 
            +
                  output << "-- #{nombre} --\n"
         | 
| 36 | 
            +
                  comida.each do |x|
         | 
| 37 | 
            +
                    output << x.nombre.ljust(25) << x.grasas.to_s.ljust(15) << x.hidratos.to_s.ljust(15) <<
         | 
| 38 | 
            +
                    x.proteinas.to_s.ljust(15) << x.fibra_alimentaria.to_s.ljust(15) << x.sal.to_s.ljust(15) << x.valor_nutr_kcal.to_s << "\n"
         | 
| 39 | 
            +
                  end
         | 
| 40 | 
            +
                  output << "\n"
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                output << "Valor energetico total\t"
         | 
| 44 | 
            +
                output << (@al_desayuno + @al_almuerzo + @al_cena).collect(&:valor_nutr_kcal).reduce(:+).to_s
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                output
         | 
| 47 | 
            +
              end
         | 
| 48 | 
            +
             | 
| 49 | 
            +
              def titulo(titl)
         | 
| 50 | 
            +
                @titl = titl
         | 
| 51 | 
            +
              end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
              def ingesta(options = {})
         | 
| 54 | 
            +
                @ingesta_min = options[:min] if options[:min]
         | 
| 55 | 
            +
                @ingesta_max = options[:max] if options[:max]
         | 
| 56 | 
            +
              end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
              def desayuno(options = {})
         | 
| 59 | 
            +
                @al_desayuno << process_etiqueta(options)
         | 
| 60 | 
            +
              end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
              def almuerzo(options = {})
         | 
| 63 | 
            +
                @al_almuerzo << process_etiqueta(options)
         | 
| 64 | 
            +
              end
         | 
| 65 | 
            +
             | 
| 66 | 
            +
              def cena(options = {})
         | 
| 67 | 
            +
                @al_cena << process_etiqueta(options)
         | 
| 68 | 
            +
              end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
              private
         | 
| 71 | 
            +
             | 
| 72 | 
            +
              def process_etiqueta(options = {})
         | 
| 73 | 
            +
                alimento = Etiqueta.new(
         | 
| 74 | 
            +
                  options[:descripcion],
         | 
| 75 | 
            +
                  options[:gramos],
         | 
| 76 | 
            +
                  Grasas.new(options[:grasas],
         | 
| 77 | 
            +
                             options[:grasas]),
         | 
| 78 | 
            +
                  Hidratos.new(options[:carbohidratos],
         | 
| 79 | 
            +
                               options[:carbohidratos]),
         | 
| 80 | 
            +
                  options[:proteinas],
         | 
| 81 | 
            +
                  options[:sal],
         | 
| 82 | 
            +
                  options[:fibra],
         | 
| 83 | 
            +
                  nil,
         | 
| 84 | 
            +
                  options[:porcion]
         | 
| 85 | 
            +
                )
         | 
| 86 | 
            +
             | 
| 87 | 
            +
                alimento
         | 
| 88 | 
            +
              end
         | 
| 89 | 
            +
            end
         | 
| @@ -0,0 +1,95 @@ | |
| 1 | 
            +
            require 'etiqueta/etiqueta'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class Menu
         | 
| 4 | 
            +
              attr_accessor :dia, :titl, :ingesta_min, :ingesta_max, :desayunos, :almuerzos, :cenas
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              def initialize(dia, &block)
         | 
| 7 | 
            +
                @dia = dia
         | 
| 8 | 
            +
                @titl = ''
         | 
| 9 | 
            +
                @ingesta_min = 0
         | 
| 10 | 
            +
                @ingesta_max = 0
         | 
| 11 | 
            +
                @desayunos = []
         | 
| 12 | 
            +
                @almuerzos = []
         | 
| 13 | 
            +
                @cenas = []
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                if block_given?
         | 
| 16 | 
            +
                  if block.arity == 1
         | 
| 17 | 
            +
                    yield self
         | 
| 18 | 
            +
                  else
         | 
| 19 | 
            +
                    instance_eval(&block)
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              def to_s
         | 
| 25 | 
            +
                output = @dia
         | 
| 26 | 
            +
                output << "\t\tTitulo: #@titl\n"
         | 
| 27 | 
            +
                output << "Ingesta min: #@ingesta_min - Ingesta max: #@ingesta_max\n"
         | 
| 28 | 
            +
                output << "==================================================================\n"
         | 
| 29 | 
            +
                output << "\t\t\tgrasas\tcarbohidratos\tproteínas\tfibra\tsal\tvalor energético"
         | 
| 30 | 
            +
                output << "Desayuno\n"
         | 
| 31 | 
            +
                desayunos.each do |x|
         | 
| 32 | 
            +
                  output << "#{x.nombre}\t#{x.grasas}\t#{x.hidratos}\t\t#{x.proteinas}\t\t#{x.fibra_alimentaria}\t#{x.sal}\t#{x.valor_nutr_kj}\n"
         | 
| 33 | 
            +
                end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                output
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
              def titulo(titl)
         | 
| 39 | 
            +
                @titl = titl
         | 
| 40 | 
            +
              end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
              def ingesta(options = {})
         | 
| 43 | 
            +
                @ingesta_min = options[:min] if options[:min]
         | 
| 44 | 
            +
                @ingesta_max = options[:max] if options[:max]
         | 
| 45 | 
            +
              end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
              def desayuno(options = {})
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                @desayunos << desay
         | 
| 50 | 
            +
             | 
| 51 | 
            +
              end
         | 
| 52 | 
            +
              private
         | 
| 53 | 
            +
              def process(options = {})
         | 
| 54 | 
            +
                alimento = Etiqueta.new(
         | 
| 55 | 
            +
                  options[:descripcion],
         | 
| 56 | 
            +
                  options[:gramos],
         | 
| 57 | 
            +
                  Grasas.new(options[:grasas],
         | 
| 58 | 
            +
                             options[:grasas]
         | 
| 59 | 
            +
                  ),
         | 
| 60 | 
            +
                  Hidratos.new(options[:carbohidratos],
         | 
| 61 | 
            +
                               options[:carbohidratos]
         | 
| 62 | 
            +
                  ),
         | 
| 63 | 
            +
                  options[:proteinas],
         | 
| 64 | 
            +
                  options[:sal],
         | 
| 65 | 
            +
                  options[:fibra],
         | 
| 66 | 
            +
                  nil,
         | 
| 67 | 
            +
                  options[:porcion])
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                alimento
         | 
| 70 | 
            +
              end
         | 
| 71 | 
            +
            end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
            @menu = Menu.new('Lunes') do
         | 
| 74 | 
            +
              titulo    'Bajo en calorías'
         | 
| 75 | 
            +
              ingesta   :min => 30, :max => 35
         | 
| 76 | 
            +
              desayuno  :descripcion => 'Pan de trigo integral',
         | 
| 77 | 
            +
                        :porcion => 1,
         | 
| 78 | 
            +
                        :gramos => '100g',
         | 
| 79 | 
            +
                        :grasas => '3.3g',
         | 
| 80 | 
            +
                        :carbohidratos => '54g',
         | 
| 81 | 
            +
                        :proteinas => '11g',
         | 
| 82 | 
            +
                        :fibra => '2.3g',
         | 
| 83 | 
            +
                        :sal => '0.06g'
         | 
| 84 | 
            +
              desayuno  :descripcion => "Actimel",
         | 
| 85 | 
            +
                        :porcion => 1,
         | 
| 86 | 
            +
                        :gramos => '100g',
         | 
| 87 | 
            +
                        :grasas => '3.4g',
         | 
| 88 | 
            +
                        :carbohidratos => '4.4g',
         | 
| 89 | 
            +
                        :proteinas => '3.6g',
         | 
| 90 | 
            +
                        :fibra => '0g',
         | 
| 91 | 
            +
                        :sal => '0.05g'
         | 
| 92 | 
            +
             | 
| 93 | 
            +
            end
         | 
| 94 | 
            +
             | 
| 95 | 
            +
            puts @menu.to_s
         | 
| @@ -0,0 +1,37 @@ | |
| 1 | 
            +
            require 'date'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # Clase que representa a un Individuo (Sin ser o no paciente)
         | 
| 4 | 
            +
            class Individuo
         | 
| 5 | 
            +
              include Comparable
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              attr_accessor :nombre, :apellidos, :sexo, :fecha_nac, :edad, :ocupacion
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              def initialize(nombre, apellidos, sexo, fecha_nac, ocupacion)
         | 
| 10 | 
            +
                @nombre = nombre
         | 
| 11 | 
            +
                @apellidos = apellidos
         | 
| 12 | 
            +
                @sexo = sexo
         | 
| 13 | 
            +
                @fecha_nac = Date.parse(fecha_nac)
         | 
| 14 | 
            +
                @edad = edad
         | 
| 15 | 
            +
                @ocupacion = ocupacion
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              # Convierte el atributo de sexo (0 o 1) a un valor legible
         | 
| 19 | 
            +
              def genero
         | 
| 20 | 
            +
                @sexo == 1 ? 'Hombre' : 'Mujer'
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              # Calcula la edad a partir de la fecha de nacimiento
         | 
| 24 | 
            +
              def edad
         | 
| 25 | 
            +
                @edad = Date.today.year - @fecha_nac.year
         | 
| 26 | 
            +
                @edad -= 1 if Date.today.month <= @fecha_nac.month &&
         | 
| 27 | 
            +
                              Date.today.day < @fecha_nac.day
         | 
| 28 | 
            +
                @edad
         | 
| 29 | 
            +
              end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
              def to_s
         | 
| 32 | 
            +
            " - Datos de #{@nombre} #{@apellidos}
         | 
| 33 | 
            +
                Sexo: #{genero}
         | 
| 34 | 
            +
                Fecha de nacimiento: #{@fecha_nac}
         | 
| 35 | 
            +
                Ocupación: #{@ocupacion}"
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
            end
         | 
| @@ -0,0 +1,16 @@ | |
| 1 | 
            +
            require 'paciente/individuo'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # Representa a un individuo asociado a una consulta específica
         | 
| 4 | 
            +
            class Paciente < Individuo
         | 
| 5 | 
            +
              attr_accessor :consulta
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              def initialize(nombre, apellidos, sexo, fecha_nac, ocupacion, consulta)
         | 
| 8 | 
            +
                super(nombre, apellidos, sexo, fecha_nac, ocupacion)
         | 
| 9 | 
            +
                @consulta = consulta
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              def to_s
         | 
| 13 | 
            +
                " || Paciente perteneciente a la consulta #{@consulta} ||\n
         | 
| 14 | 
            +
            #{super}"
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
            end
         | 
| @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            require 'paciente/paciente_datos'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # Representa un paciente cuyos datos antropométricos indican que tiene obesidad
         | 
| 4 | 
            +
            class PacienteConObesidad < PacienteConDatos
         | 
| 5 | 
            +
              def initialize(nombre, apellidos, sexo, fecha_nac, ocupacion, consulta,
         | 
| 6 | 
            +
                             datos_antropometricos)
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                super(nombre, apellidos, sexo, fecha_nac, ocupacion, consulta,
         | 
| 9 | 
            +
                      datos_antropometricos)
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                if imc < 30.0
         | 
| 12 | 
            +
                  raise TypeError, "El Paciente no tiene obesidad (IMC:
         | 
| 13 | 
            +
                  #{imc} < 30.0)"
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              def to_s
         | 
| 18 | 
            +
                "#{super}\n
         | 
| 19 | 
            +
            Según el IMC, este paciente tiene Obesidad."
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
            end
         | 
| @@ -0,0 +1,69 @@ | |
| 1 | 
            +
            require 'ruby-units'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'paciente/paciente'
         | 
| 4 | 
            +
            require 'valoracion/datos_antropometricos'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            # Representa un paciente cuyos datos han sido registrados
         | 
| 7 | 
            +
            class PacienteConDatos < Paciente
         | 
| 8 | 
            +
              include Comparable
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              attr_accessor :datos
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              def initialize(nombre, apellidos, sexo, fecha_nac, ocupacion, consulta,
         | 
| 13 | 
            +
                             datos)
         | 
| 14 | 
            +
                super(nombre, apellidos, sexo, fecha_nac, ocupacion, consulta)
         | 
| 15 | 
            +
                @datos = datos
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              # Cálculo del Indice de Masa Corporal
         | 
| 19 | 
            +
              def imc
         | 
| 20 | 
            +
                @datos.peso / (@datos.talla * @datos.talla)
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              # Cálculo del porcentaje de grasa
         | 
| 24 | 
            +
              def porcentaje_grasa
         | 
| 25 | 
            +
                (1.2 * imc + 0.23 * @edad - 10.8 * @sexo - 5.4).round(2)
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              # Cálculo de la Relación Cadera-Cintura
         | 
| 29 | 
            +
              def rcc
         | 
| 30 | 
            +
                (@datos.ccintura.to_f / @datos.ccadera).round(2)
         | 
| 31 | 
            +
              end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
              # Cálculo del peso teórico ideal
         | 
| 34 | 
            +
              def peso_teorico_ideal
         | 
| 35 | 
            +
                (@datos.talla * 100 - 150) * 0.75 + 50
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
              # Cálculo del gasto energético basal (teniendo en cuenta el sexo)
         | 
| 39 | 
            +
              def gasto_energetico_basal
         | 
| 40 | 
            +
                (10 * @datos.peso) + (6.25 * @datos.talla) - (5 * @edad) + (@sexo ?
         | 
| 41 | 
            +
                                                                            5 : -161)
         | 
| 42 | 
            +
              end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
              # Cálculo del efecto termógeno
         | 
| 45 | 
            +
              def efecto_termogeno
         | 
| 46 | 
            +
                gasto_energetico_basal * 0.10
         | 
| 47 | 
            +
              end
         | 
| 48 | 
            +
             | 
| 49 | 
            +
              # Cálculo del gasto por el factor de actividad fisica
         | 
| 50 | 
            +
              def gasto_actividad_fisica
         | 
| 51 | 
            +
                gasto_energetico_basal * @datos.actividad_fisica
         | 
| 52 | 
            +
              end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
              # Cálculo del gasto energético total (en kcal)
         | 
| 55 | 
            +
              def gasto_energetico_total
         | 
| 56 | 
            +
                Unit.new("#{gasto_energetico_basal + efecto_termogeno +
         | 
| 57 | 
            +
                 gasto_actividad_fisica} kcal")
         | 
| 58 | 
            +
              end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
              def <=>(other)
         | 
| 61 | 
            +
                [gasto_energetico_total, datos] <=> [other.gasto_energetico_total, other.datos]
         | 
| 62 | 
            +
              end
         | 
| 63 | 
            +
             | 
| 64 | 
            +
              def to_s
         | 
| 65 | 
            +
            "#{super}\n
         | 
| 66 | 
            +
             - Datos antropométricos:
         | 
| 67 | 
            +
            #{@datos}"
         | 
| 68 | 
            +
              end
         | 
| 69 | 
            +
            end
         | 
| @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            require 'paciente/paciente_datos'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # Representa un paciente cuyos datos antropométricos indican que no tiene
         | 
| 4 | 
            +
            # obesidad
         | 
| 5 | 
            +
            class PacienteSinObesidad < PacienteConDatos
         | 
| 6 | 
            +
              def initialize(nombre, apellidos, sexo, fecha_nac, ocupacion, consulta,
         | 
| 7 | 
            +
                             datos_antropometricos)
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                super(nombre, apellidos, sexo, fecha_nac, ocupacion, consulta,
         | 
| 10 | 
            +
                      datos_antropometricos)
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                if imc >= 30.0
         | 
| 13 | 
            +
                  raise TypeError, "El Paciente tiene obesidad (IMC:
         | 
| 14 | 
            +
                  #{imc} >= 30.0)"
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              def to_s
         | 
| 19 | 
            +
                "#{super}\n
         | 
| 20 | 
            +
            Según el IMC, este paciente NO tiene Obesidad."
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
            end
         | 
| @@ -0,0 +1,37 @@ | |
| 1 | 
            +
            require 'date'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module FactorActFisica
         | 
| 4 | 
            +
              REPOSO = 0.0
         | 
| 5 | 
            +
              ACT_LIGERA = 0.12
         | 
| 6 | 
            +
              ACT_MODERADA = 0.27
         | 
| 7 | 
            +
              ACT_INTENSA = 0.54
         | 
| 8 | 
            +
            end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            # Agrupa todos los datos antropométricos medibles a una persona
         | 
| 11 | 
            +
            class DatosAntropometricos
         | 
| 12 | 
            +
              include Comparable
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              attr_accessor :peso, :talla, :ccintura, :ccadera, :actividad_fisica
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              def initialize(peso, talla, ccintura, ccadera, actividad_fisica)
         | 
| 17 | 
            +
                @peso = peso
         | 
| 18 | 
            +
                @talla = talla
         | 
| 19 | 
            +
                @ccintura = ccintura
         | 
| 20 | 
            +
                @ccadera = ccadera
         | 
| 21 | 
            +
                @actividad_fisica = actividad_fisica
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              def <=>(other)
         | 
| 25 | 
            +
                [peso, talla, ccintura, ccadera, actividad_fisica] <=>
         | 
| 26 | 
            +
                [other.peso, other.talla, other.ccintura, other.ccadera,
         | 
| 27 | 
            +
                 other.actividad_fisica]
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              def to_s
         | 
| 31 | 
            +
            "Peso: #{@peso}
         | 
| 32 | 
            +
            Talla: #{@talla}
         | 
| 33 | 
            +
            Circunferencias:
         | 
| 34 | 
            +
              - Cintura: #{@ccintura}
         | 
| 35 | 
            +
              - Cadera: #{@ccadera}"
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
            end
         | 
| @@ -0,0 +1,70 @@ | |
| 1 | 
            +
            require 'paciente/paciente.rb'
         | 
| 2 | 
            +
            require 'valoracion/datos_antropometricos.rb'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            # Clase que asocia un Individuo y unos Datos Antropométricos con un historial
         | 
| 5 | 
            +
            # regististrado por la Clínica
         | 
| 6 | 
            +
            class FichaValoracionNutricional
         | 
| 7 | 
            +
              include Comparable
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              attr_accessor :paciente, :fecha, :n_historia
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              def initialize(fecha, n_historia, pacienteConDatos)
         | 
| 12 | 
            +
                @fecha = fecha
         | 
| 13 | 
            +
                @n_historia = n_historia
         | 
| 14 | 
            +
                @paciente = pacienteConDatos
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              # Devuelve (de manera legible) el resultado del IMC
         | 
| 18 | 
            +
              def significado_imc
         | 
| 19 | 
            +
                imc = @paciente.imc.round(1)
         | 
| 20 | 
            +
                if imc < 18.5
         | 
| 21 | 
            +
                  "Clasificación OMS: Bajo peso\t\t Descripción popular: Delgado"
         | 
| 22 | 
            +
                elsif imc.between?(18.5, 24.9)
         | 
| 23 | 
            +
                  "Clasificación OMS: Adecuado\t\t Descripción popular: Aceptable"
         | 
| 24 | 
            +
                elsif imc.between?(25.0, 29.9)
         | 
| 25 | 
            +
                  "Clasificación OMS: Sobrepeso\t\t Descripción popular: Sobrepeso"
         | 
| 26 | 
            +
                elsif imc.between?(30.0, 34.9)
         | 
| 27 | 
            +
                  "Clasificación OMS: Obesidad grado 1\t\t Descripción popular: Obesidad"
         | 
| 28 | 
            +
                elsif imc.between?(35.0, 39.9)
         | 
| 29 | 
            +
                  "Clasificación OMS: Obesidad grado 2\t\t Descripción popular: Obesidad"
         | 
| 30 | 
            +
                else
         | 
| 31 | 
            +
                  "Clasificación OMS: Obesidad grado 3\t\t Descripción popular: Obesidad"
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              # Devuelve (de manera legible) el resultado del RCC
         | 
| 36 | 
            +
              def significado_rcc
         | 
| 37 | 
            +
                rcc = @paciente.rcc.round(2)
         | 
| 38 | 
            +
                if @paciente.sexo == 1
         | 
| 39 | 
            +
                  if rcc.between?(0.83, 0.88)
         | 
| 40 | 
            +
                    'Riesgo: Bajo'
         | 
| 41 | 
            +
                  elsif rcc.between?(0.88, 0.95)
         | 
| 42 | 
            +
                    'Riesgo: Moderado'
         | 
| 43 | 
            +
                  elsif rcc.between?(0.95, 1.01)
         | 
| 44 | 
            +
                    'Riesgo: Alto'
         | 
| 45 | 
            +
                  elsif rcc > 1.01
         | 
| 46 | 
            +
                    'Riesgo: Muy Alto'
         | 
| 47 | 
            +
                  end
         | 
| 48 | 
            +
                else
         | 
| 49 | 
            +
                  if rcc.between?(0.72, 0.75)
         | 
| 50 | 
            +
                    'Riesgo: Bajo'
         | 
| 51 | 
            +
                  elsif rcc.between?(0.78, 0.82)
         | 
| 52 | 
            +
                    'Riesgo: Moderado'
         | 
| 53 | 
            +
                  elsif rcc > 0.82
         | 
| 54 | 
            +
                    'Riesgo: Alto'
         | 
| 55 | 
            +
                  end
         | 
| 56 | 
            +
                end
         | 
| 57 | 
            +
              end
         | 
| 58 | 
            +
             | 
| 59 | 
            +
              def <=>(other)
         | 
| 60 | 
            +
                [n_historia, fecha, paciente] <=>
         | 
| 61 | 
            +
                  [other.n_historia, other.fecha, other.paciente]
         | 
| 62 | 
            +
              end
         | 
| 63 | 
            +
             | 
| 64 | 
            +
              def to_s
         | 
| 65 | 
            +
            "--- Ficha de Valoración Nutricional ---
         | 
| 66 | 
            +
              Fecha #{@fecha}
         | 
| 67 | 
            +
              Nº Historia #{@n_historia}
         | 
| 68 | 
            +
              #{paciente.to_s}"
         | 
| 69 | 
            +
              end
         | 
| 70 | 
            +
            end
         |