-
-
Save tubbo/d0d799d3651e00081092 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
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