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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
# File 'lib/change_health/response/claim/report/report_835_data.rb', line 43
def claims
report_claims = []
transactions&.each do |transaction|
transaction['detailInfo']&.each do |detail_info|
detail_info['paymentInfo']&.each do |payment_info|
patient_control_number = payment_info.dig('claimPaymentInfo', 'patientControlNumber')
patient_first_name = payment_info.dig('patientName', 'firstName')
patient_last_name = payment_info.dig('patientName', 'lastName')
patient_member_id = payment_info.dig('patientName', 'memberId') || payment_info.dig('subscriber', 'memberId')
payer_claim_control_number = payment_info.dig('claimPaymentInfo', 'payerClaimControlNumber')
service_provider_npi = payment_info.dig('renderingProvider', 'npi') || detail_info['providerSummaryInformation']['providerIdentifier']
total_charge_amount = payment_info.dig('claimPaymentInfo', 'totalClaimChargeAmount')
= []
= 1
while payment_info.dig('outpatientAdjudication',
"claimPaymentRemarkCode#{claim_payment_remark_codes_index}")
<< payment_info.dig('outpatientAdjudication',
"claimPaymentRemarkCode#{claim_payment_remark_codes_index}")
+= 1
end
service_date_begin = nil
service_date_end = nil
service_lines = payment_info['serviceLines']&.map do |service_line|
service_line_date = ChangeHealth::Models::PARSE_DATE.call(service_line['serviceDate'])
if service_date_begin.nil? || service_line_date < service_date_begin
service_date_begin = service_line_date
end
service_date_end = service_line_date if service_date_end.nil? || service_date_end < service_line_date
adjudicated_procedure_code = service_line.dig('servicePaymentInformation', 'adjudicatedProcedureCode')
allowed_actual = service_line.dig('serviceSupplementalAmounts', 'allowedActual')
line_item_charge_amount = service_line.dig('servicePaymentInformation', 'lineItemChargeAmount')
line_item_provider_payment_amount = service_line.dig('servicePaymentInformation',
'lineItemProviderPaymentAmount')
service_adjustments = service_line['serviceAdjustments']&.map do |service_adjustment|
adjustments = {}
service_adjustment_index = 1
while service_adjustment["adjustmentReasonCode#{service_adjustment_index}"]
adjustment_reason = service_adjustment["adjustmentReasonCode#{service_adjustment_index}"]
adjustment_amount = service_adjustment["adjustmentAmount#{service_adjustment_index}"]
adjustments[adjustment_reason] = adjustment_amount
service_adjustment_index += 1
end
claim_adjustment_group_code = service_adjustment['claimAdjustmentGroupCode']
Report835ServiceAdjustment.new(
adjustments: adjustments,
claim_adjustment_group_code: claim_adjustment_group_code
)
end
= service_line['healthCareCheckRemarkCodes']&.map do ||
.new(
code_list_qualifier_code: ['codeListQualifierCode'],
code_list_qualifier_code_value: ['codeListQualifierCodeValue'],
remark_code: ['remarkCode']
)
end
Report835ServiceLine.new(
adjudicated_procedure_code: adjudicated_procedure_code,
allowed_actual: allowed_actual,
line_item_charge_amount: line_item_charge_amount,
line_item_provider_payment_amount: line_item_provider_payment_amount,
service_adjustments: service_adjustments,
health_care_check_remark_codes:
)
end
report_claims << Report835Claim.new(
check_issue_or_eft_effective_date: check_issue_or_eft_effective_date,
check_or_eft_trace_number: check_or_eft_trace_number,
claim_payment_remark_codes: ,
patient_control_number: patient_control_number,
patient_first_name: patient_first_name,
patient_last_name: patient_last_name,
patient_member_id: patient_member_id,
payer_claim_control_number: payer_claim_control_number,
payer_identification: payer_identification,
payer_identifier: payer_identifier,
payer_name: payer_name,
payment_method_code: payment_method_code,
report_creation_date: report_creation_date,
report_name: report_name,
service_date_begin: service_date_begin,
service_date_end: service_date_end,
service_lines: service_lines,
service_provider_npi: service_provider_npi,
total_actual_provider_payment_amount: total_actual_provider_payment_amount,
total_charge_amount: total_charge_amount
)
end
end
end
report_claims
end
|