I have users which have patients. But I'd like to be add the ability for users to share patients with one another. At the moment I'm creating at SharedPatient table with user\_id indicating which user the patient has been shared with and patient\_id indicating the patient. That works, but I have to get User.patients and then query the SharedPatient table for the ids of the other patients they have access to and then query the Patient table for their patient records. 

I really just want to be able to call User.patients and retrieve both their shared patients and the ones they themselves created. A boolean indicating whether the user is the creator or not seems like a solid way to sort between them, but I'm worried it's a bit hacky. Is there a preferred way of going about this or an ActiveRecord relationship I'm overlooking?

edit

```
class User < ActiveRecord::Base
  has_many :patients
  has_many :notes
  has_many :shared_patients
end

class SharedPatient < ActiveRecord::Base
  belongs_to :user
  belongs_to :patient
end

class Patient < ActiveRecord::Base
  belongs_to :user
  has_many :recordings, dependent: :destroy
  has_many :notes, dependent: :destroy
  has_many :shared_patients, dependent: :destroy 
end

```