Skip to main content

claim_procedure_wide_view

Materialized: false

Definition
 WITH procedures AS (
SELECT ct.claim_id,
ct.principal_procedure,
ct.other_procedure1,
ct.other_procedure2,
ct.other_procedure3,
ct.other_procedure4,
ct.other_procedure5,
ct.other_procedure6,
ct.other_procedure7,
ct.other_procedure8,
ct.other_procedure9,
ct.other_procedure10,
ct.other_procedure11,
ct.other_procedure12,
ct.other_procedure13,
ct.other_procedure14,
ct.other_procedure15,
ct.other_procedure16,
ct.other_procedure17,
ct.other_procedure18,
ct.other_procedure19,
ct.other_procedure20,
ct.other_procedure21,
ct.other_procedure22,
ct.other_procedure23,
ct.other_procedure24,
ct.other_procedure25,
ct.other_procedure26,
ct.other_procedure27,
ct.other_procedure28,
ct.other_procedure29,
ct.other_procedure30
FROM public.crosstab('SELECT claim_id, claim_procedure_index, procedure_code
FROM claims.claim_procedure
WHERE is_principal = true
UNION
SELECT claim_id, claim_procedure_index, procedure_code
FROM claims.claim_procedure
WHERE is_principal = false
ORDER BY claim_id, claim_procedure_index, procedure_code'::text) ct(claim_id bigint, principal_procedure text, other_procedure1 text, other_procedure2 text, other_procedure3 text, other_procedure4 text, other_procedure5 text, other_procedure6 text, other_procedure7 text, other_procedure8 text, other_procedure9 text, other_procedure10 text, other_procedure11 text, other_procedure12 text, other_procedure13 text, other_procedure14 text, other_procedure15 text, other_procedure16 text, other_procedure17 text, other_procedure18 text, other_procedure19 text, other_procedure20 text, other_procedure21 text, other_procedure22 text, other_procedure23 text, other_procedure24 text, other_procedure25 text, other_procedure26 text, other_procedure27 text, other_procedure28 text, other_procedure29 text, other_procedure30 text)
), descriptions AS (
SELECT ct.claim_id,
ct.principal_procedure_description,
ct.other_procedure_description1,
ct.other_procedure_description2,
ct.other_procedure_description3,
ct.other_procedure_description4,
ct.other_procedure_description5,
ct.other_procedure_description6,
ct.other_procedure_description7,
ct.other_procedure_description8,
ct.other_procedure_description9,
ct.other_procedure_description10,
ct.other_procedure_description11,
ct.other_procedure_description12,
ct.other_procedure_description13,
ct.other_procedure_description14,
ct.other_procedure_description15,
ct.other_procedure_description16,
ct.other_procedure_description17,
ct.other_procedure_description18,
ct.other_procedure_description19,
ct.other_procedure_description20,
ct.other_procedure_description21,
ct.other_procedure_description22,
ct.other_procedure_description23,
ct.other_procedure_description24,
ct.other_procedure_description25,
ct.other_procedure_description26,
ct.other_procedure_description27,
ct.other_procedure_description28,
ct.other_procedure_description29,
ct.other_procedure_description30
FROM public.crosstab('SELECT claim_id, claim_procedure_index, description
FROM claims.claim_procedure p
LEFT OUTER JOIN claims.icd_procedure_lookup i ON i.icd_procedure_id = p.icd_procedure_id
WHERE is_principal = true
UNION
SELECT claim_id, claim_procedure_index, description
FROM claims.claim_procedure p
LEFT OUTER JOIN claims.icd_procedure_lookup i ON i.icd_procedure_id = p.icd_procedure_id
WHERE is_principal = false
ORDER BY claim_id, claim_procedure_index, description'::text) ct(claim_id bigint, principal_procedure_description text, other_procedure_description1 text, other_procedure_description2 text, other_procedure_description3 text, other_procedure_description4 text, other_procedure_description5 text, other_procedure_description6 text, other_procedure_description7 text, other_procedure_description8 text, other_procedure_description9 text, other_procedure_description10 text, other_procedure_description11 text, other_procedure_description12 text, other_procedure_description13 text, other_procedure_description14 text, other_procedure_description15 text, other_procedure_description16 text, other_procedure_description17 text, other_procedure_description18 text, other_procedure_description19 text, other_procedure_description20 text, other_procedure_description21 text, other_procedure_description22 text, other_procedure_description23 text, other_procedure_description24 text, other_procedure_description25 text, other_procedure_description26 text, other_procedure_description27 text, other_procedure_description28 text, other_procedure_description29 text, other_procedure_description30 text)
), hcup_groups AS (
SELECT ct.claim_id,
ct.principal_procedure_hcup_group,
ct.other_procedure_hcup_group1,
ct.other_procedure_hcup_group2,
ct.other_procedure_hcup_group3,
ct.other_procedure_hcup_group4,
ct.other_procedure_hcup_group5,
ct.other_procedure_hcup_group6,
ct.other_procedure_hcup_group7,
ct.other_procedure_hcup_group8,
ct.other_procedure_hcup_group9,
ct.other_procedure_hcup_group10,
ct.other_procedure_hcup_group11,
ct.other_procedure_hcup_group12,
ct.other_procedure_hcup_group13,
ct.other_procedure_hcup_group14,
ct.other_procedure_hcup_group15,
ct.other_procedure_hcup_group16,
ct.other_procedure_hcup_group17,
ct.other_procedure_hcup_group18,
ct.other_procedure_hcup_group19,
ct.other_procedure_hcup_group20,
ct.other_procedure_hcup_group21,
ct.other_procedure_hcup_group22,
ct.other_procedure_hcup_group23,
ct.other_procedure_hcup_group24,
ct.other_procedure_hcup_group25,
ct.other_procedure_hcup_group26,
ct.other_procedure_hcup_group27,
ct.other_procedure_hcup_group28,
ct.other_procedure_hcup_group29,
ct.other_procedure_hcup_group30
FROM public.crosstab('SELECT claim_id, claim_procedure_index, description
FROM claims.claim_procedure p
LEFT OUTER JOIN claims.icd_procedure_lookup i ON i.icd_procedure_id = p.icd_procedure_id
WHERE is_principal = true
UNION
SELECT claim_id, claim_procedure_index, description
FROM claims.claim_procedure p
LEFT OUTER JOIN claims.icd_procedure_lookup i ON i.icd_procedure_id = p.icd_procedure_id
WHERE is_principal = false
ORDER BY claim_id, claim_procedure_index, description'::text) ct(claim_id bigint, principal_procedure_hcup_group text, other_procedure_hcup_group1 text, other_procedure_hcup_group2 text, other_procedure_hcup_group3 text, other_procedure_hcup_group4 text, other_procedure_hcup_group5 text, other_procedure_hcup_group6 text, other_procedure_hcup_group7 text, other_procedure_hcup_group8 text, other_procedure_hcup_group9 text, other_procedure_hcup_group10 text, other_procedure_hcup_group11 text, other_procedure_hcup_group12 text, other_procedure_hcup_group13 text, other_procedure_hcup_group14 text, other_procedure_hcup_group15 text, other_procedure_hcup_group16 text, other_procedure_hcup_group17 text, other_procedure_hcup_group18 text, other_procedure_hcup_group19 text, other_procedure_hcup_group20 text, other_procedure_hcup_group21 text, other_procedure_hcup_group22 text, other_procedure_hcup_group23 text, other_procedure_hcup_group24 text, other_procedure_hcup_group25 text, other_procedure_hcup_group26 text, other_procedure_hcup_group27 text, other_procedure_hcup_group28 text, other_procedure_hcup_group29 text, other_procedure_hcup_group30 text)
), hcup_descriptions AS (
SELECT ct.claim_id,
ct.principal_procedure_hcup_group_description,
ct.other_procedure_hcup_group_description1,
ct.other_procedure_hcup_group_description2,
ct.other_procedure_hcup_group_description3,
ct.other_procedure_hcup_group_description4,
ct.other_procedure_hcup_group_description5,
ct.other_procedure_hcup_group_description6,
ct.other_procedure_hcup_group_description7,
ct.other_procedure_hcup_group_description8,
ct.other_procedure_hcup_group_description9,
ct.other_procedure_hcup_group_description10,
ct.other_procedure_hcup_group_description11,
ct.other_procedure_hcup_group_description12,
ct.other_procedure_hcup_group_description13,
ct.other_procedure_hcup_group_description14,
ct.other_procedure_hcup_group_description15,
ct.other_procedure_hcup_group_description16,
ct.other_procedure_hcup_group_description17,
ct.other_procedure_hcup_group_description18,
ct.other_procedure_hcup_group_description19,
ct.other_procedure_hcup_group_description20,
ct.other_procedure_hcup_group_description21,
ct.other_procedure_hcup_group_description22,
ct.other_procedure_hcup_group_description23,
ct.other_procedure_hcup_group_description24,
ct.other_procedure_hcup_group_description25,
ct.other_procedure_hcup_group_description26,
ct.other_procedure_hcup_group_description27,
ct.other_procedure_hcup_group_description28,
ct.other_procedure_hcup_group_description29,
ct.other_procedure_hcup_group_description30
FROM public.crosstab('SELECT claim_id, claim_procedure_index, description
FROM claims.claim_procedure p
LEFT OUTER JOIN claims.icd_procedure_lookup i ON i.icd_procedure_id = p.icd_procedure_id
WHERE is_principal = true
UNION
SELECT claim_id, claim_procedure_index, description
FROM claims.claim_procedure p
LEFT OUTER JOIN claims.icd_procedure_lookup i ON i.icd_procedure_id = p.icd_procedure_id
WHERE is_principal = false
ORDER BY claim_id, claim_procedure_index, description'::text) ct(claim_id bigint, principal_procedure_hcup_group_description text, other_procedure_hcup_group_description1 text, other_procedure_hcup_group_description2 text, other_procedure_hcup_group_description3 text, other_procedure_hcup_group_description4 text, other_procedure_hcup_group_description5 text, other_procedure_hcup_group_description6 text, other_procedure_hcup_group_description7 text, other_procedure_hcup_group_description8 text, other_procedure_hcup_group_description9 text, other_procedure_hcup_group_description10 text, other_procedure_hcup_group_description11 text, other_procedure_hcup_group_description12 text, other_procedure_hcup_group_description13 text, other_procedure_hcup_group_description14 text, other_procedure_hcup_group_description15 text, other_procedure_hcup_group_description16 text, other_procedure_hcup_group_description17 text, other_procedure_hcup_group_description18 text, other_procedure_hcup_group_description19 text, other_procedure_hcup_group_description20 text, other_procedure_hcup_group_description21 text, other_procedure_hcup_group_description22 text, other_procedure_hcup_group_description23 text, other_procedure_hcup_group_description24 text, other_procedure_hcup_group_description25 text, other_procedure_hcup_group_description26 text, other_procedure_hcup_group_description27 text, other_procedure_hcup_group_description28 text, other_procedure_hcup_group_description29 text, other_procedure_hcup_group_description30 text)
)
SELECT procedures.claim_id,
procedures.principal_procedure,
descriptions.principal_procedure_description,
hcup_groups.principal_procedure_hcup_group,
hcup_descriptions.principal_procedure_hcup_group_description,
procedures.other_procedure1,
procedures.other_procedure2,
procedures.other_procedure3,
procedures.other_procedure4,
procedures.other_procedure5,
procedures.other_procedure6,
procedures.other_procedure7,
procedures.other_procedure8,
procedures.other_procedure9,
procedures.other_procedure10,
procedures.other_procedure11,
procedures.other_procedure12,
procedures.other_procedure13,
procedures.other_procedure14,
procedures.other_procedure15,
procedures.other_procedure16,
procedures.other_procedure17,
procedures.other_procedure18,
procedures.other_procedure19,
procedures.other_procedure20,
procedures.other_procedure21,
procedures.other_procedure22,
procedures.other_procedure23,
procedures.other_procedure24,
procedures.other_procedure25,
procedures.other_procedure26,
procedures.other_procedure27,
procedures.other_procedure28,
procedures.other_procedure29,
procedures.other_procedure30,
descriptions.other_procedure_description1,
descriptions.other_procedure_description2,
descriptions.other_procedure_description3,
descriptions.other_procedure_description4,
descriptions.other_procedure_description5,
descriptions.other_procedure_description6,
descriptions.other_procedure_description7,
descriptions.other_procedure_description8,
descriptions.other_procedure_description9,
descriptions.other_procedure_description10,
descriptions.other_procedure_description11,
descriptions.other_procedure_description12,
descriptions.other_procedure_description13,
descriptions.other_procedure_description14,
descriptions.other_procedure_description15,
descriptions.other_procedure_description16,
descriptions.other_procedure_description17,
descriptions.other_procedure_description18,
descriptions.other_procedure_description19,
descriptions.other_procedure_description20,
descriptions.other_procedure_description21,
descriptions.other_procedure_description22,
descriptions.other_procedure_description23,
descriptions.other_procedure_description24,
descriptions.other_procedure_description25,
descriptions.other_procedure_description26,
descriptions.other_procedure_description27,
descriptions.other_procedure_description28,
descriptions.other_procedure_description29,
descriptions.other_procedure_description30,
hcup_groups.other_procedure_hcup_group1,
hcup_groups.other_procedure_hcup_group2,
hcup_groups.other_procedure_hcup_group3,
hcup_groups.other_procedure_hcup_group4,
hcup_groups.other_procedure_hcup_group5,
hcup_groups.other_procedure_hcup_group6,
hcup_groups.other_procedure_hcup_group7,
hcup_groups.other_procedure_hcup_group8,
hcup_groups.other_procedure_hcup_group9,
hcup_groups.other_procedure_hcup_group10,
hcup_groups.other_procedure_hcup_group11,
hcup_groups.other_procedure_hcup_group12,
hcup_groups.other_procedure_hcup_group13,
hcup_groups.other_procedure_hcup_group14,
hcup_groups.other_procedure_hcup_group15,
hcup_groups.other_procedure_hcup_group16,
hcup_groups.other_procedure_hcup_group17,
hcup_groups.other_procedure_hcup_group18,
hcup_groups.other_procedure_hcup_group19,
hcup_groups.other_procedure_hcup_group20,
hcup_groups.other_procedure_hcup_group21,
hcup_groups.other_procedure_hcup_group22,
hcup_groups.other_procedure_hcup_group23,
hcup_groups.other_procedure_hcup_group24,
hcup_groups.other_procedure_hcup_group25,
hcup_groups.other_procedure_hcup_group26,
hcup_groups.other_procedure_hcup_group27,
hcup_groups.other_procedure_hcup_group28,
hcup_groups.other_procedure_hcup_group29,
hcup_groups.other_procedure_hcup_group30,
hcup_descriptions.other_procedure_hcup_group_description1,
hcup_descriptions.other_procedure_hcup_group_description2,
hcup_descriptions.other_procedure_hcup_group_description3,
hcup_descriptions.other_procedure_hcup_group_description4,
hcup_descriptions.other_procedure_hcup_group_description5,
hcup_descriptions.other_procedure_hcup_group_description6,
hcup_descriptions.other_procedure_hcup_group_description7,
hcup_descriptions.other_procedure_hcup_group_description8,
hcup_descriptions.other_procedure_hcup_group_description9,
hcup_descriptions.other_procedure_hcup_group_description10,
hcup_descriptions.other_procedure_hcup_group_description11,
hcup_descriptions.other_procedure_hcup_group_description12,
hcup_descriptions.other_procedure_hcup_group_description13,
hcup_descriptions.other_procedure_hcup_group_description14,
hcup_descriptions.other_procedure_hcup_group_description15,
hcup_descriptions.other_procedure_hcup_group_description16,
hcup_descriptions.other_procedure_hcup_group_description17,
hcup_descriptions.other_procedure_hcup_group_description18,
hcup_descriptions.other_procedure_hcup_group_description19,
hcup_descriptions.other_procedure_hcup_group_description20,
hcup_descriptions.other_procedure_hcup_group_description21,
hcup_descriptions.other_procedure_hcup_group_description22,
hcup_descriptions.other_procedure_hcup_group_description23,
hcup_descriptions.other_procedure_hcup_group_description24,
hcup_descriptions.other_procedure_hcup_group_description25,
hcup_descriptions.other_procedure_hcup_group_description26,
hcup_descriptions.other_procedure_hcup_group_description27,
hcup_descriptions.other_procedure_hcup_group_description28,
hcup_descriptions.other_procedure_hcup_group_description29,
hcup_descriptions.other_procedure_hcup_group_description30
FROM procedures
LEFT JOIN descriptions ON descriptions.claim_id = procedures.claim_id
LEFT JOIN hcup_groups ON hcup_groups.claim_id = procedures.claim_id
LEFT JOIN hcup_descriptions ON hcup_descriptions.claim_id = procedures.claim_id;
ColumnData TypeIndexed
claim_idbigintNo
principal_proceduretextNo
principal_procedure_descriptiontextNo
principal_procedure_hcup_grouptextNo
principal_procedure_hcup_group_descriptiontextNo
other_procedure1textNo
other_procedure2textNo
other_procedure3textNo
other_procedure4textNo
other_procedure5textNo
other_procedure6textNo
other_procedure7textNo
other_procedure8textNo
other_procedure9textNo
other_procedure10textNo
other_procedure11textNo
other_procedure12textNo
other_procedure13textNo
other_procedure14textNo
other_procedure15textNo
other_procedure16textNo
other_procedure17textNo
other_procedure18textNo
other_procedure19textNo
other_procedure20textNo
other_procedure21textNo
other_procedure22textNo
other_procedure23textNo
other_procedure24textNo
other_procedure25textNo
other_procedure26textNo
other_procedure27textNo
other_procedure28textNo
other_procedure29textNo
other_procedure30textNo
other_procedure_description1textNo
other_procedure_description2textNo
other_procedure_description3textNo
other_procedure_description4textNo
other_procedure_description5textNo
other_procedure_description6textNo
other_procedure_description7textNo
other_procedure_description8textNo
other_procedure_description9textNo
other_procedure_description10textNo
other_procedure_description11textNo
other_procedure_description12textNo
other_procedure_description13textNo
other_procedure_description14textNo
other_procedure_description15textNo
other_procedure_description16textNo
other_procedure_description17textNo
other_procedure_description18textNo
other_procedure_description19textNo
other_procedure_description20textNo
other_procedure_description21textNo
other_procedure_description22textNo
other_procedure_description23textNo
other_procedure_description24textNo
other_procedure_description25textNo
other_procedure_description26textNo
other_procedure_description27textNo
other_procedure_description28textNo
other_procedure_description29textNo
other_procedure_description30textNo
other_procedure_hcup_group1textNo
other_procedure_hcup_group2textNo
other_procedure_hcup_group3textNo
other_procedure_hcup_group4textNo
other_procedure_hcup_group5textNo
other_procedure_hcup_group6textNo
other_procedure_hcup_group7textNo
other_procedure_hcup_group8textNo
other_procedure_hcup_group9textNo
other_procedure_hcup_group10textNo
other_procedure_hcup_group11textNo
other_procedure_hcup_group12textNo
other_procedure_hcup_group13textNo
other_procedure_hcup_group14textNo
other_procedure_hcup_group15textNo
other_procedure_hcup_group16textNo
other_procedure_hcup_group17textNo
other_procedure_hcup_group18textNo
other_procedure_hcup_group19textNo
other_procedure_hcup_group20textNo
other_procedure_hcup_group21textNo
other_procedure_hcup_group22textNo
other_procedure_hcup_group23textNo
other_procedure_hcup_group24textNo
other_procedure_hcup_group25textNo
other_procedure_hcup_group26textNo
other_procedure_hcup_group27textNo
other_procedure_hcup_group28textNo
other_procedure_hcup_group29textNo
other_procedure_hcup_group30textNo
other_procedure_hcup_group_description1textNo
other_procedure_hcup_group_description2textNo
other_procedure_hcup_group_description3textNo
other_procedure_hcup_group_description4textNo
other_procedure_hcup_group_description5textNo
other_procedure_hcup_group_description6textNo
other_procedure_hcup_group_description7textNo
other_procedure_hcup_group_description8textNo
other_procedure_hcup_group_description9textNo
other_procedure_hcup_group_description10textNo
other_procedure_hcup_group_description11textNo
other_procedure_hcup_group_description12textNo
other_procedure_hcup_group_description13textNo
other_procedure_hcup_group_description14textNo
other_procedure_hcup_group_description15textNo
other_procedure_hcup_group_description16textNo
other_procedure_hcup_group_description17textNo
other_procedure_hcup_group_description18textNo
other_procedure_hcup_group_description19textNo
other_procedure_hcup_group_description20textNo
other_procedure_hcup_group_description21textNo
other_procedure_hcup_group_description22textNo
other_procedure_hcup_group_description23textNo
other_procedure_hcup_group_description24textNo
other_procedure_hcup_group_description25textNo
other_procedure_hcup_group_description26textNo
other_procedure_hcup_group_description27textNo
other_procedure_hcup_group_description28textNo
other_procedure_hcup_group_description29textNo
other_procedure_hcup_group_description30textNo