Created
September 2, 2013 20:14
-
-
Save ricardokrieg/6416872 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Model Record (Protuário) | |
class Record < ActiveRecord::Base | |
belongs_to :patient | |
has_many :appointments | |
attr_accessible :data, :patient_id | |
end | |
# Model Appointment (Cosulta) | |
class Appointment < ActiveRecord::Base | |
belongs_to :record | |
has_many :asos, :dependent => :destroy #Atestado de Saúde Ocupacional | |
has_many :complementary_exams, :dependent => :destroy #Exames Complementares, pode existir ou não em uma Consulta | |
has_many :declarations, :dependent => :destroy #Declaração de comparecimento/permanência no consultório médico | |
has_many :attests, :dependent => :destroy #Atestado | |
has_many :requisicao_exames, :dependent => :destroy #Requisição para exames laboratoriais e de imagem | |
accepts_nested_attributes_for :complementary_exams, reject_if: :all_blank, :allow_destroy => true | |
attr_accessible :record_id, :altura, :anamnese, :categoria_exame, | |
:conclusao, :data, :imc, :ordem_exame, :pa, :peso, | |
:pulso, :status, :complementary_exams_attributes | |
validates_numericality_of :peso, :altura | |
before_create :increment_ordem_exame | |
def increment_ordem_exame | |
self.ordem_exame = (self.class.last.nil?) ? "1" : ((self.class.last.ordem_exame.to_i) + 1).to_s | |
end | |
before_create :imc | |
def imc | |
self.imc = (self.class.nil?) ? 1 : ((peso.to_f) / ((altura.to_f) **2)) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment