apsislabs / phi_attrs

HIPAA compliant PHI access logging for Ruby on Rails.
MIT License
27 stars 3 forks source link

Add shorthand for joined models #2

Closed wkirby closed 6 years ago

wkirby commented 6 years ago

When dealing with a phi_model it's not that infrequent that we'll have joined phi_models. For convenience, we should have a shorthand method of extending allow_phi! to include those joins.

There should be two methods of doing this. One at the class level, which essentially acts as a permanent extension: allowing PHI access on this model will grant PHI access on these models. I'm thinking a syntax like:

class PatientInfo < ActiveRecord::Base
  phi_model
end

class Patient < ActiveRecord::Base
  has_one :patient_info

  phi_model
  extend_phi_access :patient_info
end

patient = Patient.new
patient.allow_phi!('user@example.com', 'reason')
patient.patient_info.first_name

Additionally, there should be a per-usage shorthand. Something that is passed as an argument to allow_phi!. I'm thinking something like:

class PatientInfo < ActiveRecord::Base
  phi_model
end

class Patient < ActiveRecord::Base
  has_one :patient_info

  phi_model
end

patient = Patient.new
patient.allow_phi!('user@example.com', 'reason', include: [:patient_info])
patient.patient_info.first_name
wkirby commented 6 years ago

Closed by #5