Skip to content

Instantly share code, notes, and snippets.

@klippx
Created August 27, 2014 13:40
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 klippx/bc93c15bd26b47ae5990 to your computer and use it in GitHub Desktop.
Save klippx/bc93c15bd26b47ae5990 to your computer and use it in GitHub Desktop.
All your diagnoses are belong to me
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