Skip to main content

ub04_header_view

Materialized: false

Definition
 WITH cob AS NOT MATERIALIZED (
SELECT claim_1.claim_id,
COALESCE(claim_member.payer_responsibility_sequence, 'Primary'::claims.payer_responsibility_sequence_type) AS payer_responsibility_sequence,
claim_1.payer_claim_number,
claim_1.prior_authorization_number
FROM claims.claim claim_1
JOIN claims.claim_member USING (claim_member_id)
UNION ALL
SELECT claim_coordination_of_benefits.claim_id,
claim_coordination_of_benefits.payer_responsibility_sequence,
claim_coordination_of_benefits.payer_claim_number,
claim_coordination_of_benefits.prior_authorization_number
FROM claims.claim_coordination_of_benefits
)
SELECT claim.claim_id,
tps.submit_time,
billprovseen.name_last_or_organization AS billing_provider_name_last_or_organization,
concat_ws(' '::text, billaddr.address1, billaddr.address2) AS billing_provider_address,
concat_ws(' '::text, concat_ws(', '::text, NULLIF(billaddr.city, ''::text), NULLIF(billaddr.state_or_province, ''::text)), NULLIF(billaddr.postal_code, ''::text)) AS billing_provider_city_state_zip,
concat_ws(' '::text, NULLIF(billphone.phone_number, ''::text), NULLIF(billfax.fax_number, ''::text), COALESCE(NULLIF(billaddr.country_code, ''::text), 'US'::text)) AS billing_provider_phone_fax_country,
paytoprovseen.name_last_or_organization AS pay_to_provider_name_last_or_organization,
concat_ws(' '::text, paytoaddr.address1, paytoaddr.address2) AS pay_to_provider_address,
concat_ws(' '::text, concat_ws(', '::text, NULLIF(paytoaddr.city, ''::text), NULLIF(paytoaddr.state_or_province, ''::text)), NULLIF(paytoaddr.postal_code, ''::text)) AS pay_to_provider_city_state_zip,
claim.facility_type || claim.claim_frequency_type AS type_of_bill,
COALESCE(paytoprovseen.tax_id, billprovseen.tax_id) AS tax_id,
claim.statement_date_from,
claim.statement_date_through,
claim.admit_date_or_datetime::date AS admit_date,
claim.facility_admission_type AS type_of_visit,
claim.facility_admission_source AS source_of_admission,
claim.facility_patient_status AS patient_discharge_status,
claim.auto_accident_state,
billprovseen.npi AS billing_provider_npi,
claim.claim_billed_amount AS claim_total_charges,
claim.reprice_methodology,
claim.reprice_allowed_amount,
claim.reprice_savings_amount,
claim.reprice_organization_id,
claim.reprice_exception,
cob1.prior_authorization_number AS prior_auth_number1,
cob2.prior_authorization_number AS prior_auth_number2,
cob3.prior_authorization_number AS prior_auth_number3,
cob1.payer_claim_number AS document_control_number1,
claim.repriced_claim_number,
claim.adjusted_repriced_claim_number,
cob2.payer_claim_number AS document_control_number2,
cob3.payer_claim_number AS document_control_number3,
drg.drg_code
FROM claims.claim
JOIN claims.trading_partner_submission tps ON tps.trading_partner_submission_id = claim.trading_partner_submission_id
LEFT JOIN claims.claim_provider billprov ON billprov.claim_id = claim.claim_id AND billprov.provider_type = 'Billing Provider'::claims.entity_identifier_type
LEFT JOIN claims.claim_provider paytoprov ON paytoprov.claim_id = claim.claim_id AND paytoprov.provider_type = 'Pay-to Provider'::claims.entity_identifier_type
LEFT JOIN claims.provider_seen billprovseen ON billprovseen.provider_seen_id = billprov.provider_seen_id
LEFT JOIN claims.provider_seen paytoprovseen ON paytoprovseen.provider_seen_id = paytoprov.provider_seen_id
LEFT JOIN claims.address_seen billaddr ON billaddr.address_id = billprovseen.address_id
LEFT JOIN claims.phone billphone ON billphone.phone_id = billprovseen.phone_number_id
LEFT JOIN claims.fax billfax ON billfax.fax_id = billprovseen.fax_number_id
LEFT JOIN claims.address_seen paytoaddr ON paytoaddr.address_id = paytoprovseen.address_id
LEFT JOIN cob cob1 ON cob1.claim_id = claim.claim_id AND cob1.payer_responsibility_sequence = 'Primary'::claims.payer_responsibility_sequence_type
LEFT JOIN cob cob2 ON cob2.claim_id = claim.claim_id AND cob2.payer_responsibility_sequence = 'Secondary'::claims.payer_responsibility_sequence_type
LEFT JOIN cob cob3 ON cob3.claim_id = claim.claim_id AND cob3.payer_responsibility_sequence = 'Tertiary'::claims.payer_responsibility_sequence_type
LEFT JOIN claims.claim_drg drg ON drg.claim_id = claim.claim_id
WHERE claim.form_type = 'UB-04'::claims.form_type;
ColumnData TypeIndexed
claim_idbigintNo
submit_timetimestampNo
billing_provider_name_last_or_organizationtextNo
billing_provider_addresstextNo
billing_provider_city_state_ziptextNo
billing_provider_phone_fax_countrytextNo
pay_to_provider_name_last_or_organizationtextNo
pay_to_provider_addresstextNo
pay_to_provider_city_state_ziptextNo
type_of_billtextNo
tax_idtextNo
statement_date_fromdateNo
statement_date_throughdateNo
admit_datedateNo
type_of_visittextNo
source_of_admissiontextNo
patient_discharge_statustextNo
auto_accident_statetextNo
billing_provider_npibigintNo
claim_total_chargesnumericNo
reprice_methodologypricing_methodology_typeNo
reprice_allowed_amountnumericNo
reprice_savings_amountnumericNo
reprice_organization_idtextNo
reprice_exceptionrepricing_exception_typeNo
prior_auth_number1textNo
prior_auth_number2textNo
prior_auth_number3textNo
document_control_number1textNo
repriced_claim_numbertextNo
adjusted_repriced_claim_numbertextNo
document_control_number2textNo
document_control_number3textNo
drg_codetextNo