Class: ChangeHealth::Response::Claim::Report277Data

Inherits:
ReportData show all
Defined in:
lib/change_health/response/claim/report/report_277_data.rb

Overview

Methods only return meaningful data for json reports

Instance Attribute Summary

Attributes inherited from ReportData

#json, #report_name

Attributes inherited from ResponseData

#raw, #response

Instance Method Summary collapse

Methods inherited from ReportData

#edi?, #initialize, #is_277?, is_277?, is_835?, #is_835?, #presence, report_type, #report_type

Methods inherited from ResponseData

#errors, #errors?, #initialize, #recommend_retry?, #server_error

Constructor Details

This class inherits a constructor from ChangeHealth::Response::Claim::ReportData

Instance Method Details

#claimsObject



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
# File 'lib/change_health/response/claim/report/report_277_data.rb', line 19

def claims
  report_claims = []

  transactions&.each do |transaction|
    id = transaction.dig('id')
    report_creation_date = ChangeHealth::Models::PARSE_DATE.call(transaction['transactionSetCreationDate'])
    transaction['payers']&.each do |payer|
      payer_identification = payer['payerIdentification']
      payer_name = payer['organizationName']
      payer['claimStatusTransactions']&.each do |claim_status_txn|
        claim_status_txn['claimStatusDetails']&.each do |claim_status_detail|
          service_provider_npi = claim_status_detail.dig('serviceProvider', 'npi')
          claim_status_detail['patientClaimStatusDetails']&.each do |patient_claim_status_detail|
            patient_first_name = patient_claim_status_detail.dig('subscriber', 'firstName')
            patient_last_name = patient_claim_status_detail.dig('subscriber', 'lastName')
            patient_member_id = patient_claim_status_detail.dig('subscriber', 'memberId')
            patient_claim_status_detail['claims']&.each do |claim|
              procedure_codes = []
              claim['serviceLines']&.each do |service_line|
                procedure_codes << service_line.dig('service', 'procedureCode')
              end
              claim_status = claim['claimStatus']
              next if claim_status.nil?

              clearinghouse_trace_number = claim_status['clearinghouseTraceNumber']
               = claim_status['patientAccountNumber']
              referenced_transaction_trace_number = claim_status['referencedTransactionTraceNumber']
              trading_partner_claim_number = claim_status['tradingPartnerClaimNumber']

              service_date_begin = ChangeHealth::Models::PARSE_DATE.call(presence(claim_status['claimServiceBeginDate']) || presence(claim_status['claimServiceDate']))
              service_date_end = ChangeHealth::Models::PARSE_DATE.call(presence(claim_status['claimServiceEndDate']) || presence(claim_status['claimServiceDate']))

              info_claim_statuses = []
              claim_status['informationClaimStatuses']&.each do |info_claim_status|
                message = info_claim_status['message']
                status_information_effective_date = ChangeHealth::Models::PARSE_DATE.call(info_claim_status['statusInformationEffectiveDate'])
                total_charge_amount = info_claim_status['totalClaimChargeAmount']

                info_statuses = []
                info_claim_status['informationStatuses']&.each do |info_status|
                  info_statuses << Report277InfoStatus.new(
                    status_category_code: info_status['healthCareClaimStatusCategoryCode'],
                    status_category_code_value: info_status['healthCareClaimStatusCategoryCodeValue'],
                    status_code: info_status['statusCode'],
                    status_code_value: info_status['statusCodeValue']
                  )
                end

                info_claim_statuses << Report277InfoClaimStatus.new(
                  message: message,
                  info_statuses: info_statuses,
                  total_charge_amount: total_charge_amount,
                  status_information_effective_date: status_information_effective_date
                )
              end
              report_claims << Report277Claim.new(
                clearinghouse_trace_number: clearinghouse_trace_number,
                id: id,
                info_claim_statuses: info_claim_statuses,
                patient_account_number: ,
                patient_first_name: patient_first_name,
                patient_last_name: patient_last_name,
                patient_member_id: patient_member_id,
                payer_identification: payer_identification,
                payer_name: payer_name,
                procedure_codes: procedure_codes,
                referenced_transaction_trace_number: referenced_transaction_trace_number,
                report_creation_date: report_creation_date,
                report_name: report_name,
                service_date_begin: service_date_begin,
                service_date_end: service_date_end,
                service_provider_npi: service_provider_npi,
                trading_partner_claim_number: trading_partner_claim_number
              )
            end
          end
        end
      end
    end
  end

  report_claims
end

#payer_nameObject

Only one payer per report



11
12
13
# File 'lib/change_health/response/claim/report/report_277_data.rb', line 11

def payer_name
  transactions&.first&.dig('payers')&.first&.dig('organizationName')
end

#report_creation_dateObject



15
16
17
# File 'lib/change_health/response/claim/report/report_277_data.rb', line 15

def report_creation_date
  ChangeHealth::Models::PARSE_DATE.call(transactions&.first&.dig('transactionSetCreationDate'))
end

#transactionsObject



6
7
8
# File 'lib/change_health/response/claim/report/report_277_data.rb', line 6

def transactions
  @raw['transactions']
end