Class: MedicalCopays::ZeroBalanceStatements
- Inherits:
-
Object
- Object
- MedicalCopays::ZeroBalanceStatements
- Defined in:
- app/services/medical_copays/zero_balance_statements.rb
Overview
Object for building a list of the user’s zero balance statements
Instance Attribute Summary collapse
-
#facilities ⇒ Object
Returns the value of attribute facilities.
-
#facility_hash ⇒ Array<Hash>
Object for building a list of the user’s zero balance statements.
-
#statements ⇒ Array<Hash>
Object for building a list of the user’s zero balance statements.
Class Method Summary collapse
-
.build(opts = {}) ⇒ ZeroBalanceStatements
Builds a ZeroBalanceStatements instance.
Instance Method Summary collapse
-
#facilities_ids ⇒ Array<String>
private
The list of vista keys associated with the user’s profile.
- #facility_api ⇒ Object private
-
#get_facilities ⇒ Array<Lighthouse::Facilities::Facility>
private
Get facilities that have zero balance from Lighthouse.
-
#initialize(opts) ⇒ ZeroBalanceStatements
constructor
A new instance of ZeroBalanceStatements.
-
#list ⇒ Array<Hash>
Format collection of facilities to match VBS response.
-
#request_data ⇒ Hash
private
Formatted object to pass to the Lightouse API.
-
#statements_facilities_ids ⇒ Array<String>
private
The list of facility ids found from the VBS response.
-
#zero_balance_facilities_ids ⇒ Array<String>
private
The unique list of facilities with zero balance.
Constructor Details
#initialize(opts) ⇒ ZeroBalanceStatements
Returns a new instance of ZeroBalanceStatements.
27 28 29 30 31 |
# File 'app/services/medical_copays/zero_balance_statements.rb', line 27 def initialize(opts) @facility_hash = opts[:facility_hash] @statements = opts[:statements] @facilities = get_facilities || [] end |
Instance Attribute Details
#facilities ⇒ Object
Returns the value of attribute facilities.
15 16 17 |
# File 'app/services/medical_copays/zero_balance_statements.rb', line 15 def facilities @facilities end |
#facility_hash ⇒ Array<Hash>
Object for building a list of the user’s zero balance statements
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'app/services/medical_copays/zero_balance_statements.rb', line 13 class ZeroBalanceStatements attr_reader :facility_hash, :statements attr_accessor :facilities ## # Builds a ZeroBalanceStatements instance # # @param opts [Hash] # @return [ZeroBalanceStatements] an instance of this class # def self.build(opts = {}) new(opts) end def initialize(opts) @facility_hash = opts[:facility_hash] @statements = opts[:statements] @facilities = get_facilities || [] end ## # Format collection of facilities to match VBS response # # @return [Array<Hash>] # def list facilities.map do |facility| { 'pH_AMT_DUE' => 0, 'pS_STATEMENT_DATE' => Time.zone.today.strftime('%m%d%Y'), 'station' => { 'facilitY_NUM' => facility['id'].sub('vha_', ''), 'city' => facility['address']['physical']['city'].upcase } } end end private ## # The list of vista keys associated with the user's profile # # @return [Array<String>] # def facilities_ids facility_hash&.keys end ## # The list of facility ids found from the VBS response # # @return [Array<String>] # def statements_facilities_ids statements.map { |i| i['pS_FACILITY_NUM'] } end ## # The unique list of facilities with zero balance # # @return [Array<String>] # def zero_balance_facilities_ids facilities_ids.uniq - statements_facilities_ids unless facilities_ids.nil? end ## # Formatted object to pass to the Lightouse API # # @return [Hash] # def request_data vha_formatted_ids = zero_balance_facilities_ids.map { |i| i.dup.prepend('vha_') }.join(',') { ids: vha_formatted_ids } end ## # Get facilities that have zero balance from Lighthouse # # @return [Array<Lighthouse::Facilities::Facility>] # def get_facilities facility_api.get_facilities(request_data) if zero_balance_facilities_ids.present? rescue Common::Exceptions::BackendServiceException [] end def facility_api Lighthouse::Facilities::Client.new end end |
#statements ⇒ Array<Hash>
Object for building a list of the user’s zero balance statements
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'app/services/medical_copays/zero_balance_statements.rb', line 13 class ZeroBalanceStatements attr_reader :facility_hash, :statements attr_accessor :facilities ## # Builds a ZeroBalanceStatements instance # # @param opts [Hash] # @return [ZeroBalanceStatements] an instance of this class # def self.build(opts = {}) new(opts) end def initialize(opts) @facility_hash = opts[:facility_hash] @statements = opts[:statements] @facilities = get_facilities || [] end ## # Format collection of facilities to match VBS response # # @return [Array<Hash>] # def list facilities.map do |facility| { 'pH_AMT_DUE' => 0, 'pS_STATEMENT_DATE' => Time.zone.today.strftime('%m%d%Y'), 'station' => { 'facilitY_NUM' => facility['id'].sub('vha_', ''), 'city' => facility['address']['physical']['city'].upcase } } end end private ## # The list of vista keys associated with the user's profile # # @return [Array<String>] # def facilities_ids facility_hash&.keys end ## # The list of facility ids found from the VBS response # # @return [Array<String>] # def statements_facilities_ids statements.map { |i| i['pS_FACILITY_NUM'] } end ## # The unique list of facilities with zero balance # # @return [Array<String>] # def zero_balance_facilities_ids facilities_ids.uniq - statements_facilities_ids unless facilities_ids.nil? end ## # Formatted object to pass to the Lightouse API # # @return [Hash] # def request_data vha_formatted_ids = zero_balance_facilities_ids.map { |i| i.dup.prepend('vha_') }.join(',') { ids: vha_formatted_ids } end ## # Get facilities that have zero balance from Lighthouse # # @return [Array<Lighthouse::Facilities::Facility>] # def get_facilities facility_api.get_facilities(request_data) if zero_balance_facilities_ids.present? rescue Common::Exceptions::BackendServiceException [] end def facility_api Lighthouse::Facilities::Client.new end end |
Class Method Details
.build(opts = {}) ⇒ ZeroBalanceStatements
Builds a ZeroBalanceStatements instance
23 24 25 |
# File 'app/services/medical_copays/zero_balance_statements.rb', line 23 def self.build(opts = {}) new(opts) end |
Instance Method Details
#facilities_ids ⇒ Array<String> (private)
The list of vista keys associated with the user’s profile
58 59 60 |
# File 'app/services/medical_copays/zero_balance_statements.rb', line 58 def facilities_ids facility_hash&.keys end |
#facility_api ⇒ Object (private)
101 102 103 |
# File 'app/services/medical_copays/zero_balance_statements.rb', line 101 def facility_api Lighthouse::Facilities::Client.new end |
#get_facilities ⇒ Array<Lighthouse::Facilities::Facility> (private)
Get facilities that have zero balance from Lighthouse
95 96 97 98 99 |
# File 'app/services/medical_copays/zero_balance_statements.rb', line 95 def get_facilities facility_api.get_facilities(request_data) if zero_balance_facilities_ids.present? rescue Common::Exceptions::BackendServiceException [] end |
#list ⇒ Array<Hash>
Format collection of facilities to match VBS response
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/services/medical_copays/zero_balance_statements.rb', line 38 def list facilities.map do |facility| { 'pH_AMT_DUE' => 0, 'pS_STATEMENT_DATE' => Time.zone.today.strftime('%m%d%Y'), 'station' => { 'facilitY_NUM' => facility['id'].sub('vha_', ''), 'city' => facility['address']['physical']['city'].upcase } } end end |
#request_data ⇒ Hash (private)
Formatted object to pass to the Lightouse API
85 86 87 88 |
# File 'app/services/medical_copays/zero_balance_statements.rb', line 85 def request_data vha_formatted_ids = zero_balance_facilities_ids.map { |i| i.dup.prepend('vha_') }.join(',') { ids: vha_formatted_ids } end |
#statements_facilities_ids ⇒ Array<String> (private)
The list of facility ids found from the VBS response
67 68 69 |
# File 'app/services/medical_copays/zero_balance_statements.rb', line 67 def statements_facilities_ids statements.map { |i| i['pS_FACILITY_NUM'] } end |
#zero_balance_facilities_ids ⇒ Array<String> (private)
The unique list of facilities with zero balance
76 77 78 |
# File 'app/services/medical_copays/zero_balance_statements.rb', line 76 def zero_balance_facilities_ids facilities_ids.uniq - statements_facilities_ids unless facilities_ids.nil? end |