Skip to main content

claim_occurrence_wide_view

Materialized: false

Definition
 WITH occurrences AS (
SELECT ct.claim_id,
ct.occurrence_code1,
ct.occurrence_code2,
ct.occurrence_code3,
ct.occurrence_code4,
ct.occurrence_code5,
ct.occurrence_code6,
ct.occurrence_code7,
ct.occurrence_code8,
ct.occurrence_code9,
ct.occurrence_code10,
ct.occurrence_code11,
ct.occurrence_code12,
ct.occurrence_code13,
ct.occurrence_code14,
ct.occurrence_code15,
ct.occurrence_code16,
ct.occurrence_code17,
ct.occurrence_code18,
ct.occurrence_code19,
ct.occurrence_code20,
ct.occurrence_code21,
ct.occurrence_code22,
ct.occurrence_code23,
ct.occurrence_code24,
ct.occurrence_code25,
ct.occurrence_code26,
ct.occurrence_code27,
ct.occurrence_code28,
ct.occurrence_code29,
ct.occurrence_code30
FROM public.crosstab('SELECT claim_id, claim_occurrence_index, occurrence_code
FROM claims.claim_occurrence
ORDER BY claim_id, claim_occurrence_index, occurrence_code'::text) ct(claim_id bigint, occurrence_code1 text, occurrence_code2 text, occurrence_code3 text, occurrence_code4 text, occurrence_code5 text, occurrence_code6 text, occurrence_code7 text, occurrence_code8 text, occurrence_code9 text, occurrence_code10 text, occurrence_code11 text, occurrence_code12 text, occurrence_code13 text, occurrence_code14 text, occurrence_code15 text, occurrence_code16 text, occurrence_code17 text, occurrence_code18 text, occurrence_code19 text, occurrence_code20 text, occurrence_code21 text, occurrence_code22 text, occurrence_code23 text, occurrence_code24 text, occurrence_code25 text, occurrence_code26 text, occurrence_code27 text, occurrence_code28 text, occurrence_code29 text, occurrence_code30 text)
), dates AS (
SELECT ct.claim_id,
ct.occurrence_date1,
ct.occurrence_date2,
ct.occurrence_date3,
ct.occurrence_date4,
ct.occurrence_date5,
ct.occurrence_date6,
ct.occurrence_date7,
ct.occurrence_date8,
ct.occurrence_date9,
ct.occurrence_date10,
ct.occurrence_date11,
ct.occurrence_date12,
ct.occurrence_date13,
ct.occurrence_date14,
ct.occurrence_date15,
ct.occurrence_date16,
ct.occurrence_date17,
ct.occurrence_date18,
ct.occurrence_date19,
ct.occurrence_date20,
ct.occurrence_date21,
ct.occurrence_date22,
ct.occurrence_date23,
ct.occurrence_date24,
ct.occurrence_date25,
ct.occurrence_date26,
ct.occurrence_date27,
ct.occurrence_date28,
ct.occurrence_date29,
ct.occurrence_date30
FROM public.crosstab('SELECT claim_id, claim_occurrence_index, date
FROM claims.claim_occurrence
ORDER BY claim_id, claim_occurrence_index, date'::text) ct(claim_id bigint, occurrence_date1 date, occurrence_date2 date, occurrence_date3 date, occurrence_date4 date, occurrence_date5 date, occurrence_date6 date, occurrence_date7 date, occurrence_date8 date, occurrence_date9 date, occurrence_date10 date, occurrence_date11 date, occurrence_date12 date, occurrence_date13 date, occurrence_date14 date, occurrence_date15 date, occurrence_date16 date, occurrence_date17 date, occurrence_date18 date, occurrence_date19 date, occurrence_date20 date, occurrence_date21 date, occurrence_date22 date, occurrence_date23 date, occurrence_date24 date, occurrence_date25 date, occurrence_date26 date, occurrence_date27 date, occurrence_date28 date, occurrence_date29 date, occurrence_date30 date)
), descriptions AS (
SELECT ct.claim_id,
ct.occurrence_description1,
ct.occurrence_description2,
ct.occurrence_description3,
ct.occurrence_description4,
ct.occurrence_description5,
ct.occurrence_description6,
ct.occurrence_description7,
ct.occurrence_description8,
ct.occurrence_description9,
ct.occurrence_description10,
ct.occurrence_description11,
ct.occurrence_description12,
ct.occurrence_description13,
ct.occurrence_description14,
ct.occurrence_description15,
ct.occurrence_description16,
ct.occurrence_description17,
ct.occurrence_description18,
ct.occurrence_description19,
ct.occurrence_description20,
ct.occurrence_description21,
ct.occurrence_description22,
ct.occurrence_description23,
ct.occurrence_description24,
ct.occurrence_description25,
ct.occurrence_description26,
ct.occurrence_description27,
ct.occurrence_description28,
ct.occurrence_description29,
ct.occurrence_description30
FROM public.crosstab('SELECT claim_id, claim_occurrence_index, title
FROM claims.claim_occurrence o
LEFT OUTER JOIN claims.nubc_occurrence_lookup n ON n.occurrence_code = o.occurrence_code
ORDER BY claim_id, claim_occurrence_index, title'::text) ct(claim_id bigint, occurrence_description1 text, occurrence_description2 text, occurrence_description3 text, occurrence_description4 text, occurrence_description5 text, occurrence_description6 text, occurrence_description7 text, occurrence_description8 text, occurrence_description9 text, occurrence_description10 text, occurrence_description11 text, occurrence_description12 text, occurrence_description13 text, occurrence_description14 text, occurrence_description15 text, occurrence_description16 text, occurrence_description17 text, occurrence_description18 text, occurrence_description19 text, occurrence_description20 text, occurrence_description21 text, occurrence_description22 text, occurrence_description23 text, occurrence_description24 text, occurrence_description25 text, occurrence_description26 text, occurrence_description27 text, occurrence_description28 text, occurrence_description29 text, occurrence_description30 text)
)
SELECT occurrences.claim_id,
occurrences.occurrence_code1,
occurrences.occurrence_code2,
occurrences.occurrence_code3,
occurrences.occurrence_code4,
occurrences.occurrence_code5,
occurrences.occurrence_code6,
occurrences.occurrence_code7,
occurrences.occurrence_code8,
occurrences.occurrence_code9,
occurrences.occurrence_code10,
occurrences.occurrence_code11,
occurrences.occurrence_code12,
occurrences.occurrence_code13,
occurrences.occurrence_code14,
occurrences.occurrence_code15,
occurrences.occurrence_code16,
occurrences.occurrence_code17,
occurrences.occurrence_code18,
occurrences.occurrence_code19,
occurrences.occurrence_code20,
occurrences.occurrence_code21,
occurrences.occurrence_code22,
occurrences.occurrence_code23,
occurrences.occurrence_code24,
occurrences.occurrence_code25,
occurrences.occurrence_code26,
occurrences.occurrence_code27,
occurrences.occurrence_code28,
occurrences.occurrence_code29,
occurrences.occurrence_code30,
dates.occurrence_date1,
dates.occurrence_date2,
dates.occurrence_date3,
dates.occurrence_date4,
dates.occurrence_date5,
dates.occurrence_date6,
dates.occurrence_date7,
dates.occurrence_date8,
dates.occurrence_date9,
dates.occurrence_date10,
dates.occurrence_date11,
dates.occurrence_date12,
dates.occurrence_date13,
dates.occurrence_date14,
dates.occurrence_date15,
dates.occurrence_date16,
dates.occurrence_date17,
dates.occurrence_date18,
dates.occurrence_date19,
dates.occurrence_date20,
dates.occurrence_date21,
dates.occurrence_date22,
dates.occurrence_date23,
dates.occurrence_date24,
dates.occurrence_date25,
dates.occurrence_date26,
dates.occurrence_date27,
dates.occurrence_date28,
dates.occurrence_date29,
dates.occurrence_date30,
descriptions.occurrence_description1,
descriptions.occurrence_description2,
descriptions.occurrence_description3,
descriptions.occurrence_description4,
descriptions.occurrence_description5,
descriptions.occurrence_description6,
descriptions.occurrence_description7,
descriptions.occurrence_description8,
descriptions.occurrence_description9,
descriptions.occurrence_description10,
descriptions.occurrence_description11,
descriptions.occurrence_description12,
descriptions.occurrence_description13,
descriptions.occurrence_description14,
descriptions.occurrence_description15,
descriptions.occurrence_description16,
descriptions.occurrence_description17,
descriptions.occurrence_description18,
descriptions.occurrence_description19,
descriptions.occurrence_description20,
descriptions.occurrence_description21,
descriptions.occurrence_description22,
descriptions.occurrence_description23,
descriptions.occurrence_description24,
descriptions.occurrence_description25,
descriptions.occurrence_description26,
descriptions.occurrence_description27,
descriptions.occurrence_description28,
descriptions.occurrence_description29,
descriptions.occurrence_description30
FROM occurrences
LEFT JOIN dates ON dates.claim_id = occurrences.claim_id
LEFT JOIN descriptions ON descriptions.claim_id = occurrences.claim_id;
ColumnData TypeIndexed
claim_idbigintNo
occurrence_code1textNo
occurrence_code2textNo
occurrence_code3textNo
occurrence_code4textNo
occurrence_code5textNo
occurrence_code6textNo
occurrence_code7textNo
occurrence_code8textNo
occurrence_code9textNo
occurrence_code10textNo
occurrence_code11textNo
occurrence_code12textNo
occurrence_code13textNo
occurrence_code14textNo
occurrence_code15textNo
occurrence_code16textNo
occurrence_code17textNo
occurrence_code18textNo
occurrence_code19textNo
occurrence_code20textNo
occurrence_code21textNo
occurrence_code22textNo
occurrence_code23textNo
occurrence_code24textNo
occurrence_code25textNo
occurrence_code26textNo
occurrence_code27textNo
occurrence_code28textNo
occurrence_code29textNo
occurrence_code30textNo
occurrence_date1dateNo
occurrence_date2dateNo
occurrence_date3dateNo
occurrence_date4dateNo
occurrence_date5dateNo
occurrence_date6dateNo
occurrence_date7dateNo
occurrence_date8dateNo
occurrence_date9dateNo
occurrence_date10dateNo
occurrence_date11dateNo
occurrence_date12dateNo
occurrence_date13dateNo
occurrence_date14dateNo
occurrence_date15dateNo
occurrence_date16dateNo
occurrence_date17dateNo
occurrence_date18dateNo
occurrence_date19dateNo
occurrence_date20dateNo
occurrence_date21dateNo
occurrence_date22dateNo
occurrence_date23dateNo
occurrence_date24dateNo
occurrence_date25dateNo
occurrence_date26dateNo
occurrence_date27dateNo
occurrence_date28dateNo
occurrence_date29dateNo
occurrence_date30dateNo
occurrence_description1textNo
occurrence_description2textNo
occurrence_description3textNo
occurrence_description4textNo
occurrence_description5textNo
occurrence_description6textNo
occurrence_description7textNo
occurrence_description8textNo
occurrence_description9textNo
occurrence_description10textNo
occurrence_description11textNo
occurrence_description12textNo
occurrence_description13textNo
occurrence_description14textNo
occurrence_description15textNo
occurrence_description16textNo
occurrence_description17textNo
occurrence_description18textNo
occurrence_description19textNo
occurrence_description20textNo
occurrence_description21textNo
occurrence_description22textNo
occurrence_description23textNo
occurrence_description24textNo
occurrence_description25textNo
occurrence_description26textNo
occurrence_description27textNo
occurrence_description28textNo
occurrence_description29textNo
occurrence_description30textNo