Created
August 27, 2014 13:40
-
-
Save klippx/bc93c15bd26b47ae5990 to your computer and use it in GitHub Desktop.
All your diagnoses are belong to me
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
def diagnoses_belongs_to_me | |
diagnoses_ids = [] | |
rows_array = form.rows.to_a[0...self.position - 1].reverse | |
rows_array.each do |r| | |
next if r.id == self.id | |
break if r.kind_of?(Journal::FormRow::ItemRow) or (r.kind_of?(Journal::FormRow::LabSampleRow) and r.billing_record_rows.any?) | |
if r.kind_of?(Journal::FormRow::DiagnosisRow) && r.diagnosis_id | |
diagnoses_ids << r.diagnosis_id | |
end | |
end | |
Diagnosis.find(diagnoses_ids) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment