Class: MHVPrescriptionsPolicy
- Inherits:
-
Struct
- Object
- Struct
- MHVPrescriptionsPolicy
- Defined in:
- app/policies/mhv_prescriptions_policy.rb
Constant Summary collapse
- RX_ACCOUNT_TYPES =
%w[Premium Advanced].freeze
Instance Attribute Summary collapse
-
#mhv_prescriptions ⇒ Object
Returns the value of attribute mhv_prescriptions.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#access? ⇒ Boolean
NOTE: This check for va_patient, might break functionality for mhv-sign-in users, since we only query MVI for “Premium”, and Rx is technically available to non-premium.
Instance Attribute Details
#mhv_prescriptions ⇒ Object
Returns the value of attribute mhv_prescriptions
3 4 5 |
# File 'app/policies/mhv_prescriptions_policy.rb', line 3 def mhv_prescriptions @mhv_prescriptions end |
#user ⇒ Object
Returns the value of attribute user
3 4 5 |
# File 'app/policies/mhv_prescriptions_policy.rb', line 3 def user @user end |
Instance Method Details
#access? ⇒ Boolean
NOTE: This check for va_patient, might break functionality for mhv-sign-in users, since we only query MVI for “Premium”, and Rx is technically available to non-premium.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/policies/mhv_prescriptions_policy.rb', line 8 def access? service_name = user.identity.sign_in[:service_name] access = RX_ACCOUNT_TYPES.include?(user.mhv_account_type) && (user.va_patient? || service_name == SignIn::Constants::Auth::MHV) unless access Rails.logger.info('RX ACCESS DENIED', account_type: user.mhv_account_type.presence || 'false', mhv_id: user.mhv_correlation_id.presence || 'false', sign_in_service: service_name, va_facilities: user.va_treatment_facility_ids.length, va_patient: user.va_patient?) end access end |