Skip to content

Instantly share code, notes, and snippets.

@tubbo
Forked from anonymous/gist:51888d5fcc8406a6deb8
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tubbo/d0d799d3651e00081092 to your computer and use it in GitHub Desktop.
Save tubbo/d0d799d3651e00081092 to your computer and use it in GitHub Desktop.
class Instance < ActiveRecord::Base
has_many :reports
has_many :exams, primary_key: 'study_instance_uid', foreign_key: 'study_inst_uid', inverse_of: :instance
has_many :patients, through: :exams
before_save :set_reading_physician
def reading_physician
(set_reading_physician and save!) if reading_physician.nil?
read_attribute(:reading_physician) || ''
end
private
def set_reading_physician
self.reading_physician ||= patient.reading_physician
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment