Class: Renalware::Letters::ResolveDefaultElectronicCCs
- Inherits:
-
Object
- Object
- Renalware::Letters::ResolveDefaultElectronicCCs
- Includes:
- Broadcasting
- Defined in:
- app/models/renalware/letters/resolve_default_electronic_ccs.rb
Overview
This class is responsible for collating the complete set of default electronic ccs for a new patient letter. An HD patient for instance might have a named nurse who should always be eCCed into any letters about them. Important to note here is that we are of course in the Letters module and have no knowledge of who should be eCCs and how to resolve those users; these are matters that relate for example to the user’s current modality and the corresponding module (HD, PD, Transplant etc). So here all we can do is broadcast a (synchronous) event asking anyone listening (ie any class that is configured to listen in the broadcast_map) to add their eCC users to the passed in array_of_user_ids array. We will then dedupe and return that array, where it will be used to initialize the eCC component on the letters UI form with the correct initial default set up eCC users. This only applies to new letters, ie when displaying the the UI form for a new letter.
Example usage:
array_of_ecc_users = ResolveDefaultElectronicCCs
.for(patient)
.broadcasting_to_configured_subscribers
.call
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Broadcasting
#broadcasting_to_configured_subscribers
Class Method Details
.for(patient) ⇒ Object
32 33 34 |
# File 'app/models/renalware/letters/resolve_default_electronic_ccs.rb', line 32 def self.for(patient) new(patient) end |
Instance Method Details
#call ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'app/models/renalware/letters/resolve_default_electronic_ccs.rb', line 36 def call array_of_user_ids = [] broadcast( :request_default_electronic_cc_recipients_for_use_in_letters, patient: patient, array_of_user_ids: array_of_user_ids ) array_of_user_ids.compact.uniq end |