Sha256: 952a39b4b0664b019e3bb5f7ecba286e133f491c5b1a94951fb80cbef347e545

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

class Record
  include Mongoid::Document
  
  field :first, type: String
  field :last, type: String
  field :gender, type: String
  field :birthdate, type: Integer
  field :deathdate, type: Integer
  field :effective_time, type: Integer
  field :race, type: Hash
  field :ethnicity, type: Hash
  field :languages, type: Array
  field :test_id, type: BSON::ObjectId
  field :medical_record_number, type: String

  embeds_many :allergies
  embeds_many :care_goals, class_name: "Entry"
  embeds_many :conditions, class_name: "Entry"
  embeds_many :encounters
  embeds_many :immunizations
  embeds_many :medical_equipment, class_name: "Entry"
  embeds_many :medications
  embeds_many :procedures
  embeds_many :results, class_name: "LabResult"
  embeds_many :social_history, class_name: "Entry"
  embeds_many :vital_signs, class_name: "Entry"

  Sections = [:allergies, :care_goals, :conditions, :encounters, :immunizations, :medical_equipment,
   :medications, :procedures, :results, :social_history, :vital_signs]

  embeds_many :provider_performances
  
  scope :by_provider, ->(prov, effective_date) { (effective_date) ? where(provider_queries(prov.id, effective_date)) : where('provider_performances.provider_id'=>prov.id)  }
  scope :by_patient_id, ->(id) { where(:medical_record_number => id) }
  
  def providers
    provider_performances.map {|pp| pp.provider }
  end
  
  def over_18?
    Time.at(birthdate) < Time.now.years_ago(18)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
health-data-standards-0.7.1 lib/health-data-standards/models/record.rb