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;
| Column | Data Type | Indexed |
|---|---|---|
claim_id | bigint | No |
principal_procedure | text | No |
principal_procedure_description | text | No |
principal_procedure_hcup_group | text | No |
principal_procedure_hcup_group_description | text | No |
other_procedure1 | text | No |
other_procedure2 | text | No |
other_procedure3 | text | No |
other_procedure4 | text | No |
other_procedure5 | text | No |
other_procedure6 | text | No |
other_procedure7 | text | No |
other_procedure8 | text | No |
other_procedure9 | text | No |
other_procedure10 | text | No |
other_procedure11 | text | No |
other_procedure12 | text | No |
other_procedure13 | text | No |
other_procedure14 | text | No |
other_procedure15 | text | No |
other_procedure16 | text | No |
other_procedure17 | text | No |
other_procedure18 | text | No |
other_procedure19 | text | No |
other_procedure20 | text | No |
other_procedure21 | text | No |
other_procedure22 | text | No |
other_procedure23 | text | No |
other_procedure24 | text | No |
other_procedure25 | text | No |
other_procedure26 | text | No |
other_procedure27 | text | No |
other_procedure28 | text | No |
other_procedure29 | text | No |
other_procedure30 | text | No |
other_procedure_description1 | text | No |
other_procedure_description2 | text | No |
other_procedure_description3 | text | No |
other_procedure_description4 | text | No |
other_procedure_description5 | text | No |
other_procedure_description6 | text | No |
other_procedure_description7 | text | No |
other_procedure_description8 | text | No |
other_procedure_description9 | text | No |
other_procedure_description10 | text | No |
other_procedure_description11 | text | No |
other_procedure_description12 | text | No |
other_procedure_description13 | text | No |
other_procedure_description14 | text | No |
other_procedure_description15 | text | No |
other_procedure_description16 | text | No |
other_procedure_description17 | text | No |
other_procedure_description18 | text | No |
other_procedure_description19 | text | No |
other_procedure_description20 | text | No |
other_procedure_description21 | text | No |
other_procedure_description22 | text | No |
other_procedure_description23 | text | No |
other_procedure_description24 | text | No |
other_procedure_description25 | text | No |
other_procedure_description26 | text | No |
other_procedure_description27 | text | No |
other_procedure_description28 | text | No |
other_procedure_description29 | text | No |
other_procedure_description30 | text | No |
other_procedure_hcup_group1 | text | No |
other_procedure_hcup_group2 | text | No |
other_procedure_hcup_group3 | text | No |
other_procedure_hcup_group4 | text | No |
other_procedure_hcup_group5 | text | No |
other_procedure_hcup_group6 | text | No |
other_procedure_hcup_group7 | text | No |
other_procedure_hcup_group8 | text | No |
other_procedure_hcup_group9 | text | No |
other_procedure_hcup_group10 | text | No |
other_procedure_hcup_group11 | text | No |
other_procedure_hcup_group12 | text | No |
other_procedure_hcup_group13 | text | No |
other_procedure_hcup_group14 | text | No |
other_procedure_hcup_group15 | text | No |
other_procedure_hcup_group16 | text | No |
other_procedure_hcup_group17 | text | No |
other_procedure_hcup_group18 | text | No |
other_procedure_hcup_group19 | text | No |
other_procedure_hcup_group20 | text | No |
other_procedure_hcup_group21 | text | No |
other_procedure_hcup_group22 | text | No |
other_procedure_hcup_group23 | text | No |
other_procedure_hcup_group24 | text | No |
other_procedure_hcup_group25 | text | No |
other_procedure_hcup_group26 | text | No |
other_procedure_hcup_group27 | text | No |
other_procedure_hcup_group28 | text | No |
other_procedure_hcup_group29 | text | No |
other_procedure_hcup_group30 | text | No |
other_procedure_hcup_group_description1 | text | No |
other_procedure_hcup_group_description2 | text | No |
other_procedure_hcup_group_description3 | text | No |
other_procedure_hcup_group_description4 | text | No |
other_procedure_hcup_group_description5 | text | No |
other_procedure_hcup_group_description6 | text | No |
other_procedure_hcup_group_description7 | text | No |
other_procedure_hcup_group_description8 | text | No |
other_procedure_hcup_group_description9 | text | No |
other_procedure_hcup_group_description10 | text | No |
other_procedure_hcup_group_description11 | text | No |
other_procedure_hcup_group_description12 | text | No |
other_procedure_hcup_group_description13 | text | No |
other_procedure_hcup_group_description14 | text | No |
other_procedure_hcup_group_description15 | text | No |
other_procedure_hcup_group_description16 | text | No |
other_procedure_hcup_group_description17 | text | No |
other_procedure_hcup_group_description18 | text | No |
other_procedure_hcup_group_description19 | text | No |
other_procedure_hcup_group_description20 | text | No |
other_procedure_hcup_group_description21 | text | No |
other_procedure_hcup_group_description22 | text | No |
other_procedure_hcup_group_description23 | text | No |
other_procedure_hcup_group_description24 | text | No |
other_procedure_hcup_group_description25 | text | No |
other_procedure_hcup_group_description26 | text | No |
other_procedure_hcup_group_description27 | text | No |
other_procedure_hcup_group_description28 | text | No |
other_procedure_hcup_group_description29 | text | No |
other_procedure_hcup_group_description30 | text | No |